Skip to content

Commit

Permalink
Adding chunk tickets to ending TP location
Browse files Browse the repository at this point in the history
  • Loading branch information
CoolLord22 committed Sep 6, 2023
1 parent 03d8dea commit c8bdad2
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/main/java/com/coollord22/otheranimalteleport/OATMethods.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@ public class OATMethods {
public static void teleportLeashedEnt(Entity ent, Location from, Location to, Player p, OtherAnimalTeleport plugin) {
String entID = "[Ent-" + ent.getEntityId() + "] ";
Chunk fromChunk = from.getChunk();
if(plugin.toUseTickets)
Chunk toChunk = to.getChunk();
if(plugin.toUseTickets) {
fromChunk.addPluginChunkTicket(plugin);
toChunk.addPluginChunkTicket(plugin);
}

plugin.log.logInfo(entID + "Attempting to null the leash holder.", Verbosity.HIGHEST);
((LivingEntity) ent).setLeashHolder(null);
Expand All @@ -36,8 +39,10 @@ public void run() {
plugin.log.logInfo(entID + "Re-attaching leash holder as " + p.getName() + ".", Verbosity.HIGHEST);
((LivingEntity) ent).setLeashHolder(p);

if(plugin.toUseTickets)
if(plugin.toUseTickets) {
fromChunk.removePluginChunkTicket(plugin);
toChunk.removePluginChunkTicket(plugin);
}

undoInvulnerable(ent, invulnerable, plugin);
}
Expand All @@ -47,8 +52,11 @@ public void run() {
public static void teleportEnt(Entity ent, Location from, Location to, Player p, OtherAnimalTeleport plugin) {
String entID = "[Ent-" + ent.getEntityId() + "] ";
Chunk fromChunk = from.getChunk();
if(plugin.toUseTickets)
Chunk toChunk = to.getChunk();
if(plugin.toUseTickets) {
fromChunk.addPluginChunkTicket(plugin);
toChunk.addPluginChunkTicket(plugin);
}

boolean invulnerable = ent.isInvulnerable();

Expand All @@ -62,8 +70,10 @@ public void run() {
plugin.log.logInfo(entID + "Teleporting entity" + ent.getType(), Verbosity.HIGH);
ent.teleport(to);

if(plugin.toUseTickets)
if(plugin.toUseTickets) {
fromChunk.removePluginChunkTicket(plugin);
toChunk.removePluginChunkTicket(plugin);
}

undoInvulnerable(ent, invulnerable, plugin);
}
Expand Down

0 comments on commit c8bdad2

Please sign in to comment.