1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-12-30 21:07:48 +01:00

Entity split spawned from spawners fix

This commit is contained in:
Zrips 2022-03-07 17:19:59 +02:00
parent 51657e8b9a
commit 2639e9802d
2 changed files with 12 additions and 5 deletions

View File

@ -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()) {

View File

@ -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;
}