From 5f9f3e816733c3ce1c51155b13ddabf1335de386 Mon Sep 17 00:00:00 2001 From: Jake Ben-Tovim Date: Mon, 28 Nov 2016 21:28:05 -0500 Subject: [PATCH] Fix 1.11 brewing, remove health bar from armor stands This fixes brewing on the newest Spigot API builds. The Alchemy skill was completely broken due to a change in the Spigot BrewEvent constructor, which this fixes via the changes to FakeBrewEvent.java and AlchemyPotionBrewer.java. This also adds a check in EntityListener.java for armor stands, so that health bars aren't displayed for them. The health bars never really displayed properly (armor stand health acts differently from most entities), and it allowed players to punch invisible armor stands server admins may have been intentionally hiding to temporarily reveal them via a health bar, which is an issue. --- src/main/java/META-INF/MANIFEST.MF | 3 +++ .../gmail/nossr50/events/fake/FakeBrewEvent.java | 4 ++-- .../gmail/nossr50/listeners/EntityListener.java | 16 +++++----------- .../skills/alchemy/AlchemyPotionBrewer.java | 2 +- 4 files changed, 11 insertions(+), 14 deletions(-) create mode 100644 src/main/java/META-INF/MANIFEST.MF diff --git a/src/main/java/META-INF/MANIFEST.MF b/src/main/java/META-INF/MANIFEST.MF new file mode 100644 index 000000000..f54353ad9 --- /dev/null +++ b/src/main/java/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Main-Class: com.gmail.nossr50.mcMMO + diff --git a/src/main/java/com/gmail/nossr50/events/fake/FakeBrewEvent.java b/src/main/java/com/gmail/nossr50/events/fake/FakeBrewEvent.java index 4d5537a5d..e7ef73c3e 100644 --- a/src/main/java/com/gmail/nossr50/events/fake/FakeBrewEvent.java +++ b/src/main/java/com/gmail/nossr50/events/fake/FakeBrewEvent.java @@ -5,7 +5,7 @@ import org.bukkit.event.inventory.BrewEvent; import org.bukkit.inventory.BrewerInventory; public class FakeBrewEvent extends BrewEvent { - public FakeBrewEvent(Block brewer, BrewerInventory contents) { - super(brewer, contents); + public FakeBrewEvent(Block brewer, BrewerInventory contents, int fuelLevel) { + super(brewer, contents, fuelLevel); } } diff --git a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java index 13bc19bb6..0590b3f23 100644 --- a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java @@ -4,17 +4,7 @@ import org.bukkit.Material; import org.bukkit.OfflinePlayer; import org.bukkit.block.Block; import org.bukkit.enchantments.Enchantment; -import org.bukkit.entity.AnimalTamer; -import org.bukkit.entity.Arrow; -import org.bukkit.entity.Enderman; -import org.bukkit.entity.Entity; -import org.bukkit.entity.FallingBlock; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.entity.Projectile; -import org.bukkit.entity.TNTPrimed; -import org.bukkit.entity.Tameable; -import org.bukkit.entity.Wolf; +import org.bukkit.entity.*; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; @@ -155,6 +145,10 @@ public class EntityListener implements Listener { return; } + if (event.getEntity() instanceof ArmorStand) { + return; + } + double damage = event.getFinalDamage(); Entity defender = event.getEntity(); Entity attacker = event.getDamager(); diff --git a/src/main/java/com/gmail/nossr50/skills/alchemy/AlchemyPotionBrewer.java b/src/main/java/com/gmail/nossr50/skills/alchemy/AlchemyPotionBrewer.java index 79d161634..1d48adea8 100644 --- a/src/main/java/com/gmail/nossr50/skills/alchemy/AlchemyPotionBrewer.java +++ b/src/main/java/com/gmail/nossr50/skills/alchemy/AlchemyPotionBrewer.java @@ -128,7 +128,7 @@ public final class AlchemyPotionBrewer { } } - FakeBrewEvent event = new FakeBrewEvent(brewingStand.getBlock(), inventory); + FakeBrewEvent event = new FakeBrewEvent(brewingStand.getBlock(), inventory, ((BrewingStand) brewingStand).getFuelLevel()); mcMMO.p.getServer().getPluginManager().callEvent(event); if (event.isCancelled() || inputList.isEmpty()) {