mirror of
https://github.com/EarthMC/QuickShop-Reremake.git
synced 2026-11-24 17:39:52 -05:00
Fixes #129 - Sign not updating automatically
This commit is contained in:
1 parent
0a56e68918
commit
8b67baf985
3 files changed
+21
-44
No files matched your search
+2
-26
@@ -1,25 +1,21 @@
|
||||
package org.maxgamer.quickshop.Listeners;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.event.Event.Result;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
import org.bukkit.event.inventory.InventoryOpenEvent;
|
||||
import org.bukkit.event.inventory.InventoryPickupItemEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.maxgamer.quickshop.QuickShop;
|
||||
import org.maxgamer.quickshop.Shop.Shop;
|
||||
import org.maxgamer.quickshop.Util.Util;
|
||||
|
||||
public class InventoryListener implements Listener {
|
||||
public class DisplayProtectionListener implements Listener {
|
||||
private QuickShop plugin;
|
||||
|
||||
public InventoryListener(QuickShop plugin) {
|
||||
public DisplayProtectionListener(QuickShop plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@@ -38,26 +34,6 @@ public class InventoryListener implements Listener {
|
||||
} catch (Exception e) {}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryClose(InventoryCloseEvent event) {
|
||||
final Inventory inventory = event.getInventory();
|
||||
if (inventory == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final Location location = inventory.getLocation();
|
||||
if (location == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final Shop shop = plugin.getShopManager().getShop(location);
|
||||
if (shop == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
shop.setSignText();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryClick(InventoryClickEvent event) {
|
||||
@@ -21,6 +21,7 @@ import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerPickupItemEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.BlockIterator;
|
||||
import org.maxgamer.quickshop.QuickShop;
|
||||
@@ -203,21 +204,21 @@ public class PlayerListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryClose(InventoryCloseEvent e) {
|
||||
if (e.getInventory().getHolder() instanceof Block) {
|
||||
Block block = (Block) e.getInventory().getHolder();
|
||||
if (Util.canBeShop(block)) {
|
||||
Shop shop = plugin.getShopManager().getShop(block.getLocation());
|
||||
if (shop==null && (block.getType() == Material.CHEST || block.getType() == Material.TRAPPED_CHEST)) {
|
||||
Block attached = Util.getSecondHalf(block);
|
||||
if (attached!=null) {
|
||||
shop = plugin.getShopManager().getShop(attached.getLocation());
|
||||
}
|
||||
}
|
||||
|
||||
if (shop!=null) {
|
||||
shop.setSignText();
|
||||
}
|
||||
}
|
||||
final Inventory inventory = e.getInventory();
|
||||
if (inventory == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final Location location = inventory.getLocation();
|
||||
if (location == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final Shop shop = plugin.getShopManager().getShop(location);
|
||||
if (shop == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
shop.setSignText();
|
||||
}
|
||||
}
|
||||
@@ -46,7 +46,7 @@ import org.maxgamer.quickshop.Listeners.BlockListener;
|
||||
import org.maxgamer.quickshop.Listeners.ChatListener;
|
||||
import org.maxgamer.quickshop.Listeners.ChunkListener;
|
||||
import org.maxgamer.quickshop.Listeners.HeroChatListener;
|
||||
import org.maxgamer.quickshop.Listeners.InventoryListener;
|
||||
import org.maxgamer.quickshop.Listeners.DisplayProtectionListener;
|
||||
import org.maxgamer.quickshop.Listeners.LockListener;
|
||||
import org.maxgamer.quickshop.Listeners.PlayerListener;
|
||||
import org.maxgamer.quickshop.Listeners.WorldListener;
|
||||
@@ -85,7 +85,7 @@ public class QuickShop extends JavaPlugin {
|
||||
// Listeners (These don't)
|
||||
private BlockListener blockListener;
|
||||
private PlayerListener playerListener;
|
||||
private InventoryListener inventoryListener;
|
||||
private DisplayProtectionListener inventoryListener;
|
||||
private ChunkListener chunkListener;
|
||||
private WorldListener worldListener;
|
||||
private BukkitTask itemWatcherTask;
|
||||
@@ -394,7 +394,7 @@ public class QuickShop extends JavaPlugin {
|
||||
Bukkit.getServer().getPluginManager().registerEvents(blockListener, this);
|
||||
Bukkit.getServer().getPluginManager().registerEvents(playerListener, this);
|
||||
if (this.display) {
|
||||
inventoryListener = new InventoryListener(this);
|
||||
inventoryListener = new DisplayProtectionListener(this);
|
||||
chunkListener = new ChunkListener(this);
|
||||
Bukkit.getServer().getPluginManager().registerEvents(inventoryListener, this);
|
||||
Bukkit.getServer().getPluginManager().registerEvents(chunkListener, this);
|
||||
|
||||
Reference in new issue
Block a user