name
stringlengths 12
178
| code_snippet
stringlengths 8
36.5k
| score
float64 3.26
3.68
|
---|---|---|
AreaShop_FileManager_saveIsRequiredForRegionWorld_rdh
|
/**
* Indicates that a/multiple WorldGuard regions need to be saved.
*
* @param worldName
* The world where the regions that should be saved is in
*/
public void saveIsRequiredForRegionWorld(String worldName) {
worldRegionsRequireSaving.add(worldName);
}
| 3.26 |
AreaShop_FileManager_getRegionFolder_rdh
|
/**
* Get the folder the region files are located in.
*
* @return The folder where the region.yml files are in
*/
public String getRegionFolder() {
return regionsPath;
}
| 3.26 |
AreaShop_FileManager_isBlacklisted_rdh
|
/**
* Check if a region is on the adding blacklist.
*
* @param region
* The region name to check
* @return true if the region may not be added, otherwise false
*/
public boolean isBlacklisted(String region) {
for (String line : plugin.getConfig().getStringList("blacklist")) { Pattern pattern = Pattern.compile(line, Pattern.CASE_INSENSITIVE);
Matcher v39 = pattern.matcher(region);
if (v39.matches()) {
return true;
}
}
return false;
}
| 3.26 |
AreaShop_FileManager_getBuy_rdh
|
/**
* Get a buy region.
*
* @param name
* The name of the buy region (will be normalized)
* @return BuyRegion if it could be found, otherwise null
*/public BuyRegion getBuy(String name) {
GeneralRegion region = regions.get(name.toLowerCase());if (region instanceof BuyRegion) {
return ((BuyRegion) (region));
}
return null;
}
| 3.26 |
AreaShop_FileManager_removeGroup_rdh
|
/**
* Remove a group.
*
* @param group
* Group to remove
*/
public void removeGroup(RegionGroup group) {
groups.remove(group.getLowerCaseName());
groupsConfig.set(group.getLowerCaseName(), null);
saveGroupsIsRequired();
}
| 3.26 |
AreaShop_FileManager_checkRegionAdd_rdh
|
/**
* Check if a player can add a certain region as rent or buy region.
*
* @param sender
* The player/console that wants to add a region
* @param region
* The WorldGuard region to add
* @param world
* The world the ProtectedRegion is located in
* @param type
* The type the region should have in AreaShop
* @return The result if a player would want to add this region
*/
public AddResult checkRegionAdd(CommandSender sender, ProtectedRegion region, World world, RegionType type) {
Player player = null;
if (sender instanceof Player) {
player = ((Player) (sender));
}
// Determine if the player is an owner or member of the region
boolean isMember = (player != null) && plugin.getWorldGuardHandler().containsMember(region, player.getUniqueId());
boolean isOwner = (player != null) && plugin.getWorldGuardHandler().containsOwner(region, player.getUniqueId());
AreaShop.debug((("checkRegionAdd: isOwner=" + isOwner) + ", isMember=") + isMember);
String typeString;
if (type == RegionType.RENT) {
typeString = "rent";
} else {
typeString = "buy";
}
AreaShop.debug(((((" permissions: .create=" + sender.hasPermission("areashop.create" + typeString)) + ", .create.owner=") + sender.hasPermission(("areashop.create" + typeString) + ".owner")) + ", .create.member=") + sender.hasPermission(("areashop.create" + typeString) + ".member"));
if (!((sender.hasPermission("areashop.create" + typeString) || (sender.hasPermission(("areashop.create" + typeString) + ".owner") && isOwner)) || (sender.hasPermission(("areashop.create" + typeString) + ".member") && isMember))) {
return AddResult.NOPERMISSION;
}
GeneralRegion asRegion = plugin.getFileManager().getRegion(region.getId());
if (asRegion != null) {
if (asRegion.getWorld().equals(world)) {return AddResult.ALREADYADDED;
} else {
return AddResult.f0;
}
} else if (plugin.getFileManager().isBlacklisted(region.getId())) {
return AddResult.BLACKLISTED;
} else {
return AddResult.SUCCESS;
}
}
| 3.26 |
AreaShop_FileManager_loadVersions_rdh
|
/**
* Load the file with the versions, used to check if the other files need conversion.
*/
@SuppressWarnings("unchecked")
public void loadVersions() {
File file = new File(versionPath);
if (file.exists()) {
// Load versions from the file
try (ObjectInputStream input = new ObjectInputStream(new FileInputStream(versionPath))) {
versions = ((HashMap<String, Integer>) (input.readObject()));} catch (IOException | ClassNotFoundException | ClassCastException e) {
AreaShop.warn("Something went wrong reading file: " + versionPath);
versions = null;
}
}
if ((versions == null) || versions.isEmpty()) {
versions = new HashMap<>();
versions.put(AreaShop.versionFiles, 0);
this.saveVersions();
}
}
| 3.26 |
AreaShop_FileManager_addRegionNoSave_rdh
|
/**
* Add a region to the list without saving it to disk (useful for loading at startup).
*
* @param region
* The region to add
* @return true when successful, otherwise false (denied by an event listener)
*/
public AddingRegionEvent addRegionNoSave(GeneralRegion region) {
AddingRegionEvent event = new AddingRegionEvent(region);
if (region == null) {
AreaShop.debug("Tried adding a null region!");
event.cancel("null region");
return event;}
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
return event;
}
regions.put(region.getName().toLowerCase(), region);
Bukkit.getPluginManager().callEvent(new AddedRegionEvent(region));
return event;
}
| 3.26 |
AreaShop_FileManager_loadFiles_rdh
|
/**
* Load all files from disk.
*
* @param thisTick
* Load files in the current tick or a tick later
* @return true if the files are loaded correctly, otherwise false
*/
public boolean loadFiles(boolean thisTick) {
// Load config.yml + add defaults from .jar
boolean result = loadConfigFile();
// Load default.yml + add defaults from .jar
result &= loadDefaultFile();
// Convert old formats to the latest (object saving to .yml saving)
preUpdateFiles();
if (thisTick)
{
// Load region files (regions folder)
loadRegionFiles();
// Convert old formats to the latest (changes in .yml saving format)
postUpdateFiles();
// Load groups.yml
result
&= m1();
} else {
Do.sync(() -> {
// Load region files (regions folder)
loadRegionFiles();
// Convert old formats to the latest (changes in .yml saving format)
postUpdateFiles();
// Load groups.yml
loadGroupsFile();
});
}
return result;
}
| 3.26 |
AreaShop_FileManager_postUpdateFiles_rdh
|
/**
* Checks for old file formats and converts them to the latest format.
* This is to be triggered after the load of the region files.
*/
private void postUpdateFiles() {
Integer fileStatus = versions.get(AreaShop.versionFiles);
// If the the files are already the current version
if ((fileStatus != null) && (fileStatus
== AreaShop.versionFilesCurrent)) {
return;
}
// Add 'general.lastActive' to rented/bought regions (initialize at current time)
if ((fileStatus == null) || (fileStatus < 3)) {
for (GeneralRegion region : getRegions()) {
region.updateLastActiveTime();
}
// Update versions file to 3
versions.put(AreaShop.versionFiles, 3);
saveVersions();
if (!getRegions().isEmpty()) {
AreaShop.info(" Added last active time to regions (v2 to v3)");
}
}
}
| 3.26 |
AreaShop_FileManager_getConfig_rdh
|
/**
* Get the config file (config.yml).
*
* @return YamlConfiguration with the settings of users, with fallback to the settings provided by AreaShop
*/
public YamlConfiguration getConfig() {
return config;
}
| 3.26 |
AreaShop_FileManager_getRegionNames_rdh
|
/**
* Get a list of names of all regions.
*
* @return A String list with all the names
*/
public List<String> getRegionNames() {
ArrayList<String> result = new ArrayList<>();
for (GeneralRegion region : getRegions()) {
result.add(region.getName());
}return result;
}
| 3.26 |
AreaShop_FileManager_updateAllRegions_rdh
|
/**
* Update all regions, happens in a task to minimize lag.
*/
public void updateAllRegions() {
updateRegions(getRegions(), null); }
| 3.26 |
AreaShop_FileManager_getFallbackRegionSettings_rdh
|
/**
* Get the default regions settings as provided by AreaShop (default.yml).
*
* @return YamlConfiguration with the default settings
*/
public YamlConfiguration getFallbackRegionSettings() {
return defaultConfigFallback;
}
| 3.26 |
AreaShop_FileManager_setGroupSetting_rdh
|
/**
* Set a setting for a group.
*
* @param group
* The group to set it for
* @param path
* The path to set
* @param setting
* The value to set
*/
public void setGroupSetting(RegionGroup group, String path, Object setting) {
groupsConfig.set((group.getName().toLowerCase() + ".") + path, setting);
}
| 3.26 |
AreaShop_FileManager_sendRentExpireWarnings_rdh
|
/**
* Send out rent expire warnings.
*/
public void sendRentExpireWarnings() {
Do.forAll(plugin.getConfig().getInt("expireWarning.regionsPerTick"), getRents(), RentRegion::sendExpirationWarnings);
}
| 3.26 |
AreaShop_FileManager_getBuyNames_rdh
|
/**
* Get a list of names of all buy regions.
*
* @return A String list with all the names
*/
public List<String> getBuyNames() {
ArrayList<String> result = new ArrayList<>();
for (BuyRegion region : getBuys()) {
result.add(region.getName());
}
return result;
}
| 3.26 |
AreaShop_FileManager_markGroupsAutoDirty_rdh
|
/**
* Mark all RegionGroups that they should regenerate regions.
*/
public void markGroupsAutoDirty() {
for (RegionGroup group : getGroups()) {
group.autoDirty();
}
}
| 3.26 |
AreaShop_FileManager_isSaveGroupsRequired_rdh
|
/**
* Check if saving the groups file is required.
*
* @return true if changes are made and saving is required, otherwise false
*/
public boolean isSaveGroupsRequired() {
return saveGroupsRequired;
}
| 3.26 |
AreaShop_FileManager_loadConfigFile_rdh
|
/**
* Load the default.yml file
*
* @return true if it has been loaded successfully, otherwise false
*/
public boolean loadConfigFile() {
boolean result = true;
File configFile = new File(configPath);
// Safe the file from the jar to disk if it does not exist
if (!configFile.exists()) {
try (InputStream input = plugin.getResource(AreaShop.configFile);OutputStream output = new FileOutputStream(configFile)) {
int read;
byte[] bytes = new byte[1024];
while ((read = input.read(bytes)) != (-1)) {
output.write(bytes, 0, read);
}
AreaShop.info("Default config file has been saved, should only happen on first startup");
} catch (IOException e) {
AreaShop.warn("Something went wrong saving the config file: " + configFile.getAbsolutePath());
}
}
// Load config.yml from the plugin folder
try (InputStreamReader custom = new InputStreamReader(new FileInputStream(configFile), Charsets.UTF_8);InputStreamReader
normal = new InputStreamReader(plugin.getResource(AreaShop.configFile), Charsets.UTF_8);InputStreamReader hidden = new InputStreamReader(plugin.getResource(AreaShop.configFileHidden), Charsets.UTF_8)) {
config = YamlConfiguration.loadConfiguration(custom);
if (config.getKeys(false).isEmpty()) {
AreaShop.warn("File 'config.yml' is empty, check for errors in the log.");
result = false;
} else {
config.addDefaults(YamlConfiguration.loadConfiguration(normal));
config.addDefaults(YamlConfiguration.loadConfiguration(hidden));
// Set the debug and chatprefix variables
plugin.setDebug(this.getConfig().getBoolean("debug"));
if (getConfig().isList("chatPrefix")) {plugin.setChatprefix(getConfig().getStringList("chatPrefix"));
} else {
ArrayList<String> list = new ArrayList<>();
list.add(getConfig().getString("chatPrefix"));
plugin.setChatprefix(list);
}
}
} catch (IOException e) {
AreaShop.warn("Something went wrong while reading the config.yml file: " + configFile.getAbsolutePath());
result = false;
}Utils.initialize(config);
return result;
}
| 3.26 |
AreaShop_Manager_shutdown_rdh
|
/**
* Called at shutdown of the plugin.
*/
public void shutdown() {
// To override by extending classes
}
| 3.26 |
AreaShop_TeleportCommand_canUse_rdh
|
/**
* Check if a person can teleport to the region (assuming he is not teleporting to a sign).
*
* @param person
* The person to check
* @param region
* The region to check for
* @return true if the person can teleport to it, otherwise false
*/
public static boolean canUse(CommandSender person, GeneralRegion region) {
if (!(person instanceof Player)) {
return false;
}
Player player = ((Player) (person));
return ((player.hasPermission("areashop.teleportall") || (region.isOwner(player) && player.hasPermission("areashop.teleport"))) || (region.isAvailable() && player.hasPermission("areashop.teleportavailable"))) || (region.getFriendsFeature().getFriends().contains(player.getUniqueId()) && player.hasPermission("areashop.teleportfriend"));
}
| 3.26 |
AreaShop_GithubUpdateCheck_hasUpdate_rdh
|
/**
* Check if an update has been found.
*
* @return true if an update has been found
*/
public boolean hasUpdate() {
return hasUpdate;
}
| 3.26 |
AreaShop_GithubUpdateCheck_m0_rdh
|
/**
* Get the current version.
*
* @return Current version of the plugin
*/
public String m0() {
return currentVersion;}
| 3.26 |
AreaShop_GithubUpdateCheck_hasFailed_rdh
|
/**
* Check if the update check failed.
*
* @return true if the update check failed (an error message has been logged)
*/
public boolean hasFailed() {
return error;
}
| 3.26 |
AreaShop_GithubUpdateCheck_getRepository_rdh
|
/**
* Get the repository that this update checker is checking.
*
* @return Used repository
*/
public String getRepository() {
return repository;
}
| 3.26 |
AreaShop_GithubUpdateCheck_isChecking_rdh
|
/**
* Check if an update check is running.
*
* @return true if an update check is running
*/
public boolean isChecking() {
return checking;
}
| 3.26 |
AreaShop_GithubUpdateCheck_getLatestVersion_rdh
|
/**
* Get the latest version.
*
* @return Latest version of the plugin (if checking is complete)
*/
public String getLatestVersion() {
return latestVersion;
}
| 3.26 |
AreaShop_GithubUpdateCheck_getAuthor_rdh
|
/**
* Get the author that this update checker is checking.
*
* @return Used author
*/
public String getAuthor() {
return author;
}
| 3.26 |
AreaShop_GithubUpdateCheck_checkUpdate_rdh
|
/**
* Check if an update is available.
*
* @param callback
* Callback to execute when the update check is done
* @return GithubUpdateCheck containing the status of the check
*/
public GithubUpdateCheck checkUpdate(UpdateCallback callback) {
checking = true;
final GithubUpdateCheck self = this;
// Check for update on asyn thread
new BukkitRunnable() {
@Override
public void run() {
try {try
{
String rawUrl = (((((API_HOST + "/") + author) + "/") + repository) + "/") + API_LATEST_RELEASE;
url = new URL(rawUrl);
} catch (MalformedURLException e) {
logger.severe(((((("Invalid url: '" + url) + "', are the author '") + author) + "' and repository '") + repository) + "' correct?");
error = true;
return;
}
try {
URLConnection conn = url.openConnection();
// Give up after 15 seconds
conn.setConnectTimeout(15000);// Identify ourselves
conn.addRequestProperty("User-Agent", USER_AGENT);
// Make sure we access the correct api version
conn.addRequestProperty("Accept", "application/vnd.github.v3+json");
// We want to read the result
conn.setDoOutput(true);
// Open connection
try (BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()))) {
String response = reader.readLine();
debug("Response:", response);
JSONObject latestRelease = ((JSONObject) (JSONValue.parse(response)));
if (latestRelease.isEmpty()) {
logger.warning("Failed to get api response from " + url);
error = true;return;
}
debug("json: " + latestRelease.toJSONString());
// Latest version
latestVersion = ((String) (latestRelease.get("tag_name")));
debug("Tag name:", latestVersion);
// Current version
debug("Plugin version:", currentVersion);
// Compare version
hasUpdate = versionComparator.isNewer(latestVersion, currentVersion);
}
} catch (IOException e) {
logger.severe("Failed to get latest release:" + ExceptionUtils.getStackTrace(e));
error = true;
} catch (ClassCastException e) {
logger.info("Unexpected structure of the result, failed to parse it");
error = true;
}
} finally {
checking = false;
debug("result:", self);
if (callback != null) {
// Switch back to main thread and call the callback
new BukkitRunnable() {
@Override
public void run() {
callback.run(self);
}
}.runTask(plugin);}
}
}
}.runTaskAsynchronously(plugin);
return this;
}
| 3.26 |
AreaShop_GithubUpdateCheck_withVersionComparator_rdh
|
/**
* Change the version comparator.
*
* @param versionComparator
* VersionComparator to use for checking if one version is newer than the other
* @return this
*/
public GithubUpdateCheck withVersionComparator(VersionComparator versionComparator) {
this.versionComparator = versionComparator;
return this;
}
| 3.26 |
AreaShop_GithubUpdateCheck_debug_rdh
|
/**
* Print a debug message if DEBUG is enabled.
*
* @param message
* Message to print
*/
private void debug(Object... message) {
if
(DEBUG) {
logger.info((("[" + this.getClass().getSimpleName()) + "] [DEBUG] ") + StringUtils.join(message, " "));
}
}
| 3.26 |
AreaShop_Value_get_rdh
|
/**
* Get the stored content.
*
* @return The stored content
*/
public T
get() {
return content;
}
| 3.26 |
AreaShop_Value_set_rdh
|
/**
* Set the content.
*
* @param value
* The new content
*/public void set(T value) {
this.content = value;
}
| 3.26 |
AreaShop_CancellableRegionEvent_allow_rdh
|
/**
* Let the event continue, possible overwriting a cancel() call from another plugin.
*/
public void allow() {
this.cancelled = false;
this.reason = null;
}
| 3.26 |
AreaShop_CancellableRegionEvent_isCancelled_rdh
|
/**
* Check if the event has been cancelled.
*
* @return true if the event has been cancelled, otherwise false
*/
public boolean isCancelled() {
return f0;
}
| 3.26 |
AreaShop_CancellableRegionEvent_cancel_rdh
|
/**
* Cancel the event from happening.
*
* @param reason
* The reason of cancelling, used for display to the user, should end with a dot
*/
public void
cancel(String reason) {
this.cancelled = true;
this.reason = reason;
}
| 3.26 |
AreaShop_CancellableRegionEvent_getReason_rdh
|
/**
* Get the reason why this event is cancelled.
*
* @return null if there is no reason or the event is not cancelled, otherwise a string
*/
public String getReason() {
return reason;
}
| 3.26 |
AreaShop_RegionEvent_m0_rdh
|
// Required by Bukkit/Spigot
public static HandlerList m0() {
return handlers;
}
| 3.26 |
AreaShop_RegionEvent_getRegion_rdh
|
/**
* Get the region of this event.
*
* @return The region the event is about
*/
public T getRegion() {
return region;
}
| 3.26 |
AreaShop_ResellingRegionEvent_getBuyer_rdh
|
/**
* Get the player that is trying to buy the region.
*
* @return The player that is trying to buy the region
*/
public OfflinePlayer getBuyer() {
return player;
}
| 3.26 |
AreaShop_GeneralRegion_getMaximumPoint_rdh
|
/**
* Get the maximum corner of the region.
*
* @return Vector
*/
public Vector getMaximumPoint() {
return plugin.getWorldGuardHandler().getMaximumPoint(getRegion());
}
| 3.26 |
AreaShop_GeneralRegion_getFriendsFeature_rdh
|
/**
* Get the friends feature to query and manipulate friends of this region.
*
* @return The FriendsFeature of this region
*/
public FriendsFeature getFriendsFeature() {
return getFeature(FriendsFeature.class);
}
| 3.26 |
AreaShop_GeneralRegion_resetRegionFlags_rdh
|
/**
* Reset all flags of the region.
*/
public void resetRegionFlags() {
ProtectedRegion region = getRegion();
if (region != null) {
region.setFlag(plugin.getWorldGuardHandler().fuzzyMatchFlag("greeting"), null);
region.setFlag(plugin.getWorldGuardHandler().fuzzyMatchFlag("farewell"), null);
}
}
| 3.26 |
AreaShop_GeneralRegion_setOwner_rdh
|
/**
* Change the owner of the region.
*
* @param player
* The player that should be the owner
*/
public void setOwner(UUID player) {
if (this instanceof RentRegion) {
((RentRegion)
(this)).setRenter(player);
}
else {
((BuyRegion) (this)).setBuyer(player);
}
}
| 3.26 |
AreaShop_GeneralRegion_getLowerCaseName_rdh
|
/**
* Get the lowercase region name.
*
* @return The region name in lowercase
*/
public String getLowerCaseName() {return getName().toLowerCase();
}
| 3.26 |
AreaShop_GeneralRegion_getBooleanSetting_rdh
|
// CONFIG
/**
* Get a boolean setting for this region, defined as follows
* - If the region has the setting in its own file (/regions/regionName.yml), use that
* - If the region has groups, use the setting defined by the most important group, if any
* - Otherwise fallback to the default.yml file setting
*
* @param path
* The path to get the setting of
* @return The value of the setting (strings are handled as booleans)
*/
public boolean
getBooleanSetting(String path) {
if (config.isSet(path)) {
if (config.isString(path)) {
return config.getString(path).equalsIgnoreCase("true");
}
return config.getBoolean(path);
}
boolean result = false;
int priority = Integer.MIN_VALUE;
boolean v25 = false;
for (RegionGroup group : plugin.getFileManager().getGroups()) {
if ((group.isMember(this) && group.getSettings().isSet(path)) &&
(group.getPriority() > priority)) {
if (group.getSettings().isString(path)) {result = group.getSettings().getString(path).equalsIgnoreCase("true");
} else {
result = group.getSettings().getBoolean(path);
}
priority = group.getPriority();
v25 = true;
}}
if (v25) {
return result;
}
if (this.getFileManager().getRegionSettings().isString(path)) {
return this.getFileManager().getRegionSettings().getString(path).equalsIgnoreCase("true");
}
if (this.getFileManager().getRegionSettings().isSet(path)) {return this.getFileManager().getRegionSettings().getBoolean(path);
} else {
return this.getFileManager().getFallbackRegionSettings().getBoolean(path);
}
}
| 3.26 |
AreaShop_GeneralRegion_matchesLimitGroup_rdh
|
/**
* Check if this region matches the filters of a limit group.
*
* @param group
* The group to check
* @return true if the region applies to the limit group, otherwise false
*/
public boolean matchesLimitGroup(String group) {
List<String> worlds = plugin.getConfig().getStringList(("limitGroups." + group) + ".worlds");
List<String> groups = plugin.getConfig().getStringList(("limitGroups." + group) + ".groups");
if (((worlds == null) || worlds.isEmpty()) || worlds.contains(getWorldName())) {
if ((groups == null) || groups.isEmpty()) {return true;
} else {
boolean inGroups = false;
for (RegionGroup checkGroup : plugin.getFileManager().getGroups()) {
inGroups = inGroups || (groups.contains(checkGroup.getName()) && checkGroup.isMember(this));
}
return inGroups;
}
}
return
false;
}
| 3.26 |
AreaShop_GeneralRegion_getConfig_rdh
|
/**
* Get the config file that is used to store the region information.
*
* @return The config file that stores the region information
*/
public YamlConfiguration getConfig() {
return config;
}
| 3.26 |
AreaShop_GeneralRegion_restoreRegionBlocks_rdh
|
/**
* Restore all blocks in a region for restoring later.
*
* @param fileName
* The name of the file to save to (extension and folder will be added)
* @return true if the region has been restored properly, otherwise false
*/
public boolean restoreRegionBlocks(String fileName) {
if (getRegion() == null) {
AreaShop.debug(("Region '" + getName()) + "' does not exist in WorldGuard, restore failed");
return false;
}
// The path to save the schematic
File restoreFile = new File((plugin.getFileManager().getSchematicFolder() + File.separator) + fileName);
boolean result = plugin.getWorldEditHandler().restoreRegionBlocks(restoreFile, this);
if (result) {
AreaShop.debug("Restored schematic for region " + getName());
// Workaround for signs inside the region in combination with async restore of plugins like AsyncWorldEdit and FastAsyncWorldEdit
Do.syncLater(10, getSignsFeature()::update);
}
return
result;
}
| 3.26 |
AreaShop_GeneralRegion_actionAllowed_rdh
|
/**
* Check if the action is allowed.
*
* @return true if the actions is allowed, otherwise false
*/
public boolean actionAllowed() {
return actionAllowed;
}
| 3.26 |
AreaShop_GeneralRegion_getStringSetting_rdh
|
/**
* Get a string setting for this region, defined as follows
* - If the region has the setting in its own file (/regions/regionName.yml), use that
* - If the region has groups, use the setting defined by the most important group, if any
* - Otherwise fallback to the default.yml file setting
*
* @param path
* The path to get the setting of
* @return The value of the setting
*/
public String getStringSetting(String path) {
if (config.isSet(path)) {
return config.getString(path);
}
String result = null;
int priority = Integer.MIN_VALUE;
boolean found = false;
for (RegionGroup group : plugin.getFileManager().getGroups()) {
if ((group.isMember(this) && group.getSettings().isSet(path)) && (group.getPriority() > priority)) {
result = group.getSettings().getString(path);
priority = group.getPriority();
found = true;}
}
if (found) {
return result;
}
if (this.getFileManager().getRegionSettings().isSet(path)) {
return this.getFileManager().getRegionSettings().getString(path);
} else {
return this.getFileManager().getFallbackRegionSettings().getString(path);
}
}
| 3.26 |
AreaShop_GeneralRegion_saveRegionBlocks_rdh
|
/**
* Save all blocks in a region for restoring later.
*
* @param fileName
* The name of the file to save to (extension and folder will be added)
* @return true if the region has been saved properly, otherwise false
*/
public boolean saveRegionBlocks(String fileName) {
// Check if the region is correct
ProtectedRegion
region = getRegion();
if (region == null) {
AreaShop.debug(("Region '" + getName()) + "' does not exist in WorldGuard, save failed");
return false;
}// The path to save the schematic
File saveFile =
new File((plugin.getFileManager().getSchematicFolder() + File.separator) + fileName);
// Create parent directories
File parent = saveFile.getParentFile();
if ((parent != null) && (!parent.exists())) {
if (!parent.mkdirs()) {
AreaShop.warn((("Did not save region " + getName()) + ", schematic directory could not be created: ") + saveFile.getAbsolutePath());
return false;
}
}
boolean result = plugin.getWorldEditHandler().saveRegionBlocks(saveFile, this);
if (result) {
AreaShop.debug("Saved schematic for region " + getName());}
return true;
}
| 3.26 |
AreaShop_GeneralRegion_getVolume_rdh
|
/**
* Get the volume of the region (number of blocks inside it).
*
* @return Number of blocks in the region
*/
public long getVolume() {
// Cache volume, important for polygon regions
if (volume < 0) {
volume = calculateVolume();
}
return volume;}
| 3.26 |
AreaShop_GeneralRegion_isRestoreEnabled_rdh
|
/**
* Check if restoring is enabled.
*
* @return true if restoring is enabled, otherwise false
*/
public boolean isRestoreEnabled() {
return getBooleanSetting("general.enableRestore");
}
| 3.26 |
AreaShop_GeneralRegion_getHeight_rdh
|
/**
* Get the height of the region (y-axis).
*
* @return The height of the region (y-axis)
*/@Override
public int getHeight() {
if (getRegion() == null) {
return 0;
}
return (getMaximumPoint().getBlockY() - getMinimumPoint().getBlockY()) + 1;
}
| 3.26 |
AreaShop_GeneralRegion_setSetting_rdh
|
/**
* Set a setting in the file of the region itself.
*
* @param path
* The path to set
* @param value
* The value to set it to, null to remove the setting
*/
public void setSetting(String path, Object value) {
config.set(path, value);
this.saveRequired();
}
| 3.26 |
AreaShop_GeneralRegion_needsPeriodicUpdate_rdh
|
/**
* Check if a sign needs periodic updating.
*
* @return true if the signs of this region need periodic updating, otherwise false
*/public boolean needsPeriodicUpdate() {
return (!(isDeleted() || (!(this instanceof RentRegion)))) && getSignsFeature().needsPeriodicUpdate();
}
| 3.26 |
AreaShop_GeneralRegion_getGroupNames_rdh
|
/**
* Get a list of names from groups this region is in.
*
* @return A list of groups this region is part of
*/public List<String> getGroupNames() {
List<String> result = new ArrayList<>();
for (RegionGroup group : getGroups()) {
result.add(group.getName());
}
return result;
}
| 3.26 |
AreaShop_GeneralRegion_isOwner_rdh
|
/**
* Check if the players is owner of this region.
*
* @param player
* Player to check ownership for
* @return true if the player currently rents or buys this region
*/
public boolean isOwner(UUID player) {
return ((this instanceof RentRegion) && ((RentRegion) (this)).isRenter(player)) || ((this instanceof BuyRegion) && ((BuyRegion) (this)).isBuyer(player));
}
| 3.26 |
AreaShop_GeneralRegion_calculateVolume_rdh
|
/**
* Calculate the volume of the region (could be expensive for polygon regions).
*
* @return Number of blocks in the region
*/
private long calculateVolume() {
// Use own calculation for polygon regions, as WorldGuard does not implement it and returns 0
ProtectedRegion region = getRegion();
if (region instanceof ProtectedPolygonalRegion) {
Vector min = getMinimumPoint();
Vector max = getMaximumPoint();
// Exact, but slow algorithm
if ((getWidth() * getDepth()) < 100) {
long surface = 0;
for (int x = min.getBlockX(); x <= max.getBlockX(); x++) {
for (int z = min.getBlockZ(); z <= max.getBlockZ(); z++) {if (region.contains(x, min.getBlockY(), z)) {
surface++;
}
}
}return surface * getHeight();} else // Estimate, but quick algorithm
{
List<Vector> points = plugin.getWorldGuardHandler().getRegionPoints(region);
int numPoints = points.size();
if (numPoints < 3) {
return 0;
}
double area = 0;
int x1;
int x2;
int z1;
int z2;
for (int i = 0; i <= (numPoints - 2); i++) {
x1 =
points.get(i).getBlockX(); z1 = points.get(i).getBlockZ();
x2 = points.get(i + 1).getBlockX();
z2 = points.get(i + 1).getBlockZ();area += (z1 + z2) * (x1 - x2);
}
x1 = points.get(numPoints - 1).getBlockX();
z1 = points.get(numPoints - 1).getBlockZ();
x2 = points.get(0).getBlockX();
z2 = points.get(0).getBlockZ();
area += (z1 + z2) * (x1 - x2);
area
= Math.ceil(Math.abs(area) / 2);
return ((long) (area * getHeight()));
}
} else {
return region.volume();}}
| 3.26 |
AreaShop_GeneralRegion_setRestoreSetting_rdh
|
/**
* Change the restore setting.
*
* @param restore
* true, false or general
*/
public void setRestoreSetting(Boolean restore) {
setSetting("general.enableRestore", restore);
}
| 3.26 |
AreaShop_GeneralRegion_setLandlord_rdh
|
/**
* Set the landlord of this region (the player that receives all revenue of this region).
*
* @param landlord
* The UUID of the player that should be set as landlord
* @param name
* The backup name of the player (for in case that the UUID cannot be resolved to a playername)
*/
public void setLandlord(UUID landlord, String name) {
if (landlord != null) {
setSetting("general.landlord", landlord.toString());
}
String properName = Utils.toName(landlord);
if (properName
== null) {
properName
= name;
}
setSetting("general.landlordName", properName);
}
| 3.26 |
AreaShop_GeneralRegion_removelandlord_rdh
|
/**
* Remove the landlord from this region.
*/
public void removelandlord() {
setSetting("general.landlord", null);
setSetting("general.landlordName", null);
}
| 3.26 |
AreaShop_GeneralRegion_getFeature_rdh
|
/**
* Get a feature of this region.
*
* @param clazz
* The class of the feature to get
* @param <T>
* The feature to get
* @return The feature (either just instantiated or cached)
*/
public <T extends RegionFeature> T getFeature(Class<T> clazz) {
RegionFeature result = features.get(clazz);
if (result == null) {
result = plugin.getFeatureManager().getRegionFeature(this, clazz);
features.put(clazz, result);
}
return clazz.cast(result);
}
| 3.26 |
AreaShop_GeneralRegion_update_rdh
|
/**
* Broadcast an event to indicate that region settings have been changed.
* This will update region flags, signs, etc.
*/
public void update() {
Bukkit.getServer().getPluginManager().callEvent(new UpdateRegionEvent(this));
}
| 3.26 |
AreaShop_GeneralRegion_setDeleted_rdh
|
/**
* Indicate that this region has been deleted.
*/
public void setDeleted() {
deleted = true;
}
| 3.26 |
AreaShop_GeneralRegion_getLongSetting_rdh
|
/**
* Get a long setting for this region, defined as follows
* - If the region has the setting in its own file (/regions/regionName.yml), use that
* - If the region has groups, use the setting defined by the most important group, if any
* - Otherwise fallback to the default.yml file setting
*
* @param path
* The path to get the setting of
* @return The value of the setting
*/
public long getLongSetting(String path) {
if (config.isSet(path)) {
return config.getLong(path);
}
long result = 0;
int priority = Integer.MIN_VALUE;
boolean found = false;
for (RegionGroup group : plugin.getFileManager().getGroups()) {
if ((group.isMember(this) && group.getSettings().isSet(path)) && (group.getPriority() > priority)) {
result =
group.getSettings().getLong(path);
priority = group.getPriority();
found = true;
}
}
if (found) {
return
result;
}
if (this.getFileManager().getRegionSettings().isSet(path)) {
return this.getFileManager().getRegionSettings().getLong(path);
} else {
return this.getFileManager().getFallbackRegionSettings().getLong(path);
}
}
| 3.26 |
AreaShop_GeneralRegion_setup_rdh
|
/**
* Shared setup of all constructors.
*/
public void setup() {
features =
new HashMap<>();
}
| 3.26 |
AreaShop_GeneralRegion_getFileManager_rdh
|
/**
* Get the FileManager from the plugin.
*
* @return The FileManager (responsible for saving/loading regions and getting them)
*/
public FileManager getFileManager() {
return plugin.getFileManager();
}
| 3.26 |
AreaShop_GeneralRegion_getName_rdh
|
/**
* Get the name of the region.
*
* @return The region name
*/
@Override
public String getName() {
return config.getString("general.name");
}
| 3.26 |
AreaShop_GeneralRegion_notifyAndUpdate_rdh
|
/**
* Broadcast the given event and update the region status.
*
* @param event
* The update event that should be broadcasted
*/
public void notifyAndUpdate(NotifyRegionEvent event) {
Bukkit.getPluginManager().callEvent(event);
update();
}
| 3.26 |
AreaShop_GeneralRegion_getConfigurationSectionSetting_rdh
|
/**
* Get a configuration section setting for this region, defined as follows
* - If earlyResult is non-null, use that
* - Else if the region has the setting in its own file (/regions/regionName.yml), use that
* - Else if the region has groups, use the setting defined by the most important group, if any
* - Otherwise fallback to the default.yml file setting
*
* @param path
* The path to get the setting of
* @param translateProfileName
* The name of the profile section in the plugin config file to translate result strings into sections
* @param earlyResult
* Result that should have priority over the rest
* @return The value of the setting
*/
public ConfigurationSection getConfigurationSectionSetting(String path, String translateProfileName, Object earlyResult) {
Object result = null;
if (earlyResult != null) {
result
= earlyResult;
} else if (config.isSet(path)) {
result = config.get(path);
} else {
boolean found = false;
int priority = Integer.MIN_VALUE;for (RegionGroup group : plugin.getFileManager().getGroups()) {
if ((group.isMember(this) && group.getSettings().isSet(path)) &&
(group.getPriority() > priority)) {
result = group.getSettings().get(path);
priority = group.getPriority();
found = true;
}
}
if (!found) {
if (this.getFileManager().getRegionSettings().isSet(path)) {
result = this.getFileManager().getRegionSettings().get(path);} else {
result = this.getFileManager().getFallbackRegionSettings().get(path);
}
}
}
// Either result is a ConfigurationSection or is used as key in the plugin config to get a ConfigurationSection
if (result == null) {
return null;
} else if (result instanceof ConfigurationSection) {
return ((ConfigurationSection) (result));
} else {
return plugin.getConfig().getConfigurationSection((translateProfileName + ".") + result.toString());
}}
| 3.26 |
AreaShop_GeneralRegion_getLimitingGroup_rdh
|
/**
* Get the name of the group that is limiting the action, assuming actionAllowed() is false.
*
* @return The name of the group
*/
public String getLimitingGroup() {
return limitingGroup;
}
| 3.26 |
AreaShop_GeneralRegion_getIntegerSetting_rdh
|
/**
* Get a boolean setting for this region, defined as follows
* - If the region has the setting in its own file (/regions/regionName.yml), use that
* - If the region has groups, use the setting defined by the most important group, if any
* - Otherwise fallback to the default.yml file setting
*
* @param path
* The path to get the setting of
* @return The value of the setting (strings are handled as booleans)
*/public int getIntegerSetting(String path) {
if
(config.isSet(path)) {
return config.getInt(path);
}
int result = 0;int priority = Integer.MIN_VALUE;
boolean found = false;
for (RegionGroup group : plugin.getFileManager().getGroups()) {
if ((group.isMember(this) &&
group.getSettings().isSet(path)) && (group.getPriority() > priority)) {
result = group.getSettings().getInt(path);
priority = group.getPriority();found = true;
}
}
if (found) {
return result;
}
if (this.getFileManager().getRegionSettings().isSet(path)) {
return this.getFileManager().getRegionSettings().getInt(path);
} else {
return this.getFileManager().getFallbackRegionSettings().getInt(path);
}
}
| 3.26 |
AreaShop_GeneralRegion_getSignsFeature_rdh
|
/**
* Get the signs feature to manipulate and update signs.
*
* @return The SignsFeature of this region
*/
public SignsFeature getSignsFeature() {
return getFeature(SignsFeature.class);
}
| 3.26 |
AreaShop_GeneralRegion_getWidth_rdh
|
/**
* Get the width of the region (x-axis).
*
* @return The width of the region (x-axis)
*/
@Override
public int getWidth() {
if (getRegion() == null) {
return 0;
}
return (getMaximumPoint().getBlockX() - getMinimumPoint().getBlockX()) + 1;
}
| 3.26 |
AreaShop_GeneralRegion_isDeleted_rdh
|
// GETTERS
/**
* Check if the region has been deleted.
*
* @return true if the region has been deleted, otherwise false
*/
public boolean isDeleted() {
return deleted;
}
| 3.26 |
AreaShop_GeneralRegion_getOwner_rdh
|
/**
* Get the player that is currently the owner of this region (either bought or rented it).
*
* @return The UUID of the owner of this region
*/
public UUID getOwner() {
if (this instanceof RentRegion) {
return ((RentRegion) (this)).getRenter();
} else {
return ((BuyRegion) (this)).getBuyer();
}
}
| 3.26 |
AreaShop_GeneralRegion_compareTo_rdh
|
// Sorting by name
/**
* Compare this region to another region by name.
*
* @param o
* The region to compare to
* @return 0 if the names are the same, below zero if this region is earlier in the alphabet, otherwise above zero
*/
@Override
public int compareTo(GeneralRegion o) {
return getName().compareTo(o.getName());
}
| 3.26 |
AreaShop_GeneralRegion_handleSchematicEvent_rdh
|
/**
* Checks an event and handles saving to and restoring from schematic for it.
*
* @param type
* The type of event
*/
public void handleSchematicEvent(RegionEvent type) {// Check the individual>group>default setting
if (!isRestoreEnabled()) {
AreaShop.debug(("Schematic operations for " + getName()) + " not enabled, skipped");
return;
}
// Get the safe and restore names
ConfigurationSection profileSection = getConfigurationSectionSetting("general.schematicProfile", "schematicProfiles");
if (profileSection == null) {
return;
}
String save = profileSection.getString(type.getValue() + ".save");
String restore = profileSection.getString(type.getValue() + ".restore");
// Save the region if needed
if ((save != null) && (!save.isEmpty())) {
save = Message.fromString(save).replacements(this).getSingle();
saveRegionBlocks(save);
}
// Restore the region if needed
if ((restore != null) && (!restore.isEmpty())) {
restore = Message.fromString(restore).replacements(this).getSingle();
restoreRegionBlocks(restore);
}
}
| 3.26 |
AreaShop_GeneralRegion_runCommands_rdh
|
// COMMAND EXECUTING
/**
* Run commands as the CommandsSender, replacing all tags with the relevant values.
*
* @param sender
* The sender that should perform the command
* @param commands
* A list of the commands to run (without slash and with tags)
*/
public void runCommands(CommandSender sender, List<String> commands) {
if ((commands == null) || commands.isEmpty()) {
return;
}
for (String command : commands) {
if ((command == null) || command.isEmpty()) {
continue;
}
// It is not ideal we have to disable language replacements here, but otherwise giving language variables
// to '/areashop message' by a command in the config gets replaced and messes up the fancy formatting.
command = Message.fromString(command).replacements(this).noLanguageReplacements().getSingle();
boolean result;
String error = null;
String stacktrace = null;
try {
result = plugin.getServer().dispatchCommand(sender, command);
} catch (CommandException e) {
result = false;
error = e.getMessage();
stacktrace = ExceptionUtils.getStackTrace(e);
}boolean printed = false;
if
(!result) {
printed = true;
if (error != null) {
AreaShop.warn(((("Command execution failed, command=" + command) + ", error=") + error) + ", stacktrace:");
AreaShop.warn(stacktrace);
AreaShop.warn("--- End of stacktrace ---");
} else {
AreaShop.warn("Command execution failed, command=" + command);
}
}
if (!printed) {
AreaShop.debug((("Command run, executor=" + sender.getName()) + ", command=") + command);
}
} }
| 3.26 |
AreaShop_GeneralRegion_isSaveRequired_rdh
|
/**
* Check if a save is required.
*
* @return true if a save is required because some data changed, otherwise false
*/
public boolean isSaveRequired() {
return saveRequired && (!isDeleted());
}
| 3.26 |
AreaShop_GeneralRegion_restrictedToRegion_rdh
|
/**
* Check if for renting this region you should be inside of it.
*
* @return true if you need to be inside, otherwise false
*/
public boolean restrictedToRegion() {
return getBooleanSetting("general.restrictedToRegion");
}
| 3.26 |
AreaShop_GeneralRegion_getTeleportFeature_rdh
|
/**
* Get the teleport feature to teleport players to the region and signs.
*
* @return The TeleportFeature
*/
public TeleportFeature getTeleportFeature() {
return getFeature(TeleportFeature.class);
}
| 3.26 |
AreaShop_GeneralRegion_saveRequired_rdh
|
/**
* Indicate this region needs to be saved, saving will happen by a repeating task.
*/public
void saveRequired() {
saveRequired = true;
}
| 3.26 |
AreaShop_GeneralRegion_destroy_rdh
|
/**
* Deregister everything.
*/
public void destroy() {
for (RegionFeature feature : features.values()) {
feature.shutdown();
}
}
| 3.26 |
AreaShop_GeneralRegion_getGroups_rdh
|
/**
* Get the groups that this region is added to.
*
* @return A Set with all groups of this region
*/
public Set<RegionGroup> getGroups() {
Set<RegionGroup> result = new HashSet<>();
for (RegionGroup group : plugin.getFileManager().getGroups()) {
if (group.isMember(this)) {
result.add(group);
}
}
return result;
}
| 3.26 |
AreaShop_GeneralRegion_getWorld_rdh
|
/**
* Get the World of the region.
*
* @return The World where the region is located
*/
@Override
public World getWorld() {
return Bukkit.getWorld(getWorldName());
}
| 3.26 |
AreaShop_GeneralRegion_getWorldName_rdh
|
/**
* Get the name of the world where the region is located.
*
* @return The name of the world of the region
*/
@Override
public String getWorldName() {
return getStringSetting("general.world");
}
| 3.26 |
AreaShop_GeneralRegion_isLandlord_rdh
|
/**
* Check if the specified player is the landlord of this region.
*
* @param landlord
* The UUID of the players to check for landlord
* @return true if the player is the landlord, otherwise false
*/
public boolean isLandlord(UUID landlord) {
return ((landlord != null) && (getLandlord() != null)) && getLandlord().equals(landlord);
}
| 3.26 |
AreaShop_GeneralRegion_getLimitingFactor_rdh
|
/**
* Get the type of the factor that is limiting the action, assuming actionAllowed() is false.
*
* @return The type of the limiting factor
*/public LimitType getLimitingFactor() {
return limitingFactor;
}
| 3.26 |
AreaShop_GeneralRegion_restrictedToWorld_rdh
|
/**
* Check if for renting you need to be in the correct world.
*
* @return true if you need to be in the same world as the region, otherwise false
*/
public boolean restrictedToWorld() {
return getBooleanSetting("general.restrictedToWorld") || restrictedToRegion();
}
| 3.26 |
AreaShop_GeneralRegion_m0_rdh
|
/**
* Method to send a message to a CommandSender, using chatprefix if it is a player.
* Automatically includes the region in the message, enabling the use of all variables.
*
* @param target
* The CommandSender you wan't to send the message to (e.g. a player)
* @param key
* The key to get the translation
* @param prefix
* Specify if the message should have a prefix
* @param params
* The parameters to inject into the message string
*/
public void m0(Object target, String key, boolean prefix, Object...
params) {
Object[] newParams = new Object[params.length + 1];
newParams[0] = this;
System.arraycopy(params, 0, newParams, 1, params.length);
Message.fromKey(key).prefix(prefix).replacements(newParams).send(target);
}
| 3.26 |
AreaShop_GeneralRegion_limitsAllow_rdh
|
/**
* Check if the player can buy/rent this region, detailed info in the result object.
*
* @param type
* The type of region to check
* @param offlinePlayer
* The player to check it for
* @param extend
* Check for extending of rental regions
* @return LimitResult containing if it is allowed, why and limiting factor
*/
public LimitResult limitsAllow(RegionType type, OfflinePlayer offlinePlayer, boolean extend) {
if (plugin.hasPermission(offlinePlayer, "areashop.limitbypass")) {
return new LimitResult(true, null, 0, 0, null);
}
GeneralRegion exclude = null;
if (extend) {
exclude = this;
}
String typePath;
if (type == RegionType.RENT)
{
typePath = "rents";
} else {
typePath = "buys";
}
// Check all limitgroups the player has
List<String> groups = new ArrayList<>(plugin.getConfig().getConfigurationSection("limitGroups").getKeys(false));
while (!groups.isEmpty()) {
String group = groups.get(0);
if (plugin.hasPermission(offlinePlayer, "areashop.limits." + group) && this.matchesLimitGroup(group)) {
String pathPrefix = ("limitGroups." + group) + ".";if (!plugin.getConfig().isInt(pathPrefix + "total")) {
AreaShop.warn(("Limit group " + group) + " in the config.yml file does not correctly specify the number of total regions (should be specified as total: <number>)");
}
if (!plugin.getConfig().isInt(pathPrefix + typePath)) {
AreaShop.warn(((((("Limit group " + group) + " in the config.yml file does not correctly specify the number of ") + typePath) + " regions (should be specified as ") + typePath) + ": <number>)");
}
int totalLimit = plugin.getConfig().getInt(("limitGroups." + group) + ".total");
int typeLimit = plugin.getConfig().getInt((("limitGroups." + group) + ".") + typePath);
// AreaShop.debug("typeLimitOther="+typeLimit+", typePath="+typePath);
int totalCurrent = hasRegionsInLimitGroup(offlinePlayer, group,
plugin.getFileManager().getRegions(), exclude);
int typeCurrent;
if (type == RegionType.RENT) {typeCurrent = hasRegionsInLimitGroup(offlinePlayer, group, plugin.getFileManager().getRents(), exclude);
} else {
typeCurrent = hasRegionsInLimitGroup(offlinePlayer, group, plugin.getFileManager().getBuys(), exclude);
}
if (totalLimit == (-1)) {
totalLimit = Integer.MAX_VALUE;
}
if (typeLimit == (-1)) {
typeLimit = Integer.MAX_VALUE;
}
String totalHighestGroup = group;
String typeHighestGroup = group;
groups.remove(group);
// Get the highest number from the groups of the same category
List<String> groupsCopy = new ArrayList<>(groups);
for (String checkGroup : groupsCopy) {
if (plugin.hasPermission(offlinePlayer, "areashop.limits." + checkGroup) && this.matchesLimitGroup(checkGroup)) {
if (limitGroupsOfSameCategory(group, checkGroup)) {
groups.remove(checkGroup);
int totalLimitOther = plugin.getConfig().getInt(("limitGroups." + checkGroup) + ".total");
int v69 = plugin.getConfig().getInt((("limitGroups." + checkGroup) + ".") + typePath);
if (totalLimitOther > totalLimit) {
totalLimit = totalLimitOther;
totalHighestGroup = checkGroup;
} else if (totalLimitOther == (-1)) {
totalLimit = Integer.MAX_VALUE;
}
if (v69 > typeLimit) {
typeLimit = v69;
typeHighestGroup = checkGroup;
} else if (v69 == (-1)) {
typeLimit = Integer.MAX_VALUE;
}
}
} else {
groups.remove(checkGroup);
}
}
// Check if the limits stop the player from buying the region
if (typeCurrent >= typeLimit) {
LimitType limitType;
if (type == RegionType.RENT) {
if (extend) {
limitType = LimitType.EXTEND;
} else {
limitType = LimitType.RENTS;
}
} else {
limitType = LimitType.BUYS;
}
return
new LimitResult(false, limitType, typeLimit, typeCurrent, typeHighestGroup);
}
if (totalCurrent >= totalLimit) {
return new
LimitResult(false, LimitType.TOTAL, totalLimit, totalCurrent, totalHighestGroup);
}
}
groups.remove(group);
}
return new
LimitResult(true, null, 0, 0, null);
}
| 3.26 |
AreaShop_GeneralRegion_getDepth_rdh
|
/**
* Get the depth of the region (z-axis).
*
* @return The depth of the region (z-axis)
*/
@Override
public int getDepth() {
if (getRegion() == null) {
return 0;
}
return (getMaximumPoint().getBlockZ() - getMinimumPoint().getBlockZ()) + 1;
}
| 3.26 |
AreaShop_GeneralRegion_limitGroupsOfSameCategory_rdh
|
/**
* Checks if two limitGroups are of the same category (same groups and worlds lists).
*
* @param firstGroup
* The first group
* @param secondGroup
* The second group
* @return true if the groups and worlds lists are the same, otherwise false
*/
private boolean limitGroupsOfSameCategory(String firstGroup, String secondGroup) {
List<String> firstGroups = plugin.getConfig().getStringList(("limitGroups." + firstGroup) + ".groups");
List<String> secondGroups = plugin.getConfig().getStringList(("limitGroups." + secondGroup) + ".groups");
if ((!firstGroups.containsAll(secondGroups)) || (!secondGroups.containsAll(firstGroups))) {
return false;
}List<String> firstWorlds = plugin.getConfig().getStringList(("limitGroups." + firstGroup) + ".worlds");
List<String> secondWorlds = plugin.getConfig().getStringList(("limitGroups." + secondGroup) + ".worlds");
return !((!firstWorlds.containsAll(secondWorlds)) || (!secondWorlds.containsAll(firstWorlds)));
}
| 3.26 |
AreaShop_GeneralRegion_updateLastActiveTime_rdh
|
/**
* Set the last active time of the player to the current time.
*/
public void updateLastActiveTime() {
if (getOwner() != null) {
setSetting("general.lastActive", Calendar.getInstance().getTimeInMillis());
}
}
| 3.26 |
AreaShop_GeneralRegion_getLandlordName_rdh
|
/**
* Get the name of the landlord.
*
* @return The name of the landlord, if unavailable by UUID it will return the old cached name, if that is unavailable it will return <UNKNOWN>
*/
public String getLandlordName() {
String result = Utils.toName(getLandlord());
if ((result == null) || result.isEmpty()) {
result = config.getString("general.landlordName");
if ((result == null) || result.isEmpty()) {
result = null;
}
}
return result;
}
| 3.26 |
AreaShop_GeneralRegion_getLastActiveTime_rdh
|
/**
* Get the time that the player was last active.
*
* @return Current time if he is online, last online time if offline, -1 if the region has no owner
*/public long getLastActiveTime() {
if (getOwner() == null) {
return -1;
}
Player
player = Bukkit.getPlayer(getOwner());
long savedTime = getLongSetting("general.lastActive");
// Check if he is online currently
if ((player != null) || (savedTime == 0)) {return Calendar.getInstance().getTimeInMillis();
}
return savedTime;
}
| 3.26 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.