diff --git a/scripts/commands/generic/setBiography.js b/scripts/commands/generic/setBiography.js new file mode 100644 index 000000000..ccffe3a63 --- /dev/null +++ b/scripts/commands/generic/setBiography.js @@ -0,0 +1,13 @@ +function executeCommand(galacticManager, player, target, args) { + + if(args.length() > 1025) { + return; + } + + var BiographyUpdate = Java.type("network.packets.swg.zone.object_controller.BiographyUpdate"); + var creatureObject = player.getCreatureObject(); + var objectId = creatureObject.getObjectId(); + + creatureObject.getPlayerObject().setBiography(args); + player.sendPacket(new BiographyUpdate(objectId, objectId, args)); +} diff --git a/src/network/packets/swg/zone/object_controller/BiographyUpdate.java b/src/network/packets/swg/zone/object_controller/BiographyUpdate.java new file mode 100644 index 000000000..a9e7cff0c --- /dev/null +++ b/src/network/packets/swg/zone/object_controller/BiographyUpdate.java @@ -0,0 +1,76 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore 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 Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package network.packets.swg.zone.object_controller; + +import java.nio.ByteBuffer; + +public class BiographyUpdate extends ObjectController { + + public static final int CRC = 0x01DB; + + private long targetId; + private String biography; + + public BiographyUpdate(long objectId, long targetId, String biography) { + super(objectId, CRC); + setTargetId(targetId); + setBiography(biography); + } + + public BiographyUpdate(ByteBuffer data) { + super(CRC); + decode(data); + } + + public void decode(ByteBuffer data) { + decodeHeader(data); + targetId = getLong(data); + biography = getUnicode(data); + } + + public ByteBuffer encode() { + ByteBuffer data = ByteBuffer.allocate(HEADER_LENGTH + Long.BYTES + Integer.BYTES + biography.length() * 2); + encodeHeader(data); + addLong(data, targetId); + addUnicode(data, biography); + return data; + } + + public long getTargetId() { return targetId; } + + public void setTargetId(long targetId) { this.targetId = targetId; } + + public String getBiography() { + return biography; + } + + public void setBiography(String biography) { + this.biography = biography; + } + +} diff --git a/src/network/packets/swg/zone/object_controller/ObjectController.java b/src/network/packets/swg/zone/object_controller/ObjectController.java index 41bccc863..5b6865545 100644 --- a/src/network/packets/swg/zone/object_controller/ObjectController.java +++ b/src/network/packets/swg/zone/object_controller/ObjectController.java @@ -101,6 +101,7 @@ public abstract class ObjectController extends SWGPacket { case 0x0134: return new CombatSpam(data); case 0x0146: return new ObjectMenuRequest(data); case 0x01BD: return new ShowFlyText(data); + case 0x01DB: return new BiographyUpdate(data); case 0x044D: return new ChangeRoleIconChoice(data); case 0x04C5: return new IntendedTarget(data); } diff --git a/src/resources/commands/callbacks/RequestBiographyCmdCallback.java b/src/resources/commands/callbacks/RequestBiographyCmdCallback.java new file mode 100644 index 000000000..938aff0bf --- /dev/null +++ b/src/resources/commands/callbacks/RequestBiographyCmdCallback.java @@ -0,0 +1,58 @@ +/*********************************************************************************** +* Copyright (c) 2015 /// Project SWG /// www.projectswg.com * +* * +* ProjectSWG is the first NGE emulator for Star Wars Galaxies founded on * +* July 7th, 2011 after SOE announced the official shutdown of Star Wars Galaxies. * +* Our goal is to create an emulator which will provide a server for players to * +* continue playing a game similar to the one they used to play. We are basing * +* it on the final publish of the game prior to end-game events. * +* * +* This file is part of Holocore. * +* * +* -------------------------------------------------------------------------------- * +* * +* Holocore is free software: you can redistribute it and/or modify * +* it under the terms of the GNU Affero General Public License as * +* published by the Free Software Foundation, either version 3 of the * +* License, or (at your option) any later version. * +* * +* Holocore 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 Affero General Public License for more details. * +* * +* You should have received a copy of the GNU Affero General Public License * +* along with Holocore. If not, see . * +* * +***********************************************************************************/ +package resources.commands.callbacks; + +import network.packets.swg.zone.object_controller.BiographyUpdate; +import resources.commands.ICmdCallback; +import resources.objects.SWGObject; +import resources.objects.creature.CreatureObject; +import resources.player.Player; +import resources.server_info.Log; +import services.galaxy.GalacticManager; + +/** + * + * @author mads + */ +public class RequestBiographyCmdCallback implements ICmdCallback { + + @Override + public void execute(GalacticManager galacticManager, Player player, SWGObject target, String args) { + CreatureObject creatureObject = player.getCreatureObject(); + if(target != null) { + if(creatureObject.isPlayer()) { + player.sendPacket(new BiographyUpdate(creatureObject.getObjectId(), target.getObjectId(), creatureObject.getPlayerObject().getBiography())); + } else { + Log.w("RequestBiographyCmdCallback", "%s tried to request biography of NPC %s", creatureObject, target); + } + } else { + Log.w("RequestBiographyCmdCallback", "%s tried to request biography of a null object", creatureObject); + } + } + +} \ No newline at end of file diff --git a/src/services/commands/CommandService.java b/src/services/commands/CommandService.java index 46d2c22cd..71adee345 100644 --- a/src/services/commands/CommandService.java +++ b/src/services/commands/CommandService.java @@ -312,6 +312,7 @@ public class CommandService extends Service { registerCallback("qatool", QaToolCmdCallback.class); registerCallback("goto", GotoCmdCallback.class); registerCallback("startDance", StartDanceCallback.class); + registerCallback("requestBiography", RequestBiographyCmdCallback.class); } private void clearCommands() {