summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsnowleo <snowleo@e251c2fe-e539-e718-e476-b85c1f46cddb>2011-03-30 13:31:01 +0000
committersnowleo <snowleo@e251c2fe-e539-e718-e476-b85c1f46cddb>2011-03-30 13:31:01 +0000
commit357c1b75ff36990a1200bf98af6c8831d2b7a239 (patch)
tree5784e6c1673e38e209d44df8a29afd736cfad7e9
parent903ccfc7988abd4aa2cc87844a88a912cd44f6c0 (diff)
downloadEssentials-357c1b75ff36990a1200bf98af6c8831d2b7a239.tar
Essentials-357c1b75ff36990a1200bf98af6c8831d2b7a239.tar.gz
Essentials-357c1b75ff36990a1200bf98af6c8831d2b7a239.tar.lz
Essentials-357c1b75ff36990a1200bf98af6c8831d2b7a239.tar.xz
Essentials-357c1b75ff36990a1200bf98af6c8831d2b7a239.zip
Commit 994 996
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1028 e251c2fe-e539-e718-e476-b85c1f46cddb
-rw-r--r--Essentials/src/com/earth2me/essentials/EssentialsBlockListener.java104
1 files changed, 101 insertions, 3 deletions
diff --git a/Essentials/src/com/earth2me/essentials/EssentialsBlockListener.java b/Essentials/src/com/earth2me/essentials/EssentialsBlockListener.java
index ae480f16b..494b298ba 100644
--- a/Essentials/src/com/earth2me/essentials/EssentialsBlockListener.java
+++ b/Essentials/src/com/earth2me/essentials/EssentialsBlockListener.java
@@ -6,6 +6,7 @@ import net.minecraft.server.InventoryPlayer;
import org.bukkit.*;
import org.bukkit.block.*;
import org.bukkit.craftbukkit.block.CraftSign;
+import org.bukkit.craftbukkit.inventory.CraftInventory;
import org.bukkit.craftbukkit.inventory.CraftInventoryPlayer;
import org.bukkit.entity.Player;
import org.bukkit.event.block.*;
@@ -81,10 +82,18 @@ public class EssentialsBlockListener extends BlockListener
}
if (event.getLine(0).equalsIgnoreCase("[Heal]"))
{
- if (user.isAuthorized("essentials.signs.heal.create"))
+ event.setLine(0, "§4[Heal]");
+ if (user.isAuthorized("essentials.signs.heal.create")) {
+ if (!event.getLine(1).isEmpty()) {
+ String[] l1 = event.getLine(1).split("[ :-]+");
+ boolean m1 = l1[0].matches("\\$[0-9]+");
+ int q1 = Integer.parseInt(m1 ? l1[0].substring(1) : l1[0]);
+ if (q1 < 1) throw new Exception("Quantities must be greater than 0.");
+ if (!m1) ItemDb.get(l1[1]);
+ event.setLine(1, (m1 ? "$" + q1 : q1 + " " + l1[1]));
+ }
event.setLine(0, "§1[Heal]");
- else
- event.setLine(0, "§4[Heal]");
+ }
return;
}
if (event.getLine(0).equalsIgnoreCase("[Free]"))
@@ -104,6 +113,95 @@ public class EssentialsBlockListener extends BlockListener
event.setLine(0, "§4[Mail]");
return;
}
+ if (event.getLine(0).equalsIgnoreCase("[Balance]"))
+ {
+ if (user.isAuthorized("essentials.signs.balance.create"))
+
+ event.setLine(0, "§1[Balance]");
+ else
+ event.setLine(0, "§4[Balance]");
+ return;
+ }
+ }
+ catch (Throwable ex)
+ {
+ user.sendMessage("§cError: " + ex.getMessage());
+ }
+ }
+
+ @Override
+ public void onBlockRightClick(BlockRightClickEvent event)
+ {
+ User user = User.get(event.getPlayer());
+ if (user.isJailed()) return;
+ if (Essentials.getSettings().areSignsDisabled()) return;
+ if (event.getBlock().getType() != Material.WALL_SIGN && event.getBlock().getType() != Material.SIGN_POST)
+ return;
+ Sign sign = new CraftSign(event.getBlock());
+
+ try
+ {
+ if (sign.getLine(0).equals("§1[Free]") && user.isAuthorized("essentials.signs.free.use"))
+ {
+ ItemStack item = ItemDb.get(sign.getLine(1));
+ CraftInventoryPlayer inv = new CraftInventoryPlayer(new InventoryPlayer(user.getHandle()));
+ inv.clear();
+ item.setAmount(9 * 4 * 64);
+ inv.addItem(item);
+ user.showInventory(inv);
+ return;
+ }
+ if (sign.getLine(0).equals("§1[Disposal]") && user.isAuthorized("essentials.signs.disposal.use"))
+ {
+ CraftInventoryPlayer inv = new CraftInventoryPlayer(new InventoryPlayer(user.getHandle()));
+ inv.clear();
+ user.showInventory(inv);
+ return;
+ }
+ if (sign.getLine(0).equals("§1[Heal]") && user.isAuthorized("essentials.signs.heal.use"))
+ {
+ if (!sign.getLine(1).isEmpty()) {
+ String[] l1 = sign.getLine(1).split("[ :-]+");
+ boolean m1 = l1[0].matches("\\$[0-9]+");
+ int q1 = Integer.parseInt(m1 ? l1[0].substring(1) : l1[0]);
+ if (q1 < 1) throw new Exception("Quantities must be greater than 0.");
+ if (m1)
+ {
+ if (user.getMoney() < q1) throw
+ new Exception("You do not have sufficient funds.");
+ user.takeMoney(q1);
+ user.sendMessage("$" + q1 + " taken from your bank account.");
+ }
+ else
+ {
+ ItemStack i = ItemDb.get(l1[1], q1);
+ if (!InventoryWorkaround.containsItem((CraftInventory)user.getInventory(), true, i))
+ throw new Exception("You do not have " + q1 + "x " + l1[1] + ".");
+ InventoryWorkaround.removeItem((CraftInventory)user.getInventory(), true, i);
+ user.updateInventory();
+ }
+ }
+ user.setHealth(20);
+ user.sendMessage("§7You have been healed.");
+ return;
+ }
+ if (sign.getLine(0).equals("§1[Mail]") && user.isAuthorized("essentials.signs.mail.use") && user.isAuthorized("essentials.mail"))
+ {
+ List<String> mail = Essentials.readMail(user);
+ if (mail.isEmpty())
+ {
+ user.sendMessage("§cYou do not have any mail!");
+ return;
+ }
+ for (String s : mail) user.sendMessage(s);
+ user.sendMessage("§cTo mark your mail as read, type §c/mail clear");
+ return;
+ }
+ if (sign.getLine(0).equals("§1[Balance]") && user.isAuthorized("essentials.signs.balance.use"))
+ {
+ user.sendMessage("§7Balance: $" + user.getMoney());
+ return;
+ }
}
catch (Throwable ex)
{