diff --git a/src/main/java/org/maxgamer/quickshop/Listeners/PlayerListener.java b/src/main/java/org/maxgamer/quickshop/Listeners/PlayerListener.java index ddb1abeda..0d18472fc 100644 --- a/src/main/java/org/maxgamer/quickshop/Listeners/PlayerListener.java +++ b/src/main/java/org/maxgamer/quickshop/Listeners/PlayerListener.java @@ -1,10 +1,7 @@ package org.maxgamer.quickshop.Listeners; import lombok.AllArgsConstructor; -import org.bukkit.GameMode; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.Sound; +import org.bukkit.*; import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.event.Event.Result; @@ -263,5 +260,29 @@ public class PlayerListener implements Listener { PlayerMoveEvent me = new PlayerMoveEvent(e.getPlayer(), e.getFrom(), e.getTo()); onMove(me); } - + @EventHandler(priority = EventPriority.HIGH,ignoreCancelled = true) + public void onDyeing(PlayerInteractEvent e){ + if(e.getAction() != Action.RIGHT_CLICK_BLOCK){ + return; + } + if(!Util.isDyes(e.getItem().getType())){ + return; + } + Block block = e.getClickedBlock(); + if(block == null){ + return; + } + if(!Util.isWallSign(block.getType())){ + return; + } + Block attachedBlock = Util.getAttached(block); + if(attachedBlock == null){ + return; + } + if(plugin.getShopManager().getShopIncludeAttached(attachedBlock.getLocation()) == null){ + return; + } + e.setCancelled(true); + Util.debugLog("Disallow "+e.getPlayer().getName()+" dye the shop sign."); + } } \ No newline at end of file diff --git a/src/main/java/org/maxgamer/quickshop/Shop/DisplayItem.java b/src/main/java/org/maxgamer/quickshop/Shop/DisplayItem.java index 6f3684d86..08611caeb 100644 --- a/src/main/java/org/maxgamer/quickshop/Shop/DisplayItem.java +++ b/src/main/java/org/maxgamer/quickshop/Shop/DisplayItem.java @@ -1,9 +1,11 @@ package org.maxgamer.quickshop.Shop; +import com.google.common.collect.BiMap; import com.google.gson.Gson; import com.google.gson.JsonSyntaxException; import org.bukkit.Location; import org.bukkit.entity.Entity; +import org.bukkit.inventory.ItemFlag; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; import org.jetbrains.annotations.NotNull; diff --git a/src/main/java/org/maxgamer/quickshop/Util/Util.java b/src/main/java/org/maxgamer/quickshop/Util/Util.java index 28b1efb52..f229b39e1 100644 --- a/src/main/java/org/maxgamer/quickshop/Util/Util.java +++ b/src/main/java/org/maxgamer/quickshop/Util/Util.java @@ -1124,4 +1124,13 @@ public class Util { public static boolean isDevMode() { return devMode; } + + /** + * Get a material is a dye + * @param material The material + * @return yes or not + */ + public static boolean isDyes(Material material){ + return material.name().toUpperCase().endsWith("_DYE"); + } }