Files
prestonbane/src/engine/devcmd/cmds/GotoObj.java
T

103 lines
3.4 KiB
Java
Raw Normal View History

2022-04-30 09:41:17 -04:00
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀
// Magicbane Emulator Project © 2013 - 2022
// www.magicbane.com
package engine.devcmd.cmds;
import engine.mbEnums;
2022-04-30 09:41:17 -04:00
import engine.devcmd.AbstractDevCmd;
import engine.gameManager.DbManager;
import engine.math.Vector3fImmutable;
import engine.objects.*;
public class GotoObj extends AbstractDevCmd {
2023-07-15 09:23:48 -04:00
public GotoObj() {
2022-04-30 09:41:17 -04:00
super("gotoobj");
}
2023-07-15 09:23:48 -04:00
@Override
protected void _doCmd(PlayerCharacter player, String[] words,
AbstractGameObject target) {
int uuid;
Vector3fImmutable targetLoc = Vector3fImmutable.ZERO;
mbEnums.DbObjectType objectType;
2023-07-15 09:23:48 -04:00
try {
uuid = Integer.parseInt(words[0]);
} catch (NumberFormatException e) {
this.throwbackError(player, "Failed to parse UUID" + e.toString());
return;
}
objectType = DbManager.BuildingQueries.GET_UID_ENUM(uuid);
switch (objectType) {
case NPC:
NPC npc = (NPC) DbManager.getFromCache(mbEnums.GameObjectType.NPC, uuid);
2023-07-15 09:23:48 -04:00
if (npc != null)
targetLoc = npc.getLoc();
break;
case MOB:
Mob mob = (Mob) DbManager.getFromCache(mbEnums.GameObjectType.Mob, uuid);
2023-07-15 09:23:48 -04:00
if (mob != null)
targetLoc = mob.getLoc();
break;
case CHARACTER:
PlayerCharacter playerCharacter = (PlayerCharacter) DbManager.getFromCache(mbEnums.GameObjectType.PlayerCharacter, uuid);
2023-07-15 09:23:48 -04:00
if (playerCharacter != null)
targetLoc = playerCharacter.getLoc();
break;
case BUILDING:
Building building = (Building) DbManager.getFromCache(mbEnums.GameObjectType.Building, uuid);
2023-07-15 09:23:48 -04:00
if (building != null)
targetLoc = building.getLoc();
break;
case ZONE:
Zone zone = (Zone) DbManager.getFromCache(mbEnums.GameObjectType.Zone, uuid);
2023-07-15 09:23:48 -04:00
if (zone != null)
targetLoc = zone.getLoc();
break;
case CITY:
City city = (City) DbManager.getFromCache(mbEnums.GameObjectType.City, uuid);
2023-07-15 09:23:48 -04:00
if (city != null)
targetLoc = city.getLoc();
break;
}
// Teleport player
if (targetLoc == Vector3fImmutable.ZERO) {
this.throwbackError(player, "Failed to locate UUID");
return;
}
player.teleport(targetLoc);
}
@Override
protected String _getHelpString() {
2022-04-30 09:41:17 -04:00
return "Teleports player to a UUID";
2023-07-15 09:23:48 -04:00
}
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
@Override
protected String _getUsageString() {
return "' /gotoobj <UID>'";
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
}
2022-04-30 09:41:17 -04:00
}