diff --git a/TwosideKeeper.jar b/TwosideKeeper.jar index 6d24f5e..992baed 100644 Binary files a/TwosideKeeper.jar and b/TwosideKeeper.jar differ diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/WorldShop.java b/src/sig/plugin/TwosideKeeper/HelperStructures/WorldShop.java index 6fbd7e7..6f1387e 100644 --- a/src/sig/plugin/TwosideKeeper/HelperStructures/WorldShop.java +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/WorldShop.java @@ -523,7 +523,8 @@ public class WorldShop { public static boolean isPurchaseShopSign(Sign s) { if (isWorldShopSign(s) && s.getLine(0).equalsIgnoreCase(ChatColor.BLUE+"- BUYING SHOP -") || - s.getLine(0).equalsIgnoreCase(ChatColor.YELLOW+""+ChatColor.BOLD+"-BUYING SHOP-")) { + s.getLine(0).equalsIgnoreCase(ChatColor.YELLOW+""+ChatColor.BOLD+"-BUYING SHOP-") || + s.getLine(0).equalsIgnoreCase(ChatColor.GREEN+""+ChatColor.BOLD+"-BUYING SHOP-")) { return true; } else { return false; @@ -533,7 +534,8 @@ public class WorldShop { public static boolean isWorldShopSign(Sign s) { if (s.getLine(0).equalsIgnoreCase(ChatColor.BLUE+"-- SHOP --") || s.getLine(0).equalsIgnoreCase(ChatColor.BLUE+"- BUYING SHOP -") || - s.getLine(0).equalsIgnoreCase(ChatColor.YELLOW+""+ChatColor.BOLD+"-BUYING SHOP-")) { + s.getLine(0).equalsIgnoreCase(ChatColor.YELLOW+""+ChatColor.BOLD+"-BUYING SHOP-") || + s.getLine(0).equalsIgnoreCase(ChatColor.GREEN+""+ChatColor.BOLD+"-BUYING SHOP-")) { return true; } else { return false; diff --git a/src/sig/plugin/TwosideKeeper/TwosideKeeper.java b/src/sig/plugin/TwosideKeeper/TwosideKeeper.java index 1c66ef6..0f25db8 100644 --- a/src/sig/plugin/TwosideKeeper/TwosideKeeper.java +++ b/src/sig/plugin/TwosideKeeper/TwosideKeeper.java @@ -1662,67 +1662,83 @@ public class TwosideKeeper extends JavaPlugin implements Listener { } //Now that we have the item cube. Dump whatever contents we can into the container. - //Get the inventory of the chest we are inserting into. - Chest c = (Chest)ev.getClickedBlock().getState(); - Inventory chest_inventory = c.getBlockInventory(); - if (c.getInventory().getHolder() instanceof DoubleChest) { - chest_inventory = ((DoubleChest)c.getInventory().getHolder()).getInventory(); - - log("This is a double chest",5); + //We need to make sure the chest is not a world shop. If it is, we can see if we're the owner of it. + boolean allowed=true; + String owner=""; + if (WorldShop.hasShopSignAttached(ev.getClickedBlock())) { + WorldShop s = TwosideShops.LoadWorldShopData(WorldShop.grabShopSign(ev.getClickedBlock().getLocation())); + if (!s.GetOwner().equalsIgnoreCase(ev.getPlayer().getName())) { + allowed=false; + owner=s.GetOwner(); + } } - //Get the inventory we are dumping out. - Inventory virtualinventory = ItemCube.getViewingItemCubeInventory(itemcube_id, ev.getPlayer()); - if (virtualinventory==null) { - //Then we will make one. - virtualinventory = Bukkit.createInventory(ev.getPlayer(), size); - //Load up this inventory. - List items = itemCube_loadConfig(itemcube_id); + if (allowed) { + //Get the inventory of the chest we are inserting into. + Chest c = (Chest)ev.getClickedBlock().getState(); + Inventory chest_inventory = c.getBlockInventory(); + if (c.getInventory().getHolder() instanceof DoubleChest) { + chest_inventory = ((DoubleChest)c.getInventory().getHolder()).getInventory(); + + log("This is a double chest",5); + } + + //Get the inventory we are dumping out. + Inventory virtualinventory = ItemCube.getViewingItemCubeInventory(itemcube_id, ev.getPlayer()); + if (virtualinventory==null) { + //Then we will make one. + virtualinventory = Bukkit.createInventory(ev.getPlayer(), size); + //Load up this inventory. + List items = itemCube_loadConfig(itemcube_id); + for (int i=0;i save_items = new ArrayList(); + + for (int i=0;i0) { + save_items.set(i,(ItemStack)result.get(0)); + fit=false; + log("This item "+(ItemStack)result.get(0)+" (slot "+i+") could not fit!",4); + } else { + count++; + } } } - } - List save_items = new ArrayList(); - - for (int i=0;i0) { - save_items.set(i,(ItemStack)result.get(0)); - fit=false; - log("This item "+(ItemStack)result.get(0)+" (slot "+i+") could not fit!",4); - } else { - count++; + + //The rest of the hashmap goes back in the original inventory. + if (!fit) { + ev.getPlayer().sendMessage(ChatColor.RED+"Attempted to store your items, not all of them could fit!"+ChatColor.WHITE+" Stored "+ChatColor.AQUA+count+ChatColor.WHITE+" items."); + } else { + if (count>0) { + ev.getPlayer().sendMessage("Stored "+ChatColor.AQUA+count+ChatColor.WHITE+" items inside the chest."); } } - } - - //The rest of the hashmap goes back in the original inventory. - if (!fit) { - ev.getPlayer().sendMessage(ChatColor.RED+"Attempted to store your items, not all of them could fit!"+ChatColor.WHITE+" Stored "+ChatColor.AQUA+count+ChatColor.WHITE+" items."); + virtualinventory.clear(); + + + //Save the Item Cube. + itemCube_saveConfig(itemcube_id,save_items); + //This may have been a shop. Update the shop too. + WorldShop.updateShopSign(ev.getClickedBlock().getLocation()); } else { - if (count>0) { - ev.getPlayer().sendMessage("Stored "+ChatColor.AQUA+count+ChatColor.WHITE+" items inside the chest."); - } + ev.getPlayer().sendMessage("This shop is owned by "+ChatColor.LIGHT_PURPLE+owner+ChatColor.WHITE+". You cannot dump item cubes into others' shops!"); + //ev.setCancelled(true); } - virtualinventory.clear(); - - - //Save the Item Cube. - itemCube_saveConfig(itemcube_id,save_items); - //This may have been a shop. Update the shop too. - WorldShop.updateShopSign(ev.getClickedBlock().getLocation()); } } if (b!=null && (b.getType() == Material.SIGN || @@ -1860,7 +1876,8 @@ public class TwosideKeeper extends JavaPlugin implements Listener { } } else if (s.getLine(0).equalsIgnoreCase(ChatColor.BLUE+"- BUYING SHOP -") || - s.getLine(0).equalsIgnoreCase(ChatColor.YELLOW+""+ChatColor.BOLD+"-BUYING SHOP-")) { + s.getLine(0).equalsIgnoreCase(ChatColor.YELLOW+""+ChatColor.BOLD+"-BUYING SHOP-") || + s.getLine(0).equalsIgnoreCase(ChatColor.GREEN+""+ChatColor.BOLD+"-BUYING SHOP-")) { //This is a buy shop. int shopID = TwosideShops.GetShopID(s); WorldShop shop = TwosideShops.LoadWorldShopData(shopID); @@ -3654,7 +3671,8 @@ public class TwosideKeeper extends JavaPlugin implements Listener { } } else if (s.getLine(0).equalsIgnoreCase(ChatColor.BLUE+"- BUYING SHOP -") || - s.getLine(0).equalsIgnoreCase(ChatColor.YELLOW+""+ChatColor.BOLD+"-BUYING SHOP-")) { + s.getLine(0).equalsIgnoreCase(ChatColor.YELLOW+""+ChatColor.BOLD+"-BUYING SHOP-") || + s.getLine(0).equalsIgnoreCase(ChatColor.GREEN+""+ChatColor.BOLD+"-BUYING SHOP-")) { //This is a shop. Let's find out who the owner is. int shopID = TwosideShops.GetShopID(s); WorldShop shop = TwosideShops.LoadWorldShopData(shopID); diff --git a/src/sig/plugin/TwosideKeeper/WorldShopManager.java b/src/sig/plugin/TwosideKeeper/WorldShopManager.java index be01bc3..df4ac22 100644 --- a/src/sig/plugin/TwosideKeeper/WorldShopManager.java +++ b/src/sig/plugin/TwosideKeeper/WorldShopManager.java @@ -66,7 +66,7 @@ public class WorldShopManager { //Create a shop out of this. if (purchaseshop) { if (shop.GetStoredAmount()>0) { - sign_lines.add(ChatColor.YELLOW+""+ChatColor.BOLD+"-BUYING SHOP-"); + sign_lines.add(ChatColor.GREEN+""+ChatColor.BOLD+"-BUYING SHOP-"); } else { sign_lines.add(ChatColor.BLUE+"- BUYING SHOP -"); } @@ -96,7 +96,7 @@ public class WorldShopManager { //Create a shop out of this. if (purchaseshop) { if (shop.GetStoredAmount()>0) { - sign_lines.add(ChatColor.YELLOW+""+ChatColor.BOLD+"-BUYING SHOP-"); + sign_lines.add(ChatColor.GREEN+""+ChatColor.BOLD+"-BUYING SHOP-"); } else { sign_lines.add(ChatColor.BLUE+"- BUYING SHOP -"); }