From 076c40119a1dea5832a1775bed047ee26a8c2bcc Mon Sep 17 00:00:00 2001 From: Zelytra Date: Thu, 26 Aug 2021 18:29:30 +0200 Subject: [PATCH] Remove enchant from mino head --- .../daedalus/events/EventsManager.java | 1 + .../items/listener/MinotaurHead.java | 28 +++++++++++++++++++ .../DeathHandler/listener/DeathListener.java | 2 +- .../listener/DefinitiveDeathListener.java | 4 +++ .../listener/PartielDeathListener.java | 5 ++++ .../managers/gods/list/Minotaure.java | 8 ------ 6 files changed, 39 insertions(+), 9 deletions(-) create mode 100644 src/main/java/fr/zelytra/daedalus/events/running/environnement/items/listener/MinotaurHead.java diff --git a/src/main/java/fr/zelytra/daedalus/events/EventsManager.java b/src/main/java/fr/zelytra/daedalus/events/EventsManager.java index da302bb..26a47e3 100644 --- a/src/main/java/fr/zelytra/daedalus/events/EventsManager.java +++ b/src/main/java/fr/zelytra/daedalus/events/EventsManager.java @@ -71,6 +71,7 @@ public static void registerEvents(Daedalus pl) { pm.registerEvents(new AresWarBanner(), pl); pm.registerEvents(new ArtemisHorn(), pl); pm.registerEvents(new PoseidonCoche(), pl); + pm.registerEvents(new MinotaurHead(), pl); /*Gods Handlers*/ diff --git a/src/main/java/fr/zelytra/daedalus/events/running/environnement/items/listener/MinotaurHead.java b/src/main/java/fr/zelytra/daedalus/events/running/environnement/items/listener/MinotaurHead.java new file mode 100644 index 0000000..fafc6f1 --- /dev/null +++ b/src/main/java/fr/zelytra/daedalus/events/running/environnement/items/listener/MinotaurHead.java @@ -0,0 +1,28 @@ +package fr.zelytra.daedalus.events.running.environnement.items.listener; + +import fr.zelytra.daedalus.Daedalus; +import fr.zelytra.daedalus.managers.items.CustomItemStack; +import fr.zelytra.daedalus.managers.items.CustomMaterial; +import org.bukkit.GameMode; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.inventory.InventoryType; + +public class MinotaurHead implements Listener { + + @EventHandler + public void onHeadRemove(InventoryClickEvent e) { + if (!Daedalus.getInstance().getGameManager().isRunning()) return; + + if (e.getWhoClicked().getGameMode() != GameMode.SURVIVAL) return; + + if (e.getInventory().getType() != InventoryType.CRAFTING) return; + + if (e.getCurrentItem() == null) return; + + if (CustomItemStack.getCustomMaterial(e.getCurrentItem()) == CustomMaterial.MINOTAUR_HEAD) + e.setCancelled(true); + + } +} diff --git a/src/main/java/fr/zelytra/daedalus/events/running/players/DeathHandler/listener/DeathListener.java b/src/main/java/fr/zelytra/daedalus/events/running/players/DeathHandler/listener/DeathListener.java index b7bc5af..8258cfd 100644 --- a/src/main/java/fr/zelytra/daedalus/events/running/players/DeathHandler/listener/DeathListener.java +++ b/src/main/java/fr/zelytra/daedalus/events/running/players/DeathHandler/listener/DeathListener.java @@ -57,7 +57,7 @@ public void onCustomDeath(EntityDamageEvent e) { } } - if (e.getCause() == EntityDamageEvent.DamageCause.FALL) { //Kill by falling + if (e.getCause() == EntityDamageEvent.DamageCause.FALL && e.getEntity().getLastDamageCause() != null) { //Kill by falling Player killer = (Player) ((EntityDamageByEntityEvent) e.getEntity().getLastDamageCause()).getDamager(); killByAMino = daedalus.getGameManager().getFactionManager().getFactionOf(killer).getGodsEnum() == GodsEnum.MINOTAURE; //Tuer par un mino } diff --git a/src/main/java/fr/zelytra/daedalus/events/running/players/DeathHandler/listener/DefinitiveDeathListener.java b/src/main/java/fr/zelytra/daedalus/events/running/players/DeathHandler/listener/DefinitiveDeathListener.java index df42b37..a4feb2b 100644 --- a/src/main/java/fr/zelytra/daedalus/events/running/players/DeathHandler/listener/DefinitiveDeathListener.java +++ b/src/main/java/fr/zelytra/daedalus/events/running/players/DeathHandler/listener/DefinitiveDeathListener.java @@ -120,6 +120,10 @@ private void deathFX(EntityDamageEvent e) { return; } else if (e.getCause() == EntityDamageEvent.DamageCause.FALL) { + if (e.getEntity().getLastDamageCause() == null) { + Bukkit.broadcastMessage(faction.getType().getPrefix() + e.getEntity().getName() + GameSettings.LANG.textOf("death.definitive")); + return; + } damageEvent = (EntityDamageByEntityEvent) e.getEntity().getLastDamageCause(); Bukkit.broadcastMessage(faction.getType().getPrefix() + e.getEntity().getName() + diff --git a/src/main/java/fr/zelytra/daedalus/events/running/players/DeathHandler/listener/PartielDeathListener.java b/src/main/java/fr/zelytra/daedalus/events/running/players/DeathHandler/listener/PartielDeathListener.java index 45cab6a..0b6ba1e 100644 --- a/src/main/java/fr/zelytra/daedalus/events/running/players/DeathHandler/listener/PartielDeathListener.java +++ b/src/main/java/fr/zelytra/daedalus/events/running/players/DeathHandler/listener/PartielDeathListener.java @@ -120,6 +120,11 @@ private void respawnFX(EntityDamageEvent e) { return; } else if (e.getCause() == EntityDamageEvent.DamageCause.FALL) { + if (e.getEntity().getLastDamageCause() == null) { + Bukkit.broadcastMessage(faction.getType().getPrefix() + e.getEntity().getName() + GameSettings.LANG.textOf("death.default")); + return; + } + damageEvent = (EntityDamageByEntityEvent) e.getEntity().getLastDamageCause(); Bukkit.broadcastMessage(faction.getType().getPrefix() + e.getEntity().getName() + diff --git a/src/main/java/fr/zelytra/daedalus/managers/gods/list/Minotaure.java b/src/main/java/fr/zelytra/daedalus/managers/gods/list/Minotaure.java index fb93f52..d1969e4 100644 --- a/src/main/java/fr/zelytra/daedalus/managers/gods/list/Minotaure.java +++ b/src/main/java/fr/zelytra/daedalus/managers/gods/list/Minotaure.java @@ -4,11 +4,8 @@ import fr.zelytra.daedalus.managers.gods.Gods; import fr.zelytra.daedalus.managers.items.CustomItemStack; import fr.zelytra.daedalus.managers.items.CustomMaterial; -import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemFlag; import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; @@ -24,11 +21,6 @@ public Minotaure(Faction faction) { playerList.remove(god.getUniqueId()); ItemStack item = new CustomItemStack(CustomMaterial.MINOTAUR_HEAD).getItem(); - ItemMeta meta = item.getItemMeta(); - meta.addEnchant(Enchantment.BINDING_CURSE,1,false); - meta.addItemFlags(ItemFlag.HIDE_ENCHANTS); - item.setItemMeta(meta); - faction.getGod().getInventory().setHelmet(item); }