diff options
5 files changed, 68 insertions, 21 deletions
diff --git a/Essentials/src/com/earth2me/essentials/Essentials.java b/Essentials/src/com/earth2me/essentials/Essentials.java index c390e8e7a..4be868d4c 100644 --- a/Essentials/src/com/earth2me/essentials/Essentials.java +++ b/Essentials/src/com/earth2me/essentials/Essentials.java @@ -47,6 +47,8 @@ import org.bukkit.World; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.command.PluginCommand; +import org.bukkit.command.SimpleCommandMap; +import org.bukkit.command.defaults.VanillaCommand; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -85,6 +87,7 @@ public class Essentials extends JavaPlugin implements IEssentials private transient Metrics metrics; private transient EssentialsTimer timer; private transient List<String> vanishedPlayers = new ArrayList<String>(); + private transient SimpleCommandMap scm; @Override public ISettings getSettings() @@ -123,6 +126,7 @@ public class Essentials extends JavaPlugin implements IEssentials i18n = new I18n(this); i18n.onEnable(); execTimer.mark("I18n1"); + scm = new SimpleCommandMap(this.getServer()); final PluginManager pm = getServer().getPluginManager(); for (Plugin plugin : pm.getPlugins()) { @@ -210,7 +214,7 @@ public class Essentials extends JavaPlugin implements IEssentials backup = new Backup(this); permissionsHandler = new PermissionsHandler(this, settings.useBukkitPermissions()); alternativeCommandsHandler = new AlternativeCommandsHandler(this); - + timer = new EssentialsTimer(this); getScheduler().scheduleSyncRepeatingTask(this, timer, 100, 100); @@ -234,15 +238,16 @@ public class Essentials extends JavaPlugin implements IEssentials LOGGER.log(Level.INFO, "Essentials load " + timeroutput); } } - - private void registerListeners(PluginManager pm) { + + private void registerListeners(PluginManager pm) + { HandlerList.unregisterAll(this); - + if (getSettings().isDebug()) { LOGGER.log(Level.INFO, "Registering Listeners"); } - + final EssentialsPluginListener serverListener = new EssentialsPluginListener(this); pm.registerEvents(serverListener, this); confList.add(serverListener); @@ -267,10 +272,10 @@ public class Essentials extends JavaPlugin implements IEssentials final EssentialsWorldListener worldListener = new EssentialsWorldListener(this); pm.registerEvents(worldListener, this); - + pm.registerEvents(tntListener, this); - - jails.resetListener(); + + jails.resetListener(); } @Override @@ -302,7 +307,7 @@ public class Essentials extends JavaPlugin implements IEssentials } i18n.updateLocale(settings.getLocale()); - + final PluginManager pm = getServer().getPluginManager(); registerListeners(pm); } @@ -357,6 +362,16 @@ public class Essentials extends JavaPlugin implements IEssentials // Check for disabled commands if (getSettings().isCommandDisabled(commandLabel)) { + if (scm != null) + { + for (VanillaCommand cmd : scm.getFallbackCommands()) + { + if (cmd.matches(commandLabel)) + { + cmd.execute(sender, commandLabel, args); + } + } + } return true; } diff --git a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java index 9232ce1a0..47672288d 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java @@ -425,10 +425,14 @@ public class EssentialsPlayerListener implements Listener user.sendMessage(_("noGodWorldWarning")); } - if (!event.getPlayer().getWorld().getName().equals(newWorld)) + if (!user.getWorld().getName().equals(newWorld)) { user.sendMessage(_("currentWorld", newWorld)); } + if (user.isVanished()) + { + user.setVanished(user.isAuthorized("essentials.vanish")); + } } @EventHandler(priority = EventPriority.NORMAL) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandfirework.java b/Essentials/src/com/earth2me/essentials/commands/Commandfirework.java index a9ad48dbb..5a3ad502d 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandfirework.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandfirework.java @@ -3,6 +3,7 @@ package com.earth2me.essentials.commands; import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.MetaItemStack; import com.earth2me.essentials.User; +import com.earth2me.essentials.Util; import java.util.HashMap; import java.util.Map; import java.util.regex.Pattern; @@ -14,7 +15,23 @@ import org.bukkit.entity.EntityType; import org.bukkit.entity.Firework; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.FireworkMeta; +import org.bukkit.util.Vector; +//This command has quite a complicated syntax, in theory it has 4 seperate syntaxes which are all variable: +// +//1: /firework clear - This clears all of the effects on a firework stack +// +//2: /firework power <int> - This changes the base power of a firework +// +//3: /firework fire - This 'fires' a copy of the firework held. +//3: /firework fire <int> - This 'fires' a number of copies of the firework held. +//3: /firework fire <other> - This 'fires' a copy of the firework held, in the direction you are looking, #easteregg +// +//4: /firework [meta] - This will add an effect to the firework stack held +//4: /firework color:<color> - The minimum you need to set an effect is 'color' +//4: Full Syntax: color:<color[,color,..]> [fade:<color[,color,..]>] [shape:<shape>] [effect:<effect[,effect]>] +//4: Possible Shapes: star, ball, large, creeper, burst +//4: Possible Effects trail, twinkle public class Commandfirework extends EssentialsCommand { @@ -71,8 +88,9 @@ public class Commandfirework extends EssentialsCommand else if ((args[0].equalsIgnoreCase("fire") || (args[0].equalsIgnoreCase("p"))) && user.isAuthorized("essentials.firework.fire")) { - int amount; - try + int amount = 1; + boolean direction = false; + if (Util.isInt(args[1])) { final int serverLimit = ess.getSettings().getSpawnMobLimit(); amount = Integer.parseInt(args[1]); @@ -82,14 +100,23 @@ public class Commandfirework extends EssentialsCommand user.sendMessage(_("mobSpawnLimit")); } } - catch (Exception e) + else { - amount = 1; + direction = true; } for (int i = 0; i < amount; i++) { Firework firework = (Firework)user.getWorld().spawnEntity(user.getLocation(), EntityType.FIREWORK); FireworkMeta fmeta = (FireworkMeta)stack.getItemMeta(); + if (direction) + { + final Vector vector = user.getEyeLocation().getDirection().multiply(0.075); + if (fmeta.getPower() > 1) + { + fmeta.setPower(1); + } + firework.setVelocity(vector); + } firework.setFireworkMeta(fmeta); } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandheal.java b/Essentials/src/com/earth2me/essentials/commands/Commandheal.java index 224e782de..23a8078b1 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandheal.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandheal.java @@ -68,14 +68,15 @@ public class Commandheal extends EssentialsCommand } } - private void healPlayer(final Player p) + private void healPlayer(final Player player) { - p.setHealth(20); - p.setFoodLevel(20); - p.sendMessage(_("heal")); - for (PotionEffect effect : p.getActivePotionEffects()) + player.setHealth(player.getMaxHealth()); + player.setFoodLevel(20); + player.setFireTicks(0); + player.sendMessage(_("heal")); + for (PotionEffect effect : player.getActivePotionEffects()) { - p.removePotionEffect(effect.getType()); + player.removePotionEffect(effect.getType()); } } } diff --git a/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListenerHighest.java b/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListenerHighest.java index db728bd09..9af8cf593 100644 --- a/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListenerHighest.java +++ b/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListenerHighest.java @@ -23,7 +23,7 @@ public class EssentialsChatPlayerListenerHighest extends EssentialsChatPlayer public void onPlayerChat(final AsyncPlayerChatEvent event) { final ChatStore chatStore = delChatStore(event); - if (isAborted(event)) + if (isAborted(event) || chatStore == null) { return; } |