diff --git a/scripts/commands/movefurniture.py b/scripts/commands/movefurniture.py index b6ff5c6d..1f4a7148 100644 --- a/scripts/commands/movefurniture.py +++ b/scripts/commands/movefurniture.py @@ -6,7 +6,6 @@ def setup(): def run(core, actor, target, commandString): tarObj = core.objectService.getObject(actor.getTargetId()) - actor.sendSystemMessage('target template ' + tarObj.getTemplate(),1) container = actor.getContainer() parsedMsg = commandString.split(' ', 2) diff --git a/scripts/commands/permissionlistmodify.py b/scripts/commands/permissionlistmodify.py index a34f8d43..8c0108ba 100644 --- a/scripts/commands/permissionlistmodify.py +++ b/scripts/commands/permissionlistmodify.py @@ -4,7 +4,14 @@ def setup(): return def run(core, actor, target, commandString): - core.harvesterService.handlePermissionListModify(actor, target, commandString) + permissionType = 'Undetermined' + commandArgs = commandString.split(' ') + if len(commandArgs) > 3: + permissionType = commandArgs[2] + if permissionType=='ENTRY' | permissionType=='BAN': + core.housingService.handlePermissionListModify(actor, target, commandString) + if permissionType=='ADMIN' | permissionType=='HOPPER': + core.harvesterService.handlePermissionListModify(actor, target, commandString) return \ No newline at end of file diff --git a/scripts/commands/transferitemmisc.py b/scripts/commands/transferitemmisc.py index 27bfde45..c398a980 100644 --- a/scripts/commands/transferitemmisc.py +++ b/scripts/commands/transferitemmisc.py @@ -12,9 +12,10 @@ def run(core, actor, target, commandString): actorContainer = actor.getContainer() if actorContainer != None and (container.getTemplate() == "object/cell/shared_cell.iff") & core.housingService.getPermissions(actor, actorContainer): - target.getContainer().transferTo(actor, container, target) - core.simulationService.teleport(target, actor.getPosition(), Quaternion(1,0,0,0), containerID) - return + target.getContainer().transferTo(actor, container, target) + core.simulationService.teleport(target, actor.getPosition(), Quaternion(1,0,0,0), containerID) + core.housingService.addItemToHouseItemList(target,actorContainer) + return elif actorContainer != None and container.getTemplate() == "object/cell/shared_cell.iff": actor.sendSystemMessage("You do not have permission to access that container!", 0) return diff --git a/scripts/object/building/player/player_house_generic_small_style_01.py b/scripts/object/building/player/player_house_generic_small_style_01.py index aa3c37eb..6e0ae61d 100644 --- a/scripts/object/building/player/player_house_generic_small_style_01.py +++ b/scripts/object/building/player/player_house_generic_small_style_01.py @@ -6,6 +6,6 @@ def setup(core, object): object.setAttachment("structureSign", sign) structureterminal = core.objectService.createChildObject(object, 'object/tangible/terminal/shared_terminal_player_structure.iff', -5, 0.74, -1.81, 0.707107, -0.707107, 1) - structureterminal.setAttachment('radial_filename', 'structure_management_terminal') + #structureterminal.setAttachment('radial_filename', 'structure_management_terminal') structureterminal.setAttachment('housing_parentstruct', object) return \ No newline at end of file diff --git a/scripts/radial/structure_management_terminal.py b/scripts/radial/structure_management_terminal.py index 983127e2..914133ef 100644 --- a/scripts/radial/structure_management_terminal.py +++ b/scripts/radial/structure_management_terminal.py @@ -1,8 +1,8 @@ from resources.common import RadialOptions from protocol.swg import ResourceListForSurveyMessage from services.sui.SUIService import MessageBoxType -from services.SurveyService import createSurveyRangeSUIWindow from services.sui.SUIWindow import Trigger +from tools import JythonUtilities from java.util import Vector import sys @@ -13,22 +13,24 @@ def createRadial(core, owner, target, radials): radials.add(RadialOptions(0, 7, 0, 'Examine')) radials.add(RadialOptions(0, 78, 0, '@player_structure:management')) radials.add(RadialOptions(0, 117, 0, '@player_structure:permissions')) - radials.add(RadialOptions(2, 118, 0, '@harvester:manage')) radials.add(RadialOptions(2, 128, 0, '@player_structure:permission_destroy')) radials.add(RadialOptions(2, 124, 0, '@player_structure:management_status')) radials.add(RadialOptions(2, 129, 0, '@player_structure:management_pay')) radials.add(RadialOptions(2, 50, 0, '@base_player:set_name')) - radials.add(RadialOptions(2, 51, 0, '@player_structure:management_power')) - radials.add(RadialOptions(3, 121, 0, '@player_structure:permission_admin')) - radials.add(RadialOptions(3, 123, 0, '@player_structure:permissions')) + radials.add(RadialOptions(2, 127, 0, '@player_structure:management_residence')) + #radials.add(RadialOptions(2, 125, 0, '@player_structure:management_privacy : ' + core.housingService.fetchPrivacyString(target))) + radials.add(RadialOptions(2, 171, 0, '@player_structure:find_items_find_all_house_items')) + radials.add(RadialOptions(2, 173, 0, '@player_structure:move_first_item')) + radials.add(RadialOptions(2, 174, 0, '@player_structure:find_items_search_for_house_items')) + radials.add(RadialOptions(2, 175, 0, '@player_structure:delete_all_items_title')) + radials.add(RadialOptions(2, 172, 0, 'Pack Up This Building')) + radials.add(RadialOptions(3, 121, 0, '@player_structure:permission_enter')) + radials.add(RadialOptions(3, 123, 0, '@player_structure:permission_banned')) return def handleSelection(core, owner, target, option): - if option == 118 and target: - if owner is not None: - core.housingService.handleOperateMachinery(owner,target) - return + if option == 128: if owner is not None: core.housingService.createDestroySUIPage(owner,target) @@ -45,15 +47,33 @@ def handleSelection(core, owner, target, option): if owner is not None: core.housingService.createRenameSUIPage(owner,target) return - if option == 51: + if option == 127: if owner is not None: - core.housingService.handleDepositPower(owner,target) + core.housingService.declareResidency(owner,target) + return + if option == 171: + if owner is not None: + core.housingService.handleListAllItems(owner,target) + return + if option == 175: + if owner is not None: + core.housingService.handleDeleteAllItems(owner,target) + return + if option == 173: + if owner is not None: + core.housingService.handleFindLostItems(owner,target) + return + if option == 174: + if owner is not None: + core.housingService.handleSearchForItems(owner,target) return if option == 121: if owner is not None: - core.housingService.handlePermissionAdmin(owner,target) + core.housingService.handlePermissionEntry(owner,target) return if option == 123: if owner is not None: - core.housingService.handlePermissionHopper(owner,target) + core.housingService.handlePermissionBan(owner,target) return + + diff --git a/src/protocol/swg/ObjControllerMessage.java b/src/protocol/swg/ObjControllerMessage.java index b3aa94eb..1c94c6b7 100644 --- a/src/protocol/swg/ObjControllerMessage.java +++ b/src/protocol/swg/ObjControllerMessage.java @@ -83,8 +83,9 @@ public class ObjControllerMessage extends SWGMessage { } public IoBuffer serialize() { - IoBuffer buffer = IoBuffer.allocate(1024).order(ByteOrder.LITTLE_ENDIAN); - + //IoBuffer buffer = IoBuffer.allocate(1024).order(ByteOrder.LITTLE_ENDIAN); -> java.nio.BufferOverflowException + IoBuffer buffer = IoBuffer.allocate(10).order(ByteOrder.LITTLE_ENDIAN); + buffer.setAutoExpand(true); buffer.putShort((short)5); buffer.putInt(0x80CE5E46); buffer.putInt(update); diff --git a/src/resources/objects/building/BuildingMessageBuilder.java b/src/resources/objects/building/BuildingMessageBuilder.java index 5a751d8f..b3639d99 100644 --- a/src/resources/objects/building/BuildingMessageBuilder.java +++ b/src/resources/objects/building/BuildingMessageBuilder.java @@ -22,8 +22,12 @@ package resources.objects.building; import java.nio.ByteOrder; +import java.util.Vector; + import org.apache.mina.core.buffer.IoBuffer; + import resources.objects.ObjectMessageBuilder; +import resources.objects.harvester.HarvesterObject; public class BuildingMessageBuilder extends ObjectMessageBuilder { @@ -122,6 +126,26 @@ public class BuildingMessageBuilder extends ObjectMessageBuilder { return buffer; } + + public IoBuffer buildPermissionListCreate(Vector permissionList, String listName) { + IoBuffer buffer = IoBuffer.allocate(10).order(ByteOrder.LITTLE_ENDIAN); + buffer.setAutoExpand(true); + int listSize = permissionList.size(); + buffer.putShort((short)4); + buffer.putInt(0x52F364B8); + buffer.putInt(listSize); + for (String name : permissionList){ + buffer.put(getUnicodeString(name)); + } + //buffer.putInt(0x61); + buffer.putInt(0); + //buffer.putShort((short)0); + buffer.put(getUnicodeString(listName)); + int size = buffer.position(); + buffer.flip(); + tools.CharonPacketUtils.printAnalysis(IoBuffer.allocate(size).put(buffer.array(), 0, size).flip()); + return IoBuffer.allocate(size).put(buffer.array(), 0, size).flip(); + } @Override diff --git a/src/resources/objects/building/BuildingObject.java b/src/resources/objects/building/BuildingObject.java index 37776c1e..1598b374 100644 --- a/src/resources/objects/building/BuildingObject.java +++ b/src/resources/objects/building/BuildingObject.java @@ -21,10 +21,13 @@ ******************************************************************************/ package resources.objects.building; +import java.util.Vector; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicReference; +import main.NGECore; import resources.objects.cell.CellObject; +import resources.objects.creature.CreatureObject; import com.sleepycat.je.Environment; import com.sleepycat.je.Transaction; @@ -40,7 +43,7 @@ import engine.resources.scene.Planet; import engine.resources.scene.Point3D; import engine.resources.scene.Quaternion; -@Entity(version=2) +@Entity(version=5) public class BuildingObject extends TangibleObject implements IPersistent { @NotPersistent @@ -49,7 +52,16 @@ public class BuildingObject extends TangibleObject implements IPersistent { private Transaction txn; private float maintenanceAmount = 0; - private String deedTemplate; + private int BMR = 0; + private String deedTemplate=""; + private boolean residency=false; + private byte privacy=(byte)0; + public static byte PRIVATE = (byte)0; + public static byte PUBLIC = (byte)1; + private Vector itemsList = new Vector(); + private short maximumStorageCapacity=0; + private Vector entryList = new Vector(); // Preferably the OIDs should be stored, because of name changes + private Vector banList = new Vector(); public BuildingObject() { super(); @@ -93,6 +105,117 @@ public class BuildingObject extends TangibleObject implements IPersistent { public String getDeedTemplate(){ return this.deedTemplate; } + + public String getBuildingName() { + return this.getCustomName(); + } + + public void setBuildingName(String buildingName, CreatureObject owner) { + //owner.getClient().getSession().write(messageBuilder.buildCustomNameDelta(this,buildingName)); + this.setCustomName(buildingName); + ((CreatureObject)owner).sendSystemMessage("Structure renamed.", (byte) 0); + } + + public int getBMR() { + return BMR; + } + + public void setBMR(int BMR) { + this.BMR = BMR; + } + + public void setResidency(CreatureObject owner){ + owner.sendSystemMessage("@player_structure:declared_residency", (byte) 1); + residency = true; + } + + public boolean getResidency(){ + return this.residency; + } + + public byte getPrivacy() { + return privacy; + } + + public String getPrivacyString() { + if (privacy==PRIVATE) + return "private"; + if (privacy==PUBLIC) + return "public"; + return "42"; + } + + public void setPrivacy(byte privacy) { + this.privacy = privacy; + } + + public Vector getItemsList() { + return itemsList; + } + + public void setItemsList(Vector itemsList) { + this.itemsList = itemsList; + } + + public short getMaximumStorageCapacity() { + return maximumStorageCapacity; + } + + public void setMaximumStorageCapacity(short maximumStorageCapacity) { + this.maximumStorageCapacity = maximumStorageCapacity; + } + + public void setPermissionEntry(String name,CreatureObject owner){ + Vector entryListFirstNames = new Vector(); + for (long oid : entryList){ + String firstName = NGECore.getInstance().characterService.getPlayerFirstName(oid); + entryListFirstNames.add(firstName); + } + entryListFirstNames.add("Peter"); + entryListFirstNames.add("Jackson"); + owner.getClient().getSession().write(messageBuilder.buildPermissionListCreate(entryListFirstNames, name)); + } + + public void setPermissionBan(String name,CreatureObject owner){ + Vector banListFirstNames = new Vector(); + for (long oid : banList){ + String firstName = NGECore.getInstance().characterService.getPlayerFirstName(oid); + banListFirstNames.add(firstName); + } + banListFirstNames.add("Peter"); + banListFirstNames.add("Smith"); + owner.getClient().getSession().write(messageBuilder.buildPermissionListCreate(banListFirstNames, name)); + } + + public void addPlayerToEntryList(CreatureObject owner,long oid, String firstName){ + if (!entryList.contains(oid)){ + this.entryList.add(oid); + owner.sendSystemMessage(firstName+ " added to the list.", (byte)1); // player_added %NO added to the list. + } + } + + public void removePlayerFromEntryList(CreatureObject owner,long oid, String firstName){ + if (entryList.contains(oid)){ + this.entryList.remove(oid); + owner.sendSystemMessage(firstName+ " removed to the list.", (byte)1); // player_removed %NO removed from the list. + } + } + + public void addPlayerToBanList(CreatureObject owner,long oid, String firstName){ + if (!banList.contains(oid)){ + this.banList.add(oid); + owner.sendSystemMessage(firstName+ " added to the list.", (byte)1); + } + } + + public void removePlayerFromBanList(CreatureObject owner,long oid, String firstName){ + if (banList.contains(oid)){ + this.banList.remove(oid); + owner.sendSystemMessage(firstName+ " removed to the list.", (byte)1); + } + } + + @Override public void sendBaselines(Client destination) { @@ -115,5 +238,4 @@ public class BuildingObject extends TangibleObject implements IPersistent { txn = env.beginTransaction(null, null); txn.setLockTimeout(500, TimeUnit.MILLISECONDS); } - } diff --git a/src/services/CharacterService.java b/src/services/CharacterService.java index ec394752..9a00b424 100644 --- a/src/services/CharacterService.java +++ b/src/services/CharacterService.java @@ -542,6 +542,59 @@ public class CharacterService implements INetworkDispatch { return false; } + /** + * Checks the database if a player with the given first name exists + * and returns the objectID of that player. + * @param name : String + * @return objectID : long + */ + public long getPlayerOID(String name) { + if (!name.equals("")) { + long oid = 0L; + try { + PreparedStatement ps = databaseConnection.preparedStatement("SELECT * FROM characters WHERE \"firstName\"=?"); + ps.setString(1, name); + ResultSet resultSet = ps.executeQuery(); + while (resultSet.next()) { + oid = resultSet.getLong("id"); + } + return oid; + } + + catch (SQLException e) { e.printStackTrace(); } + } + return 0L; + } + + /** + * Delivers the first name of a player + * @param oid : long + * @return firstName : String + */ + public String getPlayerFirstName(long oid) { + + String name = ""; + try { + PreparedStatement ps = databaseConnection.preparedStatement("SELECT * FROM characters WHERE \"id\"=?"); + ps.setLong(1, oid); + ResultSet resultSet = ps.executeQuery(); + while (resultSet.next()) { + name = resultSet.getString("firstName"); + if (!name.equals("")) { + if (name.contains(" ")) { + name = name.split(" ")[0]; + } + name = name.toLowerCase(); + + } + return name; + } + + } catch (SQLException e) { e.printStackTrace(); } + + return ""; + } + /** * Checks the database for if the object ID of the player exists. * @param objectId Object ID to check for in the database diff --git a/src/services/DevService.java b/src/services/DevService.java index 03464bb2..da4a5561 100644 --- a/src/services/DevService.java +++ b/src/services/DevService.java @@ -88,8 +88,8 @@ public class DevService implements INetworkDispatch { suiOptions.put((long) 23, "Jedi Items"); suiOptions.put((long) 26, "Installations"); suiOptions.put((long) 110, "Survey Devices"); - //if(creature.getClient().isGM()) suiOptions.put((long) 120, "House Deeds"); - suiOptions.put((long) 120, "House Deeds"); + if(creature.getClient().isGM()) suiOptions.put((long) 120, "House Deeds"); + //suiOptions.put((long) 120, "House Deeds"); break; case 3: // [Items] Weapons suiOptions.put((long) 30, "Jedi Weapons"); diff --git a/src/services/housing/HousingService.java b/src/services/housing/HousingService.java index b8ee3f79..5db53834 100644 --- a/src/services/housing/HousingService.java +++ b/src/services/housing/HousingService.java @@ -29,6 +29,7 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.SimpleFileVisitor; import java.nio.file.attribute.BasicFileAttributes; +import java.util.HashMap; import java.util.Map; import java.util.Random; import java.util.Vector; @@ -36,6 +37,7 @@ import java.util.concurrent.ConcurrentHashMap; import main.NGECore; import protocol.swg.EnterStructurePlacementModeMessage; +import protocol.swg.SceneCreateObjectByCrc; import protocol.swg.SceneDestroyObject; import resources.objects.building.BuildingObject; import resources.objects.creature.CreatureObject; @@ -47,6 +49,7 @@ import resources.objects.tangible.TangibleObject; import services.sui.SUIWindow; import services.sui.SUIWindow.SUICallback; import services.sui.SUIWindow.Trigger; +import engine.resources.common.CRC; import engine.resources.objects.SWGObject; import engine.resources.scene.Point3D; import engine.resources.scene.Quaternion; @@ -84,7 +87,7 @@ public class HousingService implements INetworkDispatch { public void placeStructure(final CreatureObject actor, TangibleObject deed, float positionX, float positionZ, float rotation) { HouseTemplate houseTemplate = housingTemplates.get(deed.getTemplate()); - + Player_House_Deed playerHourseDeed = (Player_House_Deed)core.objectService.getObject(deed.getObjectID()); int structureLotCost = houseTemplate.getLotCost(); String structureTemplate = houseTemplate.getBuildingTemplate(); @@ -100,12 +103,12 @@ public class HousingService implements INetworkDispatch { // return; // } // -// // Lot stuff -// if(!actor.getPlayerObject().deductLots(structureLotCost)) -// { -// actor.sendSystemMessage("You do not have enough available lots to place this structure.", (byte) 0); // should probably load this from an stf -// return; -// } + // Lot stuff + if(!actor.getPlayerObject().deductLots(structureLotCost)) + { + actor.sendSystemMessage("You do not have enough available lots to place this structure.", (byte) 0); // should probably load this from an stf + return; + } // Calculate our orientation and height Quaternion quaternion = new Quaternion(1, 0, 0, 0); @@ -132,6 +135,8 @@ public class HousingService implements INetworkDispatch { building.setAttachment("structureOwner", actor.getObjectID()); building.setAttachment("structureAdmins", admins); building.setDeedTemplate(deed.getTemplate()); + building.setBMR(playerHourseDeed.getBMR()); + building.setConditionDamage(100); // Save structure to DB //building.createTransaction(core.getBuildingODB().getEnvironment()); @@ -172,131 +177,585 @@ public class HousingService implements INetworkDispatch { public void createDestroySUIPage(final SWGObject owner, final TangibleObject target) { - final BuildingObject building = (BuildingObject) target.getAttachment("housing_parentstruct"); - //final BuildingObject building = (BuildingObject) core.objectService.getObject(target.getParentId()); - // harvester.getStfFilename(); installation_n .getTemplate(); - String displayname = "@installation_n:"+building.getStfName(); - if (building.getCustomName()!=null) - displayname = building.getCustomName(); - final SUIWindow window = core.suiService.createSUIWindow("Script.listBox", owner, target, 0); - window.setProperty("bg.caption.lblTitle:Text", displayname); - window.setProperty("Prompt.lblPrompt:Text", "@player_structure:confirm_destruction_d1 " + - "@player_structure:confirm_destruction_d2 " + - "\n \n @player_structure:confirm_destruction_d3a " + - "\\#32CD32 @player_structure:confirm_destruction_d3b \\#FFFFFF " + - "@player_structure:confirm_destruction_d4 "); - if (building.getConditionDamage()<20 && building.getMaintenanceAmount()<3000){ - window.addListBoxMenuItem("@player_structure:redeed_confirmation \\#BB0000 @player_structure:can_redeed_no_suffix \\#FFFFFF ",1 ); - } else { - window.addListBoxMenuItem("@player_structure:redeed_confirmation \\#32CD32 @player_structure:can_redeed_yes_suffix \\#FFFFFF ",1 ); - } - if (building.getConditionDamage()<20){ - window.addListBoxMenuItem("@player_structure:redeed_condition \\#BB0000 " + building.getConditionDamage() + " \\#FFFFFF ",1 ); - } else { - window.addListBoxMenuItem("@player_structure:redeed_condition \\#32CD32 " + building.getConditionDamage() + " \\#FFFFFF ",1 ); - } - if (building.getMaintenanceAmount()<0){ - window.addListBoxMenuItem("@player_structure:redeed_maintenance \\#BB0000 " + (int)building.getMaintenanceAmount() + " \\#FFFFFF ",2 ); - } else { - window.addListBoxMenuItem("@player_structure:redeed_maintenance \\#32CD32 " + (int)building.getMaintenanceAmount() + " \\#FFFFFF ",2 ); - } - window.setProperty("btnOk:visible", "True"); - window.setProperty("btnCancel:visible", "True"); - window.setProperty("btnOk:Text", "@yes"); - window.setProperty("btnCancel:Text", "@no"); - Vector returnList = new Vector(); - returnList.add("List.lstList:SelectedRow"); - window.addHandler(0, "", Trigger.TRIGGER_OK, returnList, new SUICallback() { - @SuppressWarnings("unchecked") - @Override - public void process(SWGObject owner, int eventType, Vector returnList) { - core.suiService.closeSUIWindow(owner, 0); - createCodeWindow(owner, target); - } - }); - window.addHandler(1, "", Trigger.TRIGGER_CANCEL, returnList, new SUICallback() { - @SuppressWarnings("unchecked") - @Override - public void process(SWGObject owner, int eventType, Vector returnList) { - core.suiService.closeSUIWindow(owner, 0); - } - }); - core.suiService.openSUIWindow(window); + final BuildingObject building = (BuildingObject) target.getAttachment("housing_parentstruct"); + //final BuildingObject building = (BuildingObject) core.objectService.getObject(target.getParentId()); + // harvester.getStfFilename(); installation_n .getTemplate(); + + if (building.getItemsList().size()>0){ + ((CreatureObject) owner).sendSystemMessage("@player_structure:clear_building_for_delete", (byte)1); } + String displayname = "@installation_n:"+building.getStfName(); + if (building.getCustomName()!=null) + displayname = building.getCustomName(); + final SUIWindow window = core.suiService.createSUIWindow("Script.listBox", owner, target, 0); + window.setProperty("bg.caption.lblTitle:Text", displayname); + window.setProperty("Prompt.lblPrompt:Text", "@player_structure:confirm_destruction_d1 " + + "@player_structure:confirm_destruction_d2 " + + "\n \n @player_structure:confirm_destruction_d3a " + + "\\#32CD32 @player_structure:confirm_destruction_d3b \\#FFFFFF " + + "@player_structure:confirm_destruction_d4 "); + if (building.getConditionDamage()<20 && building.getMaintenanceAmount()<3000){ + window.addListBoxMenuItem("@player_structure:redeed_confirmation \\#BB0000 @player_structure:can_redeed_no_suffix \\#FFFFFF ",1 ); + } else { + window.addListBoxMenuItem("@player_structure:redeed_confirmation \\#32CD32 @player_structure:can_redeed_yes_suffix \\#FFFFFF ",1 ); + } + if (building.getConditionDamage()<20){ + window.addListBoxMenuItem("@player_structure:redeed_condition \\#BB0000 " + building.getConditionDamage() + " \\#FFFFFF ",1 ); + } else { + window.addListBoxMenuItem("@player_structure:redeed_condition \\#32CD32 " + building.getConditionDamage() + " \\#FFFFFF ",1 ); + } + if (building.getMaintenanceAmount()<0){ + window.addListBoxMenuItem("@player_structure:redeed_maintenance \\#BB0000 " + (int)building.getMaintenanceAmount() + " \\#FFFFFF ",2 ); + } else { + window.addListBoxMenuItem("@player_structure:redeed_maintenance \\#32CD32 " + (int)building.getMaintenanceAmount() + " \\#FFFFFF ",2 ); + } + window.setProperty("btnOk:visible", "True"); + window.setProperty("btnCancel:visible", "True"); + window.setProperty("btnOk:Text", "@yes"); + window.setProperty("btnCancel:Text", "@no"); + Vector returnList = new Vector(); + returnList.add("List.lstList:SelectedRow"); + window.addHandler(0, "", Trigger.TRIGGER_OK, returnList, new SUICallback() { + @SuppressWarnings("unchecked") + @Override + public void process(SWGObject owner, int eventType, Vector returnList) { + core.suiService.closeSUIWindow(owner, 0); + createCodeWindow(owner, target); + } + }); + window.addHandler(1, "", Trigger.TRIGGER_CANCEL, returnList, new SUICallback() { + @SuppressWarnings("unchecked") + @Override + public void process(SWGObject owner, int eventType, Vector returnList) { + core.suiService.closeSUIWindow(owner, 0); + } + }); + core.suiService.openSUIWindow(window); + } + public void createCodeWindow(SWGObject owner, TangibleObject target) { - - final BuildingObject building = (BuildingObject) target.getAttachment("housing_parentstruct"); - //final BuildingObject building = (BuildingObject)target; - // harvester.getStfFilename(); installation_n .getTemplate(); - Random rnd = new Random(); - final int confirmCode = 100000 + rnd.nextInt(900000); - final SUIWindow window = core.suiService.createInputBox(2,"@player_structure:structure_status","@player_structure:structure_name_prompt", owner, target, 0); - window.setProperty("bg.caption.lblTitle:Text", "@player_structure:confirm_destruction_t"); - window.setProperty("Prompt.lblPrompt:Text", "@player_structure:your_structure_prefix " + - "\\#32CD32 @player_structure:will_redeed_confirm \\#FFFFFF "+ - "@player_structure:will_redeed_suffix " + - "\n \n Code: " + confirmCode); - - window.setProperty("btnOk:visible", "True"); - window.setProperty("btnCancel:visible", "True"); - window.setProperty("btnOk:Text", "@yes"); - window.setProperty("btnCancel:Text", "@no"); - Vector returnList = new Vector(); - returnList.add("txtInput:LocalText"); - - window.addHandler(0, "", Trigger.TRIGGER_OK, returnList, new SUICallback() { - @SuppressWarnings("unchecked") - @Override - public void process(SWGObject owner, int eventType, Vector returnList) { - CreatureObject crafter = (CreatureObject)owner; - core.suiService.closeSUIWindow(owner, 0); - if (returnList.get(0).equals(""+confirmCode)){ - // handle creation of correct deed in player inventory - PlayerObject player = (PlayerObject) crafter.getSlottedObject("ghost"); - String deedTemplate = building.getDeedTemplate(); - Player_House_Deed deed = (Player_House_Deed)core.objectService.createObject(deedTemplate, owner.getPlanet()); - if(player.getLotsRemaining()+deed.getLotRequirement()>10){ - // Something went wrong or hacking attempt - crafter.sendSystemMessage("Structure can't be redeeded. Maximum lot count exceeded.",(byte)1); - return; - } - - deed.setStructureTemplate(building.getTemplate()); - deed.setSurplusMaintenance((int)building.getMaintenanceAmount()); - deed.setAttributes(); - - SceneDestroyObject destroyObjectMsg = new SceneDestroyObject(building.getObjectID()); - owner.getClient().getSession().write(destroyObjectMsg.serialize()); - core.objectService.destroyObject(building.getObjectID()); - - SWGObject ownerInventory = owner.getSlottedObject("inventory"); - ownerInventory.add(deed); - - if(player.getLotsRemaining()+deed.getLotRequirement()<=10) - player.setLotsRemaining(player.getLotsRemaining()+deed.getLotRequirement()); - - crafter.sendSystemMessage("@player_structure:processing_destruction",(byte)1); - crafter.sendSystemMessage("@player_structure:deed_reclaimed",(byte)1); - - } else { - crafter.sendSystemMessage("@player_structure:incorrect_destroy_code",(byte)1); + final BuildingObject building = (BuildingObject) target.getAttachment("housing_parentstruct"); + //final BuildingObject building = (BuildingObject)target; + Random rnd = new Random(); + final int confirmCode = 100000 + rnd.nextInt(900000); + final SUIWindow window = core.suiService.createInputBox(2,"@player_structure:structure_status","@player_structure:structure_name_prompt", owner, target, 0); + window.setProperty("bg.caption.lblTitle:Text", "@player_structure:confirm_destruction_t"); + window.setProperty("Prompt.lblPrompt:Text", "@player_structure:your_structure_prefix " + + "\\#32CD32 @player_structure:will_redeed_confirm \\#FFFFFF "+ + "@player_structure:will_redeed_suffix " + + "\n \n Code: " + confirmCode); + + window.setProperty("btnOk:visible", "True"); + window.setProperty("btnCancel:visible", "True"); + window.setProperty("btnOk:Text", "@yes"); + window.setProperty("btnCancel:Text", "@no"); + Vector returnList = new Vector(); + returnList.add("txtInput:LocalText"); + + window.addHandler(0, "", Trigger.TRIGGER_OK, returnList, new SUICallback() { + @SuppressWarnings("unchecked") + @Override + public void process(SWGObject owner, int eventType, Vector returnList) { + CreatureObject crafter = (CreatureObject)owner; + core.suiService.closeSUIWindow(owner, 0); + if (returnList.get(0).equals(""+confirmCode)){ + // handle creation of correct deed in player inventory + PlayerObject player = (PlayerObject) crafter.getSlottedObject("ghost"); + String deedTemplate = building.getDeedTemplate(); + + Player_House_Deed deed = (Player_House_Deed)core.objectService.createObject(deedTemplate, owner.getPlanet()); + if(player.getLotsRemaining()+deed.getLotRequirement()>10){ + // Something went wrong or hacking attempt + crafter.sendSystemMessage("Structure can't be redeeded. Maximum lot count exceeded.",(byte)1); + return; } - - } - }); - window.addHandler(1, "", Trigger.TRIGGER_CANCEL, returnList, new SUICallback() { - @SuppressWarnings("unchecked") - @Override - public void process(SWGObject owner, int eventType, Vector returnList) { - core.suiService.closeSUIWindow(owner, 0); - } - }); - core.suiService.openSUIWindow(window); + + deed.setStructureTemplate(building.getTemplate()); + deed.setSurplusMaintenance((int)building.getMaintenanceAmount()); + deed.setAttributes(); + + SceneDestroyObject destroyObjectMsg = new SceneDestroyObject(building.getObjectID()); + owner.getClient().getSession().write(destroyObjectMsg.serialize()); + core.objectService.destroyObject(building.getObjectID()); + + SWGObject ownerInventory = owner.getSlottedObject("inventory"); + ownerInventory.add(deed); + + if(player.getLotsRemaining()+deed.getLotRequirement()<=10) + player.setLotsRemaining(player.getLotsRemaining()+deed.getLotRequirement()); + + crafter.sendSystemMessage("@player_structure:processing_destruction",(byte)1); + crafter.sendSystemMessage("@player_structure:deed_reclaimed",(byte)1); + + } else { + crafter.sendSystemMessage("@player_structure:incorrect_destroy_code",(byte)1); + } + + } + }); + window.addHandler(1, "", Trigger.TRIGGER_CANCEL, returnList, new SUICallback() { + @SuppressWarnings("unchecked") + @Override + public void process(SWGObject owner, int eventType, Vector returnList) { + core.suiService.closeSUIWindow(owner, 0); + } + }); + core.suiService.openSUIWindow(window); + } + + public void createPayMaintenanceSUIPage(SWGObject owner, TangibleObject target) { + CreatureObject creature = (CreatureObject) owner; + final BuildingObject building = (BuildingObject) target.getAttachment("housing_parentstruct"); + final SUIWindow window = core.suiService.createSUIWindow("Script.transfer", owner, target, 10); + window.setProperty("bg.caption.lblTitle:Text", "@player_structure:select_amount"); + window.setProperty("Prompt.lblPrompt:Text", "@player_structure:select_maint_amount" + + "\n \n @player_structure:current_maint_pool : " + (int)building.getMaintenanceAmount()); + + window.setProperty("msgPayMaintenance", "transaction.txtInputFrom"); + + window.setProperty("transaction.lblFrom:Text", "@player_structure:total_funds"); + window.setProperty("transaction.lblTo:Text", "@player_structure:to_pay"); + window.setProperty("transaction.lblFrom", "@player_structure:total_funds"); + window.setProperty("transaction.lblTo", "@player_structure:to_pay"); + + window.setProperty("transaction.lblStartingFrom:Text", ""+creature.getCashCredits()); + window.setProperty("transaction.lblStartingTo:Text", "0"); + + window.setProperty("transaction:InputFrom", "555555"); + window.setProperty("transaction:InputTo", "666666"); + + window.setProperty("transaction:txtInputFrom", ""+creature.getCashCredits()); + window.setProperty("transaction:txtInputTo", "1"); + window.setProperty("transaction.txtInputFrom:Text", ""+creature.getCashCredits()); + window.setProperty("transaction.txtInputTo:Text", "" + "0"); + + window.setProperty("transaction.ConversionRatioFrom", "1"); + window.setProperty("transaction.ConversionRatioTo", "0"); + + window.setProperty("btnOk:visible", "True"); + window.setProperty("btnCancel:visible", "True"); + window.setProperty("btnOk:Text", "@ok"); + window.setProperty("btnCancel:Text", "@cancel"); + + Vector returnList = new Vector(); + returnList.add("transaction.txtInputFrom:Text"); + returnList.add("transaction.txtInputTo:Text"); + window.addHandler(0, "", Trigger.TRIGGER_OK, returnList, new SUICallback() { + @SuppressWarnings("unchecked") + @Override + public void process(SWGObject owner, int eventType, Vector returnList) { + CreatureObject crafter = (CreatureObject)owner; + crafter.setCashCredits(crafter.getCashCredits() - Integer.parseInt(returnList.get(1))); + building.setMaintenanceAmount(building.getMaintenanceAmount()+Float.parseFloat(returnList.get(1))); + String displayname = "the structure"; + if (building.getCustomName()!=null) + displayname = building.getCustomName(); + crafter.sendSystemMessage("You successfully make a payment of " + Integer.parseInt(returnList.get(1)) + " credits to " + displayname + ".", (byte) 0); + core.suiService.closeSUIWindow(owner, 0); + } + }); + window.addHandler(1, "", Trigger.TRIGGER_CANCEL, returnList, new SUICallback() { + @SuppressWarnings("unchecked") + @Override + public void process(SWGObject owner, int eventType, Vector returnList) { + core.suiService.closeSUIWindow(owner, 0); + } + }); + core.suiService.openSUIWindow(window); + } + + public void createRenameSUIPage(SWGObject owner, TangibleObject target) { + final SUIWindow window = core.suiService.createInputBox(2,"@player_structure:structure_status","@player_structure:structure_name_prompt", owner, target, 0); + Vector returnList = new Vector(); + returnList.add("txtInput:LocalText"); + final TangibleObject outerSurveyTool = target; + window.addHandler(0, "", Trigger.TRIGGER_OK, returnList, new SUICallback() { + @SuppressWarnings("unchecked") + @Override + public void process(SWGObject owner, int eventType, Vector returnList) { + core.housingService.handleSetName((CreatureObject)owner, (TangibleObject)outerSurveyTool,returnList.get(0)); + core.suiService.closeSUIWindow(owner, 0); + } + }); + core.suiService.openSUIWindow(window); + } + + public void handleSetName(CreatureObject owner, TangibleObject target,String name) { + + ((BuildingObject) target).setBuildingName(name,owner); + } + + public void createStatusSUIPage(SWGObject owner, TangibleObject target) { + final BuildingObject building = (BuildingObject) target.getAttachment("housing_parentstruct"); + String displayname = "@installation_n:"+building.getStfName(); + if (building.getCustomName()!=null) + displayname = building.getCustomName(); + final SUIWindow window = core.suiService.createSUIWindow("Script.listBox", owner, target, 0); + window.setProperty("bg.caption.lblTitle:Text", "@player_structure:structure_status_t"); + window.setProperty("Prompt.lblPrompt:Text", "@player_structure:structure_name_prompt" + " " + displayname); + String ownerName = owner.getCustomName(); + if (ownerName.length()>0){ + String[] helper = ownerName.split(" "); + ownerName = helper[0]; } + + String maintenancePool_string = ""+(int)building.getMaintenanceAmount(); + int hourlyMaintenance = building.getBMR(); + float totalNumberOfHours = (float)building.getMaintenanceAmount()/hourlyMaintenance; + float minuteFraction = ((totalNumberOfHours * 100) % 100) / 100; + int nDays = (int)totalNumberOfHours / 24; + float difference = totalNumberOfHours % 24; + int nHours = (int)difference; + int nMinutes = (int)(minuteFraction *60); + maintenancePool_string += " (" + nDays + " days, " + nHours + " hours, " + nMinutes + " minutes)"; + + window.addListBoxMenuItem("@player_structure:owner_prompt" + " " + ownerName, 0); + if (building.getPrivacy()==BuildingObject.PRIVATE) + window.addListBoxMenuItem("@player_structure:structure_private", 1); + else + window.addListBoxMenuItem("@player_structure:structure_public", 1); + window.addListBoxMenuItem("@player_structure:condition_prompt" + " " + target.getConditionDamage()+"%", 2); + window.addListBoxMenuItem("@player_structure:maintenance_pool_prompt " + maintenancePool_string, 3); + window.addListBoxMenuItem("@player_structure:maintenance_rate_prompt " + building.getBMR() + " cr/h", 4); // @player_structure:credits_per_hour + window.addListBoxMenuItem("@player_structure:maintenance_mods_prompt", 5); + window.addListBoxMenuItem("@player_structure:items_in_building_prompt " + building.getItemsList().size(), 6); + window.addListBoxMenuItem("@player_structure:total_house_storage " + building.getMaximumStorageCapacity(), 7); + + window.setProperty("btnOk:visible", "True"); + window.setProperty("btnCancel:visible", "True"); + window.setProperty("btnOk:Text", "@ok"); + window.setProperty("btnCancel:Text", "@cancel"); + Vector returnList = new Vector(); + returnList.add("List.lstList:SelectedRow"); + + window.addHandler(0, "", Trigger.TRIGGER_OK, returnList, new SUICallback() { + @SuppressWarnings("unchecked") + @Override + public void process(SWGObject owner, int eventType, Vector returnList) { + core.suiService.closeSUIWindow(owner, 0); + } + }); + core.suiService.openSUIWindow(window); + } + + public void declareResidency(SWGObject owner, TangibleObject target) { + final BuildingObject building = (BuildingObject) target.getAttachment("housing_parentstruct"); + building.setResidency((CreatureObject)owner); + //owner.setResidence(); + } + + public void handleListAllItems(SWGObject owner, TangibleObject target) { + final BuildingObject building = (BuildingObject) target.getAttachment("housing_parentstruct"); + String displayname = "@installation_n:"+building.getStfName(); + if (building.getCustomName()!=null) + displayname = building.getCustomName(); + final SUIWindow window = core.suiService.createSUIWindow("Script.listBox", owner, target, 0); + window.setProperty("bg.caption.lblTitle:Text", "@player_structure:find_items_find_all_house_items"); + window.setProperty("Prompt.lblPrompt:Text", "@player_structure:find_items_prompt"); + + Vector itemList = building.getItemsList(); + + for (int i=0;i returnList = new Vector(); + returnList.add("List.lstList:SelectedRow"); + window.addHandler(0, "", Trigger.TRIGGER_OK, returnList, new SUICallback() { + @Override + public void process(SWGObject owner, int eventType, Vector returnList) { + core.suiService.closeSUIWindow(owner, 0); + } + }); + core.suiService.openSUIWindow(window); + + + } + + public void handleDeleteAllItems(SWGObject owner, TangibleObject target) { + final BuildingObject building = (BuildingObject) target.getAttachment("housing_parentstruct"); + //building.getItemsList().clear(); + // confirmation needed + confirmDeleteAllItems(owner, target); + } + + public void confirmDeleteAllItems(SWGObject owner, TangibleObject target) { + + final BuildingObject building = (BuildingObject) target.getAttachment("housing_parentstruct"); + + Random rnd = new Random(); + final int confirmCode = 100000 + rnd.nextInt(900000); + final SUIWindow window = core.suiService.createInputBox(2,"@player_structure:structure_status","@player_structure:structure_name_prompt", owner, target, 0); + window.setProperty("bg.caption.lblTitle:Text", "@player_structure:confirm_destruction_t"); + window.setProperty("Prompt.lblPrompt:Text", "@player_structure:delete_all_items_d " + + "@player_structure:delete_all_items_prompt " + + "\n \n Code: " + confirmCode); + + window.setProperty("btnOk:visible", "True"); + window.setProperty("btnCancel:visible", "True"); + window.setProperty("btnOk:Text", "@yes"); + window.setProperty("btnCancel:Text", "@no"); + Vector returnList = new Vector(); + returnList.add("txtInput:LocalText"); + + window.addHandler(0, "", Trigger.TRIGGER_OK, returnList, new SUICallback() { + @Override + public void process(SWGObject owner, int eventType, Vector returnList) { + CreatureObject ownerC = (CreatureObject)owner; + core.suiService.closeSUIWindow(owner, 0); + if (returnList.get(0).equals(""+confirmCode)){ + confirmDeleteAllItems2ndStage(ownerC,building); + } else { + ownerC.sendSystemMessage("@player_structure:incorrect_destroy_code",(byte)1); + } + + } + }); + window.addHandler(1, "", Trigger.TRIGGER_CANCEL, returnList, new SUICallback() { + @Override + public void process(SWGObject owner, int eventType, Vector returnList) { + core.suiService.closeSUIWindow(owner, 0); + } + }); + core.suiService.openSUIWindow(window); + } + + public void confirmDeleteAllItems2ndStage(final CreatureObject ownerC, BuildingObject building) { + + final SUIWindow window = core.suiService.createMessageBox(2,"@player_structure:structure_status","@player_structure:structure_name_prompt", ownerC, building, 0); + window.setProperty("bg.caption.lblTitle:Text", "@player_structure:confirm_destruction_t"); + window.setProperty("Prompt.lblPrompt:Text", "@player_structure:delete_all_items_second_d"); + + window.setProperty("btnOk:visible", "True"); + window.setProperty("btnCancel:visible", "True"); + window.setProperty("btnOk:Text", "@yes"); + window.setProperty("btnCancel:Text", "@no"); + Vector returnList = new Vector(); + + window.addHandler(0, "", Trigger.TRIGGER_OK, returnList, new SUICallback() { + @Override + public void process(SWGObject owner, int eventType, Vector returnList) { + for (TangibleObject del : building.getItemsList()){ + core.objectService.destroyObject(del); + } + building.getItemsList().clear(); + ownerC.sendSystemMessage("@player_structure:items_deleted",(byte)1); + core.suiService.closeSUIWindow(owner, 0); + } + }); + window.addHandler(1, "", Trigger.TRIGGER_CANCEL, returnList, new SUICallback() { + @Override + public void process(SWGObject owner, int eventType, Vector returnList) { + core.suiService.closeSUIWindow(owner, 0); + } + }); + core.suiService.openSUIWindow(window); + } + + public void handleFindLostItems(SWGObject owner, TangibleObject target) { + final BuildingObject building = (BuildingObject) target.getAttachment("housing_parentstruct"); + String displayname = "@installation_n:"+building.getStfName(); + if (building.getCustomName()!=null) + displayname = building.getCustomName(); + final SUIWindow window = core.suiService.createSUIWindow("Script.listBox", owner, target, 0); + window.setProperty("bg.caption.lblTitle:Text", "@player_structure:find_items_find_all_house_items"); + window.setProperty("Prompt.lblPrompt:Text", "@player_structure:structure_name_prompt" + " " + displayname); + + Vector itemList = building.getItemsList(); + final Map itemIDMapping = new HashMap(); + + for (int i=0;i returnList = new Vector(); + returnList.add("List.lstList:SelectedRow"); + window.addHandler(0, "", Trigger.TRIGGER_OK, returnList, new SUICallback() { + @Override + public void process(SWGObject owner, int eventType, Vector returnList) { + + int index = Integer.parseInt(returnList.get(0)); + long foundItemID = (long) itemIDMapping.get(index); + TangibleObject foundItem = (TangibleObject) core.objectService.getObject(foundItemID); + //core.simulationService.transform(foundItem,owner.getPosition()); + foundItem.setPosition(owner.getPosition()); + core.suiService.closeSUIWindow(owner, 0); + } + }); + window.addHandler(1, "", Trigger.TRIGGER_CANCEL, returnList, new SUICallback() { + @Override + public void process(SWGObject owner, int eventType, Vector returnList) { + core.suiService.closeSUIWindow(owner, 0); + } + }); + core.suiService.openSUIWindow(window); + + + } + + public void handleSearchForItems(SWGObject owner, TangibleObject target) { + // Spawning the structure terminal outside makes it display the correct radial + core.staticService.spawnObject("object/tangible/terminal/shared_terminal_player_structure.iff", "tatooine", 0L, 3525.0F, 4.0F, -4800.0F, 0.70F, 0.71F); + // I assume that childobject does not get a radial somehow + + final BuildingObject building = (BuildingObject) target.getAttachment("housing_parentstruct"); + final SUIWindow window = core.suiService.createInputBox(2,"@player_structure:structure_status","@player_structure:structure_name_prompt", owner, target, 0); + window.setProperty("bg.caption.lblTitle:Text", "@player_structure:find_items_search_keyword_title"); + window.setProperty("Prompt.lblPrompt:Text", "@player_structure:find_items_search_keyword_prompt"); + + window.setProperty("btnOk:visible", "True"); + window.setProperty("btnCancel:visible", "True"); + window.setProperty("btnOk:Text", "@ok"); + window.setProperty("btnCancel:Text", "@cancel"); + Vector returnList = new Vector(); + returnList.add("txtInput:LocalText"); + window.addHandler(0, "", Trigger.TRIGGER_OK, returnList, new SUICallback() { + @Override + public void process(SWGObject owner, int eventType, Vector returnList) { + + String itemSearchName = (String) returnList.get(0); + Vector allItems = building.getItemsList(); + Vector foundItems = new Vector(); + + for (TangibleObject obj : allItems){ + String searchAttribute=obj.getCustomName(); + if (searchAttribute==null) + searchAttribute=obj.getTemplate(); + if (searchAttribute.toLowerCase().contains(itemSearchName.toLowerCase())){ + foundItems.add(obj); + } + } + if (foundItems.size()>0){ + ((CreatureObject) owner).sendSystemMessage("@player_structure:find_items_search_list_title", (byte) 1); + displayFoundItems(owner, target, foundItems); + } else { + ((CreatureObject) owner).sendSystemMessage("@player_structure:find_items_search_not_found", (byte) 1); + } + core.suiService.closeSUIWindow(owner, 0); + } + }); + window.addHandler(1, "", Trigger.TRIGGER_CANCEL, returnList, new SUICallback() { + @Override + public void process(SWGObject owner, int eventType, Vector returnList) { + core.suiService.closeSUIWindow(owner, 0); + } + }); + core.suiService.openSUIWindow(window); + } + + public void displayFoundItems(SWGObject owner, TangibleObject target, Vector foundItems) { + final BuildingObject building = (BuildingObject) target.getAttachment("housing_parentstruct"); + final SUIWindow window = core.suiService.createSUIWindow("Script.listBox", owner, target, 0); + window.setProperty("bg.caption.lblTitle:Text", "@player_structure:find_items_search_keyword_title"); + window.setProperty("Prompt.lblPrompt:Text", "@player_structure:find_items_search_list_prompt"); + + Vector itemList = building.getItemsList(); + + final Map itemIDMapping = new HashMap(); + + for (int i=0;i returnList = new Vector(); + returnList.add("List.lstList:SelectedRow"); + window.addHandler(0, "", Trigger.TRIGGER_OK, returnList, new SUICallback() { + @Override + public void process(SWGObject owner, int eventType, Vector returnList) { + core.suiService.closeSUIWindow(owner, 0); + } + }); + window.addHandler(1, "", Trigger.TRIGGER_CANCEL, returnList, new SUICallback() { + @Override + public void process(SWGObject owner, int eventType, Vector returnList) { + core.suiService.closeSUIWindow(owner, 0); + } + }); + core.suiService.openSUIWindow(window); + } + + public void handlePermissionEntry(CreatureObject owner, TangibleObject target) { + final BuildingObject building = (BuildingObject) target.getAttachment("housing_parentstruct"); + String listName = "ENTRY"; + building.setPermissionEntry(listName,owner); + } + + public void handlePermissionBan(CreatureObject owner, TangibleObject target) { + final BuildingObject building = (BuildingObject) target.getAttachment("housing_parentstruct"); + String listName = "BAN"; + building.setPermissionBan(listName,owner); + } + + public void handlePermissionListModify(CreatureObject owner, SWGObject target, String commandArgs){ + + String[] commandSplit = commandArgs.split(" "); + if (commandSplit.length==3){ + if (core.characterService.playerExists(commandSplit[2]) && + core.characterService.getPlayerOID(commandSplit[2])>0){ + long playerOID = core.characterService.getPlayerOID(commandSplit[2]); + if (commandSplit[2].equals("ENTRY")){ + + if (commandSplit[0].equals("add")){ + ((BuildingObject)target).addPlayerToEntryList(owner, playerOID, commandSplit[2]); + } + if (commandSplit[0].equals("remove")){ + ((BuildingObject)target).removePlayerFromEntryList(owner, playerOID, commandSplit[2]); + } + } + if (commandSplit[2].equals("BAN")){ + + if (commandSplit[0].equals("add")){ + ((BuildingObject)target).addPlayerToBanList(owner, playerOID, commandSplit[2]); + } + if (commandSplit[0].equals("remove")){ + ((BuildingObject)target).removePlayerFromBanList(owner, playerOID, commandSplit[2]); + } + } + } else { + owner.sendSystemMessage(commandSplit[2]+ " is an invalid player name", (byte) 0); // modify_list_invalid_player %NO is an invalid player name. + } + } + if (commandSplit.length==2){ + owner.sendSystemMessage("No name was entered", (byte) 0); + } + + } + + public void addItemToHouseItemList(TangibleObject item, SWGObject container){ + BuildingObject building = (BuildingObject) container.getContainer(); + building.getItemsList().add(item); + } + public String fetchPrivacyString(TangibleObject object){ + final BuildingObject building = (BuildingObject) object.getAttachment("housing_parentstruct"); + return building.getPrivacyString(); + } + + public String fetchStringFromCastedClass(SWGObject object, String classToCastTo, String methodName){ + return tools.JythonUtilities.fetchStringFromCastedClass(object,classToCastTo,methodName); + } @Override public void insertOpcodes(Map arg0,