diff --git a/scripts/buffs/buildabuff_inspiration.py b/scripts/buffs/buildabuff_inspiration.py index 2bba8272..25ba7355 100644 --- a/scripts/buffs/buildabuff_inspiration.py +++ b/scripts/buffs/buildabuff_inspiration.py @@ -11,8 +11,10 @@ def add(core, actor, buff): if buffWorkshop is None: return - buff.setDuration(3600) #1 hour - + attached = actor.getAttachment('inspireDuration') + + buff.setDuration(float(actor.getAttachment('inspireDuration') * 60)) + for BuffItem in buffWorkshop: core.skillModService.addSkillMod(actor, BuffItem.getSkillName(), BuffItem.getAffectAmount()) @@ -22,5 +24,5 @@ def remove(core, actor, buff): for BuffItem in actor.getAttachment('buffWorkshop'): core.skillModService.deductSkillMod(actor, BuffItem.getSkillName(), BuffItem.getAffectAmount()) - actor.setAttachment('buffWorkshop', 'none') + actor.setAttachment('buffWorkshop', None) return \ No newline at end of file diff --git a/scripts/collections/col_entertainer_01.py b/scripts/collections/col_entertainer_01.py new file mode 100644 index 00000000..100fa53e --- /dev/null +++ b/scripts/collections/col_entertainer_01.py @@ -0,0 +1,12 @@ +from java.lang import System +import sys + +def modify(core, actor, count): + return + +def complete(core, actor, collection): + ghost = actor.getSlottedObject('ghost') + + actor.sendSystemMessage('@collection_n:col_entertainer_01_finished', 0) + ghost.addAbility('bm_dancing_pet_entertainer') + return \ No newline at end of file diff --git a/scripts/commands/colorlights.py b/scripts/commands/colorlights.py index 62774dd0..5f9f7abc 100644 --- a/scripts/commands/colorlights.py +++ b/scripts/commands/colorlights.py @@ -6,13 +6,21 @@ def setup(): def run(core, actor, target, commandString): command = 'ColorLights1' - effect = 'entertainer_color_lights_level_1.cef' + effect = 'clienteffect/entertainer_color_lights_level_1.cef' + rLevel = 4 # minimum level to perform this effect - if actor.getLevel() < 4: - actor.sendSystemMessage('@performance:effect_lack_skill_self', 0) - return + if commandString == '2': + command = 'ColorLights2' + effect = 'clienteffect/entertainer_color_lights_level_2.cef' + rLevel = 20 - # TODO: Find out levels for other colored light 2 and 3 + elif commandString == '3': + command = 'ColorLights3' + effect = 'clienteffect/entertainer_color_lights_level_3.cef' + rLevel = 50 + + if actor.getLevel() < rLevel: + actor.sendSystemMessage('@performance:effect_lack_skill_self') if core.entertainmentService.performEffect(actor, command, effect, target) is True: actor.sendSystemMessage('@performance:effect_perform_color_lights', 0) diff --git a/scripts/commands/dazzle.py b/scripts/commands/dazzle.py index 4d93db65..e1d8cefd 100644 --- a/scripts/commands/dazzle.py +++ b/scripts/commands/dazzle.py @@ -6,13 +6,21 @@ def setup(): def run(core, actor, target, commandString): command = 'Dazzle1' - effect = 'entertainer_dazzle_level_1.cef' + effect = 'clienteffect/entertainer_dazzle_level_1.cef' + rLevel = 10 # minimum level to perform this effect - if actor.getLevel() < 10: - actor.sendSystemMessage('@performance:effect_lack_skill_self', 0) - return + if commandString == '2': + command = 'Dazzle2' + effect = 'clienteffect/entertainer_dazzle_level_2.cef' + rLevel = 20 - # TODO: Find out levels for other dazzle 2 and 3 + elif commandString == '3': + command = 'Dazzle3' + effect = 'clienteffect/entertainer_dazzle_level_3.cef' + rLevel = 30 + + if actor.getLevel() < rLevel: + actor.sendSystemMessage('@performance:effect_lack_skill_self') if core.entertainmentService.performEffect(actor, command, effect, target) is True: actor.sendSystemMessage('@performance:effect_perform_dazzle', 0) diff --git a/scripts/commands/distract.py b/scripts/commands/distract.py index 6c1eb887..d92cb55e 100644 --- a/scripts/commands/distract.py +++ b/scripts/commands/distract.py @@ -6,14 +6,23 @@ def setup(): def run(core, actor, target, commandString): command = 'Distract1' - effect = 'entertainer_distract_level_1.cef' + effect = 'clienteffect/entertainer_distract_level_1.cef' + rLevel = 18 # minimum level to perform this effect - if actor.getLevel() < 18: + if commandString == '2': + command = 'Distract2' + effect = 'clienteffect/entertainer_distract_level_2.cef' + rLevel = 50 + + elif commandString == '3': + command = 'Distract3' + effect = 'clienteffect/entertainer_distract_level_3.cef' + rLevel = 75 + + if actor.getLevel() < rLevel: actor.sendSystemMessage('@performance:effect_lack_skill_self') return - # TODO: Find out levels for other distract 2 and 3 - if core.entertainmentService.performEffect(actor, command, effect, target) is True: actor.sendSystemMessage('@performance:effect_perform_distract', 0) return \ No newline at end of file diff --git a/scripts/commands/firejet.py b/scripts/commands/firejet.py index 3e67676f..63a5ba54 100644 --- a/scripts/commands/firejet.py +++ b/scripts/commands/firejet.py @@ -6,14 +6,23 @@ def setup(): def run(core, actor, target, commandString): command = 'FireJets1' - effect = 'entertainer_fire_jets_level_1.cef' + effect = 'clienteffect/entertainer_fire_jets_level_1.cef' + rLevel = 26 # minimum level to perform this effect - if actor.getLevel() < 26: - actor.sendSystemMessage('@performance:effect_lack_skill_self', 0) + if commandString == '2': + command = 'FireJets2' + effect = 'clienteffect/entertainer_fire_jets_level_2.cef' + rLevel = 50 + + elif commandString == '3': + command = 'FireJets3' + effect = 'clienteffect/entertainer_fire_jets_level_3.cef' + rLevel = 75 + + if actor.getLevel() < rLevel: + actor.sendSystemMessage('@performance:effect_lack_skill_self') return - - # TODO: Find out levels for other firejets 2 and 3 - + if core.entertainmentService.performEffect(actor, command, effect, target) is True: actor.sendSystemMessage('@performance:effect_perform_fire_jets', 0) return \ No newline at end of file diff --git a/scripts/commands/inspire.py b/scripts/commands/inspire.py index 531aa1e2..dea0e544 100644 --- a/scripts/commands/inspire.py +++ b/scripts/commands/inspire.py @@ -7,7 +7,7 @@ def setup(): def run(core, actor, target, commandString): playerObject = actor.getSlottedObject('ghost') - print playerObject.getProfession() + if not playerObject or playerObject.getProfession() != "entertainer_1a": return diff --git a/scripts/commands/smokebomb.py b/scripts/commands/smokebomb.py index 1bc0b2b9..cb747ce1 100644 --- a/scripts/commands/smokebomb.py +++ b/scripts/commands/smokebomb.py @@ -6,13 +6,21 @@ def setup(): def run(core, actor, target, commandString): command = 'SmokeBomb1' - effect = 'entertainer_smoke_bomb_level_1.cef' + effect = 'clienteffect/entertainer_smoke_bomb_level_1.cef' + rLevel = 50 # minimum level to perform this effect - if actor.getLevel() < 50: - actor.sendSystemMessage('@performance:effect_lack_skill_self', 0) - return + if commandString == '2': + command = 'SmokeBomb2' + effect = 'clienteffect/entertainer_smoke_bomb_level_2.cef' + rLevel = 75 - # TODO: Find out levels for other smoke bomb 2 and 3 + elif commandString == '3': + command = 'SmokeBomb3' + effect = 'clienteffect/entertainer_smoke_bomb_level_3.cef' + rLevel = 90 + + if actor.getLevel() < rLevel: + actor.sendSystemMessage('@performance:effect_lack_skill_self') if core.entertainmentService.performEffect(actor, command, effect, target) is True: actor.sendSystemMessage('@performance:effect_perform_smoke_bomb', 0) diff --git a/scripts/commands/spotlight.py b/scripts/commands/spotlight.py index 25341536..1f94394a 100644 --- a/scripts/commands/spotlight.py +++ b/scripts/commands/spotlight.py @@ -8,17 +8,22 @@ def run(core, actor, target, commandString): command = 'SpotLight1' effect = 'clienteffect/entertainer_spot_light_level_1.cef' + rLevel = 1 # minimum level to perform this effect - # TODO: Figure out what levels the spotlight effects upgraded at. - - if actor.getLevel() >= 80: - command == 'SpotLight3' - effect = 'clienteffect/entertainer_spot_light_level_3.cef' - - elif actor.getLevel() >= 40: - command == 'SpotLight2' + if commandString == '2': + command = 'SpotLight2' effect = 'clienteffect/entertainer_spot_light_level_2.cef' - + rLevel = 20 + + elif commandString == '3': + command = 'SpotLight3' + effect = 'clienteffect/entertainer_spot_light_level_3.cef' + rLevel = 30 + + if actor.getLevel() < rLevel: + actor.sendSystemMessage('@performance:effect_lack_skill_self') + return + if core.entertainmentService.performEffect(actor, command, effect, None) is True: actor.sendSystemMessage('@performance:effect_perform_spot_light', 0) return diff --git a/scripts/commands/startdance.py b/scripts/commands/startdance.py index 23b815c6..13aba090 100644 --- a/scripts/commands/startdance.py +++ b/scripts/commands/startdance.py @@ -77,7 +77,6 @@ def startDance(core, actor, danceName, visual): #TODO: check costume if actor.getPosture() != Posture.Upright: - print (' can\t dance because ' + str(actor.getPosture())) actor.sendSystemMessage('@performance:dance_fail', 0) return @@ -97,7 +96,7 @@ def startDance(core, actor, danceName, visual): actor.setPosture(0x09); playerObject = actor.getSlottedObject('ghost') - if playerObject and playerObject.getProfession() == "entertainer_1a": + if playerObject and playerObject.getProfession() == "entertainer_1a" and actor.getLevel() != 90: entSvc.startPerformanceExperience(actor) dance = entSvc.getDance(visual) diff --git a/scripts/commands/ventriloquism.py b/scripts/commands/ventriloquism.py index 59d5f396..dca08014 100644 --- a/scripts/commands/ventriloquism.py +++ b/scripts/commands/ventriloquism.py @@ -6,13 +6,21 @@ def setup(): def run(core, actor, target, commandString): command = 'Ventriloquism1' - effect = 'entertainer_ventriloquism_level_1.cef' + effect = 'clienteffect/entertainer_ventriloquism_level_1.cef' + rLevel = 58 # minimum level to perform this effect - if actor.getLevel() < 58: - actor.sendSystemMessage('@performance:effect_lack_skill_self', 0) - return + if commandString == '2': + command = 'Ventriloquism2' + effect = 'clienteffect/entertainer_ventriloquism_level_2.cef' + rLevel = 75 - # TODO: Find out levels for other ventriloquism 2 and 3 + elif commandString == '3': + command = 'Ventriloquism3' + effect = 'clienteffect/entertainer_ventriloquism_level_3.cef' + rLevel = 90 + + if actor.getLevel() < rLevel: + actor.sendSystemMessage('@performance:effect_lack_skill_self') if core.entertainmentService.performEffect(actor, command, effect, target) is True: actor.sendSystemMessage('@performance:effect_perform_ventriloquism', 0) diff --git a/scripts/expertise/expertise_en_intense_performer_1.py b/scripts/expertise/expertise_en_intense_performer_1.py index cf9f9699..8925253a 100644 --- a/scripts/expertise/expertise_en_intense_performer_1.py +++ b/scripts/expertise/expertise_en_intense_performer_1.py @@ -11,8 +11,8 @@ def addExpertisePoint(core, actor): return actor.addSkill('expertise_en_intense_performer_1') + core.skillModService.addSkillMod(actor, 'expertise_en_inspire_pulse_duration_increase', 1) addAbilities(core, actor, player) - return def removeExpertisePoint(core, actor): @@ -26,9 +26,8 @@ def removeExpertisePoint(core, actor): return actor.removeSkill('expertise_en_intense_performer_1') - + core.skillModService.deductSkillMod(actor, 'expertise_en_inspire_pulse_duration_increase', 1) removeAbilities(core, actor, player) - return # this checks what abilities the player gets by level, need to also call this on level-up diff --git a/scripts/expertise/expertise_en_intense_performer_2.py b/scripts/expertise/expertise_en_intense_performer_2.py index 0582a021..f0327c0c 100644 --- a/scripts/expertise/expertise_en_intense_performer_2.py +++ b/scripts/expertise/expertise_en_intense_performer_2.py @@ -11,6 +11,7 @@ def addExpertisePoint(core, actor): return actor.addSkill('expertise_en_intense_performer_2') + core.skillModService.addSkillMod(actor, 'expertise_en_inspire_pulse_duration_increase', 1) addAbilities(core, actor, player) return @@ -26,7 +27,7 @@ def removeExpertisePoint(core, actor): return actor.removeSkill('expertise_en_intense_performer_2') - + core.skillModService.deductSkillMod(actor, 'expertise_en_inspire_pulse_duration_increase', 1) removeAbilities(core, actor, player) return diff --git a/scripts/expertise/expertise_en_intense_performer_3.py b/scripts/expertise/expertise_en_intense_performer_3.py index 5ee49acf..ac3eb24a 100644 --- a/scripts/expertise/expertise_en_intense_performer_3.py +++ b/scripts/expertise/expertise_en_intense_performer_3.py @@ -11,6 +11,7 @@ def addExpertisePoint(core, actor): return actor.addSkill('expertise_en_intense_performer_3') + core.skillModService.addSkillMod(actor, 'expertise_en_inspire_pulse_duration_increase', 1) addAbilities(core, actor, player) return @@ -26,7 +27,7 @@ def removeExpertisePoint(core, actor): return actor.removeSkill('expertise_en_intense_performer_3') - + core.skillModService.deductSkillMod(actor, 'expertise_en_inspire_pulse_duration_increase', 1) removeAbilities(core, actor, player) return diff --git a/scripts/expertise/expertise_en_intense_performer_4.py b/scripts/expertise/expertise_en_intense_performer_4.py index 29b5eb73..5e316992 100644 --- a/scripts/expertise/expertise_en_intense_performer_4.py +++ b/scripts/expertise/expertise_en_intense_performer_4.py @@ -11,6 +11,7 @@ def addExpertisePoint(core, actor): return actor.addSkill('expertise_en_intense_performer_4') + core.skillModService.addSkillMod(actor, 'expertise_en_inspire_pulse_duration_increase', 1) addAbilities(core, actor, player) return @@ -26,7 +27,7 @@ def removeExpertisePoint(core, actor): return actor.removeSkill('expertise_en_intense_performer_4') - + core.skillModService.deductSkillMod(actor, 'expertise_en_inspire_pulse_duration_increase', 1) removeAbilities(core, actor, player) return diff --git a/scripts/expertise/expertise_en_lasting_impression_1.py b/scripts/expertise/expertise_en_lasting_impression_1.py index 960c9b75..1ce042fc 100644 --- a/scripts/expertise/expertise_en_lasting_impression_1.py +++ b/scripts/expertise/expertise_en_lasting_impression_1.py @@ -11,6 +11,7 @@ def addExpertisePoint(core, actor): return actor.addSkill('expertise_en_lasting_impression_1') + core.skillModService.addSkillMod(actor, 'expertise_en_inspire_buff_duration_increase', 30) addAbilities(core, actor, player) return @@ -26,7 +27,7 @@ def removeExpertisePoint(core, actor): return actor.removeSkill('expertise_en_lasting_impression_1') - + core.skillModService.deductSkillMod(actor, 'expertise_en_inspire_buff_duration_increase', 30) removeAbilities(core, actor, player) return diff --git a/scripts/expertise/expertise_en_lasting_impression_2.py b/scripts/expertise/expertise_en_lasting_impression_2.py index 0ef56c25..5daf6031 100644 --- a/scripts/expertise/expertise_en_lasting_impression_2.py +++ b/scripts/expertise/expertise_en_lasting_impression_2.py @@ -11,6 +11,7 @@ def addExpertisePoint(core, actor): return actor.addSkill('expertise_en_lasting_impression_2') + core.skillModService.addSkillMod(actor, 'expertise_en_inspire_buff_duration_increase', 30) addAbilities(core, actor, player) return @@ -26,7 +27,7 @@ def removeExpertisePoint(core, actor): return actor.removeSkill('expertise_en_lasting_impression_2') - + core.skillModService.deductSkillMod(actor, 'expertise_en_inspire_buff_duration_increase', 30) removeAbilities(core, actor, player) return diff --git a/scripts/expertise/expertise_en_lasting_impression_3.py b/scripts/expertise/expertise_en_lasting_impression_3.py index 74107ef2..8a4642bd 100644 --- a/scripts/expertise/expertise_en_lasting_impression_3.py +++ b/scripts/expertise/expertise_en_lasting_impression_3.py @@ -11,6 +11,7 @@ def addExpertisePoint(core, actor): return actor.addSkill('expertise_en_lasting_impression_3') + core.skillModService.addSkillMod(actor, 'expertise_en_inspire_buff_duration_increase', 30) addAbilities(core, actor, player) return @@ -26,7 +27,7 @@ def removeExpertisePoint(core, actor): return actor.removeSkill('expertise_en_lasting_impression_3') - + core.skillModService.deductSkillMod(actor, 'expertise_en_inspire_buff_duration_increase', 30) removeAbilities(core, actor, player) return diff --git a/scripts/expertise/expertise_en_lasting_impression_4.py b/scripts/expertise/expertise_en_lasting_impression_4.py index b71d1b91..086a38c9 100644 --- a/scripts/expertise/expertise_en_lasting_impression_4.py +++ b/scripts/expertise/expertise_en_lasting_impression_4.py @@ -11,6 +11,7 @@ def addExpertisePoint(core, actor): return actor.addSkill('expertise_en_lasting_impression_4') + core.skillModService.addSkillMod(actor, 'expertise_en_inspire_buff_duration_increase', 30) addAbilities(core, actor, player) return @@ -26,7 +27,7 @@ def removeExpertisePoint(core, actor): return actor.removeSkill('expertise_en_lasting_impression_4') - + core.skillModService.deductSkillMod(actor, 'expertise_en_inspire_buff_duration_increase', 30) removeAbilities(core, actor, player) return diff --git a/scripts/radial/player.py b/scripts/radial/player.py index 3ca2cc75..6ad15a17 100644 --- a/scripts/radial/player.py +++ b/scripts/radial/player.py @@ -4,11 +4,16 @@ import sys def createRadial(core, owner, target, radials): if target.getPosture() == Posture.SkillAnimating: - if target.getPerformanceType() is True: - radials.add(RadialOptions(0, 140, 1, 'Watch')) + if owner.getPerformanceWatchee() == target: + if target.getPerformanceType() is True: + radials.add(RadialOptions(0, 141, 3, 'Stop Watching')) + elif owner.getPerformanceListenee() == target: # TODO: Get rid of PerformanceWatchee variable, no need for listenee (same thing really) + radials.add(RadialOptions(0, 141, 3, 'Stop Listening')) else: - radials.add(RadialOptions(0, 140, 1, 'Listen')) - + if target.getPerformanceType() is True: + radials.add(RadialOptions(0, 140, 3, 'Watch')) + else: + radials.add(RadialOptions(0, 140, 3, 'Listen')) return def handleSelection(core, owner, target, option): @@ -20,4 +25,8 @@ def handleSelection(core, owner, target, option): # TODO: Insert callCommand /listen return return + + if option == 141: + #core.commandService.callCommand(owner, 'stopwatching', target, '') #SWGList error for remove audience in CreatureObject + return return \ No newline at end of file diff --git a/scripts/radial/ring/unity.py b/scripts/radial/ring/unity.py index 8c1c4c5d..92940452 100644 --- a/scripts/radial/ring/unity.py +++ b/scripts/radial/ring/unity.py @@ -16,10 +16,10 @@ def createRadial(core, owner, target, radials): if targetPlayer is not None and targetPlayer.getSlottedObject('ghost') is not None: if targetPlayer.getObjectID() == owner.getObjectID(): return - radials.add(RadialOptions(0, 69, 1, '@unity:mnu_propose')) + radials.add(RadialOptions(0, 69, 3, '@unity:mnu_propose')) return else: - radials.add(RadialOptions(0, 70, 1, '@unity:mnu_divorce')) + radials.add(RadialOptions(0, 70, 3, '@unity:mnu_divorce')) return return diff --git a/src/protocol/swg/CollectionServerFirstListRequest.java b/src/protocol/swg/CollectionServerFirstListRequest.java new file mode 100644 index 00000000..cc053664 --- /dev/null +++ b/src/protocol/swg/CollectionServerFirstListRequest.java @@ -0,0 +1,53 @@ +/******************************************************************************* + * 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; + +import org.apache.mina.core.buffer.IoBuffer; + +public class CollectionServerFirstListRequest extends SWGMessage { + + private String server; + + public CollectionServerFirstListRequest() { + } + + @Override + public void deserialize(IoBuffer data) { + data.getShort(); + data.getInt(); + setServer(getAsciiString(data)); + } + + public String getServer() { + return server; + } + + @Override + public IoBuffer serialize() { + return null; + } + + public void setServer(String server) { + this.server = server; + } + +} diff --git a/src/protocol/swg/CollectionServerFirstListResponse.java b/src/protocol/swg/CollectionServerFirstListResponse.java new file mode 100644 index 00000000..163627da --- /dev/null +++ b/src/protocol/swg/CollectionServerFirstListResponse.java @@ -0,0 +1,75 @@ +/******************************************************************************* + * 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; + +import java.nio.ByteOrder; +import java.util.Map; +import java.util.Map.Entry; + +import main.NGECore; + +import org.apache.mina.core.buffer.IoBuffer; + +import services.collections.ServerFirst; +import engine.resources.common.CRC; + +public class CollectionServerFirstListResponse extends SWGMessage { + + private Map sfList; + private String server; + + public CollectionServerFirstListResponse(String server, Map serverFirstList){ + this.sfList = serverFirstList; + this.server = server; + } + + @Override + public void deserialize(IoBuffer data) { + + } + + @Override + public IoBuffer serialize() { + IoBuffer buffer; + + int size = 0; + + synchronized (sfList) { + for (Entry entry : sfList.entrySet()) { + size += entry.getValue().getBytes().length; + } + + buffer = IoBuffer.allocate(12 + server.length() + size).order(ByteOrder.LITTLE_ENDIAN); + buffer.putShort((short) 2); + buffer.putInt(CRC.StringtoCRC("CollectionServerFirstListResponse")); + + buffer.put(getAsciiString(server)); + buffer.putInt(sfList.size()); + + for (Entry entry : sfList.entrySet()) { + buffer.put(entry.getValue().getBytes()); + + } + return buffer.flip(); + } + } +} diff --git a/src/protocol/swg/objectControllerObjects/ShowFlyText.java b/src/protocol/swg/objectControllerObjects/ShowFlyText.java index 41325368..f47bbbb2 100644 --- a/src/protocol/swg/objectControllerObjects/ShowFlyText.java +++ b/src/protocol/swg/objectControllerObjects/ShowFlyText.java @@ -27,6 +27,7 @@ import org.apache.mina.core.buffer.IoBuffer; import protocol.swg.ObjControllerMessage; import resources.common.RGB; +import resources.common.StringUtilities; public class ShowFlyText extends ObjControllerObject { @@ -70,6 +71,7 @@ public class ShowFlyText extends ObjControllerObject { this.scale = scale; this.color = color; this.alternativeStructure = true; + this.displayType = displayType; } @Override @@ -117,13 +119,16 @@ public class ShowFlyText extends ObjControllerObject { result.putLong(0); result.putLong(0); result.putLong(0); - result.put(getUnicodeString(customText)); - result.putShort(xp); + result.put(getUnicodeString(customText)); // %TO? + result.putShort(xp); // %DI ? result.putLong(0); result.putFloat(scale); result.put(color.getBytes()); result.putInt(displayType); - return result.flip(); + + result.flip(); + //StringUtilities.printBytes(result.array()); + return result; } } diff --git a/src/protocol/swg/objectControllerObjects/ShowLootBox.java b/src/protocol/swg/objectControllerObjects/ShowLootBox.java index e295fc2d..432ddd14 100644 --- a/src/protocol/swg/objectControllerObjects/ShowLootBox.java +++ b/src/protocol/swg/objectControllerObjects/ShowLootBox.java @@ -23,6 +23,7 @@ package protocol.swg.objectControllerObjects; import java.nio.ByteOrder; import java.util.List; +import java.util.Vector; import org.apache.mina.core.buffer.IoBuffer; @@ -33,9 +34,15 @@ import resources.common.StringUtilities; public class ShowLootBox extends ObjControllerObject { private long playerId; - private SWGObject[] rewards; + private Vector rewards; + private SWGObject reward; - public ShowLootBox(long playerId, SWGObject[] rewards) { + public ShowLootBox(long playerId, SWGObject reward) { + this.playerId = playerId; + this.rewards = rewards; + } + + public ShowLootBox(long playerId, Vector rewards) { this.playerId = playerId; this.rewards = rewards; } @@ -47,19 +54,24 @@ public class ShowLootBox extends ObjControllerObject { @Override public IoBuffer serialize() { - // Controller Type = 11 - IoBuffer buffer = IoBuffer.allocate(20 + (rewards.length * 8)).order(ByteOrder.LITTLE_ENDIAN); + IoBuffer buffer; + + if (rewards != null) + buffer = IoBuffer.allocate(20 + (rewards.size() * 8)).order(ByteOrder.LITTLE_ENDIAN); + + else + buffer = IoBuffer.allocate(28).order(ByteOrder.LITTLE_ENDIAN); buffer.putInt(ObjControllerMessage.SHOW_LOOT_BOX); buffer.putLong(playerId); buffer.putInt(0); // 1 for a black background on icon, 0 or 2 for transparent (default) - if (rewards.length == 1) { + if (rewards == null) { buffer.putInt(1); - buffer.putLong(rewards[0].getObjectId()); + buffer.putLong(reward.getObjectId()); } else { - buffer.putInt(rewards.length); + buffer.putInt(rewards.size()); for(SWGObject obj : rewards) { buffer.putLong(obj.getObjectID()); } diff --git a/src/resources/common/MathUtilities.java b/src/resources/common/MathUtilities.java index 8cf73cc0..8decf30b 100644 --- a/src/resources/common/MathUtilities.java +++ b/src/resources/common/MathUtilities.java @@ -21,6 +21,8 @@ ******************************************************************************/ package resources.common; +import java.math.BigDecimal; + import engine.resources.scene.*; public class MathUtilities { @@ -43,5 +45,27 @@ public class MathUtilities { q1.w * q2.z + q1.z * q2.w + q1.x * q2.y - q1.y * q2.x); } + + /** + * Converts seconds to a whole hour. + * @author Waverunner + * @param seconds + * @return hour(s) + */ + public static int secondsToWholeHours(int seconds) { + BigDecimal dec = new BigDecimal(seconds); + return dec.divide(new BigDecimal(3600), BigDecimal.ROUND_FLOOR).intValue(); + } + + /** + * Converts seconds to minutes of the hour. + * @author Waverunner + * @param seconds + * @return hour(s) + */ + public static int secondsToHourMinutes(int seconds) { + BigDecimal dec = new BigDecimal(seconds); + return dec.remainder(new BigDecimal(3600)).divide(new BigDecimal(60), BigDecimal.ROUND_FLOOR).intValue(); + } } diff --git a/src/resources/objects/creature/CreatureMessageBuilder.java b/src/resources/objects/creature/CreatureMessageBuilder.java index e3facb65..08f33a9b 100644 --- a/src/resources/objects/creature/CreatureMessageBuilder.java +++ b/src/resources/objects/creature/CreatureMessageBuilder.java @@ -379,7 +379,12 @@ public class CreatureMessageBuilder extends ObjectMessageBuilder { buffer.put((byte) 0); // performing? boolean buffer.put(creature.getDifficulty()); - buffer.putInt(0xFFFFFFFF); // -1 normal appearance, 0 hologram + + if(creature.isHologram()) + buffer.putInt(0); + else + buffer.putInt(0xFFFFFFFF); + buffer.put((byte) 1); // visibleOnRadar? boolean buffer.put((byte) 0); // no effect for 1? buffer.put((byte) 0); // no effect for 1? diff --git a/src/resources/objects/creature/CreatureObject.java b/src/resources/objects/creature/CreatureObject.java index 46d13369..2d89527f 100644 --- a/src/resources/objects/creature/CreatureObject.java +++ b/src/resources/objects/creature/CreatureObject.java @@ -57,7 +57,7 @@ import engine.resources.scene.Quaternion; import resources.objects.tangible.TangibleObject; import resources.objects.weapon.WeaponObject; -@Entity(version=1) +@Entity(version=2) public class CreatureObject extends TangibleObject implements IPersistent { @NotPersistent @@ -118,6 +118,7 @@ public class CreatureObject extends TangibleObject implements IPersistent { private byte moodId = 0; private int performanceCounter = 0; private int performanceId = 0; + private boolean hologram = false; //FIXME: this is a bit of a hack. private boolean performanceType = false; //FIXME: hmm.. or persistent? @@ -421,6 +422,7 @@ public class CreatureObject extends TangibleObject implements IPersistent { if(performanceType) { next.sendSystemMessage("You stop watching " + getCustomName() + ".",(byte)0); } else { next.sendSystemMessage("You stop listening to " + getCustomName() + ".",(byte)0); } next.getSpectatorTask().cancel(true); + next.getInspirationTick().cancel(true); } //not sure if this behaviour is correct. might need fixing later. performanceAudience = new SWGList(); @@ -435,11 +437,15 @@ public class CreatureObject extends TangibleObject implements IPersistent { } public ScheduledFuture getInspirationTick() { - return inspirationTick; + synchronized(objectMutex) { + return inspirationTick; + } } public void setInspirationTick(ScheduledFuture inspirationTick) { - this.inspirationTick = inspirationTick; + synchronized(objectMutex) { + this.inspirationTick = inspirationTick; + } } @Override @@ -570,6 +576,7 @@ public class CreatureObject extends TangibleObject implements IPersistent { public void addSkillMod(String name, int base) { if(getSkillMod(name) == null) { + // TODO: This will need to be fixed as it doesn't update in the character sheet properly (wrong delta) SkillMod skillMod = new SkillMod(); skillMod.setBase(base); skillMod.setSkillModString(name); @@ -1671,4 +1678,16 @@ public class CreatureObject extends TangibleObject implements IPersistent { this.performingEffect = hasEffect; } } + + public void setHologram(boolean isHologram) { + synchronized(objectMutex) { + this.hologram = isHologram; + } + } + + public boolean isHologram() { + synchronized(objectMutex) { + return hologram; + } + } } diff --git a/src/resources/objects/tangible/TangibleObject.java b/src/resources/objects/tangible/TangibleObject.java index 587daa91..8c579480 100644 --- a/src/resources/objects/tangible/TangibleObject.java +++ b/src/resources/objects/tangible/TangibleObject.java @@ -321,6 +321,18 @@ public class TangibleObject extends SWGObject { } } + public void showFlyText(String stfFile, String stfString, String customText, int xp, float scale, RGB color, int displayType, int unkInt) { + //Set observers = getObservers(); + + if (getClient() != null) { + getClient().getSession().write((new ObjControllerMessage(0x0000000B, new ShowFlyText(getObjectID(), getObjectID(), unkInt, 1, 1, -1, stfFile, stfString, customText, xp, scale, color, displayType))).serialize()); + } + + /*for (Client client : observers) { + client.getSession().write((new ObjControllerMessage(0x0000000B, new ShowFlyText(client.getParent().getObjectID(), getObjectID(), unkInt, 1, 1, -1, stfFile, stfString, customText, xp, scale, color, displayType))).serialize()); + }*/ + } + public void playEffectObject(String effectFile, String commandString) { notifyObservers(new PlayClientEffectObjectMessage(effectFile, getObjectID(), commandString), true); } diff --git a/src/services/BuffService.java b/src/services/BuffService.java index f8a6bcb3..aa822001 100644 --- a/src/services/BuffService.java +++ b/src/services/BuffService.java @@ -72,7 +72,7 @@ public class BuffService implements INetworkDispatch { addBuffToCreature(creature, buffName, creature); } - public void addBuffToCreature(CreatureObject target, String buffName, CreatureObject buffer) { + public boolean addBuffToCreature(CreatureObject target, String buffName, CreatureObject buffer) { /*if(!FileUtilities.doesFileExist("scripts/buffs/" + buffName + ".py")) { //System.out.println("Buff script doesnt exist for: " + buffName); @@ -82,8 +82,10 @@ public class BuffService implements INetworkDispatch { final Buff buff = new Buff(buffName, buffer.getObjectID()); if(buff.isGroupBuff()) { addGroupBuff(buffer, buffName, buffer); + return true; } else { doAddBuff(target, buffName, buffer); + return true; } } diff --git a/src/services/ConnectionService.java b/src/services/ConnectionService.java index c0d5405e..9791848a 100644 --- a/src/services/ConnectionService.java +++ b/src/services/ConnectionService.java @@ -195,6 +195,20 @@ public class ConnectionService implements INetworkDispatch { object.setInviteCounter(0); object.setInviteSenderId(0); object.setInviteSenderName(""); + + if(object.getAttachment("inspireDuration") != null) + object.setAttachment("inspireDuration", null); + + if(object.getInspirationTick() != null) { + object.getInspirationTick().cancel(true); + object.setInspirationTick(null); + } + + if(object.getSpectatorTask() != null) { + object.getSpectatorTask().cancel(true); + object.setSpectatorTask(null); + } + core.groupService.handleGroupDisband(object); for (CreatureObject opponent : object.getDuelList()) { diff --git a/src/services/EntertainmentService.java b/src/services/EntertainmentService.java index b45b0c8d..9e1a0b64 100644 --- a/src/services/EntertainmentService.java +++ b/src/services/EntertainmentService.java @@ -4,6 +4,7 @@ import java.nio.ByteOrder; import java.util.HashMap; import java.util.Iterator; import java.util.Map; +import java.util.Random; import java.util.Vector; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.Executors; @@ -24,13 +25,16 @@ import protocol.swg.objectControllerObjects.BuffBuilderEndMessage; import protocol.swg.objectControllerObjects.BuffBuilderStartMessage; import resources.common.BuffBuilder; import resources.common.Console; +import resources.common.MathUtilities; import resources.common.ObjControllerOpcodes; import resources.common.Performance; import resources.common.PerformanceEffect; +import resources.common.RGB; import resources.common.StringUtilities; import resources.datatables.Posture; import resources.objects.Buff; import resources.objects.BuffItem; +import resources.objects.SWGList; import resources.objects.creature.CreatureObject; import resources.objects.player.PlayerObject; import resources.objects.tangible.TangibleObject; @@ -38,6 +42,7 @@ import engine.clientdata.ClientFileManager; import engine.clientdata.visitors.DatatableVisitor; import engine.clients.Client; import engine.resources.objects.SWGObject; +import engine.resources.objects.SkillMod; import engine.resources.service.INetworkDispatch; import engine.resources.service.INetworkRemoteEvent; @@ -52,6 +57,8 @@ public class EntertainmentService implements INetworkDispatch { private ConcurrentHashMap performancesByIndex = new ConcurrentHashMap(); private ConcurrentHashMap danceMap = new ConcurrentHashMap(); + private Random ranWorkshop = new Random(); + private Map performanceEffects = new ConcurrentHashMap(); public EntertainmentService(NGECore core) { @@ -70,7 +77,7 @@ public class EntertainmentService implements INetworkDispatch { public void handlePacket(IoSession session, IoBuffer data) throws Exception { data.order(ByteOrder.LITTLE_ENDIAN); - StringUtilities.printBytes(data.array()); + Client client = core.getClient(session); if(client == null) @@ -145,8 +152,8 @@ public class EntertainmentService implements INetworkDispatch { Vector statBuffs = sentPacket.getStatBuffs(); - SWGObject buffer = core.objectService.getObject(sentPacket.getBufferId()); - SWGObject buffRecipient = core.objectService.getObject(sentPacket.getBuffRecipientId()); + CreatureObject buffer = (CreatureObject) core.objectService.getObject(sentPacket.getBufferId()); + CreatureObject buffRecipient = (CreatureObject) core.objectService.getObject(sentPacket.getBuffRecipientId()); if (buffer != buffRecipient) { @@ -170,7 +177,7 @@ public class EntertainmentService implements INetworkDispatch { } } - giveInspirationBuff(buffRecipient, statBuffs); + giveInspirationBuff(buffRecipient, buffer, statBuffs); BuffBuilderEndMessage endBuilder = new BuffBuilderEndMessage(changeMessage); endBuilder.setObjectId(buffer.getObjectId()); @@ -200,7 +207,7 @@ public class EntertainmentService implements INetworkDispatch { } else { if (sentPacket.getAccepted() == true) { - giveInspirationBuff(buffRecipient, statBuffs); + giveInspirationBuff(buffRecipient, buffer, statBuffs); BuffBuilderEndMessage endBuilder = new BuffBuilderEndMessage(sentPacket); endBuilder.setObjectId(buffer.getObjectId()); @@ -354,8 +361,7 @@ public class EntertainmentService implements INetworkDispatch { core.commandService.registerCommand("ventriloquism"); } - public void giveInspirationBuff(SWGObject reciever, Vector buffVector) { - CreatureObject buffCreature = (CreatureObject) reciever; + public void giveInspirationBuff(CreatureObject reciever, CreatureObject buffer, Vector buffVector) { Vector availableStats = buffBuilderSkills; Vector stats = new Vector(); @@ -372,22 +378,35 @@ public class EntertainmentService implements INetworkDispatch { BuffItem stat = new BuffItem(builder.getStatAffects(), item.getInvested(), item.getEntertainerBonus()); stat.setAffectAmount(affectTotal); - - /*System.out.println("Invested Points: " + item.getInvested()); - System.out.println("Entertainer Bonus: " + item.getEntertainerBonus()); - System.out.println("Affect Total: " + affectTotal);*/ stats.add(stat); - - break; } } } - reciever.setAttachment("buffWorkshop", buffVector); - - core.buffService.addBuffToCreature(buffCreature, "buildabuff_inspiration"); + reciever.setAttachment("buffWorkshop", stats); + PlayerObject rPlayer = (PlayerObject) reciever.getSlottedObject("ghost"); + + long timeStamp = 0; + if (reciever.getAttachment("buffWorkshopTimestamp") != null) + timeStamp = (long) reciever.getAttachment("buffWorkshopTimestamp"); + + core.buffService.addBuffToCreature(reciever, "buildabuff_inspiration", buffer); + /*if (core.buffService.addBuffToCreature(reciever, "buildabuff_inspiration", buffer) && !rPlayer.getProfession().equals("entertainer_1a")) { + if (timeStamp == 0 || (System.currentTimeMillis() - timeStamp > 86400000)) { + float random = ranWorkshop.nextFloat(); + if (random < 0.75f) { + + if(rPlayer.getProfession().contains("trader")) { core.collectionService.addCollection(buffer, "prof_trader"); } + + else { + core.collectionService.addCollection(buffer, rPlayer.getProfession()); + } + } + } else { buffer.sendSystemMessage("@collection:buffed_too_soon", (byte) 0); } + reciever.setAttachment("buffWorkshopTimestamp", System.currentTimeMillis()); + }*/ } public int getDanceVisualId(String danceName) { @@ -481,6 +500,7 @@ public class EntertainmentService implements INetworkDispatch { } public void startSpectating(final CreatureObject spectator, final CreatureObject performer) { + final ScheduledFuture spectatorTask = scheduler.scheduleAtFixedRate(new Runnable() { @Override @@ -499,14 +519,20 @@ public class EntertainmentService implements INetworkDispatch { } spectator.setMoodAnimation("neutral"); performer.removeAudience(spectator); - - spectator.getSpectatorTask().cancel(true); + + if (spectator.getInspirationTick().cancel(true)) + spectator.getSpectatorTask().cancel(true); } } }, 2, 2, TimeUnit.SECONDS); spectator.setSpectatorTask(spectatorTask); + + if(((PlayerObject)performer.getSlottedObject("ghost")).getProfession().equals("entertainer_1a")) { + handleInspirationTicks(spectator, performer); + } + } public void performFlourish(final CreatureObject performer, int flourish) { @@ -547,8 +573,6 @@ public class EntertainmentService implements INetworkDispatch { String performance = (performer.getPerformanceType()) ? "dance" : "music"; - // TODO: Skill Level check - if(performer.isPerformingEffect()) { performer.sendSystemMessage("@performance:effect_wait_self", (byte) 0); return false; @@ -591,6 +615,49 @@ public class EntertainmentService implements INetworkDispatch { return true; } + public void handleInspirationTicks(final CreatureObject spectator, final CreatureObject performer) { + // http://youtu.be/WqyAde-oC7o?t=11m14s << Player watching entertainer (Has ring only, no pet, + 15 min ticks) + // TODO: Camp/Cantina checks for expertise and duration bonus %. Right now only using basic values. + final ScheduledFuture inspirationTick = scheduler.scheduleAtFixedRate(new Runnable() { + + @Override + public void run() { + int time = 0; // current buff duration time (minutes) + int buffCap = 215; // 5 hours 35 minutes - 2 hours (buff duration increase bonus) << Taken from video, doesn't account for performance bonuses etc. + + if (spectator.getAttachment("inspireDuration") != null) + time+= (int) spectator.getAttachment("inspireDuration"); + + if (performer.getSkillMod("expertise_en_inspire_buff_duration_increase") != null) { + SkillMod durationMod = performer.getSkillMod("expertise_en_inspire_buff_duration_increase"); + buffCap += durationMod.getBase() + durationMod.getModifier(); + } + + if (time >= buffCap) { + spectator.setAttachment("inspireDuration", buffCap); // incase someone went over cap + spectator.getInspirationTick().cancel(true); + } else { + int entTick = 10; + if (performer.getSkillMod("expertise_en_inspire_pulse_duration_increase") != null) { + SkillMod pulseMod = performer.getSkillMod("expertise_en_inspire_pulse_duration_increase"); + entTick += pulseMod.getBase() + pulseMod.getModifier(); + } + + int duration = (time + entTick); // minutes + int hMinutes = MathUtilities.secondsToHourMinutes(duration * 60); + int hours = MathUtilities.secondsToWholeHours(duration * 60); + + spectator.showFlyText("spam", "buff_duration_tick_observer", String.valueOf(hours) + " hours , " + hMinutes + " minutes ", 0, (float) 0.66, new RGB(255, 182, 193), 3, 78); + + spectator.setAttachment("inspireDuration", duration); + //System.out.println("Inspire Duration: " + spectator.getAttachment("inspireDuration") + " on " + spectator.getCustomName()); + } + } + + }, 10, 10, TimeUnit.SECONDS); + spectator.setInspirationTick(inspirationTick); + } + @Override public void shutdown() { diff --git a/src/services/PlayerService.java b/src/services/PlayerService.java index fb203434..dd2f9608 100644 --- a/src/services/PlayerService.java +++ b/src/services/PlayerService.java @@ -41,6 +41,8 @@ import org.apache.mina.core.session.IoSession; import protocol.swg.CharacterSheetResponseMessage; import protocol.swg.ClientIdMsg; import protocol.swg.ClientMfdStatusUpdateMessage; +import protocol.swg.CollectionServerFirstListRequest; +import protocol.swg.CollectionServerFirstListResponse; import protocol.swg.CreateClientPathMessage; import protocol.swg.ExpertiseRequestMessage; import protocol.swg.GuildRequestMessage; @@ -57,6 +59,7 @@ import resources.common.ObjControllerOpcodes; import resources.common.Opcodes; import resources.common.RGB; import resources.common.SpawnPoint; +import resources.common.StringUtilities; import resources.datatables.PlayerFlags; import resources.guild.Guild; import resources.objects.Buff; @@ -391,8 +394,30 @@ public class PlayerService implements INetworkDispatch { swgOpcodes.put(Opcodes.CollectionServerFirstListRequest, new INetworkRemoteEvent() { @Override - public void handlePacket(IoSession session, IoBuffer buffer) throws Exception { + public void handlePacket(IoSession session, IoBuffer data) throws Exception { + data.order(ByteOrder.LITTLE_ENDIAN); + data.position(0); + + Client client = core.getClient(session); + if (client == null) + return; + + SWGObject player = client.getParent(); + + if (player == null) + return; + + CollectionServerFirstListRequest request = new CollectionServerFirstListRequest(); + request.deserialize(data); + + String server = request.getServer(); + System.out.println(server); + if (server == null || server.equals("")) + return; + + CollectionServerFirstListResponse response = new CollectionServerFirstListResponse(server, core.guildService.getGuildObject().getServerFirst()); + session.write(response.serialize()); } }); @@ -736,7 +761,7 @@ public class PlayerService implements INetworkDispatch { } if (rewards != null && !rewards.isEmpty()) { - giveItems(creature, (SWGObject[]) rewards.toArray()); + giveItems(creature, rewards); } } catch (InstantiationException | IllegalAccessException e) { @@ -750,6 +775,9 @@ public class PlayerService implements INetworkDispatch { } catch (InstantiationException | IllegalAccessException e) { e.printStackTrace(); } + + if(player.getProfession().equals("entertainer_1a") && creature.getLevel() == (short) 90) + creature.getEntertainerExperience().cancel(true); //} } @@ -793,11 +821,38 @@ public class PlayerService implements INetworkDispatch { } /** - * Gives a player items and shows the "New Items" message. - * @param reciever Player receiving the items - * @param items The object(s) to be given. This will allow multiple arguments. + * Gives a player an item and shows the "New Items" message. + * @param reciever Player receiving the item. + * @param item The object to be given. + * @author Waverunner */ - public void giveItems(CreatureObject reciever, SWGObject... items) { + public void giveItem(CreatureObject reciever, SWGObject item) { + if (reciever == null || item == null) + return; + + if (reciever.getClient() == null) + return; + Client client = reciever.getClient(); + + if (client.getSession() == null) + return; + SWGObject inventory = reciever.getSlottedObject("inventory"); + + if (inventory == null) + return; + + inventory.add(item); + + ObjControllerMessage objController = new ObjControllerMessage(11, new ShowLootBox(reciever.getObjectID(), item)); + client.getSession().write(objController.serialize()); + } + + /** + * Gives a player a variety of items and shows the "New Items" message. + * @param reciever Player receiving the items. + * @param items Vector of the items. + */ + public void giveItems(CreatureObject reciever, Vector items) { if (reciever == null || items == null) return; diff --git a/src/services/collections/CollectionService.java b/src/services/collections/CollectionService.java index c74e3993..e31bde4c 100644 --- a/src/services/collections/CollectionService.java +++ b/src/services/collections/CollectionService.java @@ -362,7 +362,7 @@ public class CollectionService implements INetworkDispatch { } if (trackServerFirst) { - if (core.guildService.getGuildObject().addServerFirst(collectionName, new ServerFirst(creature.getCustomName(), System.currentTimeMillis()))) { + if (core.guildService.getGuildObject().addServerFirst(collectionName, new ServerFirst(creature.getCustomName(), creature.getObjectId(), collectionName, System.currentTimeMillis()))) { addCollection(creature, "bdg_server_first_01"); } } diff --git a/src/services/collections/ServerFirst.java b/src/services/collections/ServerFirst.java index 1a955ed2..2b855fb4 100644 --- a/src/services/collections/ServerFirst.java +++ b/src/services/collections/ServerFirst.java @@ -21,6 +21,8 @@ ******************************************************************************/ package services.collections; +import org.apache.mina.core.buffer.IoBuffer; + import resources.objects.Delta; import com.sleepycat.persist.model.Persistent; @@ -29,11 +31,15 @@ import com.sleepycat.persist.model.Persistent; public class ServerFirst extends Delta { private String name; + private String collection; private long time; + private long objectId; - public ServerFirst(String name, long time) { + public ServerFirst(String name, long objectId, String collection, long time) { this.name = name; + this.objectId = objectId; this.time = time; + this.collection = collection; } public ServerFirst() { @@ -48,9 +54,24 @@ public class ServerFirst extends Delta { return time; } + public long getObjectId() { + return objectId; + } + + public String getCollection() { + return collection; + } + @Override public byte[] getBytes() { - return new byte[] { }; + synchronized(objectMutex) { + IoBuffer buffer = createBuffer(18 + collection.length() + (name.length() * 2)); + buffer.putInt((int) time / 1000); + buffer.put(getAsciiString(collection)); + buffer.putLong(objectId); + buffer.put(getUnicodeString(name)); + return buffer.array(); + } } }