mirror of
https://github.com/Zrips/Jobs.git
synced 2024-11-25 20:16:13 +01:00
Entity split spawned from spawners fix
This commit is contained in:
parent
51657e8b9a
commit
2639e9802d
@ -24,14 +24,16 @@ import com.gamingmesh.jobs.actions.ItemActionInfo;
|
||||
import com.gamingmesh.jobs.container.ActionType;
|
||||
import com.gamingmesh.jobs.container.PlayerCamp;
|
||||
|
||||
import net.Zrips.CMILib.Logs.CMIDebug;
|
||||
|
||||
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)
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onEntityTransformEvent(EntityTransformEvent event) {
|
||||
|
||||
|
||||
if (!Jobs.getGCManager().canPerformActionInWorld(event.getEntity().getWorld()))
|
||||
return;
|
||||
|
||||
@ -62,6 +64,7 @@ public final class JobsPayment14Listener implements Listener {
|
||||
case "SHEARED":
|
||||
break;
|
||||
case "SPLIT":
|
||||
|
||||
if (!event.getEntityType().equals(EntityType.SLIME) && !event.getEntityType().equals(EntityType.MAGMA_CUBE))
|
||||
return;
|
||||
for (Entity entity : event.getTransformedEntities()) {
|
||||
|
@ -128,6 +128,7 @@ import net.Zrips.CMILib.Container.CMILocation;
|
||||
import net.Zrips.CMILib.Entities.CMIEntityType;
|
||||
import net.Zrips.CMILib.Items.CMIItemStack;
|
||||
import net.Zrips.CMILib.Items.CMIMaterial;
|
||||
import net.Zrips.CMILib.Logs.CMIDebug;
|
||||
import net.Zrips.CMILib.Version.Version;
|
||||
|
||||
public final class JobsPaymentListener implements Listener {
|
||||
@ -1250,10 +1251,13 @@ public final class JobsPaymentListener implements Listener {
|
||||
if (!Jobs.getGCManager().payNearSpawner() && lVictim.hasMetadata(Jobs.getPlayerManager().getMobSpawnerMetadata())) {
|
||||
try {
|
||||
// So lets remove meta in case some plugin removes entity in wrong way.
|
||||
lVictim.removeMetadata(Jobs.getPlayerManager().getMobSpawnerMetadata(), plugin);
|
||||
} catch (Exception ignored) {
|
||||
// Need to delay action for other function to properly check for existing meta data relating to this entity before clearing it out
|
||||
// Longer delay is needed due to mob split event being fired few seconds after mob dies and not at same time
|
||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> {
|
||||
lVictim.removeMetadata(Jobs.getPlayerManager().getMobSpawnerMetadata(), plugin);
|
||||
}, 200L);
|
||||
} catch (Throwable ignored) {
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user