mirror of
https://github.com/ProjectSWGCore/NGECore2.git
synced 2026-07-31 01:15:57 -04:00
Merge remote-tracking branch 'origin/Wave_Collections' into Wave_Entertainer
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2013 <Project SWG>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2013 <Project SWG>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* 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<String, ServerFirst> sfList;
|
||||
private String server;
|
||||
|
||||
public CollectionServerFirstListResponse(String server, Map<String, ServerFirst> 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<String, ServerFirst> 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<String, ServerFirst> entry : sfList.entrySet()) {
|
||||
buffer.put(entry.getValue().getBytes());
|
||||
|
||||
}
|
||||
return buffer.flip();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
@@ -142,7 +142,7 @@ public class CollectionService implements INetworkDispatch {
|
||||
int bits = 0;
|
||||
boolean noScriptOnModify = false;
|
||||
boolean clearOnComplete = false;
|
||||
boolean noMessage = true;
|
||||
boolean noMessage = false;
|
||||
boolean grantIfPreReqMet = true;
|
||||
boolean buddyCollection = false;
|
||||
int numAltTitles = 0;
|
||||
@@ -359,7 +359,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");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user