diff --git a/Essentials/src/com/earth2me/essentials/ISettings.java b/Essentials/src/com/earth2me/essentials/ISettings.java index d7764ed16..41e99c29c 100644 --- a/Essentials/src/com/earth2me/essentials/ISettings.java +++ b/Essentials/src/com/earth2me/essentials/ISettings.java @@ -140,4 +140,6 @@ public interface ISettings extends IConf boolean getUpdateBedAtDaytime(); boolean getRepairEnchanted(); + + boolean getIsWorldTeleportPermissions(); } diff --git a/Essentials/src/com/earth2me/essentials/Settings.java b/Essentials/src/com/earth2me/essentials/Settings.java index b65d53616..1683fd7ef 100644 --- a/Essentials/src/com/earth2me/essentials/Settings.java +++ b/Essentials/src/com/earth2me/essentials/Settings.java @@ -29,7 +29,7 @@ public class Settings implements ISettings { return config.getBoolean("respawn-at-home", false); } - + @Override public boolean getUpdateBedAtDaytime() { @@ -332,7 +332,7 @@ public class Settings implements ISettings public void reloadConfig() { config.load(); - noGodWorlds = new HashSet(config.getStringList("no-god-in-worlds",Collections.emptyList())); + noGodWorlds = new HashSet(config.getStringList("no-god-in-worlds", Collections.emptyList())); } @Override @@ -535,13 +535,12 @@ public class Settings implements ISettings { return config.getBoolean("death-messages", true); } - - Set noGodWorlds = new HashSet(); + Set noGodWorlds = new HashSet(); + @Override public Set getNoGodWorlds() { return noGodWorlds; - } @Override @@ -549,8 +548,16 @@ public class Settings implements ISettings { this.debug = debug; } - - public boolean getRepairEnchanted() { + + @Override + public boolean getRepairEnchanted() + { return config.getBoolean("repair-enchanted", true); } + + @Override + public boolean getIsWorldTeleportPermissions() + { + return config.getBoolean("world-teleport-permissions", false); + } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandbreak.java b/Essentials/src/com/earth2me/essentials/commands/Commandbreak.java new file mode 100644 index 000000000..7528d6068 --- /dev/null +++ b/Essentials/src/com/earth2me/essentials/commands/Commandbreak.java @@ -0,0 +1,40 @@ +package com.earth2me.essentials.commands; + +import com.earth2me.essentials.User; +import org.bukkit.Material; +import org.bukkit.Server; +import org.bukkit.block.Block; +import org.bukkit.event.block.BlockBreakEvent; + + +public class Commandbreak extends EssentialsCommand +{ + public Commandbreak() + { + super("break"); + } + + @Override + public void run(Server server, User user, String commandLabel, String[] args) throws Exception + { + Block block = user.getTargetBlock(null, 20); + if (block.getType() == Material.AIR) + { + throw new NoChargeException(); + } + if (block.getType() == Material.BEDROCK && !user.isAuthorized("essentials.break.bedrock")) + { + throw new NoChargeException(); + } + BlockBreakEvent event = new BlockBreakEvent(block, user); + server.getPluginManager().callEvent(event); + if (event.isCancelled()) + { + throw new NoChargeException(); + } + else + { + block.setType(Material.AIR); + } + } +} \ No newline at end of file diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandbutcher.java b/Essentials/src/com/earth2me/essentials/commands/Commandbutcher.java new file mode 100644 index 000000000..e127e197b --- /dev/null +++ b/Essentials/src/com/earth2me/essentials/commands/Commandbutcher.java @@ -0,0 +1,146 @@ +package com.earth2me.essentials.commands; + +import com.earth2me.essentials.Mob; +import static com.earth2me.essentials.I18n._; +import java.util.Collections; +import org.bukkit.Chunk; +import org.bukkit.Server; +import org.bukkit.World; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Animals; +import org.bukkit.entity.ComplexLivingEntity; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Flying; +import org.bukkit.entity.HumanEntity; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Monster; +import org.bukkit.entity.NPC; +import org.bukkit.entity.Player; +import org.bukkit.entity.Slime; +import org.bukkit.entity.Snowman; +import org.bukkit.entity.WaterMob; +import org.bukkit.entity.Wolf; +import org.bukkit.event.entity.EntityDeathEvent; + +public class Commandbutcher extends EssentialsCommand +{ + public Commandbutcher() + { + super("butcher"); + } + + @Override + public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception + { + String type = "all"; + int radius = -1; + World world; + if (sender instanceof Player) + { + world = ((Player)sender).getWorld(); + if (args.length == 1) + { + try + { + radius = Integer.parseInt(args[0]); + } + catch (NumberFormatException e1) + { + type = args[0]; + } + } + else if (args.length > 1) + { + type = args[0]; + try + { + radius = Integer.parseInt(args[1]); + } + catch (NumberFormatException e) + { + throw new Exception(_("numberRequired")); + } + } + } + else + { + if (args.length == 0) + { + throw new NotEnoughArgumentsException(); + } + else if (args.length == 1) + { + world = ess.getWorld(args[0]); + } + else + { + type = args[0]; + world = ess.getWorld(args[1]); + } + } + String killType = type.toLowerCase(); + int numKills = 0; + for (Chunk chunk : world.getLoadedChunks()) + { + for (Entity entity : chunk.getEntities()) + { + if (sender instanceof Player) + { + if (((Player)sender).getLocation().distance(entity.getLocation()) > radius && radius >= 0) + { + continue; + } + } + if (entity instanceof LivingEntity == false || entity instanceof HumanEntity) + { + continue; + } + if (entity instanceof Wolf) + { + if (((Wolf)entity).isTamed()) + { + continue; + } + } + if (killType.contains("animal")) + { + if (entity instanceof Animals || entity instanceof NPC || entity instanceof Snowman || entity instanceof WaterMob) + { + EntityDeathEvent event = new EntityDeathEvent(entity, Collections.EMPTY_LIST); + ess.getServer().getPluginManager().callEvent(event); + entity.remove(); + numKills++; + } + } + else if (killType.contains("monster")) + { + if (entity instanceof Monster || entity instanceof ComplexLivingEntity || entity instanceof Flying || entity instanceof Slime) + { + EntityDeathEvent event = new EntityDeathEvent(entity, Collections.EMPTY_LIST); + ess.getServer().getPluginManager().callEvent(event); + entity.remove(); + numKills++; + } + } + else if (killType.contains("all")) + { + EntityDeathEvent event = new EntityDeathEvent(entity, Collections.EMPTY_LIST); + ess.getServer().getPluginManager().callEvent(event); + entity.remove(); + numKills++; + } + else + { + if (Mob.fromName(killType).getType().getEntityClass().isAssignableFrom(entity.getClass())) + { + EntityDeathEvent event = new EntityDeathEvent(entity, Collections.EMPTY_LIST); + ess.getServer().getPluginManager().callEvent(event); + entity.remove(); + numKills++; + } + } + } + } + sender.sendMessage(_("kill", numKills)); + } +} \ No newline at end of file diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandfeed.java b/Essentials/src/com/earth2me/essentials/commands/Commandfeed.java new file mode 100644 index 000000000..ac3078309 --- /dev/null +++ b/Essentials/src/com/earth2me/essentials/commands/Commandfeed.java @@ -0,0 +1,37 @@ +package com.earth2me.essentials.commands; + +import com.earth2me.essentials.User; +import org.bukkit.Server; +import org.bukkit.entity.Player; + + +public class Commandfeed extends EssentialsCommand +{ + public Commandfeed() + { + super("feed"); + } + + @Override + protected void run(Server server, User user, String commandLabel, String[] args) throws Exception + { + if (args.length > 0) + { + Player player = ess.getServer().getPlayer(args[0]); + if (player != null) + { + player.setFoodLevel(20); + player.setSaturation(10); + } + else + { + throw new NotEnoughArgumentsException(); // TODO: Translate "Player not found" + } + } + else + { + user.setFoodLevel(20); + user.setSaturation(10); // 10 because 20 seems way overpowered + } + } +} diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandmore.java b/Essentials/src/com/earth2me/essentials/commands/Commandmore.java new file mode 100644 index 000000000..3bf5d4187 --- /dev/null +++ b/Essentials/src/com/earth2me/essentials/commands/Commandmore.java @@ -0,0 +1,50 @@ +package com.earth2me.essentials.commands; + +import com.earth2me.essentials.User; +import static com.earth2me.essentials.I18n._; +import java.util.Locale; +import org.bukkit.Server; +import org.bukkit.inventory.ItemStack; + + +public class Commandmore extends EssentialsCommand +{ + public Commandmore() + { + super("more"); + } + + @Override + public void run(Server server, User user, String commandLabel, String[] args) throws Exception + { + ItemStack stack = user.getItemInHand(); + if (stack == null) + { + throw new Exception(_("cantSpawnItem", "Air")); + } + if (stack.getAmount() >= ((user.isAuthorized("essentials.oversizedstacks")) + ? ess.getSettings().getOversizedStackSize() : stack.getMaxStackSize())) + { + throw new NoChargeException(); + } + final String itemname = stack.getType().toString().toLowerCase(Locale.ENGLISH).replace("_", ""); + if (ess.getSettings().permissionBasedItemSpawn() + ? (!user.isAuthorized("essentials.itemspawn.item-all") + && !user.isAuthorized("essentials.itemspawn.item-" + itemname) + && !user.isAuthorized("essentials.itemspawn.item-" + stack.getTypeId())) + : (!user.isAuthorized("essentials.itemspawn.exempt") + && !user.canSpawnItem(stack.getTypeId()))) + { + throw new Exception(_("cantSpawnItem", itemname)); + } + if (user.isAuthorized("essentials.oversizedstacks")) + { + stack.setAmount(ess.getSettings().getOversizedStackSize()); + } + else + { + stack.setAmount(stack.getMaxStackSize()); + } + user.updateInventory(); + } +} \ No newline at end of file diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandremove.java b/Essentials/src/com/earth2me/essentials/commands/Commandremove.java new file mode 100644 index 000000000..3839ee81d --- /dev/null +++ b/Essentials/src/com/earth2me/essentials/commands/Commandremove.java @@ -0,0 +1,138 @@ +package com.earth2me.essentials.commands; + +import java.util.Locale; +import static com.earth2me.essentials.I18n._; +import org.bukkit.Chunk; +import org.bukkit.Server; +import org.bukkit.World; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Boat; +import org.bukkit.entity.Entity; +import org.bukkit.entity.ExperienceOrb; +import org.bukkit.entity.Item; +import org.bukkit.entity.Minecart; +import org.bukkit.entity.Painting; +import org.bukkit.entity.Player; +import org.bukkit.entity.Projectile; + + +public class Commandremove extends EssentialsCommand +{ + public Commandremove() + { + super("remove"); + } + + private enum ToRemove + { + DROPS, + ARROWS, + BOATS, + MINECARTS, + XP, + PAINTINGS + } + + @Override + protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception + { + if (args.length < 2) + { + throw new NotEnoughArgumentsException(); + } + World world; + int radius = -1; + if (sender instanceof Player) + { + world = ((Player)sender).getWorld(); + try + { + radius = Integer.parseInt(args[1]); + } + catch (NumberFormatException e) + { + throw new Exception(_("numberRequired")); + } + } + else + { + world = ess.getWorld(args[1]); + } + if (world == null) + { + throw new Exception(_("invalidWorld")); + } + ToRemove toRemove; + try + { + toRemove = ToRemove.valueOf(args[0].toUpperCase(Locale.ENGLISH)); + } + catch (IllegalArgumentException e) + { + throw new NotEnoughArgumentsException(); //TODO: translate and list types + } + int removed = 0; + for (Chunk chunk : world.getLoadedChunks()) + { + for (Entity e : chunk.getEntities()) + { + if (sender instanceof Player) + { + if (((Player)sender).getLocation().distance(e.getLocation()) > radius && radius >= 0) + { + continue; + } + } + if (toRemove == ToRemove.DROPS) + { + if (e instanceof Item) + { + e.remove(); + removed++; + } + } + else if (toRemove == ToRemove.ARROWS) + { + if (e instanceof Projectile) + { + e.remove(); + removed++; + } + } + else if (toRemove == ToRemove.BOATS) + { + if (e instanceof Boat) + { + e.remove(); + removed++; + } + } + else if (toRemove == ToRemove.DROPS) + { + if (e instanceof Minecart) + { + e.remove(); + removed++; + } + } + else if (toRemove == ToRemove.XP) + { + if (e instanceof ExperienceOrb) + { + e.remove(); + removed++; + } + } + else if (toRemove == ToRemove.PAINTINGS) + { + if (e instanceof Painting) + { + e.remove(); + removed++; + } + } + } + } + sender.sendMessage(_("kill", removed)); + } +} diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandworld.java b/Essentials/src/com/earth2me/essentials/commands/Commandworld.java index 7380b23ae..b62276cf8 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandworld.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandworld.java @@ -53,6 +53,15 @@ public class Commandworld extends EssentialsCommand } } + if (ess.getSettings().getIsWorldTeleportPermissions()) + { + if (!user.isAuthorized("essentials.world." + world.getName())) + { + user.sendMessage(_("invalidWorld")); //TODO: Make a "world teleport denied" translation + throw new NoChargeException(); + } + } + double factor; if (user.getWorld().getEnvironment() == World.Environment.NETHER && world.getEnvironment() == World.Environment.NORMAL) { diff --git a/Essentials/src/config.yml b/Essentials/src/config.yml index 2f43cde1e..2bb8dbd0c 100644 --- a/Essentials/src/config.yml +++ b/Essentials/src/config.yml @@ -220,6 +220,10 @@ death-messages: true no-god-in-worlds: # - world_nether +# Set to true to enable per-world permissions for teleporting with /world +# Give someone permission to teleport to a world with essentials.world. +world-teleport-permissions: false + # Oversized stacks are stacks that ignore the normal max stacksize. # They can be obtained using /give and /item, if the player has essentials.oversizedstacks permission. # How many items should be in a oversized stack? diff --git a/Essentials/src/plugin.yml b/Essentials/src/plugin.yml index f4805324c..efeaf2648 100644 --- a/Essentials/src/plugin.yml +++ b/Essentials/src/plugin.yml @@ -39,6 +39,10 @@ commands: description: Bans an IP address. usage: /
aliases: [ebanip] + break: + description: Breaks the block you are looking at. + usage: / + aliases: [ebreak] broadcast: description: Broadcasts a message to the entire server. usage: / @@ -51,6 +55,10 @@ commands: description: Set a player on fire. usage: / aliases: [eburn] + butcher: + description: Kill all mobs in a world. + usage: / + aliases: [ebutcher] clearinventory: description: Clear all items in your inventory. usage: / @@ -90,6 +98,10 @@ commands: description: Extinguish players. usage: / [player] aliases: [extinguish,eext,eextinguish] + feed: + description: Shove food down someone's throat. + usage: / + aliases: [efeed] fireball: description: Throw a fireball. usage: / [small] @@ -186,6 +198,10 @@ commands: description: Describes an action in the context of the player. usage: / aliases: [action,describe,eme,eaction,edescribe] + more: + description: Fills the item stack in hand to maximum size. + usage: / + aliases: [emore] motd: description: Views the Message Of The Day. usage: / @@ -238,6 +254,10 @@ commands: description: Displays the username of a user based on nickname. usage: / aliases: [erealname] + remove: + description: Removes entities in your world + usage: / + aliases: [eremove] repair: description: Repairs the durability of all or one item. usage: / @@ -393,4 +413,4 @@ commands: worth: description: Calculates the worth of items in hand or as specified. usage: / [item] [amount] - aliases: [eworth] \ No newline at end of file + aliases: [eworth]