Update sign when right click,Add new pritection for display-item

Former-commit-id: c4499141e182b1abd1892e8ff4aed80c0bb255c8 [formerly 2878e2150107a550c4343971c65ed3620ade2ad2]
Former-commit-id: dc961afa2914a77ad84f7b5aa49559bce14ad1da
This commit is contained in:
Ghost_chu committed 2018-11-22 16:49:27 +08:00
1 parent 8a5545c2f8
commit f856013cd4
3 files changed
+27 -4

No files matched your search

@@ -127,6 +127,7 @@ public class QS implements CommandExecutor {
shop.setPrice(price);
shop.setSignText();
shop.update();
MsgUtil.sendControlPanelInfo(sender, shop);
sender.sendMessage(MsgUtil.getMessage("price-is-now", plugin.getEcon().format(shop.getPrice())));
// Chest shops can be double shops.
if (shop instanceof ContainerShop) {
@@ -164,6 +165,9 @@ public class QS implements CommandExecutor {
}
if (shop != null) {
shop.add(shop.getItem(), add);
shop.setSignText();
shop.update();
MsgUtil.sendControlPanelInfo(player, shop);
player.sendMessage(MsgUtil.getMessage("refill-success"));
return;
}
@@ -181,6 +185,7 @@ public class QS implements CommandExecutor {
OfflinePlayer p = this.plugin.getServer().getOfflinePlayer(owner);
shop.setOwner(p.getUniqueId());
shop.update();
MsgUtil.sendControlPanelInfo(player, shop);
player.sendMessage(MsgUtil.getMessage("command.new-owner",
this.plugin.getServer().getOfflinePlayer(shop.getOwner()).getName()));
return;
@@ -222,6 +227,7 @@ public class QS implements CommandExecutor {
shop.setUnlimited(!shop.isUnlimited());
shop.setSignText();
shop.update();
MsgUtil.sendControlPanelInfo(sender, shop);
sender.sendMessage(MsgUtil.getMessage("command.toggle-unlimited",
(shop.isUnlimited() ? "unlimited" : "limited")));
return;
@@ -444,6 +450,7 @@ public class QS implements CommandExecutor {
if (shop instanceof ContainerShop) {
ContainerShop cs = (ContainerShop) shop;
cs.getInventory().clear();
MsgUtil.sendControlPanelInfo(sender, shop);
sender.sendMessage(MsgUtil.getMessage("empty-success"));
return;
}
@@ -621,6 +628,7 @@ public class QS implements CommandExecutor {
shop.setShopType(ShopType.BUYING);
shop.setSignText();
shop.update();
MsgUtil.sendControlPanelInfo(sender, shop);
sender.sendMessage(MsgUtil.getMessage("command.now-buying", shop.getDataName()));
return;
}
@@ -658,6 +666,7 @@ public class QS implements CommandExecutor {
shop.setShopType(ShopType.SELLING);
shop.setSignText();
shop.update();
MsgUtil.sendControlPanelInfo(sender, shop);
sender.sendMessage(MsgUtil.getMessage("command.now-selling", shop.getDataName()));
return;
}
@@ -7,6 +7,7 @@ import org.bukkit.event.entity.EntityPickupItemEvent;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryMoveItemEvent;
import org.bukkit.event.inventory.InventoryOpenEvent;
import org.bukkit.event.inventory.InventoryPickupItemEvent;
import org.bukkit.event.player.PlayerChangedMainHandEvent;
@@ -209,6 +210,19 @@ public class DisplayProtectionListener implements Listener {
}
} catch (Exception e) {}
}
@EventHandler(ignoreCancelled = true)
public void onInventoryMoveItem(InventoryMoveItemEvent event) {
try {
ItemStack is = event.getItem();
if (itemStackCheck(is)) {
event.setCancelled(true);
plugin.getLogger().warning("[Exploit alert] Inventory "+event.getDestination().getTitle()+" move display item "+is);
Util.sendMessageToOps(ChatColor.RED+"[QuickShop][Exploit alert] Inventory "+event.getDestination().getTitle()+" move display item "+is);
event.setItem(new ItemStack(Material.AIR));
}
} catch (Exception e) {}
}
boolean itemStackCheck(ItemStack is) {
return DisplayItem.checkShopItem(is);
@@ -142,7 +142,6 @@ public class PlayerListener implements Listener {
}
} else if (e.getAction().equals(Action.RIGHT_CLICK_BLOCK)
&& e.getClickedBlock().getType() == Material.WALL_SIGN) {
/** @TODO: ControlPanel **/
Block block;
if (e.getClickedBlock().getType() == Material.WALL_SIGN) {
block = Util.getAttached(e.getClickedBlock());
@@ -152,6 +151,7 @@ public class PlayerListener implements Listener {
if (plugin.getShopManager().getShop(block.getLocation()) != null) {
MsgUtil.sendControlPanelInfo((CommandSender) e.getPlayer(),
plugin.getShopManager().getShop(block.getLocation()));
plugin.getShopManager().getShop(block.getLocation()).setSignText();
}
}
@@ -209,17 +209,17 @@ public class PlayerListener implements Listener {
public void onInventoryClose(InventoryCloseEvent e) {
try {
final Inventory inventory = e.getInventory();
Inventory inventory = e.getInventory();
if (inventory == null) {
return;
}
final Location location = inventory.getLocation();
Location location = inventory.getLocation();
if (location == null) {
return;
}
final Shop shop = plugin.getShopManager().getShop(location);
Shop shop = plugin.getShopManager().getShop(location);
if (shop == null) {
return;
}