From 22bddca721e200f189f0d5f68eb190a95672d4a9 Mon Sep 17 00:00:00 2001 From: SpaceNiklas Date: Wed, 12 Oct 2022 06:19:03 +0200 Subject: [PATCH] fix --- .../com/spaceniklas/villagerfixes/Listeners.java | 12 +++++++++--- src/main/resources/config.yml | 6 ++++-- target/classes/config.yml | 6 ++++-- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/spaceniklas/villagerfixes/Listeners.java b/src/main/java/com/spaceniklas/villagerfixes/Listeners.java index 071b44e..9098885 100644 --- a/src/main/java/com/spaceniklas/villagerfixes/Listeners.java +++ b/src/main/java/com/spaceniklas/villagerfixes/Listeners.java @@ -51,12 +51,18 @@ public void onPlayerJoinEvent(PlayerJoinEvent e){ @EventHandler public void onEntityDamageByEntityEvent(EntityDamageByEntityEvent e){ + if(Villagerfixes.config.getBoolean("make-invincible-players-damage-vincible-entities") && countdown.get(e.getDamager()) != null && countdown.get(e.getDamager()) && countdown.get(e.getEntity()) == null || Villagerfixes.config.getBoolean("make-invincible-players-damage-vincible-entities") && countdown.get(e.getDamager()) != null && countdown.get(e.getDamager()) && !countdown.get(e.getEntity())) { + if(!e.isCancelled()){ + e.setCancelled(false); + } + + }else if(countdown.get(e.getDamager()) != null && countdown.get(e.getDamager())){ e.setCancelled(true); - e.getDamager().sendMessage(ChatColor.translateAlternateColorCodes('&', Villagerfixes.config.getString("still-invincible"))); - }else + e.getDamager().sendMessage(ChatColor.translateAlternateColorCodes('&', Villagerfixes.config.getString("still-invincible-damager"))); + } if(countdown.get(e.getEntity()) != null && countdown.get(e.getEntity())){ - e.getDamager().sendMessage(ChatColor.translateAlternateColorCodes('&', Villagerfixes.config.getString("still-invincible"))); + e.getDamager().sendMessage(ChatColor.translateAlternateColorCodes('&', Villagerfixes.config.getString("still-invincible-victim"))); e.setCancelled(true); } } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 46f1d9b..733a58f 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -6,6 +6,8 @@ command-name: 'invincibility' #The name of the command you have to execute to es #LANGUAGE SETTINGS #You can use colour codes by doing & and then a letter or number. Reference image: https://www.spigotmc.org/attachments/example2-png.402641/ -still-invincible: '&cYou are still in invincibility! Do &l/invincibility &r&cto disable your invincibility!' #Message send when player takes/gives damage to another entity. +still-invincible-victim: '&cYou are still in invincibility! Do &l/invincibility &r&cto disable your invincibility!' #Message send when player takes/gives damage to another entity. +still-invincible-damager: '&cThe player you are hitting is still in invincibility!' #Message send when player takes/gives damage to another entity. already-vincible: '&cYou are already able to damage/get damaged by other entities! If you believe that this is a bug please contact a server administrator!' #If a player runs e.g /invisibility but is already vincible. -command-message: '&aYou are now able to damage/get damaged by other entities!' #Message when a player gets rid of their invisibility by command. \ No newline at end of file +command-message: '&aYou are now able to damage/get damaged by other entities!' #Message when a player gets rid of their invisibility by command. +make-invincible-players-damage-vincible-entities: false #Does what it says ;) \ No newline at end of file diff --git a/target/classes/config.yml b/target/classes/config.yml index 46f1d9b..733a58f 100644 --- a/target/classes/config.yml +++ b/target/classes/config.yml @@ -6,6 +6,8 @@ command-name: 'invincibility' #The name of the command you have to execute to es #LANGUAGE SETTINGS #You can use colour codes by doing & and then a letter or number. Reference image: https://www.spigotmc.org/attachments/example2-png.402641/ -still-invincible: '&cYou are still in invincibility! Do &l/invincibility &r&cto disable your invincibility!' #Message send when player takes/gives damage to another entity. +still-invincible-victim: '&cYou are still in invincibility! Do &l/invincibility &r&cto disable your invincibility!' #Message send when player takes/gives damage to another entity. +still-invincible-damager: '&cThe player you are hitting is still in invincibility!' #Message send when player takes/gives damage to another entity. already-vincible: '&cYou are already able to damage/get damaged by other entities! If you believe that this is a bug please contact a server administrator!' #If a player runs e.g /invisibility but is already vincible. -command-message: '&aYou are now able to damage/get damaged by other entities!' #Message when a player gets rid of their invisibility by command. \ No newline at end of file +command-message: '&aYou are now able to damage/get damaged by other entities!' #Message when a player gets rid of their invisibility by command. +make-invincible-players-damage-vincible-entities: false #Does what it says ;) \ No newline at end of file