Fix issue with WiredEffectTeleport. Credits to Beny.

This commit is contained in:
KrewsOrg 2020-02-08 11:31:56 +00:00
parent aec2626296
commit 43f0e54209
4 changed files with 13 additions and 13 deletions

View File

@ -42,7 +42,7 @@ public class WiredEffectTeleport extends InteractionWiredEffect {
} }
public static void teleportUnitToTile(RoomUnit roomUnit, RoomTile tile) { public static void teleportUnitToTile(RoomUnit roomUnit, RoomTile tile) {
if (roomUnit == null || tile == null) if (roomUnit == null || tile == null || roomUnit.isWiredTeleporting)
return; return;
Room room = roomUnit.getRoom(); Room room = roomUnit.getRoom();

View File

@ -30,6 +30,7 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ScheduledFuture; import java.util.concurrent.ScheduledFuture;
public class RoomUnit { public class RoomUnit {
public boolean isWiredTeleporting = false;
private final ConcurrentHashMap<RoomUnitStatus, String> status; private final ConcurrentHashMap<RoomUnitStatus, String> status;
private final THashMap<String, Object> cacheable; private final THashMap<String, Object> cacheable;
public boolean canRotate = true; public boolean canRotate = true;

View File

@ -194,19 +194,16 @@ public class WiredHandler {
if (effect != null && effect.canExecute(millis)) { if (effect != null && effect.canExecute(millis)) {
executed = true; executed = true;
if (!effect.requiresTriggeringUser() || (roomUnit != null && effect.requiresTriggeringUser())) { if (!effect.requiresTriggeringUser() || (roomUnit != null && effect.requiresTriggeringUser())) {
Emulator.getThreading().run(new Runnable() { Emulator.getThreading().run(() -> {
@Override if (room.isLoaded()) {
public void run() { try {
if (room.isLoaded()) { if (!effect.execute(roomUnit, room, stuff)) return;
try { effect.setCooldown(millis);
if (!effect.execute(roomUnit, room, stuff)) return; } catch (Exception e) {
effect.setCooldown(millis); Emulator.getLogging().logErrorLine(e);
} catch (Exception e) {
Emulator.getLogging().logErrorLine(e);
}
effect.activateBox(room);
} }
effect.activateBox(room);
} }
}, effect.getDelay() * 500); }, effect.getDelay() * 500);
} }

View File

@ -27,6 +27,7 @@ public class RoomUnitTeleport implements Runnable {
this.y = y; this.y = y;
this.z = z; this.z = z;
this.newEffect = newEffect; this.newEffect = newEffect;
roomUnit.isWiredTeleporting = true;
} }
@Override @Override
@ -53,6 +54,7 @@ public class RoomUnitTeleport implements Runnable {
ServerMessage teleportMessage = new RoomUnitOnRollerComposer(this.roomUnit, t, this.room).compose(); ServerMessage teleportMessage = new RoomUnitOnRollerComposer(this.roomUnit, t, this.room).compose();
this.roomUnit.setLocation(t); this.roomUnit.setLocation(t);
this.room.sendComposer(teleportMessage); this.room.sendComposer(teleportMessage);
roomUnit.isWiredTeleporting = false;
this.room.updateHabbosAt(t.x, t.y); this.room.updateHabbosAt(t.x, t.y);
this.room.updateBotsAt(t.x, t.y); this.room.updateBotsAt(t.x, t.y);