Don't update the /back target when the to/from transform are the same.
Fixes (well, works around it)
@@ -43,14 +43,14 @@ public class BackListeners extends ListenerBase implements Reloadable {
@Listener
@Exclude(MoveEntityEvent.Teleport.Portal.class) // Don't set /back on a portal.
public void onTeleportPlayer(MoveEntityEvent.Teleport event, @Getter("getTargetEntity") Player pl) {
- if (backConfig.isOnTeleport() && getLogBack(pl) && s.testSuffix(pl, ON_TELEPORT)) {
+ if (backConfig.isOnTeleport() && check(event) && getLogBack(pl) && s.testSuffix(pl, ON_TELEPORT)) {
handler.setLastLocation(pl, event.getFromTransform());
}
}
@Listener
public void onPortalPlayer(MoveEntityEvent.Teleport.Portal event, @Getter("getTargetEntity") Player pl) {
- if (backConfig.isOnPortal() && getLogBack(pl) && s.testSuffix(pl, ON_PORTAL)) {
+ if (backConfig.isOnPortal() && check(event) && getLogBack(pl) && s.testSuffix(pl, ON_PORTAL)) {
handler.setLastLocation(pl, event.getFromTransform());
}
}
@@ -68,6 +68,10 @@ public class BackListeners extends ListenerBase implements Reloadable {
}
}
+ private boolean check(MoveEntityEvent.Teleport event) {
+ return !event.getFromTransform().equals(event.getToTransform());
+ }
+
private boolean getLogBack(Player player) {
return !(njs != null && njs.isPlayerJailed(player)) && handler.isLoggingLastLocation(player);
}
