mirror of
https://github.com/NLthijs48/AreaShop.git
synced 2024-11-26 20:26:33 +01:00
Changes handling WorldGuard flags, it now actually adds friends
Reworked applying flag settings configured in AreaShop to the WorldGuard region. Now supports adding the friends to the regions, adding groups to a region (g:groupname, would allow someone 'unlocking' functionality of a region for a whole group of players) and adding group restrictions to other flags (for example: 'entry: deny g:non_owners').
This commit is contained in:
parent
59627e1b97
commit
cf3139f373
29
config.yml
29
config.yml
@ -1,10 +1,7 @@
|
||||
##############################################
|
||||
# config.yml of the AreaShop plugin #
|
||||
# This plugin has been created by NLThijs48 #
|
||||
# Check the server minecraft.go-craft.com #
|
||||
# and then the Survival server for a demo #
|
||||
##############################################
|
||||
|
||||
# ╔════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════╗
|
||||
# ║ config.yml file of the AreaShop plugin created by NLThijs48, Github can be found at https://github.com/NLthijs48/AreaShop ║
|
||||
# ║ This file contains options to change the working of the plugin, the profiles defined here can be used in default.yml ║
|
||||
# ╚════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════╝
|
||||
# ┌────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
|
||||
# │ GENERAL: Options that influence the global state of the plugin │
|
||||
# └────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
|
||||
@ -38,7 +35,7 @@ useColorsInConsole: false
|
||||
## Post error messages in the console when a command run from the config fails (from the 'runCommands' section for example)
|
||||
postCommandErrors: true
|
||||
## Enables / disables debug messages in the console, could be useful to figure out where errors come from
|
||||
debug: false
|
||||
debug: true
|
||||
## Version of the config, do not change!
|
||||
version: 2.1.0
|
||||
|
||||
@ -81,11 +78,13 @@ limitGroups:
|
||||
# ┌────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
|
||||
# │ PROFILES: Assigned in general (default.yml), for a group (groups.yml) or individually (<region>.yml) │
|
||||
# └────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
|
||||
## Below is a list of default tags that can be used with all the profiles below.
|
||||
## Below is a list of tags that can be used with all the profiles below.
|
||||
## If a tag has no value (for example when you use %player% when the region is not rented/bought) then the tag will not get replaced
|
||||
## %region% The region name (with correct capitalization)
|
||||
## %player% The name of the player that rents/buys the region (with correct capitalization), will not get replaced if no renter/buyer
|
||||
## %uuid% The uuid of the player that rents/buys the region, will not get replaced if no renter/buyer
|
||||
## %friends% The names of friends added to this region separated by ', '
|
||||
## %friendsuuid% The UUID's of friends added to this region separated by ', '
|
||||
## %price% The price of the region formatted with the configured characters before and after the number
|
||||
## %duration% The duration of a rent region, for example '1 d', '4 minutes' or '2 years'
|
||||
## %world% The name of the world that the region is in
|
||||
@ -220,23 +219,23 @@ schematicProfiles:
|
||||
restore: ''
|
||||
## Flag profiles to specify what flags should be set on the WorldGuard regions
|
||||
## All normal region flags as present in WorldGuard can be used, and also members, owners, priority and parent
|
||||
## Use 'clear' for members or owners to remove all players. Use '' for a normal flag to reset it.
|
||||
## Use '' for members or owners to clear it. Use '' for a flag to reset it.
|
||||
flagProfiles:
|
||||
default:
|
||||
forrent:
|
||||
members: clear
|
||||
members: ''
|
||||
greeting: '%lang:prefix%%lang:greeting-forrent%'
|
||||
rented:
|
||||
members: clear, +%player%
|
||||
members: '%player%, %friends%'
|
||||
greeting: '%lang:prefix%%lang:greeting-rented%'
|
||||
forsale:
|
||||
members: clear
|
||||
members: ''
|
||||
greeting: '%lang:prefix%%lang:greeting-forsale%'
|
||||
sold:
|
||||
members: clear, +%player%
|
||||
members: '%player%, %friends%'
|
||||
greeting: '%lang:prefix%%lang:greeting-bought%'
|
||||
resale:
|
||||
members: clear, +%player%
|
||||
members: '%player%, %friends%'
|
||||
greetin: '%lang:prefix%%lang:greeting-resale%'
|
||||
## Profiles that specify when players should get messages about rent that almost run out
|
||||
## The numbers that start sections in the profile specify how time before it actually runs out it should be executed
|
||||
|
@ -1,6 +1,7 @@
|
||||
### All settings below are default settings and can be overridden
|
||||
### by group settings or region settings (copy a section to a region or group and change them there)
|
||||
|
||||
# ╔════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════╗
|
||||
# ║ default.yml file of the AreaShop plugin created by NLThijs48, Github can be found at https://github.com/NLthijs48/AreaShop ║
|
||||
# ║ All settings below are default settings and can be overridden by group settings or individual region settings ║
|
||||
# ╚════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════╝
|
||||
# ┌────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
|
||||
# │ GENERAL: Options for all regions │
|
||||
# └────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
|
||||
@ -30,6 +31,7 @@ general:
|
||||
## Restricts the /as buy and /as rent commands to the region itself (player needs to be inside)
|
||||
restrictedToRegion: false
|
||||
|
||||
|
||||
# ┌────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
|
||||
# │ RENT: Options for rent regions │
|
||||
# └────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
|
||||
@ -54,6 +56,7 @@ rent:
|
||||
## The profile for the expiration warnings as specified in the config
|
||||
expirationWarningProfile: 'default'
|
||||
|
||||
|
||||
# ┌────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
|
||||
# │ BUY: Options for buy regions │
|
||||
# └────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
|
||||
|
@ -72,6 +72,8 @@ public final class AreaShop extends JavaPlugin {
|
||||
public static final String tagTimeLeft = "%timeleft%";
|
||||
public static final String tagClicker = "%clicker%";
|
||||
public static final String tagResellPrice = "%resellprice%";
|
||||
public static final String tagFriends = "%friends%";
|
||||
public static final String tagFriendsUUID = "%friendsuuid%";
|
||||
|
||||
public static AreaShop getInstance() {
|
||||
return AreaShop.instance;
|
||||
|
@ -80,7 +80,7 @@ public class AddfriendCommand extends CommandAreaShop {
|
||||
return;
|
||||
}
|
||||
OfflinePlayer friend = Bukkit.getOfflinePlayer(args[1]);
|
||||
if(region.getFriendList().contains(friend.getUniqueId())) {
|
||||
if(region.getFriends().contains(friend.getUniqueId())) {
|
||||
plugin.message(sender, "addfriend-alreadyAdded", friend.getName());
|
||||
return;
|
||||
}
|
||||
@ -97,7 +97,7 @@ public class AddfriendCommand extends CommandAreaShop {
|
||||
if(sender.hasPermission("areashop.addfriend") && sender instanceof Player) {
|
||||
if(region.isOwner((Player)sender)) {
|
||||
OfflinePlayer friend = Bukkit.getOfflinePlayer(args[1]);
|
||||
if(region.getFriendList().contains(friend.getUniqueId())) {
|
||||
if(region.getFriends().contains(friend.getUniqueId())) {
|
||||
plugin.message(sender, "addfriend-alreadyAdded", friend.getName());
|
||||
return;
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ public class DelfriendCommand extends CommandAreaShop {
|
||||
return;
|
||||
}
|
||||
OfflinePlayer friend = Bukkit.getOfflinePlayer(args[1]);
|
||||
if(!region.getFriendList().contains(friend.getUniqueId())) {
|
||||
if(!region.getFriends().contains(friend.getUniqueId())) {
|
||||
plugin.message(sender, "delfriend-notAdded", friend.getName());
|
||||
return;
|
||||
}
|
||||
@ -91,7 +91,7 @@ public class DelfriendCommand extends CommandAreaShop {
|
||||
if(sender.hasPermission("areashop.delfriend") && sender instanceof Player) {
|
||||
if(region.isOwner((Player)sender)) {
|
||||
OfflinePlayer friend = Bukkit.getOfflinePlayer(args[1]);
|
||||
if(!region.getFriendList().contains(friend.getUniqueId())) {
|
||||
if(!region.getFriends().contains(friend.getUniqueId())) {
|
||||
plugin.message(sender, "delfriend-notAdded", friend.getName());
|
||||
return;
|
||||
}
|
||||
|
@ -268,6 +268,8 @@ public class BuyRegion extends GeneralRegion {
|
||||
plugin.message(player, "buy-payError");
|
||||
return false;
|
||||
}
|
||||
AreaShop.debug(player.getName() + " has bought region " + getName() + " for " + getFormattedPrice());
|
||||
|
||||
// Run commands
|
||||
this.runEventCommands(RegionEvent.BOUGHT, true);
|
||||
// Set the owner
|
||||
@ -280,8 +282,6 @@ public class BuyRegion extends GeneralRegion {
|
||||
|
||||
// Send message to the player
|
||||
plugin.message(player, "buy-succes", getName());
|
||||
AreaShop.debug(player.getName() + " has bought region " + getName() + " for " + getFormattedPrice());
|
||||
|
||||
this.saveRequired();
|
||||
// Run commands
|
||||
this.runEventCommands(RegionEvent.BOUGHT, false);
|
||||
|
@ -40,17 +40,10 @@ import com.sk89q.worldedit.data.DataException;
|
||||
import com.sk89q.worldedit.schematic.SchematicFormat;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.domains.DefaultDomain;
|
||||
import com.sk89q.worldguard.protection.flags.BooleanFlag;
|
||||
import com.sk89q.worldguard.protection.flags.DefaultFlag;
|
||||
import com.sk89q.worldguard.protection.flags.DoubleFlag;
|
||||
import com.sk89q.worldguard.protection.flags.EnumFlag;
|
||||
import com.sk89q.worldguard.protection.flags.Flag;
|
||||
import com.sk89q.worldguard.protection.flags.IntegerFlag;
|
||||
import com.sk89q.worldguard.protection.flags.InvalidFlagFormat;
|
||||
import com.sk89q.worldguard.protection.flags.SetFlag;
|
||||
import com.sk89q.worldguard.protection.flags.StateFlag;
|
||||
import com.sk89q.worldguard.protection.flags.StateFlag.State;
|
||||
import com.sk89q.worldguard.protection.flags.StringFlag;
|
||||
import com.sk89q.worldguard.protection.flags.RegionGroupFlag;
|
||||
import com.sk89q.worldguard.protection.managers.storage.StorageException;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion.CircularInheritanceException;
|
||||
@ -368,6 +361,8 @@ public abstract class GeneralRegion {
|
||||
result.put(AreaShop.tagWidth, getWidth());
|
||||
result.put(AreaShop.tagDepth, getDepth());
|
||||
result.put(AreaShop.tagHeight, getHeight());
|
||||
result.put(AreaShop.tagFriends, Utils.createCommaSeparatedList(getFriendNames()));
|
||||
result.put(AreaShop.tagFriendsUUID, Utils.createCommaSeparatedList(getFriends()));
|
||||
|
||||
// TODO: add more? coordinates?
|
||||
|
||||
@ -465,7 +460,7 @@ public abstract class GeneralRegion {
|
||||
* Get the list of friends added to this region
|
||||
* @return Friends added to this region
|
||||
*/
|
||||
public Set<UUID> getFriendList() {
|
||||
public Set<UUID> getFriends() {
|
||||
HashSet<UUID> result = new HashSet<UUID>();
|
||||
for(String friend : config.getStringList("general.friends")) {
|
||||
try {
|
||||
@ -480,6 +475,25 @@ public abstract class GeneralRegion {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of friends added to this region
|
||||
* @return Friends added to this region
|
||||
*/
|
||||
public Set<String> getFriendNames() {
|
||||
HashSet<String> result = new HashSet<String>();
|
||||
for(String friend : config.getStringList("general.friends")) {
|
||||
try {
|
||||
UUID id = UUID.fromString(friend);
|
||||
if(id != null) {
|
||||
result.add(Bukkit.getOfflinePlayer(id).getName());
|
||||
}
|
||||
} catch(IllegalArgumentException e) {
|
||||
// Don't add it
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove all friends that are added to this region
|
||||
*/
|
||||
@ -806,10 +820,7 @@ public abstract class GeneralRegion {
|
||||
// closer.close();
|
||||
// } catch (IOException ignored) {
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
|
||||
// }
|
||||
|
||||
editSession.enableQueue();
|
||||
try {
|
||||
@ -840,6 +851,11 @@ public abstract class GeneralRegion {
|
||||
}
|
||||
}
|
||||
|
||||
protected static <V> void setFlag(ProtectedRegion region, Flag<V> flag, CommandSender sender, String value) throws InvalidFlagFormat {
|
||||
region.setFlag(flag, flag.parseInput(WorldGuardPlugin.inst(), sender, value));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the region flags/options to the values of a ConfigurationSection
|
||||
* @param player The player that does it
|
||||
@ -847,69 +863,74 @@ public abstract class GeneralRegion {
|
||||
* @param flags
|
||||
* @return
|
||||
*/
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
protected boolean setRegionFlags(ConfigurationSection flags) {
|
||||
boolean result = true;
|
||||
|
||||
// TODO A lot of testing + delete lines below
|
||||
// https://github.com/sk89q/WorldGuard/blob/master/src/main/java/com/sk89q/worldguard/bukkit/commands/region/RegionCommands.java#L461
|
||||
// https://github.com/sk89q/WorldGuard/blob/master/src/main/java/com/sk89q/worldguard/bukkit/commands/region/RegionCommandsBase.java#L393
|
||||
boolean result = true;
|
||||
if(flags == null) {
|
||||
AreaShop.debug("Flags section is null");
|
||||
return false;
|
||||
}
|
||||
Set<String> flagNames = flags.getKeys(false);
|
||||
WorldGuardPlugin worldGuard = plugin.getWorldGuard();
|
||||
Flag<?> flagType = null;
|
||||
Object flagValue = null;
|
||||
WorldGuardPlugin worldGuard = plugin.getWorldGuard();
|
||||
|
||||
/* Get the region */
|
||||
// Get the region
|
||||
ProtectedRegion region = getRegion();
|
||||
if(region == null) {
|
||||
AreaShop.debug("Region '" + getName() + "' does not exist, setting flags failed");
|
||||
return false;
|
||||
}
|
||||
Iterator<String> it = flagNames.iterator();
|
||||
// Loop through all flags that are set in the config
|
||||
while(it.hasNext()) {
|
||||
String flagName = it.next();
|
||||
String value = flags.getString(flagName);
|
||||
|
||||
// Apply replacements
|
||||
if(value != null) {
|
||||
value = applyAllReplacements(value);
|
||||
}
|
||||
|
||||
/* Check for a couple of options or use as flag */
|
||||
value = applyAllReplacements(value);
|
||||
value = translateBukkitToWorldGuardColors(value);
|
||||
if(flagName.equalsIgnoreCase("members")) {
|
||||
/* Split the string and parse all values */
|
||||
String[] names = value.split("\\s*,\\s*");
|
||||
// Split the string and parse all values
|
||||
String[] names = value.split(", ");
|
||||
DefaultDomain members = region.getMembers();
|
||||
for(int i=0; i<names.length; i++) {
|
||||
if(names[i].equals("clear")) {
|
||||
members.removeAll();
|
||||
} else if(names[i].charAt(0) == '+') {
|
||||
members.addPlayer(names[i].substring(1));;
|
||||
} else if(names[i].charAt(0) == '-') {
|
||||
members.removePlayer(names[i].substring(1));;
|
||||
members.clear();
|
||||
for(String name : names) {
|
||||
if(name != null && !name.isEmpty()) {
|
||||
// Check for groups
|
||||
if(name.startsWith("g:")) {
|
||||
if(name.length() > 2) {
|
||||
members.addGroup(name.substring(2));
|
||||
}
|
||||
} else {
|
||||
members.addPlayer(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
region.setMembers(members);
|
||||
AreaShop.debug(" Flag " + flagName + " set: " + members.toUserFriendlyString());
|
||||
} else if(flagName.equalsIgnoreCase("owners")) {
|
||||
/* Split the string and parse all values */
|
||||
String[] names = value.split("\\s*,\\s*");
|
||||
// Split the string and parse all values
|
||||
String[] names = value.split(" ");
|
||||
DefaultDomain owners = region.getOwners();
|
||||
for(int i=0; i<names.length; i++) {
|
||||
if(names[i].equals("clear")) {
|
||||
owners.removeAll();
|
||||
} else if(names[i].charAt(0) == '+') {
|
||||
owners.addPlayer(names[i].substring(1));;
|
||||
} else if(names[i].charAt(0) == '-') {
|
||||
owners.removePlayer(names[i].substring(1));;
|
||||
owners.clear();
|
||||
for(String name : names) {
|
||||
if(name != null && !name.isEmpty()) {
|
||||
// Check for groups
|
||||
if(name.startsWith("g:")) {
|
||||
if(name.length() > 2) {
|
||||
owners.addGroup(name.substring(2));
|
||||
}
|
||||
} else {
|
||||
owners.addPlayer(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
region.setOwners(owners);
|
||||
AreaShop.debug(" Flag " + flagName + " set: " + owners.toUserFriendlyString());
|
||||
} else if(flagName.equalsIgnoreCase("priority")) {
|
||||
try {
|
||||
int priority = Integer.parseInt(value);
|
||||
region.setPriority(priority);
|
||||
AreaShop.debug("Flag set: " + flagName + " --> " + value);
|
||||
AreaShop.debug(" Flag " + flagName + " set: " + value);
|
||||
} catch(NumberFormatException e) {
|
||||
plugin.getLogger().info("The value of flag " + flagName + " is not a number");
|
||||
result = false;
|
||||
@ -919,82 +940,75 @@ public abstract class GeneralRegion {
|
||||
if(parentRegion != null) {
|
||||
try {
|
||||
region.setParent(parentRegion);
|
||||
AreaShop.debug(" Flag " + flagName + " set: " + value);
|
||||
} catch (CircularInheritanceException e) {
|
||||
plugin.getLogger().info("The parent set in the config is not correct (circular inheritance)");
|
||||
}
|
||||
} else {
|
||||
plugin.getLogger().info("The parent set in the config is not correct (region does not exist)");
|
||||
}
|
||||
} else {
|
||||
flagType = null;
|
||||
flagValue = null;
|
||||
|
||||
try {
|
||||
flagType = DefaultFlag.fuzzyMatchFlag(flagName);
|
||||
if(flagType != null && !(value.equals("") || value.equals("none"))) {
|
||||
flagValue = flagType.parseInput(worldGuard, null, value);
|
||||
}
|
||||
} catch (InvalidFlagFormat e) {
|
||||
plugin.getLogger().info("The value of flag " + flagName + " is wrong");
|
||||
result = false;
|
||||
}
|
||||
if(flagType != null) {
|
||||
if(flagType instanceof StateFlag) {
|
||||
if(value.equals("")) {
|
||||
region.setFlag((StateFlag)flagType, null);
|
||||
} else {
|
||||
region.setFlag((StateFlag)flagType, (State)flagValue);
|
||||
}
|
||||
} else if(flagType instanceof BooleanFlag) {
|
||||
if(value.equals("")) {
|
||||
region.setFlag((BooleanFlag)flagType, null);
|
||||
} else {
|
||||
region.setFlag((BooleanFlag)flagType, (Boolean)flagValue);
|
||||
}
|
||||
} else if(flagType instanceof IntegerFlag) {
|
||||
if(value.equals("")) {
|
||||
region.setFlag((IntegerFlag)flagType, null);
|
||||
} else {
|
||||
region.setFlag((IntegerFlag)flagType, (Integer)flagValue);
|
||||
}
|
||||
} else if(flagType instanceof DoubleFlag) {
|
||||
if(value.equals("")) {
|
||||
region.setFlag((DoubleFlag)flagType, null);
|
||||
} else {
|
||||
region.setFlag((DoubleFlag)flagType, (Double)flagValue);
|
||||
}
|
||||
} else if(flagType instanceof StringFlag) {
|
||||
if(value.equals("")) {
|
||||
region.setFlag((StringFlag)flagType, null);
|
||||
} else {
|
||||
String coloredValue = translateBukkitToWorldGuardColors((String)flagValue);
|
||||
region.setFlag((StringFlag)flagType, coloredValue);
|
||||
}
|
||||
} else if(flagType instanceof SetFlag<?>) {
|
||||
if(value.equals("")) {
|
||||
region.setFlag((SetFlag)flagType, null);
|
||||
} else {
|
||||
region.setFlag((SetFlag)flagType, (Set<String>)flagValue);
|
||||
}
|
||||
} /* else if(flagType instanceof LocationFlag) {
|
||||
region.setFlag((LocationFlag)flagType, (Location)flagValue);
|
||||
} */ else if(flagType instanceof EnumFlag) {
|
||||
if(value.equals("")) {
|
||||
region.setFlag((EnumFlag)flagType, null);
|
||||
} else {
|
||||
region.setFlag((EnumFlag)flagType, (Enum)flagValue);
|
||||
}
|
||||
} else {
|
||||
result = false;
|
||||
}
|
||||
AreaShop.debug("Region " + region.getId() + ", flag " + flagName + " --> " + value);
|
||||
} else {
|
||||
result = false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Parse all other normal flags (groups are also handled)
|
||||
String flagSetting = null;
|
||||
com.sk89q.worldguard.protection.flags.RegionGroup groupValue = null;
|
||||
|
||||
Flag<?> foundFlag = DefaultFlag.fuzzyMatchFlag(flagName);
|
||||
if(foundFlag == null) {
|
||||
plugin.getLogger().info("Found wrong flag in flagProfiles section: " + flagName + ", check if that is the correct WorldGuard flag");
|
||||
continue;
|
||||
}
|
||||
RegionGroupFlag groupFlag = foundFlag.getRegionGroupFlag();
|
||||
if(value == null || value.isEmpty()) {
|
||||
region.setFlag(foundFlag, null);
|
||||
if (groupFlag != null) {
|
||||
region.setFlag(groupFlag, null);
|
||||
}
|
||||
AreaShop.debug(" Flag " + flagName + " reset (+ possible group of flag)");
|
||||
continue;
|
||||
} else {
|
||||
if(groupFlag == null) {
|
||||
flagSetting = value;
|
||||
} else {
|
||||
for(String part : value.split(" ")) {
|
||||
if(part.startsWith("g:")) {
|
||||
if(part.length() > 2) {
|
||||
try {
|
||||
groupValue = groupFlag.parseInput(worldGuard, null, part.substring(2));
|
||||
} catch(InvalidFlagFormat e) {
|
||||
plugin.getLogger().info("Found wrong group value for flag " + flagName);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(flagSetting == null) {
|
||||
flagSetting = part;
|
||||
} else {
|
||||
flagSetting += " " + part;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (flagSetting != null) {
|
||||
try {
|
||||
setFlag(region, foundFlag, null, flagSetting);
|
||||
AreaShop.debug(" Flag " + flagName + " set: " + flagSetting);
|
||||
} catch (InvalidFlagFormat e) {
|
||||
plugin.getLogger().info("Found wrong value for flag " + flagName);
|
||||
}
|
||||
}
|
||||
if(groupValue != null) {
|
||||
if(groupValue == groupFlag.getDefault()) {
|
||||
region.setFlag(groupFlag, null);
|
||||
AreaShop.debug(" Group of flag " + flagName + " set to default: " + groupValue);
|
||||
} else {
|
||||
region.setFlag(groupFlag, groupValue);
|
||||
AreaShop.debug(" Group of flag " + flagName + " set: " + groupValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
// TODO include into periodic saving program
|
||||
worldGuard.getRegionManager(getWorld()).save();
|
||||
} catch (StorageException e) {
|
||||
plugin.getLogger().info("Error: regions could not be saved");
|
||||
|
@ -452,7 +452,7 @@ public class RentRegion extends GeneralRegion {
|
||||
if(!r.transactionSuccess()) {
|
||||
plugin.message(player, "rent-payError");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if(!extend) {
|
||||
// Run commands
|
||||
runEventCommands(RegionEvent.RENTED, true);
|
||||
@ -467,8 +467,8 @@ public class RentRegion extends GeneralRegion {
|
||||
calendar.setTimeInMillis(getRentedUntil());
|
||||
}
|
||||
calendar.setTimeInMillis(calendar.getTimeInMillis() + getDuration());
|
||||
|
||||
SimpleDateFormat dateFull = new SimpleDateFormat(plugin.getConfig().getString("timeFormatChat"));
|
||||
AreaShop.debug(player.getName() + " has rented region " + getName() + " for " + getFormattedPrice() + " until " + dateFull.format(calendar.getTime()));
|
||||
|
||||
/* Add values to the rent and send it to FileManager */
|
||||
setRentedUntil(calendar.getTimeInMillis());
|
||||
@ -493,8 +493,7 @@ public class RentRegion extends GeneralRegion {
|
||||
plugin.message(player, "rent-rented", getName(), dateFull.format(calendar.getTime()));
|
||||
plugin.message(player, "rent-extend");
|
||||
}
|
||||
AreaShop.debug(player.getName() + " has rented region " + getName() + " for " + getFormattedPrice() + " until " + dateFull.format(calendar.getTime()));
|
||||
|
||||
|
||||
this.saveRequired();
|
||||
if(!extend) {
|
||||
// Run commands
|
||||
|
Loading…
Reference in New Issue
Block a user