From d254b491bcd07997ca65e393b955a5061dedcdf8 Mon Sep 17 00:00:00 2001 From: songoda Date: Sat, 22 Jun 2019 05:15:24 -0400 Subject: [PATCH] Added support for most protection plugins. --- .gitlab-ci.yml | 2 +- .../songoda/ultimatestacker/listeners/BlockListeners.java | 6 +++--- .../songoda/ultimatestacker/listeners/BreedListeners.java | 3 ++- .../ultimatestacker/listeners/EntityListeners.java | 4 ++-- .../ultimatestacker/listeners/InteractListeners.java | 3 ++- .../songoda/ultimatestacker/listeners/ItemListeners.java | 8 +++++--- .../songoda/ultimatestacker/listeners/ShearListeners.java | 3 ++- .../ultimatestacker/listeners/SheepDyeListeners.java | 3 ++- .../songoda/ultimatestacker/listeners/TameListeners.java | 3 ++- 9 files changed, 21 insertions(+), 14 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1de5a0e..1ab08e2 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -4,7 +4,7 @@ stages: variables: name: "UltimateStacker" path: "/builds/$CI_PROJECT_PATH" - version: "1.5" + version: "1.5.1" build: stage: build diff --git a/src/main/java/com/songoda/ultimatestacker/listeners/BlockListeners.java b/src/main/java/com/songoda/ultimatestacker/listeners/BlockListeners.java index b41e44a..4f93460 100644 --- a/src/main/java/com/songoda/ultimatestacker/listeners/BlockListeners.java +++ b/src/main/java/com/songoda/ultimatestacker/listeners/BlockListeners.java @@ -35,7 +35,7 @@ public class BlockListeners implements Listener { this.instance = instance; } - @EventHandler + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onSpawnerInteract(PlayerInteractEvent event) { Block block = event.getClickedBlock(); Player player = event.getPlayer(); @@ -104,7 +104,7 @@ public class BlockListeners implements Listener { Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(instance, () -> instance.getHologram().processChange(block), 10L); } - @EventHandler + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onSpawnerPlace(BlockPlaceEvent event) { Block block = event.getBlock(); Player player = event.getPlayer(); @@ -138,7 +138,7 @@ public class BlockListeners implements Listener { Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(instance, () -> instance.getHologram().processChange(block), 1L); } - @EventHandler(priority = EventPriority.HIGHEST) + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onBlockBreak(BlockBreakEvent event) { Block block = event.getBlock(); if (block.getType() != (instance.isServerVersionAtLeast(ServerVersion.V1_13) ? Material.SPAWNER : Material.valueOf("MOB_SPAWNER"))) return; diff --git a/src/main/java/com/songoda/ultimatestacker/listeners/BreedListeners.java b/src/main/java/com/songoda/ultimatestacker/listeners/BreedListeners.java index d36475d..1bd3684 100644 --- a/src/main/java/com/songoda/ultimatestacker/listeners/BreedListeners.java +++ b/src/main/java/com/songoda/ultimatestacker/listeners/BreedListeners.java @@ -3,6 +3,7 @@ package com.songoda.ultimatestacker.listeners; import com.songoda.ultimatestacker.UltimateStacker; import org.bukkit.Bukkit; import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.entity.EntityBreedEvent; import org.bukkit.metadata.FixedMetadataValue; @@ -15,7 +16,7 @@ public class BreedListeners implements Listener { this.instance = instance; } - @EventHandler + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onBread(EntityBreedEvent event) { Bukkit.getScheduler().scheduleSyncDelayedTask(instance, () -> { event.getFather().removeMetadata("breedCooldown", instance); diff --git a/src/main/java/com/songoda/ultimatestacker/listeners/EntityListeners.java b/src/main/java/com/songoda/ultimatestacker/listeners/EntityListeners.java index acae1c4..3933822 100644 --- a/src/main/java/com/songoda/ultimatestacker/listeners/EntityListeners.java +++ b/src/main/java/com/songoda/ultimatestacker/listeners/EntityListeners.java @@ -35,7 +35,7 @@ public class EntityListeners implements Listener { this.instance = instance; } - @EventHandler + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onSpawn(CreatureSpawnEvent event) { LivingEntity entity = event.getEntity(); entity.setMetadata("US_REASON", new FixedMetadataValue(instance, event.getSpawnReason().name())); @@ -49,7 +49,7 @@ public class EntityListeners implements Listener { } - @EventHandler + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onEgg(ItemSpawnEvent event) { if (event.getEntity().getItemStack().getType() != Material.EGG) return; diff --git a/src/main/java/com/songoda/ultimatestacker/listeners/InteractListeners.java b/src/main/java/com/songoda/ultimatestacker/listeners/InteractListeners.java index a791c62..a385661 100644 --- a/src/main/java/com/songoda/ultimatestacker/listeners/InteractListeners.java +++ b/src/main/java/com/songoda/ultimatestacker/listeners/InteractListeners.java @@ -10,6 +10,7 @@ import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.entity.*; import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.entity.SheepDyeWoolEvent; import org.bukkit.event.player.PlayerInteractAtEntityEvent; @@ -27,7 +28,7 @@ public class InteractListeners implements Listener { this.instance = instance; } - @EventHandler + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onInteract(PlayerInteractAtEntityEvent event) { if (!(event.getRightClicked() instanceof LivingEntity)) return; Player player = event.getPlayer(); diff --git a/src/main/java/com/songoda/ultimatestacker/listeners/ItemListeners.java b/src/main/java/com/songoda/ultimatestacker/listeners/ItemListeners.java index 723b443..e0558d1 100644 --- a/src/main/java/com/songoda/ultimatestacker/listeners/ItemListeners.java +++ b/src/main/java/com/songoda/ultimatestacker/listeners/ItemListeners.java @@ -8,6 +8,7 @@ import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.entity.Item; import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.entity.ItemMergeEvent; import org.bukkit.event.entity.ItemSpawnEvent; @@ -49,21 +50,22 @@ public class ItemListeners implements Listener { updateAmount(item, newAmount); event.getEntity().remove(); } - @EventHandler + + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onInvPickup(InventoryPickupItemEvent event) { event.setCancelled(true); updateInventory(event.getItem(), event.getInventory()); } - @EventHandler + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onDispense(ItemSpawnEvent event) { if (!Setting.STACK_ITEMS.getBoolean()) return; updateAmount(event.getEntity(), event.getEntity().getItemStack().getAmount()); } - @EventHandler + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onPickup(PlayerPickupItemEvent event) { if (event.getItem().getItemStack().getAmount() < 32) return; event.setCancelled(true); diff --git a/src/main/java/com/songoda/ultimatestacker/listeners/ShearListeners.java b/src/main/java/com/songoda/ultimatestacker/listeners/ShearListeners.java index 5df84e6..b4df9a2 100644 --- a/src/main/java/com/songoda/ultimatestacker/listeners/ShearListeners.java +++ b/src/main/java/com/songoda/ultimatestacker/listeners/ShearListeners.java @@ -11,6 +11,7 @@ import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; import org.bukkit.entity.LivingEntity; import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerShearEntityEvent; import org.bukkit.util.Vector; @@ -25,7 +26,7 @@ public class ShearListeners implements Listener { this.instance = instance; } - @EventHandler + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onShear(PlayerShearEntityEvent event) { Entity entity = event.getEntity(); diff --git a/src/main/java/com/songoda/ultimatestacker/listeners/SheepDyeListeners.java b/src/main/java/com/songoda/ultimatestacker/listeners/SheepDyeListeners.java index 8063a6f..0352d1f 100644 --- a/src/main/java/com/songoda/ultimatestacker/listeners/SheepDyeListeners.java +++ b/src/main/java/com/songoda/ultimatestacker/listeners/SheepDyeListeners.java @@ -9,6 +9,7 @@ import com.songoda.ultimatestacker.utils.settings.Setting; import org.bukkit.Material; import org.bukkit.entity.*; import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.entity.SheepDyeWoolEvent; import org.bukkit.event.player.PlayerShearEntityEvent; @@ -26,7 +27,7 @@ public class SheepDyeListeners implements Listener { this.instance = instance; } - @EventHandler + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onDye(SheepDyeWoolEvent event) { LivingEntity entity = event.getEntity(); diff --git a/src/main/java/com/songoda/ultimatestacker/listeners/TameListeners.java b/src/main/java/com/songoda/ultimatestacker/listeners/TameListeners.java index 9b0fcbb..07918f8 100644 --- a/src/main/java/com/songoda/ultimatestacker/listeners/TameListeners.java +++ b/src/main/java/com/songoda/ultimatestacker/listeners/TameListeners.java @@ -8,6 +8,7 @@ import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Tameable; import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.entity.EntityTameEvent; import org.bukkit.util.Vector; @@ -22,7 +23,7 @@ public class TameListeners implements Listener { this.instance = instance; } - @EventHandler + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onTame(EntityTameEvent event) { Entity entity = event.getEntity();