diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandbigtree.java b/Essentials/src/com/earth2me/essentials/commands/Commandbigtree.java index f02b99b15..8370896b1 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandbigtree.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandbigtree.java @@ -1,5 +1,6 @@ package com.earth2me.essentials.commands; +import com.earth2me.essentials.TargetBlock; import org.bukkit.Server; import org.bukkit.TreeType; import com.earth2me.essentials.User; @@ -31,30 +32,12 @@ public class Commandbigtree extends EssentialsCommand throw new NotEnoughArgumentsException(); } - double x = user.getLocation().getX(); - double y = user.getLocation().getY(); - double z = user.getLocation().getZ(); - - // offset tree in direction player is facing - final int r = (int)user.getCorrectedYaw(); - if (r < 68 || r > 292) // north + final int[] ignore = { - x -= 3.0D; - } - else if (r > 112 && r < 248) // south - { - x += 3.0D; - } - if (r > 22 && r < 158) // east - { - z -= 3.0D; - } - else if (r > 202 && r < 338) // west - { - z += 3.0D; - } - - final Location safeLocation = Util.getSafeDestination(new Location(user.getWorld(), x, y, z)); + 8, 9 + }; + final Location loc = (new TargetBlock(user, 300, 0.2, ignore)).getTargetBlock().getLocation(); + final Location safeLocation = Util.getSafeDestination(loc); final boolean success = user.getWorld().generateTree(safeLocation, (TreeType)tree); if (success) { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandgive.java b/Essentials/src/com/earth2me/essentials/commands/Commandgive.java index 21eea2c70..68bfe8a30 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandgive.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandgive.java @@ -16,6 +16,7 @@ public class Commandgive extends EssentialsCommand super("give"); } + //TODO: move these messages to message file @Override public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandlist.java b/Essentials/src/com/earth2me/essentials/commands/Commandlist.java index d5f946bf9..ef7d6e9f8 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandlist.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandlist.java @@ -45,6 +45,7 @@ public class Commandlist extends EssentialsCommand } } charge(sender); + //TODO: move these to messages file StringBuilder online = new StringBuilder(); online.append(ChatColor.BLUE).append("There are ").append(ChatColor.RED).append(server.getOnlinePlayers().length - playerHidden); if (showhidden && playerHidden > 0) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java b/Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java index 188edab27..9514bc767 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java @@ -83,17 +83,10 @@ public class Commandspawnmob extends EssentialsCommand 8, 9 }; Location loc = (new TargetBlock(user, 300, 0.2, ignore)).getTargetBlock().getLocation(); - - Block block = user.getWorld().getBlockAt(loc); - while (!(block.getType() == Material.AIR || block.getType() == Material.WATER || block.getType() == Material.STATIONARY_WATER)) - { - loc.setY(loc.getY() + 1); - block = user.getWorld().getBlockAt(loc); - } - + Location sloc = Util.getSafeDestination(loc); try { - spawnedMob = mob.spawn(user, server, loc); + spawnedMob = mob.spawn(user, server, sloc); } catch (MobException e) { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtogglejail.java b/Essentials/src/com/earth2me/essentials/commands/Commandtogglejail.java index c88cdc5a6..75abda4bb 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtogglejail.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtogglejail.java @@ -15,6 +15,7 @@ public class Commandtogglejail extends EssentialsCommand super("togglejail"); } + //TODO: move these to messages file @Override public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtree.java b/Essentials/src/com/earth2me/essentials/commands/Commandtree.java index 8e3b567b4..81be2a329 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtree.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtree.java @@ -1,10 +1,13 @@ package com.earth2me.essentials.commands; +import com.earth2me.essentials.TargetBlock; import org.bukkit.Location; import org.bukkit.Server; import org.bukkit.TreeType; import com.earth2me.essentials.User; import com.earth2me.essentials.Util; +import org.bukkit.Material; +import org.bukkit.block.Block; public class Commandtree extends EssentialsCommand @@ -38,32 +41,14 @@ public class Commandtree extends EssentialsCommand { throw new NotEnoughArgumentsException(); } - - double x = user.getLocation().getX(); - double y = user.getLocation().getY(); - double z = user.getLocation().getZ(); - - // offset tree in direction player is facing - int r = (int)user.getCorrectedYaw(); - if (r < 68 || r > 292) // north + + final int[] ignore = { - x -= 3.0D; - } - else if (r > 112 && r < 248) // south - { - x += 3.0D; - } - if (r > 22 && r < 158) // east - { - z -= 3.0D; - } - else if (r > 202 && r < 338) // west - { - z += 3.0D; - } - - Location safeLocation = Util.getSafeDestination(new Location(user.getWorld(), x, y, z)); - boolean success = user.getWorld().generateTree(safeLocation, (TreeType)tree); + 8, 9 + }; + final Location loc = (new TargetBlock(user, 300, 0.2, ignore)).getTargetBlock().getLocation(); + final Location safeLocation = Util.getSafeDestination(loc); + final boolean success = user.getWorld().generateTree(safeLocation, (TreeType)tree); if (success) { charge(user); diff --git a/Essentials/src/com/earth2me/essentials/signs/SignProtection.java b/Essentials/src/com/earth2me/essentials/signs/SignProtection.java index 99aa62434..c595d9b03 100644 --- a/Essentials/src/com/earth2me/essentials/signs/SignProtection.java +++ b/Essentials/src/com/earth2me/essentials/signs/SignProtection.java @@ -41,6 +41,7 @@ public class SignProtection extends EssentialsSign sign.setLine(3, "§1" + username); return true; } + //TODO: move to messages player.sendMessage("§4You are not allowed to create sign here."); return false; } diff --git a/Essentials/src/com/earth2me/essentials/signs/SignTrade.java b/Essentials/src/com/earth2me/essentials/signs/SignTrade.java index a1a066088..bf85d827c 100644 --- a/Essentials/src/com/earth2me/essentials/signs/SignTrade.java +++ b/Essentials/src/com/earth2me/essentials/signs/SignTrade.java @@ -21,7 +21,7 @@ public class SignTrade extends EssentialsSign { validateTrade(sign, 1, false, ess); validateTrade(sign, 2, true, ess); - final Trade charge = getTrade(sign, 2, true, false, ess); + final Trade charge = getTrade(sign, 2, true, true, ess); charge.isAffordableFor(player); sign.setLine(3, "§8" + username); charge.charge(player);