diff --git a/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java b/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java index 5ebdbc40..9f723d6b 100644 --- a/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java @@ -834,11 +834,14 @@ public class GeneralConfigManager { c.addComment("ExploitProtections.MythicMobs", "MythicMobs plugin support", "Disable if you having issues with it or using old version"); MythicMobsEnabled = c.get("ExploitProtections.MythicMobs.enabled", true); - c.addComment("ExploitProtections.Spawner.PreventSlimeSplit", "Prevent slime splitting when they are from spawner", - "Protects against exploiting as new splitted slimes is treated as naturally spawned and not from spawner"); - PreventSlimeSplit = c.get("ExploitProtections.Spawner.PreventSlimeSplit", true); - c.addComment("ExploitProtections.Spawner.PreventMagmaCubeSplit", "Prevent magmacube splitting when they are from spawner"); - PreventMagmaCubeSplit = c.get("ExploitProtections.Spawner.PreventMagmaCubeSplit", true); + // Only applies for older versions. + if (Version.isCurrentLower(Version.v1_14_R1)) { + c.addComment("ExploitProtections.Spawner.PreventSlimeSplit", "Prevent slime splitting when they are from spawner", + "Protects against exploiting as new splitted slimes is treated as naturally spawned and not from spawner"); + PreventSlimeSplit = c.get("ExploitProtections.Spawner.PreventSlimeSplit", true); + c.addComment("ExploitProtections.Spawner.PreventMagmaCubeSplit", "Prevent magmacube splitting when they are from spawner"); + PreventMagmaCubeSplit = c.get("ExploitProtections.Spawner.PreventMagmaCubeSplit", true); + } c.addComment("ExploitProtections.Smelt.PreventHopperFillUps", "Prevent payments when hoppers moving items into furnace", "Player will not get paid, but items will be smelted"); PreventHopperFillUps = c.get("ExploitProtections.Smelt.PreventHopperFillUps", true); diff --git a/src/main/java/com/gamingmesh/jobs/listeners/JobsPayment14Listener.java b/src/main/java/com/gamingmesh/jobs/listeners/JobsPayment14Listener.java index 5064ab26..5846ec9b 100644 --- a/src/main/java/com/gamingmesh/jobs/listeners/JobsPayment14Listener.java +++ b/src/main/java/com/gamingmesh/jobs/listeners/JobsPayment14Listener.java @@ -8,12 +8,16 @@ import java.util.UUID; import org.bukkit.Location; import org.bukkit.Material; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockCookEvent; +import org.bukkit.event.entity.EntityTransformEvent; import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.metadata.FixedMetadataValue; import com.gamingmesh.jobs.Jobs; import com.gamingmesh.jobs.actions.ItemActionInfo; @@ -25,6 +29,52 @@ public final class JobsPayment14Listener implements Listener { // BlockCookEvent does not have "cooking owner" private final Map> campPlayers = new HashMap<>(); + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onEntityTransformEvent(EntityTransformEvent event) { + + if (!Jobs.getGCManager().canPerformActionInWorld(event.getEntity().getWorld())) + return; + + if (!event.getEntity().hasMetadata(Jobs.getPlayerManager().getMobSpawnerMetadata())) + return; + + // Converting to string for backwards compatibility + switch (event.getTransformReason().toString()) { + case "CURED": + break; + case "DROWNED": + if (!event.getEntityType().equals(EntityType.ZOMBIE)) + return; + + event.getTransformedEntity().setMetadata(Jobs.getPlayerManager().getMobSpawnerMetadata(), new FixedMetadataValue(Jobs.getInstance(), true)); + break; + case "FROZEN": + if (!event.getEntityType().equals(EntityType.SKELETON)) + return; + event.getTransformedEntity().setMetadata(Jobs.getPlayerManager().getMobSpawnerMetadata(), new FixedMetadataValue(Jobs.getInstance(), true)); + break; + case "INFECTION": + break; + case "LIGHTNING": + break; + case "PIGLIN_ZOMBIFIED": + break; + case "SHEARED": + break; + case "SPLIT": + if (!event.getEntityType().equals(EntityType.SLIME) && !event.getEntityType().equals(EntityType.MAGMA_CUBE)) + return; + for (Entity entity : event.getTransformedEntities()) { + entity.setMetadata(Jobs.getPlayerManager().getMobSpawnerMetadata(), new FixedMetadataValue(Jobs.getInstance(), true)); + } + break; + case "UNKNOWN": + break; + default: + break; + } + } + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onCook(BlockCookEvent event) { if (!(event.getBlock().getType() != Material.CAMPFIRE) || campPlayers.isEmpty()) diff --git a/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java b/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java index 0b1a7c3d..b6ff41b0 100644 --- a/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java +++ b/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java @@ -1435,6 +1435,11 @@ public final class JobsPaymentListener implements Listener { @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onCreatureSpawn(SlimeSplitEvent event) { + + // As of 1.14 we have appropriate event to mob changes + if (Version.isCurrentEqualOrHigher(Version.v1_14_R1)) + return; + if (!Jobs.getGCManager().canPerformActionInWorld(event.getEntity().getWorld())) return;