From 483134df10b28a766f301935fdbed1da8a9315d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A1s=20Marczink=C3=B3?= Date: Tue, 18 Jun 2019 16:22:48 +0200 Subject: [PATCH 1/5] Update locale_hu_HU.properties --- .../resources/locale/locale_hu_HU.properties | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/main/resources/locale/locale_hu_HU.properties b/src/main/resources/locale/locale_hu_HU.properties index 0ae38bbdd..35d91c9cc 100644 --- a/src/main/resources/locale/locale_hu_HU.properties +++ b/src/main/resources/locale/locale_hu_HU.properties @@ -54,6 +54,7 @@ JSON.Notification.SuperAbility={0} #These are the JSON Strings used for SubSkills JSON.Acrobatics.Roll.Interaction.Activated=Teszt [[RED]]Gurul\u00E1s Teszt JSON.Acrobatics.SubSkill.Roll.Details.Tips=Ha guggolsz es\u00E9s k\u00F6zben megakad\u00E1lyozhatod, hogy k\u00E9tszer annyi k\u00E1rt szenvedj, amit \u00E1ltal\u00E1ban! +Anvil.SingleItemStack=[[RED]]Nem lehet megmenteni, vagy jav\u00EDtani \u00F6sszerakott t\u00E1rgyakat, el\u0151sz\u00F6r szed sz\u00E9t az \u00F6sszerakott t\u00E1rgyakat. #DO NOT USE COLOR CODES IN THE JSON KEYS #COLORS ARE DEFINED IN advanced.yml IF YOU WISH TO CHANGE THEM @@ -103,6 +104,8 @@ Commands.Party.Header=[[RED]]-----[][[GREEN]]PARTY[[RED]][]----- Commands.Party.Features.Header=[[RED]]-----[][[GREEN]]FUNKCI\u00D3K[[RED]][]----- # XP BAR Allows for the following variables -- {0} = Skill Level, {1} Current XP, {2} XP Needed for next level, {3} Power Level, {4} Percentage of Level # Make sure you turn on Experience_Bars.ThisMayCauseLag.AlwaysUpdateTitlesWhenXPIsGained if you want the XP bar title to update every time a player gains XP! +XPBar.Template={0} +XPBar.Template.EarlyGameBoost=[[GOLD]]Egy \u00FAj k\u00E9pess\u00E9g tanul\u00E1sa... XPBar.Acrobatics=Akrobatika [[GOLD]]{0}. [[WHITE]]Szint XPBar.Alchemy=Alk\u00EDmia [[GOLD]]{0}. [[WHITE]]Szint XPBar.Archery=\u00CDj\u00E1szat [[GOLD]]{0}. [[WHITE]]Szint @@ -367,29 +370,32 @@ Repair.Arcane.Fail=A m\u00E1gikus er\u0151 v\u00E9gleg elhagyta ezt a t\u00E1rgy Repair.Arcane.Lost=Nem volt\u00E1l el\u00E9g tapasztalt ahhoz, hogy megtarthass valamilyen var\u00E1zslatot is. Repair.Arcane.Perfect=[[GREEN]]Sikeresen megtartottad a m\u00E1gikus energi\u00E1kat ebben a t\u00E1rgyban. #SALVAGE -Salvage.Pretty.Name=\u00C9rt\u00E9kment\u00E9s +Salvage.Pretty.Name=\u00DAjrahasznos\u00EDt\u00E1s Salvage.SubSkill.UnderstandingTheArt.Name=A M\u0171v\u00E9szet Meg\u00E9rt\u00E9se Salvage.SubSkill.UnderstandingTheArt.Description=Nem csak a szomsz\u00E9dok szem\u00E9t\u00E9ben kutatsz, hanem gondoskodsz a k\u00F6rnyezetr\u0151l is.\nAz \u00C9rt\u00E9kment\u00E9s k\u00FCl\u00F6nb\u00F6z\u0151 tulajdons\u00E1gait n\u00F6veli. -Salvage.SubSkill.AdvancedSalvage.Name=Fejlesztett \u00DAjrahasznos\u00EDt\u00E1s -Salvage.SubSkill.AdvancedSalvage.Description=S\u00E9r\u00FClt t\u00E1rgyak \u00FAjrahasznos\u00EDt\u00E1sa +Salvage.SubSkill.ScrapCollector.Name=Hullad\u00E9kgy\u0171jt\u0151 +Salvage.SubSkill.ScrapCollector.Description=Hasznos\u00EDtsd \u00FAjra az anyagokat egy t\u00E1rgyb\u00F3l, egy sikeres \u00FAjrahasznos\u00EDt\u00E1s a k\u00E9pess\u00E9gen \u00E9s a szerencs\u00E9n m\u00FAlik. +Salvage.SubSkill.ScrapCollector.Stat=Hullad\u00E9kgy\u0171jt\u0151: [[GREEN]]Hullad\u00E9kgy\u0171jt\u0151: [[GREEN]]Hasznos\u00EDts \u00FAjra ak\u00E1r [[YELLOW]]{0}[[GREEN]] t\u00E1rgyat. Egy kis szerencs\u00E9vel. Salvage.SubSkill.ArcaneSalvage.Name=M\u00E1gikus \u00DAjrahasznos\u00EDt\u00E1s Salvage.SubSkill.ArcaneSalvage.Description=Var\u00E1zslatok kinyer\u00E9se t\u00E1rgyakb\u00F3l Salvage.SubSkill.ArcaneSalvage.Stat=M\u00E1gikus \u00DAjrahasznos\u00EDt\u00E1s Szint: [[YELLOW]] {0}/{1} -Salvage.Ability.Locked.0=LEZ\u00C1RVA {0}+ SZINT ALATT FEJLESZTETT \u00DAJRAHASZNOS\u00CDT\u00C1S -Salvage.Ability.Bonus.0=Fejlesztett \u00DAjrahasznos\u00EDt\u00E1s -Salvage.Ability.Bonus.1=Az \u00FAjhasznos\u00EDt\u00E1sb\u00F3l visszanyert maxim\u00E1lis anyagok {0} +Salvage.Ability.Bonus.0=Hullad\u00E9kgy\u0171jt\u0151 +Salvage.Ability.Bonus.1=Hasznos\u00EDts \u00FAjra ak\u00E1r [[YELLOW]]{0}[[GREEN]] t\u00E1rgyat. Egy kis szerencs\u00E9vel. Salvage.Arcane.ExtractFull=[[GRAY]]M\u00C9 Teljes-Var\u00E1zslat Es\u00E9ly Salvage.Arcane.ExtractPartial=[[GRAY]]M\u00C9 R\u00E9szleges-Var\u00E1zslat Es\u00E9ly Salvage.Skills.Success=[[GREEN]]T\u00E1rgy \u00DAjrahasznos\u00EDtva! Salvage.Skills.Adept.Damaged=[[DARK_RED]]Nem vagy el\u00E9g tapasztalt, hogy s\u00E9r\u00FClt t\u00E1rgyakat hasznos\u00EDthass \u00FAjra. -Salvage.Skills.Adept.Level=Sz\u00FCks\u00E9ges szint [[YELLOW]]{1}[[RED]] \u00FAjrafelhaszn\u00E1l\u00E1s\u00E1hoz: [[YELLOW]]{0} -Salvage.Skills.TooDamaged=[[DARK_RED]]Ez a t\u00E1rgy t\u00FAls\u00E1gosan s\u00E9r\u00FClt az \u00FAjrafelhaszn\u00E1l\u00E1shoz. +Salvage.Skills.Adept.Level=Sz\u00FCks\u00E9ges szint [[YELLOW]]{1}[[RED]] \u00FAjrahasznos\u00EDt\u00E1shoz: [[YELLOW]]{0} +Salvage.Skills.TooDamaged=[[DARK_RED]]Ez a t\u00E1rgy t\u00FAls\u00E1gosan s\u00E9r\u00FClt az \u00FAjrahasznos\u00EDt\u00E1shoz. Salvage.Skills.ArcaneFailed=[[RED]]Nem tudtad kinyerni a tud\u00E1st, ami ebben a t\u00E1rgyban lakozik. Salvage.Skills.ArcanePartial=[[RED]]Csak r\u00E9szleges tud\u00E1st tudt\u00E1l kinyerni ebb\u0151l a t\u00E1rgyb\u00F3l. Salvage.Skills.ArcaneSuccess=[[GREEN]]Sikeresen kinyert\u00E9l minden tud\u00E1st ebb\u0151l a t\u00E1rgyb\u00F3l! -Salvage.Listener.Anvil=[[DARK_RED]]Lehelyezt\u00E9l egy \u00C9rt\u00E9kment\u0151 \u00DCll\u0151t. Haszn\u00E1ld ezt eszk\u00F6z\u00F6k \u00E9s p\u00E1nc\u00E9lzatok \u00FAjrafelhaszn\u00E1l\u00E1shoz. +Salvage.Listener.Anvil=[[DARK_RED]]Lehelyezt\u00E9l egy \u00C9rt\u00E9kment\u0151 \u00DCll\u0151t. Haszn\u00E1ld ezt eszk\u00F6z\u00F6k, \u00E9s p\u00E1nc\u00E9lzatok \u00FAjrahasznos\u00EDt\u00E1shoz. Salvage.Listener=\u00DAjrahasznos\u00EDt\u00E1s: Salvage.SkillName=\u00DAJRAHASZNOS\u00CDT\u00C1S +Salvage.Skills.Lottery.Normal=[[GOLD]]\u00DAjrahasznos\u00EDthatsz [[GREEN]]{0}[[GOLD]] anyagot ebb\u0151l [[DARK_AQUA]]{1}[[GOLD]]. +Salvage.Skills.Lottery.Perfect=[[GREEN]][[BOLD]]T\u00F6k\u00E9letes![[RESET]][[GOLD]] K\u00F6nnyed\u00E9n \u00FAjrahasznos\u00EDtott\u00E1l egy [[GREEN]]{1}[[GOLD]]-t visszanyerve [[DARK_AQUA]]{0}[[GOLD]] anyagot. +Salvage.Skills.Lottery.Untrained=[[GRAY]]M\u00E9g nem vagy el\u00E9g k\u00E9pezett az \u00FAjrahasznos\u00EDt\u00E1sban. Csak [[RED]]{0}[[GRAY]] anyagot tudt\u00E1l helyre\u00E1ll\u00EDtani ebb\u0151l [[GREEN]]{1}[[GRAY]]. #Anvil (Shared between SALVAGE and REPAIR) Anvil.Unbreakable=Ez a t\u00E1rgy t\u00F6rhetetlen! #SWORDS From 43b7abafe7121ed0848d51d70ede07465ee22f0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A1s=20Marczink=C3=B3?= Date: Tue, 18 Jun 2019 16:29:06 +0200 Subject: [PATCH 2/5] Update locale_hu_HU.properties --- src/main/resources/locale/locale_hu_HU.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/locale/locale_hu_HU.properties b/src/main/resources/locale/locale_hu_HU.properties index 35d91c9cc..83ba3228d 100644 --- a/src/main/resources/locale/locale_hu_HU.properties +++ b/src/main/resources/locale/locale_hu_HU.properties @@ -54,7 +54,7 @@ JSON.Notification.SuperAbility={0} #These are the JSON Strings used for SubSkills JSON.Acrobatics.Roll.Interaction.Activated=Teszt [[RED]]Gurul\u00E1s Teszt JSON.Acrobatics.SubSkill.Roll.Details.Tips=Ha guggolsz es\u00E9s k\u00F6zben megakad\u00E1lyozhatod, hogy k\u00E9tszer annyi k\u00E1rt szenvedj, amit \u00E1ltal\u00E1ban! -Anvil.SingleItemStack=[[RED]]Nem lehet megmenteni, vagy jav\u00EDtani \u00F6sszerakott t\u00E1rgyakat, el\u0151sz\u00F6r szed sz\u00E9t az \u00F6sszerakott t\u00E1rgyakat. +Anvil.SingleItemStack=[[RED]]Nem lehet \u00FAjrahasznos\u00EDtani, vagy jav\u00EDtani \u00F6sszerakott t\u00E1rgyakat, el\u0151sz\u00F6r szed sz\u00E9t az \u00F6sszerakott t\u00E1rgyakat. #DO NOT USE COLOR CODES IN THE JSON KEYS #COLORS ARE DEFINED IN advanced.yml IF YOU WISH TO CHANGE THEM From c83d38b5c207cb62aa3f476a655156f21e90f71b Mon Sep 17 00:00:00 2001 From: nossr50 Date: Tue, 18 Jun 2019 13:06:26 -0700 Subject: [PATCH 3/5] Arrow Retrieval will no longer work with piercing enchant --- Changelog.txt | 4 ++ pom.xml | 2 +- .../datatypes/skills/PrimarySkillType.java | 1 - .../nossr50/listeners/EntityListener.java | 40 +++++++++++++------ .../nossr50/listeners/PlayerListener.java | 7 +++- src/main/java/com/gmail/nossr50/mcMMO.java | 1 + .../skills/archery/ArcheryManager.java | 6 ++- .../nossr50/util/skills/CombatUtils.java | 2 +- 8 files changed, 45 insertions(+), 18 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index 33151e218..21312639e 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,3 +1,7 @@ +Version 2.1.83 + Updated hu_HU locale (thanks andris155) + (FIX) Arrow Retrieval will no longer work with piercing enchant on crossbows + Version 2.1.82 Added new WG flag 'mcmmo-hardcore' if set to negative players will not be penalized by hardcore mode (if hardcore mode is enabled) it defaults to true Added proper error handling when loading parties file diff --git a/pom.xml b/pom.xml index dc655be5d..10b5b8c72 100755 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 com.gmail.nossr50.mcMMO mcMMO - 2.1.82 + 2.1.83-SNAPSHOT mcMMO https://github.com/mcMMO-Dev/mcMMO diff --git a/src/main/java/com/gmail/nossr50/datatypes/skills/PrimarySkillType.java b/src/main/java/com/gmail/nossr50/datatypes/skills/PrimarySkillType.java index 0def74ef8..24d21e972 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/skills/PrimarySkillType.java +++ b/src/main/java/com/gmail/nossr50/datatypes/skills/PrimarySkillType.java @@ -25,7 +25,6 @@ import com.gmail.nossr50.util.StringUtils; import com.gmail.nossr50.util.skills.RankUtils; import com.google.common.collect.ImmutableList; import org.bukkit.Color; -import org.bukkit.OfflinePlayer; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.entity.Tameable; diff --git a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java index f771cc1f2..ac6ceb618 100644 --- a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java @@ -22,7 +22,9 @@ import com.gmail.nossr50.util.BlockUtils; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.player.UserManager; +import com.gmail.nossr50.util.random.RandomChanceUtil; import com.gmail.nossr50.util.skills.CombatUtils; +import com.gmail.nossr50.util.skills.SkillActivationType; import com.gmail.nossr50.worldguard.WorldGuardManager; import com.gmail.nossr50.worldguard.WorldGuardUtils; import org.bukkit.Material; @@ -109,7 +111,8 @@ public class EntityListener implements Listener { ItemStack bow = event.getBow(); - if (bow != null && bow.containsEnchantment(Enchantment.ARROW_INFINITE)) { + if (bow != null + && bow.containsEnchantment(Enchantment.ARROW_INFINITE)) { projectile.setMetadata(mcMMO.infiniteArrowKey, mcMMO.metadataValue); } @@ -123,9 +126,10 @@ public class EntityListener implements Listener { if(WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld())) return; - if(event.getEntity() instanceof Player) + if(event.getEntity().getShooter() instanceof Player) { - Player player = (Player) event.getEntity(); + + Player player = (Player) event.getEntity().getShooter(); /* WORLD GUARD MAIN FLAG CHECK */ if(WorldGuardUtils.isWorldGuardLoaded()) @@ -133,16 +137,28 @@ public class EntityListener implements Listener { if(!WorldGuardManager.getInstance().hasMainFlag(player)) return; } + + Projectile projectile = event.getEntity(); + + //Hacky stuff for 1.13/1.14 compat + + String itemKey = player.getInventory().getItemInMainHand().getType().getKey().toString(); + + if(!itemKey.equalsIgnoreCase("minecraft:bow") && !itemKey.equalsIgnoreCase("minecraft:crossbow")) + return; + + projectile.setMetadata(mcMMO.bowForceKey, new FixedMetadataValue(plugin, 1.0)); + projectile.setMetadata(mcMMO.arrowDistanceKey, new FixedMetadataValue(plugin, projectile.getLocation())); + + for(Enchantment enchantment : player.getInventory().getItemInMainHand().getEnchantments().keySet()) { + if(enchantment.getName().equalsIgnoreCase("piercing")) + return; + } + + if (RandomChanceUtil.isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.ARCHERY_ARROW_RETRIEVAL, player)) { + projectile.setMetadata(mcMMO.trackedArrow, mcMMO.metadataValue); + } } - - Projectile projectile = event.getEntity(); - - if (!(projectile instanceof Arrow) || projectile.hasMetadata(mcMMO.bowForceKey)) { - return; - } - - projectile.setMetadata(mcMMO.bowForceKey, new FixedMetadataValue(plugin, 1.0)); - projectile.setMetadata(mcMMO.arrowDistanceKey, new FixedMetadataValue(plugin, projectile.getLocation())); } /** diff --git a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java index ea13ab98d..34f84ad60 100644 --- a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java @@ -279,7 +279,7 @@ public class PlayerListener implements Listener { //TODO Update to new API once available! Waiting for case CAUGHT_TREASURE: Item fishingCatch = (Item) event.getCaught(); - if (Config.getInstance().getFishingOverrideTreasures() && + if (Config.getInstance(). getFishingOverrideTreasures() && fishingCatch.getItemStack().getType() != Material.SALMON && fishingCatch.getItemStack().getType() != Material.COD && fishingCatch.getItemStack().getType() != Material.TROPICAL_FISH && @@ -450,6 +450,11 @@ public class PlayerListener implements Listener { Item drop = event.getItem(); ItemStack dropStack = drop.getItemStack(); + //Remove tracking + if(drop.hasMetadata(mcMMO.trackedArrow)) { + drop.removeMetadata(mcMMO.trackedArrow, mcMMO.p); + } + if (drop.hasMetadata(mcMMO.disarmedItemKey)) { if (!player.getName().equals(drop.getMetadata(mcMMO.disarmedItemKey).get(0).asString())) { event.setCancelled(true); diff --git a/src/main/java/com/gmail/nossr50/mcMMO.java b/src/main/java/com/gmail/nossr50/mcMMO.java index 1778f5737..9186e2206 100644 --- a/src/main/java/com/gmail/nossr50/mcMMO.java +++ b/src/main/java/com/gmail/nossr50/mcMMO.java @@ -118,6 +118,7 @@ public class mcMMO extends JavaPlugin { public final static String customVisibleKey = "mcMMO: Name Visibility"; public final static String droppedItemKey = "mcMMO: Tracked Item"; public final static String infiniteArrowKey = "mcMMO: Infinite Arrow"; + public final static String trackedArrow = "mcMMO: Tracked Arrow"; public final static String bowForceKey = "mcMMO: Bow Force"; public final static String arrowDistanceKey = "mcMMO: Arrow Distance"; public final static String BONUS_DROPS_METAKEY = "mcMMO: Double Drops"; diff --git a/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java b/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java index b67c72274..3fd7537df 100644 --- a/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java +++ b/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java @@ -16,6 +16,7 @@ import org.bukkit.Location; import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; +import org.bukkit.entity.Projectile; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; @@ -67,9 +68,10 @@ public class ArcheryManager extends SkillManager { * * @param target The {@link LivingEntity} damaged by the arrow */ - public void retrieveArrows(LivingEntity target) { - if (RandomChanceUtil.isActivationSuccessful(SkillActivationType.RANDOM_LINEAR_100_SCALE_WITH_CAP, SubSkillType.ARCHERY_ARROW_RETRIEVAL, getPlayer())) { + public void retrieveArrows(LivingEntity target, Projectile projectile) { + if(projectile.hasMetadata(mcMMO.trackedArrow)) { Archery.incrementTrackerValue(target); + projectile.removeMetadata(mcMMO.trackedArrow, mcMMO.p); //Only 1 entity per projectile } } diff --git a/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java b/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java index 26cd72431..4b82e237f 100644 --- a/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java +++ b/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java @@ -223,7 +223,7 @@ public final class CombatUtils { } if (!arrow.hasMetadata(mcMMO.infiniteArrowKey) && archeryManager.canRetrieveArrows()) { - archeryManager.retrieveArrows(target); + archeryManager.retrieveArrows(target, arrow); } if(canUseLimitBreak(player, SubSkillType.ARCHERY_ARCHERY_LIMIT_BREAK)) From fa6995b9fdc73895fd556fdf98a78d635b9eea19 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Tue, 18 Jun 2019 14:04:42 -0700 Subject: [PATCH 4/5] You can no longer set fire to party members --- Changelog.txt | 2 + .../nossr50/listeners/EntityListener.java | 181 ++++++++++-------- 2 files changed, 107 insertions(+), 76 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index 21312639e..bf47cabb8 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,6 +1,8 @@ Version 2.1.83 Updated hu_HU locale (thanks andris155) (FIX) Arrow Retrieval will no longer work with piercing enchant on crossbows + WG Flags should now correctly recognize when a projectile belongs to a player and respect flag settings + You can no longer set party members on fire with your bow Version 2.1.82 Added new WG flag 'mcmmo-hardcore' if set to negative players will not be penalized by hardcore mode (if hardcore mode is enabled) it defaults to true diff --git a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java index ac6ceb618..fbeca79db 100644 --- a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java @@ -32,9 +32,7 @@ import org.bukkit.OfflinePlayer; import org.bukkit.block.Block; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.*; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; +import org.bukkit.event.*; import org.bukkit.event.entity.*; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityDamageEvent.DamageModifier; @@ -275,6 +273,27 @@ public class EntityListener implements Listener { } } + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + public void onEntityCombustByEntityEvent(EntityCombustByEntityEvent event) { + //Prevent players from setting fire to each other if they are in the same party + if(event.getEntity() instanceof Player) { + Player defender = (Player) event.getEntity(); + + if(event.getCombuster() instanceof Projectile) { + Projectile projectile = (Projectile) event.getCombuster(); + if(projectile.getShooter() instanceof Player) { + Player attacker = (Player) projectile.getShooter(); + if(checkParties(event, defender, attacker)) + return; + } + } else if(event.getCombuster() instanceof Player) { + Player attacker = (Player) event.getCombuster(); + if(checkParties(event, defender, attacker)) + return; + } + } + } + /** * Handle EntityDamageByEntity events that involve modifying the event. * @@ -287,6 +306,26 @@ public class EntityListener implements Listener { Entity defender = event.getEntity(); Entity attacker = event.getDamager(); + if(WorldGuardUtils.isWorldGuardLoaded()) + { + if(attacker instanceof Player) { + + if(!WorldGuardManager.getInstance().hasMainFlag((Player) attacker)) + return; + + } else if(attacker instanceof Projectile) { + + Projectile projectile = (Projectile) attacker; + + if(projectile.getShooter() instanceof Player) { + if(!WorldGuardManager.getInstance().hasMainFlag((Player) projectile.getShooter())) + return; + } + + } + } + + /* WORLD BLACKLIST CHECK */ if(WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld())) return; @@ -305,44 +344,6 @@ public class EntityListener implements Listener { return; } - if(attacker instanceof Player) - { - Player player = (Player) attacker; - - /* WORLD GUARD MAIN FLAG CHECK */ - if(WorldGuardUtils.isWorldGuardLoaded()) - { - if(!WorldGuardManager.getInstance().hasMainFlag(player)) - return; - } - } - - if (damage <= 0) { - if (defender instanceof Player && attacker instanceof Player) { - Player defendingPlayer = (Player) defender; - Player attackingPlayer = (Player) attacker; - if (event.getDamage(DamageModifier.ABSORPTION) > 0) { - //If friendly fire is off don't allow players to hurt one another - if(!Config.getInstance().getPartyFriendlyFire()) - if ((PartyManager.inSameParty(defendingPlayer, attackingPlayer) || PartyManager.areAllies(defendingPlayer, attackingPlayer)) && !(Permissions.friendlyFire(attackingPlayer) && Permissions.friendlyFire(defendingPlayer))) { - event.setCancelled(true); - return; - } - } - } - return; - } - - - /* - As far as I can tell at one point we registered meta-data about custom damage and we no longer do that. - - if (defender.hasMetadata(mcMMO.customDamageKey)) { - defender.removeMetadata(mcMMO.customDamageKey, plugin); - return; - } - */ - if (Misc.isNPCEntityExcludingVillagers(defender) || !defender.isValid() || !(defender instanceof LivingEntity)) { return; } @@ -357,26 +358,7 @@ public class EntityListener implements Listener { return; } - if (attacker instanceof Projectile) { - ProjectileSource projectileSource = ((Projectile) attacker).getShooter(); - - if (projectileSource instanceof LivingEntity) { - attacker = (LivingEntity) projectileSource; - } - - if(defender instanceof Player) { - Player playerDefender = (Player) defender; - UnarmedManager unarmedManager = UserManager.getPlayer(playerDefender).getUnarmedManager(); - - if (unarmedManager.canDeflect()) { - if(unarmedManager.deflectCheck()) { - event.setCancelled(true); - return; - } - } - } - } - else if (attacker instanceof Tameable) { + if (attacker instanceof Tameable) { AnimalTamer animalTamer = ((Tameable) attacker).getOwner(); if (animalTamer != null && ((OfflinePlayer) animalTamer).isOnline()) { @@ -389,26 +371,50 @@ public class EntityListener implements Listener { } } - if (defender instanceof Player && attacker instanceof Player) { + //Friendly fire checks + if (defender instanceof Player) { Player defendingPlayer = (Player) defender; - Player attackingPlayer = (Player) attacker; + Player attackingPlayer; - if (!UserManager.hasPlayerDataKey(defendingPlayer) || !UserManager.hasPlayerDataKey(attackingPlayer)) { - return; - } + //If the attacker is a Player or a projectile beloning to a player + if(attacker instanceof Projectile || attacker instanceof Player) { + if(attacker instanceof Projectile) { + Projectile projectile = (Projectile) attacker; + if(((Projectile) attacker).getShooter() instanceof Player) { + attackingPlayer = (Player) projectile.getShooter(); - // We want to make sure we're not gaining XP or applying abilities - // when we hit ourselves - if (defendingPlayer.equals(attackingPlayer)) { - return; - } + //Check for party friendly fire and cancel the event + if (checkParties(event, defendingPlayer, attackingPlayer)) + { + return; + } - //Party Friendly Fire - if(!Config.getInstance().getPartyFriendlyFire()) - if ((PartyManager.inSameParty(defendingPlayer, attackingPlayer) || PartyManager.areAllies(defendingPlayer, attackingPlayer)) && !(Permissions.friendlyFire(attackingPlayer) && Permissions.friendlyFire(defendingPlayer))) { - event.setCancelled(true); - return; + } + + //Deflect checks + UnarmedManager unarmedManager = UserManager.getPlayer(defendingPlayer).getUnarmedManager(); + + if (unarmedManager.canDeflect()) { + if(unarmedManager.deflectCheck()) { + event.setCancelled(true); + return; + } + } + } else { + attackingPlayer = (Player) attacker; + //Check for party friendly fire and cancel the event + if (checkParties(event, defendingPlayer, attackingPlayer)) + return; } + } + } + + //Required setup for processCombatAttack + if(attacker instanceof Projectile) { + ProjectileSource shooter = ((Projectile) attacker).getShooter(); + if(shooter instanceof LivingEntity) { + attacker = (LivingEntity) shooter; + } } CombatUtils.processCombatAttack(event, attacker, target); @@ -429,6 +435,29 @@ public class EntityListener implements Listener { } + public boolean checkParties(Cancellable event, Player defendingPlayer, Player attackingPlayer) { + if (!UserManager.hasPlayerDataKey(defendingPlayer) || !UserManager.hasPlayerDataKey(attackingPlayer)) { + return true; + } + + // We want to make sure we're not gaining XP or applying abilities + // when we hit ourselves + if (defendingPlayer.equals(attackingPlayer)) { + return true; + } + + //Party Friendly Fire + if(!Config.getInstance().getPartyFriendlyFire()) + if ((PartyManager.inSameParty(defendingPlayer, attackingPlayer) + || PartyManager.areAllies(defendingPlayer, attackingPlayer)) + && !(Permissions.friendlyFire(attackingPlayer) + && Permissions.friendlyFire(defendingPlayer))) { + event.setCancelled(true); + return true; + } + return false; + } + /** * Handle EntityDamage events that involve modifying the event. * From 83636644b13a4ad8683ba7f4ee2943e43aeb80dd Mon Sep 17 00:00:00 2001 From: nossr50 Date: Tue, 18 Jun 2019 15:28:56 -0700 Subject: [PATCH 5/5] 2.1.84 --- Changelog.txt | 7 +++++-- pom.xml | 2 +- .../java/com/gmail/nossr50/listeners/EntityListener.java | 3 +-- .../java/com/gmail/nossr50/util/skills/CombatUtils.java | 4 +++- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index bf47cabb8..5480c1e3a 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,8 +1,11 @@ +Version 2.1.84 + Added some code to make mcMMO more compatible with EpicSpawners + Version 2.1.83 - Updated hu_HU locale (thanks andris155) + You can no longer set party members on fire with your bow (FIX) Arrow Retrieval will no longer work with piercing enchant on crossbows WG Flags should now correctly recognize when a projectile belongs to a player and respect flag settings - You can no longer set party members on fire with your bow + Updated hu_HU locale (thanks andris155) Version 2.1.82 Added new WG flag 'mcmmo-hardcore' if set to negative players will not be penalized by hardcore mode (if hardcore mode is enabled) it defaults to true diff --git a/pom.xml b/pom.xml index 10b5b8c72..2b03a980b 100755 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 com.gmail.nossr50.mcMMO mcMMO - 2.1.83-SNAPSHOT + 2.1.84 mcMMO https://github.com/mcMMO-Dev/mcMMO diff --git a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java index fbeca79db..c16356e70 100644 --- a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java @@ -325,7 +325,6 @@ public class EntityListener implements Listener { } } - /* WORLD BLACKLIST CHECK */ if(WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld())) return; @@ -694,7 +693,7 @@ public class EntityListener implements Listener { * @param event * The event to watch */ - @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + @EventHandler(priority = EventPriority.MONITOR) public void onCreatureSpawn(CreatureSpawnEvent event) { /* WORLD BLACKLIST CHECK */ if(WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld())) diff --git a/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java b/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java index 4b82e237f..35a5ab83b 100644 --- a/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java +++ b/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java @@ -616,7 +616,9 @@ public final class CombatUtils { } } - if (target.hasMetadata(mcMMO.entityMetadataKey)) { + if (target.hasMetadata(mcMMO.entityMetadataKey) + //Epic Spawners compatibility + || target.hasMetadata("ES")) { baseXP *= ExperienceConfig.getInstance().getSpawnedMobXpMultiplier(); }