Players cannot unload Item Cubes into others' shops.

This commit is contained in:
sigonasr2 2016-07-08 17:59:54 -05:00
parent 7cecc25c05
commit 6cc89d3426
4 changed files with 78 additions and 58 deletions

Binary file not shown.

View File

@ -523,7 +523,8 @@ public class WorldShop {
public static boolean isPurchaseShopSign(Sign s) { public static boolean isPurchaseShopSign(Sign s) {
if (isWorldShopSign(s) && if (isWorldShopSign(s) &&
s.getLine(0).equalsIgnoreCase(ChatColor.BLUE+"- BUYING 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; return true;
} else { } else {
return false; return false;
@ -533,7 +534,8 @@ public class WorldShop {
public static boolean isWorldShopSign(Sign s) { public static boolean isWorldShopSign(Sign s) {
if (s.getLine(0).equalsIgnoreCase(ChatColor.BLUE+"-- SHOP --") || if (s.getLine(0).equalsIgnoreCase(ChatColor.BLUE+"-- SHOP --") ||
s.getLine(0).equalsIgnoreCase(ChatColor.BLUE+"- BUYING 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; return true;
} else { } else {
return false; return false;

View File

@ -1662,6 +1662,18 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
} }
//Now that we have the item cube. Dump whatever contents we can into the container. //Now that we have the item cube. Dump whatever contents we can into the container.
//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();
}
}
if (allowed) {
//Get the inventory of the chest we are inserting into. //Get the inventory of the chest we are inserting into.
Chest c = (Chest)ev.getClickedBlock().getState(); Chest c = (Chest)ev.getClickedBlock().getState();
Inventory chest_inventory = c.getBlockInventory(); Inventory chest_inventory = c.getBlockInventory();
@ -1723,6 +1735,10 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
itemCube_saveConfig(itemcube_id,save_items); itemCube_saveConfig(itemcube_id,save_items);
//This may have been a shop. Update the shop too. //This may have been a shop. Update the shop too.
WorldShop.updateShopSign(ev.getClickedBlock().getLocation()); WorldShop.updateShopSign(ev.getClickedBlock().getLocation());
} else {
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);
}
} }
} }
if (b!=null && (b.getType() == Material.SIGN || if (b!=null && (b.getType() == Material.SIGN ||
@ -1860,7 +1876,8 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
} }
} else } else
if (s.getLine(0).equalsIgnoreCase(ChatColor.BLUE+"- BUYING SHOP -") || 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. //This is a buy shop.
int shopID = TwosideShops.GetShopID(s); int shopID = TwosideShops.GetShopID(s);
WorldShop shop = TwosideShops.LoadWorldShopData(shopID); WorldShop shop = TwosideShops.LoadWorldShopData(shopID);
@ -3654,7 +3671,8 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
} }
} else } else
if (s.getLine(0).equalsIgnoreCase(ChatColor.BLUE+"- BUYING SHOP -") || 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. //This is a shop. Let's find out who the owner is.
int shopID = TwosideShops.GetShopID(s); int shopID = TwosideShops.GetShopID(s);
WorldShop shop = TwosideShops.LoadWorldShopData(shopID); WorldShop shop = TwosideShops.LoadWorldShopData(shopID);

View File

@ -66,7 +66,7 @@ public class WorldShopManager {
//Create a shop out of this. //Create a shop out of this.
if (purchaseshop) { if (purchaseshop) {
if (shop.GetStoredAmount()>0) { if (shop.GetStoredAmount()>0) {
sign_lines.add(ChatColor.YELLOW+""+ChatColor.BOLD+"-BUYING SHOP-"); sign_lines.add(ChatColor.GREEN+""+ChatColor.BOLD+"-BUYING SHOP-");
} else { } else {
sign_lines.add(ChatColor.BLUE+"- BUYING SHOP -"); sign_lines.add(ChatColor.BLUE+"- BUYING SHOP -");
} }
@ -96,7 +96,7 @@ public class WorldShopManager {
//Create a shop out of this. //Create a shop out of this.
if (purchaseshop) { if (purchaseshop) {
if (shop.GetStoredAmount()>0) { if (shop.GetStoredAmount()>0) {
sign_lines.add(ChatColor.YELLOW+""+ChatColor.BOLD+"-BUYING SHOP-"); sign_lines.add(ChatColor.GREEN+""+ChatColor.BOLD+"-BUYING SHOP-");
} else { } else {
sign_lines.add(ChatColor.BLUE+"- BUYING SHOP -"); sign_lines.add(ChatColor.BLUE+"- BUYING SHOP -");
} }