diff --git a/src/de/Ste3et_C0st/Furniture/Camera/Utils/v1_16/BlockColor.java b/src/de/Ste3et_C0st/Furniture/Camera/Utils/v1_16/BlockColor.java new file mode 100644 index 0000000..1451377 --- /dev/null +++ b/src/de/Ste3et_C0st/Furniture/Camera/Utils/v1_16/BlockColor.java @@ -0,0 +1,35 @@ +package de.Ste3et_C0st.Furniture.Camera.Utils.v1_16; + +import org.apache.commons.lang.reflect.MethodUtils; +import org.bukkit.block.Block; + +import de.Ste3et_C0st.Furniture.Camera.Utils.MinecraftBlockColor; + +public class BlockColor extends MinecraftBlockColor{ + + private static Class CraftMagicNumbersClass; + + static { + try { + CraftMagicNumbersClass = Class.forName("org.bukkit.craftbukkit." + getBukkitVersion() + ".util.CraftMagicNumbers"); + }catch (Exception e) { + e.printStackTrace(); + } + } + + @Override + public Byte getBlockColor(Block b) { + try { + Object nmsBlock = CraftMagicNumbersClass.getMethod("getBlock", org.bukkit.Material.class).invoke(null, b.getType()); + Object iBlockData = nmsBlock.getClass().getMethod("getBlockData").invoke(nmsBlock); + Object Material = MethodUtils.invokeMethod(iBlockData, "getMaterial", null); + Object MaterialMapColor = MethodUtils.invokeMethod(Material, "h", null); + int color = MaterialMapColor.getClass().getField("aj").getInt(MaterialMapColor) * 4; + return (byte) color; + }catch (Exception e) { + e.printStackTrace(); + } + return null; + } + +} diff --git a/src/de/Ste3et_C0st/Furniture/Objects/garden/sunshade.java b/src/de/Ste3et_C0st/Furniture/Objects/garden/sunshade.java index ac15a59..deb92d9 100644 --- a/src/de/Ste3et_C0st/Furniture/Objects/garden/sunshade.java +++ b/src/de/Ste3et_C0st/Furniture/Objects/garden/sunshade.java @@ -43,7 +43,7 @@ public class sunshade extends Furniture{ if(player == null) return; ItemStack is = player.getInventory().getItemInMainHand(); if(is.getType().name().contains("BANNER")){ - if(canBuild(player, false)) { + if(canBuild(player)) { for(fEntity packet : getfAsList()){ if(packet.getInventory().getHelmet()!=null&&packet.getInventory().getHelmet().getType().name().contains("BANNER")){ packet.getInventory().setHelmet(is.clone()); @@ -54,12 +54,16 @@ public class sunshade extends Furniture{ } update(); consumeItem(player); - return; } - }else if(!isOpen()){ - open(); - }else{ - close(); + return; + }else { + if(canInteract(player)){ + if(!isOpen()){ + open(); + }else{ + close(); + } + } } }