--- miscJava/bukkit-minecraft-plugins/HoerupUtils/src/main/java/dk/thoerup/bukkit/hoeruputils/SnitchingChest.java 2012/04/03 20:23:59 1769 +++ miscJava/bukkit-minecraft-plugins/HoerupUtils/src/main/java/dk/thoerup/bukkit/hoeruputils/SnitchingChest.java 2012/04/03 20:30:41 1770 @@ -8,6 +8,8 @@ import org.bukkit.Location; import org.bukkit.Material; +import org.bukkit.OfflinePlayer; +import org.bukkit.Server; import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.block.Chest; @@ -23,7 +25,7 @@ import org.bukkit.event.inventory.InventoryOpenEvent; import org.bukkit.inventory.InventoryHolder; import org.bukkit.inventory.ItemStack; -import org.bukkit.plugin.Plugin; + public class SnitchingChest implements Listener, CommandExecutor{ @@ -36,10 +38,12 @@ HashMap chestMap = new HashMap(); - Plugin plugin; + HoerupUtilsPlugin plugin; + Server server; - public SnitchingChest(Plugin plugin) { + public SnitchingChest(HoerupUtilsPlugin plugin) { this.plugin = plugin; + server = plugin.getServer(); loadChests(); } @@ -188,7 +192,8 @@ InventoryHolder holder = event.getInventory().getHolder(); if (holder instanceof Chest || holder instanceof DoubleChest) { Location loc = getChestLocation(holder); - String owner = chestMap.get(loc); + String ownerName = chestMap.get(loc); + OfflinePlayer owner = server.getOfflinePlayer(ownerName); Player player = (Player) event.getPlayer(); @@ -221,10 +226,12 @@ if (count > savedcount) { String msg = player.getName() + " added " + diff + " units of " + item + " to " + owner + "'s chest"; plugin.getLogger().info(msg); + plugin.getMessageWrapper().sendMessage(owner, msg); } if (count < savedcount) { String msg = player.getName() + " removed " + diff + " units of " + item + " from " + owner + "'s chest"; plugin.getLogger().info(msg); + plugin.getMessageWrapper().sendMessage(owner, msg); } }