diff options
author | KHobbits <rob@khobbits.co.uk> | 2012-02-14 23:56:02 +0000 |
---|---|---|
committer | KHobbits <rob@khobbits.co.uk> | 2012-02-14 23:56:02 +0000 |
commit | 1a2acb43aeb2217b772351dcf8cf829e6dd6d8ac (patch) | |
tree | 471a8c358853dbe7a951d048daf992ac90d786ee | |
parent | 36d07cb539f92ae727934d2286130d687652d8f9 (diff) | |
parent | f0c0ee1a8dd90de1524032e92c65df5e823a7b1f (diff) | |
download | Essentials-1a2acb43aeb2217b772351dcf8cf829e6dd6d8ac.tar Essentials-1a2acb43aeb2217b772351dcf8cf829e6dd6d8ac.tar.gz Essentials-1a2acb43aeb2217b772351dcf8cf829e6dd6d8ac.tar.lz Essentials-1a2acb43aeb2217b772351dcf8cf829e6dd6d8ac.tar.xz Essentials-1a2acb43aeb2217b772351dcf8cf829e6dd6d8ac.zip |
Merge branch 'master' into release
-rw-r--r-- | Essentials/src/com/earth2me/essentials/UserMap.java | 31 | ||||
-rw-r--r-- | Essentials/src/com/earth2me/essentials/Util.java | 5 | ||||
-rw-r--r-- | Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java | 17 | ||||
-rw-r--r-- | Essentials/src/config.yml | 4 |
4 files changed, 45 insertions, 12 deletions
diff --git a/Essentials/src/com/earth2me/essentials/UserMap.java b/Essentials/src/com/earth2me/essentials/UserMap.java index d15438c7d..94b504241 100644 --- a/Essentials/src/com/earth2me/essentials/UserMap.java +++ b/Essentials/src/com/earth2me/essentials/UserMap.java @@ -61,7 +61,7 @@ public class UserMap extends CacheLoader<String, User> implements IConf { try { - return users.get(Util.sanitizeFileName(name)); + return users.get(name); } catch (ExecutionException ex) { @@ -76,18 +76,31 @@ public class UserMap extends CacheLoader<String, User> implements IConf @Override public User load(final String name) throws Exception { + String sanitizedName = Util.sanitizeFileName(name); + if (!sanitizedName.equals(name)) + { + User user = getUser(sanitizedName); + if (user == null) + { + throw new Exception("User not found!"); + } + else + { + return user; + } + } for (Player player : ess.getServer().getOnlinePlayers()) { if (player.getName().equalsIgnoreCase(name)) { - keys.add(Util.sanitizeFileName(name)); + keys.add(sanitizedName); return new User(player, ess); } } - final File userFile = getUserFile(name); + final File userFile = getUserFile2(sanitizedName); if (userFile.exists()) { - keys.add(Util.sanitizeFileName(name)); + keys.add(sanitizedName); return new User(new OfflinePlayer(name, ess), ess); } throw new Exception("User not found!"); @@ -103,6 +116,7 @@ public class UserMap extends CacheLoader<String, User> implements IConf { keys.remove(Util.sanitizeFileName(name)); users.invalidate(Util.sanitizeFileName(name)); + users.invalidate(name); } public Set<String> getAllUniqueUsers() @@ -114,10 +128,15 @@ public class UserMap extends CacheLoader<String, User> implements IConf { return keys.size(); } - + public File getUserFile(final String name) { + return getUserFile2(Util.sanitizeFileName(name)); + } + + private File getUserFile2(final String name) + { final File userFolder = new File(ess.getDataFolder(), "userdata"); - return new File(userFolder, Util.sanitizeFileName(name) + ".yml"); + return new File(userFolder, name + ".yml"); } } diff --git a/Essentials/src/com/earth2me/essentials/Util.java b/Essentials/src/com/earth2me/essentials/Util.java index 65077a7fc..3e3a7efd0 100644 --- a/Essentials/src/com/earth2me/essentials/Util.java +++ b/Essentials/src/com/earth2me/essentials/Util.java @@ -22,11 +22,12 @@ public class Util } private final static Logger logger = Logger.getLogger("Minecraft"); private final static Pattern INVALIDFILECHARS = Pattern.compile("[^a-z0-9]"); - private final static Pattern INVALIDCHARS = Pattern.compile("[^\t\n\r\u0020-\u007E\u0085\u00A0-\uD7FF\uE000-\uFFFC]");; + private final static Pattern INVALIDCHARS = Pattern.compile("[^\t\n\r\u0020-\u007E\u0085\u00A0-\uD7FF\uE000-\uFFFC]"); public static String sanitizeFileName(final String name) { - return INVALIDFILECHARS.matcher(name.toLowerCase(Locale.ENGLISH)).replaceAll("_"); + final String newName = INVALIDFILECHARS.matcher(name.toLowerCase(Locale.ENGLISH)).replaceAll("_"); + return newName; } public static String sanitizeString(final String string) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java b/Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java index f867a1503..948c82871 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java @@ -7,6 +7,7 @@ import com.earth2me.essentials.User; import com.earth2me.essentials.Util; import java.util.Locale; import java.util.Random; +import java.util.Set; import org.bukkit.DyeColor; import org.bukkit.Location; import org.bukkit.Server; @@ -26,7 +27,19 @@ public class Commandspawnmob extends EssentialsCommand { if (args.length < 1) { - throw new NotEnoughArgumentsException(_("mobsAvailable", Util.joinList(Mob.getMobList()))); + Set<String> availableList = Mob.getMobList(); + for (String mob : availableList) + { + if (!user.isAuthorized("essentials.spawnmob." + mob.toLowerCase())) + { + availableList.remove(mob); + } + } + if (availableList.isEmpty()) + { + availableList.add(_("none")); + } + throw new NotEnoughArgumentsException(_("mobsAvailable", Util.joinList(availableList))); } @@ -79,7 +92,7 @@ public class Commandspawnmob extends EssentialsCommand User otherUser = null; if (args.length >= 3) { - otherUser = getPlayer(ess.getServer(), args, 2); + otherUser = getPlayer(ess.getServer(), args, 2); } final Location loc = (otherUser == null) ? block.getLocation() : otherUser.getLocation(); final Location sloc = Util.getSafeDestination(loc); diff --git a/Essentials/src/config.yml b/Essentials/src/config.yml index 63770a293..0998220ba 100644 --- a/Essentials/src/config.yml +++ b/Essentials/src/config.yml @@ -335,7 +335,7 @@ non-ess-in-help: true # Hide plugins which dont give a permission # You can override a true value here for a single plugin by adding a permission to a user/group. -# The indervidual permission is: essentials.help.<plugin>, anyone with essentials.* or '*' will see all help this setting reguardless. +# The individual permission is: essentials.help.<plugin>, anyone with essentials.* or '*' will see all help this setting reguardless. # You can use negitive permissions to remove access to just a single plugins help if the following is enabled. hide-permissionless-help: true @@ -519,7 +519,7 @@ protect: build: true # Should people with build: false in permissions be allowed to use items - # Set true to disable useing for those people + # Set true to disable using for those people use: true # Should we tell people they are not allowed to build |