diff options
19 files changed, 226 insertions, 63 deletions
diff --git a/Essentials/nbproject/project.properties b/Essentials/nbproject/project.properties index f8b41cf41..b10c5e5b4 100644 --- a/Essentials/nbproject/project.properties +++ b/Essentials/nbproject/project.properties @@ -32,6 +32,7 @@ file.reference.iCo4.jar=../lib/iCo4.jar file.reference.iCo5.jar=../lib/iCo5.jar file.reference.junit-4.5.jar=..\\lib\\junit_4\\junit-4.5.jar file.reference.Permissions3.jar=../lib/Permissions3.jar +file.reference.PermissionsEx.jar=../lib/PermissionsEx.jar includes=** jar.compress=false javac.classpath=\ @@ -39,7 +40,8 @@ javac.classpath=\ ${file.reference.craftbukkit-0.0.1-SNAPSHOT.jar}:\ ${file.reference.iCo4.jar}:\ ${file.reference.iCo5.jar}:\ - ${file.reference.BOSEconomy7.jar} + ${file.reference.BOSEconomy7.jar}:\ + ${file.reference.PermissionsEx.jar} # Space-separated list of extra javac options javac.compilerargs= javac.deprecation=false diff --git a/Essentials/src/com/earth2me/essentials/Essentials.java b/Essentials/src/com/earth2me/essentials/Essentials.java index 4a1562eaf..7f85ab2c3 100644 --- a/Essentials/src/com/earth2me/essentials/Essentials.java +++ b/Essentials/src/com/earth2me/essentials/Essentials.java @@ -143,32 +143,7 @@ public class Essentials extends JavaPlugin implements IEssentials LOGGER.log(Level.INFO, Util.i18n("bukkitFormatChanged")); } - final Plugin permissionsPlugin = pm.getPlugin("Permissions"); - - if (permissionsPlugin != null) - { - if (permissionsPlugin.getDescription().getVersion().charAt(0) == '3') - { - this.permissionsHandler = new Permissions3Handler(permissionsPlugin); - } - else - { - this.permissionsHandler = new Permissions2Handler(permissionsPlugin); - } - } - else - { - if (this.getSettings().useBukkitPermissions()) - { - this.permissionsHandler = new BukkitPermissionsHandler(); - } - else - { - this.permissionsHandler = new ConfigPermissionsHandler(this); - } - } - - final ServerListener serverListener = new EssentialsPluginListener(paymentMethod); + final ServerListener serverListener = new EssentialsPluginListener(this); pm.registerEvent(Type.PLUGIN_ENABLE, serverListener, Priority.Low, this); pm.registerEvent(Type.PLUGIN_DISABLE, serverListener, Priority.Low, this); @@ -663,6 +638,11 @@ public class Essentials extends JavaPlugin implements IEssentials { return permissionsHandler; } + + public void setPermissionsHandler(IPermissionsHandler handler) + { + this.permissionsHandler = handler; + } public BanWorkaround getBans() { diff --git a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java index 36654b91f..d6299f387 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java @@ -1,5 +1,8 @@ package com.earth2me.essentials; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.logging.Level; @@ -453,7 +456,8 @@ public class EssentialsPlayerListener extends PlayerListener } final User user = ess.getUser(event.getPlayer()); final String cmd = event.getMessage().toLowerCase().split(" ")[0].replace("/", "").toLowerCase(); - if (("msg".equals(cmd) || "r".equals(cmd) || "mail".equals(cmd))) + final List<String> commands = Arrays.asList("msg", "r", "mail", "m", "t", "emsg", "tell", "er", "reply", "ereply", "email"); + if (commands.contains(cmd)) { for (Player player : ess.getServer().getOnlinePlayers()) { diff --git a/Essentials/src/com/earth2me/essentials/EssentialsPluginListener.java b/Essentials/src/com/earth2me/essentials/EssentialsPluginListener.java index b3b5ff1c1..34632dd40 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsPluginListener.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsPluginListener.java @@ -6,40 +6,76 @@ import java.util.logging.Logger; import org.bukkit.event.server.PluginDisableEvent; import org.bukkit.event.server.PluginEnableEvent; import org.bukkit.event.server.ServerListener; +import org.bukkit.plugin.Plugin; +import org.bukkit.plugin.PluginManager; public class EssentialsPluginListener extends ServerListener { - private final Methods methods; - private static final Logger logger = Logger.getLogger("Minecraft"); + private final transient IEssentials ess; + private static final Logger LOGGER = Logger.getLogger("Minecraft"); - public EssentialsPluginListener(Methods methods) + public EssentialsPluginListener(final IEssentials ess) { - this.methods = methods; + this.ess = ess; } - + @Override - public void onPluginEnable(PluginEnableEvent event) + public void onPluginEnable(final PluginEnableEvent event) { - if (!methods.hasMethod()) + checkPermissions(); + if (!ess.getPaymentMethod().hasMethod() && ess.getPaymentMethod().setMethod(event.getPlugin())) { - if (methods.setMethod(event.getPlugin())) - { - logger.log(Level.INFO, "[Essentials] Payment method found (" + methods.getMethod().getName() + " version: " + methods.getMethod().getVersion() + ")"); - } + LOGGER.log(Level.INFO, "[Essentials] Payment method found (" + ess.getPaymentMethod().getMethod().getName() + " version: " + ess.getPaymentMethod().getMethod().getVersion() + ")"); + } } @Override public void onPluginDisable(PluginDisableEvent event) { + checkPermissions(); // Check to see if the plugin thats being disabled is the one we are using - if (methods != null && methods.hasMethod()) + if (ess.getPaymentMethod() != null && ess.getPaymentMethod().hasMethod() && ess.getPaymentMethod().checkDisabled(event.getPlugin())) { - if (methods.checkDisabled(event.getPlugin())) + LOGGER.log(Level.INFO, "[Essentials] Payment method was disabled. No longer accepting payments."); + } + } + + private void checkPermissions() + { + final PluginManager pm = ess.getServer().getPluginManager(); + final Plugin permissionsExPlugin = pm.getPlugin("PermissionsEx"); + + if (permissionsExPlugin == null || !permissionsExPlugin.isEnabled()) + { + final Plugin permissionsPlugin = pm.getPlugin("Permissions"); + if (permissionsPlugin == null || !permissionsPlugin.isEnabled()) { - logger.log(Level.INFO, "[Essentials] Payment method was disabled. No longer accepting payments."); + if (ess.getSettings().useBukkitPermissions()) + { + ess.setPermissionsHandler(new BukkitPermissionsHandler()); + } + else + { + ess.setPermissionsHandler(new ConfigPermissionsHandler(ess)); + } } + else + { + if (permissionsPlugin.getDescription().getVersion().charAt(0) == '3') + { + ess.setPermissionsHandler(new Permissions3Handler(permissionsPlugin)); + } + else + { + ess.setPermissionsHandler(new Permissions2Handler(permissionsPlugin)); + } + } + } + else + { + ess.setPermissionsHandler(new PermissionsExHandler()); } } } diff --git a/Essentials/src/com/earth2me/essentials/IEssentials.java b/Essentials/src/com/earth2me/essentials/IEssentials.java index b1c420e7d..f867daea8 100644 --- a/Essentials/src/com/earth2me/essentials/IEssentials.java +++ b/Essentials/src/com/earth2me/essentials/IEssentials.java @@ -59,9 +59,11 @@ public interface IEssentials extends Plugin IPermissionsHandler getPermissionsHandler(); + void setPermissionsHandler(IPermissionsHandler handler); + void showError(final CommandSender sender, final Throwable exception, final String commandLabel); Map<String, User> getAllUsers(); - + ItemDb getItemDb(); } diff --git a/Essentials/src/com/earth2me/essentials/PermissionsExHandler.java b/Essentials/src/com/earth2me/essentials/PermissionsExHandler.java new file mode 100644 index 000000000..f9151c77e --- /dev/null +++ b/Essentials/src/com/earth2me/essentials/PermissionsExHandler.java @@ -0,0 +1,74 @@ +package com.earth2me.essentials; + +import org.bukkit.entity.Player; +import ru.tehkode.permissions.PermissionManager; +import ru.tehkode.permissions.PermissionUser; +import ru.tehkode.permissions.bukkit.PermissionsEx; + + +class PermissionsExHandler implements IPermissionsHandler +{ + private final transient PermissionManager manager; + + public PermissionsExHandler() + { + manager = PermissionsEx.getPermissionManager(); + } + + public String getGroup(Player base) + { + final PermissionUser user = manager.getUser(base.getName()); + if (user == null) + { + return "default"; + } + return user.getGroupsNames()[0]; + } + + public boolean canBuild(Player base, String group) + { + final PermissionUser user = manager.getUser(base.getName()); + if (user == null) + { + return true; + } + + return user.getOptionBoolean("build", base.getWorld().getName(), true); + } + + public boolean inGroup(Player base, String group) + { + final PermissionUser user = manager.getUser(base.getName()); + if (user == null) + { + return false; + } + + return user.inGroup(group); + } + + public boolean hasPermission(Player base, String node) + { + return manager.has(base.getName(), node, base.getWorld().getName()); + } + + public String getPrefix(Player base) + { + final PermissionUser user = manager.getUser(base.getName()); + if (user == null) + { + return ""; + } + return user.getPrefix(); + } + + public String getSuffix(Player base) + { + final PermissionUser user = manager.getUser(base.getName()); + if (user == null) + { + return ""; + } + return user.getSuffix(); + } +} diff --git a/Essentials/src/com/earth2me/essentials/User.java b/Essentials/src/com/earth2me/essentials/User.java index bba843999..b1392a2e6 100644 --- a/Essentials/src/com/earth2me/essentials/User.java +++ b/Essentials/src/com/earth2me/essentials/User.java @@ -251,6 +251,10 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser nickname.insert(0, prefix); nickname.append(suffix); + if (suffix.length() < 2 || !suffix.substring(suffix.length() - 2, suffix.length() - 1).equals("§")) + { + nickname.append("§f"); + } return nickname.toString(); } diff --git a/Essentials/src/com/earth2me/essentials/Util.java b/Essentials/src/com/earth2me/essentials/Util.java index 2ba7f0eb7..97f051db4 100644 --- a/Essentials/src/com/earth2me/essentials/Util.java +++ b/Essentials/src/com/earth2me/essentials/Util.java @@ -218,7 +218,7 @@ public class Util public static Location getSafeDestination(Location loc) throws Exception { - if (loc == null) + if (loc == null || loc.getWorld() == null) { throw new Exception(Util.i18n("destinationNotSet")); } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandmsg.java b/Essentials/src/com/earth2me/essentials/commands/Commandmsg.java index 02b7a6c32..d6b77715f 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandmsg.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandmsg.java @@ -48,10 +48,25 @@ public class Commandmsg extends EssentialsCommand sender.sendMessage(Util.i18n("playerNotFound")); return; } + + int i = 0; + for (Player p : matches) + { + final User u = ess.getUser(p); + if (u.isHidden()) + { + i++; + } + } + if (i == matches.size()) + { + sender.sendMessage(Util.i18n("playerNotFound")); + return; + } charge(sender); for (Player p : matches) - { + { sender.sendMessage(Util.format("msgFormat", translatedMe, p.getDisplayName(), message)); final User u = ess.getUser(p); if (sender instanceof Player && (u.isIgnoredPlayer(((Player)sender).getName()) || u.isHidden())) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandmute.java b/Essentials/src/com/earth2me/essentials/commands/Commandmute.java index 8c8c2e6bf..c6022cc5c 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandmute.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandmute.java @@ -22,7 +22,7 @@ public class Commandmute extends EssentialsCommand }
User p = getPlayer(server, args, 0, true);
- if (p.isAuthorized("essentials.mute.exempt"))
+ if (!p.isMuted() && p.isAuthorized("essentials.mute.exempt"))
{
sender.sendMessage(Util.i18n("muteExempt"));
return;
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtime.java b/Essentials/src/com/earth2me/essentials/commands/Commandtime.java index 8ea14ae77..c823e84af 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtime.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtime.java @@ -33,7 +33,7 @@ public class Commandtime extends EssentialsCommand else { charge(user); - setPlayerTime(user, commandLabel); + setPlayerTime(user, args[0]); } } else diff --git a/Essentials/src/com/earth2me/essentials/commands/EssentialsCommand.java b/Essentials/src/com/earth2me/essentials/commands/EssentialsCommand.java index bb4087c92..459e48f8f 100644 --- a/Essentials/src/com/earth2me/essentials/commands/EssentialsCommand.java +++ b/Essentials/src/com/earth2me/essentials/commands/EssentialsCommand.java @@ -6,6 +6,7 @@ import org.bukkit.Server; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import com.earth2me.essentials.IEssentials; +import com.earth2me.essentials.OfflinePlayer; import org.bukkit.entity.Player; import com.earth2me.essentials.User; import com.earth2me.essentials.Util; @@ -44,7 +45,7 @@ public abstract class EssentialsCommand implements IEssentialsCommand User user = ess.getAllUsers().get(args[pos].toLowerCase()); if (user != null) { - if(!getOffline && user.isHidden()) + if(!getOffline && (user.getBase() instanceof OfflinePlayer || user.isHidden())) { throw new NoSuchFieldException(Util.i18n("playerNotFound")); } diff --git a/Essentials/src/com/earth2me/essentials/signs/SignBlockListener.java b/Essentials/src/com/earth2me/essentials/signs/SignBlockListener.java index 7574b7691..e772a5108 100644 --- a/Essentials/src/com/earth2me/essentials/signs/SignBlockListener.java +++ b/Essentials/src/com/earth2me/essentials/signs/SignBlockListener.java @@ -88,6 +88,14 @@ public class SignBlockListener extends BlockListener { return; } + User user = ess.getUser(event.getPlayer()); + if (user.isAuthorized("essentials.signs.color")) + { + for (int i = 0; i < 4; i++) + { + event.setLine(i, event.getLine(i).replaceAll("&([0-9a-f])", "§$1")); + } + } for (Signs signs : Signs.values()) { final EssentialsSign sign = signs.getSign(); @@ -103,14 +111,6 @@ public class SignBlockListener extends BlockListener return; } } - User user = ess.getUser(event.getPlayer()); - if (user.isAuthorized("essentials.signs.color")) - { - for (int i = 0; i < 4; i++) - { - event.setLine(i, event.getLine(i).replaceAll("&([0-9a-f])", "§$1")); - } - } } @Override diff --git a/Essentials/src/com/earth2me/essentials/signs/SignSpawnmob.java b/Essentials/src/com/earth2me/essentials/signs/SignSpawnmob.java new file mode 100644 index 000000000..071b61be1 --- /dev/null +++ b/Essentials/src/com/earth2me/essentials/signs/SignSpawnmob.java @@ -0,0 +1,47 @@ +package com.earth2me.essentials.signs; + +import com.earth2me.essentials.ChargeException; +import com.earth2me.essentials.IEssentials; +import com.earth2me.essentials.Trade; +import com.earth2me.essentials.User; +import com.earth2me.essentials.commands.Commandspawnmob; + + +public class SignSpawnmob extends EssentialsSign +{ + + public SignSpawnmob() + { + super("Spawnmob"); + } + + @Override + protected boolean onSignCreate(ISign sign, User player, String username, IEssentials ess) throws SignException, ChargeException + { + validateInteger(sign, 1); + validateTrade(sign, 3, ess); + return true; + } + + @Override + protected boolean onSignInteract(ISign sign, User player, String username, IEssentials ess) throws SignException, ChargeException + { + final Trade charge = getTrade(sign, 3, ess); + charge.isAffordableFor(player); + Commandspawnmob command = new Commandspawnmob(); + command.setEssentials(ess); + String[] args = new String[] { + sign.getLine(2), sign.getLine(1) + }; + try + { + command.run(ess.getServer(), player, "spawnmob", args); + } + catch (Exception ex) + { + throw new SignException(ex.getMessage(), ex); + } + charge.charge(player); + return true; + } +} diff --git a/Essentials/src/com/earth2me/essentials/signs/Signs.java b/Essentials/src/com/earth2me/essentials/signs/Signs.java index 18913ff10..53ed1d6b0 100644 --- a/Essentials/src/com/earth2me/essentials/signs/Signs.java +++ b/Essentials/src/com/earth2me/essentials/signs/Signs.java @@ -11,6 +11,7 @@ public enum Signs MAIL(new SignMail()), PROTECTION(new SignProtection()), SELL(new SignSell()), + SPAWNMOB(new SignSpawnmob()), TIME(new SignTime()), TRADE(new SignTrade()), WARP(new SignWarp()), diff --git a/Essentials/src/plugin.yml b/Essentials/src/plugin.yml index 26bcf5806..39dd25a45 100644 --- a/Essentials/src/plugin.yml +++ b/Essentials/src/plugin.yml @@ -179,7 +179,7 @@ commands: msg:
description: Sends a private message to the specified player.
usage: /<command> <to> <message>
- aliases: [m,t,emsg]
+ aliases: [m,t,emsg,tell]
mute:
description: Mutes or unmutes a player.
usage: /<command> [player] <datediff>
diff --git a/EssentialsChat/nbproject/project.properties b/EssentialsChat/nbproject/project.properties index 2e51b176b..08df72abc 100644 --- a/EssentialsChat/nbproject/project.properties +++ b/EssentialsChat/nbproject/project.properties @@ -27,13 +27,11 @@ dist.javadoc.dir=${dist.dir}/javadoc endorsed.classpath= excludes= file.reference.bukkit-0.0.1-SNAPSHOT.jar=../lib/bukkit-0.0.1-SNAPSHOT.jar -file.reference.Factions.jar=../lib/Factions.jar includes=** jar.compress=false javac.classpath=\ ${reference.Essentials.jar}:\ - ${file.reference.bukkit-0.0.1-SNAPSHOT.jar}:\ - ${file.reference.Factions.jar} + ${file.reference.bukkit-0.0.1-SNAPSHOT.jar} # Space-separated list of extra javac options javac.compilerargs= javac.deprecation=false diff --git a/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChat.java b/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChat.java index 4807ada0f..20b3756d0 100644 --- a/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChat.java +++ b/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChat.java @@ -22,8 +22,7 @@ public class EssentialsChat extends JavaPlugin final PluginManager pluginManager = getServer().getPluginManager(); final IEssentials ess = (IEssentials)pluginManager.getPlugin("Essentials"); - chatListener = new HashMap<String, IEssentialsChatListener>(); - //EssentialsChatPlayerListener.checkFactions(pluginManager); + chatListener = new HashMap<String, IEssentialsChatListener>(); final EssentialsChatPlayerListener playerListener = new EssentialsChatPlayerListener(getServer(), ess, chatListener); pluginManager.registerEvent(Type.PLAYER_CHAT, playerListener, Priority.Highest, this); diff --git a/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListener.java b/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListener.java index b38073909..c4874d631 100644 --- a/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListener.java +++ b/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListener.java @@ -100,7 +100,7 @@ public class EssentialsChatPlayerListener extends PlayerListener { continue; } - if (u.equals(user) && !u.isAuthorized("essentials.chat.spy")) + if (!u.equals(user) && !u.isAuthorized("essentials.chat.spy")) { final Location l = u.getLocation(); final int dx = Math.abs(x - l.getBlockX()); |