mirror of
https://github.com/Zrips/Jobs.git
synced 2025-01-02 14:29:07 +01:00
1.14 and up looses option to prevent slime/magma cube splits
As of 1.14 we will properly protect specific mobs on their change if they are spawned from spawner
This commit is contained in:
parent
64d9907a10
commit
ee4a323ddf
@ -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);
|
||||
|
@ -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<UUID, List<PlayerCamp>> 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())
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user