From 3d128d4cd29fc3a4f33d919f49835ccd3abcce8b Mon Sep 17 00:00:00 2001 From: Seefo Date: Mon, 5 May 2014 22:42:00 -0400 Subject: [PATCH] Fixed a bug where you could not remove a lightsaber's color crystal --- src/services/EquipmentService.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/services/EquipmentService.java b/src/services/EquipmentService.java index 029edcdf..7cc326e0 100644 --- a/src/services/EquipmentService.java +++ b/src/services/EquipmentService.java @@ -123,6 +123,8 @@ public class EquipmentService implements INetworkDispatch { return false; } + if(item.getTemplate().startsWith("object/weapon/") && item.getTemplate().contains("lightsaber") && item.getAttachment("hasColorCrystal") == null) item.setAttachment("hasColorCrystal", false); + if(item.getAttachment("hasColorCrystal") != null && (Boolean) item.getAttachment("hasColorCrystal") == false) { actor.sendSystemMessage("You may not equip a light saber that has no color crystal!", (byte) 0); @@ -320,7 +322,7 @@ public class EquipmentService implements INetworkDispatch { if(!item.getTemplate().startsWith("object/tangible/component/weapon/lightsaber/")) return; if(lightsaber.getAttachment("hasColorCrystal") == null) lightsaber.setAttachment("hasColorCrystal", false); - if(item.getAttributes().containsKey("@obj_attr_n:color") && (Boolean) lightsaber.getAttachment("hasColorCrystal")) return; + if(item.getAttributes().containsKey("@obj_attr_n:color") && (Boolean) lightsaber.getAttachment("hasColorCrystal") && !(targetContainer.getContainer() instanceof CreatureObject)) return; // Find our tuner if(item.getAttachment("tunerId") == null) item.setAttachment("tunerId", 0); @@ -335,6 +337,8 @@ public class EquipmentService implements INetworkDispatch { else item.getContainer().transferTo(actor, targetContainer, item); // Calculate attributes + lightsaber.setAttachment("hasColorCrystal", false); + lightsaberInventory.viewChildren(lightsaberInventory, false, false, new Traverser() { WeaponObject saber; @@ -342,7 +346,7 @@ public class EquipmentService implements INetworkDispatch { int minDamageBonus = 0; int maxDamageBonus = 0; - Boolean hasColorCrystal = false; + Boolean hasColorCrystal = false; public void process(SWGObject item) { @@ -359,10 +363,10 @@ public class EquipmentService implements INetworkDispatch { saber.setCustomizationVariable("private/alternate_shader_blade", bladeType); saber.setCustomizationVariable("/private/index_color_blade", bladeColor); - // System.out.println("bladeColorName: " + item.getAttributes().get("@obj_attr_n:color")); - // System.out.println("bladeColor: " + bladeColor); - // System.out.println("bladeType: " + bladeType); - // System.out.println(); + // System.out.println("bladeColorName: " + item.getAttributes().get("@obj_attr_n:color")); + // System.out.println("bladeColor: " + bladeColor); + // System.out.println("bladeType: " + bladeType); + // System.out.println(); hasColorCrystal = true; }