Files
Server/src/engine/jobs/StuckJob.java
T

82 lines
2.4 KiB
Java
Raw Normal View History

2022-04-30 09:41:17 -04:00
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
// Magicbane Emulator Project © 2013 - 2022
// www.magicbane.com
2023-05-13 12:59:05 -04:00
package engine.jobs;
2022-04-30 09:41:17 -04:00
import engine.InterestManagement.WorldGrid;
import engine.job.AbstractScheduleJob;
import engine.math.Bounds;
import engine.math.Vector3fImmutable;
import engine.net.client.msg.ErrorPopupMsg;
import engine.objects.AbstractWorldObject;
import engine.objects.Building;
import engine.objects.PlayerCharacter;
import engine.server.MBServerStatics;
import java.util.HashSet;
public class StuckJob extends AbstractScheduleJob {
2023-05-13 12:59:05 -04:00
private final PlayerCharacter player;
2022-04-30 09:41:17 -04:00
2023-05-13 12:59:05 -04:00
public StuckJob(PlayerCharacter player) {
super();
this.player = player;
}
@Override
protected void doJob() {
2022-04-30 09:41:17 -04:00
Vector3fImmutable stuckLoc;
2023-05-13 12:59:05 -04:00
Building building = null;
2022-04-30 09:41:17 -04:00
if (player == null)
return;
2023-05-13 12:59:05 -04:00
2022-04-30 09:41:17 -04:00
if (player.getClientConnection() == null)
return;
2023-05-13 12:59:05 -04:00
HashSet<AbstractWorldObject> awoList = WorldGrid.getObjectsInRangePartial(player, 150, MBServerStatics.MASK_BUILDING);
for (AbstractWorldObject awo : awoList) {
2022-04-30 09:41:17 -04:00
2023-05-13 12:59:05 -04:00
Building buildingEntry = (Building) awo;
2022-04-30 09:41:17 -04:00
2023-05-13 12:59:05 -04:00
if (buildingEntry.getStuckLocation() == null)
continue;
if (Bounds.collide(player.getLoc(), buildingEntry)) {
building = buildingEntry;
break;
}
2022-04-30 09:41:17 -04:00
}
2023-05-13 12:59:05 -04:00
if (building == null) {
2022-04-30 09:41:17 -04:00
ErrorPopupMsg.sendErrorMsg(player, "Unable to find desired location");
return;
2023-05-13 12:59:05 -04:00
}
stuckLoc = building.getStuckLocation();
if (stuckLoc == null) {
ErrorPopupMsg.sendErrorMsg(player, "Unable to find desired location");
2022-04-30 09:41:17 -04:00
return;
}
2023-05-13 13:08:36 -04:00
player.teleport(stuckLoc);
2023-05-13 12:59:05 -04:00
}
2022-04-30 09:41:17 -04:00
2023-05-13 12:59:05 -04:00
@Override
protected void _cancelJob() {
}
2022-04-30 09:41:17 -04:00
}