From 2ebaeca46b80c863c4066eeb3a366f027036da33 Mon Sep 17 00:00:00 2001 From: Jan9103 Date: Sat, 21 Mar 2020 20:01:00 +0100 Subject: [PATCH] first implimentation --- .../src/de/steamwar/bausystem/BauSystem.java | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java index 1f08e29..418eb13 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java @@ -6,14 +6,22 @@ import de.steamwar.core.CommandRemover; import de.steamwar.scoreboard.SWScoreboard; import de.steamwar.sql.SteamwarUser; import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.attribute.Attribute; import org.bukkit.configuration.InvalidConfigurationException; +import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.player.PlayerLoginEvent; import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; import org.bukkit.scheduler.BukkitTask; import java.io.File; @@ -259,4 +267,34 @@ public class BauSystem extends JavaPlugin implements Listener { if(Bukkit.getOnlinePlayers().isEmpty() || (Bukkit.getOnlinePlayers().size() == 1 && Bukkit.getOnlinePlayers().contains(player))) Bukkit.shutdown(); } + + @EventHandler + public void onInventoryClick(InventoryClickEvent e) { + ItemStack stack = e.getCursor(); + if (stack == null) + return; + if (!stack.hasItemMeta()) + return; + if (stack.getItemMeta().hasEnchants()) { + for (Enchantment en : Enchantment.values()) { + if (stack.getEnchantmentLevel(en) > en.getMaxLevel()) + stack.removeEnchantment(en); + } + } + Player p = (Player) e.getWhoClicked(); + if (stack.getItemMeta().hasAttributeModifiers()) { + ItemMeta meta = stack.getItemMeta(); + for (Attribute a : Attribute.values()) + meta.removeAttributeModifier(a); + meta.setDisplayName("We know, that you tried to cheat..."); + System.out.println("Spieler " + p.getName() + " (UUID: " + p.getUniqueId().toString() + " ) hat versucht ein Item mit AttributeModifiers zu bekommen."); + stack.setItemMeta(meta); + } + Material material = stack.getType(); + if (material == Material.POTION || material == Material.SPLASH_POTION || material == Material.LINGERING_POTION) { + p.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, 100000, 1, false, false)); + stack.setType(Material.MILK_BUCKET); + } + e.setCurrentItem(stack); + } }