Skip to content

Commit

Permalink
Add backcompat code
Browse files Browse the repository at this point in the history
  • Loading branch information
fullwall committed Sep 17, 2021
1 parent cdb7cbb commit cffb051
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions main/src/main/java/net/citizensnpcs/npc/ai/CitizensNavigator.java
Original file line number Diff line number Diff line change
Expand Up @@ -443,24 +443,35 @@ private boolean updateStationaryStatus() {
}

private void updateTicket(Location target) {
if (!CitizensAPI.hasImplementation() || !CitizensAPI.getPlugin().isEnabled())
if (!SUPPORT_CHUNK_TICKETS || !CitizensAPI.hasImplementation() || !CitizensAPI.getPlugin().isEnabled())
return;
if (target != null && this.activeTicket != null
&& new ChunkCoord(target.getChunk()).equals(new ChunkCoord(this.activeTicket.getChunk()))) {
this.activeTicket = target.clone();
return;
}
if (this.activeTicket != null) {
this.activeTicket.getChunk().removePluginChunkTicket(CitizensAPI.getPlugin());
try {
this.activeTicket.getChunk().removePluginChunkTicket(CitizensAPI.getPlugin());
} catch (NoSuchMethodError e) {
SUPPORT_CHUNK_TICKETS = false;
this.activeTicket = null;
}
}
if (target == null) {
this.activeTicket = null;
return;
}
this.activeTicket = target.clone();
this.activeTicket.getChunk().addPluginChunkTicket(CitizensAPI.getPlugin());
try {
this.activeTicket.getChunk().addPluginChunkTicket(CitizensAPI.getPlugin());
} catch (NoSuchMethodError e) {
SUPPORT_CHUNK_TICKETS = false;
this.activeTicket = null;
}
}

private static final Location STATIONARY_LOCATION = new Location(null, 0, 0, 0);
private static boolean SUPPORT_CHUNK_TICKETS = true;
private static int UNINITIALISED_SPEED = Integer.MIN_VALUE;
}

0 comments on commit cffb051

Please sign in to comment.