Merged in M4SS/holocore/biographies (pull request #221)

Biographies
This commit is contained in:
Obique PSWG
2016-05-16 14:58:57 -05:00
5 changed files with 149 additions and 0 deletions
+13
View File
@@ -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));
}
@@ -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 <http://www.gnu.org/licenses/>. *
* *
***********************************************************************************/
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;
}
}
@@ -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);
}
@@ -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 <http://www.gnu.org/licenses/>. *
* *
***********************************************************************************/
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);
}
}
}
@@ -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() {