From 4df7274ac9bcb813a7cfc6af4680ca3db80a33f8 Mon Sep 17 00:00:00 2001 From: CharonInferar Date: Fri, 11 Apr 2014 04:14:29 +0200 Subject: [PATCH 1/9] Structure terminal work Creation of player_house_deed class terminal menus made py scripts arranged --- options.cfg | 4 +- scripts/commands/movefurniture.py | 2 +- .../player_house_generic_small_style_01.py | 4 +- .../generic_house_small_deed.py | 6 +- .../terminal/terminal_player_structure.py | 1 + .../terminal/terminal_player_structure_new.py | 1 + .../terminal_player_structure_nosnap.py | 1 + .../terminal_player_structure_nosnap_mini.py | 1 + .../radial/structure_management_terminal.py | 59 ++++++ .../objects/building/BuildingObject.java | 28 ++- .../objects/deed/Player_House_Deed.java | 94 +++++++++ src/services/DevService.java | 15 +- src/services/housing/HousingService.java | 182 +++++++++++++++--- src/services/object/ObjectService.java | 7 +- 14 files changed, 372 insertions(+), 33 deletions(-) create mode 100644 scripts/radial/structure_management_terminal.py create mode 100644 src/resources/objects/deed/Player_House_Deed.java diff --git a/options.cfg b/options.cfg index 5a3a7f8e..cb743c88 100644 --- a/options.cfg +++ b/options.cfg @@ -1,3 +1,3 @@ -LOAD.SNAPSHOT_OBJECTS=1 -LOAD.BUILDOUT_OBJECTS=1 +LOAD.SNAPSHOT_OBJECTS=0 +LOAD.BUILDOUT_OBJECTS=0 LOAD.RESOURCE.SYSTEM=1 \ No newline at end of file diff --git a/scripts/commands/movefurniture.py b/scripts/commands/movefurniture.py index 3c45c55e..b6ff5c6d 100644 --- a/scripts/commands/movefurniture.py +++ b/scripts/commands/movefurniture.py @@ -6,7 +6,7 @@ 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/object/building/player/player_house_generic_small_style_01.py b/scripts/object/building/player/player_house_generic_small_style_01.py index 17c11b52..aa3c37eb 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 @@ -5,5 +5,7 @@ def setup(core, object): print(sign) object.setAttachment("structureSign", sign) - core.objectService.createChildObject(object, 'object/tangible/terminal/shared_terminal_player_structure.iff', -5, 0.74, -1.81, 0.707107, -0.707107, 1) + 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('housing_parentstruct', object) return \ No newline at end of file diff --git a/scripts/object/tangible/deed/player_house_deed/generic_house_small_deed.py b/scripts/object/tangible/deed/player_house_deed/generic_house_small_deed.py index e100519a..5dbae10f 100644 --- a/scripts/object/tangible/deed/player_house_deed/generic_house_small_deed.py +++ b/scripts/object/tangible/deed/player_house_deed/generic_house_small_deed.py @@ -1,7 +1,11 @@ import sys def setup(core, object): - object.setAttachment('radial_filename', 'structureDeed'); + object.setAttachment('radial_filename', 'structureDeed') + object.setConstructorTemplate('object/building/player/construction/shared_construction_player_house_corellia_small_style_01.iff') + object.setStructureTemplate('object/tangible/deed/player_house_deed/shared_generic_house_small_deed.iff') + object.setLotRequirement(1) + object.setBMR(15) return def use(core, actor, object): diff --git a/scripts/object/tangible/terminal/terminal_player_structure.py b/scripts/object/tangible/terminal/terminal_player_structure.py index ccad8904..839210a3 100644 --- a/scripts/object/tangible/terminal/terminal_player_structure.py +++ b/scripts/object/tangible/terminal/terminal_player_structure.py @@ -1,4 +1,5 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'structure_management_terminal') return \ No newline at end of file diff --git a/scripts/object/tangible/terminal/terminal_player_structure_new.py b/scripts/object/tangible/terminal/terminal_player_structure_new.py index ccad8904..839210a3 100644 --- a/scripts/object/tangible/terminal/terminal_player_structure_new.py +++ b/scripts/object/tangible/terminal/terminal_player_structure_new.py @@ -1,4 +1,5 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'structure_management_terminal') return \ No newline at end of file diff --git a/scripts/object/tangible/terminal/terminal_player_structure_nosnap.py b/scripts/object/tangible/terminal/terminal_player_structure_nosnap.py index ccad8904..839210a3 100644 --- a/scripts/object/tangible/terminal/terminal_player_structure_nosnap.py +++ b/scripts/object/tangible/terminal/terminal_player_structure_nosnap.py @@ -1,4 +1,5 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'structure_management_terminal') return \ No newline at end of file diff --git a/scripts/object/tangible/terminal/terminal_player_structure_nosnap_mini.py b/scripts/object/tangible/terminal/terminal_player_structure_nosnap_mini.py index ccad8904..839210a3 100644 --- a/scripts/object/tangible/terminal/terminal_player_structure_nosnap_mini.py +++ b/scripts/object/tangible/terminal/terminal_player_structure_nosnap_mini.py @@ -1,4 +1,5 @@ import sys def setup(core, object): + object.setAttachment('radial_filename', 'structure_management_terminal') return \ No newline at end of file diff --git a/scripts/radial/structure_management_terminal.py b/scripts/radial/structure_management_terminal.py new file mode 100644 index 00000000..983127e2 --- /dev/null +++ b/scripts/radial/structure_management_terminal.py @@ -0,0 +1,59 @@ +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 java.util import Vector +import sys + +def createRadial(core, owner, target, radials): + #(byte parentId, short optionId, byte optionType, String description) + radials.clear() + owner.sendSystemMessage('target template ' + target.getTemplate(),1) + 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')) + + 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) + return + if option == 124: + if owner is not None: + core.housingService.createStatusSUIPage(owner,target) + return + if option == 129: + if owner is not None: + core.housingService.createPayMaintenanceSUIPage(owner,target) + return + if option == 50: + if owner is not None: + core.housingService.createRenameSUIPage(owner,target) + return + if option == 51: + if owner is not None: + core.housingService.handleDepositPower(owner,target) + return + if option == 121: + if owner is not None: + core.housingService.handlePermissionAdmin(owner,target) + return + if option == 123: + if owner is not None: + core.housingService.handlePermissionHopper(owner,target) + return diff --git a/src/resources/objects/building/BuildingObject.java b/src/resources/objects/building/BuildingObject.java index f604d0a3..37776c1e 100644 --- a/src/resources/objects/building/BuildingObject.java +++ b/src/resources/objects/building/BuildingObject.java @@ -23,34 +23,44 @@ package resources.objects.building; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicReference; + import resources.objects.cell.CellObject; + import com.sleepycat.je.Environment; import com.sleepycat.je.Transaction; + import resources.objects.tangible.TangibleObject; + import com.sleepycat.persist.model.Entity; import com.sleepycat.persist.model.NotPersistent; + import engine.clients.Client; import engine.resources.objects.IPersistent; import engine.resources.scene.Planet; import engine.resources.scene.Point3D; import engine.resources.scene.Quaternion; -@Entity(version=0) +@Entity(version=2) public class BuildingObject extends TangibleObject implements IPersistent { @NotPersistent private BuildingMessageBuilder messageBuilder; @NotPersistent private Transaction txn; + + private float maintenanceAmount = 0; + private String deedTemplate; public BuildingObject() { super(); messageBuilder = new BuildingMessageBuilder(this); + this.setConditionDamage(100); } public BuildingObject(long objectID, Planet planet, Point3D position, Quaternion orientation, String Template) { super(objectID, planet, Template, position, orientation); messageBuilder = new BuildingMessageBuilder(this); + this.setConditionDamage(100); } public CellObject getCellByCellNumber(final int cellNumber) { @@ -67,6 +77,22 @@ public class BuildingObject extends TangibleObject implements IPersistent { return ref.get(); } + + public float getMaintenanceAmount() { + return maintenanceAmount; + } + + public void setMaintenanceAmount(float maintenanceAmount) { + this.maintenanceAmount = maintenanceAmount; + } + + public void setDeedTemplate(String deedTemplate){ + this.deedTemplate = deedTemplate; + } + + public String getDeedTemplate(){ + return this.deedTemplate; + } @Override public void sendBaselines(Client destination) { diff --git a/src/resources/objects/deed/Player_House_Deed.java b/src/resources/objects/deed/Player_House_Deed.java new file mode 100644 index 00000000..448f3da9 --- /dev/null +++ b/src/resources/objects/deed/Player_House_Deed.java @@ -0,0 +1,94 @@ +/******************************************************************************* + * Copyright (c) 2013 + * + * This File is part of NGECore2. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. + * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. + ******************************************************************************/ +package resources.objects.deed; +import com.sleepycat.persist.model.Persistent; + +import engine.resources.scene.Planet; +import engine.resources.scene.Point3D; +import engine.resources.scene.Quaternion; + +/** + * @author Seefo + * @author Charon + */ + +@Persistent(version=0) +public class Player_House_Deed extends Deed { + + private String name; + private String structureTemplate; + private String constructorTemplate; + private int BMR=0; + private int surplusMaintenance=0; + private int lotRequirement; + + + public Player_House_Deed(long objectID, Planet planet, String template, Point3D position, Quaternion orientation){ + super(objectID, planet, template, position, orientation); + } + + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + public String getStructureTemplate() { + return structureTemplate; + } + public void setStructureTemplate(String structureTemplate) { + this.structureTemplate = structureTemplate; + } + public int getLotRequirement() { + return lotRequirement; + } + public void setLotRequirement(int lotRequirement) { + this.lotRequirement = lotRequirement; + } + public String getConstructorTemplate() { + return constructorTemplate; + } + public void setConstructorTemplate(String constructorTemplate) { + this.constructorTemplate = constructorTemplate; + } + public int getBMR() { + return BMR; + } + public void setBMR(int BMR) { + this.BMR = BMR; + } + public int getSurplusMaintenance() { + return surplusMaintenance; + } + public void setSurplusMaintenance(int surplusMaintenance) { + this.surplusMaintenance = surplusMaintenance; + } + + public void setAttributes() { + this.getAttributes().put("@obj_attr_n:volume", "1"); + this.getAttributes().put("@obj_attr_n:examine_maintenance_rate", ""+this.getBMR() + "/hour"); + if (this.getSurplusMaintenance()>0) + this.getAttributes().put("@obj_attr_n:examine_maintenance", ""+this.getSurplusMaintenance()); + + + } +} diff --git a/src/services/DevService.java b/src/services/DevService.java index b5f0e2d3..03464bb2 100644 --- a/src/services/DevService.java +++ b/src/services/DevService.java @@ -39,6 +39,7 @@ import resources.common.SpawnPoint; import resources.objects.building.BuildingObject; import resources.objects.creature.CreatureObject; import resources.objects.deed.Harvester_Deed; +import resources.objects.deed.Player_House_Deed; import resources.objects.player.PlayerObject; import resources.objects.tangible.TangibleObject; import resources.objects.tool.SurveyTool; @@ -87,7 +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"); + //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"); @@ -1192,8 +1194,15 @@ public class DevService implements INetworkDispatch { core.resourceService.spawnSpecificResourceContainer("Radioactive", player, 100000); break; case 120: - SWGObject houseDeed = core.objectService.createObject("object/tangible/deed/player_house_deed/shared_generic_house_small_deed.iff", planet); - inventory.add(houseDeed); +// SWGObject houseDeed = core.objectService.createObject("object/tangible/deed/player_house_deed/shared_generic_house_small_deed.iff", planet); +// inventory.add(houseDeed); + + templateString="object/tangible/deed/player_house_deed/shared_generic_house_small_deed.iff"; + Player_House_Deed deed = (Player_House_Deed)core.objectService.createObject(templateString, planet); + deed.setBMR(15); + deed.setAttributes(); + inventory.add(deed); + return; } } diff --git a/src/services/housing/HousingService.java b/src/services/housing/HousingService.java index a9f427b5..b8ee3f79 100644 --- a/src/services/housing/HousingService.java +++ b/src/services/housing/HousingService.java @@ -30,14 +30,23 @@ import java.nio.file.Paths; import java.nio.file.SimpleFileVisitor; import java.nio.file.attribute.BasicFileAttributes; import java.util.Map; +import java.util.Random; import java.util.Vector; import java.util.concurrent.ConcurrentHashMap; import main.NGECore; import protocol.swg.EnterStructurePlacementModeMessage; +import protocol.swg.SceneDestroyObject; import resources.objects.building.BuildingObject; import resources.objects.creature.CreatureObject; +import resources.objects.deed.Harvester_Deed; +import resources.objects.deed.Player_House_Deed; +import resources.objects.harvester.HarvesterObject; +import resources.objects.player.PlayerObject; import resources.objects.tangible.TangibleObject; +import services.sui.SUIWindow; +import services.sui.SUIWindow.SUICallback; +import services.sui.SUIWindow.Trigger; import engine.resources.objects.SWGObject; import engine.resources.scene.Point3D; import engine.resources.scene.Quaternion; @@ -58,11 +67,11 @@ public class HousingService implements INetworkDispatch { public void enterStructureMode(CreatureObject actor, TangibleObject deed) { - if(!actor.getClient().isGM() && !core.terrainService.canBuildAtPosition(actor, actor.getWorldPosition().x, actor.getWorldPosition().z)) - { - actor.sendSystemMessage("You may not place a structure here.", (byte) 0); // should probably load this from an stf - return; - } +// if(!actor.getClient().isGM() && !core.terrainService.canBuildAtPosition(actor, actor.getWorldPosition().x, actor.getWorldPosition().z)) +// { +// actor.sendSystemMessage("You may not place a structure here.", (byte) 0); // should probably load this from an stf +// return; +// } if(housingTemplates.containsKey(deed.getTemplate())) { @@ -79,24 +88,24 @@ public class HousingService implements INetworkDispatch { int structureLotCost = houseTemplate.getLotCost(); String structureTemplate = houseTemplate.getBuildingTemplate(); - if(!houseTemplate.canBePlacedOn(actor.getPlanet().getName())) - { - actor.sendSystemMessage("You may not place this structure on this planet.", (byte) 0); // should probably load this from an stf - return; - } - - if(!actor.getClient().isGM() && !core.terrainService.canBuildAtPosition(actor, positionX, positionZ)) - { - actor.sendSystemMessage("You may not place a structure here.", (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; - } +// if(!houseTemplate.canBePlacedOn(actor.getPlanet().getName())) +// { +// actor.sendSystemMessage("You may not place this structure on this planet.", (byte) 0); // should probably load this from an stf +// return; +// } +// +// if(!actor.getClient().isGM() && !core.terrainService.canBuildAtPosition(actor, positionX, positionZ)) +// { +// actor.sendSystemMessage("You may not place a structure here.", (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); @@ -122,6 +131,7 @@ public class HousingService implements INetworkDispatch { building.setAttachment("structureOwner", actor.getObjectID()); building.setAttachment("structureAdmins", admins); + building.setDeedTemplate(deed.getTemplate()); // Save structure to DB //building.createTransaction(core.getBuildingODB().getEnvironment()); @@ -160,6 +170,132 @@ public class HousingService implements INetworkDispatch { catch (IOException e) { e.printStackTrace(); } } + 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); + } + + 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); + } + + } + }); + 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); + } + @Override diff --git a/src/services/object/ObjectService.java b/src/services/object/ObjectService.java index a3c317a6..ca22a7fc 100644 --- a/src/services/object/ObjectService.java +++ b/src/services/object/ObjectService.java @@ -97,6 +97,7 @@ import resources.objects.building.BuildingObject; import resources.objects.cell.CellObject; import resources.objects.creature.CreatureObject; import resources.objects.deed.Harvester_Deed; +import resources.objects.deed.Player_House_Deed; import resources.objects.group.GroupObject; import resources.objects.guild.GuildObject; import resources.objects.harvester.HarvesterObject; @@ -320,7 +321,11 @@ public class ObjectService implements INetworkDispatch { } else if(Template.startsWith("object/tangible/deed/harvester_deed") || Template.startsWith("object/tangible/deed/generator_deed")) { object = new Harvester_Deed(objectID, planet, Template, position, orientation); - + + } else if(Template.startsWith("object/tangible/deed/player_house_deed")) { + + object = new Player_House_Deed(objectID, planet, Template, position, orientation); + } else if(Template.startsWith("object/tangible")) { object = new TangibleObject(objectID, planet, Template, position, orientation); From 81f77b06dd482b58ee7a3510846d30a68e890356 Mon Sep 17 00:00:00 2001 From: CharonInferar Date: Sat, 12 Apr 2014 02:30:17 +0200 Subject: [PATCH 2/9] All structure terminal menus and functionalities implemented Dropped items add nowto the buildings itemlist Some databse work for permissions --- scripts/commands/movefurniture.py | 1 - scripts/commands/permissionlistmodify.py | 9 +- scripts/commands/transferitemmisc.py | 7 +- .../player_house_generic_small_style_01.py | 2 +- .../radial/structure_management_terminal.py | 46 +- src/protocol/swg/ObjControllerMessage.java | 5 +- .../building/BuildingMessageBuilder.java | 24 + .../objects/building/BuildingObject.java | 128 +++- src/services/CharacterService.java | 53 ++ src/services/DevService.java | 4 +- src/services/housing/HousingService.java | 707 +++++++++++++++--- 11 files changed, 836 insertions(+), 150 deletions(-) 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, From 18c184ea79809edab54e544c9bf097a290ff73df Mon Sep 17 00:00:00 2001 From: CharonInferar Date: Sat, 12 Apr 2014 03:04:17 +0200 Subject: [PATCH 3/9] Cleanup --- options.cfg | 4 +- .../radial/structure_management_terminal.py | 4 +- src/services/housing/HousingService.java | 37 +++++++++---------- 3 files changed, 20 insertions(+), 25 deletions(-) diff --git a/options.cfg b/options.cfg index cb743c88..5a3a7f8e 100644 --- a/options.cfg +++ b/options.cfg @@ -1,3 +1,3 @@ -LOAD.SNAPSHOT_OBJECTS=0 -LOAD.BUILDOUT_OBJECTS=0 +LOAD.SNAPSHOT_OBJECTS=1 +LOAD.BUILDOUT_OBJECTS=1 LOAD.RESOURCE.SYSTEM=1 \ No newline at end of file diff --git a/scripts/radial/structure_management_terminal.py b/scripts/radial/structure_management_terminal.py index 914133ef..b6e7ae3a 100644 --- a/scripts/radial/structure_management_terminal.py +++ b/scripts/radial/structure_management_terminal.py @@ -2,14 +2,12 @@ from resources.common import RadialOptions from protocol.swg import ResourceListForSurveyMessage from services.sui.SUIService import MessageBoxType from services.sui.SUIWindow import Trigger -from tools import JythonUtilities from java.util import Vector import sys def createRadial(core, owner, target, radials): #(byte parentId, short optionId, byte optionType, String description) radials.clear() - owner.sendSystemMessage('target template ' + target.getTemplate(),1) 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')) @@ -18,7 +16,7 @@ def createRadial(core, owner, target, radials): radials.add(RadialOptions(2, 129, 0, '@player_structure:management_pay')) radials.add(RadialOptions(2, 50, 0, '@base_player:set_name')) 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, 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')) diff --git a/src/services/housing/HousingService.java b/src/services/housing/HousingService.java index 5db53834..e1526ef7 100644 --- a/src/services/housing/HousingService.java +++ b/src/services/housing/HousingService.java @@ -70,11 +70,11 @@ public class HousingService implements INetworkDispatch { public void enterStructureMode(CreatureObject actor, TangibleObject deed) { -// if(!actor.getClient().isGM() && !core.terrainService.canBuildAtPosition(actor, actor.getWorldPosition().x, actor.getWorldPosition().z)) -// { -// actor.sendSystemMessage("You may not place a structure here.", (byte) 0); // should probably load this from an stf -// return; -// } + if(!actor.getClient().isGM() && !core.terrainService.canBuildAtPosition(actor, actor.getWorldPosition().x, actor.getWorldPosition().z)) + { + actor.sendSystemMessage("You may not place a structure here.", (byte) 0); // should probably load this from an stf + return; + } if(housingTemplates.containsKey(deed.getTemplate())) { @@ -91,18 +91,18 @@ public class HousingService implements INetworkDispatch { int structureLotCost = houseTemplate.getLotCost(); String structureTemplate = houseTemplate.getBuildingTemplate(); -// if(!houseTemplate.canBePlacedOn(actor.getPlanet().getName())) -// { -// actor.sendSystemMessage("You may not place this structure on this planet.", (byte) 0); // should probably load this from an stf -// return; -// } -// -// if(!actor.getClient().isGM() && !core.terrainService.canBuildAtPosition(actor, positionX, positionZ)) -// { -// actor.sendSystemMessage("You may not place a structure here.", (byte) 0); // should probably load this from an stf -// return; -// } -// + if(!houseTemplate.canBePlacedOn(actor.getPlanet().getName())) + { + actor.sendSystemMessage("You may not place this structure on this planet.", (byte) 0); // should probably load this from an stf + return; + } + + if(!actor.getClient().isGM() && !core.terrainService.canBuildAtPosition(actor, positionX, positionZ)) + { + actor.sendSystemMessage("You may not place a structure here.", (byte) 0); // should probably load this from an stf + return; + } + // Lot stuff if(!actor.getPlayerObject().deductLots(structureLotCost)) { @@ -753,9 +753,6 @@ public class HousingService implements INetworkDispatch { 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, From 1601c214e3ef1bde942ec6f75a0708d25154fc4e Mon Sep 17 00:00:00 2001 From: Light2 Date: Sat, 12 Apr 2014 15:23:14 +0200 Subject: [PATCH 4/9] minor changes --- .../AcceptAuctionResponseMessage.java | 21 ++++++++++++++++++ .../AuctionItemDescriptionMessage.java | 21 ++++++++++++++++++ .../AuctionQueryHeadersMessage.java | 21 ++++++++++++++++++ .../AuctionQueryHeadersResponseMessage.java | 21 ++++++++++++++++++ .../BidAuctionMessage.java | 21 ++++++++++++++++++ .../BidAuctionResponseMessage.java | 21 ++++++++++++++++++ .../CancelLiveAuctionMessage.java | 21 ++++++++++++++++++ .../CancelLiveAuctionResponseMessage.java | 21 ++++++++++++++++++ .../CommoditiesItemTypeListResponse.java | 22 +++++++++++++++++++ .../CommoditiesResourceTypeListResponse.java | 22 +++++++++++++++++++ .../CreateAuctionMessage.java | 21 ++++++++++++++++++ .../CreateImmediateAuctionMessage.java | 21 ++++++++++++++++++ .../GetAuctionDetails.java | 21 ++++++++++++++++++ .../GetAuctionDetailsResponse.java | 21 ++++++++++++++++++ .../IsVendorOwnerMessage.java | 21 ++++++++++++++++++ .../IsVendorOwnerResponseMessage.java | 21 ++++++++++++++++++ .../ItemSoldMessage.java | 21 ++++++++++++++++++ .../RetrieveAuctionItemMessage.java | 21 ++++++++++++++++++ .../RetrieveAuctionItemResponseMessage.java | 21 ++++++++++++++++++ src/services/bazaar/AuctionItem.java | 21 ++++++++++++++++++ src/services/bazaar/BazaarService.java | 21 ++++++++++++++++++ src/services/command/CommandService.java | 13 +++++++---- 22 files changed, 452 insertions(+), 4 deletions(-) diff --git a/src/protocol/swg/auctionManagerClientListener/AcceptAuctionResponseMessage.java b/src/protocol/swg/auctionManagerClientListener/AcceptAuctionResponseMessage.java index 669132ff..49aae248 100644 --- a/src/protocol/swg/auctionManagerClientListener/AcceptAuctionResponseMessage.java +++ b/src/protocol/swg/auctionManagerClientListener/AcceptAuctionResponseMessage.java @@ -1,3 +1,24 @@ +/******************************************************************************* + * Copyright (c) 2013 + * + * This File is part of NGECore2. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. + * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. + ******************************************************************************/ package protocol.swg.auctionManagerClientListener; import java.nio.ByteOrder; diff --git a/src/protocol/swg/auctionManagerClientListener/AuctionItemDescriptionMessage.java b/src/protocol/swg/auctionManagerClientListener/AuctionItemDescriptionMessage.java index 957118e1..bdb7e95e 100644 --- a/src/protocol/swg/auctionManagerClientListener/AuctionItemDescriptionMessage.java +++ b/src/protocol/swg/auctionManagerClientListener/AuctionItemDescriptionMessage.java @@ -1,3 +1,24 @@ +/******************************************************************************* + * Copyright (c) 2013 + * + * This File is part of NGECore2. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. + * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. + ******************************************************************************/ package protocol.swg.auctionManagerClientListener; import java.nio.ByteOrder; diff --git a/src/protocol/swg/auctionManagerClientListener/AuctionQueryHeadersMessage.java b/src/protocol/swg/auctionManagerClientListener/AuctionQueryHeadersMessage.java index 1436f459..14f345ba 100644 --- a/src/protocol/swg/auctionManagerClientListener/AuctionQueryHeadersMessage.java +++ b/src/protocol/swg/auctionManagerClientListener/AuctionQueryHeadersMessage.java @@ -1,3 +1,24 @@ +/******************************************************************************* + * Copyright (c) 2013 + * + * This File is part of NGECore2. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. + * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. + ******************************************************************************/ package protocol.swg.auctionManagerClientListener; import java.io.UnsupportedEncodingException; diff --git a/src/protocol/swg/auctionManagerClientListener/AuctionQueryHeadersResponseMessage.java b/src/protocol/swg/auctionManagerClientListener/AuctionQueryHeadersResponseMessage.java index 71eea176..4c2776c9 100644 --- a/src/protocol/swg/auctionManagerClientListener/AuctionQueryHeadersResponseMessage.java +++ b/src/protocol/swg/auctionManagerClientListener/AuctionQueryHeadersResponseMessage.java @@ -1,3 +1,24 @@ +/******************************************************************************* + * Copyright (c) 2013 + * + * This File is part of NGECore2. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. + * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. + ******************************************************************************/ package protocol.swg.auctionManagerClientListener; import org.apache.mina.core.buffer.IoBuffer; diff --git a/src/protocol/swg/auctionManagerClientListener/BidAuctionMessage.java b/src/protocol/swg/auctionManagerClientListener/BidAuctionMessage.java index 21492348..ea769785 100644 --- a/src/protocol/swg/auctionManagerClientListener/BidAuctionMessage.java +++ b/src/protocol/swg/auctionManagerClientListener/BidAuctionMessage.java @@ -1,3 +1,24 @@ +/******************************************************************************* + * Copyright (c) 2013 + * + * This File is part of NGECore2. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. + * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. + ******************************************************************************/ package protocol.swg.auctionManagerClientListener; import org.apache.mina.core.buffer.IoBuffer; diff --git a/src/protocol/swg/auctionManagerClientListener/BidAuctionResponseMessage.java b/src/protocol/swg/auctionManagerClientListener/BidAuctionResponseMessage.java index da1bccc8..2ff213ef 100644 --- a/src/protocol/swg/auctionManagerClientListener/BidAuctionResponseMessage.java +++ b/src/protocol/swg/auctionManagerClientListener/BidAuctionResponseMessage.java @@ -1,3 +1,24 @@ +/******************************************************************************* + * Copyright (c) 2013 + * + * This File is part of NGECore2. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. + * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. + ******************************************************************************/ package protocol.swg.auctionManagerClientListener; import java.nio.ByteOrder; diff --git a/src/protocol/swg/auctionManagerClientListener/CancelLiveAuctionMessage.java b/src/protocol/swg/auctionManagerClientListener/CancelLiveAuctionMessage.java index 64685acf..cc3705a1 100644 --- a/src/protocol/swg/auctionManagerClientListener/CancelLiveAuctionMessage.java +++ b/src/protocol/swg/auctionManagerClientListener/CancelLiveAuctionMessage.java @@ -1,3 +1,24 @@ +/******************************************************************************* + * Copyright (c) 2013 + * + * This File is part of NGECore2. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. + * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. + ******************************************************************************/ package protocol.swg.auctionManagerClientListener; import org.apache.mina.core.buffer.IoBuffer; diff --git a/src/protocol/swg/auctionManagerClientListener/CancelLiveAuctionResponseMessage.java b/src/protocol/swg/auctionManagerClientListener/CancelLiveAuctionResponseMessage.java index 8b72042c..d820f45b 100644 --- a/src/protocol/swg/auctionManagerClientListener/CancelLiveAuctionResponseMessage.java +++ b/src/protocol/swg/auctionManagerClientListener/CancelLiveAuctionResponseMessage.java @@ -1,3 +1,24 @@ +/******************************************************************************* + * Copyright (c) 2013 + * + * This File is part of NGECore2. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. + * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. + ******************************************************************************/ package protocol.swg.auctionManagerClientListener; import java.nio.ByteOrder; diff --git a/src/protocol/swg/auctionManagerClientListener/CommoditiesItemTypeListResponse.java b/src/protocol/swg/auctionManagerClientListener/CommoditiesItemTypeListResponse.java index bb2a915b..d299a44e 100644 --- a/src/protocol/swg/auctionManagerClientListener/CommoditiesItemTypeListResponse.java +++ b/src/protocol/swg/auctionManagerClientListener/CommoditiesItemTypeListResponse.java @@ -1,3 +1,24 @@ +/******************************************************************************* + * Copyright (c) 2013 + * + * This File is part of NGECore2. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. + * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. + ******************************************************************************/ package protocol.swg.auctionManagerClientListener; import java.nio.ByteOrder; @@ -18,6 +39,7 @@ public class CommoditiesItemTypeListResponse extends SWGMessage { @Override public IoBuffer serialize() { + // TODO: research how categories work String galaxy = NGECore.getInstance().getGalaxyName(); IoBuffer result = IoBuffer.allocate(14 + galaxy.length()).order(ByteOrder.LITTLE_ENDIAN); result.putShort((short) 2); diff --git a/src/protocol/swg/auctionManagerClientListener/CommoditiesResourceTypeListResponse.java b/src/protocol/swg/auctionManagerClientListener/CommoditiesResourceTypeListResponse.java index c55b4726..f898ade4 100644 --- a/src/protocol/swg/auctionManagerClientListener/CommoditiesResourceTypeListResponse.java +++ b/src/protocol/swg/auctionManagerClientListener/CommoditiesResourceTypeListResponse.java @@ -1,3 +1,24 @@ +/******************************************************************************* + * Copyright (c) 2013 + * + * This File is part of NGECore2. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. + * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. + ******************************************************************************/ package protocol.swg.auctionManagerClientListener; import java.nio.ByteOrder; @@ -36,6 +57,7 @@ public class CommoditiesResourceTypeListResponse extends SWGMessage { result.putInt(479); result.putLong(0); + // wrong struct, TODO: research resNames.forEach(s -> result.put(getAsciiString(s))); int size = result.position(); diff --git a/src/protocol/swg/auctionManagerClientListener/CreateAuctionMessage.java b/src/protocol/swg/auctionManagerClientListener/CreateAuctionMessage.java index 159e911b..cdabef34 100644 --- a/src/protocol/swg/auctionManagerClientListener/CreateAuctionMessage.java +++ b/src/protocol/swg/auctionManagerClientListener/CreateAuctionMessage.java @@ -1,3 +1,24 @@ +/******************************************************************************* + * Copyright (c) 2013 + * + * This File is part of NGECore2. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. + * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. + ******************************************************************************/ package protocol.swg.auctionManagerClientListener; import java.io.UnsupportedEncodingException; diff --git a/src/protocol/swg/auctionManagerClientListener/CreateImmediateAuctionMessage.java b/src/protocol/swg/auctionManagerClientListener/CreateImmediateAuctionMessage.java index ce961680..33307c41 100644 --- a/src/protocol/swg/auctionManagerClientListener/CreateImmediateAuctionMessage.java +++ b/src/protocol/swg/auctionManagerClientListener/CreateImmediateAuctionMessage.java @@ -1,3 +1,24 @@ +/******************************************************************************* + * Copyright (c) 2013 + * + * This File is part of NGECore2. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. + * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. + ******************************************************************************/ package protocol.swg.auctionManagerClientListener; import java.io.UnsupportedEncodingException; diff --git a/src/protocol/swg/auctionManagerClientListener/GetAuctionDetails.java b/src/protocol/swg/auctionManagerClientListener/GetAuctionDetails.java index 127d3450..946c0a06 100644 --- a/src/protocol/swg/auctionManagerClientListener/GetAuctionDetails.java +++ b/src/protocol/swg/auctionManagerClientListener/GetAuctionDetails.java @@ -1,3 +1,24 @@ +/******************************************************************************* + * Copyright (c) 2013 + * + * This File is part of NGECore2. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. + * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. + ******************************************************************************/ package protocol.swg.auctionManagerClientListener; import org.apache.mina.core.buffer.IoBuffer; diff --git a/src/protocol/swg/auctionManagerClientListener/GetAuctionDetailsResponse.java b/src/protocol/swg/auctionManagerClientListener/GetAuctionDetailsResponse.java index 27fe7f85..4fe23725 100644 --- a/src/protocol/swg/auctionManagerClientListener/GetAuctionDetailsResponse.java +++ b/src/protocol/swg/auctionManagerClientListener/GetAuctionDetailsResponse.java @@ -1,3 +1,24 @@ +/******************************************************************************* + * Copyright (c) 2013 + * + * This File is part of NGECore2. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. + * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. + ******************************************************************************/ package protocol.swg.auctionManagerClientListener; import org.apache.mina.core.buffer.IoBuffer; diff --git a/src/protocol/swg/auctionManagerClientListener/IsVendorOwnerMessage.java b/src/protocol/swg/auctionManagerClientListener/IsVendorOwnerMessage.java index 9492eb87..35b3b498 100644 --- a/src/protocol/swg/auctionManagerClientListener/IsVendorOwnerMessage.java +++ b/src/protocol/swg/auctionManagerClientListener/IsVendorOwnerMessage.java @@ -1,3 +1,24 @@ +/******************************************************************************* + * Copyright (c) 2013 + * + * This File is part of NGECore2. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. + * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. + ******************************************************************************/ package protocol.swg.auctionManagerClientListener; import org.apache.mina.core.buffer.IoBuffer; diff --git a/src/protocol/swg/auctionManagerClientListener/IsVendorOwnerResponseMessage.java b/src/protocol/swg/auctionManagerClientListener/IsVendorOwnerResponseMessage.java index 9f3e4aeb..cfc73637 100644 --- a/src/protocol/swg/auctionManagerClientListener/IsVendorOwnerResponseMessage.java +++ b/src/protocol/swg/auctionManagerClientListener/IsVendorOwnerResponseMessage.java @@ -1,3 +1,24 @@ +/******************************************************************************* + * Copyright (c) 2013 + * + * This File is part of NGECore2. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. + * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. + ******************************************************************************/ package protocol.swg.auctionManagerClientListener; import java.nio.ByteOrder; diff --git a/src/protocol/swg/auctionManagerClientListener/ItemSoldMessage.java b/src/protocol/swg/auctionManagerClientListener/ItemSoldMessage.java index 3ff53489..6c22d1a1 100644 --- a/src/protocol/swg/auctionManagerClientListener/ItemSoldMessage.java +++ b/src/protocol/swg/auctionManagerClientListener/ItemSoldMessage.java @@ -1,3 +1,24 @@ +/******************************************************************************* + * Copyright (c) 2013 + * + * This File is part of NGECore2. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. + * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. + ******************************************************************************/ package protocol.swg.auctionManagerClientListener; import java.nio.ByteOrder; diff --git a/src/protocol/swg/auctionManagerClientListener/RetrieveAuctionItemMessage.java b/src/protocol/swg/auctionManagerClientListener/RetrieveAuctionItemMessage.java index 486d475c..af2f0c0c 100644 --- a/src/protocol/swg/auctionManagerClientListener/RetrieveAuctionItemMessage.java +++ b/src/protocol/swg/auctionManagerClientListener/RetrieveAuctionItemMessage.java @@ -1,3 +1,24 @@ +/******************************************************************************* + * Copyright (c) 2013 + * + * This File is part of NGECore2. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. + * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. + ******************************************************************************/ package protocol.swg.auctionManagerClientListener; import org.apache.mina.core.buffer.IoBuffer; diff --git a/src/protocol/swg/auctionManagerClientListener/RetrieveAuctionItemResponseMessage.java b/src/protocol/swg/auctionManagerClientListener/RetrieveAuctionItemResponseMessage.java index dbd39f46..2d883695 100644 --- a/src/protocol/swg/auctionManagerClientListener/RetrieveAuctionItemResponseMessage.java +++ b/src/protocol/swg/auctionManagerClientListener/RetrieveAuctionItemResponseMessage.java @@ -1,3 +1,24 @@ +/******************************************************************************* + * Copyright (c) 2013 + * + * This File is part of NGECore2. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. + * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. + ******************************************************************************/ package protocol.swg.auctionManagerClientListener; import java.nio.ByteOrder; diff --git a/src/services/bazaar/AuctionItem.java b/src/services/bazaar/AuctionItem.java index 1eef0858..8b134e97 100644 --- a/src/services/bazaar/AuctionItem.java +++ b/src/services/bazaar/AuctionItem.java @@ -1,3 +1,24 @@ +/******************************************************************************* + * Copyright (c) 2013 + * + * This File is part of NGECore2. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. + * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. + ******************************************************************************/ package services.bazaar; import com.sleepycat.je.Environment; diff --git a/src/services/bazaar/BazaarService.java b/src/services/bazaar/BazaarService.java index 4d765826..1700aa64 100644 --- a/src/services/bazaar/BazaarService.java +++ b/src/services/bazaar/BazaarService.java @@ -1,3 +1,24 @@ +/******************************************************************************* + * Copyright (c) 2013 + * + * This File is part of NGECore2. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * Using NGEngine to work with NGECore2 is making a combined work based on NGEngine. + * Therefore all terms and conditions of the GNU Lesser General Public License cover the combination. + ******************************************************************************/ package services.bazaar; import java.nio.ByteOrder; diff --git a/src/services/command/CommandService.java b/src/services/command/CommandService.java index 82345d06..a215c548 100644 --- a/src/services/command/CommandService.java +++ b/src/services/command/CommandService.java @@ -76,7 +76,7 @@ public class CommandService implements INetworkDispatch { return false; } - if (command.getCharacterAbility().length() > 0 && !actor.hasAbility(command.getCharacterAbility())) { + if (command.getCharacterAbility().length() > 0 && !actor.hasAbility(command.getCharacterAbility()) && command.getGodLevel() < 1) { return false; } @@ -111,7 +111,7 @@ public class CommandService implements INetworkDispatch { //return false; } } - + switch (command.getTargetType()) { case 0: // Target Not Used For This Command break; @@ -138,7 +138,7 @@ public class CommandService implements INetworkDispatch { target = actor; } - if (target != actor && target instanceof CreatureObject) { + if (target != actor && target instanceof CreatureObject && actor.getClient() != null) { return false; } @@ -571,6 +571,11 @@ public class CommandService implements INetworkDispatch { public BaseSWGCommand registerCombatCommand(String name) { return getCommandByName(name); } public BaseSWGCommand registerCommand(String name) { return getCommandByName(name); } - public BaseSWGCommand registerGmCommand(String name) { return getCommandByName(name); } + public BaseSWGCommand registerGmCommand(String name) { + BaseSWGCommand command = getCommandByName(name); + if(command != null) + command.setGodLevel(5); + return command; + } } From 5594515cb4f739adb42f782179dac3096d5444d4 Mon Sep 17 00:00:00 2001 From: Light2 Date: Sat, 12 Apr 2014 17:19:52 +0200 Subject: [PATCH 5/9] Cleanup + persistence fix --- odb/auction/placeholder.txt | 0 scripts/commands/transferitemmisc.py | 2 +- .../objects/building/BuildingObject.java | 18 ++++++++++------- .../objects/harvester/HarvesterObject.java | 20 +++++++++---------- .../installation/InstallationObject.java | 4 ++-- src/services/housing/HousingService.java | 1 - src/services/resources/HarvesterService.java | 6 ++---- src/services/sui/SUIService.java | 5 +++-- 8 files changed, 29 insertions(+), 27 deletions(-) create mode 100644 odb/auction/placeholder.txt diff --git a/odb/auction/placeholder.txt b/odb/auction/placeholder.txt new file mode 100644 index 00000000..e69de29b diff --git a/scripts/commands/transferitemmisc.py b/scripts/commands/transferitemmisc.py index c398a980..dbe46f8a 100644 --- a/scripts/commands/transferitemmisc.py +++ b/scripts/commands/transferitemmisc.py @@ -14,7 +14,7 @@ def run(core, actor, target, commandString): 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) - core.housingService.addItemToHouseItemList(target,actorContainer) + #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) diff --git a/src/resources/objects/building/BuildingObject.java b/src/resources/objects/building/BuildingObject.java index 1598b374..502ebef4 100644 --- a/src/resources/objects/building/BuildingObject.java +++ b/src/resources/objects/building/BuildingObject.java @@ -43,7 +43,7 @@ import engine.resources.scene.Planet; import engine.resources.scene.Point3D; import engine.resources.scene.Quaternion; -@Entity(version=5) +@Entity(version=6) public class BuildingObject extends TangibleObject implements IPersistent { @NotPersistent @@ -58,7 +58,6 @@ public class BuildingObject extends TangibleObject implements IPersistent { 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(); @@ -150,13 +149,11 @@ public class BuildingObject extends TangibleObject implements IPersistent { } public Vector getItemsList() { - return itemsList; + Vector items = new Vector(); + getCells().forEach(c -> c.viewChildren(c, true, false, (item) -> items.add((TangibleObject) item))); + return items; } - public void setItemsList(Vector itemsList) { - this.itemsList = itemsList; - } - public short getMaximumStorageCapacity() { return maximumStorageCapacity; } @@ -238,4 +235,11 @@ public class BuildingObject extends TangibleObject implements IPersistent { txn = env.beginTransaction(null, null); txn.setLockTimeout(500, TimeUnit.MILLISECONDS); } + + public Vector getCells() { + Vector cells = new Vector(); + this.viewChildren(this, true, false, (cell) -> cells.add((CellObject) cell)); + return cells; + } + } diff --git a/src/resources/objects/harvester/HarvesterObject.java b/src/resources/objects/harvester/HarvesterObject.java index 5626ce35..b10755f2 100644 --- a/src/resources/objects/harvester/HarvesterObject.java +++ b/src/resources/objects/harvester/HarvesterObject.java @@ -125,7 +125,7 @@ public class HarvesterObject extends InstallationObject { private byte resourceUpdateCount; private Vector adminList = new Vector(); private Vector hopperList = new Vector(); - private SWGObject owner; + private long owner; private float currentHarvestedCountFloat=0.0F; private String deedTemplate; @@ -192,7 +192,7 @@ public class HarvesterObject extends InstallationObject { public void activateHarvester(CreatureObject owner){ activated = true; - this.setOwner(owner); + this.setOwner(owner.getObjectID()); owner.getClient().getSession().write(messageBuilder.buildHINO3Delta(this,(byte)1)); owner.getClient().getSession().write(messageBuilder.buildHINO7ActivateDelta2(this)); } @@ -335,12 +335,12 @@ public class HarvesterObject extends InstallationObject { } - public SWGObject getOwner() { + public long getOwner() { return owner; } - public void setOwner(SWGObject owner) { + public void setOwner(long owner) { this.owner = owner; } @@ -388,11 +388,11 @@ public class HarvesterObject extends InstallationObject { } public void deActivate(){ - owner.getClient().getSession().write(messageBuilder.buildResourceHarvesterActivatePageMessage(this)); + NGECore.getInstance().objectService.getObject(owner).getClient().getSession().write(messageBuilder.buildResourceHarvesterActivatePageMessage(this)); } public void placeHarvester(){ - owner.getClient().getSession().write(messageBuilder.buildResourceHarvesterActivatePageMessage(this)); + NGECore.getInstance().objectService.getObject(owner).getClient().getSession().write(messageBuilder.buildResourceHarvesterActivatePageMessage(this)); } public static void createAndPlaceHarvester(SWGObject object){ @@ -487,14 +487,14 @@ public class HarvesterObject extends InstallationObject { public void createNewHopperContainer(){ Vector planetResourcesVector = NGECore.getInstance().resourceService.getSpawnedResourcesByPlanetAndHarvesterType(this.getPlanetId(),this.getHarvester_type()); - ((CreatureObject)this.getOwner()).getClient().getSession().write(messageBuilder.buildHINOBaseline7(this, planetResourcesVector)); - ((CreatureObject)this.getOwner()).getClient().getSession().write(messageBuilder.buildHINO7Delta(this,(byte)1)); + NGECore.getInstance().objectService.getObject(owner).getClient().getSession().write(messageBuilder.buildHINOBaseline7(this, planetResourcesVector)); + NGECore.getInstance().objectService.getObject(owner).getClient().getSession().write(messageBuilder.buildHINO7Delta(this,(byte)1)); } public void continueHopperContainer(){ Vector planetResourcesVector = NGECore.getInstance().resourceService.getSpawnedResourcesByPlanetAndHarvesterType(this.getPlanetId(),this.getHarvester_type()); - ((CreatureObject)this.getOwner()).getClient().getSession().write(messageBuilder.buildHarvesterGetResourceData(this, owner, planetResourcesVector)); - ((CreatureObject)this.getOwner()).getClient().getSession().write(messageBuilder.buildHINOBaseline7(this, planetResourcesVector)); + NGECore.getInstance().objectService.getObject(owner).getClient().getSession().write(messageBuilder.buildHarvesterGetResourceData(this, NGECore.getInstance().objectService.getObject(owner), planetResourcesVector)); + NGECore.getInstance().objectService.getObject(owner).getClient().getSession().write(messageBuilder.buildHINOBaseline7(this, planetResourcesVector)); } @Override diff --git a/src/resources/objects/installation/InstallationObject.java b/src/resources/objects/installation/InstallationObject.java index 5a3870e7..3392e5fd 100644 --- a/src/resources/objects/installation/InstallationObject.java +++ b/src/resources/objects/installation/InstallationObject.java @@ -21,15 +21,15 @@ ******************************************************************************/ package resources.objects.installation; +import com.sleepycat.persist.model.Entity; import com.sleepycat.persist.model.Persistent; import engine.resources.scene.Planet; import engine.resources.scene.Point3D; import engine.resources.scene.Quaternion; - import resources.objects.tangible.TangibleObject; -@Persistent(version=0) +@Entity(version=0) public class InstallationObject extends TangibleObject { public InstallationObject(long objectID, Planet planet, String template, Point3D position, Quaternion orientation){ diff --git a/src/services/housing/HousingService.java b/src/services/housing/HousingService.java index e1526ef7..5ee88004 100644 --- a/src/services/housing/HousingService.java +++ b/src/services/housing/HousingService.java @@ -544,7 +544,6 @@ public class HousingService implements INetworkDispatch { 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); } diff --git a/src/services/resources/HarvesterService.java b/src/services/resources/HarvesterService.java index 11c17dfe..93e076c9 100644 --- a/src/services/resources/HarvesterService.java +++ b/src/services/resources/HarvesterService.java @@ -787,12 +787,12 @@ public class HarvesterService implements INetworkDispatch { public void updateHarvester(HarvesterObject harvester){ - + CreatureObject owner = (CreatureObject)core.objectService.getObject(harvester.getOwner()); + if(harvester.isActivated()) { // Check maintenance and power if (harvester.getMaintenanceAmount()<=0){ - CreatureObject owner = (CreatureObject)harvester.getOwner(); owner.sendSystemMessage("The installation is lacking maintenance.", (byte) 0); // ToDo: Send mail harvester.deactivateHarvester(owner); @@ -800,7 +800,6 @@ public class HarvesterService implements INetworkDispatch { } if (harvester.getPowerLevel()<=0 && !harvester.isGenerator()){ - CreatureObject owner = (CreatureObject)harvester.getOwner(); owner.sendSystemMessage("The installation is lacking power.", (byte) 0); // ToDo: Send mail harvester.deactivateHarvester(owner); @@ -840,7 +839,6 @@ public class HarvesterService implements INetworkDispatch { int oldStackCount = hopperContainer.getStackCount(); int newStackCount = (int) (harvester.getCurrentHarvestedCountFloat()); - CreatureObject owner = (CreatureObject)harvester.getOwner(); if (newStackCount>oldStackCount){ for (ResourceContainerObject iterContainer : outputHopperContent){ if (iterContainer.getReferenceID()==hopperContainer.getReferenceID()){ diff --git a/src/services/sui/SUIService.java b/src/services/sui/SUIService.java index b49cf67f..0e76c325 100644 --- a/src/services/sui/SUIService.java +++ b/src/services/sui/SUIService.java @@ -46,6 +46,7 @@ import resources.common.FileUtilities; import resources.common.ObjControllerOpcodes; import resources.common.Opcodes; import resources.common.RadialOptions; +import resources.objects.creature.CreatureObject; import resources.objects.harvester.HarvesterObject; import services.sui.SUIWindow.SUICallback; import services.sui.SUIWindow.Trigger; @@ -86,8 +87,8 @@ public class SUIService implements INetworkDispatch { HarvesterObject harvester = (HarvesterObject) target; Vector admins = harvester.getAdminList(); Vector hoppers = harvester.getHopperList(); - - if (harvester.getOwner()==owner && !admins.contains(owner.getCustomName())){ + CreatureObject creature = (CreatureObject) core.objectService.getObject(harvester.getOwner()); + if (creature == owner && !admins.contains(owner.getCustomName())){ admins.add(owner.getCustomName()); } From cc45a337bc2f94db99d60a44a98e6ae685735975 Mon Sep 17 00:00:00 2001 From: Light2 Date: Sat, 12 Apr 2014 18:31:37 +0200 Subject: [PATCH 6/9] more cleanup + fixes Harvesters and house terminal work now --- .gitignore | 1 + .../objects/building/BuildingObject.java | 12 +- .../objects/harvester/HarvesterObject.java | 104 +----------------- .../installation/InstallationObject.java | 6 + src/services/housing/HousingService.java | 2 - src/services/object/ObjectService.java | 12 +- src/services/resources/HarvesterService.java | 101 ++++++++++++++--- src/services/sui/SUIService.java | 6 +- 8 files changed, 116 insertions(+), 128 deletions(-) diff --git a/.gitignore b/.gitignore index 8560d241..63147709 100644 --- a/.gitignore +++ b/.gitignore @@ -60,6 +60,7 @@ odb/chatRooms/je.info.* odb/resourcehistory/je.info.* odb/resourceroots/je.info.* odb/resources/je.info.* +odb/auction/je.info.* # External tool builders .externalToolBuilders/ diff --git a/src/resources/objects/building/BuildingObject.java b/src/resources/objects/building/BuildingObject.java index 502ebef4..2c3d0db4 100644 --- a/src/resources/objects/building/BuildingObject.java +++ b/src/resources/objects/building/BuildingObject.java @@ -150,7 +150,10 @@ public class BuildingObject extends TangibleObject implements IPersistent { public Vector getItemsList() { Vector items = new Vector(); - getCells().forEach(c -> c.viewChildren(c, true, false, (item) -> items.add((TangibleObject) item))); + getCells().forEach(c -> c.viewChildren(c, true, false, (item) -> { + if(!(item instanceof CreatureObject)) + items.add((TangibleObject) item); + })); return items; } @@ -237,8 +240,11 @@ public class BuildingObject extends TangibleObject implements IPersistent { } public Vector getCells() { - Vector cells = new Vector(); - this.viewChildren(this, true, false, (cell) -> cells.add((CellObject) cell)); + final Vector cells = new Vector(); + this.viewChildren(this, true, false, (obj) -> { + if(obj instanceof CellObject) + cells.add((CellObject) obj); + }); return cells; } diff --git a/src/resources/objects/harvester/HarvesterObject.java b/src/resources/objects/harvester/HarvesterObject.java index b10755f2..7fe12cbb 100644 --- a/src/resources/objects/harvester/HarvesterObject.java +++ b/src/resources/objects/harvester/HarvesterObject.java @@ -394,97 +394,7 @@ public class HarvesterObject extends InstallationObject { public void placeHarvester(){ NGECore.getInstance().objectService.getObject(owner).getClient().getSession().write(messageBuilder.buildResourceHarvesterActivatePageMessage(this)); } - - public static void createAndPlaceHarvester(SWGObject object){ - CreatureObject actor = (CreatureObject) object.getAttachment("Owner"); - - String structureTemplate = (String)object.getAttachment("Deed_StructureTemplate"); - HarvesterObject harvester = (HarvesterObject) NGECore.getInstance().objectService.createObject(structureTemplate, actor.getPlanet()); - long objectId = harvester.getObjectID(); - - Vector adminList = harvester.getAdminList(); - String[] fullName = ((CreatureObject)actor).getCustomName().split(" "); - adminList.add(fullName[0]); - harvester.setAdminList(adminList); - // Set BER and outputhopper capacity here, take it from deed - harvester.setBER((int)object.getAttachment("Deed_BER")); - harvester.setSpecRate((int)(1.5F*(int)object.getAttachment("Deed_BER"))); - harvester.setOutputHopperCapacity((int)object.getAttachment("Deed_Capacity")); - harvester.setDeedTemplate((String)object.getAttachment("Deed_DeedTemplate")); - if ((int)object.getAttachment("Deed_SurplusMaintenance")>0){ - harvester.setMaintenanceAmount((int)object.getAttachment("Deed_SurplusMaintenance")); - } - if ((int)object.getAttachment("Deed_SurplusPower")>0){ - harvester.setPowerLevel((int)object.getAttachment("Deed_SurplusPower")); - } - - // build harvester - int resCRC = CRC.StringtoCRC(structureTemplate); - float positionY = NGECore.getInstance().terrainService.getHeight(actor.getPlanetId(), object.getPosition().x, object.getPosition().z); - SceneCreateObjectByCrc createObjectMsg = new SceneCreateObjectByCrc(objectId, object.getOrientation().x, object.getOrientation().y, object.getOrientation().z, object.getOrientation().w, object.getPosition().x, positionY, object.getPosition().z, resCRC, (byte) 0); - actor.getClient().getSession().write(createObjectMsg.serialize()); - tools.CharonPacketUtils.printAnalysis(createObjectMsg.serialize()); - - harvester.setPosition(new Point3D(object.getPosition().x,positionY, object.getPosition().z)); - - resources.objects.installation.InstallationMessageBuilder messenger = new resources.objects.installation.InstallationMessageBuilder((InstallationObject)harvester); - actor.getClient().getSession().write(messenger.buildBaseline3((InstallationObject)harvester)); - SceneEndBaselines sceneEndBaselinesMsg = new SceneEndBaselines(harvester.getObjectID()); - actor.getClient().getSession().write(sceneEndBaselinesMsg.serialize()); - tools.CharonPacketUtils.printAnalysis(sceneEndBaselinesMsg.serialize()); - - PlayerObject player = (PlayerObject) actor.getSlottedObject("ghost"); - WaypointObject constructionWaypoint = (WaypointObject)NGECore.getInstance().objectService.createObject("object/waypoint/shared_world_waypoint_blue.iff", actor.getPlanet(), harvester.getPosition().x, 0 ,harvester.getPosition().z); - String displayname = "@installation_n:"+harvester.getStfName(); - constructionWaypoint.setName(displayname); - constructionWaypoint.setPlanetCRC(engine.resources.common.CRC.StringtoCRC(actor.getPlanet().getName())); - constructionWaypoint.setPosition(new Point3D(object.getPosition().x,0, object.getPosition().z)); - player.waypointAdd(constructionWaypoint); - constructionWaypoint.setPosition(new Point3D(object.getPosition().x,0, object.getPosition().z)); - constructionWaypoint.setActive(true); - constructionWaypoint.setColor((byte)1); - constructionWaypoint.setStringAttribute("", ""); - player.waypointAdd(constructionWaypoint); - constructionWaypoint.setName(displayname); - constructionWaypoint.setPlanetCRC(engine.resources.common.CRC.StringtoCRC(actor.getPlanet().getName())); - player.setLastSurveyWaypoint(constructionWaypoint); - - List attachments = new ArrayList(); - WaypointAttachment attachment = new WaypointAttachment(); - attachment.active = true; - attachment.cellID = constructionWaypoint.getCellId(); - attachment.color = (byte)1; - attachment.name = displayname; - attachment.planetCRC = engine.resources.common.CRC.StringtoCRC(actor.getPlanet().getName()); - attachment.positionX = object.getPosition().x; - attachment.positionY = 0; - attachment.positionZ = object.getPosition().z; - attachments.add(attachment); - - // remove constructor - NGECore.getInstance().objectService.destroyObject(object); - SceneDestroyObject destroyObjectMsg = new SceneDestroyObject(object.getObjectID()); - actor.getClient().getSession().write(destroyObjectMsg.serialize()); - - // ToDo: waypoint attachment fix - Date date = new Date(); - Mail constructionNotificationMail = new Mail(); - constructionNotificationMail.setSenderName("Structure Service"); - constructionNotificationMail.setSubject("Your structure"); - constructionNotificationMail.setRecieverId(actor.getObjectID()); - constructionNotificationMail.setTimeStamp((int) (date.getTime() / 1000)); - constructionNotificationMail.setMailId(NGECore.getInstance().chatService.generateMailId()); - String message = "Your construction is ready"; - constructionNotificationMail.setMessage(message); - constructionNotificationMail.setStatus(Mail.NEW); - constructionNotificationMail.setAttachments(attachments); - //NGECore.getInstance().chatService.sendPersistentMessage(actor.getClient(), constructionNotificationMail); - NGECore.getInstance().chatService.storePersistentMessage(constructionNotificationMail); - NGECore.getInstance().chatService.sendPersistentMessageHeader(actor.getClient(), constructionNotificationMail); - - } - public void createNewHopperContainer(){ Vector planetResourcesVector = NGECore.getInstance().resourceService.getSpawnedResourcesByPlanetAndHarvesterType(this.getPlanetId(),this.getHarvester_type()); NGECore.getInstance().objectService.getObject(owner).getClient().getSession().write(messageBuilder.buildHINOBaseline7(this, planetResourcesVector)); @@ -506,16 +416,10 @@ public class HarvesterObject extends InstallationObject { return; } - destination.getSession().write(messageBuilder.buildBaseline3()); - destination.getSession().write(messageBuilder.buildBaseline6()); - destination.getSession().write(messageBuilder.buildBaseline8()); - destination.getSession().write(messageBuilder.buildBaseline9()); + destination.getSession().write(installationMessageBuilder.buildBaseline3(this)); + //destination.getSession().write(installationMessageBuilder.buildBaseline6(this)); + //destination.getSession().write(installationMessageBuilder.buildBaseline8()); + //destination.getSession().write(installationMessageBuilder.buildBaseline9()); - if(getPvPBitmask() != 0) { - UpdatePVPStatusMessage upvpm = new UpdatePVPStatusMessage(getObjectID()); - upvpm.setFaction(UpdatePVPStatusMessage.factionCRC.Neutral); - upvpm.setStatus(getPvPBitmask()); - destination.getSession().write(upvpm.serialize()); - } } } diff --git a/src/resources/objects/installation/InstallationObject.java b/src/resources/objects/installation/InstallationObject.java index 3392e5fd..856eeb59 100644 --- a/src/resources/objects/installation/InstallationObject.java +++ b/src/resources/objects/installation/InstallationObject.java @@ -24,6 +24,7 @@ package resources.objects.installation; import com.sleepycat.persist.model.Entity; import com.sleepycat.persist.model.Persistent; +import engine.clients.Client; import engine.resources.scene.Planet; import engine.resources.scene.Point3D; import engine.resources.scene.Quaternion; @@ -35,4 +36,9 @@ public class InstallationObject extends TangibleObject { public InstallationObject(long objectID, Planet planet, String template, Point3D position, Quaternion orientation){ super(objectID, planet, template, position, orientation); } + + @Override + public void sendBaselines(Client destination) { + + } } \ No newline at end of file diff --git a/src/services/housing/HousingService.java b/src/services/housing/HousingService.java index 5ee88004..e375abe0 100644 --- a/src/services/housing/HousingService.java +++ b/src/services/housing/HousingService.java @@ -276,8 +276,6 @@ public class HousingService implements INetworkDispatch { 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"); diff --git a/src/services/object/ObjectService.java b/src/services/object/ObjectService.java index ca22a7fc..aba0b902 100644 --- a/src/services/object/ObjectService.java +++ b/src/services/object/ObjectService.java @@ -54,6 +54,7 @@ import org.python.core.Py; import org.python.core.PyObject; import com.sleepycat.je.Transaction; +import com.sleepycat.je.TransactionConfig; import com.sleepycat.persist.EntityCursor; import com.sleepycat.persist.model.Entity; import com.sleepycat.persist.model.PrimaryKey; @@ -976,7 +977,8 @@ public class ObjectService implements INetworkDispatch { CrcStringTableVisitor crcTable = ClientFileManager.loadFile("misc/object_template_crc_string_table.iff", CrcStringTableVisitor.class); List persistentBuildings = new ArrayList(); Map duplicate = new HashMap(); - + Transaction txn = core.getDuplicateIdODB().getEnvironment().beginTransaction(null, null); + for (int i = 0; i < buildoutTable.getRowCount(); i++) { String template; @@ -1055,15 +1057,17 @@ public class ObjectService implements INetworkDispatch { newObjectId = core.getDuplicateIdODB().get(key, String.class, DuplicateId.class).getObjectId(); } else { newObjectId = generateObjectID(); - Transaction txn = core.getDuplicateIdODB().getEnvironment().beginTransaction(null, null); core.getDuplicateIdODB().put(new DuplicateId(key, newObjectId), String.class, DuplicateId.class, txn); - txn.commitSync(); } duplicate.put(objectId, newObjectId); objectId = newObjectId; } - + if(txn.isValid()) { + System.out.println("Committed doid transaction."); + txn.commitSync(); + } + List containers = new ArrayList(); SWGObject object; if(objectId != 0 && containerId == 0) { diff --git a/src/services/resources/HarvesterService.java b/src/services/resources/HarvesterService.java index 93e076c9..6caccdd1 100644 --- a/src/services/resources/HarvesterService.java +++ b/src/services/resources/HarvesterService.java @@ -21,8 +21,11 @@ ******************************************************************************/ package services.resources; +import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; +import java.util.Date; +import java.util.List; import java.util.Map; import java.util.Random; import java.util.Vector; @@ -30,6 +33,7 @@ import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; + import protocol.swg.EnterStructurePlacementModeMessage; import protocol.swg.SceneCreateObjectByCrc; import protocol.swg.SceneDestroyObject; @@ -53,6 +57,8 @@ import resources.objects.resource.ResourceContainerObject; import resources.objects.resource.ResourceRoot; import resources.objects.tangible.TangibleObject; import resources.objects.waypoint.WaypointObject; +import services.chat.Mail; +import services.chat.WaypointAttachment; import services.sui.SUIWindow; import services.sui.SUIWindow.SUICallback; import services.sui.SUIWindow.Trigger; @@ -383,8 +389,6 @@ public class HarvesterService implements INetworkDispatch { deed.setSurplusPower((int)harvester.getPowerLevel()); deed.setAttributes(); - SceneDestroyObject destroyObjectMsg = new SceneDestroyObject(harvester.getObjectID()); - owner.getClient().getSession().write(destroyObjectMsg.serialize()); core.objectService.destroyObject(harvester.getObjectID()); SWGObject crafterInventory = owner.getSlottedObject("inventory"); @@ -557,9 +561,7 @@ public class HarvesterService implements INetworkDispatch { int containerEnergy = containerVector.get(i).getStackCount(); if (containerEnergy <= deductedEnergy){ deductedEnergy -= containerEnergy; - playerInventory._remove(containerVector.get(i)); - SceneDestroyObject destroyObjectMsg = new SceneDestroyObject(containerVector.get(i).getObjectID()); - owner.getClient().getSession().write(destroyObjectMsg.serialize()); + playerInventory.remove(containerVector.get(i)); } else { containerEnergy -= deductedEnergy; containerVector.get(i).setStackCount(containerEnergy,(CreatureObject)owner); @@ -888,17 +890,9 @@ public class HarvesterService implements INetworkDispatch { // destroy deed TangibleObject playerInventory = (TangibleObject) actor.getSlottedObject("inventory"); - playerInventory._remove(usedDeed); - SceneDestroyObject destroyObjectMsg = new SceneDestroyObject(usedDeed.getObjectID()); - actor.getClient().getSession().write(destroyObjectMsg.serialize()); + playerInventory.remove(usedDeed); - int resCRC = CRC.StringtoCRC(constructorTemplate); - SceneCreateObjectByCrc createObjectMsg = new SceneCreateObjectByCrc(installation.getObjectID(), quaternion.x, quaternion.y, quaternion.z, quaternion.w, posX, positionY, posZ, resCRC, (byte) 0); - actor.getClient().getSession().write(createObjectMsg.serialize()); - tools.CharonPacketUtils.printAnalysis(createObjectMsg.serialize()); - SceneEndBaselines sceneEndBaselinesMsg = new SceneEndBaselines(installation.getObjectID()); - actor.getClient().getSession().write(sceneEndBaselinesMsg.serialize()); - tools.CharonPacketUtils.printAnalysis(sceneEndBaselinesMsg.serialize()); + core.simulationService.add(installation, posX, posZ, true); PlayerObject player = (PlayerObject) actor.getSlottedObject("ghost"); player.setLotsRemaining(player.getLotsRemaining()-(int)((Harvester_Deed)usedDeed).getLotRequirement()); @@ -907,8 +901,81 @@ public class HarvesterService implements INetworkDispatch { } } - public void placeHarvester(SWGObject object){ - HarvesterObject.createAndPlaceHarvester(object); + public void placeHarvester(SWGObject object) { + CreatureObject actor = (CreatureObject) object.getAttachment("Owner"); + + String structureTemplate = (String)object.getAttachment("Deed_StructureTemplate"); + HarvesterObject harvester = (HarvesterObject) NGECore.getInstance().objectService.createObject(structureTemplate, actor.getPlanet()); + long objectId = harvester.getObjectID(); + + Vector adminList = harvester.getAdminList(); + //String[] fullName = ((CreatureObject)actor).getCustomName().split(" "); + adminList.add(actor.getCustomName()); + // Set BER and outputhopper capacity here, take it from deed + harvester.setBER((int)object.getAttachment("Deed_BER")); + harvester.setSpecRate((int)(1.5F*(int)object.getAttachment("Deed_BER"))); + harvester.setOutputHopperCapacity((int)object.getAttachment("Deed_Capacity")); + harvester.setDeedTemplate((String)object.getAttachment("Deed_DeedTemplate")); + if ((int)object.getAttachment("Deed_SurplusMaintenance")>0){ + harvester.setMaintenanceAmount((int)object.getAttachment("Deed_SurplusMaintenance")); + } + if ((int)object.getAttachment("Deed_SurplusPower")>0){ + harvester.setPowerLevel((int)object.getAttachment("Deed_SurplusPower")); + } + + + // build harvester + float positionY = NGECore.getInstance().terrainService.getHeight(actor.getPlanetId(), object.getPosition().x, object.getPosition().z); + harvester.setPosition(new Point3D(object.getPosition().x,positionY, object.getPosition().z)); + core.simulationService.add(harvester, harvester.getPosition().x, harvester.getPosition().x, true); + + + PlayerObject player = (PlayerObject) actor.getSlottedObject("ghost"); + WaypointObject constructionWaypoint = (WaypointObject)NGECore.getInstance().objectService.createObject("object/waypoint/shared_world_waypoint_blue.iff", actor.getPlanet(), harvester.getPosition().x, 0 ,harvester.getPosition().z); + String displayname = "@installation_n:"+harvester.getStfName(); + constructionWaypoint.setName(displayname); + constructionWaypoint.setPlanetCRC(engine.resources.common.CRC.StringtoCRC(actor.getPlanet().getName())); + constructionWaypoint.setPosition(new Point3D(object.getPosition().x,0, object.getPosition().z)); + player.waypointAdd(constructionWaypoint); + constructionWaypoint.setPosition(new Point3D(object.getPosition().x,0, object.getPosition().z)); + constructionWaypoint.setActive(true); + constructionWaypoint.setColor((byte)1); + constructionWaypoint.setStringAttribute("", ""); + player.waypointAdd(constructionWaypoint); + constructionWaypoint.setName(displayname); + constructionWaypoint.setPlanetCRC(engine.resources.common.CRC.StringtoCRC(actor.getPlanet().getName())); + player.setLastSurveyWaypoint(constructionWaypoint); + + List attachments = new ArrayList(); + WaypointAttachment attachment = new WaypointAttachment(); + attachment.active = true; + attachment.cellID = constructionWaypoint.getCellId(); + attachment.color = (byte)1; + attachment.name = displayname; + attachment.planetCRC = engine.resources.common.CRC.StringtoCRC(actor.getPlanet().getName()); + attachment.positionX = object.getPosition().x; + attachment.positionY = 0; + attachment.positionZ = object.getPosition().z; + attachments.add(attachment); + + // remove constructor + NGECore.getInstance().objectService.destroyObject(object); + + // ToDo: waypoint attachment fix + Date date = new Date(); + Mail constructionNotificationMail = new Mail(); + constructionNotificationMail.setSenderName("Structure Service"); + constructionNotificationMail.setSubject("Your structure"); + constructionNotificationMail.setRecieverId(actor.getObjectID()); + constructionNotificationMail.setTimeStamp((int) (date.getTime() / 1000)); + constructionNotificationMail.setMailId(NGECore.getInstance().chatService.generateMailId()); + String message = "Your construction is ready"; + constructionNotificationMail.setMessage(message); + constructionNotificationMail.setStatus(Mail.NEW); + constructionNotificationMail.setAttachments(attachments); + //NGECore.getInstance().chatService.sendPersistentMessage(actor.getClient(), constructionNotificationMail); + NGECore.getInstance().chatService.storePersistentMessage(constructionNotificationMail); + NGECore.getInstance().chatService.sendPersistentMessageHeader(actor.getClient(), constructionNotificationMail); } diff --git a/src/services/sui/SUIService.java b/src/services/sui/SUIService.java index 0e76c325..a2d32ce3 100644 --- a/src/services/sui/SUIService.java +++ b/src/services/sui/SUIService.java @@ -99,13 +99,15 @@ public class SUIService implements INetworkDispatch { if (! admins.contains(owner.getCustomName()) && hoppers.contains(owner.getCustomName())){ // authorized for hopper // change radialOptions to hopper access - harvester.setAttachment("radial_filename", "harvesterHopper"); + core.scriptService.callScript("scripts/radial/", "harvesterHopper", "createRadial", core, owner, target, request.getRadialOptions()); + sendRadial(owner, target, request.getRadialOptions(), request.getRadialCount()); + return; } } if(target.getGrandparent() != null && target.getGrandparent().getAttachment("structureAdmins") != null) { - if(core.housingService.getPermissions(owner, target.getContainer())) + if(core.housingService.getPermissions(owner, target.getContainer()) && !getRadialFilename(target).equals("structure_management_terminal")) { core.scriptService.callScript("scripts/radial/", "moveable", "createRadial", core, owner, target, request.getRadialOptions()); sendRadial(owner, target, request.getRadialOptions(), request.getRadialCount()); From b7bcf89361a272ea6cfc62efedefd5108bf42fc3 Mon Sep 17 00:00:00 2001 From: Light2 Date: Sat, 12 Apr 2014 21:20:05 +0200 Subject: [PATCH 7/9] Fixed issue where non combat commands would be created as a combat command --- scripts/commands/setspeed.py | 1 - src/services/command/CommandService.java | 29 +++++++++++++----------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/scripts/commands/setspeed.py b/scripts/commands/setspeed.py index e5929c25..c73266de 100644 --- a/scripts/commands/setspeed.py +++ b/scripts/commands/setspeed.py @@ -5,6 +5,5 @@ def setup(): def run(core, actor, target, commandString): actor.setSpeedMultiplierBase(float(commandString)) - core.buffService.addBuffToCreature(actor, 'bh_prescience') return \ No newline at end of file diff --git a/src/services/command/CommandService.java b/src/services/command/CommandService.java index a215c548..e18b9535 100644 --- a/src/services/command/CommandService.java +++ b/src/services/command/CommandService.java @@ -76,7 +76,7 @@ public class CommandService implements INetworkDispatch { return false; } - if (command.getCharacterAbility().length() > 0 && !actor.hasAbility(command.getCharacterAbility()) && command.getGodLevel() < 1) { + if (command.getCharacterAbility().length() > 0 && !actor.hasAbility(command.getCharacterAbility()) && !command.getCharacterAbility().equals("admin")) { return false; } @@ -200,7 +200,7 @@ public class CommandService implements INetworkDispatch { default: break; } - + if (command.shouldCallOnTarget()) { if (target == null || !(target instanceof CreatureObject)) { return false; @@ -211,10 +211,12 @@ public class CommandService implements INetworkDispatch { long warmupTime = (long) (command.getWarmupTime() * 1000F); - try { - Thread.sleep(warmupTime); - } catch (InterruptedException e) { - e.printStackTrace(); + if(warmupTime > 0) { + try { + Thread.sleep(warmupTime); + } catch (InterruptedException e) { + e.printStackTrace(); + } } processCommand(actor, target, command, actionCounter, commandArgs); @@ -316,7 +318,7 @@ public class CommandService implements INetworkDispatch { sub += 5; } - if (hasCharacterAbility || isCombatCommand(commandName)) { + if (/*hasCharacterAbility ||*/ isCombatCommand(commandName)) { CombatCommand command = new CombatCommand(commandName); commandLookup.add(command); return command; @@ -353,15 +355,16 @@ public class CommandService implements INetworkDispatch { } public void processCommand(CreatureObject actor, SWGObject target, BaseSWGCommand command, int actionCounter, String commandArgs) { - actor.addCooldown(command.getCooldownGroup(), command.getCooldown()); - + if(command.getCooldown() > 0) + actor.addCooldown(command.getCooldownGroup(), command.getCooldown()); + if (command instanceof CombatCommand) { processCombatCommand(actor, target, (CombatCommand) command, actionCounter, commandArgs); } else { - if (FileUtilities.doesFileExist("scripts/commands/" + command.getCommandName() + ".py")) { - core.scriptService.callScript("scripts/commands/", command.getCommandName(), "run", core, actor, target, commandArgs); - } else if (FileUtilities.doesFileExist("scripts/commands/combat/" + command.getCommandName() + ".py")) { - core.scriptService.callScript("scripts/commands/combat/", command.getCommandName(), "run", core, actor, target, commandArgs); + if (FileUtilities.doesFileExist("scripts/commands/" + command.getCommandName().toLowerCase() + ".py")) { + core.scriptService.callScript("scripts/commands/", command.getCommandName().toLowerCase(), "run", core, actor, target, commandArgs); + } else if (FileUtilities.doesFileExist("scripts/commands/combat/" + command.getCommandName().toLowerCase() + ".py")) { + core.scriptService.callScript("scripts/commands/combat/", command.getCommandName().toLowerCase(), "run", core, actor, target, commandArgs); } } } From 537390832a597bae81588d342601492466ce9be0 Mon Sep 17 00:00:00 2001 From: CharonInferar Date: Sat, 12 Apr 2014 22:44:42 +0200 Subject: [PATCH 8/9] Harvester cleanup syntax error fixed --- src/services/resources/HarvesterService.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/services/resources/HarvesterService.java b/src/services/resources/HarvesterService.java index 6caccdd1..d8e028fc 100644 --- a/src/services/resources/HarvesterService.java +++ b/src/services/resources/HarvesterService.java @@ -903,11 +903,9 @@ public class HarvesterService implements INetworkDispatch { public void placeHarvester(SWGObject object) { CreatureObject actor = (CreatureObject) object.getAttachment("Owner"); - String structureTemplate = (String)object.getAttachment("Deed_StructureTemplate"); HarvesterObject harvester = (HarvesterObject) NGECore.getInstance().objectService.createObject(structureTemplate, actor.getPlanet()); long objectId = harvester.getObjectID(); - Vector adminList = harvester.getAdminList(); //String[] fullName = ((CreatureObject)actor).getCustomName().split(" "); adminList.add(actor.getCustomName()); @@ -927,9 +925,7 @@ public class HarvesterService implements INetworkDispatch { // build harvester float positionY = NGECore.getInstance().terrainService.getHeight(actor.getPlanetId(), object.getPosition().x, object.getPosition().z); harvester.setPosition(new Point3D(object.getPosition().x,positionY, object.getPosition().z)); - core.simulationService.add(harvester, harvester.getPosition().x, harvester.getPosition().x, true); - - + core.simulationService.add(harvester, harvester.getPosition().x, harvester.getPosition().z, true); PlayerObject player = (PlayerObject) actor.getSlottedObject("ghost"); WaypointObject constructionWaypoint = (WaypointObject)NGECore.getInstance().objectService.createObject("object/waypoint/shared_world_waypoint_blue.iff", actor.getPlanet(), harvester.getPosition().x, 0 ,harvester.getPosition().z); String displayname = "@installation_n:"+harvester.getStfName(); From 6f791819e69e395cfffbdd736176671e210c0346 Mon Sep 17 00:00:00 2001 From: Seefo Date: Sat, 12 Apr 2014 18:13:11 -0400 Subject: [PATCH 9/9] Fixed some housing bugs and Tusken Raider mobile template - see extended Fixed a housing issue where the structure management terminal would be returned in the item list and could be deleted via the delete all items radial. Fixed item list to display proper names of objects. Fixed the Tusken Raider mobile template to display the proper creature name and changed their default weapons from an E11 and a T21 to a Tusken Rifle. --- scripts/mobiles/tatooine/tusken_raider.py | 7 +++---- src/resources/objects/building/BuildingObject.java | 2 +- src/services/housing/HousingService.java | 3 ++- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/mobiles/tatooine/tusken_raider.py b/scripts/mobiles/tatooine/tusken_raider.py index 8daec628..b2747696 100644 --- a/scripts/mobiles/tatooine/tusken_raider.py +++ b/scripts/mobiles/tatooine/tusken_raider.py @@ -5,7 +5,7 @@ from java.util import Vector def addTemplate(core): mobileTemplate = MobileTemplate() - mobileTemplate.setCreatureName('tuskenraider') + mobileTemplate.setCreatureName('tusken_raider') mobileTemplate.setLevel(90) mobileTemplate.setDifficulty(0) mobileTemplate.setAttackRange(24) @@ -15,8 +15,7 @@ def addTemplate(core): mobileTemplate.setTemplates(templates) weaponTemplates = Vector() - weaponTemplates.add('object/weapon/ranged/rifle/shared_rifle_e11.iff') - weaponTemplates.add('object/weapon/ranged/rifle/shared_rifle_t21.iff') + weaponTemplates.add('object/weapon/ranged/rifle/shared_rifle_tusken.iff') mobileTemplate.setWeaponTemplates(weaponTemplates) @@ -24,5 +23,5 @@ def addTemplate(core): mobileTemplate.setDefaultAttack('rangedShot') mobileTemplate.setAttacks(attacks) - core.spawnService.addMobileTemplate('tuskenraider', mobileTemplate) + core.spawnService.addMobileTemplate('tusken_raider', mobileTemplate) \ No newline at end of file diff --git a/src/resources/objects/building/BuildingObject.java b/src/resources/objects/building/BuildingObject.java index 2c3d0db4..36486462 100644 --- a/src/resources/objects/building/BuildingObject.java +++ b/src/resources/objects/building/BuildingObject.java @@ -151,7 +151,7 @@ public class BuildingObject extends TangibleObject implements IPersistent { public Vector getItemsList() { Vector items = new Vector(); getCells().forEach(c -> c.viewChildren(c, true, false, (item) -> { - if(!(item instanceof CreatureObject)) + if(!(item instanceof CreatureObject) && item.getTemplate() != "object/tangible/terminal/shared_terminal_player_structure.iff") items.add((TangibleObject) item); })); return items; diff --git a/src/services/housing/HousingService.java b/src/services/housing/HousingService.java index e375abe0..50f0c2c5 100644 --- a/src/services/housing/HousingService.java +++ b/src/services/housing/HousingService.java @@ -456,7 +456,8 @@ public class HousingService implements INetworkDispatch { Vector itemList = building.getItemsList(); for (int i=0;i