From ce12ae2aaeec256aa1c2922fc7440041af3255d0 Mon Sep 17 00:00:00 2001 From: Aleksander Evensen Date: Wed, 4 Dec 2019 20:20:49 +0100 Subject: [PATCH 1/2] Added Totem options to the config.yml --- src/main/resources/config.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 4972966..b006776 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -34,3 +34,11 @@ RespawnWildText: "With no place of rest set, you awake from your dream in famili +#Totme fixed +TotemOfUndyingWorks: true # Disable or enable the Totem of Undying +TotemDeathPlayerText: "A magical power saves you from a potential casualty." # Text to display for the user when he/she uses a Totem of Undying + + + + + From 7ca835315dec637d6a3ac279242ac432fc177df3 Mon Sep 17 00:00:00 2001 From: Aleksander Evensen Date: Wed, 4 Dec 2019 21:10:53 +0100 Subject: [PATCH 2/2] Added the totem fix in PlayerDamageListener.java --- .../listeners/PlayerDamageListener.java | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/main/java/me/griimnak/hardcoreplus/listeners/PlayerDamageListener.java b/src/main/java/me/griimnak/hardcoreplus/listeners/PlayerDamageListener.java index a06b2e2..9cc98e1 100644 --- a/src/main/java/me/griimnak/hardcoreplus/listeners/PlayerDamageListener.java +++ b/src/main/java/me/griimnak/hardcoreplus/listeners/PlayerDamageListener.java @@ -5,6 +5,7 @@ import org.bukkit.ChatColor; import org.bukkit.Effect; import org.bukkit.Material; +import org.bukkit.Particle; import org.bukkit.attribute.Attribute; import org.bukkit.entity.ExperienceOrb; import org.bukkit.entity.Player; @@ -36,7 +37,28 @@ public void onPlayerDamage(EntityDamageEvent event) { } // if hp - dmg less or equal 0.0 - if((damaged.getHealth() - event.getFinalDamage()) <= 0.0D) { + if((damaged.getHealth() - event.getFinalDamage()) <= 0.0D) { + + /* + ========== + Totem fix + ========== + */ + // Check if totems are enabled in the config + if(ConfigManager.config.getBoolean("TotemOfUndyingWorks")){ + // Check if player is holding a Totem of Undying in Main- or Offhand + if(damaged.getInventory().getItemInMainHand().getType().equals(Material.TOTEM_OF_UNDYING) || + damaged.getInventory().getItemInOffHand().getType().equals(Material.TOTEM_OF_UNDYING)){ + + // Play the totem effect. + // Removing the totem from the players hand is unnecessary because the spawnParticle will handle it. + damaged.spawnParticle(Particle.TOTEM, damaged.getLocation(), 1); + damaged.sendMessage(ChatColor.GREEN + "" + ChatColor.ITALIC + ConfigManager.config.getString("TotemDeathPlayerText")); + // return so the player won't be teleported to their bed or loose the amount of hearts specified. + return; + } + } + // max hp of damaged player double max_hp = damaged.getAttribute(Attribute.GENERIC_MAX_HEALTH).getBaseValue(); if(max_hp - ConfigManager.config.getDouble("LoseMaxHealthOnRespawnAmmount") > 0.0D) {