mirror of
https://github.com/EarthMC/QuickShop-Reremake.git
synced 2026-11-24 17:39:52 -05:00
Fix People are able to use dye on other players shops, so the shop texts color changes
Former-commit-id: 2c02588e1216f26c034409380f02637df2640f79 [formerly ba507b928795bcb997d0da34b9d0356e79602ab2] Former-commit-id: e3fcb8c37a1a31f0fba92784baccc44dec824048
This commit is contained in:
1 parent
eb8efe8539
commit
7bc79121bc
3 files changed
+37
-5
No files matched your search
@@ -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.");
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user