Files
lakebane/src/engine/devcmd/cmds/UnloadFurnitureCmd.java
T

102 lines
3.3 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.Enum.GameObjectType;
import engine.devcmd.AbstractDevCmd;
import engine.net.client.msg.LoadStructureMsg;
import engine.net.client.msg.MoveToPointMsg;
import engine.net.client.msg.UnloadObjectsMsg;
import engine.objects.AbstractGameObject;
import engine.objects.AbstractWorldObject;
import engine.objects.Building;
import engine.objects.PlayerCharacter;
/**
* @author
*/
public class UnloadFurnitureCmd extends AbstractDevCmd {
2023-07-15 09:23:48 -04:00
public UnloadFurnitureCmd() {
2022-04-30 09:41:17 -04:00
super("furniture");
}
2023-07-15 09:23:48 -04:00
@Override
protected void _doCmd(PlayerCharacter pc, String[] words,
AbstractGameObject target) {
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
if (target.getObjectType() != GameObjectType.Building) {
this.throwbackError(pc, "Must be targeting a building to load/unload furniture.");
return;
}
if (words[0].equalsIgnoreCase("unload")) {
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
UnloadObjectsMsg uom = new UnloadObjectsMsg();
for (AbstractWorldObject awo : pc.getLoadedStaticObjects()) {
if (awo.getObjectType() != GameObjectType.Building)
continue;
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
Building awoBuilding = (Building) awo;
2022-04-30 09:41:17 -04:00
if (!awoBuilding.isFurniture)
2023-07-15 09:23:48 -04:00
continue;
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
if (awoBuilding.parentBuildingID != target.getObjectUUID())
continue;
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
MoveToPointMsg msg = new MoveToPointMsg(awoBuilding);
pc.getClientConnection().sendMsg(msg);
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
uom.addObject(awoBuilding);
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
}
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
pc.getClientConnection().sendMsg(uom);
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
} else if (words[0].equalsIgnoreCase("load")) {
LoadStructureMsg lsm = new LoadStructureMsg();
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
for (AbstractWorldObject awo : pc.getLoadedStaticObjects()) {
if (awo.getObjectType() != GameObjectType.Building)
continue;
Building awoBuilding = (Building) awo;
2022-04-30 09:41:17 -04:00
if (!awoBuilding.isFurniture)
2023-07-15 09:23:48 -04:00
continue;
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
if (awoBuilding.parentBuildingID != target.getObjectUUID())
continue;
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
lsm.addObject(awoBuilding);
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
}
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
pc.getClientConnection().sendMsg(lsm);
2022-04-30 09:41:17 -04:00
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 _getHelpString() {
String help = "Enchants an item with a prefix and suffix";
return help;
}
2022-04-30 09:41:17 -04:00
2023-07-15 09:23:48 -04:00
@Override
protected String _getUsageString() {
String usage = "' /enchant clear/Enchant1 Enchant2 Enchant3 ...'";
return usage;
}
2022-04-30 09:41:17 -04:00
}