mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-15 23:26:16 +01:00
Fix cat lying down, remove dead code
This commit is contained in:
parent
a535cea8bc
commit
275728e65b
@ -158,54 +158,44 @@ public class EventListen implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onChunkUnload(final ChunkUnloadEvent event) {
|
||||
Runnable runnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ChunkCoord coord = new ChunkCoord(event.getChunk());
|
||||
Location loc = new Location(null, 0, 0, 0);
|
||||
boolean loadChunk = false;
|
||||
for (NPC npc : getAllNPCs()) {
|
||||
if (npc == null || !npc.isSpawned())
|
||||
continue;
|
||||
loc = npc.getEntity().getLocation(loc);
|
||||
boolean sameChunkCoordinates = coord.z == loc.getBlockZ() >> 4 && coord.x == loc.getBlockX() >> 4;
|
||||
if (!sameChunkCoordinates || !event.getWorld().equals(loc.getWorld()))
|
||||
continue;
|
||||
if (!npc.despawn(DespawnReason.CHUNK_UNLOAD)) {
|
||||
if (!(event instanceof Cancellable)) {
|
||||
loadChunk = true;
|
||||
toRespawn.put(coord, npc);
|
||||
continue;
|
||||
}
|
||||
((Cancellable) event).setCancelled(true);
|
||||
if (Messaging.isDebugging()) {
|
||||
Messaging.debug("Cancelled chunk unload at [" + coord.x + "," + coord.z + "]");
|
||||
}
|
||||
respawnAllFromCoord(coord);
|
||||
return;
|
||||
}
|
||||
ChunkCoord coord = new ChunkCoord(event.getChunk());
|
||||
Location loc = new Location(null, 0, 0, 0);
|
||||
boolean loadChunk = false;
|
||||
for (NPC npc : getAllNPCs()) {
|
||||
if (npc == null || !npc.isSpawned())
|
||||
continue;
|
||||
loc = npc.getEntity().getLocation(loc);
|
||||
boolean sameChunkCoordinates = coord.z == loc.getBlockZ() >> 4 && coord.x == loc.getBlockX() >> 4;
|
||||
if (!sameChunkCoordinates || !event.getWorld().equals(loc.getWorld()))
|
||||
continue;
|
||||
if (!npc.despawn(DespawnReason.CHUNK_UNLOAD)) {
|
||||
if (!(event instanceof Cancellable)) {
|
||||
loadChunk = true;
|
||||
toRespawn.put(coord, npc);
|
||||
if (Messaging.isDebugging()) {
|
||||
Messaging.debug("Despawned id", npc.getId(),
|
||||
"due to chunk unload at [" + coord.x + "," + coord.z + "]");
|
||||
continue;
|
||||
}
|
||||
((Cancellable) event).setCancelled(true);
|
||||
if (Messaging.isDebugging()) {
|
||||
Messaging.debug("Cancelled chunk unload at [" + coord.x + "," + coord.z + "]");
|
||||
}
|
||||
respawnAllFromCoord(coord);
|
||||
return;
|
||||
}
|
||||
toRespawn.put(coord, npc);
|
||||
if (Messaging.isDebugging()) {
|
||||
Messaging.debug("Despawned id", npc.getId(),
|
||||
"due to chunk unload at [" + coord.x + "," + coord.z + "]");
|
||||
}
|
||||
}
|
||||
if (loadChunk) {
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!event.getChunk().isLoaded()) {
|
||||
event.getChunk().load();
|
||||
}
|
||||
}
|
||||
if (loadChunk) {
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!event.getChunk().isLoaded()) {
|
||||
event.getChunk().load();
|
||||
}
|
||||
}
|
||||
}, 10);
|
||||
}
|
||||
}
|
||||
};
|
||||
if (event instanceof Cancellable || true) {
|
||||
runnable.run();
|
||||
} else {
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(), runnable);
|
||||
}, 10);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,6 @@ import org.bukkit.craftbukkit.v1_14_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_14_R1.entity.CraftPlayer;
|
||||
import org.bukkit.craftbukkit.v1_14_R1.entity.CraftWither;
|
||||
import org.bukkit.craftbukkit.v1_14_R1.event.CraftEventFactory;
|
||||
import org.bukkit.entity.Cat;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.FishHook;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
@ -1038,6 +1037,7 @@ public class NMSImpl implements NMSBridge {
|
||||
|
||||
@Override
|
||||
public void setLyingDown(org.bukkit.entity.Entity cat, boolean lying) {
|
||||
((EntityCat) getHandle(cat)).u(lying);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1681,10 +1681,6 @@ public class NMSImpl implements NMSBridge {
|
||||
}
|
||||
}
|
||||
|
||||
public static void setLyingDown(Cat cat, boolean lying) {
|
||||
((EntityCat) getHandle(cat)).u(lying);
|
||||
}
|
||||
|
||||
public static void setNotInSchool(EntityFish entity) {
|
||||
try {
|
||||
if (ENTITY_FISH_NUM_IN_SCHOOL != null) {
|
||||
|
@ -32,7 +32,6 @@ import org.bukkit.craftbukkit.v1_15_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer;
|
||||
import org.bukkit.craftbukkit.v1_15_R1.entity.CraftWither;
|
||||
import org.bukkit.craftbukkit.v1_15_R1.event.CraftEventFactory;
|
||||
import org.bukkit.entity.Cat;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.FishHook;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
@ -1041,6 +1040,7 @@ public class NMSImpl implements NMSBridge {
|
||||
|
||||
@Override
|
||||
public void setLyingDown(org.bukkit.entity.Entity cat, boolean lying) {
|
||||
((EntityCat) getHandle(cat)).u(lying);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1671,10 +1671,6 @@ public class NMSImpl implements NMSBridge {
|
||||
}
|
||||
}
|
||||
|
||||
public static void setLyingDown(Cat cat, boolean lying) {
|
||||
((EntityCat) getHandle(cat)).u(lying);
|
||||
}
|
||||
|
||||
public static void setNotInSchool(EntityFish entity) {
|
||||
try {
|
||||
if (ENTITY_FISH_NUM_IN_SCHOOL != null) {
|
||||
|
Loading…
Reference in New Issue
Block a user