Changes owners/members handling to WorldGuard to UUID's

Now adding uuid's to the owners/members flag in the flagProfiles section
is default, adding names is possible with 'n:<name>', groups is still
'g:<group>'. Now warnings will be displayed in the console if the size
of a schematic does not match the region size.
This commit is contained in:
Thijs Wiefferink 2014-12-04 22:56:18 +01:00
parent 0c79525144
commit 83778ff803
8 changed files with 81 additions and 43 deletions

View File

@ -225,7 +225,8 @@ 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
## For the members and owners flags you can add groups by using 'g:<groupname>', so for example: '%player%, %friends%, g:vip'
## The members and owners flag normally take a list of UUID's separated by 'comma space', adding by name is possible with 'n:<name>'
## You can add groups by using 'g:<groupname>', so in total you could use: '%uuid%, %friendsuuid%, g:vip, n:cool-guy'
## For flags like 'entry' and 'exit' you can add group setting by using 'g:<scope>' behind it, <scope> is one of the following:
## members, non_members, owners, non_owners, all. Example, only owners can enter the region:
## entry: 'deny g:non_owners'
@ -236,16 +237,16 @@ flagProfiles:
members: ''
greeting: '%lang:prefix%%lang:greeting-forrent%'
rented:
members: '%player%, %friends%'
members: '%uuid%, %friendsuuid%'
greeting: '%lang:prefix%%lang:greeting-rented%'
forsale:
members: ''
greeting: '%lang:prefix%%lang:greeting-forsale%'
sold:
members: '%player%, %friends%'
members: '%uuid%, %friendsuuid%'
greeting: '%lang:prefix%%lang:greeting-bought%'
resale:
members: '%player%, %friends%'
members: '%uuid%, %friendsuuid%'
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

View File

@ -154,7 +154,7 @@ info-regionCanBeRented: "&2&l►&r Price to rent: &7%price% per %duration%"
info-regionCanBeBought: "&2&l►&r Price to buy: &7%price%"
info-regionFriends: "&2&l►&r Added friends: &7%friends%"
info-regionMoneyBackBuy: "&2&l►&r Selling payback: &7%moneyback% (%moneybackpercent%% of the price)"
info-regionMoneyBackRent: "&2&l►&r Unrenting payback &7%moneyback% (%moneybackpercent%% of the remaining time)"
info-regionMoneyBackRent: "&2&l►&r Unrenting payback: &7%moneyback% (%moneybackpercent%% of the remaining time)"
info-regionMaxExtends: "&2&l►&r Maximum number of extends: &7%maxextends% time(s)"
info-regionNoExtending: "&2&l►&r Rent cannot be extended"
info-regionExtendsLeft: "&2&l►&r Extending left: &7%extendsleft% time(s) out of %maxextends%"
@ -244,7 +244,7 @@ setteleport-notInside: "The location has to be inside the region"
setteleport-reset: "Teleport location of %0% has been reset"
find-help: "/as find <buy|rent> [maxprice] [group]"
find-noPermission: "You don't have permission to teleport to signs, so you can't use find"
find-noPermission: "You don't have permission to search regions and teleport to them"
find-success: "Found a %0% region: %1%, while searching with a max price of your balance: %2%%3%"
find-successMax: "Found a %0% region: %1%, while searching with a max price of %2%%3%"
find-wrongMaxPrice: "The specified maximum price is not a correct number: %0%"

View File

@ -564,7 +564,7 @@ public class FileManager {
try {
manager.saveChanges();
} catch(StorageException e) {
plugin.getLogger().info("Error: WorldGuard regions in world " + world + " could not be saved");
plugin.getLogger().warning("WorldGuard regions in world " + world + " could not be saved");
}
}
}
@ -639,7 +639,7 @@ public class FileManager {
versions = (HashMap<String,Integer>)input.readObject();
input.close();
} catch (IOException | ClassNotFoundException | ClassCastException e) {
plugin.getLogger().info("Error: Something went wrong reading file: " + versionPath);
plugin.getLogger().warning("Something went wrong reading file: " + versionPath);
versions = null;
}
}
@ -662,7 +662,7 @@ public class FileManager {
output.writeObject(versions);
output.close();
} catch (IOException e) {
plugin.getLogger().info("File could not be saved: " + versionPath);
plugin.getLogger().warning("File could not be saved: " + versionPath);
}
}
@ -932,7 +932,7 @@ public class FileManager {
try {
Files.move(new File(rentPath), new File(oldFolderPath + "rents"));
} catch (Exception e) {
plugin.getLogger().info(" Could not create a backup of '" + rentPath + "', check the file permissions (conversion to next version continues)");
plugin.getLogger().warning(" Could not create a backup of '" + rentPath + "', check the file permissions (conversion to next version continues)");
}
// Check if conversion is needed
if(versions.get("rents") < 1) {
@ -1039,7 +1039,7 @@ public class FileManager {
buys = (HashMap<String,HashMap<String,String>>)input.readObject();
input.close();
} catch (IOException | ClassNotFoundException | ClassCastException e) {
plugin.getLogger().warning(" Error: Something went wrong reading file: " + buyPath);
plugin.getLogger().warning(" Something went wrong reading file: " + buyPath);
}
// Delete the file if it is totally wrong
if(buys == null) {
@ -1051,7 +1051,7 @@ public class FileManager {
try {
Files.move(new File(buyPath), new File(oldFolderPath + "buys"));
} catch (Exception e) {
plugin.getLogger().info(" Could not create a backup of '" + buyPath + "', check the file permissions (conversion to next version continues)");
plugin.getLogger().warning(" Could not create a backup of '" + buyPath + "', check the file permissions (conversion to next version continues)");
}
// Check if conversion is needed
if(versions.get("buys") < 1) {

View File

@ -74,7 +74,7 @@ public class LanguageManager {
output.close();
} catch (IOException e1) {} catch (NullPointerException e2) {}
plugin.getLogger().info("Something went wrong saving a default language file: " + langFile.getPath());
plugin.getLogger().warning("Something went wrong saving a default language file: " + langFile.getPath());
}
}
@ -142,7 +142,7 @@ public class LanguageManager {
}
if(result == null) {
plugin.getLogger().info("Wrong key for getting translation: " + key);
plugin.getLogger().info("Wrong key for getting translation: " + key + ", please contact the author about this");
} else {
/* Replace all tags like %0% and if given a GeneralRegion apply all replacements */
int number=0;

View File

@ -88,7 +88,7 @@ public final class SignBreakListener implements Listener {
return;
}
region.removeSign(block.getLocation());
plugin.getLogger().info("A sign of region " + region.getName() + " has been removed by indirectly breaking it (block below/behind is destroyed)");
plugin.getLogger().warning("A sign of region " + region.getName() + " has been removed by indirectly breaking it (block below/behind is destroyed)");
}
}
}

View File

@ -280,7 +280,7 @@ public class BuyRegion extends GeneralRegion {
if(oldOwnerPlayer != null) {
r = plugin.getEconomy().depositPlayer(oldOwnerPlayer, getWorldName(), getResellPrice());
if(!r.transactionSuccess()) {
plugin.getLogger().info("Something went wrong with paying '" + oldOwnerPlayer.getName() + "' for his resell of region " + getName());
plugin.getLogger().warning("Something went wrong with paying '" + oldOwnerPlayer.getName() + "' for his resell of region " + getName());
}
}
// Resell is done, disable that now
@ -372,7 +372,7 @@ public class BuyRegion extends GeneralRegion {
error = true;
}
if(error || response == null || !response.transactionSuccess()) {
plugin.getLogger().info("Something went wrong with paying back money to " + getPlayerName() + " while selling region " + getName());
plugin.getLogger().warning("Something went wrong with paying back money to " + getPlayerName() + " while selling region " + getName());
}
}
}

View File

@ -346,21 +346,21 @@ public abstract class GeneralRegion {
* @return The width of the region (x-axis)
*/
public int getWidth() {
return getRegion().getMaximumPoint().getBlockX() - getRegion().getMinimumPoint().getBlockX();
return getRegion().getMaximumPoint().getBlockX() - getRegion().getMinimumPoint().getBlockX() +1;
}
/**
* Get the depth of the region (z-axis)
* @return The depth of the region (z-axis)
*/
public int getDepth() {
return getRegion().getMaximumPoint().getBlockZ() - getRegion().getMinimumPoint().getBlockZ();
return getRegion().getMaximumPoint().getBlockZ() - getRegion().getMinimumPoint().getBlockZ() +1;
}
/**
* Get the height of the region (y-axis)
* @return The height of the region (y-axis)
*/
public int getHeight() {
return getRegion().getMaximumPoint().getBlockY() - getRegion().getMinimumPoint().getBlockY();
return getRegion().getMaximumPoint().getBlockY() - getRegion().getMinimumPoint().getBlockY() +1;
}
/**
@ -885,8 +885,18 @@ public abstract class GeneralRegion {
editSession.enableQueue();
try {
SchematicFormat.MCEDIT.load(restoreFile).place(editSession, origin, false);
} catch (MaxChangedBlocksException | IOException | DataException e) {
CuboidClipboard clipBoard = SchematicFormat.MCEDIT.load(restoreFile);
if(clipBoard.getHeight() != getHeight()
|| clipBoard.getWidth() != getWidth()
|| clipBoard.getLength() != getDepth()) {
plugin.getLogger().warning("Size of the region " + getName() + " is not the same as the schematic to restore!");
AreaShop.debug("schematic|region, x:" + clipBoard.getWidth() + "|" + getWidth() + ", y:" + clipBoard.getHeight() + "|" + getHeight() + ", z:" + clipBoard.getLength() + "|" + getDepth());
}
clipBoard.place(editSession, origin, false);
} catch(MaxChangedBlocksException e) {
plugin.getLogger().warning("Exeeded the block limit while restoring schematic of " + getName());
result = false;
} catch(IOException | DataException e) {
result = false;
}
editSession.flushQueue();
@ -999,15 +1009,28 @@ public abstract class GeneralRegion {
String[] names = value.split(", ");
DefaultDomain members = region.getMembers();
members.clear();
for(String name : names) {
if(name != null && !name.isEmpty()) {
for(String member : names) {
if(member != null && !member.isEmpty()) {
// Check for groups
if(name.startsWith("g:")) {
if(name.length() > 2) {
members.addGroup(name.substring(2));
if(member.startsWith("g:")) {
if(member.length() > 2) {
members.addGroup(member.substring(2));
}
} else if(member.startsWith("n:")) {
if(member.length() > 2) {
members.addPlayer(member);
}
} else {
members.addPlayer(name);
UUID uuid;
try {
uuid = UUID.fromString(member);
} catch(IllegalArgumentException e) {
plugin.getLogger().warning("Tried using '" + member + "' as uuid for a region member, is your flagProfiles section correct?");
uuid = null;
}
if(uuid != null) {
members.addPlayer(uuid);
}
}
}
}
@ -1018,15 +1041,29 @@ public abstract class GeneralRegion {
String[] names = value.split(" ");
DefaultDomain owners = region.getOwners();
owners.clear();
for(String name : names) {
if(name != null && !name.isEmpty()) {
for(String owner : names) {
if(owner != null && !owner.isEmpty()) {
// Check for groups
if(name.startsWith("g:")) {
if(name.length() > 2) {
owners.addGroup(name.substring(2));
if(owner.startsWith("g:")) {
if(owner.length() > 2) {
owners.addGroup(owner.substring(2));
}
} else if(owner.startsWith("n:")) {
if(owner.length() > 2) {
owners.addPlayer(owner);
}
} else {
owners.addPlayer(name);
UUID uuid;
try {
uuid = UUID.fromString(owner);
} catch(IllegalArgumentException e) {
plugin.getLogger().warning("Tried using '" + owner + "' as uuid for a region owner, is your flagProfiles section correct?");
uuid = null;
}
if(uuid != null) {
owners.addPlayer(uuid);
}
}
}
}
@ -1038,7 +1075,7 @@ public abstract class GeneralRegion {
region.setPriority(priority);
AreaShop.debug(" Flag " + flagName + " set: " + value);
} catch(NumberFormatException e) {
plugin.getLogger().info("The value of flag " + flagName + " is not a number");
plugin.getLogger().warning("The value of flag " + flagName + " is not a number");
result = false;
}
} else if(flagName.equalsIgnoreCase("parent")) {
@ -1048,10 +1085,10 @@ public abstract class GeneralRegion {
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)");
plugin.getLogger().warning("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)");
plugin.getLogger().warning("The parent set in the config is not correct (region does not exist)");
}
} else {
// Parse all other normal flags (groups are also handled)
@ -1060,7 +1097,7 @@ public abstract class GeneralRegion {
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");
plugin.getLogger().warning("Found wrong flag in flagProfiles section: " + flagName + ", check if that is the correct WorldGuard flag");
continue;
}
RegionGroupFlag groupFlag = foundFlag.getRegionGroupFlag();
@ -1081,7 +1118,7 @@ public abstract class GeneralRegion {
try {
groupValue = groupFlag.parseInput(worldGuard, null, part.substring(2));
} catch(InvalidFlagFormat e) {
plugin.getLogger().info("Found wrong group value for flag " + flagName);
plugin.getLogger().warning("Found wrong group value for flag " + flagName);
}
}
} else {
@ -1098,7 +1135,7 @@ public abstract class GeneralRegion {
setFlag(region, foundFlag, flagSetting);
AreaShop.debug(" Flag " + flagName + " set: " + flagSetting);
} catch (InvalidFlagFormat e) {
plugin.getLogger().info("Found wrong value for flag " + flagName);
plugin.getLogger().warning("Found wrong value for flag " + flagName);
}
}
if(groupValue != null) {
@ -2059,9 +2096,9 @@ public abstract class GeneralRegion {
}
if(!result && postCommandErrors) {
if(error != null) {
plugin.getLogger().info("Command execution failed, command=" + command + ", error=" + error);
plugin.getLogger().warning("Command execution failed, command=" + command + ", error=" + error);
} else {
plugin.getLogger().info("Command execution failed, command=" + command);
plugin.getLogger().warning("Command execution failed, command=" + command);
}
}
}

View File

@ -572,7 +572,7 @@ public class RentRegion extends GeneralRegion {
error = true;
}
if(error || r == null || !r.transactionSuccess()) {
plugin.getLogger().info("Something went wrong with paying back to " + getPlayerName() + " money while unrenting region " + getName());
plugin.getLogger().warning("Something went wrong with paying back to " + getPlayerName() + " money while unrenting region " + getName());
}
}
}