mirror of
https://github.com/ChestShop-authors/ChestShop-3.git
synced 2024-12-28 10:57:47 +01:00
REALLY fixed Admin Shops now
Also, fixed out of stock message to include items. Oh, and Shift+clicking correctly gets the item amount.
This commit is contained in:
parent
bbeec231ec
commit
1e85e427ca
@ -17,7 +17,7 @@ public class Economy {
|
||||
private static EcoPlugin economy;
|
||||
|
||||
public static boolean isOwnerEconomicallyActive(Inventory inventory) {
|
||||
return !ChestShopSign.isAdminShop(inventory) || getServerAccountName().isEmpty();
|
||||
return !ChestShopSign.isAdminShop(inventory) || !getServerAccountName().isEmpty();
|
||||
}
|
||||
|
||||
public static boolean hasAccount(String p) {
|
||||
|
@ -136,7 +136,11 @@ public class PlayerInteract implements Listener {
|
||||
Action buy = Config.getBoolean(REVERSE_BUTTONS) ? LEFT_CLICK_BLOCK : RIGHT_CLICK_BLOCK;
|
||||
|
||||
if (action == buy) {
|
||||
amount = InventoryUtil.getAmount(item, inventory);
|
||||
if (inventory instanceof AdminInventory) {
|
||||
amount = Integer.MAX_VALUE;
|
||||
} else {
|
||||
amount = InventoryUtil.getAmount(item, inventory);
|
||||
}
|
||||
} else {
|
||||
amount = InventoryUtil.getAmount(item, player.getInventory());
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.Acrobot.ChestShop.Listeners.PreTransaction;
|
||||
|
||||
import com.Acrobot.Breeze.Utils.MaterialUtil;
|
||||
import com.Acrobot.ChestShop.Config.Config;
|
||||
import com.Acrobot.ChestShop.Config.Language;
|
||||
import com.Acrobot.ChestShop.Config.Property;
|
||||
@ -9,6 +10,10 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Acrobot
|
||||
@ -22,7 +27,7 @@ public class ErrorMessageSender implements Listener {
|
||||
|
||||
Language message = null;
|
||||
|
||||
switch(event.getTransactionOutcome()) {
|
||||
switch (event.getTransactionOutcome()) {
|
||||
case SHOP_DOES_NOT_BUY_THIS_ITEM:
|
||||
message = Language.NO_BUYING_HERE;
|
||||
break;
|
||||
@ -48,7 +53,8 @@ public class ErrorMessageSender implements Listener {
|
||||
message = Language.NOT_ENOUGH_ITEMS_TO_SELL;
|
||||
break;
|
||||
case NOT_ENOUGH_STOCK_IN_CHEST:
|
||||
sendMessageToOwner(event.getOwner(), Language.NOT_ENOUGH_STOCK_IN_YOUR_SHOP);
|
||||
String messageOutOfStock = Config.getLocal(Language.NOT_ENOUGH_STOCK_IN_YOUR_SHOP).replace("%material", getItemNames(event.getStock()));
|
||||
sendMessageToOwner(event.getOwner(), messageOutOfStock);
|
||||
message = Language.NOT_ENOUGH_STOCK;
|
||||
break;
|
||||
case SHOP_IS_RESTRICTED:
|
||||
@ -64,10 +70,37 @@ public class ErrorMessageSender implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
private static void sendMessageToOwner(OfflinePlayer owner, Language message) {
|
||||
private static String getItemNames(ItemStack[] stock) {
|
||||
List<ItemStack> items = new LinkedList<ItemStack>();
|
||||
|
||||
for (ItemStack stack : stock) {
|
||||
boolean hadItem = false;
|
||||
|
||||
for (ItemStack item : items) {
|
||||
if (MaterialUtil.equals(stack, item)) {
|
||||
item.setAmount(item.getAmount() + stack.getAmount());
|
||||
hadItem = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!hadItem) {
|
||||
items.add(stack.clone());
|
||||
}
|
||||
}
|
||||
|
||||
StringBuilder names = new StringBuilder(50);
|
||||
|
||||
for (ItemStack item : items) {
|
||||
names.append(MaterialUtil.getName(item)).append(',').append(' ');
|
||||
}
|
||||
|
||||
return names.toString();
|
||||
}
|
||||
|
||||
private static void sendMessageToOwner(OfflinePlayer owner, String message) {
|
||||
if (owner.isOnline() && Config.getBoolean(Property.SHOW_MESSAGE_OUT_OF_STOCK)) {
|
||||
Player player = (Player) owner;
|
||||
player.sendMessage(Config.getLocal(message));
|
||||
player.sendMessage(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ name: ChestShop
|
||||
|
||||
main: com.Acrobot.ChestShop.ChestShop
|
||||
|
||||
version: 3.50t0012
|
||||
version: 3.50t0013
|
||||
|
||||
#for CButD
|
||||
dev-url: http://dev.bukkit.org/server-mods/chestshop/
|
||||
|
Loading…
Reference in New Issue
Block a user