Check if shop owned by player to sell items

This commit is contained in:
RedSparr0w
2019-11-22 20:47:36 +13:00
parent d62e5a8d70
commit ae883964af
@@ -303,16 +303,27 @@ public class ShopAssistant {
} }
} }
boolean IsIn = false; boolean IsIn = false;
if (ShopHandler.ShopSModifier[player.myShopId] > 1) { switch (ShopHandler.ShopSModifier[player.myShopId]) {
for (int j = 0; j <= ShopHandler.ShopItemsStandard[player.myShopId]; j++) { // Only buys what is in stock
if (removeId == (ShopHandler.ShopItems[player.myShopId][j] - 1)) { case 2:
IsIn = true; for (int j = 0; j <= ShopHandler.ShopItemsStandard[player.myShopId]; j++) {
break; if (removeId == (ShopHandler.ShopItems[player.myShopId][j] - 1)) {
IsIn = true;
break;
}
} }
} break;
} else { // General store
IsIn = true; case 1:
IsIn = true;
break;
// Player owned store
case 0:
System.out.println("Is players shop: " + (ShopHandler.ShopName[player.myShopId].equalsIgnoreCase(player.properName + "'s Store") ? "true" : "false"));
IsIn = ShopHandler.ShopName[player.myShopId].equalsIgnoreCase(player.properName + "'s Store");
break;
} }
if (IsIn == false) { if (IsIn == false) {
player.getActionSender().sendMessage("You can't sell " + ItemAssistant.getItemName(removeId).toLowerCase() + " to this store."); player.getActionSender().sendMessage("You can't sell " + ItemAssistant.getItemName(removeId).toLowerCase() + " to this store.");
} else { } else {
@@ -355,25 +366,36 @@ public class ShopAssistant {
if(!player.isShopping) { if(!player.isShopping) {
return false; return false;
} }
if (player.TotalShopItems >= 39) if (player.TotalShopItems >= 39) {
{
player.getActionSender().sendMessage("If you sell more individuals items in this shop, they won't be displayed."); player.getActionSender().sendMessage("If you sell more individuals items in this shop, they won't be displayed.");
} }
if (amount > 0 && itemID == (player.playerItems[fromSlot] - 1)) { if (amount > 0 && itemID == (player.playerItems[fromSlot] - 1)) {
if (ShopHandler.ShopSModifier[player.myShopId] > 1) { boolean IsIn = false;
boolean IsIn = false; switch (ShopHandler.ShopSModifier[player.myShopId]) {
for (int i = 0; i <= ShopHandler.ShopItemsStandard[player.myShopId]; i++) { // Only buys what is in stock
if (itemID == (ShopHandler.ShopItems[player.myShopId][i] - 1)) { case 2:
IsIn = true; for (int j = 0; j <= ShopHandler.ShopItemsStandard[player.myShopId]; j++) {
break; if (itemID == (ShopHandler.ShopItems[player.myShopId][j] - 1)) {
IsIn = true;
break;
}
} }
} break;
if (IsIn == false) { // General store
player.getItemAssistant(); case 1:
player.getActionSender().sendMessage("You can't sell " + ItemAssistant.getItemName(itemID).toLowerCase() + " to this store."); IsIn = true;
return false; break;
} // Player owned store
case 0:
System.out.println("Is players shop: " + (ShopHandler.ShopName[player.myShopId].equalsIgnoreCase(player.properName + "'s Store") ? "true" : "false"));
IsIn = ShopHandler.ShopName[player.myShopId].equalsIgnoreCase(player.properName + "'s Store");
break;
}
if (IsIn == false) {
player.getItemAssistant();
player.getActionSender().sendMessage("You can't sell " + ItemAssistant.getItemName(itemID).toLowerCase() + " to this store.");
return false;
} }
if (amount > player.playerItemsN[fromSlot] && (ItemDefinitions.getDef()[player.playerItems[fromSlot] - 1].isNoteable == true || ItemDefinitions.getDef()[player.playerItems[fromSlot] - 1].isStackable == true)) { if (amount > player.playerItemsN[fromSlot] && (ItemDefinitions.getDef()[player.playerItems[fromSlot] - 1].isNoteable == true || ItemDefinitions.getDef()[player.playerItems[fromSlot] - 1].isStackable == true)) {
amount = player.playerItemsN[fromSlot]; amount = player.playerItemsN[fromSlot];
@@ -405,7 +427,6 @@ public class ShopAssistant {
addShopItem(itemID, amount); //Add item to the shop. addShopItem(itemID, amount); //Add item to the shop.
if (player.getPlayerAssistant().isPlayer()) { //Logger if (player.getPlayerAssistant().isPlayer()) { //Logger
GameLogger.writeLog(player.playerName, "shopselling", player.playerName + " sold " + itemName + " to store id: " + player.myShopId + " for" + GameLogger.formatCurrency(TotPrice2) + " coins"); GameLogger.writeLog(player.playerName, "shopselling", player.playerName + " sold " + itemName + " to store id: " + player.myShopId + " for" + GameLogger.formatCurrency(TotPrice2) + " coins");
//Remove this later. I added it to push this class because a fuck happened with my last commit.
} }
} else { } else {
player.getActionSender().sendMessage("You don't have enough space in your inventory."); player.getActionSender().sendMessage("You don't have enough space in your inventory.");