mirror of
https://github.com/EarthMC/QuickShop-Reremake.git
synced 2026-11-24 17:39:52 -05:00
Just from there move to here
Former-commit-id: f413f92e7684e3d8ccbe5b313da08c4141caf21f [formerly 6e6e1db365bcb732e28fbdfdc4a21b83cc03119d] Former-commit-id: c8bde062297b6df9d5599658f9cea84b6082d23e
This commit is contained in:
1 parent
c0008fb762
commit
e5f5b967ef
2 files changed
+143
-139
No files matched your search
@@ -3,16 +3,24 @@ package org.maxgamer.quickshop.Listeners;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.event.Event.Result;
|
||||
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.InventoryOpenEvent;
|
||||
import org.bukkit.event.inventory.InventoryPickupItemEvent;
|
||||
import org.bukkit.event.player.PlayerChangedMainHandEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerItemHeldEvent;
|
||||
import org.bukkit.event.player.PlayerItemMendEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerPickupItemEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.maxgamer.quickshop.QuickShop;
|
||||
import org.maxgamer.quickshop.Shop.DisplayItem;
|
||||
import org.maxgamer.quickshop.Util.Util;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class DisplayProtectionListener implements Listener {
|
||||
private QuickShop plugin;
|
||||
|
||||
@@ -35,7 +43,142 @@ public class DisplayProtectionListener implements Listener {
|
||||
} catch (Exception e) {}
|
||||
}
|
||||
}
|
||||
@EventHandler
|
||||
public void heldItem (PlayerItemHeldEvent e){
|
||||
ItemStack stack = e.getPlayer().getInventory().getItemInMainHand();
|
||||
ItemStack stackOffHand = e.getPlayer().getInventory().getItemInOffHand();
|
||||
try {
|
||||
if (DisplayItem.checkShopItem(stack)) {
|
||||
e.getPlayer().getInventory().setItemInMainHand(new ItemStack(Material.AIR,0));
|
||||
// You shouldn't be able to pick up that...
|
||||
plugin.getLogger().warning("[Exploit Alert] A QuickShop item found in "+e.getPlayer().getName()+"'s inventory"+" Deleteing...");
|
||||
Util.sendMessageToOps(ChatColor.RED+"[QuickShop][Exploit alert] A QuickShop item found in "+e.getPlayer().getName()+"'s inventory"+" Deleteing...");
|
||||
Util.inventoryCheck(e.getPlayer().getInventory());
|
||||
}
|
||||
if (DisplayItem.checkShopItem(stackOffHand)) {
|
||||
e.getPlayer().getInventory().setItemInOffHand(new ItemStack(Material.AIR,0));
|
||||
// You shouldn't be able to pick up that...
|
||||
plugin.getLogger().warning("[Exploit Alert] A QuickShop item found in "+e.getPlayer().getName()+"'s inventory"+" Deleteing...");
|
||||
Util.sendMessageToOps(ChatColor.RED+"[QuickShop][Exploit alert] A QuickShop item found in "+e.getPlayer().getName()+"'s inventory"+" Deleteing...");
|
||||
Util.inventoryCheck(e.getPlayer().getInventory());
|
||||
}
|
||||
} catch (NullPointerException ex) {
|
||||
|
||||
}
|
||||
}
|
||||
@EventHandler
|
||||
public void mendItem (PlayerItemMendEvent e){
|
||||
ItemStack stack = e.getPlayer().getInventory().getItemInMainHand();
|
||||
ItemStack stackOffHand = e.getPlayer().getInventory().getItemInOffHand();
|
||||
try {
|
||||
if (DisplayItem.checkShopItem(stack)) {
|
||||
e.getPlayer().getInventory().setItemInMainHand(new ItemStack(Material.AIR,0));
|
||||
// You shouldn't be able to pick up that...
|
||||
plugin.getLogger().warning("[Exploit Alert] A QuickShop item found in "+e.getPlayer().getName()+"'s inventory"+" Deleteing...");
|
||||
Util.sendMessageToOps(ChatColor.RED+"[QuickShop][Exploit alert] A QuickShop item found in "+e.getPlayer().getName()+"'s inventory"+" Deleteing...");
|
||||
Util.inventoryCheck(e.getPlayer().getInventory());
|
||||
}
|
||||
if (DisplayItem.checkShopItem(stackOffHand)) {
|
||||
e.getPlayer().getInventory().setItemInOffHand(new ItemStack(Material.AIR,0));
|
||||
// You shouldn't be able to pick up that...
|
||||
plugin.getLogger().warning("[Exploit Alert] A QuickShop item found in "+e.getPlayer().getName()+"'s inventory"+" Deleteing...");
|
||||
Util.sendMessageToOps(ChatColor.RED+"[QuickShop][Exploit alert] A QuickShop item found in "+e.getPlayer().getName()+"'s inventory"+" Deleteing...");
|
||||
Util.inventoryCheck(e.getPlayer().getInventory());
|
||||
}
|
||||
} catch (NullPointerException ex) {
|
||||
}
|
||||
}
|
||||
@EventHandler
|
||||
public void changeHand (PlayerChangedMainHandEvent e){
|
||||
ItemStack stack = e.getPlayer().getInventory().getItemInMainHand();
|
||||
ItemStack stackOffHand = e.getPlayer().getInventory().getItemInOffHand();
|
||||
try {
|
||||
if (DisplayItem.checkShopItem(stack)) {
|
||||
e.getPlayer().getInventory().setItemInMainHand(new ItemStack(Material.AIR,0));
|
||||
// You shouldn't be able to pick up that...
|
||||
plugin.getLogger().warning("[Exploit Alert] A QuickShop item found in "+e.getPlayer().getName()+"'s inventory"+" Deleteing...");
|
||||
Util.sendMessageToOps(ChatColor.RED+"[QuickShop][Exploit alert] A QuickShop item found in "+e.getPlayer().getName()+"'s inventory"+" Deleteing...");
|
||||
Util.inventoryCheck(e.getPlayer().getInventory());
|
||||
}
|
||||
if (DisplayItem.checkShopItem(stackOffHand)) {
|
||||
e.getPlayer().getInventory().setItemInOffHand(new ItemStack(Material.AIR,0));
|
||||
// You shouldn't be able to pick up that...
|
||||
plugin.getLogger().warning("[Exploit Alert] A QuickShop item found in "+e.getPlayer().getName()+"'s inventory"+" Deleteing...");
|
||||
Util.sendMessageToOps(ChatColor.RED+"[QuickShop][Exploit alert] A QuickShop item found in "+e.getPlayer().getName()+"'s inventory"+" Deleteing...");
|
||||
Util.inventoryCheck(e.getPlayer().getInventory());
|
||||
}
|
||||
} catch (NullPointerException ex) {
|
||||
}
|
||||
|
||||
}
|
||||
@EventHandler
|
||||
public void onPlayerPickup(EntityPickupItemEvent e) {
|
||||
ItemStack stack = e.getItem().getItemStack();
|
||||
try {
|
||||
if (DisplayItem.checkShopItem(stack)) {
|
||||
plugin.getLogger().warning("[Exploit Alert] A QuickShop item found in "+e.getEntity().getName()+"'s inventory"+" Deleteing...");
|
||||
Util.sendMessageToOps(ChatColor.RED+"[QuickShop][Exploit alert] A QuickShop item found in "+e.getEntity().getName()+"'s inventory"+" Deleteing...");
|
||||
e.setCancelled(true);
|
||||
// You shouldn't be able to pick up that...
|
||||
}
|
||||
} catch (NullPointerException ex) {
|
||||
} // if meta/displayname/stack is null. We don't really care in that case.
|
||||
}
|
||||
@EventHandler
|
||||
public void onPlayerClick(PlayerInteractEvent e) {
|
||||
ItemStack stack = e.getPlayer().getInventory().getItemInMainHand();
|
||||
|
||||
ItemStack stackOffHand = e.getPlayer().getInventory().getItemInOffHand();
|
||||
try {
|
||||
if (DisplayItem.checkShopItem(stack) || DisplayItem.checkShopItem(stackOffHand)) {
|
||||
plugin.getLogger().warning("[Exploit Alert] A QuickShop item found in "+e.getPlayer().getName()+"'s inventory"+" Deleteing...");
|
||||
Util.sendMessageToOps(ChatColor.RED+"[QuickShop][Exploit alert] A QuickShop item found in "+e.getPlayer().getName()+"'s inventory"+" Deleteing...");
|
||||
e.setCancelled(true);
|
||||
Util.inventoryCheck(e.getPlayer().getInventory());
|
||||
// You shouldn't be able to pick up that...
|
||||
}
|
||||
} catch (NullPointerException ex) {
|
||||
} // if meta/displayname/stack is null. We don't really care in that case.
|
||||
}
|
||||
//to support old minecraft version
|
||||
@EventHandler
|
||||
public void onPlayerPickup_Old(PlayerPickupItemEvent e) {
|
||||
ItemStack stack = e.getItem().getItemStack();
|
||||
try {
|
||||
if (DisplayItem.checkShopItem(stack)) {
|
||||
plugin.getLogger().warning("[Exploit Alert] A QuickShop item found in "+e.getPlayer().getName()+"'s inventory"+" Deleteing...");
|
||||
Util.sendMessageToOps(ChatColor.RED+"[QuickShop][Exploit alert] A QuickShop item found in "+e.getPlayer().getName()+"'s inventory"+" Deleteing...");
|
||||
e.setCancelled(true);
|
||||
Util.inventoryCheck(e.getPlayer().getInventory());
|
||||
// You shouldn't be able to pick up that...
|
||||
}
|
||||
} catch (NullPointerException ex) {
|
||||
} // if meta/displayname/stack is null. We don't really care in that case.
|
||||
}
|
||||
@EventHandler
|
||||
public void moveing (PlayerMoveEvent e){
|
||||
ItemStack stack = e.getPlayer().getInventory().getItemInMainHand();
|
||||
ItemStack stackOffHand = e.getPlayer().getInventory().getItemInOffHand();
|
||||
try {
|
||||
if (DisplayItem.checkShopItem(stack)) {
|
||||
e.getPlayer().getInventory().setItemInMainHand(new ItemStack(Material.AIR,0));
|
||||
// You shouldn't be able to pick up that...
|
||||
plugin.getLogger().warning("[Exploit Alert] A QuickShop item found in "+e.getPlayer().getName()+"'s inventory"+" Deleteing...");
|
||||
Util.sendMessageToOps(ChatColor.RED+"[QuickShop][Exploit alert] A QuickShop item found in "+e.getPlayer().getName()+"'s inventory"+" Deleteing...");
|
||||
Util.inventoryCheck(e.getPlayer().getInventory());
|
||||
}
|
||||
if (DisplayItem.checkShopItem(stackOffHand)) {
|
||||
e.getPlayer().getInventory().setItemInOffHand(new ItemStack(Material.AIR,0));
|
||||
// You shouldn't be able to pick up that...
|
||||
plugin.getLogger().warning("[Exploit Alert] A QuickShop item found in "+e.getPlayer().getName()+"'s inventory"+" Deleteing...");
|
||||
Util.sendMessageToOps(ChatColor.RED+"[QuickShop][Exploit alert] A QuickShop item found in "+e.getPlayer().getName()+"'s inventory"+" Deleteing...");
|
||||
Util.inventoryCheck(e.getPlayer().getInventory());
|
||||
}
|
||||
} catch (NullPointerException ex) {
|
||||
|
||||
}
|
||||
// if meta/displayname/stack is null. We don't really care in that case.
|
||||
}
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onInventoryClick(InventoryClickEvent event) {
|
||||
try {
|
||||
|
||||
@@ -8,7 +8,6 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.entity.EntityPickupItemEvent;
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
import org.bukkit.event.inventory.InventoryEvent;
|
||||
import org.bukkit.event.player.*;
|
||||
@@ -17,7 +16,6 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.BlockIterator;
|
||||
import org.maxgamer.quickshop.QuickShop;
|
||||
import org.maxgamer.quickshop.Command.QS;
|
||||
import org.maxgamer.quickshop.Shop.DisplayItem;
|
||||
import org.maxgamer.quickshop.Shop.Info;
|
||||
import org.maxgamer.quickshop.Shop.Shop;
|
||||
import org.maxgamer.quickshop.Shop.ShopAction;
|
||||
@@ -209,52 +207,6 @@ public class PlayerListener implements Listener {
|
||||
QS.signPlayerCache.remove(e.getPlayer().getUniqueId());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerPickup(EntityPickupItemEvent e) {
|
||||
ItemStack stack = e.getItem().getItemStack();
|
||||
try {
|
||||
if (DisplayItem.checkShopItem(stack)) {
|
||||
plugin.getLogger().warning("[Exploit Alert] A QuickShop item found in "+e.getEntity().getName()+"'s inventory"+" Deleteing...");
|
||||
Util.sendMessageToOps(ChatColor.RED+"[QuickShop][Exploit alert] A QuickShop item found in "+e.getEntity().getName()+"'s inventory"+" Deleteing...");
|
||||
e.setCancelled(true);
|
||||
// You shouldn't be able to pick up that...
|
||||
}
|
||||
} catch (NullPointerException ex) {
|
||||
} // if meta/displayname/stack is null. We don't really care in that case.
|
||||
}
|
||||
@EventHandler
|
||||
public void onPlayerClick(PlayerInteractEvent e) {
|
||||
ItemStack stack = e.getPlayer().getInventory().getItemInMainHand();
|
||||
|
||||
ItemStack stackOffHand = e.getPlayer().getInventory().getItemInOffHand();
|
||||
try {
|
||||
if (DisplayItem.checkShopItem(stack) || DisplayItem.checkShopItem(stackOffHand)) {
|
||||
plugin.getLogger().warning("[Exploit Alert] A QuickShop item found in "+e.getPlayer().getName()+"'s inventory"+" Deleteing...");
|
||||
Util.sendMessageToOps(ChatColor.RED+"[QuickShop][Exploit alert] A QuickShop item found in "+e.getPlayer().getName()+"'s inventory"+" Deleteing...");
|
||||
e.setCancelled(true);
|
||||
Util.inventoryCheck(e.getPlayer().getInventory());
|
||||
// You shouldn't be able to pick up that...
|
||||
}
|
||||
} catch (NullPointerException ex) {
|
||||
} // if meta/displayname/stack is null. We don't really care in that case.
|
||||
}
|
||||
//to support old minecraft version
|
||||
@SuppressWarnings("deprecation")
|
||||
@EventHandler
|
||||
public void onPlayerPickup_Old(PlayerPickupItemEvent e) {
|
||||
ItemStack stack = e.getItem().getItemStack();
|
||||
try {
|
||||
if (DisplayItem.checkShopItem(stack)) {
|
||||
plugin.getLogger().warning("[Exploit Alert] A QuickShop item found in "+e.getPlayer().getName()+"'s inventory"+" Deleteing...");
|
||||
Util.sendMessageToOps(ChatColor.RED+"[QuickShop][Exploit alert] A QuickShop item found in "+e.getPlayer().getName()+"'s inventory"+" Deleteing...");
|
||||
e.setCancelled(true);
|
||||
Util.inventoryCheck(e.getPlayer().getInventory());
|
||||
// You shouldn't be able to pick up that...
|
||||
}
|
||||
} catch (NullPointerException ex) {
|
||||
} // if meta/displayname/stack is null. We don't really care in that case.
|
||||
}
|
||||
@EventHandler
|
||||
public void onInventoryClose(InventoryCloseEvent e) {
|
||||
try {
|
||||
final Inventory inventory = e.getInventory();
|
||||
@@ -276,98 +228,7 @@ public class PlayerListener implements Listener {
|
||||
|
||||
}
|
||||
}
|
||||
@EventHandler
|
||||
public void heldItem (PlayerItemHeldEvent e){
|
||||
ItemStack stack = e.getPlayer().getInventory().getItemInMainHand();
|
||||
ItemStack stackOffHand = e.getPlayer().getInventory().getItemInOffHand();
|
||||
try {
|
||||
if (DisplayItem.checkShopItem(stack)) {
|
||||
e.getPlayer().getInventory().setItemInMainHand(new ItemStack(Material.AIR,0));
|
||||
// You shouldn't be able to pick up that...
|
||||
plugin.getLogger().warning("[Exploit Alert] A QuickShop item found in "+e.getPlayer().getName()+"'s inventory"+" Deleteing...");
|
||||
Util.sendMessageToOps(ChatColor.RED+"[QuickShop][Exploit alert] A QuickShop item found in "+e.getPlayer().getName()+"'s inventory"+" Deleteing...");
|
||||
Util.inventoryCheck(e.getPlayer().getInventory());
|
||||
}
|
||||
if (DisplayItem.checkShopItem(stackOffHand)) {
|
||||
e.getPlayer().getInventory().setItemInOffHand(new ItemStack(Material.AIR,0));
|
||||
// You shouldn't be able to pick up that...
|
||||
plugin.getLogger().warning("[Exploit Alert] A QuickShop item found in "+e.getPlayer().getName()+"'s inventory"+" Deleteing...");
|
||||
Util.sendMessageToOps(ChatColor.RED+"[QuickShop][Exploit alert] A QuickShop item found in "+e.getPlayer().getName()+"'s inventory"+" Deleteing...");
|
||||
Util.inventoryCheck(e.getPlayer().getInventory());
|
||||
}
|
||||
} catch (NullPointerException ex) {
|
||||
|
||||
}
|
||||
}
|
||||
@EventHandler
|
||||
public void mendItem (PlayerItemMendEvent e){
|
||||
ItemStack stack = e.getPlayer().getInventory().getItemInMainHand();
|
||||
ItemStack stackOffHand = e.getPlayer().getInventory().getItemInOffHand();
|
||||
try {
|
||||
if (DisplayItem.checkShopItem(stack)) {
|
||||
e.getPlayer().getInventory().setItemInMainHand(new ItemStack(Material.AIR,0));
|
||||
// You shouldn't be able to pick up that...
|
||||
plugin.getLogger().warning("[Exploit Alert] A QuickShop item found in "+e.getPlayer().getName()+"'s inventory"+" Deleteing...");
|
||||
Util.sendMessageToOps(ChatColor.RED+"[QuickShop][Exploit alert] A QuickShop item found in "+e.getPlayer().getName()+"'s inventory"+" Deleteing...");
|
||||
Util.inventoryCheck(e.getPlayer().getInventory());
|
||||
}
|
||||
if (DisplayItem.checkShopItem(stackOffHand)) {
|
||||
e.getPlayer().getInventory().setItemInOffHand(new ItemStack(Material.AIR,0));
|
||||
// You shouldn't be able to pick up that...
|
||||
plugin.getLogger().warning("[Exploit Alert] A QuickShop item found in "+e.getPlayer().getName()+"'s inventory"+" Deleteing...");
|
||||
Util.sendMessageToOps(ChatColor.RED+"[QuickShop][Exploit alert] A QuickShop item found in "+e.getPlayer().getName()+"'s inventory"+" Deleteing...");
|
||||
Util.inventoryCheck(e.getPlayer().getInventory());
|
||||
}
|
||||
} catch (NullPointerException ex) {
|
||||
}
|
||||
}
|
||||
@EventHandler
|
||||
public void changeHand (PlayerChangedMainHandEvent e){
|
||||
ItemStack stack = e.getPlayer().getInventory().getItemInMainHand();
|
||||
ItemStack stackOffHand = e.getPlayer().getInventory().getItemInOffHand();
|
||||
try {
|
||||
if (DisplayItem.checkShopItem(stack)) {
|
||||
e.getPlayer().getInventory().setItemInMainHand(new ItemStack(Material.AIR,0));
|
||||
// You shouldn't be able to pick up that...
|
||||
plugin.getLogger().warning("[Exploit Alert] A QuickShop item found in "+e.getPlayer().getName()+"'s inventory"+" Deleteing...");
|
||||
Util.sendMessageToOps(ChatColor.RED+"[QuickShop][Exploit alert] A QuickShop item found in "+e.getPlayer().getName()+"'s inventory"+" Deleteing...");
|
||||
Util.inventoryCheck(e.getPlayer().getInventory());
|
||||
}
|
||||
if (DisplayItem.checkShopItem(stackOffHand)) {
|
||||
e.getPlayer().getInventory().setItemInOffHand(new ItemStack(Material.AIR,0));
|
||||
// You shouldn't be able to pick up that...
|
||||
plugin.getLogger().warning("[Exploit Alert] A QuickShop item found in "+e.getPlayer().getName()+"'s inventory"+" Deleteing...");
|
||||
Util.sendMessageToOps(ChatColor.RED+"[QuickShop][Exploit alert] A QuickShop item found in "+e.getPlayer().getName()+"'s inventory"+" Deleteing...");
|
||||
Util.inventoryCheck(e.getPlayer().getInventory());
|
||||
}
|
||||
} catch (NullPointerException ex) {
|
||||
}
|
||||
|
||||
}
|
||||
@EventHandler
|
||||
public void moveing (PlayerMoveEvent e){
|
||||
ItemStack stack = e.getPlayer().getInventory().getItemInMainHand();
|
||||
ItemStack stackOffHand = e.getPlayer().getInventory().getItemInOffHand();
|
||||
try {
|
||||
if (DisplayItem.checkShopItem(stack)) {
|
||||
e.getPlayer().getInventory().setItemInMainHand(new ItemStack(Material.AIR,0));
|
||||
// You shouldn't be able to pick up that...
|
||||
plugin.getLogger().warning("[Exploit Alert] A QuickShop item found in "+e.getPlayer().getName()+"'s inventory"+" Deleteing...");
|
||||
Util.sendMessageToOps(ChatColor.RED+"[QuickShop][Exploit alert] A QuickShop item found in "+e.getPlayer().getName()+"'s inventory"+" Deleteing...");
|
||||
Util.inventoryCheck(e.getPlayer().getInventory());
|
||||
}
|
||||
if (DisplayItem.checkShopItem(stackOffHand)) {
|
||||
e.getPlayer().getInventory().setItemInOffHand(new ItemStack(Material.AIR,0));
|
||||
// You shouldn't be able to pick up that...
|
||||
plugin.getLogger().warning("[Exploit Alert] A QuickShop item found in "+e.getPlayer().getName()+"'s inventory"+" Deleteing...");
|
||||
Util.sendMessageToOps(ChatColor.RED+"[QuickShop][Exploit alert] A QuickShop item found in "+e.getPlayer().getName()+"'s inventory"+" Deleteing...");
|
||||
Util.inventoryCheck(e.getPlayer().getInventory());
|
||||
}
|
||||
} catch (NullPointerException ex) {
|
||||
|
||||
}
|
||||
// if meta/displayname/stack is null. We don't really care in that case.
|
||||
}
|
||||
@EventHandler
|
||||
public void invEvent(InventoryEvent e){
|
||||
Util.inventoryCheck(e.getInventory());
|
||||
|
||||
Reference in new issue
Block a user