mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-12-25 18:47:40 +01:00
Add more info to debug messages to help with debugging
This commit is contained in:
parent
b5f179628a
commit
4bf4dc0651
@ -151,15 +151,15 @@ public class EventListen implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onChunkLoad(ChunkLoadEvent event) {
|
||||
ChunkCoord coord = new ChunkCoord(event.getChunk());
|
||||
Runnable runnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ChunkCoord coord = new ChunkCoord(event.getChunk());
|
||||
respawnAllFromCoord(coord, event);
|
||||
}
|
||||
};
|
||||
if (Messaging.isDebugging() && Setting.DEBUG_CHUNK_LOADS.asBoolean()) {
|
||||
new Exception("CITIZENS CHUNK LOAD DEBUG " + new ChunkCoord(event.getChunk())).printStackTrace();
|
||||
if (Messaging.isDebugging() && Setting.DEBUG_CHUNK_LOADS.asBoolean() && toRespawn.containsKey(coord)) {
|
||||
new Exception("CITIZENS CHUNK LOAD DEBUG " + coord).printStackTrace();
|
||||
}
|
||||
if (event instanceof Cancellable) {
|
||||
runnable.run();
|
||||
@ -185,7 +185,7 @@ public class EventListen implements Listener {
|
||||
if (!npc.despawn(DespawnReason.CHUNK_UNLOAD)) {
|
||||
if (!(event instanceof Cancellable)) {
|
||||
if (Messaging.isDebugging()) {
|
||||
Messaging.debug("Reloading chunk because", npc.getId(), "couldn't despawn");
|
||||
Messaging.debug("Reloading chunk because", npc, "couldn't despawn");
|
||||
}
|
||||
loadChunk = true;
|
||||
toRespawn.put(coord, npc);
|
||||
@ -198,7 +198,7 @@ public class EventListen implements Listener {
|
||||
}
|
||||
toRespawn.put(coord, npc);
|
||||
if (Messaging.isDebugging()) {
|
||||
Messaging.debug("Despawned id", npc.getId(), "due to chunk unload at", coord);
|
||||
Messaging.debug("Despawned", npc, "due to chunk unload at", coord);
|
||||
}
|
||||
}
|
||||
if (Messaging.isDebugging() && Setting.DEBUG_CHUNK_LOADS.asBoolean()) {
|
||||
@ -416,7 +416,7 @@ public class EventListen implements Listener {
|
||||
ChunkCoord coord = new ChunkCoord(event.getSpawnLocation());
|
||||
if (toRespawn.containsEntry(coord, event.getNPC()))
|
||||
return;
|
||||
Messaging.debug("Stored", event.getNPC().getId(), "for respawn from NPCNeedsRespawnEvent");
|
||||
Messaging.debug("Stored", event.getNPC(), "for respawn from NPCNeedsRespawnEvent");
|
||||
toRespawn.put(coord, event.getNPC());
|
||||
}
|
||||
|
||||
@ -425,13 +425,13 @@ public class EventListen implements Listener {
|
||||
if (event.getReason() == DespawnReason.PLUGIN || event.getReason() == DespawnReason.REMOVAL
|
||||
|| event.getReason() == DespawnReason.RELOAD) {
|
||||
if (Messaging.isDebugging()) {
|
||||
Messaging.debug("Preventing further respawns of", event.getNPC().getId(),
|
||||
Messaging.debug("Preventing further respawns of", event.getNPC(),
|
||||
"due to DespawnReason." + event.getReason());
|
||||
}
|
||||
toRespawn.values().remove(event.getNPC());
|
||||
} else if (Messaging.isDebugging()) {
|
||||
Messaging.debug("Removing " + event.getNPC().getId() + " from skin tracker due to DespawnReason."
|
||||
+ event.getReason().name());
|
||||
Messaging.debug("Removing", event.getNPC(),
|
||||
"from skin tracker due to DespawnReason." + event.getReason().name());
|
||||
}
|
||||
skinUpdateTracker.onNPCDespawn(event.getNPC());
|
||||
}
|
||||
@ -445,7 +445,7 @@ public class EventListen implements Listener {
|
||||
public void onNPCSpawn(NPCSpawnEvent event) {
|
||||
skinUpdateTracker.onNPCSpawn(event.getNPC());
|
||||
if (Messaging.isDebugging()) {
|
||||
Messaging.debug("Removing respawns of", event.getNPC().getId(), "due to SpawnReason." + event.getReason());
|
||||
Messaging.debug("Removing respawns of", event.getNPC(), "due to SpawnReason." + event.getReason());
|
||||
}
|
||||
toRespawn.values().remove(event.getNPC());
|
||||
}
|
||||
@ -681,7 +681,7 @@ public class EventListen implements Listener {
|
||||
}
|
||||
if (npc.isSpawned()) {
|
||||
toRespawn.put(new ChunkCoord(npc.getEntity().getLocation()), npc);
|
||||
Messaging.debug("Despawned", npc.getId() + "due to world unload at", event.getWorld().getName());
|
||||
Messaging.debug("Despawned", npc, "due to world unload at", event.getWorld().getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -695,13 +695,13 @@ public class EventListen implements Listener {
|
||||
NPC npc = ids.get(i);
|
||||
if (npc.getOwningRegistry().getById(npc.getId()) != npc) {
|
||||
if (Messaging.isDebugging()) {
|
||||
Messaging.debug("Prevented deregistered NPC from respawning", npc.getId());
|
||||
Messaging.debug("Prevented deregistered NPC from respawning", npc);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (npc.isSpawned()) {
|
||||
if (Messaging.isDebugging()) {
|
||||
Messaging.debug("Can't respawn NPC", npc.getId(), ": already spawned");
|
||||
Messaging.debug("Can't respawn NPC", npc, ": already spawned");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
@ -709,12 +709,12 @@ public class EventListen implements Listener {
|
||||
if (!success) {
|
||||
ids.remove(i--);
|
||||
if (Messaging.isDebugging()) {
|
||||
Messaging.debug("Couldn't respawn id", npc.getId(), "during", event, "at", coord);
|
||||
Messaging.debug("Couldn't respawn", npc, "during", event, "at", coord);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (Messaging.isDebugging()) {
|
||||
Messaging.debug("Spawned id", npc.getId(), "during", event, "at", coord);
|
||||
Messaging.debug("Spawned", npc, "during", event, "at", coord);
|
||||
}
|
||||
}
|
||||
for (NPC npc : ids) {
|
||||
@ -726,7 +726,7 @@ public class EventListen implements Listener {
|
||||
Location spawn = npc.getOrAddTrait(CurrentLocation.class).getLocation();
|
||||
if (spawn == null) {
|
||||
if (Messaging.isDebugging()) {
|
||||
Messaging.debug("Couldn't find a spawn location for despawned NPC id", npc.getId());
|
||||
Messaging.debug("Couldn't find a spawn location for despawned NPC", npc);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ public class CitizensNPC extends AbstractNPC {
|
||||
@Override
|
||||
public boolean despawn(DespawnReason reason) {
|
||||
if (!isSpawned() && reason != DespawnReason.DEATH) {
|
||||
Messaging.debug("Tried to despawn", getId(), "while already despawned, DespawnReason." + reason);
|
||||
Messaging.debug("Tried to despawn", toString(), "while already despawned, DespawnReason." + reason);
|
||||
if (reason == DespawnReason.RELOAD) {
|
||||
unloadEvents();
|
||||
}
|
||||
@ -81,7 +81,7 @@ public class CitizensNPC extends AbstractNPC {
|
||||
}
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (event.isCancelled() && reason != DespawnReason.DEATH) {
|
||||
Messaging.debug("Couldn't despawn", getId(), "due to despawn event cancellation. Will load chunk.",
|
||||
Messaging.debug("Couldn't despawn", toString(), "due to despawn event cancellation. Will load chunk.",
|
||||
getEntity().isValid(), ", DespawnReason." + reason);
|
||||
return false;
|
||||
}
|
||||
@ -99,7 +99,7 @@ public class CitizensNPC extends AbstractNPC {
|
||||
for (Trait trait : new ArrayList<Trait>(traits.values())) {
|
||||
trait.onDespawn();
|
||||
}
|
||||
Messaging.debug("Despawned", getId(), "DespawnReason." + reason);
|
||||
Messaging.debug("Despawned", toString(), "DespawnReason." + reason);
|
||||
if (reason == DespawnReason.DEATH) {
|
||||
entityController.setEntity(null);
|
||||
} else {
|
||||
@ -161,7 +161,7 @@ public class CitizensNPC extends AbstractNPC {
|
||||
if (spawnLocation.getLocation() != null) {
|
||||
spawn(spawnLocation.getLocation(), SpawnReason.RESPAWN);
|
||||
} else {
|
||||
Messaging.debug("Tried to spawn", getId(), "on load but world was null");
|
||||
Messaging.debug("Tried to spawn", toString(), "on load but world was null");
|
||||
}
|
||||
}
|
||||
|
||||
@ -240,11 +240,11 @@ public class CitizensNPC extends AbstractNPC {
|
||||
Preconditions.checkNotNull(at, "location cannot be null");
|
||||
Preconditions.checkNotNull(reason, "reason cannot be null");
|
||||
if (getEntity() != null) {
|
||||
Messaging.debug("Tried to spawn", getId(), "while already spawned. SpawnReason." + reason);
|
||||
Messaging.debug("Tried to spawn", toString(), "while already spawned. SpawnReason." + reason);
|
||||
return false;
|
||||
}
|
||||
if (at.getWorld() == null) {
|
||||
Messaging.debug("Tried to spawn", getId(), "but the world was null. SpawnReason." + reason);
|
||||
Messaging.debug("Tried to spawn", toString(), "but the world was null. SpawnReason." + reason);
|
||||
return false;
|
||||
}
|
||||
at = at.clone();
|
||||
@ -272,8 +272,8 @@ public class CitizensNPC extends AbstractNPC {
|
||||
|
||||
if (!couldSpawn) {
|
||||
if (Messaging.isDebugging()) {
|
||||
Messaging.debug("Retrying spawn of", getId(), "later, SpawnReason." + reason + ". Was loaded", loaded,
|
||||
"is loaded", Util.isLoaded(at));
|
||||
Messaging.debug("Retrying spawn of", toString(), "later, SpawnReason." + reason + ". Was loaded",
|
||||
loaded, "is loaded", Util.isLoaded(at));
|
||||
}
|
||||
// we need to wait before trying to spawn
|
||||
entityController.remove();
|
||||
@ -300,7 +300,7 @@ public class CitizensNPC extends AbstractNPC {
|
||||
|
||||
if (spawnEvent.isCancelled()) {
|
||||
entityController.remove();
|
||||
Messaging.debug("Couldn't spawn", getId(), "SpawnReason." + reason + " due to event cancellation.");
|
||||
Messaging.debug("Couldn't spawn", toString(), "SpawnReason." + reason + " due to event cancellation.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -337,7 +337,7 @@ public class CitizensNPC extends AbstractNPC {
|
||||
updateCustomNameVisibility();
|
||||
updateCustomName();
|
||||
|
||||
Messaging.debug("Spawned", getId(), "SpawnReason." + reason);
|
||||
Messaging.debug("Spawned", toString(), "SpawnReason." + reason);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -352,6 +352,11 @@ public class CitizensNPC extends AbstractNPC {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getId() + "{" + getName() + ", " + getOrAddTrait(MobType.class).getType() + "}";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
try {
|
||||
|
Loading…
Reference in New Issue
Block a user