Project cleanup pre merge.
This commit is contained in:
@@ -30,12 +30,23 @@ import java.security.*;
|
||||
|
||||
public class ClientAuthenticator {
|
||||
|
||||
private static final byte P_Bytes[] = {(byte) 0xFB, (byte) 0x46, (byte) 0x56, (byte) 0xB4, (byte) 0xBE, (byte) 0x81, (byte) 0xA4,
|
||||
(byte) 0x2C, (byte) 0x37, (byte) 0xC4, (byte) 0xA2, (byte) 0x61, (byte) 0x4A, (byte) 0xAC, (byte) 0x65, (byte) 0x90,
|
||||
(byte) 0x31, (byte) 0xB6, (byte) 0x83, (byte) 0x26, (byte) 0x63, (byte) 0x94, (byte) 0x08, (byte) 0x95, (byte) 0x56,
|
||||
(byte) 0x8D, (byte) 0x5E, (byte) 0xBF, (byte) 0x94, (byte) 0x10, (byte) 0x5A, (byte) 0x37, (byte) 0xB6, (byte) 0x82,
|
||||
(byte) 0x1A, (byte) 0x75, (byte) 0x2B, (byte) 0xF1, (byte) 0x94, (byte) 0xB7, (byte) 0x7E, (byte) 0x56, (byte) 0xC6,
|
||||
(byte) 0xD1, (byte) 0xF5, (byte) 0x18, (byte) 0xE1, (byte) 0xA5, (byte) 0x13, (byte) 0x9E, (byte) 0xC1, (byte) 0x85,
|
||||
(byte) 0x98, (byte) 0xB7, (byte) 0x32, (byte) 0xDB, (byte) 0x38, (byte) 0x09, (byte) 0x1A, (byte) 0xF8, (byte) 0x5C,
|
||||
(byte) 0xDA, (byte) 0x4F, (byte) 0x9F, (byte) 0x67, (byte) 0x93, (byte) 0x72, (byte) 0x8F, (byte) 0x75, (byte) 0x4F,
|
||||
(byte) 0x0B, (byte) 0xBD, (byte) 0x69, (byte) 0x61, (byte) 0x97, (byte) 0x1F, (byte) 0xEE, (byte) 0xFB, (byte) 0x5B,
|
||||
(byte) 0xB0, (byte) 0x85, (byte) 0xC4, (byte) 0x27, (byte) 0x7E, (byte) 0x41, (byte) 0x42, (byte) 0xC2, (byte) 0xF1,
|
||||
(byte) 0xDA, (byte) 0x64, (byte) 0x8F, (byte) 0x4E, (byte) 0x28, (byte) 0xFD, (byte) 0x2A, (byte) 0x63};
|
||||
private static final BigInteger P = new BigInteger(1, P_Bytes);
|
||||
private static final BigInteger G = BigInteger.valueOf(5);
|
||||
private final AbstractConnection origin;
|
||||
|
||||
private ByteBuffer buffer = ByteBuffer.allocate(100);
|
||||
private byte[] secretKeyBytes = new byte[16];
|
||||
private SecretKeySpec BFKey;
|
||||
|
||||
private Cipher cipher;
|
||||
private byte[] iVecEnc = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
private byte[] iVecDec = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
@@ -75,7 +86,7 @@ public class ClientAuthenticator {
|
||||
private void calcKeys(AbstractConnection origin, byte[] clientPublicKeyBytes) {
|
||||
|
||||
try {
|
||||
// get the forwarded client public key, in byte[] form.
|
||||
// get the forwarded client public key, in byte[] form.
|
||||
|
||||
// Convert client public key to a BigInteger
|
||||
BigInteger clientPublicKeyBI = new BigInteger(1, clientPublicKeyBytes);
|
||||
@@ -128,14 +139,14 @@ public class ClientAuthenticator {
|
||||
try {
|
||||
read = origin.getSocketChannel().read(this.buffer);
|
||||
} catch (IOException e) {
|
||||
if (e.getLocalizedMessage() != null && !e.getLocalizedMessage().equals(MBServerStatics.EXISTING_CONNECTION_CLOSED) && !e.getLocalizedMessage().equals(MBServerStatics.RESET_BY_PEER))
|
||||
Logger.error(e);
|
||||
origin.disconnect();
|
||||
return 0;
|
||||
if (e.getLocalizedMessage() != null && !e.getLocalizedMessage().equals(MBServerStatics.EXISTING_CONNECTION_CLOSED) && !e.getLocalizedMessage().equals(MBServerStatics.RESET_BY_PEER))
|
||||
Logger.error(e);
|
||||
origin.disconnect();
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (read == -1) {
|
||||
Logger.info("EOF on Socket Channel, Disconnecting " + origin.getLocalAddressAndPortAsString());
|
||||
Logger.info("EOF on Socket Channel, Disconnecting " + origin.getLocalAddressAndPortAsString());
|
||||
origin.disconnect();
|
||||
return read;
|
||||
}
|
||||
@@ -143,7 +154,7 @@ public class ClientAuthenticator {
|
||||
this.totalRead += read;
|
||||
|
||||
if (this.totalRead > 100)
|
||||
Logger.error( "Possible Spam warning: "
|
||||
Logger.error("Possible Spam warning: "
|
||||
+ origin.getSocketChannel().socket().toString());
|
||||
|
||||
// Not all arrived yet, so wait for more
|
||||
@@ -168,7 +179,7 @@ public class ClientAuthenticator {
|
||||
// Calculate Blowfish Secret Key and make ciphers streams.
|
||||
this.BFKey = new SecretKeySpec(this.secretKeyBytes, "Blowfish");
|
||||
|
||||
// Initialize cipher and Ivecs.
|
||||
// Initialize cipher and Ivecs.
|
||||
// Ivecs must be run through the cipher once
|
||||
// to prep the cipher for cfb mode.
|
||||
this.cipher = Cipher.getInstance("Blowfish/ECB/NoPadding");
|
||||
@@ -217,7 +228,7 @@ public class ClientAuthenticator {
|
||||
//Line up the iVecEncOffset.. fall through is intentional
|
||||
if (iVecEncOffset != 0)
|
||||
if ((this.iVecEncOffset + dataIn.limit()) < 8) {
|
||||
//This handles cases where the net msg + offset won't reach 8 bytes total
|
||||
//This handles cases where the net msg + offset won't reach 8 bytes total
|
||||
//prevents BufferUnderflowException in small net messages. -
|
||||
int newEncOffset = this.iVecEncOffset + dataIn.limit();
|
||||
for (int i = this.iVecEncOffset; i < newEncOffset; i++) {
|
||||
@@ -337,8 +348,8 @@ public class ClientAuthenticator {
|
||||
this.iVecDecOffset = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Logger.error("ClientAuth.decrypt()" + e);
|
||||
@@ -363,19 +374,4 @@ public class ClientAuthenticator {
|
||||
return initialized;
|
||||
}
|
||||
|
||||
private static final byte P_Bytes[] = {(byte) 0xFB, (byte) 0x46, (byte) 0x56, (byte) 0xB4, (byte) 0xBE, (byte) 0x81, (byte) 0xA4,
|
||||
(byte) 0x2C, (byte) 0x37, (byte) 0xC4, (byte) 0xA2, (byte) 0x61, (byte) 0x4A, (byte) 0xAC, (byte) 0x65, (byte) 0x90,
|
||||
(byte) 0x31, (byte) 0xB6, (byte) 0x83, (byte) 0x26, (byte) 0x63, (byte) 0x94, (byte) 0x08, (byte) 0x95, (byte) 0x56,
|
||||
(byte) 0x8D, (byte) 0x5E, (byte) 0xBF, (byte) 0x94, (byte) 0x10, (byte) 0x5A, (byte) 0x37, (byte) 0xB6, (byte) 0x82,
|
||||
(byte) 0x1A, (byte) 0x75, (byte) 0x2B, (byte) 0xF1, (byte) 0x94, (byte) 0xB7, (byte) 0x7E, (byte) 0x56, (byte) 0xC6,
|
||||
(byte) 0xD1, (byte) 0xF5, (byte) 0x18, (byte) 0xE1, (byte) 0xA5, (byte) 0x13, (byte) 0x9E, (byte) 0xC1, (byte) 0x85,
|
||||
(byte) 0x98, (byte) 0xB7, (byte) 0x32, (byte) 0xDB, (byte) 0x38, (byte) 0x09, (byte) 0x1A, (byte) 0xF8, (byte) 0x5C,
|
||||
(byte) 0xDA, (byte) 0x4F, (byte) 0x9F, (byte) 0x67, (byte) 0x93, (byte) 0x72, (byte) 0x8F, (byte) 0x75, (byte) 0x4F,
|
||||
(byte) 0x0B, (byte) 0xBD, (byte) 0x69, (byte) 0x61, (byte) 0x97, (byte) 0x1F, (byte) 0xEE, (byte) 0xFB, (byte) 0x5B,
|
||||
(byte) 0xB0, (byte) 0x85, (byte) 0xC4, (byte) 0x27, (byte) 0x7E, (byte) 0x41, (byte) 0x42, (byte) 0xC2, (byte) 0xF1,
|
||||
(byte) 0xDA, (byte) 0x64, (byte) 0x8F, (byte) 0x4E, (byte) 0x28, (byte) 0xFD, (byte) 0x2A, (byte) 0x63};
|
||||
|
||||
private static final BigInteger P = new BigInteger(1, P_Bytes);
|
||||
private static final BigInteger G = BigInteger.valueOf(5);
|
||||
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
// www.magicbane.com
|
||||
|
||||
|
||||
|
||||
package engine.net.client;
|
||||
|
||||
import engine.Enum;
|
||||
@@ -35,320 +34,317 @@ import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
public class ClientConnection extends AbstractConnection {
|
||||
|
||||
// Enumeration of a message's origin for logging purposes
|
||||
private enum MessageSource {
|
||||
private final ClientAuthenticator crypto;
|
||||
private final String clientIpAddress;
|
||||
public String machineID;
|
||||
public long guildtreespam = 0;
|
||||
public long ordernpcspam = 0;
|
||||
public ReentrantLock trainLock = new ReentrantLock();
|
||||
public ReentrantLock sellLock = new ReentrantLock();
|
||||
public ReentrantLock buyLock = new ReentrantLock();
|
||||
public boolean desyncDebug = false;
|
||||
public byte[] lastByteBuffer;
|
||||
protected SessionID sessionID = null;
|
||||
private byte cryptoInitTries = 0;
|
||||
|
||||
SOURCE_CLIENT,
|
||||
SOURCE_SERVER
|
||||
}
|
||||
public ClientConnection(ClientConnectionManager connMan,
|
||||
SocketChannel sockChan) {
|
||||
super(connMan, sockChan, true);
|
||||
this.crypto = new ClientAuthenticator(this);
|
||||
|
||||
private byte cryptoInitTries = 0;
|
||||
protected SessionID sessionID = null;
|
||||
private final ClientAuthenticator crypto;
|
||||
private final String clientIpAddress;
|
||||
public String machineID;
|
||||
public long guildtreespam = 0;
|
||||
public long ordernpcspam = 0;
|
||||
public ReentrantLock trainLock = new ReentrantLock();
|
||||
public ReentrantLock sellLock = new ReentrantLock();
|
||||
public ReentrantLock buyLock = new ReentrantLock();
|
||||
this.clientIpAddress = sockChan.socket().getRemoteSocketAddress()
|
||||
.toString().replace("/", "").split(":")[0];
|
||||
}
|
||||
|
||||
public boolean desyncDebug = false;
|
||||
|
||||
public byte[] lastByteBuffer;
|
||||
@Override
|
||||
protected boolean _sendMsg(AbstractNetMsg msg) {
|
||||
try {
|
||||
msg.setOrigin(this);
|
||||
ByteBuffer bb = msg.serialize();
|
||||
|
||||
public ClientConnection(ClientConnectionManager connMan,
|
||||
SocketChannel sockChan) {
|
||||
super(connMan, sockChan, true);
|
||||
this.crypto = new ClientAuthenticator(this);
|
||||
// Application protocol logging toggled via
|
||||
// DevCmd: netdebug on|off
|
||||
|
||||
this.clientIpAddress = sockChan.socket().getRemoteSocketAddress()
|
||||
.toString().replace("/", "").split(":")[0];
|
||||
}
|
||||
if (MBServerStatics.DEBUG_PROTOCOL)
|
||||
applicationProtocolLogger(msg, MessageSource.SOURCE_SERVER);
|
||||
|
||||
@Override
|
||||
protected boolean _sendMsg(AbstractNetMsg msg) {
|
||||
try {
|
||||
msg.setOrigin(this);
|
||||
ByteBuffer bb = msg.serialize();
|
||||
boolean retval = this.sendBB(bb);
|
||||
Network.byteBufferPool.putBuffer(bb);//return here.
|
||||
|
||||
// Application protocol logging toggled via
|
||||
// DevCmd: netdebug on|off
|
||||
return retval;
|
||||
|
||||
if (MBServerStatics.DEBUG_PROTOCOL)
|
||||
applicationProtocolLogger(msg, MessageSource.SOURCE_SERVER);
|
||||
} catch (Exception e) { // Catch-all
|
||||
Logger.error(e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
boolean retval = this.sendBB(bb);
|
||||
Network.byteBufferPool.putBuffer(bb);//return here.
|
||||
/**
|
||||
* Sending a NetMsg to the client involves NOT including a dataLen parameter
|
||||
* and also involves encrypting the data.
|
||||
*/
|
||||
@Override
|
||||
protected boolean _sendBB(ByteBuffer bb) {
|
||||
boolean useCrypto = this.crypto.initialized();
|
||||
boolean retVal;
|
||||
|
||||
return retval;
|
||||
// Logger.debug("useCrypto: " + useCrypto + ". bb.cap(): " +
|
||||
// bb.capacity());
|
||||
if (useCrypto == false)
|
||||
retVal = super._sendBB(bb);
|
||||
else {
|
||||
if (bb == null)
|
||||
Logger.error("Incoming bb is null");
|
||||
ByteBuffer encrypted = Network.byteBufferPool.getBufferToFit(bb.capacity());
|
||||
if (encrypted == null)
|
||||
Logger.error("Encrypted bb is null");
|
||||
this.crypto.encrypt(bb, encrypted);
|
||||
retVal = super._sendBB(encrypted);
|
||||
}
|
||||
|
||||
} catch (Exception e) { // Catch-all
|
||||
Logger.error(e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sending a NetMsg to the client involves NOT including a dataLen parameter
|
||||
* and also involves encrypting the data.
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
protected boolean _sendBB(ByteBuffer bb) {
|
||||
boolean useCrypto = this.crypto.initialized();
|
||||
boolean retVal;
|
||||
/**
|
||||
* Receiving data from a client involves the initial Crypto Key Exchange,
|
||||
* waiting for a complete NetMsg to arrive using an accumulation factory and
|
||||
* decrypting the data.
|
||||
*/
|
||||
//FIXME the int return value on this means nothing! Clean it up!
|
||||
@Override
|
||||
protected int read() {
|
||||
|
||||
// Logger.debug("useCrypto: " + useCrypto + ". bb.cap(): " +
|
||||
// bb.capacity());
|
||||
if (useCrypto == false)
|
||||
retVal = super._sendBB(bb);
|
||||
else {
|
||||
if (bb == null)
|
||||
Logger.error("Incoming bb is null");
|
||||
ByteBuffer encrypted = Network.byteBufferPool.getBufferToFit(bb.capacity());
|
||||
if (encrypted == null)
|
||||
Logger.error("Encrypted bb is null");
|
||||
this.crypto.encrypt(bb, encrypted);
|
||||
retVal = super._sendBB(encrypted);
|
||||
}
|
||||
if (readLock.tryLock())
|
||||
try {
|
||||
|
||||
return retVal;
|
||||
}
|
||||
// First and foremost, check to see if we the Crypto is initted yet
|
||||
if (!this.crypto.initialized())
|
||||
this.crypto.initialize(this);
|
||||
|
||||
/**
|
||||
* Receiving data from a client involves the initial Crypto Key Exchange,
|
||||
* waiting for a complete NetMsg to arrive using an accumulation factory and
|
||||
* decrypting the data.
|
||||
*/
|
||||
//FIXME the int return value on this means nothing! Clean it up!
|
||||
@Override
|
||||
protected int read() {
|
||||
if (!this.crypto.initialized()) {
|
||||
++this.cryptoInitTries;
|
||||
if (this.cryptoInitTries >= MBServerStatics.MAX_CRYPTO_INIT_TRIES) {
|
||||
Logger.info("Failed to initialize after "
|
||||
+ MBServerStatics.MAX_CRYPTO_INIT_TRIES
|
||||
+ " tries. Disconnecting.");
|
||||
this.disconnect();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (readLock.tryLock())
|
||||
try {
|
||||
// check to see if SessionID == null;
|
||||
if (this.sessionID == null)
|
||||
this.sessionID = new SessionID(this.crypto.getSecretKeyBytes());
|
||||
|
||||
// First and foremost, check to see if we the Crypto is initted yet
|
||||
if (!this.crypto.initialized())
|
||||
this.crypto.initialize(this);
|
||||
// Get ByteBuffers out of pool.
|
||||
ByteBuffer bb = Network.byteBufferPool.getBuffer(16);
|
||||
ByteBuffer decrypted = Network.byteBufferPool.getBuffer(16);
|
||||
// ByteBuffer bb = ByteBuffer.allocate(1024 * 4);
|
||||
|
||||
if (!this.crypto.initialized()) {
|
||||
++this.cryptoInitTries;
|
||||
if (this.cryptoInitTries >= MBServerStatics.MAX_CRYPTO_INIT_TRIES) {
|
||||
Logger.info("Failed to initialize after "
|
||||
+ MBServerStatics.MAX_CRYPTO_INIT_TRIES
|
||||
+ " tries. Disconnecting.");
|
||||
this.disconnect();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
int totalBytesRead = 0;
|
||||
int lastRead = 0;
|
||||
do {
|
||||
try {
|
||||
bb.clear();
|
||||
decrypted.clear();
|
||||
lastRead = this.sockChan.read(bb);
|
||||
// On EOF on the SocketChannel, disconnect.
|
||||
if (lastRead <= -1) {
|
||||
this.disconnect();
|
||||
break;
|
||||
}
|
||||
|
||||
// check to see if SessionID == null;
|
||||
if (this.sessionID == null)
|
||||
this.sessionID = new SessionID(this.crypto.getSecretKeyBytes());
|
||||
if (lastRead == 0)
|
||||
continue;
|
||||
|
||||
// Get ByteBuffers out of pool.
|
||||
ByteBuffer bb = Network.byteBufferPool.getBuffer(16);
|
||||
ByteBuffer decrypted = Network.byteBufferPool.getBuffer(16);
|
||||
// ByteBuffer bb = ByteBuffer.allocate(1024 * 4);
|
||||
// ByteBuffer decrypted = ByteBuffer.allocate(lastRead);
|
||||
this.crypto.decrypt(bb, decrypted);
|
||||
this.factory.addData(decrypted);
|
||||
|
||||
int totalBytesRead = 0;
|
||||
int lastRead = 0;
|
||||
do {
|
||||
try {
|
||||
bb.clear();
|
||||
decrypted.clear();
|
||||
lastRead = this.sockChan.read(bb);
|
||||
// On EOF on the SocketChannel, disconnect.
|
||||
if (lastRead <= -1) {
|
||||
this.disconnect();
|
||||
break;
|
||||
}
|
||||
|
||||
if (lastRead == 0)
|
||||
continue;
|
||||
this.checkInternalFactory();
|
||||
|
||||
// ByteBuffer decrypted = ByteBuffer.allocate(lastRead);
|
||||
this.crypto.decrypt(bb, decrypted);
|
||||
this.factory.addData(decrypted);
|
||||
|
||||
|
||||
this.checkInternalFactory();
|
||||
totalBytesRead += lastRead;
|
||||
|
||||
totalBytesRead += lastRead;
|
||||
|
||||
|
||||
} catch (NotYetConnectedException e) {
|
||||
Logger.error(e.getLocalizedMessage());
|
||||
totalBytesRead = -1; // Set error retVal
|
||||
break;
|
||||
} catch (NotYetConnectedException e) {
|
||||
Logger.error(e.getLocalizedMessage());
|
||||
totalBytesRead = -1; // Set error retVal
|
||||
break;
|
||||
|
||||
} catch (ClosedChannelException e) {
|
||||
// TODO Should a closed channel be logged or just cleaned up?
|
||||
// this.logEXCEPTION(e);
|
||||
this.disconnect();
|
||||
totalBytesRead = -1; // Set error retVal
|
||||
break;
|
||||
} catch (ClosedChannelException e) {
|
||||
// TODO Should a closed channel be logged or just cleaned up?
|
||||
// this.logEXCEPTION(e);
|
||||
this.disconnect();
|
||||
totalBytesRead = -1; // Set error retVal
|
||||
break;
|
||||
|
||||
} catch (IOException e) {
|
||||
if ( e.getLocalizedMessage() != null && (!e.getLocalizedMessage().equals(MBServerStatics.EXISTING_CONNECTION_CLOSED) && !e.getLocalizedMessage().equals(MBServerStatics.RESET_BY_PEER))){
|
||||
Logger.info("Error Reading message opcode " + this.lastOpcode);
|
||||
Logger.error(e);
|
||||
}
|
||||
this.disconnect();
|
||||
totalBytesRead = -1; // Set error retVal
|
||||
break;
|
||||
} catch (IOException e) {
|
||||
if (e.getLocalizedMessage() != null && (!e.getLocalizedMessage().equals(MBServerStatics.EXISTING_CONNECTION_CLOSED) && !e.getLocalizedMessage().equals(MBServerStatics.RESET_BY_PEER))) {
|
||||
Logger.info("Error Reading message opcode " + this.lastOpcode);
|
||||
Logger.error(e);
|
||||
}
|
||||
this.disconnect();
|
||||
totalBytesRead = -1; // Set error retVal
|
||||
break;
|
||||
|
||||
} catch (Exception e){
|
||||
Logger.info("Error Reading message opcode " + this.lastOpcode);
|
||||
Logger.error(e);
|
||||
totalBytesRead = -1; // Set error retVal
|
||||
this.disconnect();
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Logger.info("Error Reading message opcode " + this.lastOpcode);
|
||||
Logger.error(e);
|
||||
totalBytesRead = -1; // Set error retVal
|
||||
this.disconnect();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
while (lastRead > 0);
|
||||
while (lastRead > 0);
|
||||
|
||||
Network.byteBufferPool.putBuffer(bb);
|
||||
Network.byteBufferPool.putBuffer(decrypted);
|
||||
Network.byteBufferPool.putBuffer(bb);
|
||||
Network.byteBufferPool.putBuffer(decrypted);
|
||||
|
||||
return totalBytesRead;
|
||||
return totalBytesRead;
|
||||
|
||||
} finally {
|
||||
readLock.unlock();
|
||||
}
|
||||
else {
|
||||
Logger.debug("Another thread already has a read lock! Skipping.");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
readLock.unlock();
|
||||
}
|
||||
else {
|
||||
Logger.debug("Another thread already has a read lock! Skipping.");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disconnect() {
|
||||
super.disconnect();
|
||||
try {
|
||||
@Override
|
||||
public void disconnect() {
|
||||
super.disconnect();
|
||||
try {
|
||||
|
||||
if (ConfigManager.serverType.equals(Enum.ServerType.WORLDSERVER))
|
||||
ConfigManager.worldServer.removeClient(this);
|
||||
else
|
||||
ConfigManager.loginServer.removeClient(this);
|
||||
if (ConfigManager.serverType.equals(Enum.ServerType.WORLDSERVER))
|
||||
ConfigManager.worldServer.removeClient(this);
|
||||
else
|
||||
ConfigManager.loginServer.removeClient(this);
|
||||
|
||||
// TODO There has to be a more direct way to do this...
|
||||
SessionManager.remSession(
|
||||
SessionManager.getSession(sessionID));
|
||||
} catch (NullPointerException e) {
|
||||
Logger
|
||||
.error(
|
||||
"Tried to remove improperly initialized session. Skipping." +
|
||||
e);
|
||||
}
|
||||
}
|
||||
|
||||
public void forceDisconnect() {
|
||||
super.disconnect();
|
||||
}
|
||||
// TODO There has to be a more direct way to do this...
|
||||
SessionManager.remSession(
|
||||
SessionManager.getSession(sessionID));
|
||||
} catch (NullPointerException e) {
|
||||
Logger
|
||||
.error(
|
||||
"Tried to remove improperly initialized session. Skipping." +
|
||||
e);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Getters n setters
|
||||
*/
|
||||
public void forceDisconnect() {
|
||||
super.disconnect();
|
||||
}
|
||||
|
||||
public SessionID getSessionID() {
|
||||
return sessionID;
|
||||
}
|
||||
public SessionID getSessionID() {
|
||||
return sessionID;
|
||||
}
|
||||
|
||||
public byte[] getSecretKeyBytes() {
|
||||
return this.crypto.getSecretKeyBytes();
|
||||
}
|
||||
/*
|
||||
* Getters n setters
|
||||
*/
|
||||
|
||||
/*
|
||||
* Convenience getters for SessionManager
|
||||
*/
|
||||
public Account getAccount() {
|
||||
return SessionManager.getAccount(this);
|
||||
}
|
||||
public byte[] getSecretKeyBytes() {
|
||||
return this.crypto.getSecretKeyBytes();
|
||||
}
|
||||
|
||||
public PlayerCharacter getPlayerCharacter() {
|
||||
return SessionManager.getPlayerCharacter(this);
|
||||
}
|
||||
/*
|
||||
* Convenience getters for SessionManager
|
||||
*/
|
||||
public Account getAccount() {
|
||||
return SessionManager.getAccount(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleClientMsg(ClientNetMsg msg) {
|
||||
public PlayerCharacter getPlayerCharacter() {
|
||||
return SessionManager.getPlayerCharacter(this);
|
||||
}
|
||||
|
||||
Protocol protocolMsg = msg.getProtocolMsg();
|
||||
@Override
|
||||
public boolean handleClientMsg(ClientNetMsg msg) {
|
||||
|
||||
switch (protocolMsg) {
|
||||
case KEEPALIVESERVERCLIENT:
|
||||
this.setLastKeepAliveTime();
|
||||
break;
|
||||
// case ClientOpcodes.OpenVault:
|
||||
// case ClientOpcodes.Random:
|
||||
// case ClientOpcodes.DoorTryOpen:
|
||||
// case ClientOpcodes.SetSelectedObect:
|
||||
// case ClientOpcodes.MoveObjectToContainer:
|
||||
// case ClientOpcodes.ToggleSitStand:
|
||||
// case ClientOpcodes.SocialChannel:
|
||||
// case ClientOpcodes.OpenFriendsCondemnList:
|
||||
case SELLOBJECT:
|
||||
this.setLastMsgTime();
|
||||
break;
|
||||
case MOVETOPOINT:
|
||||
case ARCCOMBATMODEATTACKING:
|
||||
this.setLastMsgTime();
|
||||
break;
|
||||
default:
|
||||
this.setLastMsgTime();
|
||||
break;
|
||||
}
|
||||
Protocol protocolMsg = msg.getProtocolMsg();
|
||||
|
||||
// Application protocol logging toggled via
|
||||
// DevCmd: netdebug on|off
|
||||
switch (protocolMsg) {
|
||||
case KEEPALIVESERVERCLIENT:
|
||||
this.setLastKeepAliveTime();
|
||||
break;
|
||||
// case ClientOpcodes.OpenVault:
|
||||
// case ClientOpcodes.Random:
|
||||
// case ClientOpcodes.DoorTryOpen:
|
||||
// case ClientOpcodes.SetSelectedObect:
|
||||
// case ClientOpcodes.MoveObjectToContainer:
|
||||
// case ClientOpcodes.ToggleSitStand:
|
||||
// case ClientOpcodes.SocialChannel:
|
||||
// case ClientOpcodes.OpenFriendsCondemnList:
|
||||
case SELLOBJECT:
|
||||
this.setLastMsgTime();
|
||||
break;
|
||||
case MOVETOPOINT:
|
||||
case ARCCOMBATMODEATTACKING:
|
||||
this.setLastMsgTime();
|
||||
break;
|
||||
default:
|
||||
this.setLastMsgTime();
|
||||
break;
|
||||
}
|
||||
|
||||
if (MBServerStatics.DEBUG_PROTOCOL)
|
||||
applicationProtocolLogger(msg, MessageSource.SOURCE_CLIENT);
|
||||
// Application protocol logging toggled via
|
||||
// DevCmd: netdebug on|off
|
||||
|
||||
return ConfigManager.handler.handleClientMsg(msg); // *** Refactor : Null check then call
|
||||
}
|
||||
// Method logs detailed information about application
|
||||
// protocol traffic. Toggled at runtime via the
|
||||
// DevCmd netdebug on|off
|
||||
if (MBServerStatics.DEBUG_PROTOCOL)
|
||||
applicationProtocolLogger(msg, MessageSource.SOURCE_CLIENT);
|
||||
|
||||
private void applicationProtocolLogger(AbstractNetMsg msg, MessageSource origin) {
|
||||
return ConfigManager.handler.handleClientMsg(msg); // *** Refactor : Null check then call
|
||||
}
|
||||
|
||||
String outString = "";
|
||||
PlayerCharacter tempPlayer = null;
|
||||
private void applicationProtocolLogger(AbstractNetMsg msg, MessageSource origin) {
|
||||
|
||||
// Log the protocolMsg
|
||||
if (origin == MessageSource.SOURCE_CLIENT)
|
||||
outString = " Incoming protocolMsg: ";
|
||||
else
|
||||
outString = " Outgoing protocolMsg: ";
|
||||
String outString = "";
|
||||
PlayerCharacter tempPlayer = null;
|
||||
|
||||
Logger.info(outString
|
||||
+ Integer.toHexString(msg.getProtocolMsg().opcode)
|
||||
+ '/' + msg.getProtocolMsg());
|
||||
// Log the protocolMsg
|
||||
if (origin == MessageSource.SOURCE_CLIENT)
|
||||
outString = " Incoming protocolMsg: ";
|
||||
else
|
||||
outString = " Outgoing protocolMsg: ";
|
||||
|
||||
// Dump message contents using reflection
|
||||
tempPlayer = this.getPlayerCharacter();
|
||||
outString = "";
|
||||
outString += (tempPlayer == null) ? "PlayerUnknown" : tempPlayer.getFirstName() + ' '
|
||||
+ msg.toString();
|
||||
Logger.info(outString);
|
||||
}
|
||||
Logger.info(outString
|
||||
+ Integer.toHexString(msg.getProtocolMsg().opcode)
|
||||
+ '/' + msg.getProtocolMsg());
|
||||
|
||||
public void kickToLogin(int errCode, String message) {
|
||||
// Dump message contents using reflection
|
||||
tempPlayer = this.getPlayerCharacter();
|
||||
outString = "";
|
||||
outString += (tempPlayer == null) ? "PlayerUnknown" : tempPlayer.getFirstName() + ' '
|
||||
+ msg.toString();
|
||||
Logger.info(outString);
|
||||
}
|
||||
// Method logs detailed information about application
|
||||
// protocol traffic. Toggled at runtime via the
|
||||
// DevCmd netdebug on|off
|
||||
|
||||
LoginErrorMsg lom = new LoginErrorMsg(errCode, message);
|
||||
public void kickToLogin(int errCode, String message) {
|
||||
|
||||
if (!sendMsg(lom))
|
||||
Logger.error("Failed to send message"); // TODO Do we just accept this failure to send Msg?
|
||||
LoginErrorMsg lom = new LoginErrorMsg(errCode, message);
|
||||
|
||||
DisconnectJob dj = new DisconnectJob(this);
|
||||
JobScheduler.getInstance().scheduleJob(dj, 250);
|
||||
if (!sendMsg(lom))
|
||||
Logger.error("Failed to send message"); // TODO Do we just accept this failure to send Msg?
|
||||
|
||||
}
|
||||
DisconnectJob dj = new DisconnectJob(this);
|
||||
JobScheduler.getInstance().scheduleJob(dj, 250);
|
||||
|
||||
public final String getClientIpAddress() {
|
||||
return this.clientIpAddress;
|
||||
}
|
||||
}
|
||||
|
||||
public final String getClientIpAddress() {
|
||||
return this.clientIpAddress;
|
||||
}
|
||||
|
||||
// Enumeration of a message's origin for logging purposes
|
||||
private enum MessageSource {
|
||||
|
||||
SOURCE_CLIENT,
|
||||
SOURCE_SERVER
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -252,9 +252,10 @@ public enum Protocol {
|
||||
UNKNOWN1(-263523523, Unknown1Msg.class, null),
|
||||
DROPGOLD(1461654160, DropGoldMsg.class, null);
|
||||
|
||||
public int opcode;
|
||||
private static final HashMap<Integer, Protocol> _protocolMsgByOpcode = new HashMap<>();
|
||||
private final Class message;
|
||||
private final Class handlerClass;
|
||||
public int opcode;
|
||||
public Constructor constructor;
|
||||
public AbstractClientMsgHandler handler;
|
||||
|
||||
@@ -286,8 +287,6 @@ public enum Protocol {
|
||||
}
|
||||
}
|
||||
|
||||
private static final HashMap<Integer, Protocol> _protocolMsgByOpcode = new HashMap<>();
|
||||
|
||||
public static Protocol getByOpcode(int opcode) {
|
||||
|
||||
Protocol protocol = _protocolMsgByOpcode.get(opcode);
|
||||
|
||||
@@ -19,204 +19,199 @@ import org.pmw.tinylog.Logger;
|
||||
*/
|
||||
public class AbandonAssetMsgHandler extends AbstractClientMsgHandler {
|
||||
|
||||
// Instance variables
|
||||
// Instance variables
|
||||
|
||||
public AbandonAssetMsgHandler() {
|
||||
super(AbandonAssetMsg.class);
|
||||
public AbandonAssetMsgHandler() {
|
||||
super(AbandonAssetMsg.class);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
|
||||
// Member variable declaration
|
||||
PlayerCharacter player;
|
||||
Building building;
|
||||
AbandonAssetMsg msg;
|
||||
|
||||
// Member variable assignment
|
||||
msg = (AbandonAssetMsg) baseMsg;
|
||||
|
||||
player = origin.getPlayerCharacter();
|
||||
building = BuildingManager.getBuildingFromCache(msg.getUUID());
|
||||
|
||||
// Oops! *** Refactor: Log error
|
||||
if ((player == null) || (building == null))
|
||||
return true;
|
||||
|
||||
// Early exit if object is not owned by the player
|
||||
if (building.getOwnerUUID() != player.getObjectUUID())
|
||||
return true;
|
||||
|
||||
// Cannot abandon a building without a blueprint.
|
||||
// Players do not own rocks or shrubbery.
|
||||
if (building.getBlueprintUUID() == 0)
|
||||
return true;
|
||||
|
||||
// Players cannot abandon shrines
|
||||
|
||||
if ((building.getBlueprint().getBuildingGroup() == BuildingGroup.SHRINE)) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Cannot for to abandon shrine!");
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((building.getBlueprint().getBuildingGroup() == BuildingGroup.MINE)) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Cannot abandon mine!");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Blueprint.isMeshWallPiece(building.getBlueprintUUID())) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Cannot for to abandon fortress asset!");
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((building.getBlueprint().getBuildingGroup() == BuildingGroup.BARRACK)) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Cannot for to abandon fortress asset!");
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((building.getBlueprint().getBuildingGroup() == BuildingGroup.BULWARK)) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Cannot for to abandon siege asset!");
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((building.getBlueprint().getBuildingGroup() == BuildingGroup.SIEGETENT)) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Cannot for to abandon siege asset!");
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((building.getBlueprint().getBuildingGroup() == BuildingGroup.BANESTONE)) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Cannot for to abandon banestone!");
|
||||
return true;
|
||||
}
|
||||
|
||||
// Trees require special handling beyond an individual building
|
||||
if ((building.getBlueprint().getBuildingGroup() == BuildingGroup.TOL))
|
||||
{
|
||||
// CHECK IF GUILD HAS A BANE DROPPED
|
||||
City city = ZoneManager.getCityAtLocation(building.getLoc());
|
||||
if(city.getGuild().getSubGuildList().isEmpty() == false)
|
||||
{
|
||||
//nations cant abandon their tree
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Nations Cannot Abandon Their Capital!");
|
||||
return true;
|
||||
}
|
||||
if(Bane.getBaneByAttackerGuild(city.getGuild()) != null)
|
||||
{
|
||||
ErrorPopupMsg.sendErrorMsg(player, "You Cannot Abandon Your Tree With An Active Siege!");
|
||||
return true;
|
||||
}
|
||||
|
||||
AbandonAllCityObjects(player, building);
|
||||
}
|
||||
else
|
||||
AbandonSingleAsset(player, building);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void AbandonSingleAsset(PlayerCharacter sourcePlayer,
|
||||
private static void AbandonSingleAsset(PlayerCharacter sourcePlayer,
|
||||
Building targetBuilding) {
|
||||
|
||||
// Transfer the building asset ownership and refresh all clients
|
||||
// Transfer the building asset ownership and refresh all clients
|
||||
|
||||
DbManager.BuildingQueries.CLEAR_FRIENDS_LIST(targetBuilding.getObjectUUID());
|
||||
targetBuilding.getFriends().clear();
|
||||
DbManager.BuildingQueries.CLEAR_FRIENDS_LIST(targetBuilding.getObjectUUID());
|
||||
targetBuilding.getFriends().clear();
|
||||
|
||||
// Clear protection status but only if a seige building
|
||||
// Clear protection status but only if a seige building
|
||||
|
||||
if (targetBuilding.getBlueprint().getBuildingGroup().equals(BuildingGroup.BULWARK) ||
|
||||
targetBuilding.getBlueprint().getBuildingGroup().equals(BuildingGroup.SIEGETENT))
|
||||
targetBuilding.setProtectionState(Enum.ProtectionState.NONE);
|
||||
targetBuilding.getBlueprint().getBuildingGroup().equals(BuildingGroup.SIEGETENT))
|
||||
targetBuilding.setProtectionState(Enum.ProtectionState.NONE);
|
||||
|
||||
DbManager.BuildingQueries.CLEAR_CONDEMNED_LIST(targetBuilding.getObjectUUID());
|
||||
targetBuilding.getCondemned().clear();
|
||||
targetBuilding.setOwner(null);
|
||||
targetBuilding.refreshGuild();
|
||||
DbManager.BuildingQueries.CLEAR_CONDEMNED_LIST(targetBuilding.getObjectUUID());
|
||||
targetBuilding.getCondemned().clear();
|
||||
targetBuilding.setOwner(null);
|
||||
targetBuilding.refreshGuild();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void AbandonAllCityObjects(PlayerCharacter sourcePlayer,
|
||||
Building targetBuilding) {
|
||||
Guild sourceGuild;
|
||||
Zone cityZone;
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
|
||||
sourceGuild = sourcePlayer.getGuild();
|
||||
// Member variable declaration
|
||||
PlayerCharacter player;
|
||||
Building building;
|
||||
AbandonAssetMsg msg;
|
||||
|
||||
if (sourceGuild == null)
|
||||
return;
|
||||
// Member variable assignment
|
||||
msg = (AbandonAssetMsg) baseMsg;
|
||||
|
||||
if (sourceGuild.getSubGuildList().size() > 0) {
|
||||
ChatManager.chatCityError(sourcePlayer, "You Cannot abandon a nation city.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
player = origin.getPlayerCharacter();
|
||||
building = BuildingManager.getBuildingFromCache(msg.getUUID());
|
||||
|
||||
cityZone = ZoneManager.findSmallestZone(targetBuilding.getLoc());
|
||||
// Oops! *** Refactor: Log error
|
||||
if ((player == null) || (building == null))
|
||||
return true;
|
||||
|
||||
// Can't abandon a tree not within a player city zone
|
||||
if (cityZone.isPlayerCity() == false)
|
||||
return;
|
||||
|
||||
if (targetBuilding.getCity() == null)
|
||||
return;
|
||||
|
||||
if (targetBuilding.getCity().getBane() != null){
|
||||
ErrorPopupMsg.sendErrorMsg(sourcePlayer, "Can't abandon Tree while a bane exists.");
|
||||
return;
|
||||
}
|
||||
// Early exit if object is not owned by the player
|
||||
if (building.getOwnerUUID() != player.getObjectUUID())
|
||||
return true;
|
||||
|
||||
if (targetBuilding.getCity().hasBeenTransfered == true) {
|
||||
ChatManager.chatCityError(sourcePlayer, "City can only be abandoned once per rebooting.");
|
||||
return;
|
||||
}
|
||||
// Cannot abandon a building without a blueprint.
|
||||
// Players do not own rocks or shrubbery.
|
||||
if (building.getBlueprintUUID() == 0)
|
||||
return true;
|
||||
|
||||
// Guild no longer owns his tree.
|
||||
if (!DbManager.GuildQueries.SET_GUILD_OWNED_CITY(sourceGuild.getObjectUUID(), 0)) {
|
||||
Logger.error("Failed to update Owned City to Database");
|
||||
return;
|
||||
}
|
||||
// Players cannot abandon shrines
|
||||
|
||||
sourceGuild.setCityUUID(0);
|
||||
sourceGuild.setGuildState(GuildState.Errant);
|
||||
sourceGuild.setNation(null);
|
||||
if ((building.getBlueprint().getBuildingGroup() == BuildingGroup.SHRINE)) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Cannot for to abandon shrine!");
|
||||
return true;
|
||||
}
|
||||
|
||||
// Transfer the city assets
|
||||
TransferCityAssets(sourcePlayer, targetBuilding);
|
||||
if ((building.getBlueprint().getBuildingGroup() == BuildingGroup.MINE)) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Cannot abandon mine!");
|
||||
return true;
|
||||
}
|
||||
|
||||
GuildManager.updateAllGuildTags(sourceGuild);
|
||||
GuildManager.updateAllGuildBinds(sourceGuild, null);
|
||||
if (Blueprint.isMeshWallPiece(building.getBlueprintUUID())) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Cannot for to abandon fortress asset!");
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
if ((building.getBlueprint().getBuildingGroup() == BuildingGroup.BARRACK)) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Cannot for to abandon fortress asset!");
|
||||
return true;
|
||||
}
|
||||
|
||||
private void TransferCityAssets(PlayerCharacter sourcePlayer,
|
||||
Building cityTOL) {
|
||||
if ((building.getBlueprint().getBuildingGroup() == BuildingGroup.BULWARK)) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Cannot for to abandon siege asset!");
|
||||
return true;
|
||||
}
|
||||
|
||||
Zone cityZone;
|
||||
if ((building.getBlueprint().getBuildingGroup() == BuildingGroup.SIEGETENT)) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Cannot for to abandon siege asset!");
|
||||
return true;
|
||||
}
|
||||
|
||||
// Build list of buildings within this parent zone
|
||||
cityZone = ZoneManager.findSmallestZone(cityTOL.getLoc());
|
||||
if ((building.getBlueprint().getBuildingGroup() == BuildingGroup.BANESTONE)) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Cannot for to abandon banestone!");
|
||||
return true;
|
||||
}
|
||||
|
||||
for (Building cityBuilding : cityZone.zoneBuildingSet) {
|
||||
// Trees require special handling beyond an individual building
|
||||
if ((building.getBlueprint().getBuildingGroup() == BuildingGroup.TOL)) {
|
||||
// CHECK IF GUILD HAS A BANE DROPPED
|
||||
City city = ZoneManager.getCityAtLocation(building.getLoc());
|
||||
if (city.getGuild().getSubGuildList().isEmpty() == false) {
|
||||
//nations cant abandon their tree
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Nations Cannot Abandon Their Capital!");
|
||||
return true;
|
||||
}
|
||||
if (Bane.getBaneByAttackerGuild(city.getGuild()) != null) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "You Cannot Abandon Your Tree With An Active Siege!");
|
||||
return true;
|
||||
}
|
||||
|
||||
Blueprint cityBlueprint;
|
||||
cityBlueprint = cityBuilding.getBlueprint();
|
||||
AbandonAllCityObjects(player, building);
|
||||
} else
|
||||
AbandonSingleAsset(player, building);
|
||||
|
||||
// Buildings without blueprints cannot be abandoned
|
||||
if (cityBlueprint == null)
|
||||
continue;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Transfer ownership of valid city assets
|
||||
if ((cityBlueprint.getBuildingGroup() == BuildingGroup.TOL)
|
||||
|| (cityBlueprint.getBuildingGroup() == BuildingGroup.SPIRE)
|
||||
|| (cityBlueprint.getBuildingGroup() == BuildingGroup.BARRACK)
|
||||
|| (cityBlueprint.isWallPiece())
|
||||
|| (cityBuilding.getBlueprint().getBuildingGroup() == BuildingGroup.SHRINE))
|
||||
AbandonSingleAsset(sourcePlayer, cityBuilding);
|
||||
private void AbandonAllCityObjects(PlayerCharacter sourcePlayer,
|
||||
Building targetBuilding) {
|
||||
Guild sourceGuild;
|
||||
Zone cityZone;
|
||||
|
||||
}
|
||||
sourceGuild = sourcePlayer.getGuild();
|
||||
|
||||
}
|
||||
if (sourceGuild == null)
|
||||
return;
|
||||
|
||||
if (sourceGuild.getSubGuildList().size() > 0) {
|
||||
ChatManager.chatCityError(sourcePlayer, "You Cannot abandon a nation city.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
cityZone = ZoneManager.findSmallestZone(targetBuilding.getLoc());
|
||||
|
||||
// Can't abandon a tree not within a player city zone
|
||||
if (cityZone.isPlayerCity() == false)
|
||||
return;
|
||||
|
||||
if (targetBuilding.getCity() == null)
|
||||
return;
|
||||
|
||||
if (targetBuilding.getCity().getBane() != null) {
|
||||
ErrorPopupMsg.sendErrorMsg(sourcePlayer, "Can't abandon Tree while a bane exists.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (targetBuilding.getCity().hasBeenTransfered == true) {
|
||||
ChatManager.chatCityError(sourcePlayer, "City can only be abandoned once per rebooting.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Guild no longer owns his tree.
|
||||
if (!DbManager.GuildQueries.SET_GUILD_OWNED_CITY(sourceGuild.getObjectUUID(), 0)) {
|
||||
Logger.error("Failed to update Owned City to Database");
|
||||
return;
|
||||
}
|
||||
|
||||
sourceGuild.setCityUUID(0);
|
||||
sourceGuild.setGuildState(GuildState.Errant);
|
||||
sourceGuild.setNation(null);
|
||||
|
||||
// Transfer the city assets
|
||||
TransferCityAssets(sourcePlayer, targetBuilding);
|
||||
|
||||
GuildManager.updateAllGuildTags(sourceGuild);
|
||||
GuildManager.updateAllGuildBinds(sourceGuild, null);
|
||||
|
||||
}
|
||||
|
||||
private void TransferCityAssets(PlayerCharacter sourcePlayer,
|
||||
Building cityTOL) {
|
||||
|
||||
Zone cityZone;
|
||||
|
||||
// Build list of buildings within this parent zone
|
||||
cityZone = ZoneManager.findSmallestZone(cityTOL.getLoc());
|
||||
|
||||
for (Building cityBuilding : cityZone.zoneBuildingSet) {
|
||||
|
||||
Blueprint cityBlueprint;
|
||||
cityBlueprint = cityBuilding.getBlueprint();
|
||||
|
||||
// Buildings without blueprints cannot be abandoned
|
||||
if (cityBlueprint == null)
|
||||
continue;
|
||||
|
||||
// Transfer ownership of valid city assets
|
||||
if ((cityBlueprint.getBuildingGroup() == BuildingGroup.TOL)
|
||||
|| (cityBlueprint.getBuildingGroup() == BuildingGroup.SPIRE)
|
||||
|| (cityBlueprint.getBuildingGroup() == BuildingGroup.BARRACK)
|
||||
|| (cityBlueprint.isWallPiece())
|
||||
|| (cityBuilding.getBlueprint().getBuildingGroup() == BuildingGroup.SHRINE))
|
||||
AbandonSingleAsset(sourcePlayer, cityBuilding);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -10,24 +10,25 @@ import engine.net.client.msg.ClientNetMsg;
|
||||
*/
|
||||
|
||||
public abstract class AbstractClientMsgHandler {
|
||||
private final Class<? extends ClientNetMsg> handler;
|
||||
|
||||
public AbstractClientMsgHandler(Class<? extends ClientNetMsg> handler) {
|
||||
this.handler = handler;
|
||||
}
|
||||
|
||||
public boolean handleNetMsg(ClientNetMsg msg) {
|
||||
|
||||
boolean executionSucceded;
|
||||
|
||||
try {
|
||||
executionSucceded = _handleNetMsg(msg, (ClientConnection) msg.getOrigin());
|
||||
} catch (MsgSendException e) {
|
||||
e.printStackTrace();
|
||||
executionSucceded = false;
|
||||
}
|
||||
|
||||
return executionSucceded;
|
||||
}
|
||||
|
||||
protected abstract boolean _handleNetMsg(ClientNetMsg msg, ClientConnection origin) throws MsgSendException;}
|
||||
private final Class<? extends ClientNetMsg> handler;
|
||||
|
||||
public AbstractClientMsgHandler(Class<? extends ClientNetMsg> handler) {
|
||||
this.handler = handler;
|
||||
}
|
||||
|
||||
public boolean handleNetMsg(ClientNetMsg msg) {
|
||||
|
||||
boolean executionSucceded;
|
||||
|
||||
try {
|
||||
executionSucceded = _handleNetMsg(msg, (ClientConnection) msg.getOrigin());
|
||||
} catch (MsgSendException e) {
|
||||
e.printStackTrace();
|
||||
executionSucceded = false;
|
||||
}
|
||||
|
||||
return executionSucceded;
|
||||
}
|
||||
|
||||
protected abstract boolean _handleNetMsg(ClientNetMsg msg, ClientConnection origin) throws MsgSendException;
|
||||
}
|
||||
|
||||
@@ -7,9 +7,6 @@
|
||||
// www.magicbane.com
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
@@ -43,80 +40,80 @@ import org.joda.time.DateTime;
|
||||
|
||||
public class AcceptInviteToGuildHandler extends AbstractClientMsgHandler {
|
||||
|
||||
public AcceptInviteToGuildHandler() {
|
||||
super(AcceptInviteToGuildMsg.class);
|
||||
}
|
||||
public AcceptInviteToGuildHandler() {
|
||||
super(AcceptInviteToGuildMsg.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
|
||||
PlayerCharacter player;
|
||||
AcceptInviteToGuildMsg msg;
|
||||
Guild guild;
|
||||
PlayerCharacter player;
|
||||
AcceptInviteToGuildMsg msg;
|
||||
Guild guild;
|
||||
|
||||
msg = (AcceptInviteToGuildMsg) baseMsg;
|
||||
msg = (AcceptInviteToGuildMsg) baseMsg;
|
||||
|
||||
// get PlayerCharacter of person accepting invite
|
||||
// get PlayerCharacter of person accepting invite
|
||||
|
||||
player = SessionManager.getPlayerCharacter(origin);
|
||||
player = SessionManager.getPlayerCharacter(origin);
|
||||
|
||||
if (player == null)
|
||||
return true;
|
||||
if (player == null)
|
||||
return true;
|
||||
|
||||
guild = (Guild) DbManager.getObject(GameObjectType.Guild, msg.getGuildUUID());
|
||||
guild = (Guild) DbManager.getObject(GameObjectType.Guild, msg.getGuildUUID());
|
||||
|
||||
|
||||
if (guild == null)
|
||||
return true;
|
||||
if (guild == null)
|
||||
return true;
|
||||
|
||||
if (guild.getGuildType() == null){
|
||||
ErrorPopupMsg.sendErrorPopup(player, GuildManager.NO_CHARTER_FOUND);
|
||||
return true;
|
||||
}
|
||||
if (guild.getGuildType() == null) {
|
||||
ErrorPopupMsg.sendErrorPopup(player, GuildManager.NO_CHARTER_FOUND);
|
||||
return true;
|
||||
}
|
||||
|
||||
// verify they accepted for the correct guild
|
||||
// verify they accepted for the correct guild
|
||||
|
||||
if (player.getLastGuildToInvite() != msg.getGuildUUID())
|
||||
return true;
|
||||
if (player.getLastGuildToInvite() != msg.getGuildUUID())
|
||||
return true;
|
||||
|
||||
if ( (player.getGuild() != null) &&
|
||||
(player.getGuild().isEmptyGuild() == false)) {
|
||||
ChatManager.chatGuildError(player,
|
||||
"You already belongs to a guild!");
|
||||
return true;
|
||||
}
|
||||
if ((player.getGuild() != null) &&
|
||||
(player.getGuild().isEmptyGuild() == false)) {
|
||||
ChatManager.chatGuildError(player,
|
||||
"You already belongs to a guild!");
|
||||
return true;
|
||||
}
|
||||
|
||||
// verify they are acceptable level for guild
|
||||
// verify they are acceptable level for guild
|
||||
|
||||
if (player.getLevel() < guild.getRepledgeMin() || player.getLevel() > guild.getRepledgeMax())
|
||||
return true;
|
||||
if (player.getLevel() < guild.getRepledgeMin() || player.getLevel() > guild.getRepledgeMax())
|
||||
return true;
|
||||
|
||||
// Add player to guild
|
||||
player.setGuild(guild);
|
||||
// Add player to guild
|
||||
player.setGuild(guild);
|
||||
|
||||
// Cleanup guild stuff
|
||||
player.resetGuildStatuses();
|
||||
// Cleanup guild stuff
|
||||
player.resetGuildStatuses();
|
||||
|
||||
Dispatch dispatch = Dispatch.borrow(player, msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
Dispatch dispatch = Dispatch.borrow(player, msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
|
||||
DispatchMessage.sendToAllInRange(player, new GuildInfoMsg(player, guild, 2));
|
||||
DispatchMessage.sendToAllInRange(player, new GuildInfoMsg(player, guild, 2));
|
||||
|
||||
player.incVer();
|
||||
player.incVer();
|
||||
|
||||
//Add to guild History
|
||||
//Add to guild History
|
||||
|
||||
if (player.getGuild() != null){
|
||||
if (DbManager.GuildQueries.ADD_TO_GUILDHISTORY(player.getGuildUUID(), player, DateTime.now(), GuildHistoryType.JOIN)){
|
||||
GuildHistory guildHistory = new GuildHistory(player.getGuildUUID(),player.getGuild().getName(),DateTime.now(), GuildHistoryType.JOIN) ;
|
||||
player.getGuildHistory().add(guildHistory);
|
||||
}
|
||||
}
|
||||
if (player.getGuild() != null) {
|
||||
if (DbManager.GuildQueries.ADD_TO_GUILDHISTORY(player.getGuildUUID(), player, DateTime.now(), GuildHistoryType.JOIN)) {
|
||||
GuildHistory guildHistory = new GuildHistory(player.getGuildUUID(), player.getGuild().getName(), DateTime.now(), GuildHistoryType.JOIN);
|
||||
player.getGuildHistory().add(guildHistory);
|
||||
}
|
||||
}
|
||||
|
||||
// Send guild join message
|
||||
// Send guild join message
|
||||
|
||||
ChatManager.chatGuildInfo(player, player.getFirstName() + " has joined the guild");
|
||||
return true;
|
||||
}
|
||||
ChatManager.chatGuildInfo(player, player.getFirstName() + " has joined the guild");
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -30,77 +30,77 @@ import java.util.ArrayList;
|
||||
|
||||
public class AcceptSubInviteHandler extends AbstractClientMsgHandler {
|
||||
|
||||
public AcceptSubInviteHandler() {
|
||||
super(AcceptSubInviteMsg.class);
|
||||
}
|
||||
public AcceptSubInviteHandler() {
|
||||
super(AcceptSubInviteMsg.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
|
||||
AcceptSubInviteMsg msg = (AcceptSubInviteMsg) baseMsg;
|
||||
PlayerCharacter sourcePlayer;
|
||||
Guild sourceGuild;
|
||||
Guild targetGuild;
|
||||
Dispatch dispatch;
|
||||
AcceptSubInviteMsg msg = (AcceptSubInviteMsg) baseMsg;
|
||||
PlayerCharacter sourcePlayer;
|
||||
Guild sourceGuild;
|
||||
Guild targetGuild;
|
||||
Dispatch dispatch;
|
||||
|
||||
// get PlayerCharacter of person sending sub invite
|
||||
// get PlayerCharacter of person sending sub invite
|
||||
|
||||
sourcePlayer = SessionManager.getPlayerCharacter(origin);
|
||||
sourcePlayer = SessionManager.getPlayerCharacter(origin);
|
||||
|
||||
if (sourcePlayer == null)
|
||||
return true;
|
||||
if (sourcePlayer == null)
|
||||
return true;
|
||||
|
||||
sourceGuild = sourcePlayer.getGuild();
|
||||
targetGuild = (Guild) DbManager.getObject(GameObjectType.Guild, msg.guildUUID());
|
||||
sourceGuild = sourcePlayer.getGuild();
|
||||
targetGuild = (Guild) DbManager.getObject(GameObjectType.Guild, msg.guildUUID());
|
||||
|
||||
//must be source guild to sub to
|
||||
//must be source guild to sub to
|
||||
|
||||
if (targetGuild == null) {
|
||||
ErrorPopupMsg.sendErrorPopup(sourcePlayer, 45); // Failure to swear guild
|
||||
return true;
|
||||
}
|
||||
if (sourceGuild == null) {
|
||||
ErrorPopupMsg.sendErrorPopup(sourcePlayer, 45); // Failure to swear guild
|
||||
return true;
|
||||
}
|
||||
|
||||
if (sourceGuild.equals(targetGuild))
|
||||
return true;
|
||||
if (targetGuild == null) {
|
||||
ErrorPopupMsg.sendErrorPopup(sourcePlayer, 45); // Failure to swear guild
|
||||
return true;
|
||||
}
|
||||
if (sourceGuild == null) {
|
||||
ErrorPopupMsg.sendErrorPopup(sourcePlayer, 45); // Failure to swear guild
|
||||
return true;
|
||||
}
|
||||
|
||||
if (GuildStatusController.isGuildLeader(sourcePlayer.getGuildStatus()) == false) {
|
||||
ErrorPopupMsg.sendErrorMsg(sourcePlayer, "Only a guild leader can accept fealty!");
|
||||
return true;
|
||||
}
|
||||
if (sourceGuild.equals(targetGuild))
|
||||
return true;
|
||||
|
||||
//source guild is limited to 7 subs
|
||||
//TODO this should be based on TOL rank
|
||||
if (GuildStatusController.isGuildLeader(sourcePlayer.getGuildStatus()) == false) {
|
||||
ErrorPopupMsg.sendErrorMsg(sourcePlayer, "Only a guild leader can accept fealty!");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!targetGuild.canSubAGuild(sourceGuild)) {
|
||||
ErrorPopupMsg.sendErrorPopup(sourcePlayer, 45); // Failure to swear guild
|
||||
return true;
|
||||
}
|
||||
//source guild is limited to 7 subs
|
||||
//TODO this should be based on TOL rank
|
||||
|
||||
//all tests passed, let's Handle code
|
||||
//Update Target Guild State.
|
||||
if (!targetGuild.canSubAGuild(sourceGuild)) {
|
||||
ErrorPopupMsg.sendErrorPopup(sourcePlayer, 45); // Failure to swear guild
|
||||
return true;
|
||||
}
|
||||
|
||||
sourceGuild.upgradeGuildState(false);
|
||||
//all tests passed, let's Handle code
|
||||
//Update Target Guild State.
|
||||
|
||||
//Add sub so GuildMaster can Swear in.
|
||||
sourceGuild.upgradeGuildState(false);
|
||||
|
||||
ArrayList<Guild> subs = targetGuild.getSubGuildList();
|
||||
subs.add(sourceGuild);
|
||||
//Add sub so GuildMaster can Swear in.
|
||||
|
||||
targetGuild.setGuildState(GuildState.Nation);
|
||||
ArrayList<Guild> subs = targetGuild.getSubGuildList();
|
||||
subs.add(sourceGuild);
|
||||
|
||||
targetGuild.setGuildState(GuildState.Nation);
|
||||
|
||||
|
||||
//Let's send the message back.
|
||||
//Let's send the message back.
|
||||
|
||||
msg.setUnknown02(1);
|
||||
msg.setResponse("Your guild is now a " + sourceGuild.getGuildState().name() + '.');
|
||||
dispatch = Dispatch.borrow(sourcePlayer, msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
msg.setUnknown02(1);
|
||||
msg.setResponse("Your guild is now a " + sourceGuild.getGuildState().name() + '.');
|
||||
dispatch = Dispatch.borrow(sourcePlayer, msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
|
||||
ChatManager.chatSystemInfo(sourcePlayer, "Your guild is now a " + sourceGuild.getGuildState().name() + '.');
|
||||
return true;
|
||||
}
|
||||
ChatManager.chatSystemInfo(sourcePlayer, "Your guild is now a " + sourceGuild.getGuildState().name() + '.');
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,115 +22,115 @@ import java.util.ArrayList;
|
||||
*/
|
||||
public class ActivateNPCMsgHandler extends AbstractClientMsgHandler {
|
||||
|
||||
public ActivateNPCMsgHandler() {
|
||||
super(ActivateNPCMessage.class);
|
||||
}
|
||||
public ActivateNPCMsgHandler() {
|
||||
super(ActivateNPCMessage.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
|
||||
ActivateNPCMessage msg;
|
||||
PlayerCharacter player;
|
||||
Building building;
|
||||
Contract contract;
|
||||
CharacterItemManager itemMan;
|
||||
Zone zone;
|
||||
ActivateNPCMessage msg;
|
||||
PlayerCharacter player;
|
||||
Building building;
|
||||
Contract contract;
|
||||
CharacterItemManager itemMan;
|
||||
Zone zone;
|
||||
|
||||
msg = (ActivateNPCMessage) baseMsg;
|
||||
player = SessionManager.getPlayerCharacter(origin);
|
||||
building = BuildingManager.getBuildingFromCache(msg.buildingUUID());
|
||||
msg = (ActivateNPCMessage) baseMsg;
|
||||
player = SessionManager.getPlayerCharacter(origin);
|
||||
building = BuildingManager.getBuildingFromCache(msg.buildingUUID());
|
||||
|
||||
if (player == null || building == null)
|
||||
return false;
|
||||
if (player == null || building == null)
|
||||
return false;
|
||||
|
||||
ArrayList<Item> ItemLists = new ArrayList<>();
|
||||
ArrayList<Item> ItemLists = new ArrayList<>();
|
||||
|
||||
// Filter hirelings by slot type
|
||||
// Filter hirelings by slot type
|
||||
|
||||
for (Item hirelings : player.getInventory()) {
|
||||
if (hirelings.getItemBase().getType().equals(ItemType.CONTRACT)) {
|
||||
for (Item hirelings : player.getInventory()) {
|
||||
if (hirelings.getItemBase().getType().equals(ItemType.CONTRACT)) {
|
||||
|
||||
contract = DbManager.ContractQueries.GET_CONTRACT(hirelings.getItemBase().getUUID());
|
||||
contract = DbManager.ContractQueries.GET_CONTRACT(hirelings.getItemBase().getUUID());
|
||||
|
||||
if (contract == null)
|
||||
continue;
|
||||
if (contract == null)
|
||||
continue;
|
||||
|
||||
if (contract.canSlotinBuilding(building))
|
||||
ItemLists.add(hirelings);
|
||||
}
|
||||
}
|
||||
if (contract.canSlotinBuilding(building))
|
||||
ItemLists.add(hirelings);
|
||||
}
|
||||
}
|
||||
|
||||
if (msg.getUnknown01() == 1) {
|
||||
//Request npc list to slot
|
||||
ActivateNPCMessage anm = new ActivateNPCMessage();
|
||||
anm.setSize(ItemLists.size());
|
||||
anm.setItemList(ItemLists);
|
||||
Dispatch dispatch = Dispatch.borrow(player, anm);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
}
|
||||
if (msg.getUnknown01() == 1) {
|
||||
//Request npc list to slot
|
||||
ActivateNPCMessage anm = new ActivateNPCMessage();
|
||||
anm.setSize(ItemLists.size());
|
||||
anm.setItemList(ItemLists);
|
||||
Dispatch dispatch = Dispatch.borrow(player, anm);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
}
|
||||
|
||||
if (msg.getUnknown01() == 0) {
|
||||
if (msg.getUnknown01() == 0) {
|
||||
|
||||
//Slot npc
|
||||
//Slot npc
|
||||
|
||||
if (building.getBlueprintUUID() == 0) {
|
||||
ChatManager.chatSystemError(player, "Unable to load Blueprint for Building Mesh " + building.getMeshUUID());
|
||||
return false;
|
||||
}
|
||||
if (building.getBlueprintUUID() == 0) {
|
||||
ChatManager.chatSystemError(player, "Unable to load Blueprint for Building Mesh " + building.getMeshUUID());
|
||||
return false;
|
||||
}
|
||||
|
||||
if (building.getBlueprint().getMaxSlots() == building.getHirelings().size())
|
||||
return false;
|
||||
if (building.getBlueprint().getMaxSlots() == building.getHirelings().size())
|
||||
return false;
|
||||
|
||||
Item contractItem = Item.getFromCache(msg.getContractItem());
|
||||
Item contractItem = Item.getFromCache(msg.getContractItem());
|
||||
|
||||
if (contractItem == null)
|
||||
return false;
|
||||
if (contractItem == null)
|
||||
return false;
|
||||
|
||||
if (!player.getCharItemManager().doesCharOwnThisItem(contractItem.getObjectUUID())) {
|
||||
Logger.error(player.getName() + "has attempted to place Hireling : " + contractItem.getName() + "without a valid contract!");
|
||||
return false;
|
||||
}
|
||||
if (!player.getCharItemManager().doesCharOwnThisItem(contractItem.getObjectUUID())) {
|
||||
Logger.error(player.getName() + "has attempted to place Hireling : " + contractItem.getName() + "without a valid contract!");
|
||||
return false;
|
||||
}
|
||||
|
||||
itemMan = player.getCharItemManager();
|
||||
itemMan = player.getCharItemManager();
|
||||
|
||||
zone = ZoneManager.findSmallestZone(building.getLoc());
|
||||
zone = ZoneManager.findSmallestZone(building.getLoc());
|
||||
|
||||
if (zone == null)
|
||||
return false;
|
||||
if (zone == null)
|
||||
return false;
|
||||
|
||||
contract = DbManager.ContractQueries.GET_CONTRACT(contractItem.getItemBase().getUUID());
|
||||
contract = DbManager.ContractQueries.GET_CONTRACT(contractItem.getItemBase().getUUID());
|
||||
|
||||
if (contract == null)
|
||||
return false;
|
||||
if (contract == null)
|
||||
return false;
|
||||
|
||||
// Check if contract can be slotted in this building
|
||||
// Check if contract can be slotted in this building
|
||||
|
||||
if (contract.canSlotinBuilding(building) == false)
|
||||
return false;
|
||||
if (contract.canSlotinBuilding(building) == false)
|
||||
return false;
|
||||
|
||||
if (!BuildingManager.addHireling(building, player, zone, contract, contractItem))
|
||||
return false;
|
||||
if (!BuildingManager.addHireling(building, player, zone, contract, contractItem))
|
||||
return false;
|
||||
|
||||
itemMan.delete(contractItem);
|
||||
itemMan.updateInventory();
|
||||
itemMan.delete(contractItem);
|
||||
itemMan.updateInventory();
|
||||
|
||||
ManageCityAssetsMsg mca1 = new ManageCityAssetsMsg(player, building);
|
||||
ManageCityAssetsMsg mca1 = new ManageCityAssetsMsg(player, building);
|
||||
|
||||
mca1.actionType = 3;
|
||||
mca1.actionType = 3;
|
||||
|
||||
mca1.setTargetType(building.getObjectType().ordinal());
|
||||
mca1.setTargetID(building.getObjectUUID());
|
||||
mca1.setTargetType3(building.getObjectType().ordinal());
|
||||
mca1.setTargetID3(building.getObjectUUID());
|
||||
mca1.setAssetName1(building.getName());
|
||||
mca1.setUnknown54(1);
|
||||
Dispatch dispatch = Dispatch.borrow(player, mca1);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
mca1.setTargetType(building.getObjectType().ordinal());
|
||||
mca1.setTargetID(building.getObjectUUID());
|
||||
mca1.setTargetType3(building.getObjectType().ordinal());
|
||||
mca1.setTargetID3(building.getObjectUUID());
|
||||
mca1.setAssetName1(building.getName());
|
||||
mca1.setUnknown54(1);
|
||||
Dispatch dispatch = Dispatch.borrow(player, mca1);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,142 +20,134 @@ import engine.objects.PlayerCharacter;
|
||||
*/
|
||||
public class AllianceChangeMsgHandler extends AbstractClientMsgHandler {
|
||||
|
||||
public AllianceChangeMsgHandler() {
|
||||
super(AllianceChangeMsg.class);
|
||||
}
|
||||
public AllianceChangeMsgHandler() {
|
||||
super(AllianceChangeMsg.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
private static void MakeEnemy(Guild fromGuild, Guild toGuild, AllianceChangeMsg msg, ClientConnection origin) {
|
||||
|
||||
// Member variable declaration
|
||||
// Member variable declaration
|
||||
Dispatch dispatch;
|
||||
|
||||
PlayerCharacter player;
|
||||
AllianceChangeMsg msg;
|
||||
// Member variable assignment
|
||||
|
||||
if (fromGuild == null)
|
||||
return;
|
||||
|
||||
if (toGuild == null)
|
||||
return;
|
||||
|
||||
if (!Guild.sameGuild(origin.getPlayerCharacter().getGuild(), fromGuild)) {
|
||||
msg.setMsgType(AllianceChangeMsg.ERROR_NOT_SAME_GUILD);
|
||||
dispatch = Dispatch.borrow(origin.getPlayerCharacter(), msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!GuildStatusController.isInnerCouncil(origin.getPlayerCharacter().getGuildStatus()) && !GuildStatusController.isGuildLeader(origin.getPlayerCharacter().getGuildStatus())) {
|
||||
msg.setMsgType(AllianceChangeMsg.ERROR_NOT_AUTHORIZED);
|
||||
dispatch = Dispatch.borrow(origin.getPlayerCharacter(), msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Member variable assignment
|
||||
|
||||
msg = (AllianceChangeMsg) baseMsg;
|
||||
|
||||
player = SessionManager.getPlayerCharacter(origin);
|
||||
|
||||
if (player == null)
|
||||
return true;
|
||||
dispatch = Dispatch.borrow(origin.getPlayerCharacter(), msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
|
||||
|
||||
}
|
||||
|
||||
Guild toGuild = null;
|
||||
toGuild = Guild.getGuild(msg.getSourceGuildID());
|
||||
if (toGuild.isEmptyGuild())
|
||||
return true;
|
||||
private static void makeAlly(Guild fromGuild, Guild toGuild, AllianceChangeMsg msg, ClientConnection origin) {
|
||||
|
||||
if (player.getGuild().isEmptyGuild())
|
||||
return true;
|
||||
// Member variable declaration
|
||||
Dispatch dispatch;
|
||||
|
||||
// Member variable assignment
|
||||
|
||||
if (fromGuild == null)
|
||||
return;
|
||||
|
||||
if (toGuild == null)
|
||||
return;
|
||||
|
||||
dispatch = Dispatch.borrow(origin.getPlayerCharacter(), msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
|
||||
|
||||
}
|
||||
|
||||
switch (msg.getMsgType()){
|
||||
case AllianceChangeMsg.MAKE_ALLY:
|
||||
case 1: //allyfromRecommended
|
||||
player.getGuild().addGuildToAlliance(msg, AllianceType.Ally, toGuild, player);
|
||||
break;
|
||||
case AllianceChangeMsg.MAKE_ENEMY:
|
||||
case 2: //enemy recommend
|
||||
player.getGuild().addGuildToAlliance(msg, AllianceType.Enemy, toGuild, player);
|
||||
break;
|
||||
case 3:
|
||||
case 5:
|
||||
case 7:
|
||||
player.getGuild().removeGuildFromAllAlliances(toGuild);
|
||||
break;
|
||||
private static void removeFromAlliance(Guild fromGuild, Guild toGuild, AllianceChangeMsg msg, ClientConnection origin) {
|
||||
|
||||
}
|
||||
msg.setMsgType(AllianceChangeMsg.INFO_SUCCESS);
|
||||
Dispatch dispatch = Dispatch.borrow(player, msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
// Member variable declaration
|
||||
Dispatch dispatch;
|
||||
|
||||
// Member variable assignment
|
||||
|
||||
if (fromGuild == null)
|
||||
return;
|
||||
|
||||
if (toGuild == null)
|
||||
return;
|
||||
|
||||
dispatch = Dispatch.borrow(origin.getPlayerCharacter(), msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
|
||||
// Member variable declaration
|
||||
|
||||
PlayerCharacter player;
|
||||
AllianceChangeMsg msg;
|
||||
|
||||
|
||||
// Member variable assignment
|
||||
|
||||
msg = (AllianceChangeMsg) baseMsg;
|
||||
|
||||
player = SessionManager.getPlayerCharacter(origin);
|
||||
|
||||
if (player == null)
|
||||
return true;
|
||||
|
||||
|
||||
Guild toGuild = null;
|
||||
toGuild = Guild.getGuild(msg.getSourceGuildID());
|
||||
if (toGuild.isEmptyGuild())
|
||||
return true;
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
private static void MakeEnemy(Guild fromGuild, Guild toGuild, AllianceChangeMsg msg, ClientConnection origin) {
|
||||
|
||||
// Member variable declaration
|
||||
Dispatch dispatch;
|
||||
|
||||
// Member variable assignment
|
||||
|
||||
if (fromGuild == null)
|
||||
return;
|
||||
|
||||
if (toGuild == null)
|
||||
return;
|
||||
|
||||
if (!Guild.sameGuild(origin.getPlayerCharacter().getGuild(), fromGuild)){
|
||||
msg.setMsgType(AllianceChangeMsg.ERROR_NOT_SAME_GUILD);
|
||||
dispatch = Dispatch.borrow(origin.getPlayerCharacter(), msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!GuildStatusController.isInnerCouncil(origin.getPlayerCharacter().getGuildStatus()) && !GuildStatusController.isGuildLeader(origin.getPlayerCharacter().getGuildStatus())){
|
||||
msg.setMsgType(AllianceChangeMsg.ERROR_NOT_AUTHORIZED);
|
||||
dispatch = Dispatch.borrow(origin.getPlayerCharacter(), msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
return;
|
||||
}
|
||||
if (player.getGuild().isEmptyGuild())
|
||||
return true;
|
||||
|
||||
|
||||
dispatch = Dispatch.borrow(origin.getPlayerCharacter(), msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
switch (msg.getMsgType()) {
|
||||
case AllianceChangeMsg.MAKE_ALLY:
|
||||
case 1: //allyfromRecommended
|
||||
player.getGuild().addGuildToAlliance(msg, AllianceType.Ally, toGuild, player);
|
||||
break;
|
||||
case AllianceChangeMsg.MAKE_ENEMY:
|
||||
case 2: //enemy recommend
|
||||
player.getGuild().addGuildToAlliance(msg, AllianceType.Enemy, toGuild, player);
|
||||
break;
|
||||
case 3:
|
||||
case 5:
|
||||
case 7:
|
||||
player.getGuild().removeGuildFromAllAlliances(toGuild);
|
||||
break;
|
||||
|
||||
}
|
||||
msg.setMsgType(AllianceChangeMsg.INFO_SUCCESS);
|
||||
Dispatch dispatch = Dispatch.borrow(player, msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
|
||||
|
||||
}
|
||||
|
||||
private static void makeAlly(Guild fromGuild, Guild toGuild, AllianceChangeMsg msg, ClientConnection origin) {
|
||||
|
||||
// Member variable declaration
|
||||
Dispatch dispatch;
|
||||
|
||||
// Member variable assignment
|
||||
|
||||
if (fromGuild == null)
|
||||
return;
|
||||
|
||||
if (toGuild == null)
|
||||
return;
|
||||
|
||||
dispatch = Dispatch.borrow(origin.getPlayerCharacter(), msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
|
||||
|
||||
}
|
||||
|
||||
private static void removeFromAlliance(Guild fromGuild, Guild toGuild, AllianceChangeMsg msg, ClientConnection origin) {
|
||||
|
||||
// Member variable declaration
|
||||
Dispatch dispatch;
|
||||
|
||||
// Member variable assignment
|
||||
|
||||
if (fromGuild == null)
|
||||
return;
|
||||
|
||||
if (toGuild == null)
|
||||
return;
|
||||
|
||||
dispatch = Dispatch.borrow(origin.getPlayerCharacter(), msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
|
||||
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -18,64 +18,61 @@ import engine.objects.PlayerCharacter;
|
||||
*/
|
||||
public class AllyEnemyListMsgHandler extends AbstractClientMsgHandler {
|
||||
|
||||
public AllyEnemyListMsgHandler() {
|
||||
super(AllyEnemyListMsg.class);
|
||||
}
|
||||
public AllyEnemyListMsgHandler() {
|
||||
super(AllyEnemyListMsg.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
private static void showAllyEnemyList(Guild fromGuild, Guild toGuild, AllyEnemyListMsg msg, ClientConnection origin) {
|
||||
|
||||
// Member variable declaration
|
||||
// Member variable declaration
|
||||
Dispatch dispatch;
|
||||
|
||||
PlayerCharacter player;
|
||||
AllyEnemyListMsg msg;
|
||||
// Member variable assignment
|
||||
|
||||
if (fromGuild == null)
|
||||
return;
|
||||
|
||||
if (toGuild == null)
|
||||
return;
|
||||
dispatch = Dispatch.borrow(origin.getPlayerCharacter(), msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
|
||||
// UpdateClientAlliancesMsg ucam = new UpdateClientAlliancesMsg();
|
||||
//
|
||||
// dispatch = Dispatch.borrow(origin.getPlayerCharacter(), ucam);
|
||||
// DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
|
||||
|
||||
// Member variable assignment
|
||||
}
|
||||
|
||||
msg = (AllyEnemyListMsg) baseMsg;
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
|
||||
player = SessionManager.getPlayerCharacter(origin);
|
||||
// Member variable declaration
|
||||
|
||||
if (player == null)
|
||||
return true;
|
||||
PlayerCharacter player;
|
||||
AllyEnemyListMsg msg;
|
||||
|
||||
|
||||
AllyEnemyListMsgHandler.showAllyEnemyList(player.getGuild(), Guild.getGuild(msg.getGuildID()), msg, origin);
|
||||
// Member variable assignment
|
||||
|
||||
msg = (AllyEnemyListMsg) baseMsg;
|
||||
|
||||
player = SessionManager.getPlayerCharacter(origin);
|
||||
|
||||
if (player == null)
|
||||
return true;
|
||||
|
||||
|
||||
AllyEnemyListMsgHandler.showAllyEnemyList(player.getGuild(), Guild.getGuild(msg.getGuildID()), msg, origin);
|
||||
|
||||
|
||||
// dispatch = Dispatch.borrow(player, baseMsg);
|
||||
// DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
// dispatch = Dispatch.borrow(player, baseMsg);
|
||||
// DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
private static void showAllyEnemyList(Guild fromGuild, Guild toGuild, AllyEnemyListMsg msg, ClientConnection origin) {
|
||||
|
||||
// Member variable declaration
|
||||
Dispatch dispatch;
|
||||
|
||||
// Member variable assignment
|
||||
|
||||
if (fromGuild == null)
|
||||
return;
|
||||
|
||||
if (toGuild == null)
|
||||
return;
|
||||
dispatch = Dispatch.borrow(origin.getPlayerCharacter(), msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
|
||||
// UpdateClientAlliancesMsg ucam = new UpdateClientAlliancesMsg();
|
||||
//
|
||||
// dispatch = Dispatch.borrow(origin.getPlayerCharacter(), ucam);
|
||||
// DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
|
||||
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -22,123 +22,123 @@ import org.pmw.tinylog.Logger;
|
||||
|
||||
public class ArcLoginNotifyMsgHandler extends AbstractClientMsgHandler {
|
||||
|
||||
public ArcLoginNotifyMsgHandler() {
|
||||
super(ArcLoginNotifyMsg.class);
|
||||
}
|
||||
public ArcLoginNotifyMsgHandler() {
|
||||
super(ArcLoginNotifyMsg.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
|
||||
PlayerCharacter player = SessionManager.getPlayerCharacter(origin);
|
||||
PlayerCharacter player = SessionManager.getPlayerCharacter(origin);
|
||||
|
||||
if (player == null) {
|
||||
Logger.error(ConfigManager.MB_WORLD_NAME.getValue()+ ".EnterWorld", "Unable to find player for session");
|
||||
origin.kickToLogin(MBServerStatics.LOGINERROR_UNABLE_TO_LOGIN, "Player not found.");
|
||||
return true;
|
||||
}
|
||||
if (player == null) {
|
||||
Logger.error(ConfigManager.MB_WORLD_NAME.getValue() + ".EnterWorld", "Unable to find player for session");
|
||||
origin.kickToLogin(MBServerStatics.LOGINERROR_UNABLE_TO_LOGIN, "Player not found.");
|
||||
return true;
|
||||
}
|
||||
|
||||
// cancel logout Timer if exists
|
||||
if (player.getTimers().containsKey("Logout")) {
|
||||
// cancel logout Timer if exists
|
||||
if (player.getTimers().containsKey("Logout")) {
|
||||
|
||||
JobScheduler.getInstance().cancelScheduledJob(player.getTimers().get("Logout"));
|
||||
player.getTimers().remove("Logout");
|
||||
}
|
||||
player.setTimeStamp("logout", 0);
|
||||
JobScheduler.getInstance().cancelScheduledJob(player.getTimers().get("Logout"));
|
||||
player.getTimers().remove("Logout");
|
||||
}
|
||||
player.setTimeStamp("logout", 0);
|
||||
|
||||
// refresh group window if still in group for both this player
|
||||
// and everyone else in the group
|
||||
// refresh group window if still in group for both this player
|
||||
// and everyone else in the group
|
||||
|
||||
if (GroupManager.getGroup(player) != null) {
|
||||
GroupManager.RefreshMyGroupList(player, origin);
|
||||
GroupManager.RefreshOthersGroupList(player);
|
||||
}
|
||||
if (GroupManager.getGroup(player) != null) {
|
||||
GroupManager.RefreshMyGroupList(player, origin);
|
||||
GroupManager.RefreshOthersGroupList(player);
|
||||
}
|
||||
|
||||
player.setEnteredWorld(true);
|
||||
// Set player active
|
||||
player.resetRegenUpdateTime();
|
||||
player.setActive(true);
|
||||
player.setEnteredWorld(true);
|
||||
// Set player active
|
||||
player.resetRegenUpdateTime();
|
||||
player.setActive(true);
|
||||
|
||||
//player.sendAllEffects(player.getClientConnection());
|
||||
// Send Enter world message to guild
|
||||
//player.sendAllEffects(player.getClientConnection());
|
||||
// Send Enter world message to guild
|
||||
|
||||
ChatManager.GuildEnterWorldMsg(player, origin);
|
||||
ChatManager.GuildEnterWorldMsg(player, origin);
|
||||
|
||||
// Send Guild, Nation and IC MOTD
|
||||
GuildManager.enterWorldMOTD(player);
|
||||
ChatManager.sendSystemMessage(player, ConfigManager.MB_WORLD_GREETING.getValue());
|
||||
// Send Guild, Nation and IC MOTD
|
||||
GuildManager.enterWorldMOTD(player);
|
||||
ChatManager.sendSystemMessage(player, ConfigManager.MB_WORLD_GREETING.getValue());
|
||||
|
||||
// Set player mask for QT
|
||||
if (player.getRace() != null && player.getRace().getToken() == -524731385)
|
||||
player.setObjectTypeMask(MBServerStatics.MASK_PLAYER | MBServerStatics.MASK_UNDEAD);
|
||||
else
|
||||
player.setObjectTypeMask(MBServerStatics.MASK_PLAYER);
|
||||
// Set player mask for QT
|
||||
if (player.getRace() != null && player.getRace().getToken() == -524731385)
|
||||
player.setObjectTypeMask(MBServerStatics.MASK_PLAYER | MBServerStatics.MASK_UNDEAD);
|
||||
else
|
||||
player.setObjectTypeMask(MBServerStatics.MASK_PLAYER);
|
||||
|
||||
// If player not already in world, then set them to bind loc and add
|
||||
// to world
|
||||
// If player not already in world, then set them to bind loc and add
|
||||
// to world
|
||||
|
||||
if (player.newChar)
|
||||
player.newChar = false; // TODO Fix safe mode
|
||||
if (player.newChar)
|
||||
player.newChar = false; // TODO Fix safe mode
|
||||
|
||||
// PowersManager.applyPower(player, player, new
|
||||
// Vector3f(0f, 0f, 0f), -1661758934, 50, false);
|
||||
// PowersManager.applyPower(player, player, new
|
||||
// Vector3f(0f, 0f, 0f), -1661758934, 50, false);
|
||||
|
||||
// Add player to the QT for tracking
|
||||
// Add player to the QT for tracking
|
||||
|
||||
player.setLoc(player.getLoc());
|
||||
player.setLoc(player.getLoc());
|
||||
|
||||
//send online status to friends.
|
||||
PlayerFriends.SendFriendsStatus(player, true);
|
||||
//send online status to friends.
|
||||
PlayerFriends.SendFriendsStatus(player, true);
|
||||
|
||||
// Handle too many simultaneous logins from the same forum account by disconnecting the other account(s)
|
||||
// Handle too many simultaneous logins from the same forum account by disconnecting the other account(s)
|
||||
|
||||
Account thisAccount = SessionManager.getAccount(player);
|
||||
int maxAccounts = MBServerStatics.MAX_ACTIVE_GAME_ACCOUNTS_PER_DISCORD_ACCOUNT;
|
||||
Account thisAccount = SessionManager.getAccount(player);
|
||||
int maxAccounts = MBServerStatics.MAX_ACTIVE_GAME_ACCOUNTS_PER_DISCORD_ACCOUNT;
|
||||
|
||||
if (maxAccounts > 0) {
|
||||
if (maxAccounts > 0) {
|
||||
|
||||
int count = 1;
|
||||
for (Account othAccount : SessionManager.getAllActiveAccounts()) {
|
||||
int count = 1;
|
||||
for (Account othAccount : SessionManager.getAllActiveAccounts()) {
|
||||
|
||||
if (othAccount.equals(thisAccount))
|
||||
continue;
|
||||
if (othAccount.equals(thisAccount))
|
||||
continue;
|
||||
|
||||
if (thisAccount.discordAccount.equals(othAccount.discordAccount) == false)
|
||||
continue;
|
||||
if (thisAccount.discordAccount.equals(othAccount.discordAccount) == false)
|
||||
continue;
|
||||
|
||||
count++;
|
||||
count++;
|
||||
|
||||
if (count > maxAccounts) {
|
||||
Session otherSession = SessionManager.getSession(othAccount);
|
||||
if (otherSession != null) {
|
||||
ClientConnection otherConn = otherSession.getConn();
|
||||
if (otherConn != null) {
|
||||
ChatManager.chatSystemInfo(player, "Only 4 accounts may be used simultaneously. Account '" + othAccount.getUname() + "' has been disconnected.");
|
||||
otherConn.disconnect();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (count > maxAccounts) {
|
||||
Session otherSession = SessionManager.getSession(othAccount);
|
||||
if (otherSession != null) {
|
||||
ClientConnection otherConn = otherSession.getConn();
|
||||
if (otherConn != null) {
|
||||
ChatManager.chatSystemInfo(player, "Only 4 accounts may be used simultaneously. Account '" + othAccount.getUname() + "' has been disconnected.");
|
||||
otherConn.disconnect();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
player.setTimeStamp("logout", 0);
|
||||
player.setTimeStamp("logout", 0);
|
||||
|
||||
if (player.getPet() != null) {
|
||||
PetMsg pm = new PetMsg(5, player.getPet());
|
||||
Dispatch dispatch = Dispatch.borrow(player, pm);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
}
|
||||
if (player.getPet() != null) {
|
||||
PetMsg pm = new PetMsg(5, player.getPet());
|
||||
Dispatch dispatch = Dispatch.borrow(player, pm);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
}
|
||||
|
||||
//Send current hotzone
|
||||
//Send current hotzone
|
||||
|
||||
if (ZoneManager.hotZone != null) {
|
||||
HotzoneChangeMsg hcm = new HotzoneChangeMsg(Enum.GameObjectType.Zone.ordinal(), ZoneManager.hotZone.getObjectUUID());
|
||||
Dispatch dispatch = Dispatch.borrow(player, hcm);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
}
|
||||
if (ZoneManager.hotZone != null) {
|
||||
HotzoneChangeMsg hcm = new HotzoneChangeMsg(Enum.GameObjectType.Zone.ordinal(), ZoneManager.hotZone.getObjectUUID());
|
||||
Dispatch dispatch = Dispatch.borrow(player, hcm);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
}
|
||||
|
||||
if (player.getGuild() != null && !player.getGuild().isEmptyGuild()) {
|
||||
Guild.UpdateClientAlliancesForPlayer(player);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (player.getGuild() != null && !player.getGuild().isEmptyGuild()) {
|
||||
Guild.UpdateClientAlliancesForPlayer(player);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -29,7 +29,7 @@ public class ArcMineWindowAvailableTimeHandler extends AbstractClientMsgHandler
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
|
||||
ArcMineWindowAvailableTimeMsg msg = (ArcMineWindowAvailableTimeMsg) baseMsg;
|
||||
ArcMineWindowAvailableTimeMsg msg = (ArcMineWindowAvailableTimeMsg) baseMsg;
|
||||
PlayerCharacter playerCharacter = origin.getPlayerCharacter();
|
||||
Building treeOfLife = BuildingManager.getBuildingFromCache(msg.getBuildingUUID());
|
||||
Dispatch dispatch;
|
||||
|
||||
@@ -21,100 +21,100 @@ import org.pmw.tinylog.Logger;
|
||||
|
||||
public class ArcSiegeSpireMsgHandler extends AbstractClientMsgHandler {
|
||||
|
||||
public ArcSiegeSpireMsgHandler() {
|
||||
super(ArcSiegeSpireMsg.class);
|
||||
}
|
||||
public ArcSiegeSpireMsgHandler() {
|
||||
super(ArcSiegeSpireMsg.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
|
||||
PlayerCharacter player;
|
||||
Building spire;
|
||||
ArcSiegeSpireMsg msg;
|
||||
PlayerCharacter player;
|
||||
Building spire;
|
||||
ArcSiegeSpireMsg msg;
|
||||
|
||||
msg = (ArcSiegeSpireMsg) baseMsg;
|
||||
msg = (ArcSiegeSpireMsg) baseMsg;
|
||||
|
||||
player = SessionManager.getPlayerCharacter(origin);
|
||||
player = SessionManager.getPlayerCharacter(origin);
|
||||
|
||||
if (player == null)
|
||||
return true;
|
||||
if (player == null)
|
||||
return true;
|
||||
|
||||
spire = (Building) DbManager.getObject(GameObjectType.Building, msg.getBuildingUUID());
|
||||
spire = (Building) DbManager.getObject(GameObjectType.Building, msg.getBuildingUUID());
|
||||
|
||||
if (spire == null)
|
||||
return true;
|
||||
if (spire == null)
|
||||
return true;
|
||||
|
||||
if (spire.getCity() == null)
|
||||
return true;
|
||||
|
||||
spire.getCity().transactionLock.writeLock().lock();
|
||||
|
||||
try{
|
||||
|
||||
|
||||
//can't activate a spire that's not rank 1.
|
||||
if (spire.getCity() == null)
|
||||
return true;
|
||||
|
||||
if (spire.getRank() < 1)
|
||||
return true;
|
||||
spire.getCity().transactionLock.writeLock().lock();
|
||||
|
||||
// can't activate a spire without a city
|
||||
try {
|
||||
|
||||
if (spire.getCity() == null)
|
||||
return true;
|
||||
|
||||
// Must have management authority for the spire
|
||||
//can't activate a spire that's not rank 1.
|
||||
|
||||
if ((player.getGuild().equals(spire.getGuild()) == false)
|
||||
|| (GuildStatusController.isInnerCouncil(player.getGuildStatus()) == false) )
|
||||
return true;
|
||||
if (spire.getRank() < 1)
|
||||
return true;
|
||||
|
||||
// Handle case where spire is sabotaged
|
||||
// can't activate a spire without a city
|
||||
|
||||
if (spire.getTimeStamp("DISABLED") > System.currentTimeMillis()) {
|
||||
ErrorPopupMsg.sendErrorPopup(player, 174); //This siege spire cannot be toggled yet.
|
||||
return true;
|
||||
}
|
||||
if (spire.getCity() == null)
|
||||
return true;
|
||||
|
||||
// Handle case where spire's toggle delay hasn't yet passed
|
||||
// Must have management authority for the spire
|
||||
|
||||
if (spire.getTimeStamp("TOGGLEDELAY") > System.currentTimeMillis()) {
|
||||
ErrorPopupMsg.sendErrorPopup(player, 174); //This siege spire cannot be toggled yet.
|
||||
return true;
|
||||
}
|
||||
if ((player.getGuild().equals(spire.getGuild()) == false)
|
||||
|| (GuildStatusController.isInnerCouncil(player.getGuildStatus()) == false))
|
||||
return true;
|
||||
|
||||
// This protocol message is a toggle. If it's currently active then disable
|
||||
// the spire.
|
||||
// Handle case where spire is sabotaged
|
||||
|
||||
if (spire.isSpireIsActive()) {
|
||||
spire.disableSpire(false);
|
||||
return true;
|
||||
}
|
||||
if (spire.getTimeStamp("DISABLED") > System.currentTimeMillis()) {
|
||||
ErrorPopupMsg.sendErrorPopup(player, 174); //This siege spire cannot be toggled yet.
|
||||
return true;
|
||||
}
|
||||
|
||||
// Must be enough gold on the spire to turn it on
|
||||
// Handle case where spire's toggle delay hasn't yet passed
|
||||
|
||||
if (!spire.hasFunds(5000)){
|
||||
ErrorPopupMsg.sendErrorPopup(player, 127); // Not enough gold in strongbox
|
||||
return true;
|
||||
}
|
||||
if (spire.getTimeStamp("TOGGLEDELAY") > System.currentTimeMillis()) {
|
||||
ErrorPopupMsg.sendErrorPopup(player, 174); //This siege spire cannot be toggled yet.
|
||||
return true;
|
||||
}
|
||||
|
||||
if (spire.getStrongboxValue() < 5000) {
|
||||
ErrorPopupMsg.sendErrorPopup(player, 127); // Not enough gold in strongbox
|
||||
return true;
|
||||
}
|
||||
// This protocol message is a toggle. If it's currently active then disable
|
||||
// the spire.
|
||||
|
||||
spire.transferGold(-5000,false);
|
||||
spire.enableSpire();
|
||||
if (spire.isSpireIsActive()) {
|
||||
spire.disableSpire(false);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Spire is now enabled. Reset the toggle delay
|
||||
// Must be enough gold on the spire to turn it on
|
||||
|
||||
spire.setTimeStamp("TOGGLEDELAY", System.currentTimeMillis() + (long) 10 * 60 * 1000);
|
||||
}catch(Exception e){
|
||||
Logger.error(e);
|
||||
}finally{
|
||||
spire.getCity().transactionLock.writeLock().unlock();
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
if (!spire.hasFunds(5000)) {
|
||||
ErrorPopupMsg.sendErrorPopup(player, 127); // Not enough gold in strongbox
|
||||
return true;
|
||||
}
|
||||
|
||||
if (spire.getStrongboxValue() < 5000) {
|
||||
ErrorPopupMsg.sendErrorPopup(player, 127); // Not enough gold in strongbox
|
||||
return true;
|
||||
}
|
||||
|
||||
spire.transferGold(-5000, false);
|
||||
spire.enableSpire();
|
||||
|
||||
// Spire is now enabled. Reset the toggle delay
|
||||
|
||||
spire.setTimeStamp("TOGGLEDELAY", System.currentTimeMillis() + (long) 10 * 60 * 1000);
|
||||
} catch (Exception e) {
|
||||
Logger.error(e);
|
||||
} finally {
|
||||
spire.getCity().transactionLock.writeLock().unlock();
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -40,9 +40,9 @@ public class ArcViewAssetTransactionsMsgHandler extends AbstractClientMsgHandler
|
||||
Warehouse warehouse = Warehouse.warehouseByBuildingUUID.get(msg.getWarehouseID());
|
||||
|
||||
if (warehouse == null)
|
||||
return true;
|
||||
|
||||
newMsg = new ArcViewAssetTransactionsMsg(warehouse,msg);
|
||||
return true;
|
||||
|
||||
newMsg = new ArcViewAssetTransactionsMsg(warehouse, msg);
|
||||
newMsg.configure();
|
||||
|
||||
dispatch = Dispatch.borrow(player, newMsg);
|
||||
|
||||
@@ -20,221 +20,220 @@ import org.pmw.tinylog.Logger;
|
||||
*/
|
||||
public class AssetSupportMsgHandler extends AbstractClientMsgHandler {
|
||||
|
||||
public AssetSupportMsgHandler() {
|
||||
super(AssetSupportMsg.class);
|
||||
}
|
||||
public AssetSupportMsgHandler() {
|
||||
super(AssetSupportMsg.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
private static void protectAsset(AssetSupportMsg msg, Building targetBuilding, NPC vendor, ClientConnection origin) {
|
||||
|
||||
// Member variable declaration
|
||||
// Member variable declaration
|
||||
|
||||
PlayerCharacter player;
|
||||
NPC vendor;
|
||||
Building targetBuilding;
|
||||
Dispatch dispatch;
|
||||
Zone serverZone;
|
||||
City serverCity;
|
||||
ManageNPCMsg outMsg;
|
||||
int protectionSlots;
|
||||
Dispatch dispatch;
|
||||
|
||||
AssetSupportMsg msg;
|
||||
CityAssetMsg outMsg;
|
||||
// Member variable assignment
|
||||
|
||||
// Member variable assignment
|
||||
if (targetBuilding == null)
|
||||
return;
|
||||
|
||||
msg = (AssetSupportMsg) baseMsg;
|
||||
serverZone = vendor.getParentZone();
|
||||
|
||||
player = SessionManager.getPlayerCharacter(origin);
|
||||
if (serverZone == null)
|
||||
return;
|
||||
|
||||
if (player == null)
|
||||
return true;
|
||||
serverCity = City.GetCityFromCache(serverZone.getPlayerCityUUID());
|
||||
|
||||
vendor = NPC.getFromCache(msg.getNpcID());
|
||||
if (serverCity == null)
|
||||
return;
|
||||
|
||||
if (msg.getMessageType() !=6 && msg.getMessageType() != 7){
|
||||
if (vendor == null)
|
||||
return true;
|
||||
if (!serverCity.isLocationOnCityZone(targetBuilding.getLoc())) {
|
||||
ErrorPopupMsg.sendErrorMsg(origin.getPlayerCharacter(), "Structura must be on city zone for to protect.");
|
||||
return;
|
||||
}
|
||||
|
||||
vendor.getBuilding();
|
||||
if ((serverCity.getTOL() == null) || (serverCity.getTOL().getRank() < 1))
|
||||
return;
|
||||
|
||||
if (vendor.getBuilding() == null)
|
||||
return true;
|
||||
}
|
||||
if (serverCity.protectionEnforced == false) {
|
||||
ErrorPopupMsg.sendErrorMsg(origin.getPlayerCharacter(), "Runemaster can not protect structura during bane!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (serverCity.getRuneMaster() == null) {
|
||||
ErrorPopupMsg.sendErrorMsg(origin.getPlayerCharacter(), "Runemaster is needed for to protect structura!");
|
||||
return;
|
||||
}
|
||||
|
||||
// Enforce runemaster protection limits
|
||||
|
||||
protectionSlots = (2 * serverCity.getRuneMaster().getRank()) + 6;
|
||||
|
||||
if (serverCity.getRuneMaster().getProtectedBuildings().size() >=
|
||||
protectionSlots) {
|
||||
ErrorPopupMsg.sendErrorMsg(origin.getPlayerCharacter(), "Runemaster can only protect " + protectionSlots + " structura!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (msg.getWeeklyTax() != 0) {
|
||||
if (!serverCity.getTOL().addProtectionTax(targetBuilding, origin.getPlayerCharacter(), TaxType.WEEKLY, msg.getWeeklyTax(), msg.getEnforceKOS() == 1 ? true : false)) {
|
||||
ErrorPopupMsg.sendErrorMsg(origin.getPlayerCharacter(), "Failed to add taxes to building.");
|
||||
return;
|
||||
}
|
||||
targetBuilding.setProtectionState(Enum.ProtectionState.PENDING);
|
||||
} else if (msg.getProfitTax() != 0) {
|
||||
if (!serverCity.getTOL().addProtectionTax(targetBuilding, origin.getPlayerCharacter(), TaxType.PROFIT, msg.getProfitTax(), msg.getEnforceKOS() == 1 ? true : false)) {
|
||||
ErrorPopupMsg.sendErrorMsg(origin.getPlayerCharacter(), "Failed to add taxes to building.");
|
||||
return;
|
||||
}
|
||||
targetBuilding.setProtectionState(Enum.ProtectionState.PENDING);
|
||||
} else
|
||||
targetBuilding.setProtectionState(Enum.ProtectionState.CONTRACT);
|
||||
|
||||
|
||||
SupportMsgType supportType = SupportMsgType.typeLookup.get(msg.getMessageType());
|
||||
outMsg = new ManageNPCMsg(vendor);
|
||||
dispatch = Dispatch.borrow(origin.getPlayerCharacter(), outMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
}
|
||||
|
||||
if (supportType == null) {
|
||||
supportType = Enum.SupportMsgType.NONE;
|
||||
Logger.error("No enumeration for support type" + msg.getMessageType());
|
||||
}
|
||||
switch (supportType) {
|
||||
private static void unprotectAsset(Building targetBuilding, NPC vendor, ClientConnection origin) {
|
||||
|
||||
case PROTECT:
|
||||
targetBuilding = BuildingManager.getBuildingFromCache(msg.getProtectedBuildingID());
|
||||
protectAsset(msg,targetBuilding, vendor, origin);
|
||||
break;
|
||||
case UNPROTECT:
|
||||
targetBuilding = BuildingManager.getBuildingFromCache(msg.getProtectedBuildingID());
|
||||
unprotectAsset(targetBuilding, vendor, origin);
|
||||
break;
|
||||
case VIEWUNPROTECTED:
|
||||
outMsg = new CityAssetMsg();
|
||||
outMsg.setBuildingID(msg.getBuildingID());
|
||||
outMsg.configure();
|
||||
if (targetBuilding == null)
|
||||
return;
|
||||
|
||||
dispatch = Dispatch.borrow(player, outMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
break;
|
||||
// Early exit if UUID < the last database derived building UUID.
|
||||
|
||||
case REMOVETAX:
|
||||
targetBuilding = BuildingManager.getBuildingFromCache(msg.getBuildingID());
|
||||
if (targetBuilding.getProtectionState() == Enum.ProtectionState.NPC) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (targetBuilding == null)
|
||||
return true;
|
||||
if (targetBuilding.getProtectionState() == engine.Enum.ProtectionState.NONE)
|
||||
return;
|
||||
|
||||
targetBuilding.removeTaxes();
|
||||
unprotectAsset(targetBuilding, null, origin);
|
||||
if (GuildStatusController.isInnerCouncil(origin.getPlayerCharacter().getGuildStatus()) == false)
|
||||
return;
|
||||
|
||||
ManageCityAssetsMsg mca = new ManageCityAssetsMsg(origin.getPlayerCharacter(),targetBuilding);
|
||||
targetBuilding.removeTaxes();
|
||||
|
||||
// Action TYPE
|
||||
mca.actionType = 3;
|
||||
mca.setTargetType(targetBuilding.getObjectType().ordinal());
|
||||
mca.setTargetID(targetBuilding.getObjectUUID());
|
||||
mca.setTargetType3(targetBuilding.getObjectType().ordinal());
|
||||
mca.setTargetID3(targetBuilding.getObjectUUID());
|
||||
mca.setAssetName1(targetBuilding.getName());
|
||||
mca.setUnknown54(1);
|
||||
dispatch = Dispatch.borrow(player, mca);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
return true;
|
||||
targetBuilding.setProtectionState(engine.Enum.ProtectionState.NONE);
|
||||
|
||||
case ACCEPTTAX: //AcceptTax
|
||||
}
|
||||
|
||||
targetBuilding = BuildingManager.getBuildingFromCache(msg.getBuildingID());
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
|
||||
if (targetBuilding == null)
|
||||
return true;
|
||||
// Member variable declaration
|
||||
|
||||
targetBuilding.acceptTaxes();
|
||||
PlayerCharacter player;
|
||||
NPC vendor;
|
||||
Building targetBuilding;
|
||||
Dispatch dispatch;
|
||||
|
||||
mca = new ManageCityAssetsMsg(origin.getPlayerCharacter(),targetBuilding);
|
||||
AssetSupportMsg msg;
|
||||
CityAssetMsg outMsg;
|
||||
|
||||
// Action TYPE
|
||||
mca.actionType = 3;
|
||||
mca.setTargetType(targetBuilding.getObjectType().ordinal());
|
||||
mca.setTargetID(targetBuilding.getObjectUUID());
|
||||
mca.setTargetType3(targetBuilding.getObjectType().ordinal());
|
||||
mca.setTargetID3(targetBuilding.getObjectUUID());
|
||||
mca.setAssetName1(targetBuilding.getName());
|
||||
mca.setUnknown54(1);
|
||||
// Member variable assignment
|
||||
|
||||
dispatch = Dispatch.borrow(player, mca);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
return true;
|
||||
}
|
||||
msg = (AssetSupportMsg) baseMsg;
|
||||
|
||||
dispatch = Dispatch.borrow(player, baseMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
player = SessionManager.getPlayerCharacter(origin);
|
||||
|
||||
return true;
|
||||
if (player == null)
|
||||
return true;
|
||||
|
||||
}
|
||||
vendor = NPC.getFromCache(msg.getNpcID());
|
||||
|
||||
private static void protectAsset(AssetSupportMsg msg, Building targetBuilding, NPC vendor, ClientConnection origin) {
|
||||
if (msg.getMessageType() != 6 && msg.getMessageType() != 7) {
|
||||
if (vendor == null)
|
||||
return true;
|
||||
|
||||
// Member variable declaration
|
||||
vendor.getBuilding();
|
||||
|
||||
Zone serverZone;
|
||||
City serverCity;
|
||||
ManageNPCMsg outMsg;
|
||||
int protectionSlots;
|
||||
Dispatch dispatch;
|
||||
|
||||
// Member variable assignment
|
||||
|
||||
if (targetBuilding == null)
|
||||
return;
|
||||
|
||||
serverZone = vendor.getParentZone();
|
||||
|
||||
if (serverZone == null)
|
||||
return;
|
||||
|
||||
serverCity = City.GetCityFromCache(serverZone.getPlayerCityUUID());
|
||||
|
||||
if (serverCity == null)
|
||||
return;
|
||||
|
||||
if (!serverCity.isLocationOnCityZone(targetBuilding.getLoc())){
|
||||
ErrorPopupMsg.sendErrorMsg(origin.getPlayerCharacter(), "Structura must be on city zone for to protect.");
|
||||
return;
|
||||
}
|
||||
|
||||
if ((serverCity.getTOL() == null)|| (serverCity.getTOL().getRank() < 1))
|
||||
return;
|
||||
|
||||
if (serverCity.protectionEnforced == false) {
|
||||
ErrorPopupMsg.sendErrorMsg(origin.getPlayerCharacter(), "Runemaster can not protect structura during bane!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (serverCity.getRuneMaster() == null) {
|
||||
ErrorPopupMsg.sendErrorMsg(origin.getPlayerCharacter(), "Runemaster is needed for to protect structura!");
|
||||
return;
|
||||
}
|
||||
|
||||
// Enforce runemaster protection limits
|
||||
|
||||
protectionSlots = (2 * serverCity.getRuneMaster().getRank()) + 6;
|
||||
|
||||
if (serverCity.getRuneMaster().getProtectedBuildings().size() >=
|
||||
protectionSlots) {
|
||||
ErrorPopupMsg.sendErrorMsg(origin.getPlayerCharacter(), "Runemaster can only protect " + protectionSlots + " structura!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (msg.getWeeklyTax() != 0){
|
||||
if (!serverCity.getTOL().addProtectionTax(targetBuilding, origin.getPlayerCharacter(), TaxType.WEEKLY, msg.getWeeklyTax(), msg.getEnforceKOS() == 1 ? true: false)){
|
||||
ErrorPopupMsg.sendErrorMsg(origin.getPlayerCharacter(), "Failed to add taxes to building.");
|
||||
return;
|
||||
}
|
||||
targetBuilding.setProtectionState(Enum.ProtectionState.PENDING);
|
||||
}else if (msg.getProfitTax() != 0){
|
||||
if (!serverCity.getTOL().addProtectionTax(targetBuilding, origin.getPlayerCharacter(), TaxType.PROFIT, msg.getProfitTax(), msg.getEnforceKOS() == 1 ? true: false)){
|
||||
ErrorPopupMsg.sendErrorMsg(origin.getPlayerCharacter(), "Failed to add taxes to building.");
|
||||
return;
|
||||
}
|
||||
targetBuilding.setProtectionState(Enum.ProtectionState.PENDING);
|
||||
}else
|
||||
targetBuilding.setProtectionState(Enum.ProtectionState.CONTRACT);
|
||||
if (vendor.getBuilding() == null)
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
SupportMsgType supportType = SupportMsgType.typeLookup.get(msg.getMessageType());
|
||||
|
||||
outMsg = new ManageNPCMsg(vendor);
|
||||
dispatch = Dispatch.borrow(origin.getPlayerCharacter(), outMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
}
|
||||
if (supportType == null) {
|
||||
supportType = Enum.SupportMsgType.NONE;
|
||||
Logger.error("No enumeration for support type" + msg.getMessageType());
|
||||
}
|
||||
switch (supportType) {
|
||||
|
||||
private static void unprotectAsset(Building targetBuilding, NPC vendor, ClientConnection origin) {
|
||||
case PROTECT:
|
||||
targetBuilding = BuildingManager.getBuildingFromCache(msg.getProtectedBuildingID());
|
||||
protectAsset(msg, targetBuilding, vendor, origin);
|
||||
break;
|
||||
case UNPROTECT:
|
||||
targetBuilding = BuildingManager.getBuildingFromCache(msg.getProtectedBuildingID());
|
||||
unprotectAsset(targetBuilding, vendor, origin);
|
||||
break;
|
||||
case VIEWUNPROTECTED:
|
||||
outMsg = new CityAssetMsg();
|
||||
outMsg.setBuildingID(msg.getBuildingID());
|
||||
outMsg.configure();
|
||||
|
||||
if (targetBuilding == null)
|
||||
return;
|
||||
dispatch = Dispatch.borrow(player, outMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
break;
|
||||
|
||||
// Early exit if UUID < the last database derived building UUID.
|
||||
case REMOVETAX:
|
||||
targetBuilding = BuildingManager.getBuildingFromCache(msg.getBuildingID());
|
||||
|
||||
if (targetBuilding.getProtectionState() == Enum.ProtectionState.NPC) {
|
||||
return;
|
||||
}
|
||||
if (targetBuilding == null)
|
||||
return true;
|
||||
|
||||
if (targetBuilding.getProtectionState() == engine.Enum.ProtectionState.NONE)
|
||||
return;
|
||||
targetBuilding.removeTaxes();
|
||||
unprotectAsset(targetBuilding, null, origin);
|
||||
|
||||
if (GuildStatusController.isInnerCouncil(origin.getPlayerCharacter().getGuildStatus()) == false)
|
||||
return;
|
||||
ManageCityAssetsMsg mca = new ManageCityAssetsMsg(origin.getPlayerCharacter(), targetBuilding);
|
||||
|
||||
targetBuilding.removeTaxes();
|
||||
// Action TYPE
|
||||
mca.actionType = 3;
|
||||
mca.setTargetType(targetBuilding.getObjectType().ordinal());
|
||||
mca.setTargetID(targetBuilding.getObjectUUID());
|
||||
mca.setTargetType3(targetBuilding.getObjectType().ordinal());
|
||||
mca.setTargetID3(targetBuilding.getObjectUUID());
|
||||
mca.setAssetName1(targetBuilding.getName());
|
||||
mca.setUnknown54(1);
|
||||
dispatch = Dispatch.borrow(player, mca);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
return true;
|
||||
|
||||
targetBuilding.setProtectionState(engine.Enum.ProtectionState.NONE);
|
||||
case ACCEPTTAX: //AcceptTax
|
||||
|
||||
}
|
||||
targetBuilding = BuildingManager.getBuildingFromCache(msg.getBuildingID());
|
||||
|
||||
if (targetBuilding == null)
|
||||
return true;
|
||||
|
||||
targetBuilding.acceptTaxes();
|
||||
|
||||
mca = new ManageCityAssetsMsg(origin.getPlayerCharacter(), targetBuilding);
|
||||
|
||||
// Action TYPE
|
||||
mca.actionType = 3;
|
||||
mca.setTargetType(targetBuilding.getObjectType().ordinal());
|
||||
mca.setTargetID(targetBuilding.getObjectUUID());
|
||||
mca.setTargetType3(targetBuilding.getObjectType().ordinal());
|
||||
mca.setTargetID3(targetBuilding.getObjectUUID());
|
||||
mca.setAssetName1(targetBuilding.getName());
|
||||
mca.setUnknown54(1);
|
||||
|
||||
dispatch = Dispatch.borrow(player, mca);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
return true;
|
||||
}
|
||||
|
||||
dispatch = Dispatch.borrow(player, baseMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -30,100 +30,97 @@ import org.joda.time.DateTime;
|
||||
|
||||
public class BanishUnbanishHandler extends AbstractClientMsgHandler {
|
||||
|
||||
public BanishUnbanishHandler() {
|
||||
super(BanishUnbanishMsg.class);
|
||||
}
|
||||
public BanishUnbanishHandler() {
|
||||
super(BanishUnbanishMsg.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
BanishUnbanishMsg msg = (BanishUnbanishMsg) baseMsg;
|
||||
Dispatch dispatch;
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
BanishUnbanishMsg msg = (BanishUnbanishMsg) baseMsg;
|
||||
Dispatch dispatch;
|
||||
|
||||
int target = msg.getTarget();
|
||||
PlayerCharacter source = origin.getPlayerCharacter();
|
||||
int target = msg.getTarget();
|
||||
PlayerCharacter source = origin.getPlayerCharacter();
|
||||
|
||||
if(source == null || source.getGuild().isEmptyGuild() || source.getGuild().getObjectUUID() == 0)
|
||||
return true;
|
||||
if (source == null || source.getGuild().isEmptyGuild() || source.getGuild().getObjectUUID() == 0)
|
||||
return true;
|
||||
|
||||
if (GuildStatusController.isGuildLeader(source.getGuildStatus()) == false && GuildStatusController.isInnerCouncil(source.getGuildStatus()) == false)
|
||||
return true;
|
||||
if (GuildStatusController.isGuildLeader(source.getGuildStatus()) == false && GuildStatusController.isInnerCouncil(source.getGuildStatus()) == false)
|
||||
return true;
|
||||
|
||||
if (source.getObjectUUID() == target) {
|
||||
ErrorPopupMsg.sendErrorPopup(source, 103); // You may not banish this char
|
||||
return true;
|
||||
}
|
||||
if (source.getObjectUUID() == target) {
|
||||
ErrorPopupMsg.sendErrorPopup(source, 103); // You may not banish this char
|
||||
return true;
|
||||
}
|
||||
|
||||
boolean success = false;
|
||||
Guild guild = source.getGuild();
|
||||
PlayerCharacter realizedTarget = PlayerCharacter.getFromCache(target);
|
||||
boolean success = false;
|
||||
Guild guild = source.getGuild();
|
||||
PlayerCharacter realizedTarget = PlayerCharacter.getFromCache(target);
|
||||
|
||||
if(realizedTarget != null) {
|
||||
// Guild leader can't leave guild. must pass GL or disband
|
||||
if ( GuildStatusController.isGuildLeader(realizedTarget.getGuildStatus()) == false) {
|
||||
//ICs cannot banish other ICs
|
||||
if (!(GuildStatusController.isInnerCouncil(realizedTarget.getGuildStatus()) && GuildStatusController.isGuildLeader(source.getGuildStatus()) == false)) {
|
||||
success = true;
|
||||
if (msg.getMsgType() == 1){
|
||||
if (!DbManager.GuildQueries.ADD_TO_BANISHED_FROM_GUILDLIST(guild.getObjectUUID(), realizedTarget.getObjectUUID())){
|
||||
ChatManager.chatGuildError(source, "Failed To unbanish " + realizedTarget.getName());
|
||||
return true;
|
||||
}
|
||||
guild.getBanishList().remove(realizedTarget);
|
||||
}
|
||||
if (realizedTarget != null) {
|
||||
// Guild leader can't leave guild. must pass GL or disband
|
||||
if (GuildStatusController.isGuildLeader(realizedTarget.getGuildStatus()) == false) {
|
||||
//ICs cannot banish other ICs
|
||||
if (!(GuildStatusController.isInnerCouncil(realizedTarget.getGuildStatus()) && GuildStatusController.isGuildLeader(source.getGuildStatus()) == false)) {
|
||||
success = true;
|
||||
if (msg.getMsgType() == 1) {
|
||||
if (!DbManager.GuildQueries.ADD_TO_BANISHED_FROM_GUILDLIST(guild.getObjectUUID(), realizedTarget.getObjectUUID())) {
|
||||
ChatManager.chatGuildError(source, "Failed To unbanish " + realizedTarget.getName());
|
||||
return true;
|
||||
}
|
||||
guild.getBanishList().remove(realizedTarget);
|
||||
} else {
|
||||
|
||||
if (!DbManager.GuildQueries.ADD_TO_BANISHED_FROM_GUILDLIST(guild.getObjectUUID(), realizedTarget.getObjectUUID())) {
|
||||
ChatManager.chatGuildError(source, "Failed To Banish " + realizedTarget.getName());
|
||||
return true;
|
||||
}
|
||||
guild.removePlayer(realizedTarget, GuildHistoryType.BANISHED);
|
||||
guild.getBanishList().add(realizedTarget); //TODO we might encapsulate this a bit better; also not sure that a list of PC objects is really ideal
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (guild.getGuildLeaderUUID() != target) {
|
||||
PlayerCharacter toBanish = PlayerCharacter.getPlayerCharacter(target);
|
||||
if (toBanish == null)
|
||||
return true;
|
||||
//already added previously.
|
||||
if (SessionManager.getPlayerCharacterByID(toBanish.getObjectUUID()) != null)
|
||||
return true;
|
||||
|
||||
if (DbManager.GuildQueries.BANISH_FROM_GUILD_OFFLINE(target, GuildStatusController.isGuildLeader(source.getGuildStatus())) != 0) {
|
||||
|
||||
success = true;
|
||||
|
||||
//Set guild history
|
||||
|
||||
if (DbManager.GuildQueries.ADD_TO_GUILDHISTORY(guild.getObjectUUID(), toBanish, DateTime.now(), GuildHistoryType.BANISHED)) {
|
||||
GuildHistory guildHistory = new GuildHistory(toBanish.getGuildUUID(), toBanish.getGuild().getName(), DateTime.now(), GuildHistoryType.BANISHED);
|
||||
toBanish.getGuildHistory().add(guildHistory);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
else{
|
||||
if (success) {
|
||||
//TODO re enable this once we get unbanish working!!!!
|
||||
//DbManager.GuildQueries.ADD_TO_BANISHED_FROM_GUILDLIST(guild.getobjectUUID(), target);
|
||||
|
||||
if (!DbManager.GuildQueries.ADD_TO_BANISHED_FROM_GUILDLIST(guild.getObjectUUID(), realizedTarget.getObjectUUID())){
|
||||
ChatManager.chatGuildError(source, "Failed To Banish " + realizedTarget.getName());
|
||||
return true;
|
||||
}
|
||||
guild.removePlayer(realizedTarget, GuildHistoryType.BANISHED);
|
||||
guild.getBanishList().add(realizedTarget); //TODO we might encapsulate this a bit better; also not sure that a list of PC objects is really ideal
|
||||
}
|
||||
// Send left guild message to rest of guild
|
||||
String targetName = PlayerCharacter.getFirstName(target);
|
||||
ChatManager.chatGuildInfo(guild,
|
||||
targetName + " has been banished from " + guild.getName() + '.');
|
||||
GuildListMsg guildListMsg = new GuildListMsg(guild);
|
||||
dispatch = Dispatch.borrow(source, guildListMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
} else {
|
||||
ErrorPopupMsg.sendErrorPopup(source, 103); // You may not banish this char
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (guild.getGuildLeaderUUID() != target) {
|
||||
PlayerCharacter toBanish = PlayerCharacter.getPlayerCharacter(target);
|
||||
if (toBanish == null)
|
||||
return true;
|
||||
//already added previously.
|
||||
if (SessionManager.getPlayerCharacterByID(toBanish.getObjectUUID()) != null)
|
||||
return true;
|
||||
|
||||
if(DbManager.GuildQueries.BANISH_FROM_GUILD_OFFLINE(target, GuildStatusController.isGuildLeader(source.getGuildStatus())) != 0) {
|
||||
|
||||
success = true;
|
||||
|
||||
//Set guild history
|
||||
|
||||
if (DbManager.GuildQueries.ADD_TO_GUILDHISTORY(guild.getObjectUUID(), toBanish, DateTime.now(), GuildHistoryType.BANISHED)){
|
||||
GuildHistory guildHistory = new GuildHistory(toBanish.getGuildUUID(),toBanish.getGuild().getName(),DateTime.now(), GuildHistoryType.BANISHED) ;
|
||||
toBanish.getGuildHistory().add(guildHistory);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(success) {
|
||||
//TODO re enable this once we get unbanish working!!!!
|
||||
//DbManager.GuildQueries.ADD_TO_BANISHED_FROM_GUILDLIST(guild.getobjectUUID(), target);
|
||||
|
||||
// Send left guild message to rest of guild
|
||||
String targetName = PlayerCharacter.getFirstName(target);
|
||||
ChatManager.chatGuildInfo(guild,
|
||||
targetName + " has been banished from " + guild.getName() + '.');
|
||||
GuildListMsg guildListMsg = new GuildListMsg(guild);
|
||||
dispatch = Dispatch.borrow(source, guildListMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
} else {
|
||||
ErrorPopupMsg.sendErrorPopup(source, 103); // You may not banish this char
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -31,161 +31,160 @@ import java.util.ArrayList;
|
||||
|
||||
public class BreakFealtyHandler extends AbstractClientMsgHandler {
|
||||
|
||||
public BreakFealtyHandler() {
|
||||
super(BreakFealtyMsg.class);
|
||||
}
|
||||
public BreakFealtyHandler() {
|
||||
super(BreakFealtyMsg.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
|
||||
BreakFealtyMsg bfm;
|
||||
PlayerCharacter player;
|
||||
Guild toBreak;
|
||||
Guild guild;
|
||||
Dispatch dispatch;
|
||||
BreakFealtyMsg bfm;
|
||||
PlayerCharacter player;
|
||||
Guild toBreak;
|
||||
Guild guild;
|
||||
Dispatch dispatch;
|
||||
|
||||
bfm = (BreakFealtyMsg) baseMsg;
|
||||
bfm = (BreakFealtyMsg) baseMsg;
|
||||
|
||||
// get PlayerCharacter of person accepting invite
|
||||
// get PlayerCharacter of person accepting invite
|
||||
|
||||
player = SessionManager.getPlayerCharacter(
|
||||
origin);
|
||||
player = SessionManager.getPlayerCharacter(
|
||||
origin);
|
||||
|
||||
if (player == null)
|
||||
return true;
|
||||
if (player == null)
|
||||
return true;
|
||||
|
||||
toBreak = (Guild) DbManager.getObject(GameObjectType.Guild, bfm.getGuildUUID());
|
||||
toBreak = (Guild) DbManager.getObject(GameObjectType.Guild, bfm.getGuildUUID());
|
||||
|
||||
if (toBreak == null) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "A Serious error has occured. Please post details for to ensure transaction integrity");
|
||||
return true;
|
||||
}
|
||||
if (toBreak == null) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "A Serious error has occured. Please post details for to ensure transaction integrity");
|
||||
return true;
|
||||
}
|
||||
|
||||
guild = player.getGuild();
|
||||
guild = player.getGuild();
|
||||
|
||||
if (guild == null) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "You do not belong to a guild!");
|
||||
return true;
|
||||
}
|
||||
if (guild == null) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "You do not belong to a guild!");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (toBreak.isNPCGuild()){
|
||||
if (GuildStatusController.isGuildLeader(player.getGuildStatus()) == false) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Only guild leader can break fealty!");
|
||||
return true;
|
||||
}
|
||||
if (toBreak.isNPCGuild()) {
|
||||
if (GuildStatusController.isGuildLeader(player.getGuildStatus()) == false) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Only guild leader can break fealty!");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if (!DbManager.GuildQueries.UPDATE_PARENT(guild.getObjectUUID(), WorldServer.worldUUID)) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "A Serious error has occurred. Please post details for to ensure transaction integrity");
|
||||
return true;
|
||||
}
|
||||
if (!DbManager.GuildQueries.UPDATE_PARENT(guild.getObjectUUID(), WorldServer.worldUUID)) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "A Serious error has occurred. Please post details for to ensure transaction integrity");
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (guild.getGuildState()) {
|
||||
case Sworn:
|
||||
guild.setNation(null);
|
||||
GuildManager.updateAllGuildTags(guild);
|
||||
GuildManager.updateAllGuildBinds(guild, null);
|
||||
break;
|
||||
case Province:
|
||||
guild.setNation(guild);
|
||||
GuildManager.updateAllGuildTags(guild);
|
||||
GuildManager.updateAllGuildBinds(guild, guild.getOwnedCity());
|
||||
break;
|
||||
}
|
||||
switch (guild.getGuildState()) {
|
||||
case Sworn:
|
||||
guild.setNation(null);
|
||||
GuildManager.updateAllGuildTags(guild);
|
||||
GuildManager.updateAllGuildBinds(guild, null);
|
||||
break;
|
||||
case Province:
|
||||
guild.setNation(guild);
|
||||
GuildManager.updateAllGuildTags(guild);
|
||||
GuildManager.updateAllGuildBinds(guild, guild.getOwnedCity());
|
||||
break;
|
||||
}
|
||||
|
||||
guild.downgradeGuildState();
|
||||
guild.downgradeGuildState();
|
||||
|
||||
SendGuildEntryMsg msg = new SendGuildEntryMsg(player);
|
||||
dispatch = Dispatch.borrow(player, msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
SendGuildEntryMsg msg = new SendGuildEntryMsg(player);
|
||||
dispatch = Dispatch.borrow(player, msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
|
||||
//Update Map.
|
||||
//Update Map.
|
||||
|
||||
final Session s = SessionManager.getSession(player);
|
||||
final Session s = SessionManager.getSession(player);
|
||||
|
||||
City.lastCityUpdate = System.currentTimeMillis();
|
||||
City.lastCityUpdate = System.currentTimeMillis();
|
||||
|
||||
|
||||
ArrayList<PlayerCharacter> guildMembers = SessionManager.getActivePCsInGuildID(guild.getObjectUUID());
|
||||
ArrayList<PlayerCharacter> guildMembers = SessionManager.getActivePCsInGuildID(guild.getObjectUUID());
|
||||
|
||||
for (PlayerCharacter member : guildMembers) {
|
||||
ChatManager.chatGuildInfo(member, guild.getName() + " has broke fealty from " + toBreak.getName() + '!');
|
||||
}
|
||||
for (PlayerCharacter member : guildMembers) {
|
||||
ChatManager.chatGuildInfo(member, guild.getName() + " has broke fealty from " + toBreak.getName() + '!');
|
||||
}
|
||||
|
||||
ArrayList<PlayerCharacter> breakFealtyMembers = SessionManager.getActivePCsInGuildID(toBreak.getObjectUUID());
|
||||
ArrayList<PlayerCharacter> breakFealtyMembers = SessionManager.getActivePCsInGuildID(toBreak.getObjectUUID());
|
||||
|
||||
for (PlayerCharacter member : breakFealtyMembers) {
|
||||
ChatManager.chatGuildInfo(member, guild.getName() + " has broken fealty from " + toBreak.getName() + '!');
|
||||
}
|
||||
for (PlayerCharacter member : breakFealtyMembers) {
|
||||
ChatManager.chatGuildInfo(member, guild.getName() + " has broken fealty from " + toBreak.getName() + '!');
|
||||
}
|
||||
|
||||
return true;
|
||||
return true;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (!toBreak.getSubGuildList().contains(guild)) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Failure to break fealty!");
|
||||
return true;
|
||||
}
|
||||
if (!toBreak.getSubGuildList().contains(guild)) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Failure to break fealty!");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (GuildStatusController.isGuildLeader(player.getGuildStatus()) == false) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Only guild leader can break fealty!");
|
||||
return true;
|
||||
}
|
||||
if (GuildStatusController.isGuildLeader(player.getGuildStatus()) == false) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Only guild leader can break fealty!");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Bane.getBaneByAttackerGuild(guild) != null)
|
||||
{
|
||||
ErrorPopupMsg.sendErrorMsg(player, "You may break fealty with active bane!");
|
||||
return true;
|
||||
}
|
||||
if (Bane.getBaneByAttackerGuild(guild) != null) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "You may break fealty with active bane!");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!DbManager.GuildQueries.UPDATE_PARENT(guild.getObjectUUID(), WorldServer.worldUUID)) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "A Serious error has occurred. Please post details for to ensure transaction integrity");
|
||||
return true;
|
||||
}
|
||||
if (!DbManager.GuildQueries.UPDATE_PARENT(guild.getObjectUUID(), WorldServer.worldUUID)) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "A Serious error has occurred. Please post details for to ensure transaction integrity");
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (guild.getGuildState()) {
|
||||
case Sworn:
|
||||
guild.setNation(null);
|
||||
GuildManager.updateAllGuildTags(guild);
|
||||
GuildManager.updateAllGuildBinds(guild, null);
|
||||
break;
|
||||
case Province:
|
||||
guild.setNation(guild);
|
||||
GuildManager.updateAllGuildTags(guild);
|
||||
GuildManager.updateAllGuildBinds(guild, guild.getOwnedCity());
|
||||
break;
|
||||
}
|
||||
switch (guild.getGuildState()) {
|
||||
case Sworn:
|
||||
guild.setNation(null);
|
||||
GuildManager.updateAllGuildTags(guild);
|
||||
GuildManager.updateAllGuildBinds(guild, null);
|
||||
break;
|
||||
case Province:
|
||||
guild.setNation(guild);
|
||||
GuildManager.updateAllGuildTags(guild);
|
||||
GuildManager.updateAllGuildBinds(guild, guild.getOwnedCity());
|
||||
break;
|
||||
}
|
||||
|
||||
guild.downgradeGuildState();
|
||||
toBreak.getSubGuildList().remove(guild);
|
||||
guild.downgradeGuildState();
|
||||
toBreak.getSubGuildList().remove(guild);
|
||||
|
||||
if (toBreak.getSubGuildList().isEmpty())
|
||||
toBreak.downgradeGuildState();
|
||||
if (toBreak.getSubGuildList().isEmpty())
|
||||
toBreak.downgradeGuildState();
|
||||
|
||||
SendGuildEntryMsg msg = new SendGuildEntryMsg(player);
|
||||
dispatch = Dispatch.borrow(player, msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
SendGuildEntryMsg msg = new SendGuildEntryMsg(player);
|
||||
dispatch = Dispatch.borrow(player, msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
|
||||
//Update Map.
|
||||
//Update Map.
|
||||
|
||||
final Session s = SessionManager.getSession(player);
|
||||
final Session s = SessionManager.getSession(player);
|
||||
|
||||
City.lastCityUpdate = System.currentTimeMillis();
|
||||
City.lastCityUpdate = System.currentTimeMillis();
|
||||
|
||||
|
||||
ArrayList<PlayerCharacter> guildMembers = SessionManager.getActivePCsInGuildID(guild.getObjectUUID());
|
||||
ArrayList<PlayerCharacter> guildMembers = SessionManager.getActivePCsInGuildID(guild.getObjectUUID());
|
||||
|
||||
for (PlayerCharacter member : guildMembers) {
|
||||
ChatManager.chatGuildInfo(member, guild.getName() + " has broke fealty from " + toBreak.getName() + '!');
|
||||
}
|
||||
for (PlayerCharacter member : guildMembers) {
|
||||
ChatManager.chatGuildInfo(member, guild.getName() + " has broke fealty from " + toBreak.getName() + '!');
|
||||
}
|
||||
|
||||
ArrayList<PlayerCharacter> breakFealtyMembers = SessionManager.getActivePCsInGuildID(toBreak.getObjectUUID());
|
||||
ArrayList<PlayerCharacter> breakFealtyMembers = SessionManager.getActivePCsInGuildID(toBreak.getObjectUUID());
|
||||
|
||||
for (PlayerCharacter member : breakFealtyMembers) {
|
||||
ChatManager.chatGuildInfo(member, guild.getName() + " has broken fealty from " + toBreak.getName() + '!');
|
||||
}
|
||||
for (PlayerCharacter member : breakFealtyMembers) {
|
||||
ChatManager.chatGuildInfo(member, guild.getName() + " has broken fealty from " + toBreak.getName() + '!');
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,167 +24,157 @@ import org.pmw.tinylog.Logger;
|
||||
|
||||
public class ChangeAltitudeHandler extends AbstractClientMsgHandler {
|
||||
|
||||
public ChangeAltitudeHandler() {
|
||||
super(ChangeAltitudeMsg.class);
|
||||
}
|
||||
public ChangeAltitudeHandler() {
|
||||
super(ChangeAltitudeMsg.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg,
|
||||
ClientConnection origin) throws MsgSendException {
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg,
|
||||
ClientConnection origin) throws MsgSendException {
|
||||
|
||||
ChangeAltitudeMsg msg = (ChangeAltitudeMsg) baseMsg;
|
||||
ChangeAltitudeMsg msg = (ChangeAltitudeMsg) baseMsg;
|
||||
|
||||
PlayerCharacter pc = origin.getPlayerCharacter();
|
||||
if (pc == null) {
|
||||
return false;
|
||||
}
|
||||
PlayerCharacter pc = origin.getPlayerCharacter();
|
||||
if (pc == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!AbstractCharacter.CanFly(pc))
|
||||
return false;
|
||||
|
||||
if (pc.isSwimming())
|
||||
return false;
|
||||
if (pc.region != null && !pc.region.isOutside())
|
||||
return false;
|
||||
|
||||
if (!AbstractCharacter.CanFly(pc))
|
||||
return false;
|
||||
|
||||
if (pc.isSwimming())
|
||||
return false;
|
||||
if (pc.region != null && !pc.region.isOutside())
|
||||
return false;
|
||||
|
||||
|
||||
// Find out if we already have an altitude timer running and if so
|
||||
// do not process more alt change requests
|
||||
|
||||
if (pc.getTakeOffTime() != 0)
|
||||
return false;
|
||||
|
||||
|
||||
|
||||
// remove all movement timers and jobs
|
||||
//TODO: test if they can fly
|
||||
|
||||
// Find out if we already have an altitude timer running and if so
|
||||
// do not process more alt change requests
|
||||
|
||||
if (pc.getTakeOffTime() != 0)
|
||||
return false;
|
||||
float targetAlt;
|
||||
float amount = msg.getAmountToMove();
|
||||
if (amount != 10 && amount != 60)
|
||||
return false;
|
||||
if (pc.getAltitude() == 60 && msg.up())
|
||||
return true;
|
||||
if (pc.getAltitude() == 0 && !msg.up())
|
||||
return true;
|
||||
|
||||
|
||||
// remove all movement timers and jobs
|
||||
//TODO: test if they can fly
|
||||
pc.update();
|
||||
pc.stopMovement(pc.getLoc());
|
||||
msg.setStartAlt(pc.getAltitude());
|
||||
if (msg.up()) {
|
||||
|
||||
float targetAlt;
|
||||
float amount = msg.getAmountToMove();
|
||||
if (amount != 10 && amount != 60)
|
||||
return false;
|
||||
if (pc.getAltitude() == 60 && msg.up())
|
||||
return true;
|
||||
if (pc.getAltitude() == 0 && !msg.up())
|
||||
return true;
|
||||
|
||||
pc.update();
|
||||
pc.stopMovement(pc.getLoc());
|
||||
msg.setStartAlt(pc.getAltitude());
|
||||
if (msg.up()) {
|
||||
pc.landingRegion = null;
|
||||
if (pc.getAltitude() == 0) {
|
||||
Regions upRegion = pc.region;
|
||||
if (upRegion != null) {
|
||||
float startAlt = 0;
|
||||
Building regionBuilding = Regions.GetBuildingForRegion(upRegion);
|
||||
if (upRegion != null)
|
||||
startAlt = upRegion.lerpY(pc) - regionBuilding.getLoc().y;
|
||||
float rounded = startAlt * .10f;
|
||||
|
||||
pc.landingRegion = null;
|
||||
if (pc.getAltitude() == 0){
|
||||
Regions upRegion = pc.region;
|
||||
if (upRegion != null){
|
||||
float startAlt = 0;
|
||||
Building regionBuilding = Regions.GetBuildingForRegion(upRegion);
|
||||
if (upRegion != null)
|
||||
startAlt = upRegion.lerpY(pc) - regionBuilding.getLoc().y;
|
||||
float rounded = startAlt *.10f;
|
||||
rounded = ((int) rounded) * 10;
|
||||
|
||||
rounded = ((int)rounded) * 10;
|
||||
|
||||
if (rounded < 0)
|
||||
rounded = 0;
|
||||
|
||||
|
||||
msg.setStartAlt(startAlt);
|
||||
targetAlt = rounded + amount;
|
||||
|
||||
if (targetAlt > 60)
|
||||
targetAlt = 60;
|
||||
|
||||
pc.setAltitude(startAlt);
|
||||
pc.setDesiredAltitude(targetAlt);
|
||||
}else{
|
||||
msg.setStartAlt(pc.getAltitude());
|
||||
targetAlt = pc.getAltitude() + amount;
|
||||
if (targetAlt > 60)
|
||||
targetAlt = 60;
|
||||
}
|
||||
}else{
|
||||
msg.setStartAlt(pc.getAltitude());
|
||||
|
||||
targetAlt = pc.getAltitude() + amount;
|
||||
if (targetAlt > 60)
|
||||
targetAlt = 60;
|
||||
}
|
||||
if (rounded < 0)
|
||||
rounded = 0;
|
||||
|
||||
|
||||
} else {
|
||||
msg.setStartAlt(pc.getAltitude());
|
||||
targetAlt = pc.getAltitude() - amount;
|
||||
if (targetAlt < 0)
|
||||
targetAlt = 0;
|
||||
}
|
||||
msg.setTargetAlt(targetAlt);
|
||||
if (pc.getAltitude() < 1 && targetAlt > pc.getAltitude()) {
|
||||
// char is on the ground and is about to start flight
|
||||
if (pc.getStamina() < 10) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
msg.setStartAlt(startAlt);
|
||||
targetAlt = rounded + amount;
|
||||
|
||||
if (MBServerStatics.MOVEMENT_SYNC_DEBUG) {
|
||||
Logger.info ("Changing Altitude, moving=" + pc.isMoving() +
|
||||
" Current Loc " + pc.getLoc().getX() + ' ' + pc.getLoc().getZ() +
|
||||
" End Loc " + pc.getEndLoc().getX() + ' ' + pc.getEndLoc().getZ());
|
||||
}
|
||||
if (targetAlt > 60)
|
||||
targetAlt = 60;
|
||||
|
||||
if (msg.up()){
|
||||
pc.update();
|
||||
pc.setDesiredAltitude(targetAlt);
|
||||
pc.setTakeOffTime(System.currentTimeMillis());
|
||||
}
|
||||
|
||||
else{
|
||||
Regions region = PlayerCharacter.InsideBuildingRegionGoingDown(pc);
|
||||
|
||||
|
||||
|
||||
if (region != null){
|
||||
float landingAltitude = 0;
|
||||
Building building = Regions.GetBuildingForRegion(region);
|
||||
if (building != null)
|
||||
landingAltitude = region.lerpY(pc) - building.getLoc().y;
|
||||
|
||||
if (landingAltitude >= targetAlt){
|
||||
pc.landingRegion = region;
|
||||
pc.landingAltitude = landingAltitude;
|
||||
pc.setDesiredAltitude(landingAltitude);
|
||||
}else{
|
||||
pc.landingRegion = null;
|
||||
pc.setDesiredAltitude(targetAlt);
|
||||
}
|
||||
|
||||
|
||||
}else
|
||||
pc.setDesiredAltitude(targetAlt);
|
||||
pc.setAltitude(startAlt);
|
||||
pc.setDesiredAltitude(targetAlt);
|
||||
} else {
|
||||
msg.setStartAlt(pc.getAltitude());
|
||||
targetAlt = pc.getAltitude() + amount;
|
||||
if (targetAlt > 60)
|
||||
targetAlt = 60;
|
||||
}
|
||||
} else {
|
||||
msg.setStartAlt(pc.getAltitude());
|
||||
|
||||
pc.update();
|
||||
|
||||
|
||||
pc.setTakeOffTime(System.currentTimeMillis());
|
||||
}
|
||||
targetAlt = pc.getAltitude() + amount;
|
||||
if (targetAlt > 60)
|
||||
targetAlt = 60;
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
msg.setStartAlt(pc.getAltitude());
|
||||
targetAlt = pc.getAltitude() - amount;
|
||||
if (targetAlt < 0)
|
||||
targetAlt = 0;
|
||||
}
|
||||
msg.setTargetAlt(targetAlt);
|
||||
if (pc.getAltitude() < 1 && targetAlt > pc.getAltitude()) {
|
||||
// char is on the ground and is about to start flight
|
||||
if (pc.getStamina() < 10) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Add timer for height change cooldown, this also tells getLoc we are not moving
|
||||
//MovementManager.addChangeAltitudeTimer(pc, msg.getStartAlt(), msg.getTargetAlt(), (int)((MBServerStatics.HEIGHT_CHANGE_TIMER_MS * amount) + 100 ) );
|
||||
if (MBServerStatics.MOVEMENT_SYNC_DEBUG) {
|
||||
Logger.info("Changing Altitude, moving=" + pc.isMoving() +
|
||||
" Current Loc " + pc.getLoc().getX() + ' ' + pc.getLoc().getZ() +
|
||||
" End Loc " + pc.getEndLoc().getX() + ' ' + pc.getEndLoc().getZ());
|
||||
}
|
||||
|
||||
// Add flight timer job to check stam and ground you when you run out
|
||||
//MovementManager.addFlightTimer(pc, msg, MBServerStatics.FLY_FREQUENCY_MS);
|
||||
//Send change altitude to all in range
|
||||
DispatchMessage.dispatchMsgToInterestArea(pc, msg, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, false);
|
||||
|
||||
|
||||
if (msg.up()) {
|
||||
pc.update();
|
||||
pc.setDesiredAltitude(targetAlt);
|
||||
pc.setTakeOffTime(System.currentTimeMillis());
|
||||
} else {
|
||||
Regions region = PlayerCharacter.InsideBuildingRegionGoingDown(pc);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (region != null) {
|
||||
float landingAltitude = 0;
|
||||
Building building = Regions.GetBuildingForRegion(region);
|
||||
if (building != null)
|
||||
landingAltitude = region.lerpY(pc) - building.getLoc().y;
|
||||
|
||||
if (landingAltitude >= targetAlt) {
|
||||
pc.landingRegion = region;
|
||||
pc.landingAltitude = landingAltitude;
|
||||
pc.setDesiredAltitude(landingAltitude);
|
||||
} else {
|
||||
pc.landingRegion = null;
|
||||
pc.setDesiredAltitude(targetAlt);
|
||||
}
|
||||
|
||||
|
||||
} else
|
||||
pc.setDesiredAltitude(targetAlt);
|
||||
|
||||
pc.update();
|
||||
|
||||
|
||||
pc.setTakeOffTime(System.currentTimeMillis());
|
||||
}
|
||||
|
||||
|
||||
// Add timer for height change cooldown, this also tells getLoc we are not moving
|
||||
//MovementManager.addChangeAltitudeTimer(pc, msg.getStartAlt(), msg.getTargetAlt(), (int)((MBServerStatics.HEIGHT_CHANGE_TIMER_MS * amount) + 100 ) );
|
||||
|
||||
// Add flight timer job to check stam and ground you when you run out
|
||||
//MovementManager.addFlightTimer(pc, msg, MBServerStatics.FLY_FREQUENCY_MS);
|
||||
//Send change altitude to all in range
|
||||
DispatchMessage.dispatchMsgToInterestArea(pc, msg, DispatchChannel.PRIMARY, MBServerStatics.CHARACTER_LOAD_RANGE, true, false);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -28,120 +28,113 @@ import engine.objects.PlayerCharacter;
|
||||
|
||||
public class ChangeGuildLeaderHandler extends AbstractClientMsgHandler {
|
||||
|
||||
public ChangeGuildLeaderHandler() {
|
||||
super(ChangeGuildLeaderMsg.class);
|
||||
}
|
||||
public ChangeGuildLeaderHandler() {
|
||||
super(ChangeGuildLeaderMsg.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
|
||||
ChangeGuildLeaderMsg msg;
|
||||
PlayerCharacter sourcePlayer;
|
||||
PlayerCharacter targetPlayer;
|
||||
City city;
|
||||
ChangeGuildLeaderMsg msg;
|
||||
PlayerCharacter sourcePlayer;
|
||||
PlayerCharacter targetPlayer;
|
||||
City city;
|
||||
|
||||
msg = (ChangeGuildLeaderMsg) baseMsg;
|
||||
sourcePlayer = origin.getPlayerCharacter();
|
||||
if (sourcePlayer == null)
|
||||
return true;
|
||||
if (GuildStatusController.isGuildLeader(sourcePlayer.getGuildStatus()) == false)
|
||||
return true;
|
||||
msg = (ChangeGuildLeaderMsg) baseMsg;
|
||||
sourcePlayer = origin.getPlayerCharacter();
|
||||
if (sourcePlayer == null)
|
||||
return true;
|
||||
if (GuildStatusController.isGuildLeader(sourcePlayer.getGuildStatus()) == false)
|
||||
return true;
|
||||
|
||||
|
||||
Guild glGuild = sourcePlayer.getGuild();
|
||||
|
||||
Guild glGuild = sourcePlayer.getGuild();
|
||||
if (glGuild == null)
|
||||
return true;
|
||||
|
||||
if (glGuild == null)
|
||||
return true;
|
||||
|
||||
if (!glGuild.isGuildLeader(sourcePlayer.getObjectUUID()))
|
||||
return true;
|
||||
targetPlayer = (PlayerCharacter) DbManager.getObject(GameObjectType.PlayerCharacter, msg.getTargetID());
|
||||
if (!glGuild.isGuildLeader(sourcePlayer.getObjectUUID()))
|
||||
return true;
|
||||
targetPlayer = (PlayerCharacter) DbManager.getObject(GameObjectType.PlayerCharacter, msg.getTargetID());
|
||||
|
||||
|
||||
if (targetPlayer == null)
|
||||
return true;
|
||||
if (targetPlayer == null)
|
||||
return true;
|
||||
|
||||
if (GuildStatusController.isGuildLeader(targetPlayer.getGuildStatus()))
|
||||
return true;
|
||||
if (GuildStatusController.isGuildLeader(targetPlayer.getGuildStatus()))
|
||||
return true;
|
||||
|
||||
if (!Guild.sameGuild(sourcePlayer.getGuild(),targetPlayer.getGuild()))
|
||||
return false;
|
||||
if (!Guild.sameGuild(sourcePlayer.getGuild(), targetPlayer.getGuild()))
|
||||
return false;
|
||||
|
||||
|
||||
//updateSource will generate a new promote/demote screen for sourcePlayer
|
||||
//updateTarget will sync guild info for the target and all players in range
|
||||
//updateSource will generate a new promote/demote screen for sourcePlayer
|
||||
//updateTarget will sync guild info for the target and all players in range
|
||||
|
||||
|
||||
String targetName = null;
|
||||
boolean isMale = true;
|
||||
boolean updateTarget;
|
||||
|
||||
Enum.GuildType t = Enum.GuildType.getGuildTypeFromInt(sourcePlayer.getGuild().getCharter());
|
||||
|
||||
|
||||
String targetName = null;
|
||||
boolean isMale = true;
|
||||
boolean updateTarget;
|
||||
if (!DbManager.GuildQueries.SET_GUILD_LEADER(targetPlayer.getObjectUUID(), glGuild.getObjectUUID())) {
|
||||
ChatManager.chatGuildError(sourcePlayer, "Failed to change guild leader!");
|
||||
return false;
|
||||
}
|
||||
|
||||
Enum.GuildType t = Enum.GuildType.getGuildTypeFromInt(sourcePlayer.getGuild().getCharter());
|
||||
glGuild.setGuildLeader(targetPlayer);
|
||||
|
||||
|
||||
if (!DbManager.GuildQueries.SET_GUILD_LEADER(targetPlayer.getObjectUUID(), glGuild.getObjectUUID())){
|
||||
ChatManager.chatGuildError(sourcePlayer, "Failed to change guild leader!");
|
||||
return false;
|
||||
}
|
||||
if (glGuild.getOwnedCity() != null) {
|
||||
city = glGuild.getOwnedCity();
|
||||
if (!city.transferGuildLeader(targetPlayer)) {
|
||||
ChatManager.chatGuildError(sourcePlayer, "Failed to Transfer City Objects. Contact CCR!");
|
||||
return false;
|
||||
}
|
||||
|
||||
glGuild.setGuildLeader(targetPlayer);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (glGuild.getOwnedCity() != null){
|
||||
city = glGuild.getOwnedCity();
|
||||
if (!city.transferGuildLeader(targetPlayer)){
|
||||
ChatManager.chatGuildError(sourcePlayer, "Failed to Transfer City Objects. Contact CCR!");
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
targetPlayer.setGuildLeader(true);
|
||||
targetPlayer.setInnerCouncil(true);
|
||||
targetPlayer.setFullMember(true);
|
||||
targetPlayer.incVer();
|
||||
targetName = targetPlayer.getFirstName();
|
||||
updateTarget = true;
|
||||
|
||||
|
||||
ChatManager.chatGuildInfo(sourcePlayer.getGuild(),
|
||||
targetName + " has been promoted to "
|
||||
+ "guild leader!");
|
||||
|
||||
targetPlayer.setGuildLeader(true);
|
||||
targetPlayer.setInnerCouncil(true);
|
||||
targetPlayer.setFullMember(true);
|
||||
targetPlayer.incVer();
|
||||
targetName = targetPlayer.getFirstName();
|
||||
updateTarget = true;
|
||||
//These values record a change, not the new value...
|
||||
|
||||
|
||||
ChatManager.chatGuildInfo(sourcePlayer.getGuild(),
|
||||
targetName + " has been promoted to "
|
||||
+ "guild leader!");
|
||||
//updateOldGuildLeader
|
||||
sourcePlayer.setInnerCouncil(true);
|
||||
sourcePlayer.setFullMember(true);
|
||||
sourcePlayer.setGuildLeader(false);
|
||||
sourcePlayer.incVer();
|
||||
|
||||
//These values record a change, not the new value...
|
||||
GuildInfoMsg guildInfoMsg = new GuildInfoMsg(sourcePlayer, sourcePlayer.getGuild(), 2);
|
||||
Dispatch dispatch = Dispatch.borrow(sourcePlayer, guildInfoMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, engine.Enum.DispatchChannel.SECONDARY);
|
||||
|
||||
GuildListMsg guildListMsg = new GuildListMsg(sourcePlayer.getGuild());
|
||||
|
||||
dispatch = Dispatch.borrow(sourcePlayer, guildListMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, engine.Enum.DispatchChannel.SECONDARY);
|
||||
|
||||
|
||||
if (targetPlayer != null) {
|
||||
if (updateTarget)
|
||||
DispatchMessage.sendToAllInRange(targetPlayer, new GuildInfoMsg(targetPlayer, targetPlayer.getGuild(), 2));
|
||||
}
|
||||
|
||||
//updateOldGuildLeader
|
||||
sourcePlayer.setInnerCouncil(true);
|
||||
sourcePlayer.setFullMember(true);
|
||||
sourcePlayer.setGuildLeader(false);
|
||||
sourcePlayer.incVer();
|
||||
|
||||
GuildInfoMsg guildInfoMsg = new GuildInfoMsg(sourcePlayer, sourcePlayer.getGuild(), 2);
|
||||
Dispatch dispatch = Dispatch.borrow(sourcePlayer, guildInfoMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, engine.Enum.DispatchChannel.SECONDARY);
|
||||
return true;
|
||||
|
||||
GuildListMsg guildListMsg = new GuildListMsg(sourcePlayer.getGuild());
|
||||
|
||||
dispatch = Dispatch.borrow(sourcePlayer, guildListMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, engine.Enum.DispatchChannel.SECONDARY);
|
||||
|
||||
|
||||
|
||||
if (targetPlayer != null) {
|
||||
if (updateTarget)
|
||||
DispatchMessage.sendToAllInRange(targetPlayer, new GuildInfoMsg(targetPlayer, targetPlayer.getGuild(), 2));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -7,9 +7,6 @@
|
||||
// www.magicbane.com
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
@@ -57,12 +54,12 @@ public class ChangeRankHandler extends AbstractClientMsgHandler {
|
||||
if (msg.getPlayerUUID() == 0)
|
||||
targetPlayer = sourcePlayer;
|
||||
|
||||
//updateSource will generate a new promote/demote screen for sourcePlayer
|
||||
//updateSource will generate a new promote/demote screen for sourcePlayer
|
||||
//updateTarget will sync guild info for the target and all players in range
|
||||
|
||||
|
||||
boolean updateSource = false, updateTarget = false;
|
||||
|
||||
if (sourcePlayer == null ||GuildStatusController.isInnerCouncil(sourcePlayer.getGuildStatus()) == false)
|
||||
if (sourcePlayer == null || GuildStatusController.isInnerCouncil(sourcePlayer.getGuildStatus()) == false)
|
||||
return true;
|
||||
|
||||
if (targetPlayer != null && (targetPlayer.getGuild().equals(sourcePlayer.getGuild()) == false))
|
||||
@@ -88,8 +85,8 @@ public class ChangeRankHandler extends AbstractClientMsgHandler {
|
||||
|
||||
ChatManager.chatGuildInfo(sourcePlayer.getGuild(),
|
||||
targetName + " has been "
|
||||
+ ((msg.getNewRank() > msg.getPreviousRank()) ? "pro" : "de") + "moted to "
|
||||
+ t.getRankForGender(msg.getNewRank(), isMale) + '!');
|
||||
+ ((msg.getNewRank() > msg.getPreviousRank()) ? "pro" : "de") + "moted to "
|
||||
+ t.getRankForGender(msg.getNewRank(), isMale) + '!');
|
||||
updateSource = true;
|
||||
}
|
||||
|
||||
@@ -117,10 +114,10 @@ public class ChangeRankHandler extends AbstractClientMsgHandler {
|
||||
taxUpdate = (GuildStatusController.isTaxCollector(targetPlayer.getGuildStatus()) != (msg.getTax() > 0)) && GuildStatusController.isGuildLeader(sourcePlayer.getGuildStatus());
|
||||
|
||||
//This logic branch only executes if targetPlayer has passed a null check...
|
||||
if (icUpdate){
|
||||
targetPlayer.setInnerCouncil(msg.getIc() > 0);
|
||||
targetPlayer.setFullMember(true);
|
||||
targetPlayer.incVer();
|
||||
if (icUpdate) {
|
||||
targetPlayer.setInnerCouncil(msg.getIc() > 0);
|
||||
targetPlayer.setFullMember(true);
|
||||
targetPlayer.incVer();
|
||||
}
|
||||
|
||||
if (recruitUpdate)
|
||||
@@ -136,8 +133,8 @@ public class ChangeRankHandler extends AbstractClientMsgHandler {
|
||||
if (icUpdate) {
|
||||
ChatManager.chatGuildInfo(sourcePlayer.getGuild(),
|
||||
(msg.getIc() > 0)
|
||||
? targetName + " has been appointed to the inner council."
|
||||
: targetName + " is no longer a member of the inner council.");
|
||||
? targetName + " has been appointed to the inner council."
|
||||
: targetName + " is no longer a member of the inner council.");
|
||||
|
||||
updateSource = true;
|
||||
updateTarget = true;
|
||||
|
||||
@@ -20,104 +20,104 @@ import org.pmw.tinylog.Logger;
|
||||
*/
|
||||
public class ChannelMuteMsgHandler extends AbstractClientMsgHandler {
|
||||
|
||||
// Instance variables
|
||||
// Instance variables
|
||||
|
||||
public ChannelMuteMsgHandler() {
|
||||
super(ChatFilterMsg.class);
|
||||
public ChannelMuteMsgHandler() {
|
||||
super(ChatFilterMsg.class);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void AbandonSingleAsset(PlayerCharacter sourcePlayer,
|
||||
private static void AbandonSingleAsset(PlayerCharacter sourcePlayer,
|
||||
Building targetBuilding) {
|
||||
|
||||
// Transfer the building asset ownership and refresh all clients
|
||||
// Transfer the building asset ownership and refresh all clients
|
||||
|
||||
DbManager.BuildingQueries.CLEAR_FRIENDS_LIST(targetBuilding.getObjectUUID());
|
||||
targetBuilding.getFriends().clear();
|
||||
DbManager.BuildingQueries.CLEAR_FRIENDS_LIST(targetBuilding.getObjectUUID());
|
||||
targetBuilding.getFriends().clear();
|
||||
|
||||
DbManager.BuildingQueries.CLEAR_CONDEMNED_LIST(targetBuilding.getObjectUUID());
|
||||
targetBuilding.getCondemned().clear();
|
||||
targetBuilding.setOwner(null);
|
||||
targetBuilding.refreshGuild();
|
||||
}
|
||||
DbManager.BuildingQueries.CLEAR_CONDEMNED_LIST(targetBuilding.getObjectUUID());
|
||||
targetBuilding.getCondemned().clear();
|
||||
targetBuilding.setOwner(null);
|
||||
targetBuilding.refreshGuild();
|
||||
}
|
||||
|
||||
private void AbandonAllCityObjects(PlayerCharacter sourcePlayer,
|
||||
Building targetBuilding) {
|
||||
Guild sourceGuild;
|
||||
Zone cityZone;
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
|
||||
sourceGuild = sourcePlayer.getGuild();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (sourceGuild == null)
|
||||
return;
|
||||
private void AbandonAllCityObjects(PlayerCharacter sourcePlayer,
|
||||
Building targetBuilding) {
|
||||
Guild sourceGuild;
|
||||
Zone cityZone;
|
||||
|
||||
if (sourceGuild.getSubGuildList().size() > 0) {
|
||||
ChatManager.chatCityError(sourcePlayer, "You Cannot abandon a nation city.");
|
||||
return;
|
||||
}
|
||||
sourceGuild = sourcePlayer.getGuild();
|
||||
|
||||
cityZone = ZoneManager.findSmallestZone(targetBuilding.getLoc());
|
||||
if (sourceGuild == null)
|
||||
return;
|
||||
|
||||
// Can't abandon a tree not within a player city zone
|
||||
if (cityZone.isPlayerCity() == false)
|
||||
return;
|
||||
if (sourceGuild.getSubGuildList().size() > 0) {
|
||||
ChatManager.chatCityError(sourcePlayer, "You Cannot abandon a nation city.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (targetBuilding.getCity().hasBeenTransfered == true) {
|
||||
ChatManager.chatCityError(sourcePlayer, "City can only be abandoned once per rebooting.");
|
||||
return;
|
||||
}
|
||||
cityZone = ZoneManager.findSmallestZone(targetBuilding.getLoc());
|
||||
|
||||
// Guild no longer owns his tree.
|
||||
if (!DbManager.GuildQueries.SET_GUILD_OWNED_CITY(sourceGuild.getObjectUUID(), 0)) {
|
||||
Logger.error( "Failed to update Owned City to Database");
|
||||
return;
|
||||
}
|
||||
// Can't abandon a tree not within a player city zone
|
||||
if (cityZone.isPlayerCity() == false)
|
||||
return;
|
||||
|
||||
sourceGuild.setCityUUID(0);
|
||||
sourceGuild.setGuildState(GuildState.Errant);
|
||||
sourceGuild.setNation(null);
|
||||
if (targetBuilding.getCity().hasBeenTransfered == true) {
|
||||
ChatManager.chatCityError(sourcePlayer, "City can only be abandoned once per rebooting.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Transfer the city assets
|
||||
TransferCityAssets(sourcePlayer, targetBuilding);
|
||||
// Guild no longer owns his tree.
|
||||
if (!DbManager.GuildQueries.SET_GUILD_OWNED_CITY(sourceGuild.getObjectUUID(), 0)) {
|
||||
Logger.error("Failed to update Owned City to Database");
|
||||
return;
|
||||
}
|
||||
|
||||
GuildManager.updateAllGuildTags(sourceGuild);
|
||||
GuildManager.updateAllGuildBinds(sourceGuild, null);
|
||||
sourceGuild.setCityUUID(0);
|
||||
sourceGuild.setGuildState(GuildState.Errant);
|
||||
sourceGuild.setNation(null);
|
||||
|
||||
}
|
||||
// Transfer the city assets
|
||||
TransferCityAssets(sourcePlayer, targetBuilding);
|
||||
|
||||
private void TransferCityAssets(PlayerCharacter sourcePlayer,
|
||||
Building cityTOL) {
|
||||
GuildManager.updateAllGuildTags(sourceGuild);
|
||||
GuildManager.updateAllGuildBinds(sourceGuild, null);
|
||||
|
||||
Zone cityZone;
|
||||
}
|
||||
|
||||
// Build list of buildings within this parent zone
|
||||
cityZone = ZoneManager.findSmallestZone(cityTOL.getLoc());
|
||||
private void TransferCityAssets(PlayerCharacter sourcePlayer,
|
||||
Building cityTOL) {
|
||||
|
||||
for (Building cityBuilding : cityZone.zoneBuildingSet) {
|
||||
Zone cityZone;
|
||||
|
||||
Blueprint cityBlueprint;
|
||||
cityBlueprint = cityBuilding.getBlueprint();
|
||||
// Build list of buildings within this parent zone
|
||||
cityZone = ZoneManager.findSmallestZone(cityTOL.getLoc());
|
||||
|
||||
// Buildings without blueprints cannot be abandoned
|
||||
if (cityBlueprint == null)
|
||||
continue;
|
||||
for (Building cityBuilding : cityZone.zoneBuildingSet) {
|
||||
|
||||
// Transfer ownership of valid city assets
|
||||
if ((cityBlueprint.getBuildingGroup() == BuildingGroup.TOL)
|
||||
|| (cityBlueprint.getBuildingGroup() == BuildingGroup.SPIRE)
|
||||
|| (cityBlueprint.getBuildingGroup() == BuildingGroup.BARRACK)
|
||||
|| (cityBlueprint.isWallPiece())
|
||||
|| (cityBuilding.getBlueprint().getBuildingGroup() == BuildingGroup.SHRINE))
|
||||
AbandonSingleAsset(sourcePlayer, cityBuilding);
|
||||
Blueprint cityBlueprint;
|
||||
cityBlueprint = cityBuilding.getBlueprint();
|
||||
|
||||
}
|
||||
// Buildings without blueprints cannot be abandoned
|
||||
if (cityBlueprint == null)
|
||||
continue;
|
||||
|
||||
}
|
||||
// Transfer ownership of valid city assets
|
||||
if ((cityBlueprint.getBuildingGroup() == BuildingGroup.TOL)
|
||||
|| (cityBlueprint.getBuildingGroup() == BuildingGroup.SPIRE)
|
||||
|| (cityBlueprint.getBuildingGroup() == BuildingGroup.BARRACK)
|
||||
|| (cityBlueprint.isWallPiece())
|
||||
|| (cityBuilding.getBlueprint().getBuildingGroup() == BuildingGroup.SHRINE))
|
||||
AbandonSingleAsset(sourcePlayer, cityBuilding);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -22,48 +22,48 @@ import engine.objects.PlayerCharacter;
|
||||
|
||||
public class CityChoiceMsgHandler extends AbstractClientMsgHandler {
|
||||
|
||||
public CityChoiceMsgHandler() {
|
||||
super(CityChoiceMsg.class);
|
||||
}
|
||||
public CityChoiceMsgHandler() {
|
||||
super(CityChoiceMsg.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
|
||||
PlayerCharacter player = origin.getPlayerCharacter();
|
||||
Dispatch dispatch;
|
||||
PlayerCharacter player = origin.getPlayerCharacter();
|
||||
Dispatch dispatch;
|
||||
|
||||
CityChoiceMsg msg = (CityChoiceMsg) baseMsg;
|
||||
CityChoiceMsg msg = (CityChoiceMsg) baseMsg;
|
||||
|
||||
if (player == null)
|
||||
return true;
|
||||
if (player == null)
|
||||
return true;
|
||||
|
||||
switch (msg.getMsgType()) {
|
||||
case 5:
|
||||
TeleportRepledgeListMsg trlm = new TeleportRepledgeListMsg(player, false);
|
||||
trlm.configure();
|
||||
dispatch = Dispatch.borrow(player, trlm);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
break;
|
||||
case 3:
|
||||
City city = City.getCity(msg.getCityID());
|
||||
switch (msg.getMsgType()) {
|
||||
case 5:
|
||||
TeleportRepledgeListMsg trlm = new TeleportRepledgeListMsg(player, false);
|
||||
trlm.configure();
|
||||
dispatch = Dispatch.borrow(player, trlm);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
break;
|
||||
case 3:
|
||||
City city = City.getCity(msg.getCityID());
|
||||
|
||||
if (city == null)
|
||||
return true;
|
||||
if (city == null)
|
||||
return true;
|
||||
|
||||
Guild cityGuild = city.getGuild();
|
||||
Guild cityGuild = city.getGuild();
|
||||
|
||||
if (cityGuild == null)
|
||||
return true;
|
||||
if (cityGuild == null)
|
||||
return true;
|
||||
|
||||
if (player.getLevel() < cityGuild.getRepledgeMin() || player.getLevel() > cityGuild.getRepledgeMax())
|
||||
return true;
|
||||
if (player.getLevel() < cityGuild.getRepledgeMin() || player.getLevel() > cityGuild.getRepledgeMax())
|
||||
return true;
|
||||
|
||||
//if repledge, reguild the player but set his building now.
|
||||
//if repledge, reguild the player but set his building now.
|
||||
|
||||
GuildManager.joinGuild(player, cityGuild, city.getObjectUUID(), Enum.GuildHistoryType.JOIN);
|
||||
break;
|
||||
}
|
||||
GuildManager.joinGuild(player, cityGuild, city.getObjectUUID(), Enum.GuildHistoryType.JOIN);
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -64,10 +64,10 @@ public class CityDataHandler extends AbstractClientMsgHandler {
|
||||
// If the hotZone has changed then update the client's map accordingly.
|
||||
|
||||
if (playerCharacter.getTimeStamp("hotzoneupdate") <= ZoneManager.hotZoneLastUpdate.toEpochMilli() && ZoneManager.hotZone != null) {
|
||||
HotzoneChangeMsg hotzoneChangeMsg = new HotzoneChangeMsg(Enum.GameObjectType.Zone.ordinal(), ZoneManager.hotZone.getObjectUUID());
|
||||
dispatch = Dispatch.borrow(playerCharacter, hotzoneChangeMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
playerCharacter.setTimeStamp("hotzoneupdate", System.currentTimeMillis() - 100);
|
||||
HotzoneChangeMsg hotzoneChangeMsg = new HotzoneChangeMsg(Enum.GameObjectType.Zone.ordinal(), ZoneManager.hotZone.getObjectUUID());
|
||||
dispatch = Dispatch.borrow(playerCharacter, hotzoneChangeMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
playerCharacter.setTimeStamp("hotzoneupdate", System.currentTimeMillis() - 100);
|
||||
}
|
||||
|
||||
// Serialize the realms for this map
|
||||
|
||||
@@ -37,103 +37,103 @@ public class ClaimAssetMsgHandler extends AbstractClientMsgHandler {
|
||||
// Instance variables
|
||||
|
||||
private final ReentrantReadWriteLock claimLock = new ReentrantReadWriteLock();
|
||||
|
||||
public ClaimAssetMsgHandler() {
|
||||
super(ClaimAssetMsg.class);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
|
||||
// Member variable declaration
|
||||
this.claimLock.writeLock().lock();
|
||||
|
||||
try{
|
||||
PlayerCharacter sourcePlayer;
|
||||
Building targetBuilding;
|
||||
Blueprint blueprint;
|
||||
ClaimAssetMsg msg;
|
||||
int targetUUID;
|
||||
|
||||
msg = (ClaimAssetMsg) baseMsg;
|
||||
targetUUID = msg.getUUID();
|
||||
|
||||
sourcePlayer = origin.getPlayerCharacter();
|
||||
targetBuilding = BuildingManager.getBuildingFromCache(targetUUID);
|
||||
public ClaimAssetMsgHandler() {
|
||||
super(ClaimAssetMsg.class);
|
||||
|
||||
// Oops! *** Refactor: Log error
|
||||
|
||||
if ((sourcePlayer == null) ||
|
||||
(targetBuilding == null))
|
||||
return true;
|
||||
}
|
||||
|
||||
// Player must be reasonably close to building in order to claim
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
|
||||
if (sourcePlayer.getLoc().distanceSquared2D(targetBuilding.getLoc()) > sqr(100))
|
||||
return true;
|
||||
// Member variable declaration
|
||||
this.claimLock.writeLock().lock();
|
||||
|
||||
// Early exit if object to be claimed is not errant
|
||||
|
||||
if (targetBuilding.getOwnerUUID() != 0)
|
||||
return true;
|
||||
try {
|
||||
PlayerCharacter sourcePlayer;
|
||||
Building targetBuilding;
|
||||
Blueprint blueprint;
|
||||
ClaimAssetMsg msg;
|
||||
int targetUUID;
|
||||
|
||||
msg = (ClaimAssetMsg) baseMsg;
|
||||
targetUUID = msg.getUUID();
|
||||
|
||||
sourcePlayer = origin.getPlayerCharacter();
|
||||
targetBuilding = BuildingManager.getBuildingFromCache(targetUUID);
|
||||
|
||||
// Oops! *** Refactor: Log error
|
||||
|
||||
if ((sourcePlayer == null) ||
|
||||
(targetBuilding == null))
|
||||
return true;
|
||||
|
||||
// Player must be reasonably close to building in order to claim
|
||||
|
||||
if (sourcePlayer.getLoc().distanceSquared2D(targetBuilding.getLoc()) > sqr(100))
|
||||
return true;
|
||||
|
||||
// Early exit if object to be claimed is not errant
|
||||
|
||||
if (targetBuilding.getOwnerUUID() != 0)
|
||||
return true;
|
||||
|
||||
|
||||
// Early exit if UUID < the last database derived building UUID.
|
||||
// Early exit if UUID < the last database derived building UUID.
|
||||
|
||||
if (targetBuilding.getProtectionState() == Enum.ProtectionState.NPC) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Early exit if claiming player does not
|
||||
// have a guild.
|
||||
|
||||
// Errant players cannot claim
|
||||
|
||||
if (sourcePlayer.getGuild().isEmptyGuild())
|
||||
return true;
|
||||
|
||||
// Can't claim an object without a blueprint
|
||||
|
||||
if (targetBuilding.getBlueprintUUID() == 0)
|
||||
return true;
|
||||
|
||||
blueprint = targetBuilding.getBlueprint();
|
||||
|
||||
//cant claim mine this way.
|
||||
if (blueprint.getBuildingGroup() == BuildingGroup.MINE)
|
||||
return true;
|
||||
|
||||
// Players cannot claim shrines
|
||||
|
||||
if ((targetBuilding.getBlueprint().getBuildingGroup() == BuildingGroup.SHRINE))
|
||||
return true;
|
||||
|
||||
// Can't claim a tree if your guild already owns one
|
||||
// *** Refactor : Send error to player here
|
||||
|
||||
if ((sourcePlayer.getGuild().isNation()) &&
|
||||
(blueprint.getBuildingGroup() == BuildingGroup.TOL))
|
||||
return true;
|
||||
|
||||
// Process the transfer of the building(s)
|
||||
|
||||
if (blueprint.getBuildingGroup() == BuildingGroup.TOL) {
|
||||
targetBuilding.getCity().claim(sourcePlayer);
|
||||
|
||||
// Push transfer of city to data warehouse
|
||||
CityRecord cityRecord = CityRecord.borrow(targetBuilding.getCity(), Enum.RecordEventType.TRANSFER);
|
||||
DataWarehouse.pushToWarehouse(cityRecord);
|
||||
|
||||
} else
|
||||
targetBuilding.claim(sourcePlayer);
|
||||
|
||||
} catch(Exception e){
|
||||
Logger.error("ClaimAssetMsgHandler", e.getMessage());
|
||||
}finally{
|
||||
this.claimLock.writeLock().unlock();
|
||||
if (targetBuilding.getProtectionState() == Enum.ProtectionState.NPC) {
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
|
||||
// Early exit if claiming player does not
|
||||
// have a guild.
|
||||
|
||||
// Errant players cannot claim
|
||||
|
||||
if (sourcePlayer.getGuild().isEmptyGuild())
|
||||
return true;
|
||||
|
||||
// Can't claim an object without a blueprint
|
||||
|
||||
if (targetBuilding.getBlueprintUUID() == 0)
|
||||
return true;
|
||||
|
||||
blueprint = targetBuilding.getBlueprint();
|
||||
|
||||
//cant claim mine this way.
|
||||
if (blueprint.getBuildingGroup() == BuildingGroup.MINE)
|
||||
return true;
|
||||
|
||||
// Players cannot claim shrines
|
||||
|
||||
if ((targetBuilding.getBlueprint().getBuildingGroup() == BuildingGroup.SHRINE))
|
||||
return true;
|
||||
|
||||
// Can't claim a tree if your guild already owns one
|
||||
// *** Refactor : Send error to player here
|
||||
|
||||
if ((sourcePlayer.getGuild().isNation()) &&
|
||||
(blueprint.getBuildingGroup() == BuildingGroup.TOL))
|
||||
return true;
|
||||
|
||||
// Process the transfer of the building(s)
|
||||
|
||||
if (blueprint.getBuildingGroup() == BuildingGroup.TOL) {
|
||||
targetBuilding.getCity().claim(sourcePlayer);
|
||||
|
||||
// Push transfer of city to data warehouse
|
||||
CityRecord cityRecord = CityRecord.borrow(targetBuilding.getCity(), Enum.RecordEventType.TRANSFER);
|
||||
DataWarehouse.pushToWarehouse(cityRecord);
|
||||
|
||||
} else
|
||||
targetBuilding.claim(sourcePlayer);
|
||||
|
||||
} catch (Exception e) {
|
||||
Logger.error("ClaimAssetMsgHandler", e.getMessage());
|
||||
} finally {
|
||||
this.claimLock.writeLock().unlock();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -31,161 +31,161 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
*/
|
||||
public class ClaimGuildTreeMsgHandler extends AbstractClientMsgHandler {
|
||||
|
||||
// Instance variables
|
||||
// Instance variables
|
||||
|
||||
private final ReentrantReadWriteLock claimLock = new ReentrantReadWriteLock();
|
||||
private static final int RENAME_TREE = 2;
|
||||
private static final int BIND_TREE = 3;
|
||||
private static final int OPEN_CITY = 4;
|
||||
private static final int CLOSE_CITY = 5;
|
||||
private static final int RENAME_TREE = 2;
|
||||
private static final int BIND_TREE = 3;
|
||||
private static final int OPEN_CITY = 4;
|
||||
private static final int CLOSE_CITY = 5;
|
||||
private final ReentrantReadWriteLock claimLock = new ReentrantReadWriteLock();
|
||||
|
||||
public ClaimGuildTreeMsgHandler() {
|
||||
super(ClaimGuildTreeMsg.class);
|
||||
}
|
||||
public ClaimGuildTreeMsgHandler() {
|
||||
super(ClaimGuildTreeMsg.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
|
||||
// Member variable declaration
|
||||
this.claimLock.writeLock().lock();
|
||||
// Member variable declaration
|
||||
this.claimLock.writeLock().lock();
|
||||
|
||||
try{
|
||||
PlayerCharacter sourcePlayer;
|
||||
Building building;
|
||||
Blueprint blueprint;
|
||||
Zone playerZone= null;
|
||||
City playerCity= null;
|
||||
ClaimGuildTreeMsg msg;
|
||||
int targetUUID;
|
||||
Dispatch dispatch;
|
||||
try {
|
||||
PlayerCharacter sourcePlayer;
|
||||
Building building;
|
||||
Blueprint blueprint;
|
||||
Zone playerZone = null;
|
||||
City playerCity = null;
|
||||
ClaimGuildTreeMsg msg;
|
||||
int targetUUID;
|
||||
Dispatch dispatch;
|
||||
|
||||
msg = (ClaimGuildTreeMsg) baseMsg;
|
||||
targetUUID = msg.getTargetID();
|
||||
msg = (ClaimGuildTreeMsg) baseMsg;
|
||||
targetUUID = msg.getTargetID();
|
||||
|
||||
sourcePlayer = origin.getPlayerCharacter();
|
||||
building = BuildingManager.getBuildingFromCache(targetUUID);
|
||||
sourcePlayer = origin.getPlayerCharacter();
|
||||
building = BuildingManager.getBuildingFromCache(targetUUID);
|
||||
|
||||
if (building != null)
|
||||
playerZone = building.getParentZone();
|
||||
if (building != null)
|
||||
playerZone = building.getParentZone();
|
||||
|
||||
if (playerZone != null)
|
||||
playerCity = City.getCity(playerZone.getPlayerCityUUID());
|
||||
if (playerZone != null)
|
||||
playerCity = City.getCity(playerZone.getPlayerCityUUID());
|
||||
|
||||
// Oops! *** Refactor: Log error
|
||||
switch (msg.getMessageType()){
|
||||
case RENAME_TREE:
|
||||
if ((sourcePlayer == null) ||
|
||||
(building == null) || playerZone == null ||playerCity == null)
|
||||
return true;
|
||||
// Oops! *** Refactor: Log error
|
||||
switch (msg.getMessageType()) {
|
||||
case RENAME_TREE:
|
||||
if ((sourcePlayer == null) ||
|
||||
(building == null) || playerZone == null || playerCity == null)
|
||||
return true;
|
||||
|
||||
// Early exit if object to be claimed is not errant
|
||||
// Early exit if object to be claimed is not errant
|
||||
|
||||
if (building.getOwnerUUID() == 0)
|
||||
return true;
|
||||
if (building.getOwnerUUID() == 0)
|
||||
return true;
|
||||
|
||||
// Errant players cannot rename
|
||||
// Errant players cannot rename
|
||||
|
||||
if (sourcePlayer.getGuild().isEmptyGuild())
|
||||
return true;
|
||||
if (sourcePlayer.getGuild().isEmptyGuild())
|
||||
return true;
|
||||
|
||||
// Can't rename an object without a blueprint
|
||||
// Can't rename an object without a blueprint
|
||||
|
||||
if (building.getBlueprintUUID() == 0)
|
||||
return true;
|
||||
if (building.getBlueprintUUID() == 0)
|
||||
return true;
|
||||
|
||||
blueprint = building.getBlueprint();
|
||||
blueprint = building.getBlueprint();
|
||||
|
||||
//can only rename tree this way.
|
||||
if (blueprint.getBuildingGroup() != BuildingGroup.TOL)
|
||||
return true;
|
||||
//can only rename tree this way.
|
||||
if (blueprint.getBuildingGroup() != BuildingGroup.TOL)
|
||||
return true;
|
||||
|
||||
//dont rename if guild is null
|
||||
if (building.getGuild().isEmptyGuild())
|
||||
return true;
|
||||
//dont rename if guild is null
|
||||
if (building.getGuild().isEmptyGuild())
|
||||
return true;
|
||||
|
||||
if (!ManageCityAssetMsgHandler.playerCanManageNotFriends(sourcePlayer, building))
|
||||
return true;
|
||||
if (!ManageCityAssetMsgHandler.playerCanManageNotFriends(sourcePlayer, building))
|
||||
return true;
|
||||
|
||||
|
||||
if (!playerCity.renameCity(msg.getTreeName())){
|
||||
ChatManager.chatSystemError(sourcePlayer, "Failed to rename city!");
|
||||
return true;
|
||||
}
|
||||
if (!playerCity.renameCity(msg.getTreeName())) {
|
||||
ChatManager.chatSystemError(sourcePlayer, "Failed to rename city!");
|
||||
return true;
|
||||
}
|
||||
|
||||
GuildTreeStatusMsg gtsm = new GuildTreeStatusMsg(building,sourcePlayer);
|
||||
gtsm.configure();
|
||||
dispatch = Dispatch.borrow(sourcePlayer, gtsm);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
GuildTreeStatusMsg gtsm = new GuildTreeStatusMsg(building, sourcePlayer);
|
||||
gtsm.configure();
|
||||
dispatch = Dispatch.borrow(sourcePlayer, gtsm);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
|
||||
CityZoneMsg czm = new CityZoneMsg(2,playerZone.getLoc().x, playerZone.getLoc().y, playerZone.getLoc().z, playerCity.getCityName(),playerZone, Enum.CityBoundsType.ZONE.extents, Enum.CityBoundsType.ZONE.extents);
|
||||
DispatchMessage.dispatchMsgToAll(czm);
|
||||
CityZoneMsg czm = new CityZoneMsg(2, playerZone.getLoc().x, playerZone.getLoc().y, playerZone.getLoc().z, playerCity.getCityName(), playerZone, Enum.CityBoundsType.ZONE.extents, Enum.CityBoundsType.ZONE.extents);
|
||||
DispatchMessage.dispatchMsgToAll(czm);
|
||||
|
||||
break;
|
||||
case BIND_TREE:
|
||||
break;
|
||||
case BIND_TREE:
|
||||
|
||||
Guild pcGuild = sourcePlayer.getGuild();
|
||||
Guild pcGuild = sourcePlayer.getGuild();
|
||||
|
||||
//test tree is valid for binding, same guild or same nation
|
||||
if (!Guild.sameNation(pcGuild, building.getGuild())) {
|
||||
//test tree is valid for binding, same guild or same nation
|
||||
if (!Guild.sameNation(pcGuild, building.getGuild())) {
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if (building.getGuild().isEmptyGuild())
|
||||
return true;
|
||||
if (building.getGuild().isEmptyGuild())
|
||||
return true;
|
||||
|
||||
|
||||
//get bind city
|
||||
Zone zone =building.getParentZone();
|
||||
//get bind city
|
||||
Zone zone = building.getParentZone();
|
||||
|
||||
if (zone == null) {
|
||||
ErrorPopupMsg.sendErrorMsg(sourcePlayer, "A Serious error has occurred. Please post details for to ensure transaction integrity");
|
||||
return true;
|
||||
}
|
||||
if (zone == null) {
|
||||
ErrorPopupMsg.sendErrorMsg(sourcePlayer, "A Serious error has occurred. Please post details for to ensure transaction integrity");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (playerCity == null && building.getGuild() != null)
|
||||
playerCity = building.getGuild().getOwnedCity();
|
||||
if (playerCity == null && building.getGuild() != null)
|
||||
playerCity = building.getGuild().getOwnedCity();
|
||||
|
||||
if (playerCity == null)
|
||||
return true;
|
||||
if (playerCity == null)
|
||||
return true;
|
||||
|
||||
|
||||
sourcePlayer.setBindBuildingID(building.getObjectUUID());
|
||||
dispatch = Dispatch.borrow(sourcePlayer, msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
break;
|
||||
case OPEN_CITY:
|
||||
case CLOSE_CITY:
|
||||
if ((sourcePlayer == null) ||
|
||||
(building == null) || playerZone == null ||playerCity == null)
|
||||
return true;
|
||||
|
||||
if (!ManageCityAssetMsgHandler.playerCanManageNotFriends(sourcePlayer, building))
|
||||
return true;
|
||||
sourcePlayer.setBindBuildingID(building.getObjectUUID());
|
||||
dispatch = Dispatch.borrow(sourcePlayer, msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
break;
|
||||
case OPEN_CITY:
|
||||
case CLOSE_CITY:
|
||||
if ((sourcePlayer == null) ||
|
||||
(building == null) || playerZone == null || playerCity == null)
|
||||
return true;
|
||||
|
||||
boolean open = (msg.getMessageType() == OPEN_CITY);
|
||||
if (!ManageCityAssetMsgHandler.playerCanManageNotFriends(sourcePlayer, building))
|
||||
return true;
|
||||
|
||||
if (!playerCity.openCity(open)){
|
||||
ErrorPopupMsg.sendErrorMsg(sourcePlayer, "A Serious error has occurred. Please post details for to ensure transaction integrity");
|
||||
return true;
|
||||
}
|
||||
boolean open = (msg.getMessageType() == OPEN_CITY);
|
||||
|
||||
dispatch = Dispatch.borrow(sourcePlayer, msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (!playerCity.openCity(open)) {
|
||||
ErrorPopupMsg.sendErrorMsg(sourcePlayer, "A Serious error has occurred. Please post details for to ensure transaction integrity");
|
||||
return true;
|
||||
}
|
||||
|
||||
} catch(Exception e){
|
||||
Logger.error( e.getMessage());
|
||||
}finally{
|
||||
try{
|
||||
this.claimLock.writeLock().unlock();
|
||||
}catch(Exception e){
|
||||
Logger.info("failClaimsync");
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
dispatch = Dispatch.borrow(sourcePlayer, msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
Logger.error(e.getMessage());
|
||||
} finally {
|
||||
try {
|
||||
this.claimLock.writeLock().unlock();
|
||||
} catch (Exception e) {
|
||||
Logger.info("failClaimsync");
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -19,90 +19,90 @@ import engine.objects.*;
|
||||
|
||||
public class DestroyBuildingHandler extends AbstractClientMsgHandler {
|
||||
|
||||
public DestroyBuildingHandler() {
|
||||
super(DestroyBuildingMsg.class);
|
||||
}
|
||||
public DestroyBuildingHandler() {
|
||||
super(DestroyBuildingMsg.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
|
||||
PlayerCharacter pc = origin.getPlayerCharacter();
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
|
||||
DestroyBuildingMsg msg;
|
||||
msg = (DestroyBuildingMsg) baseMsg;
|
||||
Bane bane = null;
|
||||
Blueprint blueprint;
|
||||
PlayerCharacter pc = origin.getPlayerCharacter();
|
||||
|
||||
int buildingUUID = msg.getUUID();
|
||||
DestroyBuildingMsg msg;
|
||||
msg = (DestroyBuildingMsg) baseMsg;
|
||||
Bane bane = null;
|
||||
Blueprint blueprint;
|
||||
|
||||
Building building = BuildingManager.getBuildingFromCache(buildingUUID);
|
||||
;
|
||||
if (pc == null || building == null)
|
||||
return true;
|
||||
int buildingUUID = msg.getUUID();
|
||||
|
||||
blueprint = building.getBlueprint();
|
||||
City city = building.getCity();
|
||||
Building building = BuildingManager.getBuildingFromCache(buildingUUID);
|
||||
;
|
||||
if (pc == null || building == null)
|
||||
return true;
|
||||
|
||||
// Can't destroy buildings without a blueprint.
|
||||
blueprint = building.getBlueprint();
|
||||
City city = building.getCity();
|
||||
|
||||
if (blueprint == null)
|
||||
return true;
|
||||
// Can't destroy buildings without a blueprint.
|
||||
|
||||
// Cannot destroy Oblivion database derived buildings.
|
||||
if (blueprint == null)
|
||||
return true;
|
||||
|
||||
if (building.getProtectionState() == Enum.ProtectionState.NPC) {
|
||||
return true;
|
||||
}
|
||||
// Cannot destroy Oblivion database derived buildings.
|
||||
|
||||
if (!BuildingManager.PlayerCanControlNotOwner(building, pc))
|
||||
return true;
|
||||
if (building.getProtectionState() == Enum.ProtectionState.NPC) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Can't delete siege assets during an active bane.
|
||||
if (!BuildingManager.PlayerCanControlNotOwner(building, pc))
|
||||
return true;
|
||||
|
||||
if (city != null)
|
||||
bane = city.getBane();
|
||||
// Can't delete siege assets during an active bane.
|
||||
|
||||
if ( bane != null && bane.getSiegePhase() == Enum.SiegePhase.WAR) {
|
||||
ErrorPopupMsg.sendErrorPopup(pc, 171);
|
||||
return true;
|
||||
}
|
||||
if (city != null)
|
||||
bane = city.getBane();
|
||||
|
||||
// Can't destroy a tree of life
|
||||
if (blueprint.getBuildingGroup() == BuildingGroup.TOL)
|
||||
return true;
|
||||
if (bane != null && bane.getSiegePhase() == Enum.SiegePhase.WAR) {
|
||||
ErrorPopupMsg.sendErrorPopup(pc, 171);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Can't destroy a shrine
|
||||
if (blueprint.getBuildingGroup() == BuildingGroup.SHRINE)
|
||||
return true;
|
||||
// Can't destroy a tree of life
|
||||
if (blueprint.getBuildingGroup() == BuildingGroup.TOL)
|
||||
return true;
|
||||
|
||||
// Cannot destroy mines outside of normal mine mechanics
|
||||
// Can't destroy a shrine
|
||||
if (blueprint.getBuildingGroup() == BuildingGroup.SHRINE)
|
||||
return true;
|
||||
|
||||
if (blueprint.getBuildingGroup() == BuildingGroup.MINE)
|
||||
return true;
|
||||
// Cannot destroy mines outside of normal mine mechanics
|
||||
|
||||
// Cannot delete rungates
|
||||
if (blueprint.getBuildingGroup() == BuildingGroup.MINE)
|
||||
return true;
|
||||
|
||||
if (blueprint.getBuildingGroup() == BuildingGroup.RUNEGATE)
|
||||
return true;
|
||||
// Cannot delete rungates
|
||||
|
||||
if (blueprint.getBuildingGroup() == BuildingGroup.RUNEGATE)
|
||||
return true;
|
||||
|
||||
|
||||
// Turn off spire if destoying
|
||||
if (blueprint.getBuildingGroup() == BuildingGroup.SPIRE)
|
||||
building.disableSpire(true);
|
||||
// Turn off spire if destoying
|
||||
if (blueprint.getBuildingGroup() == BuildingGroup.SPIRE)
|
||||
building.disableSpire(true);
|
||||
|
||||
if (blueprint.getBuildingGroup() == BuildingGroup.WAREHOUSE) {
|
||||
if (city != null)
|
||||
city.setWarehouseBuildingID(0);
|
||||
}
|
||||
if (blueprint.getBuildingGroup() == BuildingGroup.WAREHOUSE) {
|
||||
if (city != null)
|
||||
city.setWarehouseBuildingID(0);
|
||||
}
|
||||
|
||||
building.setRank(-1);
|
||||
WorldGrid.RemoveWorldObject(building);
|
||||
WorldGrid.removeObject(building);
|
||||
building.getParentZone().zoneBuildingSet.remove(building);
|
||||
if(building.getBlueprint() != null && building.getBlueprint().getBuildingGroup().equals(BuildingGroup.BARRACK)){
|
||||
building.RemoveFromBarracksList();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
building.setRank(-1);
|
||||
WorldGrid.RemoveWorldObject(building);
|
||||
WorldGrid.removeObject(building);
|
||||
building.getParentZone().zoneBuildingSet.remove(building);
|
||||
if (building.getBlueprint() != null && building.getBlueprint().getBuildingGroup().equals(BuildingGroup.BARRACK)) {
|
||||
building.RemoveFromBarracksList();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -27,7 +27,7 @@ public class DisbandGroupHandler extends AbstractClientMsgHandler {
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
|
||||
|
||||
PlayerCharacter source = SessionManager.getPlayerCharacter(origin);
|
||||
if (source == null) {
|
||||
return false;
|
||||
|
||||
@@ -32,90 +32,90 @@ import engine.objects.PlayerCharacter;
|
||||
|
||||
public class DisbandGuildHandler extends AbstractClientMsgHandler {
|
||||
|
||||
public DisbandGuildHandler() {
|
||||
super(DisbandGuildMsg.class);
|
||||
}
|
||||
public DisbandGuildHandler() {
|
||||
super(DisbandGuildMsg.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
|
||||
PlayerCharacter player;
|
||||
Guild guild;
|
||||
Dispatch dispatch;
|
||||
PlayerCharacter player;
|
||||
Guild guild;
|
||||
Dispatch dispatch;
|
||||
|
||||
player = SessionManager.getPlayerCharacter(origin);
|
||||
player = SessionManager.getPlayerCharacter(origin);
|
||||
|
||||
//don't allow non guild leaders to disband guild.
|
||||
//don't allow non guild leaders to disband guild.
|
||||
|
||||
if (player == null || GuildStatusController.isGuildLeader(player.getGuildStatus()) == false)
|
||||
return true;
|
||||
if (player == null || GuildStatusController.isGuildLeader(player.getGuildStatus()) == false)
|
||||
return true;
|
||||
|
||||
guild = player.getGuild();
|
||||
guild = player.getGuild();
|
||||
|
||||
if (guild == null || guild.isEmptyGuild())
|
||||
return true;
|
||||
if (guild == null || guild.isEmptyGuild())
|
||||
return true;
|
||||
|
||||
// Don't allow disbanding if a city is owned
|
||||
// *** Refactor: We should allow this by abandoning the tree first.
|
||||
// Don't allow disbanding if a city is owned
|
||||
// *** Refactor: We should allow this by abandoning the tree first.
|
||||
|
||||
if (guild.getOwnedCity() != null) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "You cannot disband a soverign guild!");
|
||||
return true;
|
||||
}
|
||||
if (guild.getOwnedCity() != null) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "You cannot disband a soverign guild!");
|
||||
return true;
|
||||
}
|
||||
|
||||
Bane guildBane = Bane.getBaneByAttackerGuild(guild);
|
||||
Bane guildBane = Bane.getBaneByAttackerGuild(guild);
|
||||
|
||||
if (guildBane != null) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "You cannot disband a guild with an active bane!");
|
||||
return true;
|
||||
}
|
||||
if (guildBane != null) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "You cannot disband a guild with an active bane!");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (guild.getSubGuildList().size() > 0) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "You cannot disband a nation!");
|
||||
return true;
|
||||
}
|
||||
if (guild.getSubGuildList().size() > 0) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "You cannot disband a nation!");
|
||||
return true;
|
||||
}
|
||||
|
||||
// Send message to guild (before kicking everyone out of it)
|
||||
// Send message to guild (before kicking everyone out of it)
|
||||
|
||||
ChatManager.chatGuildInfo(guild, guild.getName() + " has been disbanded!");
|
||||
ChatManager.chatGuildInfo(guild, guild.getName() + " has been disbanded!");
|
||||
|
||||
// Log event to data warehous
|
||||
// Log event to data warehous
|
||||
|
||||
GuildRecord guildRecord = GuildRecord.borrow(guild, Enum.RecordEventType.DISBAND);
|
||||
DataWarehouse.pushToWarehouse(guildRecord);
|
||||
GuildRecord guildRecord = GuildRecord.borrow(guild, Enum.RecordEventType.DISBAND);
|
||||
DataWarehouse.pushToWarehouse(guildRecord);
|
||||
|
||||
// Remove us as a subguild of our nation
|
||||
// Remove us as a subguild of our nation
|
||||
|
||||
if (guild.getNation() != null && Guild.sameGuild(guild, guild.getNation()) == false && guild.getNation().isEmptyGuild() == false)
|
||||
guild.getNation().removeSubGuild(guild);
|
||||
if (guild.getNation() != null && Guild.sameGuild(guild, guild.getNation()) == false && guild.getNation().isEmptyGuild() == false)
|
||||
guild.getNation().removeSubGuild(guild);
|
||||
|
||||
// Update all online guild players
|
||||
// Update all online guild players
|
||||
|
||||
for (PlayerCharacter pcs : Guild.GuildRoster(guild)) {
|
||||
for (PlayerCharacter pcs : Guild.GuildRoster(guild)) {
|
||||
|
||||
guild.removePlayer(pcs,GuildHistoryType.DISBAND);
|
||||
}
|
||||
guild.removePlayer(pcs, GuildHistoryType.DISBAND);
|
||||
}
|
||||
|
||||
//Save Guild data
|
||||
//Save Guild data
|
||||
|
||||
player.setGuildLeader(false);
|
||||
player.setInnerCouncil(false);
|
||||
guild.setGuildLeaderUUID(0);
|
||||
guild.setNation(null);
|
||||
player.setGuildLeader(false);
|
||||
player.setInnerCouncil(false);
|
||||
guild.setGuildLeaderUUID(0);
|
||||
guild.setNation(null);
|
||||
|
||||
DbManager.GuildQueries.DELETE_GUILD(guild);
|
||||
DbManager.GuildQueries.DELETE_GUILD(guild);
|
||||
|
||||
DbManager.removeFromCache(guild);
|
||||
WorldGrid.removeObject(guild, player);
|
||||
DbManager.removeFromCache(guild);
|
||||
WorldGrid.removeObject(guild, player);
|
||||
|
||||
// Send message back to client
|
||||
// Send message back to client
|
||||
|
||||
LeaveGuildMsg leaveGuildMsg = new LeaveGuildMsg();
|
||||
leaveGuildMsg.setMessage("You guild has been disbanded!");
|
||||
dispatch = Dispatch.borrow(player, leaveGuildMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
LeaveGuildMsg leaveGuildMsg = new LeaveGuildMsg();
|
||||
leaveGuildMsg.setMessage("You guild has been disbanded!");
|
||||
dispatch = Dispatch.borrow(player, leaveGuildMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -54,31 +54,30 @@ public class DismissGuildHandler extends AbstractClientMsgHandler {
|
||||
toDismiss = (Guild) DbManager.getObject(GameObjectType.Guild, dismissMsg.getGuildID());
|
||||
|
||||
if (toDismiss == null) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "A Serious error has occured. Please post details for to ensure transaction integrity");
|
||||
ErrorPopupMsg.sendErrorMsg(player, "A Serious error has occured. Please post details for to ensure transaction integrity");
|
||||
return true;
|
||||
}
|
||||
|
||||
nation = player.getGuild();
|
||||
|
||||
if (nation == null) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Nothing to disband, your guild is not a nation!");
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Nothing to disband, your guild is not a nation!");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!nation.getSubGuildList().contains(toDismiss)) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "You do not have authority to dismiss this guild!");
|
||||
ErrorPopupMsg.sendErrorMsg(player, "You do not have authority to dismiss this guild!");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (GuildStatusController.isGuildLeader(player.getGuildStatus()) == false) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Only a guild leader can dismiss a subguild!");
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Only a guild leader can dismiss a subguild!");
|
||||
return true;
|
||||
}
|
||||
|
||||
// Restriction on active bane desubbing
|
||||
|
||||
if (Bane.getBaneByAttackerGuild(toDismiss) != null)
|
||||
{
|
||||
if (Bane.getBaneByAttackerGuild(toDismiss) != null) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "You may not dismiss subguild with active bane!");
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ import java.util.HashSet;
|
||||
* @Author:
|
||||
* @Summary: Processes application protocol message which handle
|
||||
* open and close door requests to and from the client.
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class DoorTryOpenMsgHandler extends AbstractClientMsgHandler {
|
||||
|
||||
@@ -35,17 +35,17 @@ public class DoorTryOpenMsgHandler extends AbstractClientMsgHandler {
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
|
||||
// Member variable declaration
|
||||
|
||||
|
||||
PlayerCharacter player;
|
||||
DoorTryOpenMsg msg;
|
||||
Building targetBuilding;
|
||||
int doorNumber;
|
||||
|
||||
|
||||
// Member variable assignment
|
||||
|
||||
msg = (DoorTryOpenMsg)baseMsg;
|
||||
|
||||
msg = (DoorTryOpenMsg) baseMsg;
|
||||
player = origin.getPlayerCharacter();
|
||||
targetBuilding = BuildingManager.getBuildingFromCache(msg.getBuildingUUID());
|
||||
targetBuilding = BuildingManager.getBuildingFromCache(msg.getBuildingUUID());
|
||||
|
||||
if (player == null || targetBuilding == null) {
|
||||
Logger.error("Player or Building returned NULL in OpenCloseDoor handling.");
|
||||
@@ -53,7 +53,7 @@ public class DoorTryOpenMsgHandler extends AbstractClientMsgHandler {
|
||||
}
|
||||
|
||||
// Must be within x distance from door to manipulate it
|
||||
|
||||
|
||||
if (player.getLoc().distanceSquared2D(targetBuilding.getLoc()) > MBServerStatics.OPENCLOSEDOORDISTANCE * MBServerStatics.OPENCLOSEDOORDISTANCE)
|
||||
return true;
|
||||
|
||||
@@ -77,7 +77,7 @@ public class DoorTryOpenMsgHandler extends AbstractClientMsgHandler {
|
||||
MBServerStatics.MASK_PLAYER);
|
||||
|
||||
for (AbstractWorldObject awo : container) {
|
||||
PlayerCharacter playerCharacter = (PlayerCharacter)awo;
|
||||
PlayerCharacter playerCharacter = (PlayerCharacter) awo;
|
||||
Dispatch dispatch = Dispatch.borrow(playerCharacter, msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
}
|
||||
|
||||
@@ -25,54 +25,52 @@ import engine.objects.PlayerFriends;
|
||||
|
||||
public class FriendAcceptHandler extends AbstractClientMsgHandler {
|
||||
|
||||
public FriendAcceptHandler() {
|
||||
super(AcceptFriendMsg.class);
|
||||
}
|
||||
public FriendAcceptHandler() {
|
||||
super(AcceptFriendMsg.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg,
|
||||
ClientConnection origin) throws MsgSendException {
|
||||
|
||||
PlayerCharacter player = origin.getPlayerCharacter();
|
||||
|
||||
if (player == null)
|
||||
return true;
|
||||
|
||||
//change to Request
|
||||
public static void HandleAcceptFriend(PlayerCharacter player, AcceptFriendMsg msg) {
|
||||
PlayerCharacter sourceFriend = SessionManager.getPlayerCharacterByLowerCaseName(msg.sourceName);
|
||||
|
||||
AcceptFriendMsg msg = (AcceptFriendMsg)baseMsg;
|
||||
|
||||
|
||||
HandleAcceptFriend(player,msg);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (sourceFriend == null) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Could not find player " + msg.sourceName);
|
||||
return;
|
||||
}
|
||||
|
||||
PlayerFriends.AddToFriends(sourceFriend.getObjectUUID(), player.getObjectUUID());
|
||||
PlayerFriends.AddToFriends(player.getObjectUUID(), sourceFriend.getObjectUUID());
|
||||
|
||||
|
||||
AddFriendMessage outMsg = new AddFriendMessage(player);
|
||||
|
||||
Dispatch dispatch = Dispatch.borrow(sourceFriend, outMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
|
||||
outMsg = new AddFriendMessage(sourceFriend);
|
||||
dispatch = Dispatch.borrow(player, outMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
|
||||
ChatManager.chatSystemInfo(sourceFriend, player.getFirstName() + " has agreed to be your friend.");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg,
|
||||
ClientConnection origin) throws MsgSendException {
|
||||
|
||||
PlayerCharacter player = origin.getPlayerCharacter();
|
||||
|
||||
if (player == null)
|
||||
return true;
|
||||
|
||||
|
||||
AcceptFriendMsg msg = (AcceptFriendMsg) baseMsg;
|
||||
|
||||
|
||||
HandleAcceptFriend(player, msg);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//change to Request
|
||||
public static void HandleAcceptFriend(PlayerCharacter player, AcceptFriendMsg msg){
|
||||
PlayerCharacter sourceFriend = SessionManager.getPlayerCharacterByLowerCaseName(msg.sourceName);
|
||||
|
||||
if (sourceFriend == null){
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Could not find player " + msg.sourceName);
|
||||
return;
|
||||
}
|
||||
|
||||
PlayerFriends.AddToFriends(sourceFriend.getObjectUUID(), player.getObjectUUID());
|
||||
PlayerFriends.AddToFriends(player.getObjectUUID(), sourceFriend.getObjectUUID());
|
||||
|
||||
|
||||
AddFriendMessage outMsg = new AddFriendMessage(player);
|
||||
|
||||
Dispatch dispatch = Dispatch.borrow(sourceFriend, outMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
|
||||
outMsg = new AddFriendMessage(sourceFriend);
|
||||
dispatch = Dispatch.borrow(player, outMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
|
||||
ChatManager.chatSystemInfo(sourceFriend, player.getFirstName() + " has agreed to be your friend.");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -22,42 +22,40 @@ import engine.objects.PlayerCharacter;
|
||||
|
||||
public class FriendDeclineHandler extends AbstractClientMsgHandler {
|
||||
|
||||
public FriendDeclineHandler() {
|
||||
super(DeclineFriendMsg.class);
|
||||
}
|
||||
public FriendDeclineHandler() {
|
||||
super(DeclineFriendMsg.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg,
|
||||
ClientConnection origin) throws MsgSendException {
|
||||
|
||||
PlayerCharacter player = origin.getPlayerCharacter();
|
||||
|
||||
if (player == null)
|
||||
return true;
|
||||
|
||||
//change to Request
|
||||
public static void HandleDeclineFriend(PlayerCharacter player, DeclineFriendMsg msg) {
|
||||
PlayerCharacter sourceFriend = SessionManager.getPlayerCharacterByLowerCaseName(msg.sourceName);
|
||||
|
||||
DeclineFriendMsg msg = (DeclineFriendMsg)baseMsg;
|
||||
|
||||
|
||||
HandleDeclineFriend(player,msg);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (sourceFriend == null) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Could not find player " + msg.sourceName);
|
||||
return;
|
||||
}
|
||||
|
||||
Dispatch dispatch = Dispatch.borrow(sourceFriend, msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg,
|
||||
ClientConnection origin) throws MsgSendException {
|
||||
|
||||
PlayerCharacter player = origin.getPlayerCharacter();
|
||||
|
||||
if (player == null)
|
||||
return true;
|
||||
|
||||
|
||||
DeclineFriendMsg msg = (DeclineFriendMsg) baseMsg;
|
||||
|
||||
|
||||
HandleDeclineFriend(player, msg);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//change to Request
|
||||
public static void HandleDeclineFriend(PlayerCharacter player, DeclineFriendMsg msg){
|
||||
PlayerCharacter sourceFriend = SessionManager.getPlayerCharacterByLowerCaseName(msg.sourceName);
|
||||
|
||||
if (sourceFriend == null){
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Could not find player " + msg.sourceName);
|
||||
return;
|
||||
}
|
||||
|
||||
Dispatch dispatch = Dispatch.borrow(sourceFriend, msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -23,47 +23,43 @@ import engine.objects.PlayerCharacter;
|
||||
|
||||
public class FriendRequestHandler extends AbstractClientMsgHandler {
|
||||
|
||||
public FriendRequestHandler() {
|
||||
super(FriendRequestMsg.class);
|
||||
}
|
||||
public FriendRequestHandler() {
|
||||
super(FriendRequestMsg.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg,
|
||||
ClientConnection origin) throws MsgSendException {
|
||||
|
||||
PlayerCharacter player = origin.getPlayerCharacter();
|
||||
|
||||
if (player == null)
|
||||
return true;
|
||||
|
||||
public static void HandleRequestFriend(PlayerCharacter player, FriendRequestMsg msg) {
|
||||
PlayerCharacter targetFriend = SessionManager.getPlayerCharacterByLowerCaseName(msg.friendName);
|
||||
|
||||
FriendRequestMsg msg = (FriendRequestMsg)baseMsg;
|
||||
|
||||
HandleRequestFriend(player,msg);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (targetFriend == null) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Could not find player " + msg.friendName);
|
||||
return;
|
||||
}
|
||||
|
||||
if (targetFriend.equals(player))
|
||||
return;
|
||||
|
||||
|
||||
Dispatch dispatch = Dispatch.borrow(targetFriend, msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
ChatManager.chatSystemInfo(player, "Your friend request has been sent.");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg,
|
||||
ClientConnection origin) throws MsgSendException {
|
||||
|
||||
PlayerCharacter player = origin.getPlayerCharacter();
|
||||
|
||||
if (player == null)
|
||||
return true;
|
||||
|
||||
|
||||
FriendRequestMsg msg = (FriendRequestMsg) baseMsg;
|
||||
|
||||
HandleRequestFriend(player, msg);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public static void HandleRequestFriend(PlayerCharacter player, FriendRequestMsg msg){
|
||||
PlayerCharacter targetFriend = SessionManager.getPlayerCharacterByLowerCaseName(msg.friendName);
|
||||
|
||||
if (targetFriend == null){
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Could not find player " + msg.friendName);
|
||||
return;
|
||||
}
|
||||
|
||||
if (targetFriend.equals(player))
|
||||
return;
|
||||
|
||||
|
||||
|
||||
|
||||
Dispatch dispatch = Dispatch.borrow(targetFriend, msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
ChatManager.chatSystemInfo(player, "Your friend request has been sent.");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,29 +20,29 @@ import engine.objects.PlayerCharacter;
|
||||
|
||||
public class FurnitureHandler extends AbstractClientMsgHandler {
|
||||
|
||||
public FurnitureHandler() {
|
||||
super(FurnitureMsg.class);
|
||||
}
|
||||
public FurnitureHandler() {
|
||||
super(FurnitureMsg.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg,
|
||||
ClientConnection origin) throws MsgSendException {
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg,
|
||||
ClientConnection origin) throws MsgSendException {
|
||||
|
||||
FurnitureMsg msg = (FurnitureMsg) baseMsg;
|
||||
FurnitureMsg msg = (FurnitureMsg) baseMsg;
|
||||
|
||||
PlayerCharacter pc = origin.getPlayerCharacter();
|
||||
if (pc == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (msg.getType() == 1)
|
||||
msg.setType(2);
|
||||
|
||||
if (msg.getType() == 3)
|
||||
msg.setType(2);
|
||||
Dispatch dispatch = Dispatch.borrow(pc, msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
return true;
|
||||
}
|
||||
PlayerCharacter pc = origin.getPlayerCharacter();
|
||||
if (pc == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (msg.getType() == 1)
|
||||
msg.setType(2);
|
||||
|
||||
if (msg.getType() == 3)
|
||||
msg.setType(2);
|
||||
Dispatch dispatch = Dispatch.borrow(pc, msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -25,102 +25,102 @@ import engine.objects.PlayerCharacter;
|
||||
|
||||
public class GroupInviteHandler extends AbstractClientMsgHandler {
|
||||
|
||||
public GroupInviteHandler() {
|
||||
super(GroupInviteMsg.class);
|
||||
}
|
||||
public GroupInviteHandler() {
|
||||
super(GroupInviteMsg.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg,
|
||||
private static Group createGroup(PlayerCharacter pc, ClientConnection origin) {
|
||||
|
||||
ClientConnection origin) throws MsgSendException {
|
||||
GroupInviteMsg msg = (GroupInviteMsg) baseMsg;
|
||||
PlayerCharacter source = SessionManager.getPlayerCharacter(origin);
|
||||
if (pc == null)
|
||||
return null;
|
||||
|
||||
if (source == null)
|
||||
return false;
|
||||
Group group = new Group(pc, GroupManager.incrGroupCount());
|
||||
group.addGroupMember(pc);
|
||||
GroupManager.addNewGroup(group);
|
||||
|
||||
Group group = GroupManager.getGroup(source);
|
||||
pc.setFollow(false);
|
||||
// Send add self to group message
|
||||
GroupUpdateMsg msg = new GroupUpdateMsg();
|
||||
msg.setGroup(group);
|
||||
msg.setPlayer(pc);
|
||||
msg.setMessageType(1);
|
||||
Dispatch dispatch = Dispatch.borrow(pc, msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, engine.Enum.DispatchChannel.SECONDARY);
|
||||
|
||||
// Group is new, create it.
|
||||
group.addUpdateGroupJob();
|
||||
|
||||
if (group == null)
|
||||
group = GroupInviteHandler.createGroup(source, origin);
|
||||
return group;
|
||||
}
|
||||
|
||||
if (group == null)
|
||||
return false;
|
||||
// this can only be called if you already know you are not in a group
|
||||
// and have issued an invite
|
||||
|
||||
if (!group.isGroupLead(source)) // person doing invite must be group lead
|
||||
return true;
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg,
|
||||
|
||||
PlayerCharacter target = null;
|
||||
ClientConnection origin) throws MsgSendException {
|
||||
GroupInviteMsg msg = (GroupInviteMsg) baseMsg;
|
||||
PlayerCharacter source = SessionManager.getPlayerCharacter(origin);
|
||||
|
||||
if (msg.getInvited() == 1) { // Use name for invite
|
||||
target = SessionManager.getPlayerCharacterByLowerCaseName(msg.getName().toLowerCase());
|
||||
} else { // Use ID for invite
|
||||
target = SessionManager.getPlayerCharacterByID(msg.getTargetID());
|
||||
}
|
||||
if (source == null)
|
||||
return false;
|
||||
|
||||
if (target == null)
|
||||
return false;
|
||||
Group group = GroupManager.getGroup(source);
|
||||
|
||||
// Client must be online
|
||||
// Group is new, create it.
|
||||
|
||||
if (SessionManager.getClientConnection(target) == null)
|
||||
return false;
|
||||
if (group == null)
|
||||
group = GroupInviteHandler.createGroup(source, origin);
|
||||
|
||||
if (source == target) // Inviting self, so we're done
|
||||
return false;
|
||||
if (group == null)
|
||||
return false;
|
||||
|
||||
if (!group.isGroupLead(source)) // person doing invite must be group lead
|
||||
return true;
|
||||
|
||||
PlayerCharacter target = null;
|
||||
|
||||
if (msg.getInvited() == 1) { // Use name for invite
|
||||
target = SessionManager.getPlayerCharacterByLowerCaseName(msg.getName().toLowerCase());
|
||||
} else { // Use ID for invite
|
||||
target = SessionManager.getPlayerCharacterByID(msg.getTargetID());
|
||||
}
|
||||
|
||||
if (target == null)
|
||||
return false;
|
||||
|
||||
// Client must be online
|
||||
|
||||
if (SessionManager.getClientConnection(target) == null)
|
||||
return false;
|
||||
|
||||
if (source == target) // Inviting self, so we're done
|
||||
return false;
|
||||
|
||||
|
||||
//Skip invite if target is ignoring source
|
||||
//Skip invite if target is ignoring source
|
||||
|
||||
if (target.isIgnoringPlayer(source))
|
||||
return false;
|
||||
if (target.isIgnoringPlayer(source))
|
||||
return false;
|
||||
|
||||
|
||||
// dont block invites to people already in a group and
|
||||
// dont check for pending invites, the client does it
|
||||
// Send invite message to target
|
||||
// dont block invites to people already in a group and
|
||||
// dont check for pending invites, the client does it
|
||||
// Send invite message to target
|
||||
|
||||
msg.setSourceType(GameObjectType.PlayerCharacter.ordinal());
|
||||
msg.setSourceID(source.getObjectUUID());
|
||||
msg.setTargetType(0);
|
||||
msg.setTargetID(0);
|
||||
msg.setGroupType(GameObjectType.Group.ordinal());
|
||||
msg.setGroupID(group.getObjectUUID());
|
||||
msg.setInvited(1);
|
||||
msg.setName(source.getFirstName());
|
||||
msg.setSourceType(GameObjectType.PlayerCharacter.ordinal());
|
||||
msg.setSourceID(source.getObjectUUID());
|
||||
msg.setTargetType(0);
|
||||
msg.setTargetID(0);
|
||||
msg.setGroupType(GameObjectType.Group.ordinal());
|
||||
msg.setGroupID(group.getObjectUUID());
|
||||
msg.setInvited(1);
|
||||
msg.setName(source.getFirstName());
|
||||
|
||||
Dispatch dispatch = Dispatch.borrow(target, msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
Dispatch dispatch = Dispatch.borrow(target, msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// this can only be called if you already know you are not in a group
|
||||
// and have issued an invite
|
||||
|
||||
private static Group createGroup(PlayerCharacter pc, ClientConnection origin) {
|
||||
|
||||
if (pc == null)
|
||||
return null;
|
||||
|
||||
Group group = new Group(pc, GroupManager.incrGroupCount());
|
||||
group.addGroupMember(pc);
|
||||
GroupManager.addNewGroup(group);
|
||||
|
||||
pc.setFollow(false);
|
||||
// Send add self to group message
|
||||
GroupUpdateMsg msg = new GroupUpdateMsg();
|
||||
msg.setGroup(group);
|
||||
msg.setPlayer(pc);
|
||||
msg.setMessageType(1);
|
||||
Dispatch dispatch = Dispatch.borrow(pc, msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, engine.Enum.DispatchChannel.SECONDARY);
|
||||
|
||||
group.addUpdateGroupJob();
|
||||
|
||||
return group;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ public class GroupInviteResponseHandler extends AbstractClientMsgHandler {
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg,
|
||||
ClientConnection origin) throws MsgSendException {
|
||||
ClientConnection origin) throws MsgSendException {
|
||||
|
||||
GroupInviteResponseMsg msg = (GroupInviteResponseMsg) baseMsg;
|
||||
|
||||
@@ -50,7 +50,7 @@ public class GroupInviteResponseHandler extends AbstractClientMsgHandler {
|
||||
if (currGroup != null) // if we are already in a group we are leaving it
|
||||
GroupManager.LeaveGroup(player);
|
||||
|
||||
// not sure we need to test for invites to wrong grp as only
|
||||
// not sure we need to test for invites to wrong grp as only
|
||||
// 1 invite can be on screen at a time
|
||||
//if (invitesPending.get(player) != msg.getGroupID()) // Can't accept
|
||||
// invite to
|
||||
@@ -85,8 +85,8 @@ public class GroupInviteResponseHandler extends AbstractClientMsgHandler {
|
||||
|
||||
groupUpdateMsg.setPlayer(groupMember);
|
||||
|
||||
Dispatch dispatch = Dispatch.borrow(player, groupUpdateMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
Dispatch dispatch = Dispatch.borrow(player, groupUpdateMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
|
||||
}
|
||||
|
||||
@@ -104,8 +104,8 @@ public class GroupInviteResponseHandler extends AbstractClientMsgHandler {
|
||||
|
||||
KEYCLONEAUDIT.audit(player, group);
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,10 +22,10 @@ public class GroupUpdateHandler extends AbstractClientMsgHandler {
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg,
|
||||
ClientConnection origin) throws MsgSendException {
|
||||
ClientConnection origin) throws MsgSendException {
|
||||
|
||||
//GroupUpdateMsg msg = (GroupUpdateMsg) baseMsg;
|
||||
// not sure what to do with these as we spend our time sending them
|
||||
//GroupUpdateMsg msg = (GroupUpdateMsg) baseMsg;
|
||||
// not sure what to do with these as we spend our time sending them
|
||||
// to the whole group ourselves
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -24,27 +24,27 @@ import engine.objects.PlayerCharacter;
|
||||
|
||||
public class GuildControlHandler extends AbstractClientMsgHandler {
|
||||
|
||||
public GuildControlHandler() {
|
||||
super(GuildControlMsg.class);
|
||||
}
|
||||
|
||||
// TODO Don't think this protocolMsg (0x3235E5EA) is actually player history. so
|
||||
// take further look at it.
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
GuildControlMsg msg = (GuildControlMsg) baseMsg;
|
||||
public GuildControlHandler() {
|
||||
super(GuildControlMsg.class);
|
||||
}
|
||||
|
||||
// TODO Don't think this protocolMsg (0x3235E5EA) is actually player history. so
|
||||
// take further look at it.
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
GuildControlMsg msg = (GuildControlMsg) baseMsg;
|
||||
Dispatch dispatch;
|
||||
|
||||
// until we know what it's for, just echo it back.
|
||||
msg.setUnknown05((byte) 1);
|
||||
// until we know what it's for, just echo it back.
|
||||
msg.setUnknown05((byte) 1);
|
||||
|
||||
//Send a GuildList msg
|
||||
if(msg.getUnknown01() == 1) {
|
||||
//Send a GuildList msg
|
||||
if (msg.getUnknown01() == 1) {
|
||||
|
||||
PlayerCharacter player = SessionManager.getPlayerCharacter(origin);
|
||||
//TODO figure out why GL can't be changed and IC can't be banished
|
||||
//Bounce back the rank options
|
||||
msg.setGM((byte) (GuildStatusController.isGuildLeader(player.getGuildStatus()) ? 1 : 0));
|
||||
PlayerCharacter player = SessionManager.getPlayerCharacter(origin);
|
||||
//TODO figure out why GL can't be changed and IC can't be banished
|
||||
//Bounce back the rank options
|
||||
msg.setGM((byte) (GuildStatusController.isGuildLeader(player.getGuildStatus()) ? 1 : 0));
|
||||
|
||||
dispatch = Dispatch.borrow(player, msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
@@ -52,23 +52,23 @@ public class GuildControlHandler extends AbstractClientMsgHandler {
|
||||
if (GuildStatusController.isInnerCouncil(player.getGuildStatus()) || GuildStatusController.isGuildLeader(player.getGuildStatus())) {
|
||||
dispatch = Dispatch.borrow(player, new GuildListMsg(player.getGuild()));
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
} else
|
||||
} else
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Only guild leader and inner council have such authority!");
|
||||
|
||||
|
||||
} else if(msg.getUnknown01() == 2) {
|
||||
PlayerCharacter player = SessionManager.getPlayerCharacter(origin);
|
||||
|
||||
//If we don't get a valid PC for whatever reason.. just ignore it.
|
||||
PlayerCharacter pc = PlayerCharacter.getFromCache(msg.getUnknown03());
|
||||
} else if (msg.getUnknown01() == 2) {
|
||||
PlayerCharacter player = SessionManager.getPlayerCharacter(origin);
|
||||
|
||||
if(pc != null) {
|
||||
dispatch = Dispatch.borrow(player,new GuildListMsg(pc));
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
//If we don't get a valid PC for whatever reason.. just ignore it.
|
||||
PlayerCharacter pc = PlayerCharacter.getFromCache(msg.getUnknown03());
|
||||
|
||||
if (pc != null) {
|
||||
dispatch = Dispatch.borrow(player, new GuildListMsg(pc));
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,15 +16,15 @@ import engine.net.client.msg.guild.GuildCreationCloseMsg;
|
||||
|
||||
public class GuildCreationCloseHandler extends AbstractClientMsgHandler {
|
||||
|
||||
public GuildCreationCloseHandler() {
|
||||
super(GuildCreationCloseMsg.class);
|
||||
}
|
||||
public GuildCreationCloseHandler() {
|
||||
super(GuildCreationCloseMsg.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
// GuildCreationCloseMsg msg = (GuildCreationCloseMsg) baseMsg;
|
||||
// origin.sendMsg(msg);
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -7,9 +7,6 @@
|
||||
// www.magicbane.com
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
@@ -46,114 +43,114 @@ import engine.util.StringUtils;
|
||||
|
||||
public class GuildCreationFinalizeHandler extends AbstractClientMsgHandler {
|
||||
|
||||
public GuildCreationFinalizeHandler() {
|
||||
super(GuildCreationFinalizeMsg.class);
|
||||
}
|
||||
public GuildCreationFinalizeHandler() {
|
||||
super(GuildCreationFinalizeMsg.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
|
||||
PlayerCharacter player;
|
||||
GuildCreationFinalizeMsg msg;
|
||||
Enum.GuildType charterType;
|
||||
Guild newGuild;
|
||||
Guild playerGuild;
|
||||
ItemBase itemBase;
|
||||
Item charter;
|
||||
Dispatch dispatch;
|
||||
PlayerCharacter player;
|
||||
GuildCreationFinalizeMsg msg;
|
||||
Enum.GuildType charterType;
|
||||
Guild newGuild;
|
||||
Guild playerGuild;
|
||||
ItemBase itemBase;
|
||||
Item charter;
|
||||
Dispatch dispatch;
|
||||
|
||||
msg = (GuildCreationFinalizeMsg) baseMsg;
|
||||
msg = (GuildCreationFinalizeMsg) baseMsg;
|
||||
|
||||
player = SessionManager.getPlayerCharacter(origin);
|
||||
playerGuild = player.getGuild();
|
||||
player = SessionManager.getPlayerCharacter(origin);
|
||||
playerGuild = player.getGuild();
|
||||
|
||||
if (playerGuild.isEmptyGuild() == false && player.getGuild().getGuildLeaderUUID() == player.getObjectUUID()) {
|
||||
ErrorPopupMsg.sendErrorPopup(player, GuildManager.MUST_LEAVE_GUILD);
|
||||
return true;
|
||||
}
|
||||
if (playerGuild.isEmptyGuild() == false && player.getGuild().getGuildLeaderUUID() == player.getObjectUUID()) {
|
||||
ErrorPopupMsg.sendErrorPopup(player, GuildManager.MUST_LEAVE_GUILD);
|
||||
return true;
|
||||
}
|
||||
|
||||
//Validate the Charter
|
||||
//Validate the Charter
|
||||
|
||||
charter = msg.getCharter();
|
||||
charter = msg.getCharter();
|
||||
|
||||
if (charter == null || charter.getOwnerType() != OwnerType.PlayerCharacter || charter.getOwnerID() != player.getObjectUUID()) {
|
||||
ErrorPopupMsg.sendErrorPopup(player, GuildManager.NO_CHARTER_FOUND);
|
||||
return true;
|
||||
}
|
||||
if (charter == null || charter.getOwnerType() != OwnerType.PlayerCharacter || charter.getOwnerID() != player.getObjectUUID()) {
|
||||
ErrorPopupMsg.sendErrorPopup(player, GuildManager.NO_CHARTER_FOUND);
|
||||
return true;
|
||||
}
|
||||
|
||||
itemBase = charter.getItemBase();
|
||||
itemBase = charter.getItemBase();
|
||||
|
||||
// Item must be a valid charterType (type 10 in db)
|
||||
// Item must be a valid charterType (type 10 in db)
|
||||
|
||||
if (itemBase == null || (itemBase.getType().equals(ItemType.GUILDCHARTER) == false)) {
|
||||
ErrorPopupMsg.sendErrorPopup(player, GuildManager.NO_CHARTER_FOUND);
|
||||
return true;
|
||||
}
|
||||
if (itemBase == null || (itemBase.getType().equals(ItemType.GUILDCHARTER) == false)) {
|
||||
ErrorPopupMsg.sendErrorPopup(player, GuildManager.NO_CHARTER_FOUND);
|
||||
return true;
|
||||
}
|
||||
|
||||
charterType = Enum.GuildType.getGuildTypeFromCharter(itemBase);
|
||||
charterType = Enum.GuildType.getGuildTypeFromCharter(itemBase);
|
||||
|
||||
if (charterType == null){
|
||||
ErrorPopupMsg.sendErrorPopup(player, GuildManager.NO_CHARTER_FOUND);
|
||||
return true;
|
||||
}
|
||||
if (charterType == null) {
|
||||
ErrorPopupMsg.sendErrorPopup(player, GuildManager.NO_CHARTER_FOUND);
|
||||
return true;
|
||||
}
|
||||
|
||||
//Validate Guild Tags
|
||||
//Validate Guild Tags
|
||||
|
||||
if (!msg.getGuildTag().isValid()) {
|
||||
ErrorPopupMsg.sendErrorPopup(player, GuildManager.CREST_RESERVED);
|
||||
return true;
|
||||
}
|
||||
if (!msg.getGuildTag().isValid()) {
|
||||
ErrorPopupMsg.sendErrorPopup(player, GuildManager.CREST_RESERVED);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Validation passes. Leave current guild and create new one.
|
||||
// Validation passes. Leave current guild and create new one.
|
||||
|
||||
if (player.getGuild() != null && player.getGuild().isEmptyGuild() == false)
|
||||
player.getGuild().removePlayer(player,GuildHistoryType.LEAVE);
|
||||
if (player.getGuild() != null && player.getGuild().isEmptyGuild() == false)
|
||||
player.getGuild().removePlayer(player, GuildHistoryType.LEAVE);
|
||||
|
||||
int leadershipType = ((msg.getICVoteFlag() << 1) | msg.getMemberVoteFlag());
|
||||
int leadershipType = ((msg.getICVoteFlag() << 1) | msg.getMemberVoteFlag());
|
||||
|
||||
newGuild = new Guild( msg.getName(),null, charterType.ordinal(),
|
||||
charterType.getLeadershipType(leadershipType), msg.getGuildTag(),
|
||||
StringUtils.truncate(msg.getMotto(), 120));
|
||||
newGuild = new Guild(msg.getName(), null, charterType.ordinal(),
|
||||
charterType.getLeadershipType(leadershipType), msg.getGuildTag(),
|
||||
StringUtils.truncate(msg.getMotto(), 120));
|
||||
|
||||
newGuild.setGuildLeaderForCreate(player);
|
||||
newGuild.setGuildLeaderForCreate(player);
|
||||
|
||||
synchronized (this) {
|
||||
if (!DbManager.GuildQueries.IS_NAME_UNIQUE(msg.getName())) {
|
||||
ErrorPopupMsg.sendErrorPopup(player, GuildManager.UNIQUE_NAME);
|
||||
return true;
|
||||
}
|
||||
synchronized (this) {
|
||||
if (!DbManager.GuildQueries.IS_NAME_UNIQUE(msg.getName())) {
|
||||
ErrorPopupMsg.sendErrorPopup(player, GuildManager.UNIQUE_NAME);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!DbManager.GuildQueries.IS_CREST_UNIQUE(msg.getGuildTag())) {
|
||||
ErrorPopupMsg.sendErrorPopup(player, GuildManager.UNIQUE_CREST);
|
||||
return true;
|
||||
}
|
||||
if (!DbManager.GuildQueries.IS_CREST_UNIQUE(msg.getGuildTag())) {
|
||||
ErrorPopupMsg.sendErrorPopup(player, GuildManager.UNIQUE_CREST);
|
||||
return true;
|
||||
}
|
||||
|
||||
newGuild = DbManager.GuildQueries.SAVE_TO_DATABASE(newGuild);
|
||||
}
|
||||
newGuild = DbManager.GuildQueries.SAVE_TO_DATABASE(newGuild);
|
||||
}
|
||||
|
||||
if (newGuild == null) {
|
||||
ErrorPopupMsg.sendErrorPopup(player, GuildManager.FAILURE_TO_SWEAR_GUILD);
|
||||
return true;
|
||||
}
|
||||
|
||||
dispatch = Dispatch.borrow(player, msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
if (newGuild == null) {
|
||||
ErrorPopupMsg.sendErrorPopup(player, GuildManager.FAILURE_TO_SWEAR_GUILD);
|
||||
return true;
|
||||
}
|
||||
|
||||
GuildManager.joinGuild(player, newGuild, GuildHistoryType.CREATE);
|
||||
|
||||
newGuild.setGuildLeader(player);
|
||||
player.setGuildLeader(true);
|
||||
player.setInnerCouncil(true);
|
||||
player.setFullMember(true);
|
||||
player.setGuildTitle(charterType.getNumberOfRanks() - 1);
|
||||
player.getCharItemManager().delete(charter);
|
||||
player.getCharItemManager().updateInventory();
|
||||
player.incVer();
|
||||
dispatch = Dispatch.borrow(player, msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
|
||||
DispatchMessage.sendToAllInRange(player, new GuildInfoMsg(player, newGuild, 2));
|
||||
GuildManager.joinGuild(player, newGuild, GuildHistoryType.CREATE);
|
||||
|
||||
ChatManager.chatSystemInfo(player, msg.getName() + " has arrived on Grief server!");
|
||||
newGuild.setGuildLeader(player);
|
||||
player.setGuildLeader(true);
|
||||
player.setInnerCouncil(true);
|
||||
player.setFullMember(true);
|
||||
player.setGuildTitle(charterType.getNumberOfRanks() - 1);
|
||||
player.getCharItemManager().delete(charter);
|
||||
player.getCharItemManager().updateInventory();
|
||||
player.incVer();
|
||||
|
||||
return true;
|
||||
}
|
||||
DispatchMessage.sendToAllInRange(player, new GuildInfoMsg(player, newGuild, 2));
|
||||
|
||||
ChatManager.chatSystemInfo(player, msg.getName() + " has arrived on Grief server!");
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,21 +19,21 @@ import engine.objects.PlayerCharacter;
|
||||
|
||||
public class GuildCreationOptionsHandler extends AbstractClientMsgHandler {
|
||||
|
||||
public GuildCreationOptionsHandler() {
|
||||
super(GuildCreationOptionsMsg.class);
|
||||
}
|
||||
public GuildCreationOptionsHandler() {
|
||||
super(GuildCreationOptionsMsg.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
GuildCreationOptionsMsg msg = (GuildCreationOptionsMsg) baseMsg;
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
GuildCreationOptionsMsg msg = (GuildCreationOptionsMsg) baseMsg;
|
||||
PlayerCharacter sourcePlayer = origin.getPlayerCharacter();
|
||||
Dispatch dispatch;
|
||||
|
||||
if(msg.getScreenType() == 1) {
|
||||
msg.setScreenType(3);
|
||||
} else if(msg.getScreenType() == 2) {
|
||||
msg.setScreenType(4);
|
||||
}
|
||||
if (msg.getScreenType() == 1) {
|
||||
msg.setScreenType(3);
|
||||
} else if (msg.getScreenType() == 2) {
|
||||
msg.setScreenType(4);
|
||||
}
|
||||
|
||||
if (sourcePlayer == null)
|
||||
return true;
|
||||
@@ -41,7 +41,7 @@ public class GuildCreationOptionsHandler extends AbstractClientMsgHandler {
|
||||
dispatch = Dispatch.borrow(sourcePlayer, msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, engine.Enum.DispatchChannel.SECONDARY);
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -21,47 +21,47 @@ import engine.objects.PlayerCharacter;
|
||||
|
||||
public class GuildInfoHandler extends AbstractClientMsgHandler {
|
||||
|
||||
public GuildInfoHandler() {
|
||||
super(GuildInfoMsg.class);
|
||||
}
|
||||
public GuildInfoHandler() {
|
||||
super(GuildInfoMsg.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
GuildInfoMsg msg = (GuildInfoMsg) baseMsg;
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
GuildInfoMsg msg = (GuildInfoMsg) baseMsg;
|
||||
Dispatch dispatch;
|
||||
|
||||
// get source player
|
||||
PlayerCharacter sourcePlayer = SessionManager
|
||||
.getPlayerCharacter(origin);
|
||||
// get source player
|
||||
PlayerCharacter sourcePlayer = SessionManager
|
||||
.getPlayerCharacter(origin);
|
||||
|
||||
if (sourcePlayer == null)
|
||||
return true;
|
||||
|
||||
if(msg.getMsgType() == 1) {
|
||||
dispatch = Dispatch.borrow(sourcePlayer, new GuildInfoMsg(sourcePlayer, sourcePlayer.getGuild(), 4));
|
||||
if (sourcePlayer == null)
|
||||
return true;
|
||||
|
||||
if (msg.getMsgType() == 1) {
|
||||
dispatch = Dispatch.borrow(sourcePlayer, new GuildInfoMsg(sourcePlayer, sourcePlayer.getGuild(), 4));
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, engine.Enum.DispatchChannel.SECONDARY);
|
||||
} else if(msg.getMsgType() == 5) {
|
||||
|
||||
if(msg.getObjectType() == GameObjectType.PlayerCharacter.ordinal()) {
|
||||
PlayerCharacter pc = PlayerCharacter.getPlayerCharacter(msg.getObjectID());
|
||||
} else if (msg.getMsgType() == 5) {
|
||||
|
||||
if (msg.getObjectType() == GameObjectType.PlayerCharacter.ordinal()) {
|
||||
PlayerCharacter pc = PlayerCharacter.getPlayerCharacter(msg.getObjectID());
|
||||
dispatch = Dispatch.borrow(sourcePlayer, new GuildInfoMsg(pc, pc.getGuild(), 5));
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, engine.Enum.DispatchChannel.SECONDARY);
|
||||
} else {
|
||||
//TODO Change this to a null object when we make a null object.
|
||||
} else {
|
||||
//TODO Change this to a null object when we make a null object.
|
||||
|
||||
dispatch = Dispatch.borrow(sourcePlayer,new GuildInfoMsg(sourcePlayer, sourcePlayer.getGuild(), 1));
|
||||
dispatch = Dispatch.borrow(sourcePlayer, new GuildInfoMsg(sourcePlayer, sourcePlayer.getGuild(), 1));
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, engine.Enum.DispatchChannel.SECONDARY);
|
||||
}
|
||||
}
|
||||
|
||||
// Send PromoteDemoteScreen info message response. 0x001D4DF6
|
||||
}
|
||||
}
|
||||
|
||||
// Send guild member list? 0x6949C720
|
||||
// GuildList(source, origin);
|
||||
// Send PromoteDemoteScreen info message response. 0x001D4DF6
|
||||
|
||||
// send 0x3235E5EA? See what that is
|
||||
|
||||
return true;
|
||||
}
|
||||
// Send guild member list? 0x6949C720
|
||||
// GuildList(source, origin);
|
||||
|
||||
// send 0x3235E5EA? See what that is
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,21 +16,21 @@ import engine.net.client.msg.guild.GuildListMsg;
|
||||
|
||||
public class GuildListHandler extends AbstractClientMsgHandler {
|
||||
|
||||
public GuildListHandler() {
|
||||
super(GuildListMsg.class);
|
||||
}
|
||||
public GuildListHandler() {
|
||||
super(GuildListMsg.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
// GuildListMsg msg = (GuildListMsg) baseMsg;
|
||||
|
||||
// GuildListMsg msg = new GuildListMsg(origin);
|
||||
// GuildTableList gtl = new GuildTableList();
|
||||
// gtl.setUUID(pc.getUUID()); gtl.setName(pc.getName());
|
||||
// msg.add(gtl);
|
||||
// origin.sendMsg(msg);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// GuildListMsg msg = new GuildListMsg(origin);
|
||||
// GuildTableList gtl = new GuildTableList();
|
||||
// gtl.setUUID(pc.getUUID()); gtl.setName(pc.getName());
|
||||
// msg.add(gtl);
|
||||
// origin.sendMsg(msg);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,14 +16,14 @@ import engine.net.client.msg.guild.GuildUnknownMsg;
|
||||
|
||||
public class GuildUnknownHandler extends AbstractClientMsgHandler {
|
||||
|
||||
public GuildUnknownHandler() {
|
||||
super(GuildUnknownMsg.class);
|
||||
}
|
||||
public GuildUnknownHandler() {
|
||||
super(GuildUnknownMsg.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
// GuildUnknownMsg msg = (GuildUnknownMsg) baseMsg;
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -7,9 +7,6 @@
|
||||
// www.magicbane.com
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||
@@ -38,57 +35,56 @@ import engine.objects.PlayerCharacter;
|
||||
|
||||
public class HirelingServiceMsgHandler extends AbstractClientMsgHandler {
|
||||
|
||||
public HirelingServiceMsgHandler() {
|
||||
super(HirelingServiceMsg.class);
|
||||
}
|
||||
public HirelingServiceMsgHandler() {
|
||||
super(HirelingServiceMsg.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
|
||||
PlayerCharacter player;
|
||||
HirelingServiceMsg msg;
|
||||
PlayerCharacter player;
|
||||
HirelingServiceMsg msg;
|
||||
|
||||
msg = (HirelingServiceMsg) baseMsg;
|
||||
msg = (HirelingServiceMsg) baseMsg;
|
||||
|
||||
// get PlayerCharacter of person accepting invite
|
||||
// get PlayerCharacter of person accepting invite
|
||||
|
||||
player = SessionManager.getPlayerCharacter(origin);
|
||||
player = SessionManager.getPlayerCharacter(origin);
|
||||
|
||||
if (player == null)
|
||||
return true;
|
||||
|
||||
switch (msg.messageType){
|
||||
case HirelingServiceMsg.SETREPAIRCOST:
|
||||
Building building = BuildingManager.getBuildingFromCache(msg.buildingID);
|
||||
|
||||
if (building == null)
|
||||
return true;
|
||||
|
||||
NPC npc = NPC.getFromCache(msg.npcID);
|
||||
|
||||
if (npc == null)
|
||||
return true;
|
||||
|
||||
if (!BuildingManager.playerCanManage(player, building))
|
||||
return true;
|
||||
|
||||
|
||||
|
||||
npc.setRepairCost(msg.repairCost);
|
||||
ManageNPCMsg outMsg = new ManageNPCMsg(npc);
|
||||
Dispatch dispatch = Dispatch.borrow(player, msg);
|
||||
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
dispatch = Dispatch.borrow(player, outMsg);
|
||||
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
if (player == null)
|
||||
return true;
|
||||
|
||||
|
||||
}
|
||||
switch (msg.messageType) {
|
||||
case HirelingServiceMsg.SETREPAIRCOST:
|
||||
Building building = BuildingManager.getBuildingFromCache(msg.buildingID);
|
||||
|
||||
if (building == null)
|
||||
return true;
|
||||
|
||||
NPC npc = NPC.getFromCache(msg.npcID);
|
||||
|
||||
if (npc == null)
|
||||
return true;
|
||||
|
||||
if (!BuildingManager.playerCanManage(player, building))
|
||||
return true;
|
||||
|
||||
|
||||
npc.setRepairCost(msg.repairCost);
|
||||
ManageNPCMsg outMsg = new ManageNPCMsg(npc);
|
||||
Dispatch dispatch = Dispatch.borrow(player, msg);
|
||||
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
dispatch = Dispatch.borrow(player, outMsg);
|
||||
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -27,125 +27,123 @@ import engine.objects.PlayerCharacter;
|
||||
|
||||
public class InviteToGuildHandler extends AbstractClientMsgHandler {
|
||||
|
||||
public InviteToGuildHandler() {
|
||||
super(InviteToGuildMsg.class);
|
||||
}
|
||||
public InviteToGuildHandler() {
|
||||
super(InviteToGuildMsg.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
InviteToGuildMsg msg;
|
||||
PlayerCharacter sourcePlayer;
|
||||
PlayerCharacter targetPlayer;
|
||||
Dispatch dispatch;
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
InviteToGuildMsg msg;
|
||||
PlayerCharacter sourcePlayer;
|
||||
PlayerCharacter targetPlayer;
|
||||
Dispatch dispatch;
|
||||
|
||||
msg = (InviteToGuildMsg) baseMsg;
|
||||
msg = (InviteToGuildMsg) baseMsg;
|
||||
|
||||
// First see if this is a refusal to another guild invite
|
||||
// First see if this is a refusal to another guild invite
|
||||
|
||||
if (msg.getResponse() == 4)
|
||||
return true; // Player refused invite
|
||||
if (msg.getResponse() == 4)
|
||||
return true; // Player refused invite
|
||||
|
||||
// get sourcePlayer player
|
||||
// get sourcePlayer player
|
||||
|
||||
sourcePlayer = SessionManager.getPlayerCharacter(origin);
|
||||
sourcePlayer = SessionManager.getPlayerCharacter(origin);
|
||||
|
||||
if (sourcePlayer == null)
|
||||
return true;
|
||||
if (sourcePlayer == null)
|
||||
return true;
|
||||
|
||||
if (msg.getTargetUUID() == 0) {
|
||||
// get targetPlayer player by name
|
||||
targetPlayer = SessionManager.getPlayerCharacterByLowerCaseName(msg.getTargetName());
|
||||
if (msg.getTargetUUID() == 0) {
|
||||
// get targetPlayer player by name
|
||||
targetPlayer = SessionManager.getPlayerCharacterByLowerCaseName(msg.getTargetName());
|
||||
|
||||
if (targetPlayer == null) {
|
||||
ChatManager.chatGuildError(sourcePlayer,
|
||||
"No such player exists!");
|
||||
return true;
|
||||
}
|
||||
} else
|
||||
if (msg.getTargetType() == GameObjectType.PlayerCharacter.ordinal()) {
|
||||
if (targetPlayer == null) {
|
||||
ChatManager.chatGuildError(sourcePlayer,
|
||||
"No such player exists!");
|
||||
return true;
|
||||
}
|
||||
} else if (msg.getTargetType() == GameObjectType.PlayerCharacter.ordinal()) {
|
||||
|
||||
targetPlayer = SessionManager.getPlayerCharacterByID(msg.getTargetUUID());
|
||||
targetPlayer = SessionManager.getPlayerCharacterByID(msg.getTargetUUID());
|
||||
|
||||
if (targetPlayer == null) {
|
||||
ChatManager.chatGuildError(sourcePlayer,
|
||||
"No such player exists!");
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
ChatManager.chatGuildError(sourcePlayer,
|
||||
"You cannot invite that character!");
|
||||
return true;
|
||||
}
|
||||
if (targetPlayer == null) {
|
||||
ChatManager.chatGuildError(sourcePlayer,
|
||||
"No such player exists!");
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
ChatManager.chatGuildError(sourcePlayer,
|
||||
"You cannot invite that character!");
|
||||
return true;
|
||||
}
|
||||
|
||||
// get sourcePlayer guild. Verify sourcePlayer player is in guild
|
||||
// get sourcePlayer guild. Verify sourcePlayer player is in guild
|
||||
|
||||
if (sourcePlayer.getGuild().getObjectUUID() == 0 || sourcePlayer.getGuild().isEmptyGuild()) {
|
||||
ChatManager.chatGuildError(sourcePlayer,
|
||||
"You cannot invite someone for errant!");
|
||||
return true;
|
||||
}
|
||||
if (sourcePlayer.getGuild().getObjectUUID() == 0 || sourcePlayer.getGuild().isEmptyGuild()) {
|
||||
ChatManager.chatGuildError(sourcePlayer,
|
||||
"You cannot invite someone for errant!");
|
||||
return true;
|
||||
}
|
||||
|
||||
Enum.GuildType guildType = Enum.GuildType.values()[sourcePlayer.getGuild().getCharter()];
|
||||
Enum.GuildType guildType = Enum.GuildType.values()[sourcePlayer.getGuild().getCharter()];
|
||||
|
||||
if (guildType == null){
|
||||
ErrorPopupMsg.sendErrorPopup(sourcePlayer, GuildManager.NO_CHARTER_FOUND);
|
||||
return true;
|
||||
}
|
||||
if (guildType == null) {
|
||||
ErrorPopupMsg.sendErrorPopup(sourcePlayer, GuildManager.NO_CHARTER_FOUND);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// verify sourcePlayer player is full member so they can invite
|
||||
|
||||
// verify sourcePlayer player is full member so they can invite
|
||||
if (GuildStatusController.isFullMember(sourcePlayer.getGuildStatus()) == false) {
|
||||
ChatManager.chatGuildError(sourcePlayer,
|
||||
"You do not have authority to invite!");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (GuildStatusController.isFullMember(sourcePlayer.getGuildStatus()) == false) {
|
||||
ChatManager.chatGuildError(sourcePlayer,
|
||||
"You do not have authority to invite!");
|
||||
return true;
|
||||
}
|
||||
//block invite is targetPlayer is ignoring sourcePlayer
|
||||
|
||||
//block invite is targetPlayer is ignoring sourcePlayer
|
||||
if (targetPlayer.isIgnoringPlayer(sourcePlayer))
|
||||
return true;
|
||||
|
||||
if (targetPlayer.isIgnoringPlayer(sourcePlayer))
|
||||
return true;
|
||||
if ((targetPlayer.getGuild().isEmptyGuild() == false)) {
|
||||
ChatManager.chatGuildError(sourcePlayer,
|
||||
targetPlayer.getFirstName() + " already belongs to a guild!");
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((targetPlayer.getGuild().isEmptyGuild() == false)) {
|
||||
ChatManager.chatGuildError(sourcePlayer,
|
||||
targetPlayer.getFirstName() + " already belongs to a guild!");
|
||||
return true;
|
||||
}
|
||||
// verify targetPlayer player is not on banish list
|
||||
|
||||
// verify targetPlayer player is not on banish list
|
||||
if (sourcePlayer.getGuild().getBanishList().contains(targetPlayer)) {
|
||||
ErrorPopupMsg.sendErrorPopup(sourcePlayer, 135);// Character is considered BANISHED by guild leadership
|
||||
return true;
|
||||
}
|
||||
|
||||
if (sourcePlayer.getGuild().getBanishList().contains(targetPlayer)) {
|
||||
ErrorPopupMsg.sendErrorPopup(sourcePlayer, 135);// Character is considered BANISHED by guild leadership
|
||||
return true;
|
||||
}
|
||||
//verify targetPlayer meets level requirements of guild
|
||||
|
||||
//verify targetPlayer meets level requirements of guild
|
||||
if ((targetPlayer.getLevel() < sourcePlayer.getGuild().getRepledgeMin()) || targetPlayer.getLevel() > sourcePlayer.getGuild().getRepledgeMax()) {
|
||||
ErrorPopupMsg.sendErrorPopup(sourcePlayer, 135);// you do not meet the level required for this SWORN guild
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((targetPlayer.getLevel() < sourcePlayer.getGuild().getRepledgeMin()) || targetPlayer.getLevel() > sourcePlayer.getGuild().getRepledgeMax()) {
|
||||
ErrorPopupMsg.sendErrorPopup(sourcePlayer, 135);// you do not meet the level required for this SWORN guild
|
||||
return true;
|
||||
}
|
||||
targetPlayer.setLastGuildToInvite(sourcePlayer.getGuild().getObjectUUID());
|
||||
|
||||
targetPlayer.setLastGuildToInvite(sourcePlayer.getGuild().getObjectUUID());
|
||||
// setup guild invite message to send to targetPlayer
|
||||
|
||||
// setup guild invite message to send to targetPlayer
|
||||
msg.setSourceType(sourcePlayer.getObjectType().ordinal());
|
||||
msg.setSourceUUID(sourcePlayer.getObjectUUID());
|
||||
msg.setTargetType(targetPlayer.getObjectType().ordinal());
|
||||
|
||||
msg.setSourceType(sourcePlayer.getObjectType().ordinal());
|
||||
msg.setSourceUUID(sourcePlayer.getObjectUUID());
|
||||
msg.setTargetType(targetPlayer.getObjectType().ordinal());
|
||||
msg.setTargetUUID(targetPlayer.getObjectUUID());
|
||||
msg.setGuildTag(sourcePlayer.getGuild().getGuildTag());
|
||||
msg.setGuildName(sourcePlayer.getGuild().getName());
|
||||
msg.setGuildType(sourcePlayer.getGuild().getObjectType().ordinal());
|
||||
msg.setGuildUUID(sourcePlayer.getGuild().getObjectUUID());
|
||||
msg.setTargetName("");
|
||||
|
||||
msg.setTargetUUID(targetPlayer.getObjectUUID());
|
||||
msg.setGuildTag(sourcePlayer.getGuild().getGuildTag());
|
||||
msg.setGuildName(sourcePlayer.getGuild().getName());
|
||||
msg.setGuildType(sourcePlayer.getGuild().getObjectType().ordinal());
|
||||
msg.setGuildUUID(sourcePlayer.getGuild().getObjectUUID());
|
||||
msg.setTargetName("");
|
||||
dispatch = Dispatch.borrow(targetPlayer, msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
|
||||
dispatch = Dispatch.borrow(targetPlayer, msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -27,107 +27,107 @@ import engine.objects.PlayerCharacter;
|
||||
|
||||
public class InviteToSubHandler extends AbstractClientMsgHandler {
|
||||
|
||||
public InviteToSubHandler() {
|
||||
super(InviteToSubMsg.class);
|
||||
}
|
||||
public InviteToSubHandler() {
|
||||
super(InviteToSubMsg.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
private static void sendChat(PlayerCharacter source, String msg) {
|
||||
ChatManager.chatGuildError(source, msg);
|
||||
}
|
||||
|
||||
PlayerCharacter source;
|
||||
PlayerCharacter target;
|
||||
Guild sourceGuild;
|
||||
Guild targetGuild;
|
||||
InviteToSubMsg msg = (InviteToSubMsg) baseMsg;
|
||||
Dispatch dispatch;
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
|
||||
source = SessionManager.getPlayerCharacter(origin);
|
||||
PlayerCharacter source;
|
||||
PlayerCharacter target;
|
||||
Guild sourceGuild;
|
||||
Guild targetGuild;
|
||||
InviteToSubMsg msg = (InviteToSubMsg) baseMsg;
|
||||
Dispatch dispatch;
|
||||
|
||||
if (source == null)
|
||||
return true;
|
||||
source = SessionManager.getPlayerCharacter(origin);
|
||||
|
||||
target = (PlayerCharacter) DbManager.getObject(GameObjectType.PlayerCharacter, msg.getTargetUUID());
|
||||
if (source == null)
|
||||
return true;
|
||||
|
||||
if (target == null) {
|
||||
ErrorPopupMsg.sendErrorMsg(source, "A Serious error has occured. Please post details for to ensure transaction integrity");
|
||||
return true;
|
||||
}
|
||||
target = (PlayerCharacter) DbManager.getObject(GameObjectType.PlayerCharacter, msg.getTargetUUID());
|
||||
|
||||
//Ignore invites to sub if ignoring player
|
||||
if (target == null) {
|
||||
ErrorPopupMsg.sendErrorMsg(source, "A Serious error has occured. Please post details for to ensure transaction integrity");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (target.isIgnoringPlayer(source))
|
||||
return true;
|
||||
//Ignore invites to sub if ignoring player
|
||||
|
||||
sourceGuild = source.getGuild();
|
||||
targetGuild = target.getGuild();
|
||||
if (target.isIgnoringPlayer(source))
|
||||
return true;
|
||||
|
||||
//source must be in guild
|
||||
sourceGuild = source.getGuild();
|
||||
targetGuild = target.getGuild();
|
||||
|
||||
if (sourceGuild == null) {
|
||||
sendChat(source, "You must be in a guild to invite to sub.");
|
||||
return true;
|
||||
}
|
||||
//source must be in guild
|
||||
|
||||
if (sourceGuild.isEmptyGuild()){
|
||||
sendChat(source, "You must be in a guild to invite to sub.");
|
||||
return true;
|
||||
}
|
||||
if (sourceGuild == null) {
|
||||
sendChat(source, "You must be in a guild to invite to sub.");
|
||||
return true;
|
||||
}
|
||||
|
||||
//source must be GL or IC
|
||||
if (sourceGuild.isEmptyGuild()) {
|
||||
sendChat(source, "You must be in a guild to invite to sub.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (GuildStatusController.isInnerCouncil(source.getGuildStatus()) == false) {
|
||||
sendChat(source, "Only guild leadership can invite to sub.");
|
||||
return true;
|
||||
}
|
||||
//source must be GL or IC
|
||||
|
||||
if (sourceGuild.getNation().isEmptyGuild())
|
||||
return true;
|
||||
if (GuildStatusController.isInnerCouncil(source.getGuildStatus()) == false) {
|
||||
sendChat(source, "Only guild leadership can invite to sub.");
|
||||
return true;
|
||||
}
|
||||
|
||||
//target must be in a guild
|
||||
if (sourceGuild.getNation().isEmptyGuild())
|
||||
return true;
|
||||
|
||||
if (targetGuild == null)
|
||||
return true;
|
||||
|
||||
if (sourceGuild.equals(targetGuild))
|
||||
return true;
|
||||
//target must be in a guild
|
||||
|
||||
//target must be GL or IC
|
||||
if (targetGuild == null)
|
||||
return true;
|
||||
|
||||
if (GuildStatusController.isInnerCouncil(target.getGuildStatus()) == false && GuildStatusController.isGuildLeader(target.getGuildStatus()) == false) {
|
||||
sendChat(source, "Target player is not guild leadership.");
|
||||
return true;
|
||||
}
|
||||
if (sourceGuild.equals(targetGuild))
|
||||
return true;
|
||||
|
||||
//Can't already be same nation or errant
|
||||
//source guild is limited to 7 subs
|
||||
//TODO this should be based on TOL rank
|
||||
//target must be GL or IC
|
||||
|
||||
if (GuildStatusController.isInnerCouncil(target.getGuildStatus()) == false && GuildStatusController.isGuildLeader(target.getGuildStatus()) == false) {
|
||||
sendChat(source, "Target player is not guild leadership.");
|
||||
return true;
|
||||
}
|
||||
|
||||
//Can't already be same nation or errant
|
||||
//source guild is limited to 7 subs
|
||||
//TODO this should be based on TOL rank
|
||||
|
||||
|
||||
if (!sourceGuild.canSubAGuild(targetGuild)) {
|
||||
sendChat(source, "This Guild can't be subbed.");
|
||||
return true;
|
||||
}
|
||||
if (!sourceGuild.canSubAGuild(targetGuild)) {
|
||||
sendChat(source, "This Guild can't be subbed.");
|
||||
return true;
|
||||
}
|
||||
|
||||
//all tests passed, let's send invite.
|
||||
//all tests passed, let's send invite.
|
||||
|
||||
if (target.getClientConnection() != null) {
|
||||
msg.setGuildTag(sourceGuild.getGuildTag());
|
||||
msg.setGuildName(sourceGuild.getName());
|
||||
msg.setGuildUUID(sourceGuild.getObjectUUID());
|
||||
msg.setUnknown02(1);
|
||||
if (target.getClientConnection() != null) {
|
||||
msg.setGuildTag(sourceGuild.getGuildTag());
|
||||
msg.setGuildName(sourceGuild.getName());
|
||||
msg.setGuildUUID(sourceGuild.getObjectUUID());
|
||||
msg.setUnknown02(1);
|
||||
|
||||
dispatch = Dispatch.borrow(target, msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
dispatch = Dispatch.borrow(target, msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
|
||||
} else {
|
||||
sendChat(source, "Failed to send sub invite to target.");
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
sendChat(source, "Failed to send sub invite to target.");
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void sendChat(PlayerCharacter source, String msg) {
|
||||
ChatManager.chatGuildError(source, msg);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,488 +34,478 @@ import java.util.HashMap;
|
||||
*/
|
||||
public class ItemProductionMsgHandler extends AbstractClientMsgHandler {
|
||||
|
||||
private static final int ACTION_PRODUCE = 1;
|
||||
private static final int ACTION_JUNK = 2;
|
||||
private static final int ACTION_RECYCLE = 3;
|
||||
private static final int ACTION_COMPLETE = 4;
|
||||
private static final int ACTION_DEPOSIT = 6;
|
||||
private static final int ACTION_SETPRICE = 5;
|
||||
private static final int ACTION_TAKE = 7;
|
||||
private static final int ACTION_CONFIRM_SETPRICE = 9; // Unsure. Sent by client
|
||||
private static final int ACTION_CONFIRM_DEPOSIT = 10; // Unsure. Sent by client
|
||||
private static final int ACTION_CONFIRM_TAKE = 11; // Unsure. Sent by client
|
||||
private static final int ACTION_PRODUCE = 1;
|
||||
private static final int ACTION_JUNK = 2;
|
||||
private static final int ACTION_RECYCLE = 3;
|
||||
private static final int ACTION_COMPLETE = 4;
|
||||
private static final int ACTION_DEPOSIT = 6;
|
||||
private static final int ACTION_SETPRICE = 5;
|
||||
private static final int ACTION_TAKE = 7;
|
||||
private static final int ACTION_CONFIRM_SETPRICE = 9; // Unsure. Sent by client
|
||||
private static final int ACTION_CONFIRM_DEPOSIT = 10; // Unsure. Sent by client
|
||||
private static final int ACTION_CONFIRM_TAKE = 11; // Unsure. Sent by client
|
||||
|
||||
public ItemProductionMsgHandler() {
|
||||
super(ItemProductionMsg.class);
|
||||
}
|
||||
public ItemProductionMsgHandler() {
|
||||
super(ItemProductionMsg.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
private static void setItemPrice(int itemType, int itemUUID, int itemPrice, NPC vendor, ClientConnection origin) {
|
||||
|
||||
// Member variable declaration
|
||||
|
||||
PlayerCharacter player;
|
||||
NPC vendorNPC;
|
||||
ItemProductionMsg msg;
|
||||
Dispatch dispatch;
|
||||
Item targetItem;
|
||||
ItemProductionMsg outMsg;
|
||||
Dispatch dispatch;
|
||||
|
||||
// Member variable assignment
|
||||
PlayerCharacter player = origin.getPlayerCharacter();
|
||||
|
||||
msg = (ItemProductionMsg) baseMsg;
|
||||
player = origin.getPlayerCharacter();
|
||||
if (player == null)
|
||||
return;
|
||||
|
||||
if (player == null)
|
||||
return true;
|
||||
|
||||
// Grab reference to vendor we are interacting with
|
||||
|
||||
vendorNPC = (NPC) DbManager.getObject(engine.Enum.GameObjectType.NPC, msg.getNpcUUID());
|
||||
|
||||
// Oops?
|
||||
|
||||
if (vendorNPC == null)
|
||||
return true;
|
||||
|
||||
// Process Request
|
||||
|
||||
switch (msg.getActionType()) {
|
||||
|
||||
case ACTION_PRODUCE:
|
||||
boolean isRandom = false;
|
||||
if (msg.getUnknown03() != 0 && msg.getpToken() == 0 && msg.getsToken() == 0)
|
||||
isRandom = true;
|
||||
//Create Multiple Item Function.. Fill all empty slots
|
||||
if (msg.isMultiple()){
|
||||
int emptySlots = vendorNPC.getRank() - vendorNPC.getRolling().size();
|
||||
if (emptySlots > 0){
|
||||
for (int i = 0;i<emptySlots;i++){
|
||||
vendorNPC.produceItem(player.getObjectUUID(),msg.getTotalProduction(),isRandom,msg.getpToken(),msg.getsToken(),msg.getName(),msg.getItemUUID());
|
||||
}
|
||||
}
|
||||
}else
|
||||
vendorNPC.produceItem(player.getObjectUUID(),msg.getTotalProduction(),isRandom,msg.getpToken(),msg.getsToken(),msg.getName(),msg.getItemUUID());
|
||||
break;
|
||||
case ACTION_JUNK:
|
||||
junkItem(msg.getItemUUID(), vendorNPC, origin);
|
||||
break;
|
||||
case ACTION_RECYCLE:
|
||||
recycleItem(msg.getItemIDtoTypeMap(), vendorNPC, origin);
|
||||
msg.setActionType(7);
|
||||
dispatch = Dispatch.borrow(player, msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
break;
|
||||
case ACTION_COMPLETE:
|
||||
|
||||
vendorNPC.completeItem(msg.getItemUUID());
|
||||
|
||||
// ManageNPCMsg outMsg = new ManageNPCMsg(vendorNPC);
|
||||
// outMsg.setMessageType(1);
|
||||
//
|
||||
// dispatch = Dispatch.borrow(player, outMsg);
|
||||
// DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
if (itemType == GameObjectType.Item.ordinal())
|
||||
targetItem = Item.getFromCache(itemUUID);
|
||||
else if (itemType == GameObjectType.MobLoot.ordinal())
|
||||
targetItem = MobLoot.getFromCache(itemUUID);
|
||||
else
|
||||
targetItem = null;
|
||||
|
||||
|
||||
if (targetItem == null)
|
||||
return;
|
||||
|
||||
if (targetItem.getObjectType() == GameObjectType.Item) {
|
||||
if (!DbManager.ItemQueries.UPDATE_VALUE(targetItem, itemPrice)) {
|
||||
ChatManager.chatInfoError(origin.getPlayerCharacter(), "Failed to set price! Contact CCR For help.");
|
||||
return;
|
||||
}
|
||||
targetItem.setValue(itemPrice);
|
||||
outMsg = new ItemProductionMsg(vendor.getBuilding(), vendor, targetItem, ACTION_DEPOSIT, true);
|
||||
dispatch = Dispatch.borrow(player, outMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
|
||||
outMsg = new ItemProductionMsg(vendor.getBuilding(), vendor, targetItem, ACTION_SETPRICE, true);
|
||||
dispatch = Dispatch.borrow(player, outMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
} else if (targetItem.getObjectType() == GameObjectType.MobLoot) {
|
||||
MobLoot mobLoot = (MobLoot) targetItem;
|
||||
if (!DbManager.NPCQueries.UPDATE_ITEM_PRICE(mobLoot.getObjectUUID(), vendor.getObjectUUID(), itemPrice)) {
|
||||
ChatManager.chatInfoError(origin.getPlayerCharacter(), "Failed to set price! Contact CCR For help.");
|
||||
return;
|
||||
}
|
||||
targetItem.setValue(itemPrice);
|
||||
outMsg = new ItemProductionMsg(vendor.getBuilding(), vendor, targetItem, ACTION_DEPOSIT, true);
|
||||
dispatch = Dispatch.borrow(player, outMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
|
||||
outMsg = new ItemProductionMsg(vendor.getBuilding(), vendor, targetItem, ACTION_SETPRICE, true);
|
||||
dispatch = Dispatch.borrow(player, outMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
}
|
||||
|
||||
break;
|
||||
case ACTION_DEPOSIT:
|
||||
depositItem(msg.getItemUUID(), vendorNPC, origin);
|
||||
break;
|
||||
case ACTION_SETPRICE:
|
||||
setItemPrice(msg.getItemType(),msg.getItemUUID(), msg.getItemPrice(), vendorNPC, origin);
|
||||
break;
|
||||
case ACTION_TAKE:
|
||||
takeItem(msg.getItemIDtoTypeMap(), vendorNPC, origin);
|
||||
dispatch = Dispatch.borrow(player, msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
break;
|
||||
// Set item's price
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Method sets the price on an item in the vendor inventory
|
||||
}
|
||||
|
||||
private static void setItemPrice(int itemType, int itemUUID, int itemPrice, NPC vendor, ClientConnection origin) {
|
||||
// Method sets the price on an item in the vendor inventory
|
||||
|
||||
Item targetItem;
|
||||
ItemProductionMsg outMsg;
|
||||
Dispatch dispatch;
|
||||
private static void depositItem(int itemUUID, NPC vendor, ClientConnection origin) {
|
||||
|
||||
PlayerCharacter player = origin.getPlayerCharacter();
|
||||
Item targetItem;
|
||||
ItemProductionMsg outMsg;
|
||||
CharacterItemManager itemMan;
|
||||
Dispatch dispatch;
|
||||
|
||||
if (player == null)
|
||||
return;
|
||||
PlayerCharacter player = origin.getPlayerCharacter();
|
||||
|
||||
if (itemType == GameObjectType.Item.ordinal())
|
||||
targetItem = Item.getFromCache(itemUUID);
|
||||
else if (itemType == GameObjectType.MobLoot.ordinal())
|
||||
targetItem = MobLoot.getFromCache(itemUUID);
|
||||
else
|
||||
targetItem = null;
|
||||
if (player == null)
|
||||
return;
|
||||
|
||||
if (origin.sellLock.tryLock()) {
|
||||
try {
|
||||
targetItem = Item.getFromCache(itemUUID);
|
||||
|
||||
if (targetItem == null)
|
||||
return;
|
||||
if (targetItem == null)
|
||||
return;
|
||||
|
||||
if (targetItem.getObjectType() == GameObjectType.Item){
|
||||
if (!DbManager.ItemQueries.UPDATE_VALUE(targetItem, itemPrice)) {
|
||||
ChatManager.chatInfoError(origin.getPlayerCharacter(), "Failed to set price! Contact CCR For help.");
|
||||
return;
|
||||
}
|
||||
targetItem.setValue(itemPrice);
|
||||
outMsg = new ItemProductionMsg(vendor.getBuilding(), vendor, targetItem, ACTION_DEPOSIT, true);
|
||||
dispatch = Dispatch.borrow(player, outMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
if (targetItem.getItemBase().getType() == ItemType.GOLD)
|
||||
return;
|
||||
|
||||
outMsg = new ItemProductionMsg(vendor.getBuilding(), vendor, targetItem, ACTION_SETPRICE, true);
|
||||
dispatch = Dispatch.borrow(player, outMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
}else if (targetItem.getObjectType() == GameObjectType.MobLoot){
|
||||
MobLoot mobLoot = (MobLoot)targetItem;
|
||||
if (!DbManager.NPCQueries.UPDATE_ITEM_PRICE(mobLoot.getObjectUUID(), vendor.getObjectUUID(), itemPrice)) {
|
||||
ChatManager.chatInfoError(origin.getPlayerCharacter(), "Failed to set price! Contact CCR For help.");
|
||||
return;
|
||||
}
|
||||
targetItem.setValue(itemPrice);
|
||||
outMsg = new ItemProductionMsg(vendor.getBuilding(), vendor, targetItem, ACTION_DEPOSIT, true);
|
||||
dispatch = Dispatch.borrow(player, outMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
if (!vendor.getCharItemManager().hasRoomInventory(targetItem.getItemBase().getWeight())) {
|
||||
|
||||
outMsg = new ItemProductionMsg(vendor.getBuilding(), vendor, targetItem, ACTION_SETPRICE, true);
|
||||
dispatch = Dispatch.borrow(player, outMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
}
|
||||
ErrorPopupMsg.sendErrorPopup(player, 21);
|
||||
return;
|
||||
}
|
||||
|
||||
// Set item's price
|
||||
itemMan = origin.getPlayerCharacter().getCharItemManager();
|
||||
|
||||
if (itemMan == null)
|
||||
return;
|
||||
|
||||
}
|
||||
if (vendor.getCharItemManager().getInventoryWeight() > 500) {
|
||||
ErrorPopupMsg.sendErrorPopup(player, 21);
|
||||
return;
|
||||
}
|
||||
|
||||
// Method adds an item from the players inventory to the vendor.
|
||||
if (!targetItem.validForInventory(origin, player, itemMan)) {
|
||||
ErrorPopupMsg.sendErrorPopup(player, 19);
|
||||
return;
|
||||
}
|
||||
|
||||
private static void depositItem(int itemUUID, NPC vendor, ClientConnection origin) {
|
||||
// Transfer item from player to vendor's inventory
|
||||
|
||||
Item targetItem;
|
||||
ItemProductionMsg outMsg;
|
||||
CharacterItemManager itemMan;
|
||||
Dispatch dispatch;
|
||||
if (!itemMan.sellToNPC(targetItem, vendor)) {
|
||||
ErrorPopupMsg.sendErrorPopup(player, 109);
|
||||
return;
|
||||
}
|
||||
|
||||
PlayerCharacter player = origin.getPlayerCharacter();
|
||||
|
||||
if (player == null)
|
||||
return;
|
||||
outMsg = new ItemProductionMsg(vendor.getBuilding(), vendor, targetItem, ACTION_DEPOSIT, true);
|
||||
dispatch = Dispatch.borrow(player, outMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
|
||||
if (origin.sellLock.tryLock()) {
|
||||
try {
|
||||
targetItem = Item.getFromCache(itemUUID);
|
||||
outMsg = new ItemProductionMsg(vendor.getBuilding(), vendor, targetItem, ACTION_CONFIRM_DEPOSIT, true);
|
||||
dispatch = Dispatch.borrow(player, outMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
|
||||
if (targetItem == null)
|
||||
return;
|
||||
origin.getPlayerCharacter().getCharItemManager().updateInventory();
|
||||
} catch (Exception e) {
|
||||
Logger.error(e);
|
||||
} finally {
|
||||
origin.sellLock.unlock();
|
||||
}
|
||||
|
||||
if (targetItem.getItemBase().getType() == ItemType.GOLD)
|
||||
return;
|
||||
}
|
||||
|
||||
if (!vendor.getCharItemManager().hasRoomInventory(targetItem.getItemBase().getWeight())){
|
||||
|
||||
ErrorPopupMsg.sendErrorPopup(player, 21);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
itemMan = origin.getPlayerCharacter().getCharItemManager();
|
||||
// Method adds an item from the players inventory to the vendor.
|
||||
|
||||
if (itemMan == null)
|
||||
return;
|
||||
private static void completeItem(int itemUUID, NPC vendor, ClientConnection origin, ItemProductionMsg msg) {
|
||||
|
||||
if (vendor.getCharItemManager().getInventoryWeight() > 500) {
|
||||
ErrorPopupMsg.sendErrorPopup(player, 21);
|
||||
return;
|
||||
}
|
||||
Item targetItem;
|
||||
ManageNPCMsg outMsg;
|
||||
Dispatch dispatch;
|
||||
|
||||
if (!targetItem.validForInventory(origin, player, itemMan)){
|
||||
ErrorPopupMsg.sendErrorPopup(player, 19);
|
||||
return;
|
||||
}
|
||||
PlayerCharacter player = origin.getPlayerCharacter();
|
||||
|
||||
// Transfer item from player to vendor's inventory
|
||||
if (player == null)
|
||||
return;
|
||||
|
||||
if (!itemMan.sellToNPC(targetItem, vendor)){
|
||||
ErrorPopupMsg.sendErrorPopup(player, 109);
|
||||
return;
|
||||
}
|
||||
if (origin.buyLock.tryLock()) {
|
||||
try {
|
||||
targetItem = Item.getFromCache(itemUUID);
|
||||
|
||||
if (targetItem == null)
|
||||
return;
|
||||
|
||||
outMsg = new ItemProductionMsg(vendor.getBuilding(), vendor, targetItem, ACTION_DEPOSIT, true);
|
||||
dispatch = Dispatch.borrow(player, outMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
|
||||
outMsg = new ItemProductionMsg(vendor.getBuilding(), vendor, targetItem, ACTION_CONFIRM_DEPOSIT, true);
|
||||
dispatch = Dispatch.borrow(player, outMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
if (!vendor.getCharItemManager().forgeContains(targetItem, vendor))
|
||||
return;
|
||||
|
||||
origin.getPlayerCharacter().getCharItemManager().updateInventory();
|
||||
}catch (Exception e){
|
||||
Logger.error(e);
|
||||
}finally {
|
||||
origin.sellLock.unlock();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
boolean worked = DbManager.ItemQueries.UPDATE_FORGE_TO_INVENTORY(targetItem);
|
||||
if (!worked) {
|
||||
Guild guild = vendor.getGuild();
|
||||
if (guild == null)
|
||||
return;
|
||||
//ChatManager.chatGuildInfo(guild, "Failed to complete Item " + targetItem.getName());
|
||||
return;
|
||||
}
|
||||
|
||||
targetItem.containerType = Enum.ItemContainerType.INVENTORY;
|
||||
targetItem.setOwner(vendor);
|
||||
vendor.getCharItemManager().addItemToInventory(targetItem);
|
||||
|
||||
}
|
||||
vendor.removeItemFromForge(targetItem);
|
||||
|
||||
// Method completes an item that has been previously rolled
|
||||
// adding it to the NPC's inventory
|
||||
outMsg = new ManageNPCMsg(vendor);
|
||||
outMsg.setMessageType(ACTION_PRODUCE);
|
||||
dispatch = Dispatch.borrow(player, outMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
} finally {
|
||||
origin.buyLock.unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void completeItem(int itemUUID, NPC vendor, ClientConnection origin, ItemProductionMsg msg) {
|
||||
// Method completes an item that has been previously rolled
|
||||
// adding it to the NPC's inventory
|
||||
|
||||
Item targetItem;
|
||||
ManageNPCMsg outMsg;
|
||||
Dispatch dispatch;
|
||||
private static void recycleItem(HashMap<Integer, Integer> itemList, NPC vendor, ClientConnection origin) {
|
||||
|
||||
PlayerCharacter player = origin.getPlayerCharacter();
|
||||
Item targetItem;
|
||||
ItemProductionMsg outMsg;
|
||||
int totalValue = 0;
|
||||
int currentStrongbox;
|
||||
Dispatch dispatch;
|
||||
|
||||
if (player == null)
|
||||
return;
|
||||
if (vendor.getBuilding() == null)
|
||||
return;
|
||||
|
||||
if (origin.buyLock.tryLock()) {
|
||||
try {
|
||||
targetItem = Item.getFromCache(itemUUID);
|
||||
PlayerCharacter player = origin.getPlayerCharacter();
|
||||
|
||||
if (targetItem == null)
|
||||
return;
|
||||
if (player == null)
|
||||
return;
|
||||
|
||||
if (itemList == null)
|
||||
return;
|
||||
|
||||
if (!vendor.getCharItemManager().forgeContains(targetItem, vendor))
|
||||
return;
|
||||
if (origin.sellLock.tryLock()) {
|
||||
try {
|
||||
|
||||
boolean worked = DbManager.ItemQueries.UPDATE_FORGE_TO_INVENTORY(targetItem);
|
||||
if (!worked) {
|
||||
Guild guild = vendor.getGuild();
|
||||
if (guild == null)
|
||||
return;
|
||||
//ChatManager.chatGuildInfo(guild, "Failed to complete Item " + targetItem.getName());
|
||||
return;
|
||||
}
|
||||
|
||||
targetItem.containerType = Enum.ItemContainerType.INVENTORY;
|
||||
targetItem.setOwner(vendor);
|
||||
vendor.getCharItemManager().addItemToInventory(targetItem);
|
||||
for (int itemUUID : itemList.keySet()) {
|
||||
int itemValue = 0;
|
||||
|
||||
vendor.removeItemFromForge(targetItem);
|
||||
int type = itemList.get(itemUUID);
|
||||
|
||||
outMsg = new ManageNPCMsg(vendor);
|
||||
outMsg.setMessageType(ACTION_PRODUCE);
|
||||
dispatch = Dispatch.borrow(player, outMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
} finally {
|
||||
origin.buyLock.unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (type == GameObjectType.Item.ordinal())
|
||||
targetItem = Item.getFromCache(itemUUID);
|
||||
else
|
||||
targetItem = MobLoot.getFromCache(itemUUID);
|
||||
|
||||
// Method handles recycling of an item
|
||||
if (targetItem == null)
|
||||
continue;
|
||||
|
||||
private static void recycleItem(HashMap<Integer, Integer> itemList, NPC vendor, ClientConnection origin) {
|
||||
if (targetItem.getItemBase().getType() == ItemType.GOLD)
|
||||
return;
|
||||
|
||||
Item targetItem;
|
||||
ItemProductionMsg outMsg;
|
||||
int totalValue = 0;
|
||||
int currentStrongbox;
|
||||
Dispatch dispatch;
|
||||
if (!vendor.getCharItemManager().doesCharOwnThisItem(targetItem.getObjectUUID()))
|
||||
continue;
|
||||
if (vendor.getCharItemManager().inventoryContains(targetItem) == false)
|
||||
continue;
|
||||
|
||||
if (vendor.getBuilding() == null)
|
||||
return;
|
||||
itemValue = targetItem.getBaseValue();
|
||||
|
||||
PlayerCharacter player = origin.getPlayerCharacter();
|
||||
if (vendor.getBuilding().getStrongboxValue() + itemValue > vendor.getBuilding().getMaxGold()) {
|
||||
ErrorPopupMsg.sendErrorPopup(player, 201);
|
||||
break;
|
||||
}
|
||||
|
||||
if (player == null)
|
||||
return;
|
||||
switch (targetItem.getItemBase().getType()) {
|
||||
case CONTRACT:
|
||||
case GUILDCHARTER:
|
||||
case DEED:
|
||||
case REALMCHARTER:
|
||||
case SCROLL:
|
||||
case TEARS:
|
||||
itemValue = 0;
|
||||
continue;
|
||||
}
|
||||
totalValue += itemValue;
|
||||
long start = System.currentTimeMillis();
|
||||
vendor.getCharItemManager().recycle(targetItem);
|
||||
long end = System.currentTimeMillis();
|
||||
long timetook = end - start;
|
||||
|
||||
if (itemList == null)
|
||||
return;
|
||||
|
||||
if (origin.sellLock.tryLock()) {
|
||||
try {
|
||||
// ChatManager.chatSystemInfo(player, "Took " + timetook + " ms to finish");
|
||||
|
||||
outMsg = new ItemProductionMsg(vendor.getBuilding(), vendor, targetItem, ACTION_TAKE, true);
|
||||
|
||||
dispatch = Dispatch.borrow(origin.getPlayerCharacter(), outMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
}
|
||||
|
||||
for (int itemUUID : itemList.keySet()) {
|
||||
int itemValue = 0;
|
||||
// Refund a portion of the gold
|
||||
|
||||
int type = itemList.get(itemUUID);
|
||||
if (!vendor.getBuilding().transferGold(totalValue, false))
|
||||
return;
|
||||
|
||||
if (type == GameObjectType.Item.ordinal())
|
||||
targetItem = Item.getFromCache(itemUUID);
|
||||
else
|
||||
targetItem = MobLoot.getFromCache(itemUUID);
|
||||
|
||||
if (targetItem == null)
|
||||
continue;
|
||||
} catch (Exception e) {
|
||||
Logger.error(e);
|
||||
} finally {
|
||||
|
||||
if (targetItem.getItemBase().getType() == ItemType.GOLD)
|
||||
return;
|
||||
origin.sellLock.unlock();
|
||||
}
|
||||
|
||||
if (!vendor.getCharItemManager().doesCharOwnThisItem(targetItem.getObjectUUID()))
|
||||
continue;
|
||||
if (vendor.getCharItemManager().inventoryContains(targetItem) == false)
|
||||
continue;
|
||||
}
|
||||
|
||||
itemValue = targetItem.getBaseValue();
|
||||
// Refresh vendor's inventory to client
|
||||
|
||||
if (vendor.getBuilding().getStrongboxValue() + itemValue > vendor.getBuilding().getMaxGold()) {
|
||||
ErrorPopupMsg.sendErrorPopup(player, 201);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
switch (targetItem.getItemBase().getType()) {
|
||||
case CONTRACT:
|
||||
case GUILDCHARTER:
|
||||
case DEED:
|
||||
case REALMCHARTER:
|
||||
case SCROLL:
|
||||
case TEARS:
|
||||
itemValue = 0;
|
||||
continue;
|
||||
}
|
||||
totalValue += itemValue;
|
||||
long start = System.currentTimeMillis();
|
||||
vendor.getCharItemManager().recycle(targetItem);
|
||||
long end = System.currentTimeMillis();
|
||||
long timetook = end - start;
|
||||
// Method handles recycling of an item
|
||||
|
||||
// ChatManager.chatSystemInfo(player, "Took " + timetook + " ms to finish");
|
||||
private static void junkItem(int itemUUID, NPC vendor, ClientConnection origin) {
|
||||
|
||||
outMsg = new ItemProductionMsg(vendor.getBuilding(), vendor, targetItem, ACTION_TAKE, true);
|
||||
MobLoot targetItem;
|
||||
ManageNPCMsg outMsg;
|
||||
Dispatch dispatch;
|
||||
|
||||
dispatch = Dispatch.borrow(origin.getPlayerCharacter(), outMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
}
|
||||
if (origin.sellLock.tryLock()) {
|
||||
try {
|
||||
targetItem = MobLoot.getFromCache(itemUUID);
|
||||
|
||||
// Refund a portion of the gold
|
||||
PlayerCharacter player = origin.getPlayerCharacter();
|
||||
|
||||
if (!vendor.getBuilding().transferGold(totalValue,false))
|
||||
return;
|
||||
|
||||
|
||||
if (player == null)
|
||||
return;
|
||||
|
||||
}catch (Exception e){
|
||||
Logger.error(e);
|
||||
}finally {
|
||||
|
||||
origin.sellLock.unlock();
|
||||
}
|
||||
// Can't junk nothing!
|
||||
|
||||
}
|
||||
if (targetItem == null)
|
||||
return;
|
||||
|
||||
// Refresh vendor's inventory to client
|
||||
|
||||
}
|
||||
if (!vendor.getCharItemManager().forgeContains(targetItem, vendor))
|
||||
return;
|
||||
|
||||
// Method junks an item that has been rolled but not completed
|
||||
// Cannot junk items without a forge!
|
||||
|
||||
private static void junkItem(int itemUUID, NPC vendor, ClientConnection origin) {
|
||||
if (vendor.getBuilding() == null)
|
||||
return;
|
||||
|
||||
MobLoot targetItem;
|
||||
ManageNPCMsg outMsg;
|
||||
Dispatch dispatch;
|
||||
// Delete the item and cancel any pending rolling timer jobs
|
||||
|
||||
if (origin.sellLock.tryLock()) {
|
||||
try {
|
||||
targetItem = MobLoot.getFromCache(itemUUID);
|
||||
targetItem.recycle(vendor);
|
||||
vendor.removeItemFromForge(targetItem);
|
||||
|
||||
PlayerCharacter player = origin.getPlayerCharacter();
|
||||
// Refresh vendor's inventory to client
|
||||
|
||||
if (player == null)
|
||||
return;
|
||||
outMsg = new ManageNPCMsg(vendor);
|
||||
outMsg.setMessageType(1);
|
||||
dispatch = Dispatch.borrow(player, outMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
;
|
||||
} finally {
|
||||
origin.sellLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
// Can't junk nothing!
|
||||
}
|
||||
|
||||
if (targetItem == null)
|
||||
return;
|
||||
// Method junks an item that has been rolled but not completed
|
||||
|
||||
private static void takeItem(HashMap<Integer, Integer> itemList, NPC vendor, ClientConnection origin) {
|
||||
|
||||
Item targetItem;
|
||||
|
||||
if (!vendor.getCharItemManager().forgeContains(targetItem, vendor))
|
||||
return;
|
||||
|
||||
// Cannot junk items without a forge!
|
||||
PlayerCharacter player = origin.getPlayerCharacter();
|
||||
|
||||
if (vendor.getBuilding() == null)
|
||||
return;
|
||||
if (player == null)
|
||||
return;
|
||||
|
||||
// Delete the item and cancel any pending rolling timer jobs
|
||||
|
||||
targetItem.recycle(vendor);
|
||||
vendor.removeItemFromForge(targetItem);
|
||||
for (int itemUUID : itemList.keySet()) {
|
||||
|
||||
// Refresh vendor's inventory to client
|
||||
int type = itemList.get(itemUUID);
|
||||
if (type == GameObjectType.Item.ordinal()) {
|
||||
targetItem = Item.getFromCache(itemUUID);
|
||||
|
||||
outMsg = new ManageNPCMsg(vendor);
|
||||
outMsg.setMessageType(1);
|
||||
dispatch = Dispatch.borrow(player, outMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
;
|
||||
} finally {
|
||||
origin.sellLock.unlock();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
targetItem = MobLoot.getFromCache(itemUUID);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Method removes item from an NPC's inventory and transferes it to a player
|
||||
if (targetItem == null)
|
||||
return;
|
||||
|
||||
private static void takeItem(HashMap<Integer, Integer> itemList, NPC vendor, ClientConnection origin) {
|
||||
|
||||
Item targetItem;
|
||||
if (targetItem.getItemBase().getType() == ItemType.GOLD)
|
||||
return;
|
||||
if (vendor.getCharItemManager().inventoryContains(targetItem) == false)
|
||||
return;
|
||||
|
||||
if (player.getCharItemManager().hasRoomInventory(targetItem.getItemBase().getWeight()) == false)
|
||||
return;
|
||||
|
||||
PlayerCharacter player = origin.getPlayerCharacter();
|
||||
player.getCharItemManager().buyFromNPC(targetItem, vendor);
|
||||
|
||||
if (player == null)
|
||||
return;
|
||||
}
|
||||
|
||||
player.getCharItemManager().updateInventory();
|
||||
|
||||
// Update NPC inventory to client
|
||||
|
||||
for (int itemUUID : itemList.keySet()) {
|
||||
|
||||
int type = itemList.get(itemUUID);
|
||||
if (type == GameObjectType.Item.ordinal()){
|
||||
targetItem = Item.getFromCache(itemUUID);
|
||||
}
|
||||
|
||||
}
|
||||
else{
|
||||
targetItem = MobLoot.getFromCache(itemUUID);
|
||||
// Method removes item from an NPC's inventory and transferes it to a player
|
||||
|
||||
}
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
|
||||
if (targetItem == null)
|
||||
return;
|
||||
// Member variable declaration
|
||||
|
||||
PlayerCharacter player;
|
||||
NPC vendorNPC;
|
||||
ItemProductionMsg msg;
|
||||
Dispatch dispatch;
|
||||
|
||||
if (targetItem.getItemBase().getType() == ItemType.GOLD)
|
||||
return;
|
||||
if (vendor.getCharItemManager().inventoryContains(targetItem) == false)
|
||||
return;
|
||||
// Member variable assignment
|
||||
|
||||
if (player.getCharItemManager().hasRoomInventory(targetItem.getItemBase().getWeight()) == false)
|
||||
return;
|
||||
msg = (ItemProductionMsg) baseMsg;
|
||||
player = origin.getPlayerCharacter();
|
||||
|
||||
player.getCharItemManager().buyFromNPC(targetItem, vendor);
|
||||
if (player == null)
|
||||
return true;
|
||||
|
||||
}
|
||||
// Grab reference to vendor we are interacting with
|
||||
|
||||
player.getCharItemManager().updateInventory();
|
||||
vendorNPC = (NPC) DbManager.getObject(engine.Enum.GameObjectType.NPC, msg.getNpcUUID());
|
||||
|
||||
// Update NPC inventory to client
|
||||
// Oops?
|
||||
|
||||
if (vendorNPC == null)
|
||||
return true;
|
||||
|
||||
}
|
||||
// Process Request
|
||||
|
||||
// Method handles rolling item requests from the client
|
||||
switch (msg.getActionType()) {
|
||||
|
||||
case ACTION_PRODUCE:
|
||||
boolean isRandom = false;
|
||||
if (msg.getUnknown03() != 0 && msg.getpToken() == 0 && msg.getsToken() == 0)
|
||||
isRandom = true;
|
||||
//Create Multiple Item Function.. Fill all empty slots
|
||||
if (msg.isMultiple()) {
|
||||
int emptySlots = vendorNPC.getRank() - vendorNPC.getRolling().size();
|
||||
if (emptySlots > 0) {
|
||||
for (int i = 0; i < emptySlots; i++) {
|
||||
vendorNPC.produceItem(player.getObjectUUID(), msg.getTotalProduction(), isRandom, msg.getpToken(), msg.getsToken(), msg.getName(), msg.getItemUUID());
|
||||
}
|
||||
}
|
||||
} else
|
||||
vendorNPC.produceItem(player.getObjectUUID(), msg.getTotalProduction(), isRandom, msg.getpToken(), msg.getsToken(), msg.getName(), msg.getItemUUID());
|
||||
break;
|
||||
case ACTION_JUNK:
|
||||
junkItem(msg.getItemUUID(), vendorNPC, origin);
|
||||
break;
|
||||
case ACTION_RECYCLE:
|
||||
recycleItem(msg.getItemIDtoTypeMap(), vendorNPC, origin);
|
||||
msg.setActionType(7);
|
||||
dispatch = Dispatch.borrow(player, msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
break;
|
||||
case ACTION_COMPLETE:
|
||||
|
||||
vendorNPC.completeItem(msg.getItemUUID());
|
||||
|
||||
// ManageNPCMsg outMsg = new ManageNPCMsg(vendorNPC);
|
||||
// outMsg.setMessageType(1);
|
||||
//
|
||||
// dispatch = Dispatch.borrow(player, outMsg);
|
||||
// DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
|
||||
|
||||
break;
|
||||
case ACTION_DEPOSIT:
|
||||
depositItem(msg.getItemUUID(), vendorNPC, origin);
|
||||
break;
|
||||
case ACTION_SETPRICE:
|
||||
setItemPrice(msg.getItemType(), msg.getItemUUID(), msg.getItemPrice(), vendorNPC, origin);
|
||||
break;
|
||||
case ACTION_TAKE:
|
||||
takeItem(msg.getItemIDtoTypeMap(), vendorNPC, origin);
|
||||
dispatch = Dispatch.borrow(player, msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
break;
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Method handles rolling item requests from the client
|
||||
|
||||
}
|
||||
|
||||
@@ -17,32 +17,31 @@ import engine.objects.PlayerCharacter;
|
||||
|
||||
public class KeepAliveServerClientHandler extends AbstractClientMsgHandler {
|
||||
|
||||
public KeepAliveServerClientHandler() {
|
||||
super(KeepAliveServerClientMsg.class);
|
||||
}
|
||||
public KeepAliveServerClientHandler() {
|
||||
super(KeepAliveServerClientMsg.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
|
||||
PlayerCharacter pc = origin.getPlayerCharacter();
|
||||
|
||||
|
||||
|
||||
// Member variable declaration
|
||||
|
||||
KeepAliveServerClientMsg msg;
|
||||
|
||||
// Member variable assignment
|
||||
|
||||
msg = (KeepAliveServerClientMsg) baseMsg;
|
||||
|
||||
|
||||
// Send ping to client
|
||||
|
||||
Dispatch dispatch = Dispatch.borrow(pc, msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.PRIMARY);
|
||||
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
|
||||
PlayerCharacter pc = origin.getPlayerCharacter();
|
||||
|
||||
|
||||
// Member variable declaration
|
||||
|
||||
KeepAliveServerClientMsg msg;
|
||||
|
||||
// Member variable assignment
|
||||
|
||||
msg = (KeepAliveServerClientMsg) baseMsg;
|
||||
|
||||
|
||||
// Send ping to client
|
||||
|
||||
Dispatch dispatch = Dispatch.borrow(pc, msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.PRIMARY);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -23,7 +23,7 @@ public class LeaveGroupHandler extends AbstractClientMsgHandler {
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg,
|
||||
ClientConnection origin) throws MsgSendException {
|
||||
ClientConnection origin) throws MsgSendException {
|
||||
GroupManager.LeaveGroup(origin);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -25,53 +25,53 @@ import engine.objects.PlayerCharacter;
|
||||
|
||||
public class LeaveGuildHandler extends AbstractClientMsgHandler {
|
||||
|
||||
public LeaveGuildHandler() {
|
||||
super(LeaveGuildMsg.class);
|
||||
}
|
||||
public LeaveGuildHandler() {
|
||||
super(LeaveGuildMsg.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
LeaveGuildMsg msg = (LeaveGuildMsg) baseMsg;
|
||||
Dispatch dispatch;
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
LeaveGuildMsg msg = (LeaveGuildMsg) baseMsg;
|
||||
Dispatch dispatch;
|
||||
|
||||
// get PlayerCharacter of person leaving invite
|
||||
// get PlayerCharacter of person leaving invite
|
||||
|
||||
PlayerCharacter playerCharacter = SessionManager.getPlayerCharacter(origin);
|
||||
PlayerCharacter playerCharacter = SessionManager.getPlayerCharacter(origin);
|
||||
|
||||
if (playerCharacter == null)
|
||||
return true;
|
||||
if (playerCharacter == null)
|
||||
return true;
|
||||
|
||||
// Guild leader can't leave guild. must pass GL or disband
|
||||
// Guild leader can't leave guild. must pass GL or disband
|
||||
|
||||
if (GuildStatusController.isGuildLeader(playerCharacter.getGuildStatus())) {
|
||||
msg.setMessage("You must switch leadership of your guild before leaving!");
|
||||
dispatch = Dispatch.borrow(playerCharacter, msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, engine.Enum.DispatchChannel.SECONDARY);
|
||||
return true;
|
||||
}
|
||||
if (GuildStatusController.isGuildLeader(playerCharacter.getGuildStatus())) {
|
||||
msg.setMessage("You must switch leadership of your guild before leaving!");
|
||||
dispatch = Dispatch.borrow(playerCharacter, msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, engine.Enum.DispatchChannel.SECONDARY);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Release all mine claims
|
||||
// Release all mine claims
|
||||
|
||||
Mine.releaseMineClaims(playerCharacter);
|
||||
Mine.releaseMineClaims(playerCharacter);
|
||||
|
||||
// get old Guild
|
||||
Guild oldGuild = playerCharacter.getGuild();
|
||||
// get old Guild
|
||||
Guild oldGuild = playerCharacter.getGuild();
|
||||
|
||||
if (oldGuild == null || oldGuild.isEmptyGuild()) {
|
||||
return true;
|
||||
}
|
||||
if (oldGuild == null || oldGuild.isEmptyGuild()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Send left guild message to rest of guild
|
||||
ChatManager.chatGuildInfo(oldGuild, playerCharacter.getFirstName() + " has left the guild.");
|
||||
// Send left guild message to rest of guild
|
||||
ChatManager.chatGuildInfo(oldGuild, playerCharacter.getFirstName() + " has left the guild.");
|
||||
|
||||
oldGuild.removePlayer(playerCharacter, GuildHistoryType.LEAVE);
|
||||
oldGuild.removePlayer(playerCharacter, GuildHistoryType.LEAVE);
|
||||
|
||||
// Send message back to client
|
||||
msg.setMessage("You have left the guild.");
|
||||
dispatch = Dispatch.borrow(playerCharacter, msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, engine.Enum.DispatchChannel.SECONDARY);
|
||||
// Send message back to client
|
||||
msg.setMessage("You have left the guild.");
|
||||
dispatch = Dispatch.borrow(playerCharacter, msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, engine.Enum.DispatchChannel.SECONDARY);
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ import org.pmw.tinylog.Logger;
|
||||
* @Author:
|
||||
* @Summary: Processes application protocol message which handle
|
||||
* lock and unlock door requests to and from the client.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
public class LockUnlockDoorMsgHandler extends AbstractClientMsgHandler {
|
||||
@@ -31,14 +31,14 @@ public class LockUnlockDoorMsgHandler extends AbstractClientMsgHandler {
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
|
||||
// Member variable declarations
|
||||
|
||||
|
||||
PlayerCharacter player;
|
||||
Building targetBuilding;
|
||||
int doorNum;
|
||||
LockUnlockDoorMsg msg;
|
||||
|
||||
// Member variable assignment
|
||||
|
||||
|
||||
msg = (LockUnlockDoorMsg) baseMsg;
|
||||
player = SessionManager.getPlayerCharacter(origin);
|
||||
targetBuilding = BuildingManager.getBuilding((int) msg.getTargetID());
|
||||
@@ -59,9 +59,9 @@ public class LockUnlockDoorMsgHandler extends AbstractClientMsgHandler {
|
||||
doorNum = Blueprint.getDoorNumberbyMesh(msg.getDoorID());
|
||||
|
||||
// Debugging code
|
||||
|
||||
|
||||
// Logger.debug("DoorLockUnlock", "Door mesh: " + msg.getDoorID() + " Door number: " + doorNum);
|
||||
|
||||
|
||||
boolean stateChanged;
|
||||
|
||||
if (targetBuilding.isDoorLocked(doorNum)) {
|
||||
|
||||
@@ -25,100 +25,100 @@ import org.pmw.tinylog.Logger;
|
||||
|
||||
public class LoginToGameServerMsgHandler extends AbstractClientMsgHandler {
|
||||
|
||||
public LoginToGameServerMsgHandler() {
|
||||
super(LoginToGameServerMsg.class);
|
||||
}
|
||||
public LoginToGameServerMsgHandler() {
|
||||
super(LoginToGameServerMsg.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
|
||||
LoginToGameServerMsg msg = (LoginToGameServerMsg) baseMsg;
|
||||
LoginToGameServerMsg msg = (LoginToGameServerMsg) baseMsg;
|
||||
|
||||
CSSession sessionInfo = CSSession.getCrossServerSession(msg.getSecKey());
|
||||
CSSession sessionInfo = CSSession.getCrossServerSession(msg.getSecKey());
|
||||
|
||||
if (sessionInfo == null) {
|
||||
Logger.error("Failed to validate session information from " + origin.getLocalAddressAndPortAsString());
|
||||
origin.kickToLogin(MBServerStatics.LOGINERROR_UNABLE_TO_LOGIN, "Unable to validate session data");
|
||||
// TODO Evaluate if we need to delete CSSessions here. We couldn't
|
||||
// find it before, why would this attempt be different?
|
||||
if (sessionInfo == null) {
|
||||
Logger.error("Failed to validate session information from " + origin.getLocalAddressAndPortAsString());
|
||||
origin.kickToLogin(MBServerStatics.LOGINERROR_UNABLE_TO_LOGIN, "Unable to validate session data");
|
||||
// TODO Evaluate if we need to delete CSSessions here. We couldn't
|
||||
// find it before, why would this attempt be different?
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Account acc = sessionInfo.getAccount();
|
||||
Account acc = sessionInfo.getAccount();
|
||||
|
||||
if (acc == null) {
|
||||
String err = "Session returned NULL Account. Conn:" + origin.getLocalAddressAndPortAsString();
|
||||
Logger.error(err);
|
||||
origin.kickToLogin(MBServerStatics.LOGINERROR_UNABLE_TO_LOGIN, err);
|
||||
return true;
|
||||
}
|
||||
if (acc == null) {
|
||||
String err = "Session returned NULL Account. Conn:" + origin.getLocalAddressAndPortAsString();
|
||||
Logger.error(err);
|
||||
origin.kickToLogin(MBServerStatics.LOGINERROR_UNABLE_TO_LOGIN, err);
|
||||
return true;
|
||||
}
|
||||
|
||||
PlayerCharacter pc = sessionInfo.getPlayerCharacter();
|
||||
PlayerCharacter pc = sessionInfo.getPlayerCharacter();
|
||||
|
||||
if (pc == null) {
|
||||
String err = "Session returned NULL PlayerCharacter. Conn:" + origin.getLocalAddressAndPortAsString();
|
||||
if (pc == null) {
|
||||
String err = "Session returned NULL PlayerCharacter. Conn:" + origin.getLocalAddressAndPortAsString();
|
||||
|
||||
Logger.error(err);
|
||||
origin.kickToLogin(MBServerStatics.LOGINERROR_UNABLE_TO_LOGIN, err);
|
||||
return true;
|
||||
}
|
||||
Logger.error(err);
|
||||
origin.kickToLogin(MBServerStatics.LOGINERROR_UNABLE_TO_LOGIN, err);
|
||||
return true;
|
||||
}
|
||||
|
||||
// If account is suspended, kick
|
||||
// If account is suspended, kick
|
||||
|
||||
if (acc.status.equals(Enum.AccountStatus.BANNED)) {
|
||||
origin.kickToLogin(MBServerStatics.LOGINERROR_NO_MORE_PLAYTIME_ON_ACCOUNT, "Account banned.");
|
||||
return true;
|
||||
}
|
||||
if (acc.status.equals(Enum.AccountStatus.BANNED)) {
|
||||
origin.kickToLogin(MBServerStatics.LOGINERROR_NO_MORE_PLAYTIME_ON_ACCOUNT, "Account banned.");
|
||||
return true;
|
||||
}
|
||||
|
||||
ClientConnection old = SessionManager.getClientConnection(acc);
|
||||
ClientConnection old = SessionManager.getClientConnection(acc);
|
||||
|
||||
if (old != null)
|
||||
if (old != origin) {
|
||||
Logger.info("Disconnecting other client connection Using Same Account " + old.getRemoteAddressAndPortAsString());
|
||||
old.disconnect();
|
||||
}
|
||||
if (old != null)
|
||||
if (old != origin) {
|
||||
Logger.info("Disconnecting other client connection Using Same Account " + old.getRemoteAddressAndPortAsString());
|
||||
old.disconnect();
|
||||
}
|
||||
|
||||
// Set machine ID here from CSS info
|
||||
origin.machineID = sessionInfo.getMachineID();
|
||||
// Set machine ID here from CSS info
|
||||
origin.machineID = sessionInfo.getMachineID();
|
||||
|
||||
// Send response
|
||||
msg.setSecKey("");
|
||||
// Send response
|
||||
msg.setSecKey("");
|
||||
|
||||
if (!origin.sendMsg(msg)) {
|
||||
Logger.error("Failed to send message");
|
||||
origin.kickToLogin(MBServerStatics.LOGINERROR_UNABLE_TO_LOGIN, "Unable to send ValidateGameServer to client.");
|
||||
return true;
|
||||
}
|
||||
if (!origin.sendMsg(msg)) {
|
||||
Logger.error("Failed to send message");
|
||||
origin.kickToLogin(MBServerStatics.LOGINERROR_UNABLE_TO_LOGIN, "Unable to send ValidateGameServer to client.");
|
||||
return true;
|
||||
}
|
||||
|
||||
//# Why was this all changed?
|
||||
// CLEAN UP OTHER INSTANCES OF THIS CHARACTER
|
||||
//# Why was this all changed?
|
||||
// CLEAN UP OTHER INSTANCES OF THIS CHARACTER
|
||||
|
||||
Session toKill = SessionManager.getSession(sessionInfo.getPlayerCharacter());
|
||||
Session toKill = SessionManager.getSession(sessionInfo.getPlayerCharacter());
|
||||
|
||||
if (toKill != null) {
|
||||
if (toKill.getConn() != null) {
|
||||
LoginErrorMsg lom = new LoginErrorMsg(MBServerStatics.LOGINERROR_UNABLE_TO_LOGIN, "You may not login the same character twice!");
|
||||
ClientConnection conn = toKill.getConn();
|
||||
if (conn != null && !conn.sendMsg(lom))
|
||||
Logger.error("Failed to send message"); // TODO Do we just accept this failure to send Msg?
|
||||
}
|
||||
SessionManager.remSession(toKill);
|
||||
WorldGrid.RemoveWorldObject(sessionInfo.getPlayerCharacter());
|
||||
}
|
||||
Session s = SessionManager.getNewSession(sessionInfo.getAccount(), origin);
|
||||
SessionManager.setPlayerCharacter(s, sessionInfo.getPlayerCharacter());
|
||||
if (toKill != null) {
|
||||
if (toKill.getConn() != null) {
|
||||
LoginErrorMsg lom = new LoginErrorMsg(MBServerStatics.LOGINERROR_UNABLE_TO_LOGIN, "You may not login the same character twice!");
|
||||
ClientConnection conn = toKill.getConn();
|
||||
if (conn != null && !conn.sendMsg(lom))
|
||||
Logger.error("Failed to send message"); // TODO Do we just accept this failure to send Msg?
|
||||
}
|
||||
SessionManager.remSession(toKill);
|
||||
WorldGrid.RemoveWorldObject(sessionInfo.getPlayerCharacter());
|
||||
}
|
||||
Session s = SessionManager.getNewSession(sessionInfo.getAccount(), origin);
|
||||
SessionManager.setPlayerCharacter(s, sessionInfo.getPlayerCharacter());
|
||||
|
||||
Logger.info("Login from Account: " + sessionInfo.getAccount().getUname() + " Character: " +
|
||||
sessionInfo.getPlayerCharacter().getName() + " machineID: " + sessionInfo.getMachineID());
|
||||
Logger.info("Login from Account: " + sessionInfo.getAccount().getUname() + " Character: " +
|
||||
sessionInfo.getPlayerCharacter().getName() + " machineID: " + sessionInfo.getMachineID());
|
||||
|
||||
// Log Admin Login Event
|
||||
// Log Admin Login Event
|
||||
|
||||
if (pc.getAccount().status.equals(Enum.AccountStatus.ADMIN))
|
||||
DbManager.AccountQueries.WRITE_ADMIN_LOG(pc.getCombinedName(), "ADMIN LOGIN");
|
||||
if (pc.getAccount().status.equals(Enum.AccountStatus.ADMIN))
|
||||
DbManager.AccountQueries.WRITE_ADMIN_LOG(pc.getCombinedName(), "ADMIN LOGIN");
|
||||
|
||||
DbManager.AccountQueries.SET_ACCOUNT_LOGIN(sessionInfo.getAccount(), sessionInfo.getPlayerCharacter().getName(), origin.getClientIpAddress(), sessionInfo.getMachineID());
|
||||
return true;
|
||||
}
|
||||
DbManager.AccountQueries.SET_ACCOUNT_LOGIN(sessionInfo.getAccount(), sessionInfo.getPlayerCharacter().getName(), origin.getClientIpAddress(), sessionInfo.getMachineID());
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -23,60 +23,60 @@ import engine.objects.PlayerCharacter;
|
||||
|
||||
public class MOTDCommitHandler extends AbstractClientMsgHandler {
|
||||
|
||||
public MOTDCommitHandler() {
|
||||
super(MOTDCommitMsg.class);
|
||||
}
|
||||
public MOTDCommitHandler() {
|
||||
super(MOTDCommitMsg.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
MOTDCommitMsg msg = (MOTDCommitMsg) baseMsg;
|
||||
Dispatch dispatch;
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
MOTDCommitMsg msg = (MOTDCommitMsg) baseMsg;
|
||||
Dispatch dispatch;
|
||||
|
||||
// get source player
|
||||
PlayerCharacter sourcePlayer = SessionManager.getPlayerCharacter(
|
||||
origin);
|
||||
// get source player
|
||||
PlayerCharacter sourcePlayer = SessionManager.getPlayerCharacter(
|
||||
origin);
|
||||
|
||||
if (sourcePlayer == null)
|
||||
return true;
|
||||
if (sourcePlayer == null)
|
||||
return true;
|
||||
|
||||
int type = msg.getType();
|
||||
int type = msg.getType();
|
||||
|
||||
if (type == 0 || type == 1 || type == 3) {
|
||||
if (type == 0 || type == 1 || type == 3) {
|
||||
|
||||
if (GuildStatusController.isInnerCouncil(sourcePlayer.getGuildStatus()) == false)
|
||||
return true;
|
||||
if (GuildStatusController.isInnerCouncil(sourcePlayer.getGuildStatus()) == false)
|
||||
return true;
|
||||
|
||||
Guild guild = sourcePlayer.getGuild();
|
||||
Guild guild = sourcePlayer.getGuild();
|
||||
|
||||
if (guild == null)
|
||||
return true;
|
||||
if (guild == null)
|
||||
return true;
|
||||
|
||||
if (type == 1) { // Guild MOTD
|
||||
guild.setMOTD(msg.getMessage());
|
||||
ChatManager.chatGuildMOTD(sourcePlayer, msg.getMessage(),
|
||||
true);
|
||||
} else if (type == 3) { // IC MOTD
|
||||
guild.setICMOTD(msg.getMessage());
|
||||
ChatManager
|
||||
.chatICMOTD(sourcePlayer, msg.getMessage(), true);
|
||||
} else if (type == 0) { // Nation MOTD
|
||||
Guild nation = guild.getNation();
|
||||
if (nation == null)
|
||||
return true;
|
||||
if (nation.isNation()) { // only
|
||||
// nation's
|
||||
// primary guild can
|
||||
// set nation motd
|
||||
nation.setMOTD(msg.getMessage());
|
||||
ChatManager.chatNationMOTD(sourcePlayer,
|
||||
msg.getMessage(), true);
|
||||
}
|
||||
}
|
||||
if (type == 1) { // Guild MOTD
|
||||
guild.setMOTD(msg.getMessage());
|
||||
ChatManager.chatGuildMOTD(sourcePlayer, msg.getMessage(),
|
||||
true);
|
||||
} else if (type == 3) { // IC MOTD
|
||||
guild.setICMOTD(msg.getMessage());
|
||||
ChatManager
|
||||
.chatICMOTD(sourcePlayer, msg.getMessage(), true);
|
||||
} else if (type == 0) { // Nation MOTD
|
||||
Guild nation = guild.getNation();
|
||||
if (nation == null)
|
||||
return true;
|
||||
if (nation.isNation()) { // only
|
||||
// nation's
|
||||
// primary guild can
|
||||
// set nation motd
|
||||
nation.setMOTD(msg.getMessage());
|
||||
ChatManager.chatNationMOTD(sourcePlayer,
|
||||
msg.getMessage(), true);
|
||||
}
|
||||
}
|
||||
dispatch = Dispatch.borrow(sourcePlayer, msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, engine.Enum.DispatchChannel.SECONDARY);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -25,59 +25,59 @@ import engine.objects.PlayerCharacter;
|
||||
|
||||
public class MOTDEditHandler extends AbstractClientMsgHandler {
|
||||
|
||||
public MOTDEditHandler() {
|
||||
super(MOTDMsg.class);
|
||||
}
|
||||
public MOTDEditHandler() {
|
||||
super(MOTDMsg.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
MOTDMsg msg = (MOTDMsg) baseMsg;
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
MOTDMsg msg = (MOTDMsg) baseMsg;
|
||||
Dispatch dispatch;
|
||||
|
||||
// get source player
|
||||
PlayerCharacter playerCharacter = SessionManager.getPlayerCharacter(
|
||||
origin);
|
||||
// get source player
|
||||
PlayerCharacter playerCharacter = SessionManager.getPlayerCharacter(
|
||||
origin);
|
||||
|
||||
if (playerCharacter == null)
|
||||
return true;
|
||||
if (playerCharacter == null)
|
||||
return true;
|
||||
|
||||
int type = msg.getType();
|
||||
int type = msg.getType();
|
||||
|
||||
msg.setResponse((byte) 1);
|
||||
if (type == 0 || type == 1 || type == 3) {
|
||||
if (GuildStatusController.isInnerCouncil(playerCharacter.getGuildStatus()) == false) {
|
||||
ErrorPopupMsg.sendErrorMsg(playerCharacter, "You do not have such authority!");
|
||||
return true;
|
||||
}
|
||||
msg.setResponse((byte) 1);
|
||||
if (type == 0 || type == 1 || type == 3) {
|
||||
if (GuildStatusController.isInnerCouncil(playerCharacter.getGuildStatus()) == false) {
|
||||
ErrorPopupMsg.sendErrorMsg(playerCharacter, "You do not have such authority!");
|
||||
return true;
|
||||
}
|
||||
|
||||
Guild guild = playerCharacter.getGuild();
|
||||
Guild guild = playerCharacter.getGuild();
|
||||
|
||||
if (guild == null || guild.getObjectUUID() == 0) {
|
||||
if (guild == null || guild.getObjectUUID() == 0) {
|
||||
|
||||
LeaveGuildMsg leaveGuildMsg = new LeaveGuildMsg();
|
||||
leaveGuildMsg.setMessage("You do not belong to a guild!");
|
||||
dispatch = Dispatch.borrow(playerCharacter, leaveGuildMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if (type == 1) // Guild MOTD
|
||||
msg.setMessage(guild.getMOTD());
|
||||
else if (type == 3) // IC MOTD
|
||||
msg.setMessage(guild.getICMOTD());
|
||||
else if (type == 0) { // Nation MOTD
|
||||
Guild nation = guild.getNation();
|
||||
if (nation == null || !nation.isNation()) {
|
||||
ErrorPopupMsg.sendErrorMsg(playerCharacter, "You do not have such authority!");
|
||||
return true;
|
||||
}
|
||||
msg.setMessage(nation.getMOTD());
|
||||
}
|
||||
if (type == 1) // Guild MOTD
|
||||
msg.setMessage(guild.getMOTD());
|
||||
else if (type == 3) // IC MOTD
|
||||
msg.setMessage(guild.getICMOTD());
|
||||
else if (type == 0) { // Nation MOTD
|
||||
Guild nation = guild.getNation();
|
||||
if (nation == null || !nation.isNation()) {
|
||||
ErrorPopupMsg.sendErrorMsg(playerCharacter, "You do not have such authority!");
|
||||
return true;
|
||||
}
|
||||
msg.setMessage(nation.getMOTD());
|
||||
}
|
||||
dispatch = Dispatch.borrow(playerCharacter, msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,340 +25,335 @@ import org.joda.time.DateTime;
|
||||
*/
|
||||
public class ManageCityAssetMsgHandler extends AbstractClientMsgHandler {
|
||||
|
||||
public ManageCityAssetMsgHandler() {
|
||||
super(ManageCityAssetsMsg.class);
|
||||
}
|
||||
public ManageCityAssetMsgHandler() {
|
||||
super(ManageCityAssetsMsg.class);
|
||||
}
|
||||
|
||||
public static boolean playerCanManageNotFriends(PlayerCharacter player, Building building){
|
||||
public static boolean playerCanManageNotFriends(PlayerCharacter player, Building building) {
|
||||
|
||||
//Player Can only Control Building if player is in Same Guild as Building and is higher rank than IC.
|
||||
//Player Can only Control Building if player is in Same Guild as Building and is higher rank than IC.
|
||||
|
||||
if (player == null)
|
||||
return false;
|
||||
if (player == null)
|
||||
return false;
|
||||
|
||||
if (building.getRank() == -1)
|
||||
return false;
|
||||
if (building.getRank() == -1)
|
||||
return false;
|
||||
|
||||
if (BuildingManager.IsOwner(building, player))
|
||||
return true;
|
||||
if (BuildingManager.IsOwner(building, player))
|
||||
return true;
|
||||
|
||||
if (GuildStatusController.isGuildLeader(player.getGuildStatus()) == false && GuildStatusController.isInnerCouncil(player.getGuildStatus()) == false)
|
||||
return false;
|
||||
if (GuildStatusController.isGuildLeader(player.getGuildStatus()) == false && GuildStatusController.isInnerCouncil(player.getGuildStatus()) == false)
|
||||
return false;
|
||||
|
||||
//Somehow guild leader check fails above? lets check if Player is true Guild GL.
|
||||
if (building.getGuild() != null && building.getGuild().isGuildLeader(player.getObjectUUID()))
|
||||
return true;
|
||||
//Somehow guild leader check fails above? lets check if Player is true Guild GL.
|
||||
if (building.getGuild() != null && building.getGuild().isGuildLeader(player.getObjectUUID()))
|
||||
return true;
|
||||
|
||||
return Guild.sameGuild(building.getGuild(), player.getGuild());
|
||||
return Guild.sameGuild(building.getGuild(), player.getGuild());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
|
||||
ManageCityAssetsMsg msg;
|
||||
PlayerCharacter player;
|
||||
ManageCityAssetsMsg outMsg;
|
||||
Building building;
|
||||
ManageCityAssetsMsg msg;
|
||||
PlayerCharacter player;
|
||||
ManageCityAssetsMsg outMsg;
|
||||
Building building;
|
||||
|
||||
msg = (ManageCityAssetsMsg) baseMsg;
|
||||
msg = (ManageCityAssetsMsg) baseMsg;
|
||||
|
||||
player = SessionManager.getPlayerCharacter(origin);
|
||||
player = SessionManager.getPlayerCharacter(origin);
|
||||
|
||||
if (player == null)
|
||||
return true;
|
||||
if (player == null)
|
||||
return true;
|
||||
|
||||
building = BuildingManager.getBuildingFromCache(msg.getTargetID());
|
||||
building = BuildingManager.getBuildingFromCache(msg.getTargetID());
|
||||
|
||||
if (building == null){
|
||||
if (msg.actionType == 14) {
|
||||
|
||||
Zone zone = ZoneManager.findSmallestZone(player.getLoc());
|
||||
|
||||
if (!zone.isPlayerCity()){
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Unable to find city to command.");
|
||||
return true;
|
||||
}
|
||||
|
||||
City city = City.GetCityFromCache(zone.getPlayerCityUUID());
|
||||
|
||||
if (city == null){
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Unable to find city to command.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!city.getGuild().equals(player.getGuild())){
|
||||
ErrorPopupMsg.sendErrorMsg(player, "You are not in the correct guild to command this city.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!GuildStatusController.isInnerCouncil(player.getGuildStatus()) && !GuildStatusController.isGuildLeader(player.getGuildStatus())){
|
||||
ErrorPopupMsg.sendErrorMsg(player, "You must be an Inner Council or Guild leader to access city commands.");
|
||||
return true;
|
||||
}
|
||||
ManageCityAssetsMsg mca = new ManageCityAssetsMsg(player, building);
|
||||
mca.actionType = 15;
|
||||
Dispatch dispatch = Dispatch.borrow(player, mca);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (building == null) {
|
||||
if (msg.actionType == 14) {
|
||||
|
||||
outMsg = new ManageCityAssetsMsg(player, building);
|
||||
Zone zone = ZoneManager.findSmallestZone(player.getLoc());
|
||||
|
||||
if (player.isSafeMode()){
|
||||
outMsg.actionType = 4;
|
||||
outMsg.setTargetType(building.getObjectType().ordinal());
|
||||
outMsg.setTargetID(building.getObjectUUID());
|
||||
outMsg.setAssetName(building.getName());
|
||||
Dispatch dispatch = Dispatch.borrow(player, outMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
return true;
|
||||
}
|
||||
if (!zone.isPlayerCity()) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Unable to find city to command.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (msg.actionType == 2 || msg.actionType == 22) {
|
||||
City city = City.GetCityFromCache(zone.getPlayerCityUUID());
|
||||
|
||||
if (building.getBlueprint() != null && building.getBlueprint().getBuildingGroup() == engine.Enum.BuildingGroup.BANESTONE) {
|
||||
if (city == null) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Unable to find city to command.");
|
||||
return true;
|
||||
}
|
||||
|
||||
outMsg.actionType = 18;
|
||||
outMsg.setTargetType(building.getObjectType().ordinal());
|
||||
outMsg.setTargetID(building.getObjectUUID());
|
||||
if (!city.getGuild().equals(player.getGuild())) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "You are not in the correct guild to command this city.");
|
||||
return true;
|
||||
}
|
||||
|
||||
} else if (BuildingManager.playerCanManage(player, building)) { //TODO allow Friends list.
|
||||
configWindowState(player, building, outMsg);
|
||||
outMsg.actionType = 3;
|
||||
outMsg.setTargetType(building.getObjectType().ordinal());
|
||||
outMsg.setTargetID(building.getObjectUUID());
|
||||
outMsg.setTargetType3(building.getObjectType().ordinal());
|
||||
outMsg.setTargetID3(building.getObjectUUID());
|
||||
outMsg.setUnknown54(1);
|
||||
if (!GuildStatusController.isInnerCouncil(player.getGuildStatus()) && !GuildStatusController.isGuildLeader(player.getGuildStatus())) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "You must be an Inner Council or Guild leader to access city commands.");
|
||||
return true;
|
||||
}
|
||||
ManageCityAssetsMsg mca = new ManageCityAssetsMsg(player, building);
|
||||
mca.actionType = 15;
|
||||
Dispatch dispatch = Dispatch.borrow(player, mca);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
if (building.getBlueprintUUID() != 0)
|
||||
switch (building.getBlueprint().getBuildingGroup()) {
|
||||
case SHRINE:
|
||||
if (building.getRank() == -1) {
|
||||
if (!Bounds.collide(player.getLoc(), building)) {
|
||||
ErrorPopupMsg.sendErrorPopup(player, 64);
|
||||
return true;
|
||||
}
|
||||
outMsg = new ManageCityAssetsMsg(player, building);
|
||||
|
||||
Shrine shrine = Shrine.shrinesByBuildingUUID.get(building.getObjectUUID());
|
||||
|
||||
if (shrine == null)
|
||||
return true;
|
||||
|
||||
if (shrine.getFavors() == 0) {
|
||||
ErrorPopupMsg.sendErrorPopup(player, 166); // There is no more favor in this shrine to loot
|
||||
return true;
|
||||
}
|
||||
|
||||
BuildingManager.lootBuilding(player, building);
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case WAREHOUSE:
|
||||
//TODO check
|
||||
if (building.getRank() == -1) {
|
||||
if (!Bounds.collide(player.getLoc(), building)) {
|
||||
ErrorPopupMsg.sendErrorPopup(player, 64);
|
||||
return true;
|
||||
}
|
||||
|
||||
Warehouse warehouse = Warehouse.warehouseByBuildingUUID.get(building.getObjectUUID());
|
||||
|
||||
if (warehouse == null)
|
||||
return true;
|
||||
|
||||
if (warehouse.isEmpty()) {
|
||||
ErrorPopupMsg.sendErrorPopup(player, 167); // no more resources.
|
||||
return true;
|
||||
}
|
||||
|
||||
BuildingManager.lootBuilding(player, building);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (building.getRank() == -1)
|
||||
return true;
|
||||
|
||||
AbstractCharacter owner = building.getOwner();
|
||||
|
||||
//no owner, send building info
|
||||
if (owner == null) {
|
||||
msg.actionType = 4;
|
||||
|
||||
Dispatch dispatch = Dispatch.borrow(player, msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
return true;
|
||||
}
|
||||
outMsg.actionType = 4;
|
||||
outMsg.setTargetType(building.getObjectType().ordinal());
|
||||
outMsg.setTargetID(building.getObjectUUID());
|
||||
outMsg.setAssetName(building.getName());
|
||||
|
||||
}
|
||||
Dispatch dispatch = Dispatch.borrow(player, outMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (msg.actionType == 13) {
|
||||
outMsg.actionType = 13;
|
||||
Dispatch dispatch = Dispatch.borrow(player, outMsg);
|
||||
if (player.isSafeMode()) {
|
||||
outMsg.actionType = 4;
|
||||
outMsg.setTargetType(building.getObjectType().ordinal());
|
||||
outMsg.setTargetID(building.getObjectUUID());
|
||||
outMsg.setAssetName(building.getName());
|
||||
Dispatch dispatch = Dispatch.borrow(player, outMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (msg.actionType == 2 || msg.actionType == 22) {
|
||||
|
||||
//Rename Building.
|
||||
if (building.getBlueprint() != null && building.getBlueprint().getBuildingGroup() == engine.Enum.BuildingGroup.BANESTONE) {
|
||||
|
||||
if (msg.actionType == 5) {
|
||||
outMsg.actionType = 18;
|
||||
outMsg.setTargetType(building.getObjectType().ordinal());
|
||||
outMsg.setTargetID(building.getObjectUUID());
|
||||
|
||||
//TODO we need to check names before allowing
|
||||
building.setName(msg.getAssetName());
|
||||
configWindowState(player, building, outMsg);
|
||||
} else if (BuildingManager.playerCanManage(player, building)) { //TODO allow Friends list.
|
||||
configWindowState(player, building, outMsg);
|
||||
outMsg.actionType = 3;
|
||||
outMsg.setTargetType(building.getObjectType().ordinal());
|
||||
outMsg.setTargetID(building.getObjectUUID());
|
||||
outMsg.setTargetType3(building.getObjectType().ordinal());
|
||||
outMsg.setTargetID3(building.getObjectUUID());
|
||||
outMsg.setUnknown54(1);
|
||||
|
||||
outMsg.actionType = 3;
|
||||
outMsg.setTargetType(building.getObjectType().ordinal());
|
||||
outMsg.setTargetID(building.getObjectUUID());
|
||||
outMsg.setTargetType3(GameObjectType.Building.ordinal());
|
||||
outMsg.setTargetID3(building.getObjectUUID());
|
||||
outMsg.setAssetName1(building.getName());
|
||||
outMsg.setUnknown54(1);
|
||||
} else {
|
||||
|
||||
if (building.getBlueprintUUID() != 0)
|
||||
switch (building.getBlueprint().getBuildingGroup()) {
|
||||
case SHRINE:
|
||||
if (building.getRank() == -1) {
|
||||
if (!Bounds.collide(player.getLoc(), building)) {
|
||||
ErrorPopupMsg.sendErrorPopup(player, 64);
|
||||
return true;
|
||||
}
|
||||
|
||||
Shrine shrine = Shrine.shrinesByBuildingUUID.get(building.getObjectUUID());
|
||||
|
||||
if (shrine == null)
|
||||
return true;
|
||||
|
||||
if (shrine.getFavors() == 0) {
|
||||
ErrorPopupMsg.sendErrorPopup(player, 166); // There is no more favor in this shrine to loot
|
||||
return true;
|
||||
}
|
||||
|
||||
BuildingManager.lootBuilding(player, building);
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
case WAREHOUSE:
|
||||
//TODO check
|
||||
if (building.getRank() == -1) {
|
||||
if (!Bounds.collide(player.getLoc(), building)) {
|
||||
ErrorPopupMsg.sendErrorPopup(player, 64);
|
||||
return true;
|
||||
}
|
||||
|
||||
Warehouse warehouse = Warehouse.warehouseByBuildingUUID.get(building.getObjectUUID());
|
||||
|
||||
if (warehouse == null)
|
||||
return true;
|
||||
|
||||
if (warehouse.isEmpty()) {
|
||||
ErrorPopupMsg.sendErrorPopup(player, 167); // no more resources.
|
||||
return true;
|
||||
}
|
||||
|
||||
BuildingManager.lootBuilding(player, building);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (building.getRank() == -1)
|
||||
return true;
|
||||
|
||||
AbstractCharacter owner = building.getOwner();
|
||||
|
||||
//no owner, send building info
|
||||
if (owner == null) {
|
||||
msg.actionType = 4;
|
||||
|
||||
Dispatch dispatch = Dispatch.borrow(player, msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
return true;
|
||||
}
|
||||
outMsg.actionType = 4;
|
||||
outMsg.setTargetType(building.getObjectType().ordinal());
|
||||
outMsg.setTargetID(building.getObjectUUID());
|
||||
outMsg.setAssetName(building.getName());
|
||||
|
||||
}
|
||||
Dispatch dispatch = Dispatch.borrow(player, outMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (msg.actionType == 13) {
|
||||
outMsg.actionType = 13;
|
||||
Dispatch dispatch = Dispatch.borrow(player, outMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//Rename Building.
|
||||
|
||||
if (msg.actionType == 5) {
|
||||
|
||||
//TODO we need to check names before allowing
|
||||
building.setName(msg.getAssetName());
|
||||
configWindowState(player, building, outMsg);
|
||||
|
||||
outMsg.actionType = 3;
|
||||
outMsg.setTargetType(building.getObjectType().ordinal());
|
||||
outMsg.setTargetID(building.getObjectUUID());
|
||||
outMsg.setTargetType3(GameObjectType.Building.ordinal());
|
||||
outMsg.setTargetID3(building.getObjectUUID());
|
||||
outMsg.setAssetName1(building.getName());
|
||||
outMsg.setUnknown54(1);
|
||||
|
||||
Dispatch dispatch = Dispatch.borrow(player, outMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
|
||||
|
||||
return true;
|
||||
|
||||
//TOL, update city name also
|
||||
//TODO update city and zone in database
|
||||
//TODO update city map data in game server
|
||||
}
|
||||
//TOL, update city name also
|
||||
//TODO update city and zone in database
|
||||
//TODO update city map data in game server
|
||||
}
|
||||
|
||||
if (msg.actionType == 14) {
|
||||
ManageCityAssetsMsg mca = new ManageCityAssetsMsg(player, building);
|
||||
mca.actionType = 15;
|
||||
Dispatch dispatch = Dispatch.borrow(player, mca);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
return true;
|
||||
}
|
||||
if (msg.actionType == 14) {
|
||||
ManageCityAssetsMsg mca = new ManageCityAssetsMsg(player, building);
|
||||
mca.actionType = 15;
|
||||
Dispatch dispatch = Dispatch.borrow(player, mca);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (msg.actionType == 20) {
|
||||
if (msg.actionType == 20) {
|
||||
|
||||
Zone baneZone = building.getParentZone();
|
||||
Zone baneZone = building.getParentZone();
|
||||
|
||||
if (baneZone == null)
|
||||
return true;
|
||||
if (baneZone == null)
|
||||
return true;
|
||||
|
||||
City banedCity = City.getCity(baneZone.getPlayerCityUUID());
|
||||
City banedCity = City.getCity(baneZone.getPlayerCityUUID());
|
||||
|
||||
if (banedCity == null)
|
||||
return true;
|
||||
if (banedCity == null)
|
||||
return true;
|
||||
|
||||
Bane bane = banedCity.getBane();
|
||||
Bane bane = banedCity.getBane();
|
||||
|
||||
if (bane == null || bane.getLiveDate() != null || player.getGuild() != banedCity.getGuild() || GuildStatusController.isInnerCouncil(player.getGuildStatus()) == false)
|
||||
return true;
|
||||
if (bane == null || bane.getLiveDate() != null || player.getGuild() != banedCity.getGuild() || GuildStatusController.isInnerCouncil(player.getGuildStatus()) == false)
|
||||
return true;
|
||||
|
||||
int baneHour = msg.getBaneHour();
|
||||
int baneHour = msg.getBaneHour();
|
||||
|
||||
if (baneHour < 16 || baneHour > 24) {
|
||||
PlaceAssetMsg.sendPlaceAssetError(origin, 1, "A Serious error has occurred. Please post details for to ensure transaction integrity");
|
||||
return true;
|
||||
}
|
||||
if (baneHour < 16 || baneHour > 24) {
|
||||
PlaceAssetMsg.sendPlaceAssetError(origin, 1, "A Serious error has occurred. Please post details for to ensure transaction integrity");
|
||||
return true;
|
||||
}
|
||||
|
||||
DateTime baneLive = new DateTime(bane.getPlacementDate());
|
||||
baneLive = baneHour == 24 ? baneLive.plusDays(3) : baneLive.plusDays(2);
|
||||
baneLive = baneHour == 24 ? baneLive.hourOfDay().setCopy(0) : baneLive.hourOfDay().setCopy(baneHour);
|
||||
baneLive = baneLive.minuteOfHour().setCopy(0);
|
||||
baneLive = baneLive.secondOfMinute().setCopy(1);
|
||||
bane.setLiveDate(baneLive);
|
||||
outMsg.actionType = 18;
|
||||
DateTime baneLive = new DateTime(bane.getPlacementDate());
|
||||
baneLive = baneHour == 24 ? baneLive.plusDays(3) : baneLive.plusDays(2);
|
||||
baneLive = baneHour == 24 ? baneLive.hourOfDay().setCopy(0) : baneLive.hourOfDay().setCopy(baneHour);
|
||||
baneLive = baneLive.minuteOfHour().setCopy(0);
|
||||
baneLive = baneLive.secondOfMinute().setCopy(1);
|
||||
bane.setLiveDate(baneLive);
|
||||
outMsg.actionType = 18;
|
||||
|
||||
Dispatch dispatch = Dispatch.borrow(player, outMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
Dispatch dispatch = Dispatch.borrow(player, outMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void configWindowState(PlayerCharacter player, Building building, ManageCityAssetsMsg manageCityAssetsMsg) {
|
||||
public void configWindowState(PlayerCharacter player, Building building, ManageCityAssetsMsg manageCityAssetsMsg) {
|
||||
|
||||
// Tests to turn on upgrade button if a building is not
|
||||
// at it's maximum allowed rank or currently ranking
|
||||
// Tests to turn on upgrade button if a building is not
|
||||
// at it's maximum allowed rank or currently ranking
|
||||
|
||||
|
||||
// Owner is obviously allowed to upgrade his own buildings
|
||||
// Owner is obviously allowed to upgrade his own buildings
|
||||
|
||||
if (building.getOwner().equals(player)) {
|
||||
if (building.getOwner().equals(player)) {
|
||||
|
||||
// Players cannot destroy or transfer a TOL.
|
||||
// Players cannot destroy or transfer a TOL.
|
||||
|
||||
if (building.getBlueprint() == null){
|
||||
manageCityAssetsMsg.buttonDestroy = 0;
|
||||
manageCityAssetsMsg.buttonTransfer = 0;
|
||||
manageCityAssetsMsg.buttonAbandon = 0;
|
||||
manageCityAssetsMsg.buttonUpgrade = 0;
|
||||
}
|
||||
else
|
||||
if (building.getBlueprint().getBuildingGroup() == Enum.BuildingGroup.TOL) {
|
||||
manageCityAssetsMsg.buttonDestroy = 0;
|
||||
manageCityAssetsMsg.buttonTransfer = 0;
|
||||
manageCityAssetsMsg.buttonAbandon = 1;
|
||||
manageCityAssetsMsg.buttonUpgrade = 1;
|
||||
}
|
||||
else if (building.getBlueprint().getBuildingGroup() == Enum.BuildingGroup.MINE) {
|
||||
manageCityAssetsMsg.buttonDestroy = 0;
|
||||
manageCityAssetsMsg.buttonTransfer = 0;
|
||||
manageCityAssetsMsg.buttonAbandon = 0;
|
||||
manageCityAssetsMsg.buttonUpgrade = 0; // Cannot upgrade a mine
|
||||
}
|
||||
else{
|
||||
manageCityAssetsMsg.buttonDestroy = 1;
|
||||
manageCityAssetsMsg.buttonTransfer = 1;
|
||||
manageCityAssetsMsg.buttonAbandon = 1;
|
||||
manageCityAssetsMsg.buttonUpgrade = 1;
|
||||
}
|
||||
}
|
||||
if (building.getBlueprint() == null) {
|
||||
manageCityAssetsMsg.buttonDestroy = 0;
|
||||
manageCityAssetsMsg.buttonTransfer = 0;
|
||||
manageCityAssetsMsg.buttonAbandon = 0;
|
||||
manageCityAssetsMsg.buttonUpgrade = 0;
|
||||
} else if (building.getBlueprint().getBuildingGroup() == Enum.BuildingGroup.TOL) {
|
||||
manageCityAssetsMsg.buttonDestroy = 0;
|
||||
manageCityAssetsMsg.buttonTransfer = 0;
|
||||
manageCityAssetsMsg.buttonAbandon = 1;
|
||||
manageCityAssetsMsg.buttonUpgrade = 1;
|
||||
} else if (building.getBlueprint().getBuildingGroup() == Enum.BuildingGroup.MINE) {
|
||||
manageCityAssetsMsg.buttonDestroy = 0;
|
||||
manageCityAssetsMsg.buttonTransfer = 0;
|
||||
manageCityAssetsMsg.buttonAbandon = 0;
|
||||
manageCityAssetsMsg.buttonUpgrade = 0; // Cannot upgrade a mine
|
||||
} else {
|
||||
manageCityAssetsMsg.buttonDestroy = 1;
|
||||
manageCityAssetsMsg.buttonTransfer = 1;
|
||||
manageCityAssetsMsg.buttonAbandon = 1;
|
||||
manageCityAssetsMsg.buttonUpgrade = 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Inner Council of the same guild can also upgrade
|
||||
// Inner Council of the same guild can also upgrade
|
||||
|
||||
if ((player.getGuild().equals(building.getGuild())) &&
|
||||
GuildStatusController.isInnerCouncil(player.getGuildStatus()))
|
||||
manageCityAssetsMsg.buttonUpgrade = 1;
|
||||
if ((player.getGuild().equals(building.getGuild())) &&
|
||||
GuildStatusController.isInnerCouncil(player.getGuildStatus()))
|
||||
manageCityAssetsMsg.buttonUpgrade = 1;
|
||||
|
||||
// Disable upgrade button if at max rank.
|
||||
// Disable upgrade button if at max rank.
|
||||
|
||||
if (building.getBlueprint() == null)
|
||||
manageCityAssetsMsg.buttonUpgrade = 0;
|
||||
else
|
||||
if (building.getRank() >= building.getBlueprint().getMaxRank())
|
||||
manageCityAssetsMsg.buttonUpgrade = 0;;
|
||||
if (building.getBlueprint() == null)
|
||||
manageCityAssetsMsg.buttonUpgrade = 0;
|
||||
else if (building.getRank() >= building.getBlueprint().getMaxRank())
|
||||
manageCityAssetsMsg.buttonUpgrade = 0;
|
||||
;
|
||||
|
||||
// If a building is not protected we can exit here
|
||||
// If a building is not protected we can exit here
|
||||
|
||||
if (building.assetIsProtected() == false)
|
||||
return;
|
||||
if (building.assetIsProtected() == false)
|
||||
return;
|
||||
|
||||
// Protection is displayed as "UNDER SIEGE" if
|
||||
// an active bane is invalidating the protection
|
||||
// contracts of the city.
|
||||
// Protection is displayed as "UNDER SIEGE" if
|
||||
// an active bane is invalidating the protection
|
||||
// contracts of the city.
|
||||
|
||||
if ((building.getCity() != null) &&
|
||||
(building.getCity().protectionEnforced == false)) {
|
||||
manageCityAssetsMsg.labelProtected = 0;
|
||||
manageCityAssetsMsg.labelSiege = 1;
|
||||
manageCityAssetsMsg.labelCeaseFire = 0;
|
||||
return;
|
||||
}
|
||||
if ((building.getCity() != null) &&
|
||||
(building.getCity().protectionEnforced == false)) {
|
||||
manageCityAssetsMsg.labelProtected = 0;
|
||||
manageCityAssetsMsg.labelSiege = 1;
|
||||
manageCityAssetsMsg.labelCeaseFire = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
// Building is currently protected by a TOL
|
||||
// Building is currently protected by a TOL
|
||||
|
||||
manageCityAssetsMsg.labelProtected = 1;
|
||||
}
|
||||
manageCityAssetsMsg.labelProtected = 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,440 +26,429 @@ import java.util.ArrayList;
|
||||
|
||||
public class MerchantMsgHandler extends AbstractClientMsgHandler {
|
||||
|
||||
public MerchantMsgHandler() {
|
||||
super(MerchantMsg.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
|
||||
// Member variable declaration
|
||||
|
||||
MerchantMsg msg;
|
||||
PlayerCharacter player;
|
||||
NPC npc;
|
||||
int msgType;
|
||||
Building warehouse;
|
||||
Dispatch dispatch;
|
||||
|
||||
// Member variable assignment
|
||||
|
||||
player = SessionManager.getPlayerCharacter(origin);
|
||||
msg = (MerchantMsg) baseMsg;
|
||||
npc = NPC.getNPC(msg.getNPCID());
|
||||
|
||||
// Early exit if something goes awry
|
||||
|
||||
if ((player == null) || (npc == null))
|
||||
return true;
|
||||
|
||||
// Player must be within talking range
|
||||
|
||||
if (player.getLoc().distanceSquared2D(npc.getLoc()) > MBServerStatics.NPC_TALK_RANGE * MBServerStatics.NPC_TALK_RANGE) {
|
||||
ErrorPopupMsg.sendErrorPopup(player, 14);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Process application protocol message
|
||||
|
||||
msgType = msg.getType();
|
||||
|
||||
switch (msgType) {
|
||||
case 3:
|
||||
break;
|
||||
case 5:
|
||||
|
||||
dispatch = Dispatch.borrow(player, msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
requestSwearAsSubGuild(msg, origin, player, npc);
|
||||
break;
|
||||
case 10:
|
||||
teleportRepledgeScreen(msg, origin, player, false, npc);
|
||||
break;
|
||||
case 11:
|
||||
teleportRepledge(msg, origin, player, false, npc);
|
||||
break;
|
||||
case 12:
|
||||
teleportRepledgeScreen(msg, origin, player, true, npc);
|
||||
break;
|
||||
case 13:
|
||||
teleportRepledge(msg, origin, player, true, npc);
|
||||
break;
|
||||
case 14:
|
||||
if (isHermit(npc))
|
||||
requestHermitBlessing(msg, origin, player, npc);
|
||||
else
|
||||
requestBoon(msg, origin, player, npc);
|
||||
break;
|
||||
case 15:
|
||||
LeaderboardMessage lbm = new LeaderboardMessage();
|
||||
dispatch = Dispatch.borrow(player, lbm);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
break;
|
||||
case 16:
|
||||
ViewResourcesMessage vrm = new ViewResourcesMessage(player);
|
||||
warehouse = npc.getBuilding();
|
||||
vrm.setGuild(player.getGuild());
|
||||
vrm.setWarehouseBuilding(warehouse);
|
||||
vrm.configure();
|
||||
dispatch = Dispatch.borrow(player, vrm);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
break;
|
||||
case 17:
|
||||
Warehouse.warehouseWithdraw(msg, player, npc, origin);
|
||||
break;
|
||||
case 18:
|
||||
Warehouse.warehouseDeposit(msg, player, npc, origin);
|
||||
break;
|
||||
case 19:
|
||||
Warehouse.warehouseLock(msg, player, npc, origin);
|
||||
break;
|
||||
}
|
||||
public MerchantMsgHandler() {
|
||||
super(MerchantMsg.class);
|
||||
}
|
||||
|
||||
return true;
|
||||
private static void requestSwearAsSubGuild(MerchantMsg msg, ClientConnection origin, PlayerCharacter player, NPC npc) {
|
||||
|
||||
}
|
||||
boolean Disabled = true;
|
||||
|
||||
private static void requestSwearAsSubGuild(MerchantMsg msg, ClientConnection origin, PlayerCharacter player, NPC npc) {
|
||||
if (Disabled) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Swearing to Safeholds have been temporary disabled."); //Cannot sub as errant guild.
|
||||
return;
|
||||
}
|
||||
|
||||
boolean Disabled = true;
|
||||
if (player.getGuild().isEmptyGuild()) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "You do not belong to a guild!"); //Cannot sub as errant guild.
|
||||
return;
|
||||
}
|
||||
|
||||
if (Disabled){
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Swearing to Safeholds have been temporary disabled."); //Cannot sub as errant guild.
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.getGuild().isEmptyGuild()){
|
||||
ErrorPopupMsg.sendErrorMsg(player, "You do not belong to a guild!"); //Cannot sub as errant guild.
|
||||
return;
|
||||
}
|
||||
if (player.getGuild().getNation() != null && !player.getGuild().getNation().isEmptyGuild()) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "You already belong to a nation!"); //Cannot sub as errant guild.
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.getGuild().getNation() != null && !player.getGuild().getNation().isEmptyGuild()){
|
||||
ErrorPopupMsg.sendErrorMsg(player, "You already belong to a nation!"); //Cannot sub as errant guild.
|
||||
return;
|
||||
}
|
||||
if (player.getGuild().getGuildLeaderUUID() != player.getObjectUUID()) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "You must be a Guild Leader to Swear your guild as a Sub Guild!"); //Cannot sub as errant guild.
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.getGuild().getGuildLeaderUUID() != player.getObjectUUID()){
|
||||
ErrorPopupMsg.sendErrorMsg(player, "You must be a Guild Leader to Swear your guild as a Sub Guild!"); //Cannot sub as errant guild.
|
||||
return;
|
||||
}
|
||||
if (!GuildStatusController.isGuildLeader(player.getGuildStatus())) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "You must be a Guild Leader to Swear your guild as a Sub Guild!"); //Cannot sub as errant guild.
|
||||
return;
|
||||
}
|
||||
|
||||
if (!GuildStatusController.isGuildLeader(player.getGuildStatus())){
|
||||
ErrorPopupMsg.sendErrorMsg(player, "You must be a Guild Leader to Swear your guild as a Sub Guild!"); //Cannot sub as errant guild.
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (!npc.getGuild().isNPCGuild()){
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Runemaster does not belong to a safehold!"); //Cannot sub as errant guild.
|
||||
return;
|
||||
}
|
||||
if (!npc.getGuild().isNPCGuild()) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Runemaster does not belong to a safehold!"); //Cannot sub as errant guild.
|
||||
return;
|
||||
}
|
||||
|
||||
if (npc.getGuild().getRepledgeMin() > player.getLevel()){
|
||||
ErrorPopupMsg.sendErrorMsg(player, "You are too low of a level to sub to this guild!"); //Cannot sub as errant guild.
|
||||
return;
|
||||
}
|
||||
if (npc.getGuild().getRepledgeMin() > player.getLevel()) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "You are too low of a level to sub to this guild!"); //Cannot sub as errant guild.
|
||||
return;
|
||||
}
|
||||
|
||||
if (npc.getGuild().getRepledgeMax() < 75){
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Runemaster Guild Cannot Swear in your guild!"); //Cannot sub as errant guild.
|
||||
return;
|
||||
}
|
||||
if (npc.getGuild().getRepledgeMax() < 75) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Runemaster Guild Cannot Swear in your guild!"); //Cannot sub as errant guild.
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (!DbManager.GuildQueries.UPDATE_PARENT(player.getGuild().getObjectUUID(), npc.getGuild().getObjectUUID())) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "A Serious error has occured. Please post details for to ensure transaction integrity");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
GuildManager.updateAllGuildBinds(player.getGuild(), npc.getGuild().getOwnedCity());
|
||||
|
||||
if (!DbManager.GuildQueries.UPDATE_PARENT(player.getGuild().getObjectUUID(), npc.getGuild().getObjectUUID())) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "A Serious error has occured. Please post details for to ensure transaction integrity");
|
||||
return;
|
||||
}
|
||||
|
||||
//update Guild state.
|
||||
player.getGuild().setNation(npc.getGuild());
|
||||
GuildManager.updateAllGuildTags(player.getGuild());
|
||||
|
||||
GuildManager.updateAllGuildBinds(player.getGuild(), npc.getGuild().getOwnedCity());
|
||||
//update state twice, errant to petitioner, to sworn.
|
||||
player.getGuild().upgradeGuildState(false);//to petitioner
|
||||
player.getGuild().upgradeGuildState(false);//to sworn
|
||||
|
||||
|
||||
}
|
||||
|
||||
//update Guild state.
|
||||
player.getGuild().setNation(npc.getGuild());
|
||||
GuildManager.updateAllGuildTags(player.getGuild());
|
||||
private static void requestHermitBlessing(MerchantMsg msg, ClientConnection origin, PlayerCharacter player, NPC npc) {
|
||||
|
||||
//update state twice, errant to petitioner, to sworn.
|
||||
player.getGuild().upgradeGuildState(false);//to petitioner
|
||||
player.getGuild().upgradeGuildState(false);//to sworn
|
||||
Guild guild;
|
||||
Realm realm;
|
||||
City city;
|
||||
Building tol;
|
||||
|
||||
// Validate player can obtain blessing
|
||||
|
||||
if (GuildStatusController.isGuildLeader(player.getGuildStatus()) == false) {
|
||||
ErrorPopupMsg.sendErrorPopup(player, 173); // You must be the leader of a guild to receive a blessing
|
||||
return;
|
||||
}
|
||||
|
||||
guild = player.getGuild();
|
||||
city = guild.getOwnedCity();
|
||||
|
||||
if (city == null) {
|
||||
ErrorPopupMsg.sendErrorPopup(player, 179); // Only landed guilds may claim a territory
|
||||
return;
|
||||
}
|
||||
tol = city.getTOL();
|
||||
|
||||
}
|
||||
if (tol.getRank() != 7) {
|
||||
ErrorPopupMsg.sendErrorPopup(player, 181); // Your tree must be rank 7 before claiming a territory
|
||||
return;
|
||||
}
|
||||
|
||||
realm = RealmMap.getRealmForCity(city);
|
||||
|
||||
if (realm.getCanBeClaimed() == false) {
|
||||
ErrorPopupMsg.sendErrorPopup(player, 180); // This territory cannot be ruled by anyone
|
||||
return;
|
||||
}
|
||||
|
||||
private static void requestHermitBlessing(MerchantMsg msg, ClientConnection origin, PlayerCharacter player, NPC npc) {
|
||||
if (realm.isRuled() == true) {
|
||||
ErrorPopupMsg.sendErrorPopup(player, 178); // This territory is already claimed
|
||||
return;
|
||||
}
|
||||
|
||||
Guild guild;
|
||||
Realm realm;
|
||||
City city;
|
||||
Building tol;
|
||||
// Everything should be good, apply boon for this hermit
|
||||
|
||||
// Validate player can obtain blessing
|
||||
PowersManager.applyPower(player, player, player.getLoc(), getPowerforHermit(npc).getToken(), 40, false);
|
||||
|
||||
if (GuildStatusController.isGuildLeader(player.getGuildStatus()) == false) {
|
||||
ErrorPopupMsg.sendErrorPopup(player, 173); // You must be the leader of a guild to receive a blessing
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
guild = player.getGuild();
|
||||
city = guild.getOwnedCity();
|
||||
private static void requestBoon(MerchantMsg msg, ClientConnection origin, PlayerCharacter player, NPC npc) {
|
||||
|
||||
if (city == null) {
|
||||
ErrorPopupMsg.sendErrorPopup(player, 179); // Only landed guilds may claim a territory
|
||||
return;
|
||||
}
|
||||
tol = city.getTOL();
|
||||
Building shrineBuilding;
|
||||
Shrine shrine;
|
||||
|
||||
if (tol.getRank() != 7) {
|
||||
ErrorPopupMsg.sendErrorPopup(player, 181); // Your tree must be rank 7 before claiming a territory
|
||||
return;
|
||||
}
|
||||
if (npc.getGuild() != player.getGuild())
|
||||
return;
|
||||
|
||||
realm = RealmMap.getRealmForCity(city);
|
||||
shrineBuilding = npc.getBuilding();
|
||||
|
||||
if (realm.getCanBeClaimed() == false) {
|
||||
ErrorPopupMsg.sendErrorPopup(player, 180); // This territory cannot be ruled by anyone
|
||||
return;
|
||||
}
|
||||
if (shrineBuilding == null)
|
||||
return;
|
||||
|
||||
if (realm.isRuled() == true) {
|
||||
ErrorPopupMsg.sendErrorPopup(player, 178); // This territory is already claimed
|
||||
return;
|
||||
}
|
||||
if (shrineBuilding.getBlueprint() != null && shrineBuilding.getBlueprint().getBuildingGroup() != engine.Enum.BuildingGroup.SHRINE)
|
||||
return;
|
||||
|
||||
// Everything should be good, apply boon for this hermit
|
||||
if (shrineBuilding.getRank() == -1)
|
||||
return;
|
||||
|
||||
PowersManager.applyPower(player, player, player.getLoc(), getPowerforHermit(npc).getToken(), 40, false);
|
||||
shrine = Shrine.shrinesByBuildingUUID.get(shrineBuilding.getObjectUUID());
|
||||
|
||||
}
|
||||
if (shrine == null)
|
||||
return;
|
||||
|
||||
private static void requestBoon(MerchantMsg msg, ClientConnection origin, PlayerCharacter player, NPC npc) {
|
||||
if (shrine.getFavors() == 0) {
|
||||
ErrorPopupMsg.sendErrorPopup(player, 172);
|
||||
return;
|
||||
}
|
||||
|
||||
Building shrineBuilding;
|
||||
Shrine shrine;
|
||||
//already haz boon.
|
||||
|
||||
if (npc.getGuild() != player.getGuild())
|
||||
return;
|
||||
if (player.containsEffect(shrine.getShrineType().getPowerToken())) {
|
||||
ErrorPopupMsg.sendErrorPopup(player, 199);
|
||||
return;
|
||||
}
|
||||
|
||||
shrineBuilding = npc.getBuilding();
|
||||
if (!Shrine.canTakeFavor(player, shrine))
|
||||
return;
|
||||
|
||||
if (shrineBuilding == null)
|
||||
return;
|
||||
if (!shrine.takeFavor(player))
|
||||
return;
|
||||
|
||||
if (shrineBuilding.getBlueprint() != null && shrineBuilding.getBlueprint().getBuildingGroup() != engine.Enum.BuildingGroup.SHRINE)
|
||||
return;
|
||||
PowersBase shrinePower = PowersManager.getPowerByToken(shrine.getShrineType().getPowerToken());
|
||||
|
||||
if (shrineBuilding.getRank() == -1)
|
||||
return;
|
||||
if (shrinePower == null) {
|
||||
ChatManager.chatSystemError(player, "FAILED TO APPLY POWER!");
|
||||
return;
|
||||
}
|
||||
|
||||
shrine = Shrine.shrinesByBuildingUUID.get(shrineBuilding.getObjectUUID());
|
||||
int rank = shrine.getRank();
|
||||
//R8 trees always get atleast rank 2 boons. rank uses index, where 0 is first place, 1 is second, etc...
|
||||
if (shrineBuilding.getCity() != null && shrineBuilding.getCity().getTOL() != null && shrineBuilding.getCity().getTOL().getRank() == 8)
|
||||
if (rank != 0)
|
||||
rank = 1;
|
||||
int trains = 40 - (rank * 10);
|
||||
if (trains < 0)
|
||||
trains = 0;
|
||||
|
||||
if (shrine == null)
|
||||
return;
|
||||
//System.out.println(trains);
|
||||
PowersManager.applyPower(player, player, player.getLoc(), shrinePower.getToken(), trains, false);
|
||||
ChatManager.chatGuildInfo(player.getGuild(), player.getName() + " has recieved a boon costing " + 1 + " point of favor.");
|
||||
shrineBuilding.addEffectBit(1000000 << 2);
|
||||
shrineBuilding.updateEffects();
|
||||
|
||||
if (shrine.getFavors() == 0) {
|
||||
ErrorPopupMsg.sendErrorPopup(player, 172);
|
||||
return;
|
||||
}
|
||||
//remove the effect so players loading shrines dont see the effect go off.
|
||||
shrineBuilding.removeEffectBit(1000000 << 2);
|
||||
}
|
||||
|
||||
//already haz boon.
|
||||
private static void teleportRepledgeScreen(MerchantMsg msg, ClientConnection origin, PlayerCharacter pc, boolean isTeleport, NPC npc) {
|
||||
|
||||
if (player.containsEffect(shrine.getShrineType().getPowerToken())) {
|
||||
ErrorPopupMsg.sendErrorPopup(player, 199);
|
||||
return;
|
||||
}
|
||||
Dispatch dispatch;
|
||||
TeleportRepledgeListMsg trlm;
|
||||
|
||||
if (!Shrine.canTakeFavor(player, shrine))
|
||||
return;
|
||||
//verify npc is runemaster
|
||||
|
||||
if (!shrine.takeFavor(player))
|
||||
return;
|
||||
Contract contract = npc.getContract();
|
||||
|
||||
PowersBase shrinePower = PowersManager.getPowerByToken(shrine.getShrineType().getPowerToken());
|
||||
if (contract == null || !contract.isRuneMaster())
|
||||
return;
|
||||
|
||||
if (shrinePower == null) {
|
||||
ChatManager.chatSystemError(player, "FAILED TO APPLY POWER!");
|
||||
return;
|
||||
}
|
||||
if (!isTeleport)
|
||||
trlm = new TeleportRepledgeListMsg(pc, false);
|
||||
else
|
||||
trlm = new TeleportRepledgeListMsg(pc, true);
|
||||
|
||||
int rank = shrine.getRank();
|
||||
//R8 trees always get atleast rank 2 boons. rank uses index, where 0 is first place, 1 is second, etc...
|
||||
if (shrineBuilding.getCity() != null && shrineBuilding.getCity().getTOL() != null && shrineBuilding.getCity().getTOL().getRank() == 8)
|
||||
if (rank != 0)
|
||||
rank = 1;
|
||||
int trains = 40 - (rank * 10);
|
||||
if (trains < 0)
|
||||
trains = 0;
|
||||
trlm.configure();
|
||||
|
||||
//System.out.println(trains);
|
||||
PowersManager.applyPower(player, player, player.getLoc(), shrinePower.getToken(), trains, false);
|
||||
ChatManager.chatGuildInfo(player.getGuild(), player.getName() + " has recieved a boon costing " + 1 + " point of favor.");
|
||||
shrineBuilding.addEffectBit(1000000 << 2);
|
||||
shrineBuilding.updateEffects();
|
||||
dispatch = Dispatch.borrow(pc, trlm);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
}
|
||||
|
||||
//remove the effect so players loading shrines dont see the effect go off.
|
||||
shrineBuilding.removeEffectBit(1000000 << 2);
|
||||
}
|
||||
private static void teleportRepledge(MerchantMsg msg, ClientConnection origin, PlayerCharacter player, boolean isTeleport, NPC npc) {
|
||||
|
||||
private static void teleportRepledgeScreen(MerchantMsg msg, ClientConnection origin, PlayerCharacter pc, boolean isTeleport, NPC npc) {
|
||||
//verify npc is runemaster
|
||||
|
||||
Dispatch dispatch;
|
||||
TeleportRepledgeListMsg trlm;
|
||||
Contract contract = npc.getContract();
|
||||
Dispatch dispatch;
|
||||
|
||||
//verify npc is runemaster
|
||||
if (contract == null || !contract.isRuneMaster())
|
||||
return;
|
||||
|
||||
Contract contract = npc.getContract();
|
||||
//get city to teleport/repledge to and verify valid
|
||||
|
||||
if (contract == null || !contract.isRuneMaster())
|
||||
return;
|
||||
ArrayList<City> cities;
|
||||
|
||||
if (!isTeleport)
|
||||
trlm = new TeleportRepledgeListMsg(pc, false);
|
||||
else
|
||||
trlm = new TeleportRepledgeListMsg(pc, true);
|
||||
City targetCity = null;
|
||||
|
||||
trlm.configure();
|
||||
if (isTeleport)
|
||||
cities = City.getCitiesToTeleportTo(player);
|
||||
else
|
||||
cities = City.getCitiesToRepledgeTo(player);
|
||||
for (City city : cities) {
|
||||
if (city.getObjectUUID() == msg.getCityID()) {
|
||||
targetCity = city;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
dispatch = Dispatch.borrow(pc, trlm);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
}
|
||||
if (targetCity == null)
|
||||
return;
|
||||
|
||||
private static void teleportRepledge(MerchantMsg msg, ClientConnection origin, PlayerCharacter player, boolean isTeleport, NPC npc) {
|
||||
//verify level required to teleport or repledge
|
||||
|
||||
//verify npc is runemaster
|
||||
Guild toGuild = targetCity.getGuild();
|
||||
|
||||
Contract contract = npc.getContract();
|
||||
Dispatch dispatch;
|
||||
if (toGuild != null)
|
||||
if (isTeleport) {
|
||||
if (player.getLevel() < toGuild.getTeleportMin() || player.getLevel() > toGuild.getTeleportMax())
|
||||
return;
|
||||
} else if (player.getLevel() < toGuild.getRepledgeMin() || player.getLevel() > toGuild.getRepledgeMax())
|
||||
return;
|
||||
|
||||
if (contract == null || !contract.isRuneMaster())
|
||||
return;
|
||||
boolean joinedGuild = false;
|
||||
|
||||
//get city to teleport/repledge to and verify valid
|
||||
//if repledge, reguild the player
|
||||
|
||||
ArrayList<City> cities;
|
||||
if (!isTeleport)
|
||||
joinedGuild = GuildManager.joinGuild(player, targetCity.getGuild(), targetCity.getObjectUUID(), GuildHistoryType.JOIN);
|
||||
|
||||
City targetCity = null;
|
||||
int time;
|
||||
|
||||
if (isTeleport)
|
||||
cities = City.getCitiesToTeleportTo(player);
|
||||
else
|
||||
cities = City.getCitiesToRepledgeTo(player);
|
||||
for (City city : cities) {
|
||||
if (city.getObjectUUID() == msg.getCityID()) {
|
||||
targetCity = city;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!isTeleport) //repledge
|
||||
time = MBServerStatics.REPLEDGE_TIME_IN_SECONDS;
|
||||
else
|
||||
time = MBServerStatics.TELEPORT_TIME_IN_SECONDS;
|
||||
|
||||
if (targetCity == null)
|
||||
return;
|
||||
//resend message
|
||||
msg.setTeleportTime(time);
|
||||
|
||||
//verify level required to teleport or repledge
|
||||
if ((!isTeleport && joinedGuild) || (isTeleport)) {
|
||||
|
||||
Guild toGuild = targetCity.getGuild();
|
||||
dispatch = Dispatch.borrow(player, msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
}
|
||||
|
||||
if (toGuild != null)
|
||||
if (isTeleport) {
|
||||
if (player.getLevel() < toGuild.getTeleportMin() || player.getLevel() > toGuild.getTeleportMax())
|
||||
return;
|
||||
}
|
||||
else if (player.getLevel() < toGuild.getRepledgeMin() || player.getLevel() > toGuild.getRepledgeMax())
|
||||
return;
|
||||
//teleport player to city
|
||||
|
||||
boolean joinedGuild = false;
|
||||
Vector3fImmutable teleportLoc;
|
||||
|
||||
//if repledge, reguild the player
|
||||
if (targetCity.getTOL().getRank() == 8)
|
||||
teleportLoc = targetCity.getTOL().getStuckLocation();
|
||||
else
|
||||
teleportLoc = Vector3fImmutable.getRandomPointOnCircle(targetCity.getTOL().getLoc(), MBServerStatics.TREE_TELEPORT_RADIUS);
|
||||
|
||||
if (!isTeleport)
|
||||
joinedGuild = GuildManager.joinGuild(player, targetCity.getGuild(), targetCity.getObjectUUID(), GuildHistoryType.JOIN);
|
||||
if (time > 0) {
|
||||
//TODO add timer to teleport
|
||||
TeleportJob tj = new TeleportJob(player, npc, teleportLoc, origin, true);
|
||||
JobScheduler.getInstance().scheduleJob(tj, time * 1000);
|
||||
} else if (joinedGuild) {
|
||||
player.teleport(teleportLoc);
|
||||
player.setSafeMode();
|
||||
}
|
||||
}
|
||||
|
||||
int time;
|
||||
private static PowersBase getPowerforHermit(NPC npc) {
|
||||
|
||||
if (!isTeleport) //repledge
|
||||
time = MBServerStatics.REPLEDGE_TIME_IN_SECONDS;
|
||||
else
|
||||
time = MBServerStatics.TELEPORT_TIME_IN_SECONDS;
|
||||
int contractID;
|
||||
PowersBase power;
|
||||
Contract contract;
|
||||
|
||||
//resend message
|
||||
msg.setTeleportTime(time);
|
||||
|
||||
if ((!isTeleport && joinedGuild) || (isTeleport)) {
|
||||
|
||||
dispatch = Dispatch.borrow(player, msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
}
|
||||
|
||||
//teleport player to city
|
||||
|
||||
Vector3fImmutable teleportLoc;
|
||||
|
||||
if (targetCity.getTOL().getRank() == 8)
|
||||
teleportLoc = targetCity.getTOL().getStuckLocation();
|
||||
else
|
||||
teleportLoc = Vector3fImmutable.getRandomPointOnCircle(targetCity.getTOL().getLoc(), MBServerStatics.TREE_TELEPORT_RADIUS);
|
||||
|
||||
if (time > 0) {
|
||||
//TODO add timer to teleport
|
||||
TeleportJob tj = new TeleportJob(player, npc, teleportLoc, origin, true);
|
||||
JobScheduler.getInstance().scheduleJob(tj, time * 1000);
|
||||
}
|
||||
else if (joinedGuild) {
|
||||
player.teleport(teleportLoc);
|
||||
player.setSafeMode();
|
||||
}
|
||||
}
|
||||
|
||||
private static PowersBase getPowerforHermit(NPC npc) {
|
||||
|
||||
int contractID;
|
||||
PowersBase power;
|
||||
Contract contract;
|
||||
|
||||
contract = npc.getContract();
|
||||
contractID = contract.getContractID();
|
||||
power = null;
|
||||
|
||||
switch (contractID) {
|
||||
case 435579:
|
||||
power = PowersManager.getPowerByIDString("BLS-POWER");
|
||||
break;
|
||||
case 435580:
|
||||
power = PowersManager.getPowerByIDString("BLS-FORTUNE");
|
||||
break;
|
||||
case 435581:
|
||||
power = PowersManager.getPowerByIDString("BLS-WISDOM");
|
||||
break;
|
||||
|
||||
}
|
||||
return power;
|
||||
}
|
||||
|
||||
private static boolean isHermit(NPC npc) {
|
||||
|
||||
int contractID;
|
||||
boolean retValue = false;
|
||||
|
||||
contractID = npc.getContractID();
|
||||
|
||||
switch (contractID) {
|
||||
case 435579:
|
||||
case 435580:
|
||||
case 435581:
|
||||
retValue = true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return retValue;
|
||||
}
|
||||
contract = npc.getContract();
|
||||
contractID = contract.getContractID();
|
||||
power = null;
|
||||
|
||||
switch (contractID) {
|
||||
case 435579:
|
||||
power = PowersManager.getPowerByIDString("BLS-POWER");
|
||||
break;
|
||||
case 435580:
|
||||
power = PowersManager.getPowerByIDString("BLS-FORTUNE");
|
||||
break;
|
||||
case 435581:
|
||||
power = PowersManager.getPowerByIDString("BLS-WISDOM");
|
||||
break;
|
||||
|
||||
}
|
||||
return power;
|
||||
}
|
||||
|
||||
private static boolean isHermit(NPC npc) {
|
||||
|
||||
int contractID;
|
||||
boolean retValue = false;
|
||||
|
||||
contractID = npc.getContractID();
|
||||
|
||||
switch (contractID) {
|
||||
case 435579:
|
||||
case 435580:
|
||||
case 435581:
|
||||
retValue = true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return retValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
|
||||
// Member variable declaration
|
||||
|
||||
MerchantMsg msg;
|
||||
PlayerCharacter player;
|
||||
NPC npc;
|
||||
int msgType;
|
||||
Building warehouse;
|
||||
Dispatch dispatch;
|
||||
|
||||
// Member variable assignment
|
||||
|
||||
player = SessionManager.getPlayerCharacter(origin);
|
||||
msg = (MerchantMsg) baseMsg;
|
||||
npc = NPC.getNPC(msg.getNPCID());
|
||||
|
||||
// Early exit if something goes awry
|
||||
|
||||
if ((player == null) || (npc == null))
|
||||
return true;
|
||||
|
||||
// Player must be within talking range
|
||||
|
||||
if (player.getLoc().distanceSquared2D(npc.getLoc()) > MBServerStatics.NPC_TALK_RANGE * MBServerStatics.NPC_TALK_RANGE) {
|
||||
ErrorPopupMsg.sendErrorPopup(player, 14);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Process application protocol message
|
||||
|
||||
msgType = msg.getType();
|
||||
|
||||
switch (msgType) {
|
||||
case 3:
|
||||
break;
|
||||
case 5:
|
||||
|
||||
dispatch = Dispatch.borrow(player, msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
requestSwearAsSubGuild(msg, origin, player, npc);
|
||||
break;
|
||||
case 10:
|
||||
teleportRepledgeScreen(msg, origin, player, false, npc);
|
||||
break;
|
||||
case 11:
|
||||
teleportRepledge(msg, origin, player, false, npc);
|
||||
break;
|
||||
case 12:
|
||||
teleportRepledgeScreen(msg, origin, player, true, npc);
|
||||
break;
|
||||
case 13:
|
||||
teleportRepledge(msg, origin, player, true, npc);
|
||||
break;
|
||||
case 14:
|
||||
if (isHermit(npc))
|
||||
requestHermitBlessing(msg, origin, player, npc);
|
||||
else
|
||||
requestBoon(msg, origin, player, npc);
|
||||
break;
|
||||
case 15:
|
||||
LeaderboardMessage lbm = new LeaderboardMessage();
|
||||
dispatch = Dispatch.borrow(player, lbm);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
break;
|
||||
case 16:
|
||||
ViewResourcesMessage vrm = new ViewResourcesMessage(player);
|
||||
warehouse = npc.getBuilding();
|
||||
vrm.setGuild(player.getGuild());
|
||||
vrm.setWarehouseBuilding(warehouse);
|
||||
vrm.configure();
|
||||
dispatch = Dispatch.borrow(player, vrm);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
break;
|
||||
case 17:
|
||||
Warehouse.warehouseWithdraw(msg, player, npc, origin);
|
||||
break;
|
||||
case 18:
|
||||
Warehouse.warehouseDeposit(msg, player, npc, origin);
|
||||
break;
|
||||
case 19:
|
||||
Warehouse.warehouseLock(msg, player, npc, origin);
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -34,88 +34,88 @@ import java.time.LocalDateTime;
|
||||
|
||||
public class MineWindowChangeHandler extends AbstractClientMsgHandler {
|
||||
|
||||
public MineWindowChangeHandler() {
|
||||
super(ArcMineWindowChangeMsg.class);
|
||||
}
|
||||
public MineWindowChangeHandler() {
|
||||
super(ArcMineWindowChangeMsg.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
|
||||
PlayerCharacter playerCharacter = SessionManager.getPlayerCharacter(origin);
|
||||
ArcMineWindowChangeMsg mineWindowChangeMsg = (ArcMineWindowChangeMsg) baseMsg;
|
||||
int newMineTime;
|
||||
PlayerCharacter playerCharacter = SessionManager.getPlayerCharacter(origin);
|
||||
ArcMineWindowChangeMsg mineWindowChangeMsg = (ArcMineWindowChangeMsg) baseMsg;
|
||||
int newMineTime;
|
||||
|
||||
if (playerCharacter == null)
|
||||
return true;
|
||||
if (playerCharacter == null)
|
||||
return true;
|
||||
|
||||
Building treeOfLife = BuildingManager.getBuildingFromCache(mineWindowChangeMsg.getBuildingID());
|
||||
Building treeOfLife = BuildingManager.getBuildingFromCache(mineWindowChangeMsg.getBuildingID());
|
||||
|
||||
if (treeOfLife == null)
|
||||
return true;
|
||||
if (treeOfLife == null)
|
||||
return true;
|
||||
|
||||
if (treeOfLife.getBlueprintUUID() == 0)
|
||||
return true;
|
||||
if (treeOfLife.getBlueprintUUID() == 0)
|
||||
return true;
|
||||
|
||||
if (treeOfLife.getBlueprint().getBuildingGroup() != Enum.BuildingGroup.TOL)
|
||||
return true;
|
||||
if (treeOfLife.getBlueprint().getBuildingGroup() != Enum.BuildingGroup.TOL)
|
||||
return true;
|
||||
|
||||
Guild mineGuild = treeOfLife.getGuild();
|
||||
Guild mineGuild = treeOfLife.getGuild();
|
||||
|
||||
if (mineGuild.isEmptyGuild())
|
||||
return true;
|
||||
if (mineGuild.isEmptyGuild())
|
||||
return true;
|
||||
|
||||
if (!Guild.sameGuild(mineGuild, playerCharacter.getGuild()))
|
||||
return true; //must be same guild
|
||||
if (!Guild.sameGuild(mineGuild, playerCharacter.getGuild()))
|
||||
return true; //must be same guild
|
||||
|
||||
if (GuildStatusController.isInnerCouncil(playerCharacter.getGuildStatus()) == false) // is this only GL?
|
||||
return true;
|
||||
if (GuildStatusController.isInnerCouncil(playerCharacter.getGuildStatus()) == false) // is this only GL?
|
||||
return true;
|
||||
|
||||
newMineTime = mineWindowChangeMsg.getTime();
|
||||
newMineTime = mineWindowChangeMsg.getTime();
|
||||
|
||||
// Sanity check for possible slider value
|
||||
// Sanity check for possible slider value
|
||||
|
||||
if (newMineTime == 24)
|
||||
newMineTime = 0;
|
||||
if (newMineTime == 24)
|
||||
newMineTime = 0;
|
||||
|
||||
// Enforce time restriction between WOO edits
|
||||
// Enforce time restriction between WOO edits
|
||||
|
||||
if (mineGuild.wooWasModified) {
|
||||
ErrorPopupMsg.sendErrorMsg(playerCharacter, "You can only modify your WOO once per day.");
|
||||
return true;
|
||||
}
|
||||
if (mineGuild.wooWasModified) {
|
||||
ErrorPopupMsg.sendErrorMsg(playerCharacter, "You can only modify your WOO once per day.");
|
||||
return true;
|
||||
}
|
||||
|
||||
//hodge podge sanity check to make sure they don't set it before early window and is not set at late window.
|
||||
//hodge podge sanity check to make sure they don't set it before early window and is not set at late window.
|
||||
|
||||
if (newMineTime < MBServerStatics.MINE_EARLY_WINDOW &&
|
||||
newMineTime != MBServerStatics.MINE_LATE_WINDOW) {
|
||||
ErrorPopupMsg.sendErrorMsg(playerCharacter, "Mine time is outside the NA Woo window.");
|
||||
return true;
|
||||
}
|
||||
if (newMineTime < MBServerStatics.MINE_EARLY_WINDOW &&
|
||||
newMineTime != MBServerStatics.MINE_LATE_WINDOW) {
|
||||
ErrorPopupMsg.sendErrorMsg(playerCharacter, "Mine time is outside the NA Woo window.");
|
||||
return true;
|
||||
}
|
||||
|
||||
// Cannot set a time to a window that has closed if mines are currently open.
|
||||
// Cannot set a time to a window that has closed if mines are currently open.
|
||||
|
||||
if (LocalDateTime.now().getHour() >= MBServerStatics.MINE_EARLY_WINDOW &&
|
||||
LocalDateTime.now().getHour() != MBServerStatics.MINE_LATE_WINDOW) {
|
||||
if (LocalDateTime.now().getHour() >= MBServerStatics.MINE_EARLY_WINDOW &&
|
||||
LocalDateTime.now().getHour() != MBServerStatics.MINE_LATE_WINDOW) {
|
||||
|
||||
if (newMineTime <= LocalDateTime.now().getHour())
|
||||
ErrorPopupMsg.sendErrorMsg(playerCharacter, "Cannot set mines to a previous window.");
|
||||
return true;
|
||||
}
|
||||
if (newMineTime <= LocalDateTime.now().getHour())
|
||||
ErrorPopupMsg.sendErrorMsg(playerCharacter, "Cannot set mines to a previous window.");
|
||||
return true;
|
||||
}
|
||||
|
||||
// Update guild mine time
|
||||
// Update guild mine time
|
||||
|
||||
if (!DbManager.GuildQueries.UPDATE_MINETIME(mineGuild.getObjectUUID(), newMineTime)) {
|
||||
Logger.error("MineWindowChange", "Failed to update mine time for guild " + mineGuild.getObjectUUID());
|
||||
ChatManager.chatGuildError(playerCharacter, "Failed to update the mine time");
|
||||
return true;
|
||||
}
|
||||
if (!DbManager.GuildQueries.UPDATE_MINETIME(mineGuild.getObjectUUID(), newMineTime)) {
|
||||
Logger.error("MineWindowChange", "Failed to update mine time for guild " + mineGuild.getObjectUUID());
|
||||
ChatManager.chatGuildError(playerCharacter, "Failed to update the mine time");
|
||||
return true;
|
||||
}
|
||||
|
||||
mineGuild.setMineTime(newMineTime);
|
||||
mineGuild.wooWasModified = true;
|
||||
mineGuild.setMineTime(newMineTime);
|
||||
mineGuild.wooWasModified = true;
|
||||
|
||||
ChatManager.chatGuildInfo(playerCharacter, "Mine time updated.");
|
||||
|
||||
return true;
|
||||
}
|
||||
ChatManager.chatGuildInfo(playerCharacter, "Mine time updated.");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -25,296 +25,295 @@ import java.util.HashMap;
|
||||
|
||||
public class MinionTrainingMsgHandler extends AbstractClientMsgHandler {
|
||||
|
||||
public static HashMap<Integer, ArrayList<Integer>> _minionsByCaptain = null;
|
||||
public static HashMap<Integer, ArrayList<Integer>> _minionsByCaptain = null;
|
||||
|
||||
public MinionTrainingMsgHandler() {
|
||||
super(MinionTrainingMessage.class);
|
||||
}
|
||||
public MinionTrainingMsgHandler() {
|
||||
super(MinionTrainingMessage.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
|
||||
MinionTrainingMessage minionMsg = (MinionTrainingMessage) baseMsg;
|
||||
MinionTrainingMessage minionMsg = (MinionTrainingMessage) baseMsg;
|
||||
|
||||
PlayerCharacter player = SessionManager.getPlayerCharacter(origin);
|
||||
PlayerCharacter player = SessionManager.getPlayerCharacter(origin);
|
||||
|
||||
if (player == null)
|
||||
return true;
|
||||
if (player == null)
|
||||
return true;
|
||||
|
||||
if (minionMsg.getNpcType() == Enum.GameObjectType.NPC.ordinal()){
|
||||
if (minionMsg.getNpcType() == Enum.GameObjectType.NPC.ordinal()) {
|
||||
|
||||
NPC npc = NPC.getFromCache(minionMsg.getNpcID());
|
||||
NPC npc = NPC.getFromCache(minionMsg.getNpcID());
|
||||
|
||||
if (npc == null)
|
||||
return true;
|
||||
if (npc == null)
|
||||
return true;
|
||||
|
||||
Building b = BuildingManager.getBuildingFromCache(minionMsg.getBuildingID());
|
||||
Building b = BuildingManager.getBuildingFromCache(minionMsg.getBuildingID());
|
||||
|
||||
if (b == null)
|
||||
return true;
|
||||
if (b == null)
|
||||
return true;
|
||||
|
||||
//clear minion
|
||||
//clear minion
|
||||
|
||||
if (npc.minionLock.writeLock().tryLock()) {
|
||||
try {
|
||||
if (minionMsg.getType() == 2) {
|
||||
if (npc.minionLock.writeLock().tryLock()) {
|
||||
try {
|
||||
if (minionMsg.getType() == 2) {
|
||||
|
||||
Mob toRemove = Mob.getFromCache(minionMsg.getUUID());
|
||||
Mob toRemove = Mob.getFromCache(minionMsg.getUUID());
|
||||
|
||||
if (!npc.getSiegeMinionMap().containsKey(toRemove))
|
||||
return true;
|
||||
if (!npc.getSiegeMinionMap().containsKey(toRemove))
|
||||
return true;
|
||||
|
||||
npc.getSiegeMinionMap().remove(toRemove);
|
||||
|
||||
//toRemove.disableIntelligence();
|
||||
WorldGrid.RemoveWorldObject(toRemove);
|
||||
//toRemove.disableIntelligence();
|
||||
WorldGrid.RemoveWorldObject(toRemove);
|
||||
|
||||
if (toRemove.getParentZone() != null)
|
||||
toRemove.getParentZone().zoneMobSet.remove(toRemove);
|
||||
if (toRemove.getParentZone() != null)
|
||||
toRemove.getParentZone().zoneMobSet.remove(toRemove);
|
||||
|
||||
DbManager.removeFromCache(toRemove);
|
||||
PlayerCharacter petOwner = toRemove.getOwner();
|
||||
DbManager.removeFromCache(toRemove);
|
||||
PlayerCharacter petOwner = toRemove.getOwner();
|
||||
|
||||
if (petOwner != null) {
|
||||
petOwner.setPet(null);
|
||||
toRemove.setOwner(null);
|
||||
PetMsg petMsg = new PetMsg(5, null);
|
||||
Dispatch dispatch = Dispatch.borrow(petOwner, petMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
}
|
||||
|
||||
// we Found the move to remove, lets break the for loop so it doesnt look for more.
|
||||
|
||||
ManageCityAssetsMsg mca1 = new ManageCityAssetsMsg(player, b);
|
||||
mca1.actionType = 3;
|
||||
mca1.setTargetType(b.getObjectType().ordinal());
|
||||
mca1.setTargetID(b.getObjectUUID());
|
||||
|
||||
mca1.setTargetType3(npc.getObjectType().ordinal());
|
||||
mca1.setTargetID3(npc.getObjectUUID());
|
||||
mca1.setAssetName1(b.getName());
|
||||
mca1.setUnknown54(1);
|
||||
|
||||
Dispatch dispatch = Dispatch.borrow(player, mca1);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
|
||||
ManageNPCMsg mnm = new ManageNPCMsg(npc);
|
||||
dispatch = Dispatch.borrow(player, mnm);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
|
||||
//Add Minion
|
||||
}
|
||||
else {
|
||||
Zone zone = npc.getParentZone();
|
||||
|
||||
if (zone == null)
|
||||
return true;
|
||||
|
||||
int maxSlots = 3;
|
||||
|
||||
if (npc.getContractID() == 842)
|
||||
maxSlots = 1;
|
||||
|
||||
if (npc.getSiegeMinionMap().size() == maxSlots)
|
||||
return true;
|
||||
|
||||
int mobBase;
|
||||
|
||||
switch (minionMsg.getMinion()){
|
||||
case 9:
|
||||
mobBase = 13171;
|
||||
break;
|
||||
case 2:
|
||||
mobBase = 13758;
|
||||
break;
|
||||
case 3:
|
||||
mobBase = 13757;
|
||||
break;
|
||||
case 4:
|
||||
mobBase = 2111;
|
||||
break;
|
||||
case 5:
|
||||
mobBase = 12402;
|
||||
break;
|
||||
case 6:
|
||||
mobBase = 2113;
|
||||
break;
|
||||
default:
|
||||
mobBase = minionMsg.getMinion();
|
||||
}
|
||||
|
||||
if (mobBase == 0)
|
||||
return true;
|
||||
|
||||
Mob toCreate = Mob.createSiegeMob(npc,mobBase, npc.getGuild(), zone, b.getLoc(), (short) 1);
|
||||
|
||||
if (toCreate == null)
|
||||
return true;
|
||||
|
||||
// toCreate.despawn();
|
||||
if (toCreate != null) {
|
||||
toCreate.setSpawnTime(60 * 15);
|
||||
Building building = BuildingManager.getBuilding(((MinionTrainingMessage) baseMsg).getBuildingID());
|
||||
int slot = ((NPC)toCreate.npcOwner).getSiegeMinionMap().get(toCreate);
|
||||
Vector3fImmutable slotLocation;
|
||||
toCreate.building = building;
|
||||
toCreate.parentZone = zone;
|
||||
BuildingLocation buildingLocation = BuildingManager._slotLocations.get(building.meshUUID).get(slot);
|
||||
slotLocation = building.getLoc().add(buildingLocation.getLocation());
|
||||
toCreate.setBindLoc(slotLocation);
|
||||
zone.zoneMobSet.add(toCreate);
|
||||
MovementManager.translocate(toCreate,toCreate.getBindLoc(),toCreate.npcOwner.region);
|
||||
if (petOwner != null) {
|
||||
petOwner.setPet(null);
|
||||
toRemove.setOwner(null);
|
||||
PetMsg petMsg = new PetMsg(5, null);
|
||||
Dispatch dispatch = Dispatch.borrow(petOwner, petMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
}
|
||||
}
|
||||
|
||||
ManageNPCMsg mnm = new ManageNPCMsg(npc);
|
||||
mnm.setMessageType(1);
|
||||
Dispatch dispatch = Dispatch.borrow(player, mnm);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
// we Found the move to remove, lets break the for loop so it doesnt look for more.
|
||||
|
||||
} finally {
|
||||
npc.minionLock.writeLock().unlock();
|
||||
}
|
||||
}
|
||||
ManageCityAssetsMsg mca1 = new ManageCityAssetsMsg(player, b);
|
||||
mca1.actionType = 3;
|
||||
mca1.setTargetType(b.getObjectType().ordinal());
|
||||
mca1.setTargetID(b.getObjectUUID());
|
||||
|
||||
}else if (minionMsg.getNpcType() == Enum.GameObjectType.Mob.ordinal()){
|
||||
mca1.setTargetType3(npc.getObjectType().ordinal());
|
||||
mca1.setTargetID3(npc.getObjectUUID());
|
||||
mca1.setAssetName1(b.getName());
|
||||
mca1.setUnknown54(1);
|
||||
|
||||
Mob npc = Mob.getFromCache(minionMsg.getNpcID());
|
||||
Dispatch dispatch = Dispatch.borrow(player, mca1);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
|
||||
if (npc == null)
|
||||
return true;
|
||||
ManageNPCMsg mnm = new ManageNPCMsg(npc);
|
||||
dispatch = Dispatch.borrow(player, mnm);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
|
||||
Building b = BuildingManager.getBuildingFromCache(minionMsg.getBuildingID());
|
||||
//Add Minion
|
||||
} else {
|
||||
Zone zone = npc.getParentZone();
|
||||
|
||||
if (b == null)
|
||||
return true;
|
||||
if (zone == null)
|
||||
return true;
|
||||
|
||||
//clear minion
|
||||
int maxSlots = 3;
|
||||
|
||||
if (npc.minionLock.writeLock().tryLock()) {
|
||||
try {
|
||||
if (minionMsg.getType() == 2) {
|
||||
if (npc.getContractID() == 842)
|
||||
maxSlots = 1;
|
||||
|
||||
Mob toRemove = Mob.getFromCache(minionMsg.getUUID());
|
||||
if (!npc.getSiegeMinionMap().containsKey(toRemove))
|
||||
return true;
|
||||
if (npc.getSiegeMinionMap().size() == maxSlots)
|
||||
return true;
|
||||
|
||||
if (!DbManager.MobQueries.REMOVE_FROM_GUARDS(npc.getObjectUUID(), toRemove.getMobBaseID(), npc.getSiegeMinionMap().get(toRemove)))
|
||||
return true;
|
||||
int mobBase;
|
||||
|
||||
switch (minionMsg.getMinion()) {
|
||||
case 9:
|
||||
mobBase = 13171;
|
||||
break;
|
||||
case 2:
|
||||
mobBase = 13758;
|
||||
break;
|
||||
case 3:
|
||||
mobBase = 13757;
|
||||
break;
|
||||
case 4:
|
||||
mobBase = 2111;
|
||||
break;
|
||||
case 5:
|
||||
mobBase = 12402;
|
||||
break;
|
||||
case 6:
|
||||
mobBase = 2113;
|
||||
break;
|
||||
default:
|
||||
mobBase = minionMsg.getMinion();
|
||||
}
|
||||
|
||||
if (mobBase == 0)
|
||||
return true;
|
||||
|
||||
Mob toCreate = Mob.createSiegeMob(npc, mobBase, npc.getGuild(), zone, b.getLoc(), (short) 1);
|
||||
|
||||
if (toCreate == null)
|
||||
return true;
|
||||
|
||||
// toCreate.despawn();
|
||||
if (toCreate != null) {
|
||||
toCreate.setSpawnTime(60 * 15);
|
||||
Building building = BuildingManager.getBuilding(((MinionTrainingMessage) baseMsg).getBuildingID());
|
||||
int slot = ((NPC) toCreate.npcOwner).getSiegeMinionMap().get(toCreate);
|
||||
Vector3fImmutable slotLocation;
|
||||
toCreate.building = building;
|
||||
toCreate.parentZone = zone;
|
||||
BuildingLocation buildingLocation = BuildingManager._slotLocations.get(building.meshUUID).get(slot);
|
||||
slotLocation = building.getLoc().add(buildingLocation.getLocation());
|
||||
toCreate.setBindLoc(slotLocation);
|
||||
zone.zoneMobSet.add(toCreate);
|
||||
MovementManager.translocate(toCreate, toCreate.getBindLoc(), toCreate.npcOwner.region);
|
||||
}
|
||||
}
|
||||
|
||||
ManageNPCMsg mnm = new ManageNPCMsg(npc);
|
||||
mnm.setMessageType(1);
|
||||
Dispatch dispatch = Dispatch.borrow(player, mnm);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
|
||||
} finally {
|
||||
npc.minionLock.writeLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
} else if (minionMsg.getNpcType() == Enum.GameObjectType.Mob.ordinal()) {
|
||||
|
||||
Mob npc = Mob.getFromCache(minionMsg.getNpcID());
|
||||
|
||||
if (npc == null)
|
||||
return true;
|
||||
|
||||
Building b = BuildingManager.getBuildingFromCache(minionMsg.getBuildingID());
|
||||
|
||||
if (b == null)
|
||||
return true;
|
||||
|
||||
//clear minion
|
||||
|
||||
if (npc.minionLock.writeLock().tryLock()) {
|
||||
try {
|
||||
if (minionMsg.getType() == 2) {
|
||||
|
||||
Mob toRemove = Mob.getFromCache(minionMsg.getUUID());
|
||||
if (!npc.getSiegeMinionMap().containsKey(toRemove))
|
||||
return true;
|
||||
|
||||
if (!DbManager.MobQueries.REMOVE_FROM_GUARDS(npc.getObjectUUID(), toRemove.getMobBaseID(), npc.getSiegeMinionMap().get(toRemove)))
|
||||
return true;
|
||||
|
||||
npc.getSiegeMinionMap().remove(toRemove);
|
||||
|
||||
//toRemove.disableIntelligence();
|
||||
WorldGrid.RemoveWorldObject(toRemove);
|
||||
//toRemove.disableIntelligence();
|
||||
WorldGrid.RemoveWorldObject(toRemove);
|
||||
|
||||
if (toRemove.getParentZone() != null)
|
||||
toRemove.getParentZone().zoneMobSet.remove(toRemove);
|
||||
if (toRemove.getParentZone() != null)
|
||||
toRemove.getParentZone().zoneMobSet.remove(toRemove);
|
||||
|
||||
DbManager.removeFromCache(toRemove);
|
||||
PlayerCharacter petOwner = toRemove.getOwner();
|
||||
DbManager.removeFromCache(toRemove);
|
||||
PlayerCharacter petOwner = toRemove.getOwner();
|
||||
|
||||
if (petOwner != null) {
|
||||
petOwner.setPet(null);
|
||||
toRemove.setOwner(null);
|
||||
PetMsg petMsg = new PetMsg(5, null);
|
||||
Dispatch dispatch = Dispatch.borrow(petOwner, petMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
}
|
||||
|
||||
// we Found the move to remove, lets break the for loop so it doesnt look for more.
|
||||
|
||||
ManageCityAssetsMsg mca1 = new ManageCityAssetsMsg(player, b);
|
||||
mca1.actionType = 3;
|
||||
mca1.setTargetType(b.getObjectType().ordinal());
|
||||
mca1.setTargetID(b.getObjectUUID());
|
||||
|
||||
mca1.setTargetType3(npc.getObjectType().ordinal());
|
||||
mca1.setTargetID3(npc.getObjectUUID());
|
||||
mca1.setAssetName1(b.getName());
|
||||
mca1.setUnknown54(1);
|
||||
|
||||
Dispatch dispatch = Dispatch.borrow(player, mca1);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);;
|
||||
|
||||
ManageNPCMsg mnm = new ManageNPCMsg(npc);
|
||||
dispatch = Dispatch.borrow(player, mnm);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
|
||||
//Add Minion
|
||||
}
|
||||
else {
|
||||
Zone zone = npc.getParentZone();
|
||||
|
||||
if (zone == null)
|
||||
return true;
|
||||
|
||||
int maxSlots = 5;
|
||||
|
||||
if (npc.getContract().getContractID() == 842)//artillery captain
|
||||
maxSlots = 1;
|
||||
if(npc.getContract().getContractID() == 910)//guard dogs
|
||||
maxSlots = 0;
|
||||
switch (npc.getRank()){
|
||||
case 1:
|
||||
case 2:
|
||||
maxSlots = 1;
|
||||
break;
|
||||
case 3:
|
||||
maxSlots = 2;
|
||||
break;
|
||||
case 4:
|
||||
case 5:
|
||||
maxSlots = 3;
|
||||
break;
|
||||
case 6:
|
||||
maxSlots = 4;
|
||||
break;
|
||||
case 7:
|
||||
maxSlots = 5;
|
||||
break;
|
||||
}
|
||||
|
||||
if (npc.getSiegeMinionMap().size() == maxSlots)
|
||||
return true;
|
||||
|
||||
int mobBase = npc.getMobBaseID();
|
||||
|
||||
if (mobBase == 0)
|
||||
return true;
|
||||
|
||||
String pirateName = NPCManager.getPirateName(mobBase);
|
||||
|
||||
if (!DbManager.MobQueries.ADD_TO_GUARDS(npc.getObjectUUID(), mobBase, pirateName, npc.getSiegeMinionMap().size() + 1))
|
||||
return true;
|
||||
|
||||
Mob toCreate = Mob.createGuardMob(npc, npc.getGuild(), zone, b.getLoc(), npc.getLevel(),pirateName);
|
||||
|
||||
if (toCreate == null)
|
||||
return true;
|
||||
|
||||
// toCreate.despawn();
|
||||
if (toCreate != null) {
|
||||
toCreate.setTimeToSpawnSiege(System.currentTimeMillis() + MBServerStatics.FIFTEEN_MINUTES);
|
||||
toCreate.setDeathTime(System.currentTimeMillis());
|
||||
toCreate.parentZone.zoneMobSet.add(toCreate);
|
||||
if (petOwner != null) {
|
||||
petOwner.setPet(null);
|
||||
toRemove.setOwner(null);
|
||||
PetMsg petMsg = new PetMsg(5, null);
|
||||
Dispatch dispatch = Dispatch.borrow(petOwner, petMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
}
|
||||
}
|
||||
|
||||
ManageNPCMsg mnm = new ManageNPCMsg(npc);
|
||||
mnm.setMessageType(1);
|
||||
Dispatch dispatch = Dispatch.borrow(player, mnm);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
// we Found the move to remove, lets break the for loop so it doesnt look for more.
|
||||
|
||||
}catch (Exception e){
|
||||
Logger.error(e);
|
||||
}finally {
|
||||
|
||||
npc.minionLock.writeLock().unlock();
|
||||
}
|
||||
}
|
||||
ManageCityAssetsMsg mca1 = new ManageCityAssetsMsg(player, b);
|
||||
mca1.actionType = 3;
|
||||
mca1.setTargetType(b.getObjectType().ordinal());
|
||||
mca1.setTargetID(b.getObjectUUID());
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
mca1.setTargetType3(npc.getObjectType().ordinal());
|
||||
mca1.setTargetID3(npc.getObjectUUID());
|
||||
mca1.setAssetName1(b.getName());
|
||||
mca1.setUnknown54(1);
|
||||
|
||||
Dispatch dispatch = Dispatch.borrow(player, mca1);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
;
|
||||
|
||||
ManageNPCMsg mnm = new ManageNPCMsg(npc);
|
||||
dispatch = Dispatch.borrow(player, mnm);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
|
||||
//Add Minion
|
||||
} else {
|
||||
Zone zone = npc.getParentZone();
|
||||
|
||||
if (zone == null)
|
||||
return true;
|
||||
|
||||
int maxSlots = 5;
|
||||
|
||||
if (npc.getContract().getContractID() == 842)//artillery captain
|
||||
maxSlots = 1;
|
||||
if (npc.getContract().getContractID() == 910)//guard dogs
|
||||
maxSlots = 0;
|
||||
switch (npc.getRank()) {
|
||||
case 1:
|
||||
case 2:
|
||||
maxSlots = 1;
|
||||
break;
|
||||
case 3:
|
||||
maxSlots = 2;
|
||||
break;
|
||||
case 4:
|
||||
case 5:
|
||||
maxSlots = 3;
|
||||
break;
|
||||
case 6:
|
||||
maxSlots = 4;
|
||||
break;
|
||||
case 7:
|
||||
maxSlots = 5;
|
||||
break;
|
||||
}
|
||||
|
||||
if (npc.getSiegeMinionMap().size() == maxSlots)
|
||||
return true;
|
||||
|
||||
int mobBase = npc.getMobBaseID();
|
||||
|
||||
if (mobBase == 0)
|
||||
return true;
|
||||
|
||||
String pirateName = NPCManager.getPirateName(mobBase);
|
||||
|
||||
if (!DbManager.MobQueries.ADD_TO_GUARDS(npc.getObjectUUID(), mobBase, pirateName, npc.getSiegeMinionMap().size() + 1))
|
||||
return true;
|
||||
|
||||
Mob toCreate = Mob.createGuardMob(npc, npc.getGuild(), zone, b.getLoc(), npc.getLevel(), pirateName);
|
||||
|
||||
if (toCreate == null)
|
||||
return true;
|
||||
|
||||
// toCreate.despawn();
|
||||
if (toCreate != null) {
|
||||
toCreate.setTimeToSpawnSiege(System.currentTimeMillis() + MBServerStatics.FIFTEEN_MINUTES);
|
||||
toCreate.setDeathTime(System.currentTimeMillis());
|
||||
toCreate.parentZone.zoneMobSet.add(toCreate);
|
||||
}
|
||||
}
|
||||
|
||||
ManageNPCMsg mnm = new ManageNPCMsg(npc);
|
||||
mnm.setMessageType(1);
|
||||
Dispatch dispatch = Dispatch.borrow(player, mnm);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
|
||||
} catch (Exception e) {
|
||||
Logger.error(e);
|
||||
} finally {
|
||||
|
||||
npc.minionLock.writeLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -24,7 +24,7 @@ public class MoveToPointHandler extends AbstractClientMsgHandler {
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg,
|
||||
ClientConnection origin) throws MsgSendException {
|
||||
ClientConnection origin) throws MsgSendException {
|
||||
MoveToPointMsg msg = (MoveToPointMsg) baseMsg;
|
||||
|
||||
PlayerCharacter pc = (origin != null) ? (origin.getPlayerCharacter()) : null;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -26,372 +26,371 @@ import java.util.ArrayList;
|
||||
|
||||
public class OpenFriendsCondemnListMsgHandler extends AbstractClientMsgHandler {
|
||||
|
||||
public OpenFriendsCondemnListMsgHandler() {
|
||||
super(OpenFriendsCondemnListMsg.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
|
||||
PlayerCharacter player = SessionManager.getPlayerCharacter(origin);
|
||||
Building sourceBuilding;
|
||||
OpenFriendsCondemnListMsg msg;
|
||||
OpenFriendsCondemnListMsg openFriendsCondemnListMsg;
|
||||
Enum.FriendListType friendListType;
|
||||
Dispatch dispatch;
|
||||
|
||||
if (player == null)
|
||||
return true;
|
||||
|
||||
msg = (OpenFriendsCondemnListMsg) baseMsg;
|
||||
openFriendsCondemnListMsg = new OpenFriendsCondemnListMsg(msg);
|
||||
friendListType = Enum.FriendListType.getListTypeByID(msg.getMessageType());
|
||||
|
||||
if (friendListType == null){
|
||||
Logger.error("Invalid FriendListType for messageType " + msg.getMessageType());
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (friendListType) {
|
||||
case VIEWHERALDRY: // Heraldry
|
||||
|
||||
Heraldry.ValidateHeraldry(player.getObjectUUID());
|
||||
OpenFriendsCondemnListMsg outMsg = new OpenFriendsCondemnListMsg(msg);
|
||||
outMsg.setOrigin(origin);
|
||||
outMsg.setMessageType(2);
|
||||
dispatch = Dispatch.borrow(player, outMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
break;
|
||||
|
||||
case ADDHERALDRY:
|
||||
Heraldry.ValidateHeraldry(player.getObjectUUID());
|
||||
if (msg.getPlayerID() <= 0){
|
||||
//ErrorPopupMsg.sendErrorMsg(player, "Invalid Heraldry Object.");
|
||||
return true;
|
||||
}
|
||||
AbstractCharacter toAdd = null;
|
||||
if (msg.getPlayerType() == GameObjectType.PlayerCharacter.ordinal())
|
||||
toAdd = PlayerCharacter.getFromCache(msg.getPlayerID());
|
||||
else if (msg.getPlayerType() == GameObjectType.NPC.ordinal())
|
||||
toAdd = NPC.getFromCache(msg.getPlayerID());
|
||||
else if (msg.getPlayerType() == GameObjectType.Mob.ordinal())
|
||||
toAdd = Mob.getFromCache(msg.getPlayerID());
|
||||
else{
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Invalid Heraldry Object.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (toAdd == null){
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Invalid Heraldry Object.");
|
||||
return true;
|
||||
}
|
||||
|
||||
Heraldry.AddToHeraldy(player.getObjectUUID(), toAdd);
|
||||
|
||||
|
||||
outMsg = new OpenFriendsCondemnListMsg(msg);
|
||||
outMsg.setOrigin(origin);
|
||||
outMsg.setMessageType(2);
|
||||
dispatch = Dispatch.borrow(player, outMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
|
||||
break;
|
||||
case REMOVEHERALDRY:
|
||||
Heraldry.ValidateHeraldry(player.getObjectUUID());
|
||||
Heraldry.RemoveFromHeraldy(player.getObjectUUID(), msg.getPlayerID());
|
||||
|
||||
|
||||
outMsg = new OpenFriendsCondemnListMsg(msg);
|
||||
outMsg.setOrigin(origin);
|
||||
outMsg.setMessageType(2);
|
||||
dispatch = Dispatch.borrow(player, outMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
|
||||
break;
|
||||
|
||||
case DEALTHS: // Death List
|
||||
openFriendsCondemnListMsg.updateMsg(8, new ArrayList<>(player.pvpDeaths));
|
||||
dispatch = Dispatch.borrow(player, openFriendsCondemnListMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
break;
|
||||
|
||||
case KILLS: // Kill List
|
||||
openFriendsCondemnListMsg.updateMsg(10, new ArrayList<>(player.pvpKills));
|
||||
dispatch = Dispatch.borrow(player, openFriendsCondemnListMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
break;
|
||||
|
||||
case VIEWCONDEMN:
|
||||
|
||||
sourceBuilding = BuildingManager.getBuildingFromCache(msg.getBuildingID());
|
||||
|
||||
if (sourceBuilding == null)
|
||||
return true;
|
||||
|
||||
openFriendsCondemnListMsg = new OpenFriendsCondemnListMsg(12, sourceBuilding.getCondemned(), sourceBuilding.reverseKOS);
|
||||
openFriendsCondemnListMsg.configure();
|
||||
dispatch = Dispatch.borrow(player, openFriendsCondemnListMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
|
||||
//msg.updateMsg(12, DbManager.GuildQueries.)
|
||||
break;
|
||||
//REMOVE CONDEMN
|
||||
case REMOVECONDEMN:
|
||||
|
||||
sourceBuilding = BuildingManager.getBuildingFromCache(msg.getBuildingID());
|
||||
|
||||
if (sourceBuilding == null)
|
||||
return true;
|
||||
|
||||
if (!BuildingManager.PlayerCanControlNotOwner(sourceBuilding, player))
|
||||
return true;
|
||||
|
||||
Condemned removeCondemn = sourceBuilding.getCondemned().get(msg.getRemoveFriendID());
|
||||
|
||||
if (removeCondemn == null)
|
||||
return true;
|
||||
|
||||
if (!DbManager.BuildingQueries.REMOVE_FROM_CONDEMNED_LIST(removeCondemn.getParent(), removeCondemn.getPlayerUID(), removeCondemn.getGuildUID(), removeCondemn.getFriendType()))
|
||||
return true;
|
||||
|
||||
sourceBuilding.getCondemned().remove(msg.getRemoveFriendID());
|
||||
dispatch = Dispatch.borrow(player, msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
break;
|
||||
|
||||
case TOGGLEACTIVE:
|
||||
|
||||
sourceBuilding = BuildingManager.getBuildingFromCache(msg.getBuildingID());
|
||||
|
||||
if (sourceBuilding == null)
|
||||
return true;
|
||||
|
||||
if (!BuildingManager.PlayerCanControlNotOwner(sourceBuilding, player))
|
||||
return true;
|
||||
|
||||
Condemned condemn = sourceBuilding.getCondemned().get(msg.getRemoveFriendID());
|
||||
public OpenFriendsCondemnListMsgHandler() {
|
||||
super(OpenFriendsCondemnListMsg.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
|
||||
PlayerCharacter player = SessionManager.getPlayerCharacter(origin);
|
||||
Building sourceBuilding;
|
||||
OpenFriendsCondemnListMsg msg;
|
||||
OpenFriendsCondemnListMsg openFriendsCondemnListMsg;
|
||||
Enum.FriendListType friendListType;
|
||||
Dispatch dispatch;
|
||||
|
||||
if (player == null)
|
||||
return true;
|
||||
|
||||
msg = (OpenFriendsCondemnListMsg) baseMsg;
|
||||
openFriendsCondemnListMsg = new OpenFriendsCondemnListMsg(msg);
|
||||
friendListType = Enum.FriendListType.getListTypeByID(msg.getMessageType());
|
||||
|
||||
if (friendListType == null) {
|
||||
Logger.error("Invalid FriendListType for messageType " + msg.getMessageType());
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (friendListType) {
|
||||
case VIEWHERALDRY: // Heraldry
|
||||
|
||||
Heraldry.ValidateHeraldry(player.getObjectUUID());
|
||||
OpenFriendsCondemnListMsg outMsg = new OpenFriendsCondemnListMsg(msg);
|
||||
outMsg.setOrigin(origin);
|
||||
outMsg.setMessageType(2);
|
||||
dispatch = Dispatch.borrow(player, outMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
break;
|
||||
|
||||
case ADDHERALDRY:
|
||||
Heraldry.ValidateHeraldry(player.getObjectUUID());
|
||||
if (msg.getPlayerID() <= 0) {
|
||||
//ErrorPopupMsg.sendErrorMsg(player, "Invalid Heraldry Object.");
|
||||
return true;
|
||||
}
|
||||
AbstractCharacter toAdd = null;
|
||||
if (msg.getPlayerType() == GameObjectType.PlayerCharacter.ordinal())
|
||||
toAdd = PlayerCharacter.getFromCache(msg.getPlayerID());
|
||||
else if (msg.getPlayerType() == GameObjectType.NPC.ordinal())
|
||||
toAdd = NPC.getFromCache(msg.getPlayerID());
|
||||
else if (msg.getPlayerType() == GameObjectType.Mob.ordinal())
|
||||
toAdd = Mob.getFromCache(msg.getPlayerID());
|
||||
else {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Invalid Heraldry Object.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (condemn == null)
|
||||
return true;
|
||||
if (toAdd == null) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Invalid Heraldry Object.");
|
||||
return true;
|
||||
}
|
||||
|
||||
condemn.setActive(msg.isReverseKOS());
|
||||
openFriendsCondemnListMsg.setReverseKOS(condemn.isActive());
|
||||
dispatch = Dispatch.borrow(player, msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
break;
|
||||
case REVERSEKOS:
|
||||
Heraldry.AddToHeraldy(player.getObjectUUID(), toAdd);
|
||||
|
||||
|
||||
sourceBuilding = BuildingManager.getBuildingFromCache(msg.getBuildingID());
|
||||
outMsg = new OpenFriendsCondemnListMsg(msg);
|
||||
outMsg.setOrigin(origin);
|
||||
outMsg.setMessageType(2);
|
||||
dispatch = Dispatch.borrow(player, outMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
|
||||
if (sourceBuilding == null)
|
||||
return true;
|
||||
break;
|
||||
case REMOVEHERALDRY:
|
||||
Heraldry.ValidateHeraldry(player.getObjectUUID());
|
||||
Heraldry.RemoveFromHeraldy(player.getObjectUUID(), msg.getPlayerID());
|
||||
|
||||
if (!BuildingManager.PlayerCanControlNotOwner(sourceBuilding, player))
|
||||
return true;
|
||||
|
||||
if (!sourceBuilding.setReverseKOS(msg.isReverseKOS()))
|
||||
return true;
|
||||
break;
|
||||
outMsg = new OpenFriendsCondemnListMsg(msg);
|
||||
outMsg.setOrigin(origin);
|
||||
outMsg.setMessageType(2);
|
||||
dispatch = Dispatch.borrow(player, outMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
|
||||
//ADD GUILD CONDEMN
|
||||
case ADDCONDEMN:
|
||||
break;
|
||||
|
||||
sourceBuilding = BuildingManager.getBuildingFromCache(msg.getBuildingID());
|
||||
case DEALTHS: // Death List
|
||||
openFriendsCondemnListMsg.updateMsg(8, new ArrayList<>(player.pvpDeaths));
|
||||
dispatch = Dispatch.borrow(player, openFriendsCondemnListMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
break;
|
||||
|
||||
if (sourceBuilding == null)
|
||||
return true;
|
||||
case KILLS: // Kill List
|
||||
openFriendsCondemnListMsg.updateMsg(10, new ArrayList<>(player.pvpKills));
|
||||
dispatch = Dispatch.borrow(player, openFriendsCondemnListMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
break;
|
||||
|
||||
if (!BuildingManager.PlayerCanControlNotOwner(sourceBuilding, player))
|
||||
return true;
|
||||
case VIEWCONDEMN:
|
||||
|
||||
switch (msg.getInviteType()) {
|
||||
case 2:
|
||||
sourceBuilding = BuildingManager.getBuildingFromCache(msg.getBuildingID());
|
||||
|
||||
if (msg.getPlayerID() == 0)
|
||||
return true;
|
||||
|
||||
if (msg.getPlayerType() != GameObjectType.PlayerCharacter.ordinal())
|
||||
return true;
|
||||
if (sourceBuilding == null)
|
||||
return true;
|
||||
|
||||
PlayerCharacter playerCharacter = PlayerCharacter.getFromCache(msg.getPlayerID());
|
||||
openFriendsCondemnListMsg = new OpenFriendsCondemnListMsg(12, sourceBuilding.getCondemned(), sourceBuilding.reverseKOS);
|
||||
openFriendsCondemnListMsg.configure();
|
||||
dispatch = Dispatch.borrow(player, openFriendsCondemnListMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
|
||||
if (playerCharacter == null)
|
||||
return true;
|
||||
//msg.updateMsg(12, DbManager.GuildQueries.)
|
||||
break;
|
||||
//REMOVE CONDEMN
|
||||
case REMOVECONDEMN:
|
||||
|
||||
if (Guild.sameNationExcludeErrant(sourceBuilding.getGuild(), playerCharacter.getGuild()))
|
||||
return true;
|
||||
sourceBuilding = BuildingManager.getBuildingFromCache(msg.getBuildingID());
|
||||
|
||||
if (sourceBuilding.getCondemned().containsKey(playerCharacter.getObjectUUID()))
|
||||
return true;
|
||||
if (sourceBuilding == null)
|
||||
return true;
|
||||
|
||||
if (!DbManager.BuildingQueries.ADD_TO_CONDEMNLIST(sourceBuilding.getObjectUUID(), playerCharacter.getObjectUUID(), msg.getGuildID(), msg.getInviteType())) {
|
||||
Logger.debug( "Failed to add Condemned: " + playerCharacter.getFirstName() + " to Building With UID " + sourceBuilding.getObjectUUID());
|
||||
return true;
|
||||
}
|
||||
if (!BuildingManager.PlayerCanControlNotOwner(sourceBuilding, player))
|
||||
return true;
|
||||
|
||||
sourceBuilding.getCondemned().put(playerCharacter.getObjectUUID(), new Condemned(playerCharacter.getObjectUUID(), sourceBuilding.getObjectUUID(), msg.getGuildID(), msg.getInviteType()));
|
||||
break;
|
||||
case 4:
|
||||
if (msg.getGuildID() == 0)
|
||||
return true;
|
||||
Condemned removeCondemn = sourceBuilding.getCondemned().get(msg.getRemoveFriendID());
|
||||
|
||||
if (sourceBuilding.getCondemned().containsKey(msg.getGuildID()))
|
||||
return true;
|
||||
if (removeCondemn == null)
|
||||
return true;
|
||||
|
||||
Guild condemnedGuild = Guild.getGuild(msg.getGuildID());
|
||||
if (!DbManager.BuildingQueries.REMOVE_FROM_CONDEMNED_LIST(removeCondemn.getParent(), removeCondemn.getPlayerUID(), removeCondemn.getGuildUID(), removeCondemn.getFriendType()))
|
||||
return true;
|
||||
|
||||
if (condemnedGuild == null)
|
||||
return true;
|
||||
sourceBuilding.getCondemned().remove(msg.getRemoveFriendID());
|
||||
dispatch = Dispatch.borrow(player, msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
break;
|
||||
|
||||
if (!DbManager.BuildingQueries.ADD_TO_CONDEMNLIST(sourceBuilding.getObjectUUID(), msg.getPlayerID(), condemnedGuild.getObjectUUID(), msg.getInviteType())) {
|
||||
Logger.debug("Failed to add Condemned: " + condemnedGuild.getName() + " to Building With UID " + sourceBuilding.getObjectUUID());
|
||||
return true;
|
||||
}
|
||||
case TOGGLEACTIVE:
|
||||
|
||||
sourceBuilding.getCondemned().put(condemnedGuild.getObjectUUID(), new Condemned(msg.getPlayerID(), sourceBuilding.getObjectUUID(), condemnedGuild.getObjectUUID(), msg.getInviteType()));
|
||||
break;
|
||||
case 5:
|
||||
if (msg.getNationID() == 0)
|
||||
return true;
|
||||
sourceBuilding = BuildingManager.getBuildingFromCache(msg.getBuildingID());
|
||||
|
||||
if (sourceBuilding.getCondemned().containsKey(msg.getNationID()))
|
||||
return true;
|
||||
if (sourceBuilding == null)
|
||||
return true;
|
||||
|
||||
Guild condemnedNation = Guild.getGuild(msg.getNationID());
|
||||
if (!BuildingManager.PlayerCanControlNotOwner(sourceBuilding, player))
|
||||
return true;
|
||||
|
||||
if (condemnedNation == null)
|
||||
return true;
|
||||
Condemned condemn = sourceBuilding.getCondemned().get(msg.getRemoveFriendID());
|
||||
|
||||
if (!DbManager.BuildingQueries.ADD_TO_CONDEMNLIST(sourceBuilding.getObjectUUID(), msg.getPlayerID(), condemnedNation.getObjectUUID(), msg.getInviteType())) {
|
||||
Logger.debug( "Failed to add Condemned: " + condemnedNation.getName() + " to Building With UID " + sourceBuilding.getObjectUUID());
|
||||
return true;
|
||||
}
|
||||
if (condemn == null)
|
||||
return true;
|
||||
|
||||
sourceBuilding.getCondemned().put(condemnedNation.getObjectUUID(), new Condemned(msg.getPlayerID(), sourceBuilding.getObjectUUID(), condemnedNation.getObjectUUID(), msg.getInviteType()));
|
||||
break;
|
||||
condemn.setActive(msg.isReverseKOS());
|
||||
openFriendsCondemnListMsg.setReverseKOS(condemn.isActive());
|
||||
dispatch = Dispatch.borrow(player, msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
break;
|
||||
case REVERSEKOS:
|
||||
|
||||
}
|
||||
|
||||
openFriendsCondemnListMsg = new OpenFriendsCondemnListMsg(12, sourceBuilding.getCondemned(), sourceBuilding.reverseKOS);
|
||||
openFriendsCondemnListMsg.configure();
|
||||
dispatch = Dispatch.borrow(player, openFriendsCondemnListMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
break;
|
||||
sourceBuilding = BuildingManager.getBuildingFromCache(msg.getBuildingID());
|
||||
|
||||
//ADD FRIEND BUILDING
|
||||
case ADDFRIEND:
|
||||
sourceBuilding = BuildingManager.getBuildingFromCache(msg.getBuildingID());
|
||||
if (sourceBuilding == null)
|
||||
return true;
|
||||
|
||||
if (sourceBuilding == null)
|
||||
return true;
|
||||
if (!BuildingManager.PlayerCanControlNotOwner(sourceBuilding, player))
|
||||
return true;
|
||||
|
||||
if (msg.getGuildID() == 0)
|
||||
return true;
|
||||
if (!sourceBuilding.setReverseKOS(msg.isReverseKOS()))
|
||||
return true;
|
||||
break;
|
||||
|
||||
if (!BuildingManager.PlayerCanControlNotOwner(sourceBuilding, player))
|
||||
return true;
|
||||
|
||||
PlayerCharacter playerCharacter = null;
|
||||
//ADD GUILD CONDEMN
|
||||
case ADDCONDEMN:
|
||||
|
||||
|
||||
sourceBuilding = BuildingManager.getBuildingFromCache(msg.getBuildingID());
|
||||
|
||||
Guild guildInvited = Guild.getGuild(msg.getGuildID());
|
||||
if (sourceBuilding == null)
|
||||
return true;
|
||||
|
||||
if (guildInvited == null)
|
||||
return true;
|
||||
if (!BuildingManager.PlayerCanControlNotOwner(sourceBuilding, player))
|
||||
return true;
|
||||
|
||||
//Check to see if the invited is already on the friends list.
|
||||
switch (msg.getInviteType()) {
|
||||
case 7:
|
||||
playerCharacter = PlayerCharacter.getFromCache(msg.getPlayerID());
|
||||
if (playerCharacter == null)
|
||||
return true;
|
||||
if (sourceBuilding.getFriends().containsKey(playerCharacter.getObjectUUID()))
|
||||
return true;
|
||||
break;
|
||||
case 8:
|
||||
case 9:
|
||||
if (sourceBuilding.getFriends().containsKey(guildInvited.getObjectUUID()))
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!DbManager.BuildingQueries.ADD_TO_FRIENDS_LIST(sourceBuilding.getObjectUUID(), msg.getPlayerID(), guildInvited.getObjectUUID(), msg.getInviteType())) {
|
||||
Logger.debug( "Failed to add Friend: " + playerCharacter.getFirstName() + " to Building With UID " + sourceBuilding.getObjectUUID());
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (msg.getInviteType()) {
|
||||
case 7:
|
||||
sourceBuilding.getFriends().put(playerCharacter.getObjectUUID(), new BuildingFriends(playerCharacter.getObjectUUID(), sourceBuilding.getObjectUUID(), playerCharacter.getGuild().getObjectUUID(), 7));
|
||||
break;
|
||||
case 8:
|
||||
sourceBuilding.getFriends().put(guildInvited.getObjectUUID(), new BuildingFriends(msg.getPlayerID(), sourceBuilding.getObjectUUID(), guildInvited.getObjectUUID(), 8));
|
||||
break;
|
||||
case 9:
|
||||
sourceBuilding.getFriends().put(guildInvited.getObjectUUID(), new BuildingFriends(msg.getPlayerID(), sourceBuilding.getObjectUUID(), guildInvited.getObjectUUID(), 9));
|
||||
break;
|
||||
}
|
||||
|
||||
openFriendsCondemnListMsg = new OpenFriendsCondemnListMsg(26, sourceBuilding.getFriends());
|
||||
openFriendsCondemnListMsg.configure();
|
||||
|
||||
dispatch = Dispatch.borrow(player, openFriendsCondemnListMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
break;
|
||||
//REMOVE from friends list.
|
||||
case REMOVEFRIEND:
|
||||
sourceBuilding = BuildingManager.getBuildingFromCache(msg.getBuildingID());
|
||||
|
||||
if (sourceBuilding == null)
|
||||
return true;
|
||||
|
||||
if (!BuildingManager.PlayerCanControlNotOwner(sourceBuilding, player))
|
||||
return true;
|
||||
|
||||
BuildingFriends friend = sourceBuilding.getFriends().get(msg.getRemoveFriendID());
|
||||
|
||||
if (friend == null)
|
||||
return true;
|
||||
switch (msg.getInviteType()) {
|
||||
case 2:
|
||||
|
||||
if (!DbManager.BuildingQueries.REMOVE_FROM_FRIENDS_LIST(sourceBuilding.getObjectUUID(), friend.getPlayerUID(), friend.getGuildUID(), friend.getFriendType())) {
|
||||
Logger.debug( "Failed to remove Friend: " + msg.getRemoveFriendID() + " from Building With UID " + sourceBuilding.getObjectUUID());
|
||||
return true;
|
||||
}
|
||||
sourceBuilding.getFriends().remove(msg.getRemoveFriendID());
|
||||
|
||||
openFriendsCondemnListMsg = new OpenFriendsCondemnListMsg(26, sourceBuilding.getFriends());
|
||||
openFriendsCondemnListMsg.configure();
|
||||
dispatch = Dispatch.borrow(player, openFriendsCondemnListMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
|
||||
break;
|
||||
//view Friends
|
||||
case VIEWFRIENDS:
|
||||
|
||||
Building building = BuildingManager.getBuildingFromCache(msg.getBuildingID());
|
||||
|
||||
if (building == null)
|
||||
return true;
|
||||
|
||||
if (!BuildingManager.PlayerCanControlNotOwner(building, player))
|
||||
return true;
|
||||
|
||||
//this message is sent twice back?????
|
||||
|
||||
openFriendsCondemnListMsg = new OpenFriendsCondemnListMsg(26, building.getFriends());
|
||||
openFriendsCondemnListMsg.configure();
|
||||
|
||||
|
||||
dispatch = Dispatch.borrow(player, openFriendsCondemnListMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (msg.getPlayerID() == 0)
|
||||
return true;
|
||||
|
||||
if (msg.getPlayerType() != GameObjectType.PlayerCharacter.ordinal())
|
||||
return true;
|
||||
|
||||
PlayerCharacter playerCharacter = PlayerCharacter.getFromCache(msg.getPlayerID());
|
||||
|
||||
if (playerCharacter == null)
|
||||
return true;
|
||||
|
||||
if (Guild.sameNationExcludeErrant(sourceBuilding.getGuild(), playerCharacter.getGuild()))
|
||||
return true;
|
||||
|
||||
if (sourceBuilding.getCondemned().containsKey(playerCharacter.getObjectUUID()))
|
||||
return true;
|
||||
|
||||
if (!DbManager.BuildingQueries.ADD_TO_CONDEMNLIST(sourceBuilding.getObjectUUID(), playerCharacter.getObjectUUID(), msg.getGuildID(), msg.getInviteType())) {
|
||||
Logger.debug("Failed to add Condemned: " + playerCharacter.getFirstName() + " to Building With UID " + sourceBuilding.getObjectUUID());
|
||||
return true;
|
||||
}
|
||||
|
||||
sourceBuilding.getCondemned().put(playerCharacter.getObjectUUID(), new Condemned(playerCharacter.getObjectUUID(), sourceBuilding.getObjectUUID(), msg.getGuildID(), msg.getInviteType()));
|
||||
break;
|
||||
case 4:
|
||||
if (msg.getGuildID() == 0)
|
||||
return true;
|
||||
|
||||
if (sourceBuilding.getCondemned().containsKey(msg.getGuildID()))
|
||||
return true;
|
||||
|
||||
Guild condemnedGuild = Guild.getGuild(msg.getGuildID());
|
||||
|
||||
if (condemnedGuild == null)
|
||||
return true;
|
||||
|
||||
if (!DbManager.BuildingQueries.ADD_TO_CONDEMNLIST(sourceBuilding.getObjectUUID(), msg.getPlayerID(), condemnedGuild.getObjectUUID(), msg.getInviteType())) {
|
||||
Logger.debug("Failed to add Condemned: " + condemnedGuild.getName() + " to Building With UID " + sourceBuilding.getObjectUUID());
|
||||
return true;
|
||||
}
|
||||
|
||||
sourceBuilding.getCondemned().put(condemnedGuild.getObjectUUID(), new Condemned(msg.getPlayerID(), sourceBuilding.getObjectUUID(), condemnedGuild.getObjectUUID(), msg.getInviteType()));
|
||||
break;
|
||||
case 5:
|
||||
if (msg.getNationID() == 0)
|
||||
return true;
|
||||
|
||||
if (sourceBuilding.getCondemned().containsKey(msg.getNationID()))
|
||||
return true;
|
||||
|
||||
Guild condemnedNation = Guild.getGuild(msg.getNationID());
|
||||
|
||||
if (condemnedNation == null)
|
||||
return true;
|
||||
|
||||
if (!DbManager.BuildingQueries.ADD_TO_CONDEMNLIST(sourceBuilding.getObjectUUID(), msg.getPlayerID(), condemnedNation.getObjectUUID(), msg.getInviteType())) {
|
||||
Logger.debug("Failed to add Condemned: " + condemnedNation.getName() + " to Building With UID " + sourceBuilding.getObjectUUID());
|
||||
return true;
|
||||
}
|
||||
|
||||
sourceBuilding.getCondemned().put(condemnedNation.getObjectUUID(), new Condemned(msg.getPlayerID(), sourceBuilding.getObjectUUID(), condemnedNation.getObjectUUID(), msg.getInviteType()));
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
openFriendsCondemnListMsg = new OpenFriendsCondemnListMsg(12, sourceBuilding.getCondemned(), sourceBuilding.reverseKOS);
|
||||
openFriendsCondemnListMsg.configure();
|
||||
dispatch = Dispatch.borrow(player, openFriendsCondemnListMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
break;
|
||||
|
||||
//ADD FRIEND BUILDING
|
||||
case ADDFRIEND:
|
||||
sourceBuilding = BuildingManager.getBuildingFromCache(msg.getBuildingID());
|
||||
|
||||
if (sourceBuilding == null)
|
||||
return true;
|
||||
|
||||
if (msg.getGuildID() == 0)
|
||||
return true;
|
||||
|
||||
if (!BuildingManager.PlayerCanControlNotOwner(sourceBuilding, player))
|
||||
return true;
|
||||
|
||||
PlayerCharacter playerCharacter = null;
|
||||
|
||||
|
||||
Guild guildInvited = Guild.getGuild(msg.getGuildID());
|
||||
|
||||
if (guildInvited == null)
|
||||
return true;
|
||||
|
||||
//Check to see if the invited is already on the friends list.
|
||||
switch (msg.getInviteType()) {
|
||||
case 7:
|
||||
playerCharacter = PlayerCharacter.getFromCache(msg.getPlayerID());
|
||||
if (playerCharacter == null)
|
||||
return true;
|
||||
if (sourceBuilding.getFriends().containsKey(playerCharacter.getObjectUUID()))
|
||||
return true;
|
||||
break;
|
||||
case 8:
|
||||
case 9:
|
||||
if (sourceBuilding.getFriends().containsKey(guildInvited.getObjectUUID()))
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!DbManager.BuildingQueries.ADD_TO_FRIENDS_LIST(sourceBuilding.getObjectUUID(), msg.getPlayerID(), guildInvited.getObjectUUID(), msg.getInviteType())) {
|
||||
Logger.debug("Failed to add Friend: " + playerCharacter.getFirstName() + " to Building With UID " + sourceBuilding.getObjectUUID());
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (msg.getInviteType()) {
|
||||
case 7:
|
||||
sourceBuilding.getFriends().put(playerCharacter.getObjectUUID(), new BuildingFriends(playerCharacter.getObjectUUID(), sourceBuilding.getObjectUUID(), playerCharacter.getGuild().getObjectUUID(), 7));
|
||||
break;
|
||||
case 8:
|
||||
sourceBuilding.getFriends().put(guildInvited.getObjectUUID(), new BuildingFriends(msg.getPlayerID(), sourceBuilding.getObjectUUID(), guildInvited.getObjectUUID(), 8));
|
||||
break;
|
||||
case 9:
|
||||
sourceBuilding.getFriends().put(guildInvited.getObjectUUID(), new BuildingFriends(msg.getPlayerID(), sourceBuilding.getObjectUUID(), guildInvited.getObjectUUID(), 9));
|
||||
break;
|
||||
}
|
||||
|
||||
openFriendsCondemnListMsg = new OpenFriendsCondemnListMsg(26, sourceBuilding.getFriends());
|
||||
openFriendsCondemnListMsg.configure();
|
||||
|
||||
dispatch = Dispatch.borrow(player, openFriendsCondemnListMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
break;
|
||||
//REMOVE from friends list.
|
||||
case REMOVEFRIEND:
|
||||
sourceBuilding = BuildingManager.getBuildingFromCache(msg.getBuildingID());
|
||||
|
||||
if (sourceBuilding == null)
|
||||
return true;
|
||||
|
||||
if (!BuildingManager.PlayerCanControlNotOwner(sourceBuilding, player))
|
||||
return true;
|
||||
|
||||
BuildingFriends friend = sourceBuilding.getFriends().get(msg.getRemoveFriendID());
|
||||
|
||||
if (friend == null)
|
||||
return true;
|
||||
|
||||
if (!DbManager.BuildingQueries.REMOVE_FROM_FRIENDS_LIST(sourceBuilding.getObjectUUID(), friend.getPlayerUID(), friend.getGuildUID(), friend.getFriendType())) {
|
||||
Logger.debug("Failed to remove Friend: " + msg.getRemoveFriendID() + " from Building With UID " + sourceBuilding.getObjectUUID());
|
||||
return true;
|
||||
}
|
||||
sourceBuilding.getFriends().remove(msg.getRemoveFriendID());
|
||||
|
||||
openFriendsCondemnListMsg = new OpenFriendsCondemnListMsg(26, sourceBuilding.getFriends());
|
||||
openFriendsCondemnListMsg.configure();
|
||||
dispatch = Dispatch.borrow(player, openFriendsCondemnListMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
|
||||
break;
|
||||
//view Friends
|
||||
case VIEWFRIENDS:
|
||||
|
||||
Building building = BuildingManager.getBuildingFromCache(msg.getBuildingID());
|
||||
|
||||
if (building == null)
|
||||
return true;
|
||||
|
||||
if (!BuildingManager.PlayerCanControlNotOwner(building, player))
|
||||
return true;
|
||||
|
||||
//this message is sent twice back?????
|
||||
|
||||
openFriendsCondemnListMsg = new OpenFriendsCondemnListMsg(26, building.getFriends());
|
||||
openFriendsCondemnListMsg.configure();
|
||||
|
||||
|
||||
dispatch = Dispatch.borrow(player, openFriendsCondemnListMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -19,72 +19,69 @@ import engine.objects.PlayerCharacter;
|
||||
*/
|
||||
public class RecommendNationMsgHandler extends AbstractClientMsgHandler {
|
||||
|
||||
public RecommendNationMsgHandler() {
|
||||
super(RecommendNationMsg.class);
|
||||
}
|
||||
public RecommendNationMsgHandler() {
|
||||
super(RecommendNationMsg.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
private static void RecommendNation(Guild fromGuild, Guild toGuild, RecommendNationMsg msg, ClientConnection origin) {
|
||||
|
||||
// Member variable declaration
|
||||
// Member variable declaration
|
||||
Dispatch dispatch;
|
||||
|
||||
PlayerCharacter player;
|
||||
RecommendNationMsg msg;
|
||||
// Member variable assignment
|
||||
|
||||
if (fromGuild == null)
|
||||
return;
|
||||
|
||||
if (toGuild == null)
|
||||
return;
|
||||
|
||||
AllianceType allianceType;
|
||||
if (msg.getAlly() == 1)
|
||||
allianceType = AllianceType.RecommendedAlly;
|
||||
else
|
||||
allianceType = AllianceType.RecommendedEnemy;
|
||||
|
||||
if (!fromGuild.addGuildToAlliance(new AllianceChangeMsg(origin.getPlayerCharacter(), fromGuild.getObjectUUID(), toGuild.getObjectUUID(), (byte) 0, 0), allianceType, toGuild, origin.getPlayerCharacter()))
|
||||
return;
|
||||
String alliance = msg.getAlly() == 1 ? "ally" : "enemy";
|
||||
|
||||
ChatManager.chatGuildInfo(fromGuild, origin.getPlayerCharacter().getFirstName() + " has recommended " + toGuild.getName() + " as an " + alliance);
|
||||
|
||||
// dispatch = Dispatch.borrow(origin.getPlayerCharacter(), msg);
|
||||
// DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
|
||||
|
||||
// Member variable assignment
|
||||
}
|
||||
|
||||
msg = (RecommendNationMsg) baseMsg;
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
|
||||
player = SessionManager.getPlayerCharacter(origin);
|
||||
// Member variable declaration
|
||||
|
||||
if (player == null)
|
||||
return true;
|
||||
PlayerCharacter player;
|
||||
RecommendNationMsg msg;
|
||||
|
||||
|
||||
RecommendNationMsgHandler.RecommendNation(player.getGuild(), Guild.getGuild(msg.getGuildID()), msg, origin);
|
||||
// Member variable assignment
|
||||
|
||||
msg = (RecommendNationMsg) baseMsg;
|
||||
|
||||
player = SessionManager.getPlayerCharacter(origin);
|
||||
|
||||
if (player == null)
|
||||
return true;
|
||||
|
||||
|
||||
RecommendNationMsgHandler.RecommendNation(player.getGuild(), Guild.getGuild(msg.getGuildID()), msg, origin);
|
||||
|
||||
|
||||
// dispatch = Dispatch.borrow(player, baseMsg);
|
||||
// DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
// dispatch = Dispatch.borrow(player, baseMsg);
|
||||
// DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
private static void RecommendNation(Guild fromGuild, Guild toGuild, RecommendNationMsg msg, ClientConnection origin) {
|
||||
|
||||
// Member variable declaration
|
||||
Dispatch dispatch;
|
||||
|
||||
// Member variable assignment
|
||||
|
||||
if (fromGuild == null)
|
||||
return;
|
||||
|
||||
if (toGuild == null)
|
||||
return;
|
||||
|
||||
AllianceType allianceType;
|
||||
if (msg.getAlly() == 1)
|
||||
allianceType = AllianceType.RecommendedAlly;
|
||||
else
|
||||
allianceType = AllianceType.RecommendedEnemy;
|
||||
|
||||
if (!fromGuild.addGuildToAlliance(new AllianceChangeMsg(origin.getPlayerCharacter(),fromGuild.getObjectUUID(), toGuild.getObjectUUID(), (byte)0, 0), allianceType, toGuild, origin.getPlayerCharacter()))
|
||||
return;
|
||||
String alliance = msg.getAlly() == 1? "ally" : "enemy";
|
||||
|
||||
ChatManager.chatGuildInfo(fromGuild, origin.getPlayerCharacter().getFirstName() + " has recommended " + toGuild.getName() + " as an " + alliance );
|
||||
|
||||
// dispatch = Dispatch.borrow(origin.getPlayerCharacter(), msg);
|
||||
// DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
|
||||
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -20,45 +20,42 @@ import engine.objects.PlayerCharacter;
|
||||
import engine.objects.PlayerFriends;
|
||||
|
||||
|
||||
|
||||
public class RemoveFriendHandler extends AbstractClientMsgHandler {
|
||||
|
||||
public RemoveFriendHandler() {
|
||||
super(RemoveFriendMessage.class);
|
||||
}
|
||||
public RemoveFriendHandler() {
|
||||
super(RemoveFriendMessage.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg,
|
||||
ClientConnection origin) throws MsgSendException {
|
||||
|
||||
PlayerCharacter player = origin.getPlayerCharacter();
|
||||
|
||||
if (player == null)
|
||||
return true;
|
||||
|
||||
public static void HandleRemoveFriend(PlayerCharacter player, RemoveFriendMessage msg) {
|
||||
|
||||
RemoveFriendMessage msg = (RemoveFriendMessage)baseMsg;
|
||||
|
||||
HandleRemoveFriend(player,msg);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//No friends in list. Early exit.
|
||||
PlayerFriends.RemoveFromFriends(player.getObjectUUID(), msg.friendID);
|
||||
PlayerFriends.RemoveFromFriends(msg.friendID, player.getObjectUUID());
|
||||
|
||||
Dispatch dispatch = Dispatch.borrow(player, msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
|
||||
msg = new RemoveFriendMessage(msg.friendID);
|
||||
|
||||
dispatch = Dispatch.borrow(player, msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg,
|
||||
ClientConnection origin) throws MsgSendException {
|
||||
|
||||
PlayerCharacter player = origin.getPlayerCharacter();
|
||||
|
||||
if (player == null)
|
||||
return true;
|
||||
|
||||
|
||||
RemoveFriendMessage msg = (RemoveFriendMessage) baseMsg;
|
||||
|
||||
HandleRemoveFriend(player, msg);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public static void HandleRemoveFriend(PlayerCharacter player, RemoveFriendMessage msg){
|
||||
|
||||
//No friends in list. Early exit.
|
||||
PlayerFriends.RemoveFromFriends(player.getObjectUUID(), msg.friendID);
|
||||
PlayerFriends.RemoveFromFriends(msg.friendID, player.getObjectUUID());
|
||||
|
||||
Dispatch dispatch = Dispatch.borrow(player, msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
|
||||
msg = new RemoveFriendMessage(msg.friendID);
|
||||
|
||||
dispatch = Dispatch.borrow(player, msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,116 +24,108 @@ import engine.objects.Zone;
|
||||
*/
|
||||
public class RepairBuildingMsgHandler extends AbstractClientMsgHandler {
|
||||
|
||||
public RepairBuildingMsgHandler() {
|
||||
super(RepairBuildingMsg.class);
|
||||
}
|
||||
public RepairBuildingMsgHandler() {
|
||||
super(RepairBuildingMsg.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
private static void RepairBuilding(Building targetBuilding, ClientConnection origin, RepairBuildingMsg msg) {
|
||||
|
||||
// Member variable declaration
|
||||
// Member variable declaration
|
||||
|
||||
PlayerCharacter player;
|
||||
Building targetBuilding;
|
||||
RepairBuildingMsg msg;
|
||||
Zone serverZone;
|
||||
Dispatch dispatch;
|
||||
|
||||
// Member variable assignment
|
||||
|
||||
if (targetBuilding == null)
|
||||
return;
|
||||
|
||||
if (!targetBuilding.hasFunds(BuildingManager.GetRepairCost(targetBuilding)))
|
||||
return;
|
||||
|
||||
PlayerCharacter pc = origin.getPlayerCharacter();
|
||||
|
||||
serverZone = ZoneManager.findSmallestZone(pc.getLoc());
|
||||
|
||||
if (serverZone.getPlayerCityUUID() == 0 && targetBuilding.getBlueprint() != null && targetBuilding.getBlueprint().getBuildingGroup() != BuildingGroup.MINE)
|
||||
return;
|
||||
|
||||
|
||||
// Member variable assignment
|
||||
City city = City.GetCityFromCache(serverZone.getPlayerCityUUID());
|
||||
|
||||
msg = (RepairBuildingMsg) baseMsg;
|
||||
if (city != null) {
|
||||
if (city.getBane() != null && city.protectionEnforced == false)
|
||||
return;
|
||||
|
||||
player = SessionManager.getPlayerCharacter(origin);
|
||||
}
|
||||
|
||||
if (player == null)
|
||||
return true;
|
||||
//cannot repair mines during 24/7 activity.
|
||||
|
||||
if (targetBuilding.getBlueprint() != null && targetBuilding.getBlueprint().getBuildingGroup() == BuildingGroup.MINE) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
int maxHP = (int) targetBuilding.getMaxHitPoints();
|
||||
int repairCost = BuildingManager.GetRepairCost(targetBuilding);
|
||||
int missingHealth = (int) BuildingManager.GetMissingHealth(targetBuilding);
|
||||
|
||||
switch (msg.getType()) {
|
||||
case 0:
|
||||
targetBuilding = BuildingManager.getBuildingFromCache(msg.getBuildingID());
|
||||
RepairBuilding(targetBuilding, origin, msg);
|
||||
break;
|
||||
if (!targetBuilding.transferGold(-repairCost, false))
|
||||
return;
|
||||
|
||||
// targetBuilding.createFurniture(item.getItemBase().getUseID(), 0, msg.getFurnitureLoc(), Vector3f.ZERO, 0, player);
|
||||
targetBuilding.modifyHealth(BuildingManager.GetMissingHealth(targetBuilding), null);
|
||||
|
||||
UpdateObjectMsg uom = new UpdateObjectMsg(targetBuilding, 3);
|
||||
|
||||
dispatch = Dispatch.borrow(origin.getPlayerCharacter(), uom);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
|
||||
|
||||
}
|
||||
RepairBuildingMsg rbm = new RepairBuildingMsg(targetBuilding.getObjectUUID(), maxHP, missingHealth, repairCost, targetBuilding.getStrongboxValue());
|
||||
|
||||
|
||||
dispatch = Dispatch.borrow(origin.getPlayerCharacter(), rbm);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
|
||||
// Member variable declaration
|
||||
|
||||
PlayerCharacter player;
|
||||
Building targetBuilding;
|
||||
RepairBuildingMsg msg;
|
||||
|
||||
|
||||
// dispatch = Dispatch.borrow(player, baseMsg);
|
||||
// DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
// Member variable assignment
|
||||
|
||||
return true;
|
||||
msg = (RepairBuildingMsg) baseMsg;
|
||||
|
||||
}
|
||||
player = SessionManager.getPlayerCharacter(origin);
|
||||
|
||||
private static void RepairBuilding(Building targetBuilding, ClientConnection origin, RepairBuildingMsg msg) {
|
||||
|
||||
// Member variable declaration
|
||||
|
||||
Zone serverZone;
|
||||
Dispatch dispatch;
|
||||
|
||||
// Member variable assignment
|
||||
|
||||
if (targetBuilding == null)
|
||||
return;
|
||||
|
||||
if (!targetBuilding.hasFunds(BuildingManager.GetRepairCost(targetBuilding)))
|
||||
return;
|
||||
|
||||
PlayerCharacter pc = origin.getPlayerCharacter();
|
||||
|
||||
serverZone = ZoneManager.findSmallestZone(pc.getLoc());
|
||||
|
||||
if (serverZone.getPlayerCityUUID() == 0 && targetBuilding.getBlueprint() != null && targetBuilding.getBlueprint().getBuildingGroup() != BuildingGroup.MINE)
|
||||
return;
|
||||
if (player == null)
|
||||
return true;
|
||||
|
||||
|
||||
City city = City.GetCityFromCache(serverZone.getPlayerCityUUID());
|
||||
switch (msg.getType()) {
|
||||
case 0:
|
||||
targetBuilding = BuildingManager.getBuildingFromCache(msg.getBuildingID());
|
||||
RepairBuilding(targetBuilding, origin, msg);
|
||||
break;
|
||||
|
||||
if (city != null){
|
||||
if(city.getBane() != null && city.protectionEnforced == false)
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
//cannot repair mines during 24/7 activity.
|
||||
|
||||
if (targetBuilding.getBlueprint() != null && targetBuilding.getBlueprint().getBuildingGroup() == BuildingGroup.MINE){
|
||||
return;
|
||||
}
|
||||
// targetBuilding.createFurniture(item.getItemBase().getUseID(), 0, msg.getFurnitureLoc(), Vector3f.ZERO, 0, player);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
// dispatch = Dispatch.borrow(player, baseMsg);
|
||||
// DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
|
||||
int maxHP = (int) targetBuilding.getMaxHitPoints();
|
||||
int repairCost = BuildingManager.GetRepairCost(targetBuilding);
|
||||
int missingHealth = (int) BuildingManager.GetMissingHealth(targetBuilding);
|
||||
|
||||
if (!targetBuilding.transferGold(-repairCost,false))
|
||||
return;
|
||||
|
||||
targetBuilding.modifyHealth(BuildingManager.GetMissingHealth(targetBuilding), null);
|
||||
|
||||
UpdateObjectMsg uom = new UpdateObjectMsg(targetBuilding,3);
|
||||
|
||||
dispatch = Dispatch.borrow(origin.getPlayerCharacter(), uom);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
|
||||
|
||||
|
||||
RepairBuildingMsg rbm = new RepairBuildingMsg( targetBuilding.getObjectUUID(), maxHP, missingHealth, repairCost, targetBuilding.getStrongboxValue());
|
||||
|
||||
|
||||
dispatch = Dispatch.borrow(origin.getPlayerCharacter(), rbm);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -14,34 +14,33 @@ import engine.net.client.ClientConnection;
|
||||
import engine.net.client.msg.ClientNetMsg;
|
||||
import engine.net.client.msg.RequestBallListMessage;
|
||||
import engine.objects.PlayerCharacter;
|
||||
|
||||
public class RequestBallListHandler extends AbstractClientMsgHandler {
|
||||
|
||||
public RequestBallListHandler() {
|
||||
super(RequestBallListMessage.class);
|
||||
}
|
||||
public RequestBallListHandler() {
|
||||
super(RequestBallListMessage.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg,
|
||||
ClientConnection origin) throws MsgSendException {
|
||||
|
||||
PlayerCharacter player = origin.getPlayerCharacter();
|
||||
|
||||
if (player == null)
|
||||
return true;
|
||||
|
||||
public static void HandleRequestBallList(PlayerCharacter player, RequestBallListMessage msg) {
|
||||
//currently not handled.
|
||||
|
||||
RequestBallListMessage msg = (RequestBallListMessage)baseMsg;
|
||||
|
||||
HandleRequestBallList(player,msg);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg,
|
||||
ClientConnection origin) throws MsgSendException {
|
||||
|
||||
PlayerCharacter player = origin.getPlayerCharacter();
|
||||
|
||||
if (player == null)
|
||||
return true;
|
||||
|
||||
|
||||
RequestBallListMessage msg = (RequestBallListMessage) baseMsg;
|
||||
|
||||
HandleRequestBallList(player, msg);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public static void HandleRequestBallList(PlayerCharacter player, RequestBallListMessage msg){
|
||||
//currently not handled.
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -30,134 +30,134 @@ import org.pmw.tinylog.Logger;
|
||||
|
||||
public class RequestEnterWorldHandler extends AbstractClientMsgHandler {
|
||||
|
||||
public RequestEnterWorldHandler() {
|
||||
super(RequestEnterWorldMsg.class);
|
||||
}
|
||||
public RequestEnterWorldHandler() {
|
||||
super(RequestEnterWorldMsg.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
|
||||
RequestEnterWorldMsg msg;
|
||||
RequestEnterWorldMsg msg;
|
||||
|
||||
msg = (RequestEnterWorldMsg) baseMsg;
|
||||
msg = (RequestEnterWorldMsg) baseMsg;
|
||||
|
||||
Session session = SessionManager.getSession(origin);
|
||||
Session session = SessionManager.getSession(origin);
|
||||
|
||||
if (session == null)
|
||||
return true;
|
||||
if (session == null)
|
||||
return true;
|
||||
|
||||
PlayerCharacter player = origin.getPlayerCharacter();
|
||||
PlayerCharacter player = origin.getPlayerCharacter();
|
||||
|
||||
WorldGrid.RemoveWorldObject(player);
|
||||
Dispatch dispatch;
|
||||
WorldGrid.RemoveWorldObject(player);
|
||||
Dispatch dispatch;
|
||||
|
||||
if (player == null) {
|
||||
Logger.error("Unable to find player for session" + session.getSessionID());
|
||||
origin.kickToLogin(MBServerStatics.LOGINERROR_UNABLE_TO_LOGIN, "Player not found.");
|
||||
return true;
|
||||
}
|
||||
if (player == null) {
|
||||
Logger.error("Unable to find player for session" + session.getSessionID());
|
||||
origin.kickToLogin(MBServerStatics.LOGINERROR_UNABLE_TO_LOGIN, "Player not found.");
|
||||
return true;
|
||||
}
|
||||
|
||||
player.setEnteredWorld(false);
|
||||
player.setEnteredWorld(false);
|
||||
|
||||
Account acc = SessionManager.getAccount(origin);
|
||||
Account acc = SessionManager.getAccount(origin);
|
||||
|
||||
if (acc.status.ordinal() < WorldServer.worldAccessLevel.ordinal() || MBServerStatics.blockLogin) {
|
||||
origin.disconnect();
|
||||
return true;
|
||||
}
|
||||
|
||||
// Brand new character. Send the city select screen
|
||||
// Brand new character. Send the city select screen
|
||||
|
||||
if (player.getLevel() == 1 && player.getBindBuildingID() == -1) {
|
||||
SelectCityMsg scm = new SelectCityMsg(player, true);
|
||||
dispatch = Dispatch.borrow(player, scm);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
return true;
|
||||
}
|
||||
if (player.getLevel() == 1 && player.getBindBuildingID() == -1) {
|
||||
SelectCityMsg scm = new SelectCityMsg(player, true);
|
||||
dispatch = Dispatch.borrow(player, scm);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
return true;
|
||||
}
|
||||
|
||||
player.resetRegenUpdateTime();
|
||||
player.resetRegenUpdateTime();
|
||||
|
||||
// Map Data
|
||||
// Map Data
|
||||
|
||||
try {
|
||||
WorldDataMsg wdm = new WorldDataMsg();
|
||||
dispatch = Dispatch.borrow(player, wdm);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.PRIMARY);
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
Logger.error("WORLDDATAMESSAGE" + e.getMessage());
|
||||
}
|
||||
try {
|
||||
WorldDataMsg wdm = new WorldDataMsg();
|
||||
dispatch = Dispatch.borrow(player, wdm);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.PRIMARY);
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
Logger.error("WORLDDATAMESSAGE" + e.getMessage());
|
||||
}
|
||||
|
||||
// Realm Data
|
||||
// Realm Data
|
||||
|
||||
try {
|
||||
WorldRealmMsg wrm = new WorldRealmMsg();
|
||||
dispatch = Dispatch.borrow(player, wrm);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.PRIMARY);
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
Logger.error("REALMMESSAGE" + e.getMessage());
|
||||
}
|
||||
try {
|
||||
WorldRealmMsg wrm = new WorldRealmMsg();
|
||||
dispatch = Dispatch.borrow(player, wrm);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.PRIMARY);
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
Logger.error("REALMMESSAGE" + e.getMessage());
|
||||
}
|
||||
|
||||
// Object Data
|
||||
CityDataMsg wom = new CityDataMsg(session, true);
|
||||
dispatch = Dispatch.borrow(player, wom);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.PRIMARY);
|
||||
// Object Data
|
||||
CityDataMsg wom = new CityDataMsg(session, true);
|
||||
dispatch = Dispatch.borrow(player, wom);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.PRIMARY);
|
||||
|
||||
player.getTimestamps().put("EnterWorld", System.currentTimeMillis());
|
||||
player.getTimestamps().put("EnterWorld", System.currentTimeMillis());
|
||||
|
||||
if (player.getLoc().equals(Vector3fImmutable.ZERO) || System.currentTimeMillis() > player.getTimeStamp("logout") + (15 * 60 * 1000)) {
|
||||
player.stopMovement(player.getBindLoc());
|
||||
player.setSafeMode();
|
||||
player.updateLocation();
|
||||
player.setRegion(AbstractWorldObject.GetRegionByWorldObject(player));
|
||||
}
|
||||
if (player.getLoc().equals(Vector3fImmutable.ZERO) || System.currentTimeMillis() > player.getTimeStamp("logout") + (15 * 60 * 1000)) {
|
||||
player.stopMovement(player.getBindLoc());
|
||||
player.setSafeMode();
|
||||
player.updateLocation();
|
||||
player.setRegion(AbstractWorldObject.GetRegionByWorldObject(player));
|
||||
}
|
||||
|
||||
player.setTimeStamp("logout", 0);
|
||||
player.respawnLock.writeLock().lock();
|
||||
try{
|
||||
if (!player.isAlive()){
|
||||
Logger.info("respawning player on enter world.");
|
||||
player.respawn(true, true,true);
|
||||
}
|
||||
|
||||
}catch (Exception e){
|
||||
Logger.error(e);
|
||||
}finally{
|
||||
player.respawnLock.writeLock().unlock();
|
||||
}
|
||||
|
||||
player.setTimeStamp("logout", 0);
|
||||
player.respawnLock.writeLock().lock();
|
||||
try {
|
||||
if (!player.isAlive()) {
|
||||
Logger.info("respawning player on enter world.");
|
||||
player.respawn(true, true, true);
|
||||
}
|
||||
|
||||
player.resetDataAtLogin();
|
||||
} catch (Exception e) {
|
||||
Logger.error(e);
|
||||
} finally {
|
||||
player.respawnLock.writeLock().unlock();
|
||||
}
|
||||
|
||||
InterestManager.INTERESTMANAGER.HandleLoadForEnterWorld(player);
|
||||
|
||||
// If this is a brand new character...
|
||||
// when they enter world is a great time to write their
|
||||
// character record to the data warehouse.
|
||||
player.resetDataAtLogin();
|
||||
|
||||
if (player.getHash() == null) {
|
||||
InterestManager.INTERESTMANAGER.HandleLoadForEnterWorld(player);
|
||||
|
||||
if (DataWarehouse.recordExists(Enum.DataRecordType.CHARACTER, player.getObjectUUID()) == false) {
|
||||
CharacterRecord characterRecord = CharacterRecord.borrow(player);
|
||||
DataWarehouse.pushToWarehouse(characterRecord);
|
||||
}
|
||||
player.setHash();
|
||||
}
|
||||
// If this is a brand new character...
|
||||
// when they enter world is a great time to write their
|
||||
// character record to the data warehouse.
|
||||
|
||||
if (player.getHash() == null) {
|
||||
|
||||
if (DataWarehouse.recordExists(Enum.DataRecordType.CHARACTER, player.getObjectUUID()) == false) {
|
||||
CharacterRecord characterRecord = CharacterRecord.borrow(player);
|
||||
DataWarehouse.pushToWarehouse(characterRecord);
|
||||
}
|
||||
player.setHash();
|
||||
}
|
||||
|
||||
//
|
||||
// We will load the kill/death lists here as data is only pertinent
|
||||
// to characters actually logged into the game.
|
||||
// We will load the kill/death lists here as data is only pertinent
|
||||
// to characters actually logged into the game.
|
||||
//
|
||||
|
||||
player.pvpKills = PvpRecord.getCharacterPvPHistory(player.getObjectUUID(), Enum.PvpHistoryType.KILLS);
|
||||
player.pvpDeaths = PvpRecord.getCharacterPvPHistory(player.getObjectUUID(), Enum.PvpHistoryType.DEATHS);
|
||||
player.pvpKills = PvpRecord.getCharacterPvPHistory(player.getObjectUUID(), Enum.PvpHistoryType.KILLS);
|
||||
player.pvpDeaths = PvpRecord.getCharacterPvPHistory(player.getObjectUUID(), Enum.PvpHistoryType.DEATHS);
|
||||
|
||||
SendOwnPlayerMsg sopm = new SendOwnPlayerMsg(SessionManager.getSession(origin));
|
||||
dispatch = Dispatch.borrow(player, sopm);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.PRIMARY);
|
||||
SendOwnPlayerMsg sopm = new SendOwnPlayerMsg(SessionManager.getSession(origin));
|
||||
dispatch = Dispatch.borrow(player, sopm);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.PRIMARY);
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,30 +26,30 @@ import engine.objects.PlayerCharacter;
|
||||
|
||||
public class RequestGuildListHandler extends AbstractClientMsgHandler {
|
||||
|
||||
public RequestGuildListHandler() {
|
||||
super(ReqGuildListMsg.class);
|
||||
}
|
||||
public RequestGuildListHandler() {
|
||||
super(ReqGuildListMsg.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
Dispatch dispatch;
|
||||
|
||||
// get PlayerCharacter of person accepting invite
|
||||
PlayerCharacter pc = SessionManager.getPlayerCharacter(
|
||||
origin);
|
||||
if (pc == null)
|
||||
return true;
|
||||
|
||||
if (GuildStatusController.isGuildLeader(pc.getGuildStatus()) == false){
|
||||
ErrorPopupMsg.sendErrorMsg(pc, "You do not have such authority!");
|
||||
}
|
||||
SendGuildEntryMsg msg = new SendGuildEntryMsg(pc);
|
||||
// get PlayerCharacter of person accepting invite
|
||||
PlayerCharacter pc = SessionManager.getPlayerCharacter(
|
||||
origin);
|
||||
if (pc == null)
|
||||
return true;
|
||||
|
||||
if (GuildStatusController.isGuildLeader(pc.getGuildStatus()) == false) {
|
||||
ErrorPopupMsg.sendErrorMsg(pc, "You do not have such authority!");
|
||||
}
|
||||
SendGuildEntryMsg msg = new SendGuildEntryMsg(pc);
|
||||
|
||||
|
||||
dispatch = Dispatch.borrow(pc, msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -14,34 +14,33 @@ import engine.net.client.ClientConnection;
|
||||
import engine.net.client.msg.ClientNetMsg;
|
||||
import engine.net.client.msg.SendBallEntryMessage;
|
||||
import engine.objects.PlayerCharacter;
|
||||
|
||||
public class SendBallEntryHandler extends AbstractClientMsgHandler {
|
||||
|
||||
public SendBallEntryHandler() {
|
||||
super(SendBallEntryMessage.class);
|
||||
}
|
||||
public SendBallEntryHandler() {
|
||||
super(SendBallEntryMessage.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg,
|
||||
ClientConnection origin) throws MsgSendException {
|
||||
|
||||
PlayerCharacter player = origin.getPlayerCharacter();
|
||||
|
||||
if (player == null)
|
||||
return true;
|
||||
|
||||
public static void HandleAddBall(PlayerCharacter player, SendBallEntryMessage msg) {
|
||||
//currently not handled.
|
||||
|
||||
SendBallEntryMessage msg = (SendBallEntryMessage)baseMsg;
|
||||
|
||||
HandleAddBall(player,msg);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg,
|
||||
ClientConnection origin) throws MsgSendException {
|
||||
|
||||
PlayerCharacter player = origin.getPlayerCharacter();
|
||||
|
||||
if (player == null)
|
||||
return true;
|
||||
|
||||
|
||||
SendBallEntryMessage msg = (SendBallEntryMessage) baseMsg;
|
||||
|
||||
HandleAddBall(player, msg);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public static void HandleAddBall(PlayerCharacter player, SendBallEntryMessage msg){
|
||||
//currently not handled.
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -55,20 +55,20 @@ public class SwearInGuildHandler extends AbstractClientMsgHandler {
|
||||
targetGuild = (Guild) DbManager.getObject(GameObjectType.Guild, swearInMsg.getGuildUUID());
|
||||
|
||||
if (targetGuild == null) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "A Serious error has occured. Please post details for to ensure transaction integrity");
|
||||
ErrorPopupMsg.sendErrorMsg(player, "A Serious error has occured. Please post details for to ensure transaction integrity");
|
||||
return true;
|
||||
}
|
||||
|
||||
nation = player.getGuild();
|
||||
|
||||
if (nation == null) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "You do not belong to a guild!");
|
||||
ErrorPopupMsg.sendErrorMsg(player, "You do not belong to a guild!");
|
||||
return true;
|
||||
}
|
||||
|
||||
try {
|
||||
if (!nation.isNation()) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Your guild is not a nation!");
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Your guild is not a nation!");
|
||||
return true;
|
||||
}
|
||||
if (!nation.getSubGuildList().contains(targetGuild)) {
|
||||
@@ -81,7 +81,7 @@ public class SwearInGuildHandler extends AbstractClientMsgHandler {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (GuildStatusController.isGuildLeader(player.getGuildStatus()) == false){
|
||||
if (GuildStatusController.isGuildLeader(player.getGuildStatus()) == false) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Your do not have such authority!");
|
||||
return true;
|
||||
}
|
||||
@@ -114,7 +114,7 @@ public class SwearInGuildHandler extends AbstractClientMsgHandler {
|
||||
dispatch = Dispatch.borrow(player, msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
|
||||
City.lastCityUpdate = System.currentTimeMillis();
|
||||
City.lastCityUpdate = System.currentTimeMillis();
|
||||
|
||||
ArrayList<PlayerCharacter> guildMembers = SessionManager.getActivePCsInGuildID(nation.getObjectUUID());
|
||||
|
||||
@@ -128,7 +128,7 @@ public class SwearInGuildHandler extends AbstractClientMsgHandler {
|
||||
ChatManager.chatGuildInfo(member, "Your Guild has sword fealty to " + nation.getName() + '.');
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Logger.error( e.getMessage());
|
||||
Logger.error(e.getMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
// www.magicbane.com
|
||||
|
||||
|
||||
|
||||
package engine.net.client.handlers;
|
||||
|
||||
import engine.Enum;
|
||||
@@ -27,53 +26,53 @@ import engine.objects.PlayerCharacter;
|
||||
|
||||
public class SwearInHandler extends AbstractClientMsgHandler {
|
||||
|
||||
public SwearInHandler() {
|
||||
super(SwearInMsg.class);
|
||||
}
|
||||
public SwearInHandler() {
|
||||
super(SwearInMsg.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
SwearInMsg msg = (SwearInMsg) baseMsg;
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
SwearInMsg msg = (SwearInMsg) baseMsg;
|
||||
Dispatch dispatch;
|
||||
|
||||
// get source player
|
||||
PlayerCharacter source = SessionManager.getPlayerCharacter(origin);
|
||||
// get source player
|
||||
PlayerCharacter source = SessionManager.getPlayerCharacter(origin);
|
||||
|
||||
if (source == null)
|
||||
return true;
|
||||
if (source == null)
|
||||
return true;
|
||||
|
||||
// get target player
|
||||
PlayerCharacter target = SessionManager.getPlayerCharacterByID(msg.getTargetID());
|
||||
// get target player
|
||||
PlayerCharacter target = SessionManager.getPlayerCharacterByID(msg.getTargetID());
|
||||
|
||||
if (target == null) {
|
||||
ChatManager.chatGuildError(source,
|
||||
"No such character found!");
|
||||
return true;
|
||||
}
|
||||
if (target == null) {
|
||||
ChatManager.chatGuildError(source,
|
||||
"No such character found!");
|
||||
return true;
|
||||
}
|
||||
|
||||
if(source.getGuild() != target.getGuild()) {
|
||||
ChatManager.chatGuildError(source,
|
||||
"That player is not a member of " + source.getGuild().getName());
|
||||
return true;
|
||||
}
|
||||
if (source.getGuild() != target.getGuild()) {
|
||||
ChatManager.chatGuildError(source,
|
||||
"That player is not a member of " + source.getGuild().getName());
|
||||
return true;
|
||||
}
|
||||
|
||||
// Verify source has authority to swear in
|
||||
if (GuildStatusController.isInnerCouncil(source.getGuildStatus()) == false) {
|
||||
ErrorPopupMsg.sendErrorMsg(source, "Your do not have such authority!");
|
||||
return true;
|
||||
}
|
||||
// Verify source has authority to swear in
|
||||
if (GuildStatusController.isInnerCouncil(source.getGuildStatus()) == false) {
|
||||
ErrorPopupMsg.sendErrorMsg(source, "Your do not have such authority!");
|
||||
return true;
|
||||
}
|
||||
|
||||
// Swear target in and send message to guild
|
||||
target.setFullMember(true);
|
||||
target.incVer();
|
||||
// Swear target in and send message to guild
|
||||
target.setFullMember(true);
|
||||
target.incVer();
|
||||
|
||||
ChatManager.chatGuildInfo(source,target.getFirstName() + " has been sworn in as a full member!");
|
||||
ChatManager.chatGuildInfo(source, target.getFirstName() + " has been sworn in as a full member!");
|
||||
|
||||
dispatch = Dispatch.borrow(source, new GuildListMsg(source.getGuild()));
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
DispatchMessage.sendToAllInRange(target, new GuildInfoMsg(target, target.getGuild(), 2));
|
||||
DispatchMessage.sendToAllInRange(target, new GuildInfoMsg(target, target.getGuild(), 2));
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,89 +20,68 @@ import engine.objects.*;
|
||||
*/
|
||||
public class TaxCityMsgHandler extends AbstractClientMsgHandler {
|
||||
|
||||
public TaxCityMsgHandler() {
|
||||
super(TaxCityMsg.class);
|
||||
}
|
||||
public TaxCityMsgHandler() {
|
||||
super(TaxCityMsg.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
private static boolean ViewTaxes(TaxCityMsg msg, PlayerCharacter player) {
|
||||
|
||||
// Member variable declaration
|
||||
// Member variable declaration
|
||||
Building building = BuildingManager.getBuildingFromCache(msg.getGuildID());
|
||||
Guild playerGuild = player.getGuild();
|
||||
|
||||
PlayerCharacter player;
|
||||
TaxCityMsg msg;
|
||||
if (building == null) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Not a valid Building!");
|
||||
return true;
|
||||
}
|
||||
|
||||
player = origin.getPlayerCharacter();
|
||||
City city = building.getCity();
|
||||
if (city == null) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "This building does not belong to a city.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (city.getWarehouse() == null) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "This city does not have a warehouse!");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
msg = (TaxCityMsg) baseMsg;
|
||||
if (playerGuild == null || playerGuild.isEmptyGuild()) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "You must belong to a guild to do that!");
|
||||
return true;
|
||||
}
|
||||
|
||||
ViewTaxes(msg,player);
|
||||
if (playerGuild.getOwnedCity() == null) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Your Guild needs to own a city!");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (playerGuild.getOwnedCity().getWarehouse() == null) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Your Guild needs to own a warehouse!");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
private static boolean ViewTaxes(TaxCityMsg msg, PlayerCharacter player) {
|
||||
|
||||
// Member variable declaration
|
||||
Building building = BuildingManager.getBuildingFromCache(msg.getGuildID());
|
||||
Guild playerGuild = player.getGuild();
|
||||
|
||||
if (building == null){
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Not a valid Building!");
|
||||
return true;
|
||||
}
|
||||
|
||||
City city = building.getCity();
|
||||
if (city == null){
|
||||
ErrorPopupMsg.sendErrorMsg(player, "This building does not belong to a city.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (city.getWarehouse() == null){
|
||||
ErrorPopupMsg.sendErrorMsg(player, "This city does not have a warehouse!");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if (playerGuild == null || playerGuild.isEmptyGuild()){
|
||||
ErrorPopupMsg.sendErrorMsg(player, "You must belong to a guild to do that!");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (playerGuild.getOwnedCity() == null){
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Your Guild needs to own a city!");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (playerGuild.getOwnedCity().getWarehouse() == null){
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Your Guild needs to own a warehouse!");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (playerGuild.getOwnedCity().getTOL() == null){
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Cannot find Tree of Life for your city!");
|
||||
return true;
|
||||
}
|
||||
if (playerGuild.getOwnedCity().getTOL() == null) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Cannot find Tree of Life for your city!");
|
||||
return true;
|
||||
}
|
||||
|
||||
// if (playerGuild.getOwnedCity().getTOL().getRank() != 8){
|
||||
// ErrorPopupMsg.sendErrorMsg(player, "Your City needs to Own a realm!");
|
||||
// return true;
|
||||
// }
|
||||
|
||||
if (playerGuild.getOwnedCity().getRealm() == null){
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Cannot find realm for your city!");
|
||||
return true;
|
||||
}
|
||||
Realm targetRealm = RealmMap.getRealmForCity(city);
|
||||
if (playerGuild.getOwnedCity().getRealm() == null) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Cannot find realm for your city!");
|
||||
return true;
|
||||
}
|
||||
Realm targetRealm = RealmMap.getRealmForCity(city);
|
||||
|
||||
if (targetRealm == null){
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Cannot find realm for city you are attempting to tax!");
|
||||
return true;
|
||||
}
|
||||
if (targetRealm == null) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Cannot find realm for city you are attempting to tax!");
|
||||
return true;
|
||||
}
|
||||
|
||||
// if (targetRealm.getRulingCity() == null){
|
||||
// ErrorPopupMsg.sendErrorMsg(player, "Realm Does not have a ruling city!");
|
||||
@@ -120,35 +99,48 @@ public class TaxCityMsgHandler extends AbstractClientMsgHandler {
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
if (!GuildStatusController.isTaxCollector(player.getGuildStatus())){
|
||||
ErrorPopupMsg.sendErrorMsg(player, "You Must be a tax Collector!");
|
||||
return true;
|
||||
}
|
||||
if (!GuildStatusController.isTaxCollector(player.getGuildStatus())) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "You Must be a tax Collector!");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// if (!city.isAfterTaxPeriod(DateTime.now(), player))
|
||||
// return true;
|
||||
|
||||
|
||||
|
||||
ViewResourcesMessage vrm = new ViewResourcesMessage(player);
|
||||
vrm.setGuild(building.getGuild());
|
||||
vrm.setWarehouseBuilding(BuildingManager.getBuildingFromCache(building.getCity().getWarehouse().getBuildingUID()));
|
||||
vrm.configure();
|
||||
Dispatch dispatch = Dispatch.borrow(player, msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
dispatch = Dispatch.borrow(player, vrm);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
return true;
|
||||
ViewResourcesMessage vrm = new ViewResourcesMessage(player);
|
||||
vrm.setGuild(building.getGuild());
|
||||
vrm.setWarehouseBuilding(BuildingManager.getBuildingFromCache(building.getCity().getWarehouse().getBuildingUID()));
|
||||
vrm.configure();
|
||||
Dispatch dispatch = Dispatch.borrow(player, msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
dispatch = Dispatch.borrow(player, vrm);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
return true;
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
|
||||
// Member variable declaration
|
||||
|
||||
PlayerCharacter player;
|
||||
TaxCityMsg msg;
|
||||
|
||||
player = origin.getPlayerCharacter();
|
||||
|
||||
|
||||
msg = (TaxCityMsg) baseMsg;
|
||||
|
||||
ViewTaxes(msg, player);
|
||||
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -17,57 +17,56 @@ import engine.objects.PlayerCharacter;
|
||||
*/
|
||||
public class TaxResourcesMsgHandler extends AbstractClientMsgHandler {
|
||||
|
||||
public TaxResourcesMsgHandler() {
|
||||
super(TaxResourcesMsg.class);
|
||||
}
|
||||
public TaxResourcesMsgHandler() {
|
||||
super(TaxResourcesMsg.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
private static boolean TaxWarehouse(TaxResourcesMsg msg, PlayerCharacter player) {
|
||||
|
||||
// Member variable declaration
|
||||
|
||||
PlayerCharacter player;
|
||||
TaxResourcesMsg msg;
|
||||
|
||||
player = origin.getPlayerCharacter();
|
||||
if (player == null)
|
||||
return true;
|
||||
// Member variable declaration
|
||||
Building building = BuildingManager.getBuildingFromCache(msg.getBuildingID());
|
||||
|
||||
|
||||
msg = (TaxResourcesMsg) baseMsg;
|
||||
if (building == null) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Not a valid Building!");
|
||||
return true;
|
||||
}
|
||||
|
||||
TaxWarehouse(msg,player);
|
||||
City city = building.getCity();
|
||||
if (city == null) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "This building does not belong to a city.");
|
||||
return true;
|
||||
}
|
||||
|
||||
city.TaxWarehouse(msg, player);
|
||||
|
||||
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
private static boolean TaxWarehouse(TaxResourcesMsg msg, PlayerCharacter player) {
|
||||
|
||||
// Member variable declaration
|
||||
Building building = BuildingManager.getBuildingFromCache(msg.getBuildingID());
|
||||
return true;
|
||||
|
||||
|
||||
if (building == null){
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Not a valid Building!");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
City city = building.getCity();
|
||||
if (city == null){
|
||||
ErrorPopupMsg.sendErrorMsg(player, "This building does not belong to a city.");
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
|
||||
city.TaxWarehouse(msg, player);
|
||||
// Member variable declaration
|
||||
|
||||
PlayerCharacter player;
|
||||
TaxResourcesMsg msg;
|
||||
|
||||
player = origin.getPlayerCharacter();
|
||||
if (player == null)
|
||||
return true;
|
||||
|
||||
|
||||
return true;
|
||||
msg = (TaxResourcesMsg) baseMsg;
|
||||
|
||||
TaxWarehouse(msg, player);
|
||||
|
||||
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -28,21 +28,21 @@ public class ToggleGroupSplitHandler extends AbstractClientMsgHandler {
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg,
|
||||
ClientConnection origin) throws MsgSendException {
|
||||
ClientConnection origin) throws MsgSendException {
|
||||
|
||||
// Member variable declaration
|
||||
|
||||
|
||||
PlayerCharacter source;
|
||||
Group group;
|
||||
boolean split;
|
||||
|
||||
|
||||
source = SessionManager.getPlayerCharacter(origin);
|
||||
|
||||
|
||||
if (source == null)
|
||||
return false;
|
||||
|
||||
group = GroupManager.getGroup(source);
|
||||
|
||||
|
||||
if (group == null)
|
||||
return false;
|
||||
|
||||
@@ -59,10 +59,10 @@ public class ToggleGroupSplitHandler extends AbstractClientMsgHandler {
|
||||
group.sendUpdate(gum);
|
||||
|
||||
// Send split message
|
||||
|
||||
|
||||
if (split)
|
||||
ChatManager.chatGroupInfo(source, "Treasure is now being split.");
|
||||
else
|
||||
else
|
||||
ChatManager.chatGroupInfo(source, "Treasure is no longer being split.");
|
||||
|
||||
return false;
|
||||
|
||||
@@ -20,80 +20,80 @@ import engine.objects.PlayerCharacter;
|
||||
|
||||
public class TransferAssetMsgHandler extends AbstractClientMsgHandler {
|
||||
|
||||
public TransferAssetMsgHandler() {
|
||||
super(TransferAssetMsg.class);
|
||||
}
|
||||
public TransferAssetMsgHandler() {
|
||||
super(TransferAssetMsg.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
|
||||
TransferAssetMsg transferAssetMsg = (TransferAssetMsg) baseMsg;
|
||||
TransferAssetMsg transferAssetMsg = (TransferAssetMsg) baseMsg;
|
||||
|
||||
int Buildingid = transferAssetMsg.getObjectID();
|
||||
int BuildingType = transferAssetMsg.getObjectType(); //ToDue Later
|
||||
int TargetID = transferAssetMsg.getTargetID();
|
||||
int TargetType = transferAssetMsg.getTargetType(); //ToDue later
|
||||
int Buildingid = transferAssetMsg.getObjectID();
|
||||
int BuildingType = transferAssetMsg.getObjectType(); //ToDue Later
|
||||
int TargetID = transferAssetMsg.getTargetID();
|
||||
int TargetType = transferAssetMsg.getTargetType(); //ToDue later
|
||||
|
||||
Building building = BuildingManager.getBuildingFromCache(Buildingid);
|
||||
PlayerCharacter newOwner = PlayerCharacter.getFromCache(TargetID);
|
||||
PlayerCharacter player = origin.getPlayerCharacter();
|
||||
Building building = BuildingManager.getBuildingFromCache(Buildingid);
|
||||
PlayerCharacter newOwner = PlayerCharacter.getFromCache(TargetID);
|
||||
PlayerCharacter player = origin.getPlayerCharacter();
|
||||
|
||||
if (player == null || building == null || newOwner == null)
|
||||
return true;
|
||||
if (player == null || building == null || newOwner == null)
|
||||
return true;
|
||||
|
||||
Blueprint blueprint = building.getBlueprint();
|
||||
Blueprint blueprint = building.getBlueprint();
|
||||
|
||||
if (blueprint == null)
|
||||
return true;
|
||||
if (blueprint == null)
|
||||
return true;
|
||||
|
||||
if (building.getBlueprint().getBuildingGroup() == Enum.BuildingGroup.MINE) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "You cannot transfer a mine!");
|
||||
return true;
|
||||
}
|
||||
if (building.getBlueprint().getBuildingGroup() == Enum.BuildingGroup.MINE) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "You cannot transfer a mine!");
|
||||
return true;
|
||||
}
|
||||
|
||||
// Players cannot transfer shrines
|
||||
// Players cannot transfer shrines
|
||||
|
||||
if ((building.getBlueprint().getBuildingGroup() == Enum.BuildingGroup.SHRINE)) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Cannot for to transfer shrine!");
|
||||
return true;
|
||||
}
|
||||
if ((building.getBlueprint().getBuildingGroup() == Enum.BuildingGroup.SHRINE)) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Cannot for to transfer shrine!");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Blueprint.isMeshWallPiece(building.getBlueprintUUID())) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Cannot for to transfer fortress asset!");
|
||||
return true;
|
||||
}
|
||||
if (Blueprint.isMeshWallPiece(building.getBlueprintUUID())) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Cannot for to transfer fortress asset!");
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((building.getBlueprint().getBuildingGroup() == Enum.BuildingGroup.BARRACK)) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Cannot for to transfer fortress asset!");
|
||||
return true;
|
||||
}
|
||||
if ((building.getBlueprint().getBuildingGroup() == Enum.BuildingGroup.BARRACK)) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Cannot for to transfer fortress asset!");
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((building.getBlueprint().getBuildingGroup() == Enum.BuildingGroup.BULWARK)) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Cannot for to transfer siege asset!");
|
||||
return true;
|
||||
}
|
||||
if ((building.getBlueprint().getBuildingGroup() == Enum.BuildingGroup.BULWARK)) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Cannot for to transfer siege asset!");
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((building.getBlueprint().getBuildingGroup() == Enum.BuildingGroup.SIEGETENT)) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Cannot for to transfer siege asset!");
|
||||
return true;
|
||||
}
|
||||
if ((building.getBlueprint().getBuildingGroup() == Enum.BuildingGroup.SIEGETENT)) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Cannot for to transfer siege asset!");
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((building.getBlueprint().getBuildingGroup() == Enum.BuildingGroup.BANESTONE)) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Cannot for to transfer banestone!");
|
||||
return true;
|
||||
}
|
||||
if (building.getOwnerUUID() != player.getObjectUUID()) {
|
||||
ChatManager.chatSystemError(player, "You do not own this asset.");
|
||||
return true;
|
||||
}
|
||||
if ((building.getBlueprint().getBuildingGroup() == Enum.BuildingGroup.BANESTONE)) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Cannot for to transfer banestone!");
|
||||
return true;
|
||||
}
|
||||
if (building.getOwnerUUID() != player.getObjectUUID()) {
|
||||
ChatManager.chatSystemError(player, "You do not own this asset.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (building.getOwnerUUID() == newOwner.getObjectUUID()) {
|
||||
ChatManager.chatSystemError(player, "You already own this asset.");
|
||||
return true;
|
||||
}
|
||||
if (building.getOwnerUUID() == newOwner.getObjectUUID()) {
|
||||
ChatManager.chatSystemError(player, "You already own this asset.");
|
||||
return true;
|
||||
}
|
||||
|
||||
building.setOwner(newOwner);
|
||||
return true;
|
||||
}
|
||||
building.setOwner(newOwner);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -26,90 +26,90 @@ import org.pmw.tinylog.Logger;
|
||||
|
||||
public class TransferGoldToFromBuildingMsgHandler extends AbstractClientMsgHandler {
|
||||
|
||||
public TransferGoldToFromBuildingMsgHandler() {
|
||||
super(TransferGoldToFromBuildingMsg.class);
|
||||
}
|
||||
public TransferGoldToFromBuildingMsgHandler() {
|
||||
super(TransferGoldToFromBuildingMsg.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
|
||||
PlayerCharacter player;
|
||||
Building building;
|
||||
CharacterItemManager itemMan;
|
||||
Item goldItem;
|
||||
TransferGoldToFromBuildingMsg msg;
|
||||
Dispatch dispatch;
|
||||
PlayerCharacter player;
|
||||
Building building;
|
||||
CharacterItemManager itemMan;
|
||||
Item goldItem;
|
||||
TransferGoldToFromBuildingMsg msg;
|
||||
Dispatch dispatch;
|
||||
|
||||
player = SessionManager.getPlayerCharacter(origin);
|
||||
player = SessionManager.getPlayerCharacter(origin);
|
||||
|
||||
if (player == null)
|
||||
return true;
|
||||
if (player == null)
|
||||
return true;
|
||||
|
||||
msg = (TransferGoldToFromBuildingMsg) baseMsg;
|
||||
msg = (TransferGoldToFromBuildingMsg) baseMsg;
|
||||
|
||||
building = BuildingManager.getBuildingFromCache(msg.getObjectID());
|
||||
building = BuildingManager.getBuildingFromCache(msg.getObjectID());
|
||||
|
||||
if (building == null)
|
||||
return true;
|
||||
if (building == null)
|
||||
return true;
|
||||
|
||||
if (msg.getDirection() == 2){
|
||||
if (msg.getDirection() == 2) {
|
||||
|
||||
if(!ManageCityAssetMsgHandler.playerCanManageNotFriends(player, building))
|
||||
return true;
|
||||
if (building.setReserve(msg.getUnknown01(),player)){
|
||||
dispatch = Dispatch.borrow(player, msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
if (!ManageCityAssetMsgHandler.playerCanManageNotFriends(player, building))
|
||||
return true;
|
||||
if (building.setReserve(msg.getUnknown01(), player)) {
|
||||
dispatch = Dispatch.borrow(player, msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
}
|
||||
|
||||
// if (building.getTimeStamp(MBServerStatics.STRONGBOX_DELAY_STRING) > System.currentTimeMillis()){
|
||||
// ErrorPopupMsg.sendErrorMsg(player, MBServerStatics.STRONGBOX_DELAY_OUTPUT);
|
||||
// return true;
|
||||
// }
|
||||
return true;
|
||||
}
|
||||
|
||||
//building.getTimestamps().put(MBServerStatics.STRONGBOX_DELAY_STRING, System.currentTimeMillis() + MBServerStatics.ONE_MINUTE);
|
||||
// if (building.getTimeStamp(MBServerStatics.STRONGBOX_DELAY_STRING) > System.currentTimeMillis()){
|
||||
// ErrorPopupMsg.sendErrorMsg(player, MBServerStatics.STRONGBOX_DELAY_OUTPUT);
|
||||
// return true;
|
||||
// }
|
||||
|
||||
itemMan = player.getCharItemManager();
|
||||
//building.getTimestamps().put(MBServerStatics.STRONGBOX_DELAY_STRING, System.currentTimeMillis() + MBServerStatics.ONE_MINUTE);
|
||||
|
||||
goldItem = itemMan.getGoldInventory();
|
||||
itemMan = player.getCharItemManager();
|
||||
|
||||
if (goldItem == null) {
|
||||
Logger.error("Could not access gold item");
|
||||
return true;
|
||||
}
|
||||
goldItem = itemMan.getGoldInventory();
|
||||
|
||||
if (goldItem == null) {
|
||||
Logger.error("Could not access gold item");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// Update in-game gold values for player and building
|
||||
// Update in-game gold values for player and building
|
||||
|
||||
|
||||
try {
|
||||
try {
|
||||
|
||||
|
||||
if (!itemMan.transferGoldToFromBuilding(msg.getAmount(), building))
|
||||
return true;
|
||||
if (!itemMan.transferGoldToFromBuilding(msg.getAmount(), building))
|
||||
return true;
|
||||
|
||||
|
||||
UpdateGoldMsg ugm = new UpdateGoldMsg(player);
|
||||
ugm.configure();
|
||||
dispatch = Dispatch.borrow(player, ugm);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
UpdateGoldMsg ugm = new UpdateGoldMsg(player);
|
||||
ugm.configure();
|
||||
dispatch = Dispatch.borrow(player, ugm);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
|
||||
// Refresh the player's inventory if it's currently open
|
||||
// Refresh the player's inventory if it's currently open
|
||||
|
||||
// Refresh the tree's window to update strongbox
|
||||
// Refresh the tree's window to update strongbox
|
||||
|
||||
|
||||
msg.setAmount(building.getStrongboxValue());
|
||||
dispatch = Dispatch.borrow(player, msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
msg.setAmount(building.getStrongboxValue());
|
||||
dispatch = Dispatch.borrow(player, msg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
|
||||
} catch (Exception e) {
|
||||
PlaceAssetMsg.sendPlaceAssetError(player.getClientConnection(), 1, "A Serious error has occurred. Please post details for to ensure transaction integrity");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
PlaceAssetMsg.sendPlaceAssetError(player.getClientConnection(), 1, "A Serious error has occurred. Please post details for to ensure transaction integrity");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -26,59 +26,58 @@ import java.util.HashSet;
|
||||
|
||||
public class UpdateFriendStatusHandler extends AbstractClientMsgHandler {
|
||||
|
||||
public UpdateFriendStatusHandler() {
|
||||
super(UpdateFriendStatusMessage.class);
|
||||
}
|
||||
public UpdateFriendStatusHandler() {
|
||||
super(UpdateFriendStatusMessage.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg,
|
||||
ClientConnection origin) throws MsgSendException {
|
||||
|
||||
PlayerCharacter player = origin.getPlayerCharacter();
|
||||
|
||||
if (player == null)
|
||||
return true;
|
||||
|
||||
//change to Request
|
||||
public static void HandleUpdateFriend(PlayerCharacter player, UpdateFriendStatusMessage msg) {
|
||||
FriendStatus friendStatus = FriendStatus.Available;
|
||||
|
||||
UpdateFriendStatusMessage msg = (UpdateFriendStatusMessage)baseMsg;
|
||||
|
||||
|
||||
HandleUpdateFriend(player,msg);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
try {
|
||||
friendStatus = FriendStatus.values()[msg.statusType];
|
||||
} catch (Exception e) {
|
||||
Logger.error(e);
|
||||
}
|
||||
player.friendStatus = friendStatus;
|
||||
SendUpdateToFriends(player);
|
||||
}
|
||||
|
||||
//change to Request
|
||||
public static void HandleUpdateFriend(PlayerCharacter player, UpdateFriendStatusMessage msg){
|
||||
FriendStatus friendStatus = FriendStatus.Available;
|
||||
|
||||
try {
|
||||
friendStatus = FriendStatus.values()[msg.statusType];
|
||||
}catch (Exception e){
|
||||
Logger.error(e);
|
||||
}
|
||||
player.friendStatus = friendStatus;
|
||||
SendUpdateToFriends(player);
|
||||
}
|
||||
|
||||
public static void SendUpdateToFriends(PlayerCharacter player){
|
||||
|
||||
HashSet<Integer> friends = PlayerFriends.PlayerFriendsMap.get(player.getObjectUUID());
|
||||
|
||||
if (friends == null)
|
||||
return;
|
||||
|
||||
UpdateFriendStatusMessage outMsg = new UpdateFriendStatusMessage(player);
|
||||
|
||||
for (int friendID : friends){
|
||||
PlayerCharacter playerFriend = SessionManager.getPlayerCharacterByID(friendID);
|
||||
if (playerFriend == null)
|
||||
return;
|
||||
Dispatch dispatch = Dispatch.borrow(playerFriend, outMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
public static void SendUpdateToFriends(PlayerCharacter player) {
|
||||
|
||||
HashSet<Integer> friends = PlayerFriends.PlayerFriendsMap.get(player.getObjectUUID());
|
||||
|
||||
if (friends == null)
|
||||
return;
|
||||
|
||||
UpdateFriendStatusMessage outMsg = new UpdateFriendStatusMessage(player);
|
||||
|
||||
for (int friendID : friends) {
|
||||
PlayerCharacter playerFriend = SessionManager.getPlayerCharacterByID(friendID);
|
||||
if (playerFriend == null)
|
||||
return;
|
||||
Dispatch dispatch = Dispatch.borrow(playerFriend, outMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, DispatchChannel.SECONDARY);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg,
|
||||
ClientConnection origin) throws MsgSendException {
|
||||
|
||||
PlayerCharacter player = origin.getPlayerCharacter();
|
||||
|
||||
if (player == null)
|
||||
return true;
|
||||
|
||||
|
||||
UpdateFriendStatusMessage msg = (UpdateFriendStatusMessage) baseMsg;
|
||||
|
||||
|
||||
HandleUpdateFriend(player, msg);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,130 +25,129 @@ import static engine.net.client.msg.ErrorPopupMsg.sendErrorPopup;
|
||||
*/
|
||||
public class UpgradeAssetMsgHandler extends AbstractClientMsgHandler {
|
||||
|
||||
// Constructor
|
||||
public UpgradeAssetMsgHandler() {
|
||||
// Constructor
|
||||
public UpgradeAssetMsgHandler() {
|
||||
|
||||
super(UpgradeAssetMessage.class);
|
||||
}
|
||||
super(UpgradeAssetMessage.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
@Override
|
||||
protected boolean _handleNetMsg(ClientNetMsg baseMsg, ClientConnection origin) throws MsgSendException {
|
||||
|
||||
// Member variable declaration
|
||||
// Member variable declaration
|
||||
|
||||
UpgradeAssetMessage msg;
|
||||
ManageCityAssetsMsg outMsg;
|
||||
PlayerCharacter player;
|
||||
int buildingUUID;
|
||||
Building buildingToRank;
|
||||
LocalDateTime dateToUpgrade;
|
||||
int nextRank;
|
||||
int rankCost;
|
||||
Dispatch dispatch;
|
||||
UpgradeAssetMessage msg;
|
||||
ManageCityAssetsMsg outMsg;
|
||||
PlayerCharacter player;
|
||||
int buildingUUID;
|
||||
Building buildingToRank;
|
||||
LocalDateTime dateToUpgrade;
|
||||
int nextRank;
|
||||
int rankCost;
|
||||
Dispatch dispatch;
|
||||
|
||||
// Assign member variables
|
||||
// Assign member variables
|
||||
|
||||
msg = (UpgradeAssetMessage) baseMsg;
|
||||
msg = (UpgradeAssetMessage) baseMsg;
|
||||
|
||||
// Grab pointer to the requesting player
|
||||
// Grab pointer to the requesting player
|
||||
|
||||
player = SessionManager.getPlayerCharacter(origin);
|
||||
player = SessionManager.getPlayerCharacter(origin);
|
||||
|
||||
// Grab pointer to the building from the cache
|
||||
// Grab pointer to the building from the cache
|
||||
|
||||
buildingUUID = msg.getBuildingUUID();
|
||||
buildingUUID = msg.getBuildingUUID();
|
||||
|
||||
buildingToRank = (Building) DbManager.getObject(GameObjectType.Building, buildingUUID);
|
||||
buildingToRank = (Building) DbManager.getObject(GameObjectType.Building, buildingUUID);
|
||||
|
||||
// Early exit if building not in cache.
|
||||
// Early exit if building not in cache.
|
||||
|
||||
if (buildingToRank == null) {
|
||||
Logger.error("Attempt to upgrade null building by " + player.getName());
|
||||
return true;
|
||||
}
|
||||
if (buildingToRank == null) {
|
||||
Logger.error("Attempt to upgrade null building by " + player.getName());
|
||||
return true;
|
||||
}
|
||||
|
||||
// Early exit for building that is already ranking
|
||||
// Early exit for building that is already ranking
|
||||
|
||||
if (buildingToRank.isRanking()) {
|
||||
Logger.error("Attempt to upgrade a building already ranking by " + player.getName());
|
||||
return true;
|
||||
}
|
||||
if (buildingToRank.isRanking()) {
|
||||
Logger.error("Attempt to upgrade a building already ranking by " + player.getName());
|
||||
return true;
|
||||
}
|
||||
|
||||
// Calculate and set time/cost to upgrade
|
||||
// Calculate and set time/cost to upgrade
|
||||
|
||||
nextRank = (buildingToRank.getRank() + 1);
|
||||
nextRank = (buildingToRank.getRank() + 1);
|
||||
|
||||
if (buildingToRank.getBlueprint() == null)
|
||||
return true;
|
||||
if (buildingToRank.getBlueprint().getMaxRank() < nextRank || nextRank == 8){
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Building is already at it's Max rank.");
|
||||
return true;
|
||||
}
|
||||
if (buildingToRank.getBlueprint() == null)
|
||||
return true;
|
||||
if (buildingToRank.getBlueprint().getMaxRank() < nextRank || nextRank == 8) {
|
||||
ErrorPopupMsg.sendErrorMsg(player, "Building is already at it's Max rank.");
|
||||
return true;
|
||||
}
|
||||
|
||||
rankCost = buildingToRank.getBlueprint().getRankCost(nextRank);
|
||||
rankCost = buildingToRank.getBlueprint().getRankCost(nextRank);
|
||||
|
||||
// SEND NOT ENOUGH GOLD ERROR
|
||||
// SEND NOT ENOUGH GOLD ERROR
|
||||
|
||||
if (!buildingToRank.hasFunds(rankCost)){
|
||||
ErrorPopupMsg.sendErrorPopup(player, 127); // Not enough gold in strongbox
|
||||
return true;
|
||||
}
|
||||
if (!buildingToRank.hasFunds(rankCost)) {
|
||||
ErrorPopupMsg.sendErrorPopup(player, 127); // Not enough gold in strongbox
|
||||
return true;
|
||||
}
|
||||
|
||||
if (rankCost > buildingToRank.getStrongboxValue()) {
|
||||
sendErrorPopup(player, 127);
|
||||
return true;
|
||||
}
|
||||
if (rankCost > buildingToRank.getStrongboxValue()) {
|
||||
sendErrorPopup(player, 127);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Validation appears good. Let's now process the upgrade
|
||||
|
||||
try {
|
||||
if (buildingToRank.getCity() != null){
|
||||
buildingToRank.getCity().transactionLock.writeLock().lock();
|
||||
try{
|
||||
if (!buildingToRank.transferGold(-rankCost,false)) {
|
||||
sendErrorPopup(player, 127);
|
||||
return true;
|
||||
}
|
||||
}catch(Exception e){
|
||||
Logger.error(e);
|
||||
}finally{
|
||||
buildingToRank.getCity().transactionLock.writeLock().unlock();
|
||||
}
|
||||
}else
|
||||
if (!buildingToRank.transferGold(-rankCost,false)) {
|
||||
sendErrorPopup(player, 127);
|
||||
return true;
|
||||
}
|
||||
// Validation appears good. Let's now process the upgrade
|
||||
|
||||
dateToUpgrade = LocalDateTime.now().plusHours(buildingToRank.getBlueprint().getRankTime(nextRank));
|
||||
try {
|
||||
if (buildingToRank.getCity() != null) {
|
||||
buildingToRank.getCity().transactionLock.writeLock().lock();
|
||||
try {
|
||||
if (!buildingToRank.transferGold(-rankCost, false)) {
|
||||
sendErrorPopup(player, 127);
|
||||
return true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Logger.error(e);
|
||||
} finally {
|
||||
buildingToRank.getCity().transactionLock.writeLock().unlock();
|
||||
}
|
||||
} else if (!buildingToRank.transferGold(-rankCost, false)) {
|
||||
sendErrorPopup(player, 127);
|
||||
return true;
|
||||
}
|
||||
|
||||
BuildingManager.setUpgradeDateTime(buildingToRank, dateToUpgrade, 0);
|
||||
dateToUpgrade = LocalDateTime.now().plusHours(buildingToRank.getBlueprint().getRankTime(nextRank));
|
||||
|
||||
// Schedule upgrade job
|
||||
BuildingManager.setUpgradeDateTime(buildingToRank, dateToUpgrade, 0);
|
||||
|
||||
BuildingManager.submitUpgradeJob(buildingToRank);
|
||||
// Schedule upgrade job
|
||||
|
||||
// Refresh the client's manage asset window
|
||||
// *** Refactor : We have some of these unknowns
|
||||
BuildingManager.submitUpgradeJob(buildingToRank);
|
||||
|
||||
outMsg = new ManageCityAssetsMsg(player, buildingToRank);
|
||||
// Refresh the client's manage asset window
|
||||
// *** Refactor : We have some of these unknowns
|
||||
|
||||
// Action TYPE
|
||||
outMsg.actionType = 3;
|
||||
outMsg.setTargetType(buildingToRank.getObjectType().ordinal());
|
||||
outMsg.setTargetID(buildingToRank.getObjectUUID());
|
||||
outMsg.setTargetType3(buildingToRank.getObjectType().ordinal());
|
||||
outMsg.setTargetID3(buildingToRank.getObjectUUID());
|
||||
outMsg.setAssetName1(buildingToRank.getName());
|
||||
outMsg.setUnknown54(1);
|
||||
outMsg = new ManageCityAssetsMsg(player, buildingToRank);
|
||||
|
||||
dispatch = Dispatch.borrow(player, outMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
// Action TYPE
|
||||
outMsg.actionType = 3;
|
||||
outMsg.setTargetType(buildingToRank.getObjectType().ordinal());
|
||||
outMsg.setTargetID(buildingToRank.getObjectUUID());
|
||||
outMsg.setTargetType3(buildingToRank.getObjectType().ordinal());
|
||||
outMsg.setTargetID3(buildingToRank.getObjectUUID());
|
||||
outMsg.setAssetName1(buildingToRank.getName());
|
||||
outMsg.setUnknown54(1);
|
||||
|
||||
} catch (Exception e) {
|
||||
PlaceAssetMsg.sendPlaceAssetError(player.getClientConnection(), 1, "A Serious error has occurred. Please post details for to ensure transaction integrity");
|
||||
}
|
||||
dispatch = Dispatch.borrow(player, outMsg);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
|
||||
return true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
PlaceAssetMsg.sendPlaceAssetError(player.getClientConnection(), 1, "A Serious error has occurred. Please post details for to ensure transaction integrity");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ public class AbandonAssetMsg extends ClientNetMsg {
|
||||
* past the limit) then this constructor Throws that Exception to the
|
||||
* caller.
|
||||
*/
|
||||
public AbandonAssetMsg(AbstractConnection origin, ByteBufferReader reader){
|
||||
public AbandonAssetMsg(AbstractConnection origin, ByteBufferReader reader) {
|
||||
super(Protocol.ABANDONASSET, origin, reader);
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ public class AbandonAssetMsg extends ClientNetMsg {
|
||||
* Deserializes the subclass specific items from the supplied NetMsgReader.
|
||||
*/
|
||||
@Override
|
||||
protected void _deserialize(ByteBufferReader reader) {
|
||||
protected void _deserialize(ByteBufferReader reader) {
|
||||
this.pad = reader.getInt();
|
||||
this.objectType = reader.getInt();
|
||||
this.objectUUID = reader.getInt();
|
||||
@@ -60,10 +60,6 @@ public class AbandonAssetMsg extends ClientNetMsg {
|
||||
this.objectType = value;
|
||||
}
|
||||
|
||||
public void setPad(int value) {
|
||||
this.pad = value;
|
||||
}
|
||||
|
||||
public int getUUID() {
|
||||
return objectUUID;
|
||||
|
||||
@@ -72,4 +68,8 @@ public class AbandonAssetMsg extends ClientNetMsg {
|
||||
public int getPad() {
|
||||
return pad;
|
||||
}
|
||||
|
||||
public void setPad(int value) {
|
||||
this.pad = value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,51 +15,50 @@ import engine.objects.PlayerCharacter;
|
||||
|
||||
public class AcceptFriendMsg extends ClientNetMsg {
|
||||
|
||||
public String sourceName;
|
||||
public String friendName;
|
||||
public String sourceName;
|
||||
public String friendName;
|
||||
|
||||
/**
|
||||
* This is the general purpose constructor.
|
||||
*/
|
||||
public AcceptFriendMsg(PlayerCharacter pc) {
|
||||
super(Protocol.FRIENDACCEPT);
|
||||
}
|
||||
/**
|
||||
* This is the general purpose constructor.
|
||||
*/
|
||||
public AcceptFriendMsg(PlayerCharacter pc) {
|
||||
super(Protocol.FRIENDACCEPT);
|
||||
}
|
||||
|
||||
/**
|
||||
* This constructor is used by NetMsgFactory. It attempts to deserialize the
|
||||
* ByteBuffer into a message. If a BufferUnderflow occurs (based on reading
|
||||
* past the limit) then this constructor Throws that Exception to the
|
||||
* caller.
|
||||
*/
|
||||
public AcceptFriendMsg(AbstractConnection origin, ByteBufferReader reader) {
|
||||
super(Protocol.FRIENDACCEPT, origin, reader);
|
||||
}
|
||||
/**
|
||||
* This constructor is used by NetMsgFactory. It attempts to deserialize the
|
||||
* ByteBuffer into a message. If a BufferUnderflow occurs (based on reading
|
||||
* past the limit) then this constructor Throws that Exception to the
|
||||
* caller.
|
||||
*/
|
||||
public AcceptFriendMsg(AbstractConnection origin, ByteBufferReader reader) {
|
||||
super(Protocol.FRIENDACCEPT, origin, reader);
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy constructor
|
||||
*/
|
||||
public AcceptFriendMsg(AcceptFriendMsg msg) {
|
||||
super(Protocol.FRIENDACCEPT);
|
||||
}
|
||||
/**
|
||||
* Copy constructor
|
||||
*/
|
||||
public AcceptFriendMsg(AcceptFriendMsg msg) {
|
||||
super(Protocol.FRIENDACCEPT);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Deserializes the subclass specific items from the supplied ByteBufferReader.
|
||||
*/
|
||||
@Override
|
||||
protected void _deserialize(ByteBufferReader reader) {
|
||||
//Do we even want to try this?
|
||||
this.sourceName = reader.getString(); //This is source name.. this friends list must never been updated since launch, not using IDS.
|
||||
this.friendName = reader.getString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Serializes the subclass specific items to the supplied ByteBufferWriter.
|
||||
*/
|
||||
@Override
|
||||
protected void _serialize(ByteBufferWriter writer) {
|
||||
writer.putString(this.sourceName);
|
||||
writer.putString(this.friendName);
|
||||
}
|
||||
/**
|
||||
* Deserializes the subclass specific items from the supplied ByteBufferReader.
|
||||
*/
|
||||
@Override
|
||||
protected void _deserialize(ByteBufferReader reader) {
|
||||
//Do we even want to try this?
|
||||
this.sourceName = reader.getString(); //This is source name.. this friends list must never been updated since launch, not using IDS.
|
||||
this.friendName = reader.getString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Serializes the subclass specific items to the supplied ByteBufferWriter.
|
||||
*/
|
||||
@Override
|
||||
protected void _serialize(ByteBufferWriter writer) {
|
||||
writer.putString(this.sourceName);
|
||||
writer.putString(this.friendName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ public class AcceptTradeRequestMsg extends ClientNetMsg {
|
||||
private int playerID;
|
||||
private int targetType;
|
||||
private int targetID;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This is the general purpose constructor
|
||||
@@ -38,9 +38,9 @@ public class AcceptTradeRequestMsg extends ClientNetMsg {
|
||||
super(Protocol.REQUESTTRADEOK);
|
||||
this.unknown01 = unknown01;
|
||||
this.playerType = player.getObjectType().ordinal();
|
||||
this.playerID =player.getObjectUUID();
|
||||
this.playerID = player.getObjectUUID();
|
||||
this.targetType = target.getObjectType().ordinal();
|
||||
this.targetID =target.getObjectUUID();
|
||||
this.targetID = target.getObjectUUID();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -49,8 +49,7 @@ public class AcceptTradeRequestMsg extends ClientNetMsg {
|
||||
* past the limit) then this constructor Throws that Exception to the
|
||||
* caller.
|
||||
*/
|
||||
public AcceptTradeRequestMsg(AbstractConnection origin, ByteBufferReader reader)
|
||||
{
|
||||
public AcceptTradeRequestMsg(AbstractConnection origin, ByteBufferReader reader) {
|
||||
super(Protocol.REQUESTTRADEOK, origin, reader);
|
||||
}
|
||||
|
||||
@@ -58,14 +57,13 @@ public class AcceptTradeRequestMsg extends ClientNetMsg {
|
||||
* Deserializes the subclass specific items to the supplied NetMsgWriter.
|
||||
*/
|
||||
@Override
|
||||
protected void _deserialize(ByteBufferReader reader)
|
||||
{
|
||||
protected void _deserialize(ByteBufferReader reader) {
|
||||
unknown01 = reader.getInt();
|
||||
playerType = reader.getInt();
|
||||
playerID = reader.getInt();
|
||||
targetType = reader.getInt();
|
||||
targetID = reader.getInt();
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -95,39 +93,37 @@ public class AcceptTradeRequestMsg extends ClientNetMsg {
|
||||
this.unknown01 = unknown01;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public int getPlayerType() {
|
||||
return playerType;
|
||||
}
|
||||
public int getPlayerType() {
|
||||
return playerType;
|
||||
}
|
||||
|
||||
public void setPlayerType(int playerType) {
|
||||
this.playerType = playerType;
|
||||
}
|
||||
public void setPlayerType(int playerType) {
|
||||
this.playerType = playerType;
|
||||
}
|
||||
|
||||
public int getPlayerID() {
|
||||
return playerID;
|
||||
}
|
||||
public int getPlayerID() {
|
||||
return playerID;
|
||||
}
|
||||
|
||||
public void setPlayerID(int playerID) {
|
||||
this.playerID = playerID;
|
||||
}
|
||||
public void setPlayerID(int playerID) {
|
||||
this.playerID = playerID;
|
||||
}
|
||||
|
||||
public int getTargetType() {
|
||||
return targetType;
|
||||
}
|
||||
public int getTargetType() {
|
||||
return targetType;
|
||||
}
|
||||
|
||||
public void setTargetType(int targetType) {
|
||||
this.targetType = targetType;
|
||||
}
|
||||
public void setTargetType(int targetType) {
|
||||
this.targetType = targetType;
|
||||
}
|
||||
|
||||
public int getTargetID() {
|
||||
return targetID;
|
||||
}
|
||||
public int getTargetID() {
|
||||
return targetID;
|
||||
}
|
||||
|
||||
public void setTargetID(int targetID) {
|
||||
this.targetID = targetID;
|
||||
}
|
||||
public void setTargetID(int targetID) {
|
||||
this.targetID = targetID;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,9 +24,9 @@ import engine.objects.PlayerCharacter;
|
||||
*/
|
||||
public class AckBankWindowOpenedMsg extends ClientNetMsg {
|
||||
|
||||
private int playerType;
|
||||
private int playerID;
|
||||
private long unknown01; // possibly NPC ID?
|
||||
private int playerType;
|
||||
private int playerID;
|
||||
private long unknown01; // possibly NPC ID?
|
||||
private long unknown02;
|
||||
|
||||
/**
|
||||
@@ -46,7 +46,7 @@ public class AckBankWindowOpenedMsg extends ClientNetMsg {
|
||||
* past the limit) then this constructor Throws that Exception to the
|
||||
* caller.
|
||||
*/
|
||||
public AckBankWindowOpenedMsg(AbstractConnection origin, ByteBufferReader reader) {
|
||||
public AckBankWindowOpenedMsg(AbstractConnection origin, ByteBufferReader reader) {
|
||||
super(Protocol.COSTTOOPENBANK, origin, reader);
|
||||
}
|
||||
|
||||
@@ -54,9 +54,9 @@ public class AckBankWindowOpenedMsg extends ClientNetMsg {
|
||||
* Deserializes the subclass specific items to the supplied NetMsgWriter.
|
||||
*/
|
||||
@Override
|
||||
protected void _deserialize(ByteBufferReader reader) {
|
||||
playerType = reader.getInt();
|
||||
playerID = reader.getInt();
|
||||
protected void _deserialize(ByteBufferReader reader) {
|
||||
playerType = reader.getInt();
|
||||
playerID = reader.getInt();
|
||||
unknown01 = reader.getLong();
|
||||
unknown02 = reader.getLong();
|
||||
}
|
||||
@@ -66,25 +66,26 @@ public class AckBankWindowOpenedMsg extends ClientNetMsg {
|
||||
*/
|
||||
@Override
|
||||
protected void _serialize(ByteBufferWriter writer) throws SerializationException {
|
||||
writer.putInt(playerType);
|
||||
writer.putInt(playerID);
|
||||
writer.putInt(playerType);
|
||||
writer.putInt(playerID);
|
||||
writer.putLong(unknown01);
|
||||
writer.putLong(unknown02);
|
||||
}
|
||||
|
||||
public int getPlayerID() {
|
||||
return playerID;
|
||||
}
|
||||
return playerID;
|
||||
}
|
||||
|
||||
public void setPlayerID(int playerID) {
|
||||
this.playerID = playerID;
|
||||
}
|
||||
public void setPlayerID(int playerID) {
|
||||
this.playerID = playerID;
|
||||
}
|
||||
|
||||
public int getPlayerType() {
|
||||
return playerType;
|
||||
}
|
||||
public int getPlayerType() {
|
||||
return playerType;
|
||||
}
|
||||
|
||||
public void setPlayerType(int playerType) {
|
||||
this.playerType = playerType;
|
||||
}
|
||||
public void setPlayerType(int playerType) {
|
||||
this.playerType = playerType;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -39,7 +39,6 @@ public class ActivateNPCMessage extends ClientNetMsg {
|
||||
|
||||
/**
|
||||
* This is the general purpose constructor.
|
||||
*
|
||||
*/
|
||||
public ActivateNPCMessage(ArrayList<Item> items) {
|
||||
super(Protocol.ACTIVATENPC);
|
||||
@@ -54,7 +53,7 @@ public class ActivateNPCMessage extends ClientNetMsg {
|
||||
* past the limit) then this constructor Throws that Exception to the
|
||||
* caller.
|
||||
*/
|
||||
public ActivateNPCMessage(AbstractConnection origin, ByteBufferReader reader) {
|
||||
public ActivateNPCMessage(AbstractConnection origin, ByteBufferReader reader) {
|
||||
super(Protocol.ACTIVATENPC, origin, reader);
|
||||
}
|
||||
|
||||
@@ -77,9 +76,9 @@ public class ActivateNPCMessage extends ClientNetMsg {
|
||||
}
|
||||
writer.putInt(this.size);
|
||||
for (Item item : this.ItemList) {
|
||||
writer.putInt(item.getObjectType().ordinal());
|
||||
writer.putInt(item.getObjectUUID());
|
||||
|
||||
writer.putInt(item.getObjectType().ordinal());
|
||||
writer.putInt(item.getObjectUUID());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,7 +86,7 @@ public class ActivateNPCMessage extends ClientNetMsg {
|
||||
* Deserializes the subclass specific items from the supplied NetMsgReader.
|
||||
*/
|
||||
@Override
|
||||
protected void _deserialize(ByteBufferReader reader) {
|
||||
protected void _deserialize(ByteBufferReader reader) {
|
||||
unknown01 = reader.getInt();
|
||||
unknown02 = reader.getInt();
|
||||
reader.getInt(); // Object Type Padding
|
||||
@@ -108,50 +107,50 @@ public class ActivateNPCMessage extends ClientNetMsg {
|
||||
return unknown01;
|
||||
}
|
||||
|
||||
public int getUnknown02() {
|
||||
return unknown02;
|
||||
}
|
||||
|
||||
public int getUnknown03() {
|
||||
return unknown03;
|
||||
}
|
||||
|
||||
public int getContractItem() {
|
||||
return contractItem;
|
||||
}
|
||||
|
||||
public int getUnknown05() {
|
||||
return unknown05;
|
||||
}
|
||||
|
||||
public int buildingUUID() {
|
||||
return buildingUUID;
|
||||
}
|
||||
|
||||
public void setUnknown01(int unknown01) {
|
||||
this.unknown01 = unknown01;
|
||||
}
|
||||
|
||||
public void setSize(int size) {
|
||||
this.size = size;
|
||||
public int getUnknown02() {
|
||||
return unknown02;
|
||||
}
|
||||
|
||||
public void setUnknown02(int unknown02) {
|
||||
this.unknown02 = unknown02;
|
||||
}
|
||||
|
||||
public int getUnknown03() {
|
||||
return unknown03;
|
||||
}
|
||||
|
||||
public void setUnknown03(int unknown03) {
|
||||
this.unknown03 = unknown03;
|
||||
}
|
||||
|
||||
public int getContractItem() {
|
||||
return contractItem;
|
||||
}
|
||||
|
||||
public void setContractItem(int contractItem) {
|
||||
this.contractItem = contractItem;
|
||||
}
|
||||
|
||||
public int getUnknown05() {
|
||||
return unknown05;
|
||||
}
|
||||
|
||||
public void setUnknown05(int unknown05) {
|
||||
this.unknown05 = unknown05;
|
||||
}
|
||||
|
||||
public int buildingUUID() {
|
||||
return buildingUUID;
|
||||
}
|
||||
|
||||
public void setSize(int size) {
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
public void setItemList(ArrayList<Item> value) {
|
||||
this.ItemList = value;
|
||||
}
|
||||
|
||||
@@ -16,52 +16,51 @@ import engine.objects.PlayerCharacter;
|
||||
|
||||
public class AddFriendMessage extends ClientNetMsg {
|
||||
|
||||
public PlayerCharacter friend;
|
||||
public PlayerCharacter friend;
|
||||
|
||||
/**
|
||||
* This is the general purpose constructor.
|
||||
*/
|
||||
public AddFriendMessage(PlayerCharacter pc) {
|
||||
super(Protocol.ADDFRIEND);
|
||||
friend = pc;
|
||||
}
|
||||
/**
|
||||
* This is the general purpose constructor.
|
||||
*/
|
||||
public AddFriendMessage(PlayerCharacter pc) {
|
||||
super(Protocol.ADDFRIEND);
|
||||
friend = pc;
|
||||
}
|
||||
|
||||
/**
|
||||
* This constructor is used by NetMsgFactory. It attempts to deserialize the
|
||||
* ByteBuffer into a message. If a BufferUnderflow occurs (based on reading
|
||||
* past the limit) then this constructor Throws that Exception to the
|
||||
* caller.
|
||||
*/
|
||||
public AddFriendMessage(AbstractConnection origin, ByteBufferReader reader) {
|
||||
super(Protocol.ADDFRIEND, origin, reader);
|
||||
}
|
||||
/**
|
||||
* This constructor is used by NetMsgFactory. It attempts to deserialize the
|
||||
* ByteBuffer into a message. If a BufferUnderflow occurs (based on reading
|
||||
* past the limit) then this constructor Throws that Exception to the
|
||||
* caller.
|
||||
*/
|
||||
public AddFriendMessage(AbstractConnection origin, ByteBufferReader reader) {
|
||||
super(Protocol.ADDFRIEND, origin, reader);
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy constructor
|
||||
*/
|
||||
public AddFriendMessage(AddFriendMessage msg) {
|
||||
super(Protocol.ADDFRIEND);
|
||||
}
|
||||
/**
|
||||
* Copy constructor
|
||||
*/
|
||||
public AddFriendMessage(AddFriendMessage msg) {
|
||||
super(Protocol.ADDFRIEND);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Deserializes the subclass specific items from the supplied ByteBufferReader.
|
||||
*/
|
||||
//message is serialize only, no need for deserialize.
|
||||
@Override
|
||||
protected void _deserialize(ByteBufferReader reader) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Serializes the subclass specific items to the supplied ByteBufferWriter.
|
||||
*/
|
||||
@Override
|
||||
protected void _serialize(ByteBufferWriter writer) {
|
||||
writer.putInt(GameObjectType.PlayerCharacter.ordinal());
|
||||
writer.putInt(friend.getObjectUUID());
|
||||
writer.putString(friend.getName());
|
||||
writer.putInt(0); //possibly available, busy, away?
|
||||
writer.putInt(0);
|
||||
}
|
||||
/**
|
||||
* Deserializes the subclass specific items from the supplied ByteBufferReader.
|
||||
*/
|
||||
//message is serialize only, no need for deserialize.
|
||||
@Override
|
||||
protected void _deserialize(ByteBufferReader reader) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Serializes the subclass specific items to the supplied ByteBufferWriter.
|
||||
*/
|
||||
@Override
|
||||
protected void _serialize(ByteBufferWriter writer) {
|
||||
writer.putInt(GameObjectType.PlayerCharacter.ordinal());
|
||||
writer.putInt(friend.getObjectUUID());
|
||||
writer.putString(friend.getName());
|
||||
writer.putInt(0); //possibly available, busy, away?
|
||||
writer.putInt(0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,8 +39,7 @@ public class AddGoldToTradeWindowMsg extends ClientNetMsg {
|
||||
* past the limit) then this constructor Throws that Exception to the
|
||||
* caller.
|
||||
*/
|
||||
public AddGoldToTradeWindowMsg(AbstractConnection origin, ByteBufferReader reader)
|
||||
{
|
||||
public AddGoldToTradeWindowMsg(AbstractConnection origin, ByteBufferReader reader) {
|
||||
super(Protocol.TRADEADDGOLD, origin, reader);
|
||||
}
|
||||
|
||||
@@ -48,8 +47,7 @@ public class AddGoldToTradeWindowMsg extends ClientNetMsg {
|
||||
* Deserializes the subclass specific items to the supplied NetMsgWriter.
|
||||
*/
|
||||
@Override
|
||||
protected void _deserialize(ByteBufferReader reader)
|
||||
{
|
||||
protected void _deserialize(ByteBufferReader reader) {
|
||||
unknown01 = reader.getInt();
|
||||
playerCompID = reader.getLong();
|
||||
amount = reader.getInt();
|
||||
|
||||
@@ -24,7 +24,7 @@ public class AddItemToTradeWindowMsg extends ClientNetMsg {
|
||||
private int playerID;
|
||||
private int itemID;
|
||||
private int itemType;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This is the general purpose constructor
|
||||
@@ -44,8 +44,7 @@ public class AddItemToTradeWindowMsg extends ClientNetMsg {
|
||||
* past the limit) then this constructor Throws that Exception to the
|
||||
* caller.
|
||||
*/
|
||||
public AddItemToTradeWindowMsg(AbstractConnection origin, ByteBufferReader reader)
|
||||
{
|
||||
public AddItemToTradeWindowMsg(AbstractConnection origin, ByteBufferReader reader) {
|
||||
super(Protocol.TRADEADDOBJECT, origin, reader);
|
||||
}
|
||||
|
||||
@@ -53,8 +52,7 @@ public class AddItemToTradeWindowMsg extends ClientNetMsg {
|
||||
* Deserializes the subclass specific items to the supplied NetMsgWriter.
|
||||
*/
|
||||
@Override
|
||||
protected void _deserialize(ByteBufferReader reader)
|
||||
{
|
||||
protected void _deserialize(ByteBufferReader reader) {
|
||||
unknown01 = reader.getInt();
|
||||
playerType = reader.getInt();
|
||||
playerID = reader.getInt();
|
||||
@@ -89,32 +87,29 @@ public class AddItemToTradeWindowMsg extends ClientNetMsg {
|
||||
this.unknown01 = unknown01;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public int getPlayerType() {
|
||||
return playerType;
|
||||
}
|
||||
|
||||
public int getPlayerType() {
|
||||
return playerType;
|
||||
}
|
||||
public void setPlayerType(int playerType) {
|
||||
this.playerType = playerType;
|
||||
}
|
||||
|
||||
public void setPlayerType(int playerType) {
|
||||
this.playerType = playerType;
|
||||
}
|
||||
public int getPlayerID() {
|
||||
return playerID;
|
||||
}
|
||||
|
||||
public int getPlayerID() {
|
||||
return playerID;
|
||||
}
|
||||
public void setPlayerID(int playerID) {
|
||||
this.playerID = playerID;
|
||||
}
|
||||
|
||||
public void setPlayerID(int playerID) {
|
||||
this.playerID = playerID;
|
||||
}
|
||||
public int getItemID() {
|
||||
return itemID;
|
||||
}
|
||||
|
||||
public int getItemID() {
|
||||
return itemID;
|
||||
}
|
||||
|
||||
public void setItemID(int itemID) {
|
||||
this.itemID = itemID;
|
||||
}
|
||||
public void setItemID(int itemID) {
|
||||
this.itemID = itemID;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,127 +18,123 @@ import engine.net.client.Protocol;
|
||||
import engine.objects.PlayerCharacter;
|
||||
|
||||
|
||||
|
||||
public class AllianceChangeMsg extends ClientNetMsg {
|
||||
public final static int MAKE_ENEMY = 4;
|
||||
public final static int MAKE_ALLY = 6;
|
||||
public final static int REMOVE = 7;
|
||||
public final static byte INFO_SUCCESS = 0;
|
||||
public final static byte ERROR_NOT_RECOMMENDED = 1;
|
||||
public final static byte ERROR_NOT_SAME_GUILD = 2;
|
||||
public final static byte ERROR_NOT_AUTHORIZED = 4;
|
||||
public final static byte ERROR_NOT_SAME_FACTION = 7;
|
||||
public final static byte ERROR_TOO_MANY = 13;
|
||||
public final static byte ERROR_TO0_EARLY = 14;
|
||||
private byte msgType;
|
||||
private int sourceGuildID;
|
||||
private int targetGuildID;
|
||||
private int secondsToWait;
|
||||
private boolean ally;
|
||||
public final static int MAKE_ENEMY = 4;
|
||||
public final static int MAKE_ALLY = 6;
|
||||
public final static int REMOVE = 7;
|
||||
public final static byte INFO_SUCCESS = 0;
|
||||
public final static byte ERROR_NOT_RECOMMENDED = 1;
|
||||
public final static byte ERROR_NOT_SAME_GUILD = 2;
|
||||
public final static byte ERROR_NOT_AUTHORIZED = 4;
|
||||
public final static byte ERROR_NOT_SAME_FACTION = 7;
|
||||
public final static byte ERROR_TOO_MANY = 13;
|
||||
public final static byte ERROR_TO0_EARLY = 14;
|
||||
private byte msgType;
|
||||
private int sourceGuildID;
|
||||
private int targetGuildID;
|
||||
private int secondsToWait;
|
||||
private boolean ally;
|
||||
|
||||
|
||||
public AllianceChangeMsg(PlayerCharacter player, int sourceGuildID,int targetGuildID, byte msgType, int secondsToWait) {
|
||||
super(Protocol.ALLIANCECHANGE);
|
||||
this.sourceGuildID = sourceGuildID;
|
||||
this.targetGuildID = targetGuildID;
|
||||
this.msgType = msgType;
|
||||
this.secondsToWait = secondsToWait;
|
||||
public AllianceChangeMsg(PlayerCharacter player, int sourceGuildID, int targetGuildID, byte msgType, int secondsToWait) {
|
||||
super(Protocol.ALLIANCECHANGE);
|
||||
this.sourceGuildID = sourceGuildID;
|
||||
this.targetGuildID = targetGuildID;
|
||||
this.msgType = msgType;
|
||||
this.secondsToWait = secondsToWait;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public AllianceChangeMsg() {
|
||||
super(Protocol.ALLIANCECHANGE);
|
||||
}
|
||||
public AllianceChangeMsg() {
|
||||
super(Protocol.ALLIANCECHANGE);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This constructor is used by NetMsgFactory. It attempts to deserialize the
|
||||
* ByteBuffer into a message. If a BufferUnderflow occurs (based on reading
|
||||
* past the limit) then this constructor Throws that Exception to the
|
||||
* caller.
|
||||
*/
|
||||
public AllianceChangeMsg(AbstractConnection origin, ByteBufferReader reader) {
|
||||
super(Protocol.ALLIANCECHANGE, origin, reader);
|
||||
}
|
||||
//CALL THIS AFTER SANITY CHECKS AND BEFORE UPDATING HEALTH/GOLD.
|
||||
/**
|
||||
* This constructor is used by NetMsgFactory. It attempts to deserialize the
|
||||
* ByteBuffer into a message. If a BufferUnderflow occurs (based on reading
|
||||
* past the limit) then this constructor Throws that Exception to the
|
||||
* caller.
|
||||
*/
|
||||
public AllianceChangeMsg(AbstractConnection origin, ByteBufferReader reader) {
|
||||
super(Protocol.ALLIANCECHANGE, origin, reader);
|
||||
}
|
||||
//CALL THIS AFTER SANITY CHECKS AND BEFORE UPDATING HEALTH/GOLD.
|
||||
|
||||
|
||||
/**
|
||||
* Deserializes the subclass specific items from the supplied NetMsgReader.
|
||||
*/
|
||||
@Override
|
||||
protected void _deserialize(ByteBufferReader reader) {
|
||||
this.msgType = reader.get();
|
||||
/**
|
||||
* Deserializes the subclass specific items from the supplied NetMsgReader.
|
||||
*/
|
||||
@Override
|
||||
protected void _deserialize(ByteBufferReader reader) {
|
||||
this.msgType = reader.get();
|
||||
|
||||
switch (this.msgType){
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
case MAKE_ENEMY:
|
||||
case MAKE_ALLY:
|
||||
case REMOVE:
|
||||
case 5:
|
||||
reader.getInt(); //source guild type;
|
||||
this.sourceGuildID = reader.getInt();
|
||||
reader.getInt();
|
||||
this.targetGuildID = reader.getInt();
|
||||
break;
|
||||
switch (this.msgType) {
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
case MAKE_ENEMY:
|
||||
case MAKE_ALLY:
|
||||
case REMOVE:
|
||||
case 5:
|
||||
reader.getInt(); //source guild type;
|
||||
this.sourceGuildID = reader.getInt();
|
||||
reader.getInt();
|
||||
this.targetGuildID = reader.getInt();
|
||||
break;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
// Precache and configure this message before we serialize it
|
||||
|
||||
|
||||
// Precache and configure this message before we serialize it
|
||||
/**
|
||||
* Serializes the subclass specific items to the supplied NetMsgWriter.
|
||||
*/
|
||||
@Override
|
||||
protected void _serialize(ByteBufferWriter writer) throws SerializationException {
|
||||
writer.put(this.msgType);
|
||||
if (this.msgType == ERROR_TO0_EARLY)
|
||||
writer.putInt(this.secondsToWait);
|
||||
writer.putInt(GameObjectType.Guild.ordinal());
|
||||
writer.putInt(this.sourceGuildID);
|
||||
writer.putInt(GameObjectType.Guild.ordinal());
|
||||
writer.putInt(this.targetGuildID);
|
||||
|
||||
|
||||
/**
|
||||
* Serializes the subclass specific items to the supplied NetMsgWriter.
|
||||
*/
|
||||
@Override
|
||||
protected void _serialize(ByteBufferWriter writer) throws SerializationException {
|
||||
writer.put(this.msgType);
|
||||
if (this.msgType == ERROR_TO0_EARLY)
|
||||
writer.putInt(this.secondsToWait);
|
||||
writer.putInt(GameObjectType.Guild.ordinal());
|
||||
writer.putInt(this.sourceGuildID);
|
||||
writer.putInt(GameObjectType.Guild.ordinal());
|
||||
writer.putInt(this.targetGuildID);
|
||||
}
|
||||
|
||||
|
||||
public int getSecondsToWait() {
|
||||
return secondsToWait;
|
||||
}
|
||||
|
||||
}
|
||||
public void setSecondsToWait(int secondsToWait) {
|
||||
this.secondsToWait = secondsToWait;
|
||||
}
|
||||
|
||||
public int getMsgType() {
|
||||
return msgType;
|
||||
}
|
||||
|
||||
public int getSecondsToWait() {
|
||||
return secondsToWait;
|
||||
}
|
||||
public void setMsgType(byte msgType) {
|
||||
this.msgType = msgType;
|
||||
}
|
||||
|
||||
public void setSecondsToWait(int secondsToWait) {
|
||||
this.secondsToWait = secondsToWait;
|
||||
}
|
||||
public int getSourceGuildID() {
|
||||
return sourceGuildID;
|
||||
}
|
||||
|
||||
public int getMsgType() {
|
||||
return msgType;
|
||||
}
|
||||
public int getTargetGuildID() {
|
||||
return targetGuildID;
|
||||
}
|
||||
|
||||
public int getSourceGuildID() {
|
||||
return sourceGuildID;
|
||||
}
|
||||
|
||||
public int getTargetGuildID() {
|
||||
return targetGuildID;
|
||||
}
|
||||
|
||||
public boolean isAlly() {
|
||||
return ally;
|
||||
}
|
||||
|
||||
public void setMsgType(byte msgType) {
|
||||
this.msgType = msgType;
|
||||
}
|
||||
public boolean isAlly() {
|
||||
return ally;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,102 +21,101 @@ import engine.objects.GuildTag;
|
||||
import engine.objects.PlayerCharacter;
|
||||
|
||||
|
||||
|
||||
public class AllyEnemyListMsg extends ClientNetMsg {
|
||||
|
||||
|
||||
private int guildID;
|
||||
private int guildID;
|
||||
|
||||
|
||||
public AllyEnemyListMsg(PlayerCharacter player) {
|
||||
super(Protocol.ALLYENEMYLIST);
|
||||
this.guildID = player.getGuildUUID();
|
||||
public AllyEnemyListMsg(PlayerCharacter player) {
|
||||
super(Protocol.ALLYENEMYLIST);
|
||||
this.guildID = player.getGuildUUID();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public AllyEnemyListMsg() {
|
||||
super(Protocol.ALLYENEMYLIST);
|
||||
}
|
||||
public AllyEnemyListMsg() {
|
||||
super(Protocol.ALLYENEMYLIST);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This constructor is used by NetMsgFactory. It attempts to deserialize the
|
||||
* ByteBuffer into a message. If a BufferUnderflow occurs (based on reading
|
||||
* past the limit) then this constructor Throws that Exception to the
|
||||
* caller.
|
||||
*/
|
||||
public AllyEnemyListMsg(AbstractConnection origin, ByteBufferReader reader) {
|
||||
super(Protocol.ALLYENEMYLIST, origin, reader);
|
||||
}
|
||||
//CALL THIS AFTER SANITY CHECKS AND BEFORE UPDATING HEALTH/GOLD.
|
||||
/**
|
||||
* This constructor is used by NetMsgFactory. It attempts to deserialize the
|
||||
* ByteBuffer into a message. If a BufferUnderflow occurs (based on reading
|
||||
* past the limit) then this constructor Throws that Exception to the
|
||||
* caller.
|
||||
*/
|
||||
public AllyEnemyListMsg(AbstractConnection origin, ByteBufferReader reader) {
|
||||
super(Protocol.ALLYENEMYLIST, origin, reader);
|
||||
}
|
||||
//CALL THIS AFTER SANITY CHECKS AND BEFORE UPDATING HEALTH/GOLD.
|
||||
|
||||
|
||||
/**
|
||||
* Deserializes the subclass specific items from the supplied NetMsgReader.
|
||||
*/
|
||||
@Override
|
||||
protected void _deserialize(ByteBufferReader reader) {
|
||||
reader.getInt();
|
||||
this.guildID = reader.getInt();
|
||||
}
|
||||
/**
|
||||
* Deserializes the subclass specific items from the supplied NetMsgReader.
|
||||
*/
|
||||
@Override
|
||||
protected void _deserialize(ByteBufferReader reader) {
|
||||
reader.getInt();
|
||||
this.guildID = reader.getInt();
|
||||
}
|
||||
|
||||
|
||||
// Precache and configure this message before we serialize it
|
||||
// Precache and configure this message before we serialize it
|
||||
|
||||
|
||||
/**
|
||||
* Serializes the subclass specific items to the supplied NetMsgWriter.
|
||||
*/
|
||||
@Override
|
||||
protected void _serialize(ByteBufferWriter writer) throws SerializationException {
|
||||
/**
|
||||
* Serializes the subclass specific items to the supplied NetMsgWriter.
|
||||
*/
|
||||
@Override
|
||||
protected void _serialize(ByteBufferWriter writer) throws SerializationException {
|
||||
|
||||
writer.putInt(GameObjectType.Guild.ordinal());
|
||||
writer.putInt(this.guildID);
|
||||
writer.putInt(GameObjectType.Guild.ordinal());
|
||||
writer.putInt(this.guildID);
|
||||
|
||||
Guild guild = Guild.getGuild(this.guildID);
|
||||
Guild guild = Guild.getGuild(this.guildID);
|
||||
|
||||
writer.putInt(guild.getAllyList().size());
|
||||
writer.putInt(guild.getAllyList().size());
|
||||
|
||||
for (Guild ally: guild.getAllyList()){
|
||||
writer.putInt(GameObjectType.Guild.ordinal());//guildType
|
||||
writer.putInt(ally.getObjectUUID());//GuildID
|
||||
writer.putString(ally.getName());
|
||||
GuildTag._serializeForDisplay(ally.getGuildTag(),writer);
|
||||
writer.put((byte)0);
|
||||
}
|
||||
for (Guild ally : guild.getAllyList()) {
|
||||
writer.putInt(GameObjectType.Guild.ordinal());//guildType
|
||||
writer.putInt(ally.getObjectUUID());//GuildID
|
||||
writer.putString(ally.getName());
|
||||
GuildTag._serializeForDisplay(ally.getGuildTag(), writer);
|
||||
writer.put((byte) 0);
|
||||
}
|
||||
|
||||
|
||||
writer.putInt(guild.getEnemyList().size());
|
||||
writer.putInt(guild.getEnemyList().size());
|
||||
|
||||
for (Guild enemy: guild.getEnemyList()){
|
||||
writer.putInt(GameObjectType.Guild.ordinal());//guildType
|
||||
writer.putInt(enemy.getObjectUUID());//GuildID
|
||||
writer.putString(enemy.getName());
|
||||
GuildTag._serializeForDisplay(enemy.getGuildTag(),writer);
|
||||
writer.put((byte)1);
|
||||
}
|
||||
for (Guild enemy : guild.getEnemyList()) {
|
||||
writer.putInt(GameObjectType.Guild.ordinal());//guildType
|
||||
writer.putInt(enemy.getObjectUUID());//GuildID
|
||||
writer.putString(enemy.getName());
|
||||
GuildTag._serializeForDisplay(enemy.getGuildTag(), writer);
|
||||
writer.put((byte) 1);
|
||||
}
|
||||
|
||||
|
||||
writer.putInt(guild.getRecommendList().size());
|
||||
for (Guild recommended: guild.getRecommendList()){
|
||||
writer.putInt(guild.getRecommendList().size());
|
||||
for (Guild recommended : guild.getRecommendList()) {
|
||||
|
||||
GuildAlliances guildAlliance = guild.guildAlliances.get(recommended.getObjectUUID());
|
||||
writer.putInt(GameObjectType.Guild.ordinal());//guildType
|
||||
writer.putInt(recommended.getObjectUUID());//GuildID
|
||||
writer.putString(recommended.getName());
|
||||
GuildTag._serializeForDisplay(recommended.getGuildTag(),writer);
|
||||
writer.put((byte)1); // ?
|
||||
writer.putString(guildAlliance.getRecommender()); // recommender name.
|
||||
writer.put((byte) (guildAlliance.isAlly()?1:0)); //ally 1 enemy 0
|
||||
GuildAlliances guildAlliance = guild.guildAlliances.get(recommended.getObjectUUID());
|
||||
writer.putInt(GameObjectType.Guild.ordinal());//guildType
|
||||
writer.putInt(recommended.getObjectUUID());//GuildID
|
||||
writer.putString(recommended.getName());
|
||||
GuildTag._serializeForDisplay(recommended.getGuildTag(), writer);
|
||||
writer.put((byte) 1); // ?
|
||||
writer.putString(guildAlliance.getRecommender()); // recommender name.
|
||||
writer.put((byte) (guildAlliance.isAlly() ? 1 : 0)); //ally 1 enemy 0
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
writer.put((byte)1);
|
||||
writer.put((byte) 1);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public int getGuildID() {
|
||||
return guildID;
|
||||
}
|
||||
public int getGuildID() {
|
||||
return guildID;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,93 +18,93 @@ import engine.net.client.Protocol;
|
||||
|
||||
public class ApplyBuildingEffectMsg extends ClientNetMsg {
|
||||
|
||||
protected int unknown01;
|
||||
protected int unknown02;
|
||||
protected int buildingType;
|
||||
protected int buildingID;
|
||||
protected int unknown03;
|
||||
protected int unknown01;
|
||||
protected int unknown02;
|
||||
protected int buildingType;
|
||||
protected int buildingID;
|
||||
protected int unknown03;
|
||||
|
||||
/**
|
||||
* This is the general purpose constructor.
|
||||
*/
|
||||
public ApplyBuildingEffectMsg() {
|
||||
super(Protocol.VISUALUPDATE);
|
||||
}
|
||||
/**
|
||||
* This is the general purpose constructor.
|
||||
*/
|
||||
public ApplyBuildingEffectMsg() {
|
||||
super(Protocol.VISUALUPDATE);
|
||||
}
|
||||
|
||||
public ApplyBuildingEffectMsg(int unknown01, int unknown02, int buildingType, int buildingID, int unknown03) {
|
||||
super(Protocol.VISUALUPDATE);
|
||||
this.unknown01 = unknown01;
|
||||
this.unknown02 = unknown02;
|
||||
this.buildingType = buildingType;
|
||||
this.buildingID = buildingID;
|
||||
this.unknown03 = unknown03;
|
||||
}
|
||||
public ApplyBuildingEffectMsg(int unknown01, int unknown02, int buildingType, int buildingID, int unknown03) {
|
||||
super(Protocol.VISUALUPDATE);
|
||||
this.unknown01 = unknown01;
|
||||
this.unknown02 = unknown02;
|
||||
this.buildingType = buildingType;
|
||||
this.buildingID = buildingID;
|
||||
this.unknown03 = unknown03;
|
||||
}
|
||||
|
||||
/**
|
||||
* This constructor is used by NetMsgFactory. It attempts to deserialize the
|
||||
* ByteBuffer into a message. If a BufferUnderflow occurs (based on reading
|
||||
* past the limit) then this constructor Throws that Exception to the
|
||||
* caller.
|
||||
*/
|
||||
public ApplyBuildingEffectMsg(AbstractConnection origin, ByteBufferReader reader) {
|
||||
super(Protocol.VISUALUPDATE, origin, reader);
|
||||
}
|
||||
/**
|
||||
* This constructor is used by NetMsgFactory. It attempts to deserialize the
|
||||
* ByteBuffer into a message. If a BufferUnderflow occurs (based on reading
|
||||
* past the limit) then this constructor Throws that Exception to the
|
||||
* caller.
|
||||
*/
|
||||
public ApplyBuildingEffectMsg(AbstractConnection origin, ByteBufferReader reader) {
|
||||
super(Protocol.VISUALUPDATE, origin, reader);
|
||||
}
|
||||
|
||||
/**
|
||||
* Serializes the subclass specific items to the supplied NetMsgWriter.
|
||||
*/
|
||||
@Override
|
||||
protected void _serialize(ByteBufferWriter writer) {
|
||||
writer.putInt(this.unknown01);
|
||||
writer.putInt(this.unknown02);
|
||||
if (this.unknown02 == 0){
|
||||
writer.putInt(this.unknown03);
|
||||
writer.putInt(this.buildingType);
|
||||
writer.putInt(this.buildingID);
|
||||
writer.putInt(0);
|
||||
return;
|
||||
}
|
||||
writer.putInt(this.buildingType);
|
||||
writer.putInt(this.buildingID);
|
||||
writer.putInt(this.unknown03);
|
||||
}
|
||||
/**
|
||||
* Serializes the subclass specific items to the supplied NetMsgWriter.
|
||||
*/
|
||||
@Override
|
||||
protected void _serialize(ByteBufferWriter writer) {
|
||||
writer.putInt(this.unknown01);
|
||||
writer.putInt(this.unknown02);
|
||||
if (this.unknown02 == 0) {
|
||||
writer.putInt(this.unknown03);
|
||||
writer.putInt(this.buildingType);
|
||||
writer.putInt(this.buildingID);
|
||||
writer.putInt(0);
|
||||
return;
|
||||
}
|
||||
writer.putInt(this.buildingType);
|
||||
writer.putInt(this.buildingID);
|
||||
writer.putInt(this.unknown03);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deserializes the subclass specific items from the supplied NetMsgReader.
|
||||
*/
|
||||
@Override
|
||||
protected void _deserialize(ByteBufferReader reader) {
|
||||
}
|
||||
/**
|
||||
* Deserializes the subclass specific items from the supplied NetMsgReader.
|
||||
*/
|
||||
@Override
|
||||
protected void _deserialize(ByteBufferReader reader) {
|
||||
}
|
||||
|
||||
public void setUnknown01(int unknown01) {
|
||||
this.unknown01 = unknown01;
|
||||
}
|
||||
public int getUnknown01() {
|
||||
return unknown01;
|
||||
}
|
||||
|
||||
public void setUnknown02(int unknown02) {
|
||||
this.unknown02 = unknown02;
|
||||
}
|
||||
public void setUnknown01(int unknown01) {
|
||||
this.unknown01 = unknown01;
|
||||
}
|
||||
|
||||
public void setBuildingID(int buildingID) {
|
||||
this.buildingID = buildingID;
|
||||
}
|
||||
public int getUnknown02() {
|
||||
return unknown02;
|
||||
}
|
||||
|
||||
public void setUnknown03(int unknown03) {
|
||||
this.unknown03 = unknown03;
|
||||
}
|
||||
public void setUnknown02(int unknown02) {
|
||||
this.unknown02 = unknown02;
|
||||
}
|
||||
|
||||
public int getUnknown01() {
|
||||
return unknown01;
|
||||
}
|
||||
public int getBuildingID() {
|
||||
return buildingID;
|
||||
}
|
||||
|
||||
public int getUnknown02() {
|
||||
return unknown02;
|
||||
}
|
||||
public void setBuildingID(int buildingID) {
|
||||
this.buildingID = buildingID;
|
||||
}
|
||||
|
||||
public int getBuildingID() {
|
||||
return buildingID;
|
||||
}
|
||||
public int getUnknown03() {
|
||||
return unknown03;
|
||||
}
|
||||
|
||||
public int getUnknown03() {
|
||||
return unknown03;
|
||||
}
|
||||
public void setUnknown03(int unknown03) {
|
||||
this.unknown03 = unknown03;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ public class ApplyEffectMsg extends ClientNetMsg {
|
||||
* This is the general purpose constructor.
|
||||
*/
|
||||
public ApplyEffectMsg(AbstractWorldObject source, AbstractWorldObject target, int numTrains, int effectID, int duration,
|
||||
int powerUsedID, String powerUsedName) {
|
||||
int powerUsedID, String powerUsedName) {
|
||||
super(Protocol.POWERACTION);
|
||||
this.numTrains = numTrains;
|
||||
this.effectID = effectID;
|
||||
@@ -99,7 +99,7 @@ public class ApplyEffectMsg extends ClientNetMsg {
|
||||
* past the limit) then this constructor Throws that Exception to the
|
||||
* caller.
|
||||
*/
|
||||
public ApplyEffectMsg(AbstractConnection origin, ByteBufferReader reader) {
|
||||
public ApplyEffectMsg(AbstractConnection origin, ByteBufferReader reader) {
|
||||
super(Protocol.POWERACTION, origin, reader);
|
||||
}
|
||||
|
||||
@@ -125,9 +125,7 @@ public class ApplyEffectMsg extends ClientNetMsg {
|
||||
if (this.unknown06 == (byte) 1) {
|
||||
writer.putInt(this.effectSourceType);
|
||||
writer.putInt(this.effectSourceID);
|
||||
}
|
||||
|
||||
else {
|
||||
} else {
|
||||
writer.putInt(this.powerUsedID);
|
||||
}
|
||||
|
||||
@@ -138,7 +136,7 @@ public class ApplyEffectMsg extends ClientNetMsg {
|
||||
* Deserializes the subclass specific items from the supplied NetMsgReader.
|
||||
*/
|
||||
@Override
|
||||
protected void _deserialize(ByteBufferReader reader) {
|
||||
protected void _deserialize(ByteBufferReader reader) {
|
||||
this.numTrains = reader.getInt();
|
||||
this.effectID = reader.getInt();
|
||||
|
||||
@@ -162,86 +160,86 @@ public class ApplyEffectMsg extends ClientNetMsg {
|
||||
return this.numTrains;
|
||||
}
|
||||
|
||||
public int getEffectID() {
|
||||
return this.effectID;
|
||||
}
|
||||
|
||||
public int getSourceType() {
|
||||
return this.sourceType;
|
||||
}
|
||||
|
||||
public int getSourceID() {
|
||||
return this.sourceID;
|
||||
}
|
||||
|
||||
public int getTargetType() {
|
||||
return this.targetType;
|
||||
}
|
||||
|
||||
public int getTargetID() {
|
||||
return this.targetID;
|
||||
}
|
||||
|
||||
public int getUnknown02() {
|
||||
return this.unknown02;
|
||||
}
|
||||
|
||||
public int getUnknown03() {
|
||||
return this.unknown03;
|
||||
}
|
||||
|
||||
public int getDuration() {
|
||||
return this.duration;
|
||||
}
|
||||
|
||||
public int getUnknown05() {
|
||||
return this.unknown05;
|
||||
}
|
||||
|
||||
public byte getUnknown06() {
|
||||
return this.unknown06;
|
||||
}
|
||||
|
||||
public void setNumTrains(int value) {
|
||||
this.numTrains = value;
|
||||
}
|
||||
|
||||
public int getEffectID() {
|
||||
return this.effectID;
|
||||
}
|
||||
|
||||
public void setEffectID(int value) {
|
||||
this.effectID = value;
|
||||
}
|
||||
|
||||
public int getSourceType() {
|
||||
return this.sourceType;
|
||||
}
|
||||
|
||||
public void setSourceType(int value) {
|
||||
this.sourceType = value;
|
||||
}
|
||||
|
||||
public int getSourceID() {
|
||||
return this.sourceID;
|
||||
}
|
||||
|
||||
public void setSourceID(int value) {
|
||||
this.sourceID = value;
|
||||
}
|
||||
|
||||
public int getTargetType() {
|
||||
return this.targetType;
|
||||
}
|
||||
|
||||
public void setTargetType(int value) {
|
||||
this.targetType = value;
|
||||
}
|
||||
|
||||
public int getTargetID() {
|
||||
return this.targetID;
|
||||
}
|
||||
|
||||
public void setTargetID(int value) {
|
||||
this.targetID = value;
|
||||
}
|
||||
|
||||
public int getUnknown02() {
|
||||
return this.unknown02;
|
||||
}
|
||||
|
||||
public void setUnknown02(int value) {
|
||||
this.unknown02 = value;
|
||||
}
|
||||
|
||||
public int getUnknown03() {
|
||||
return this.unknown03;
|
||||
}
|
||||
|
||||
public void setUnknown03(int value) {
|
||||
this.unknown03 = value;
|
||||
}
|
||||
|
||||
public int getDuration() {
|
||||
return this.duration;
|
||||
}
|
||||
|
||||
public void setDuration(int value) {
|
||||
this.duration = value;
|
||||
}
|
||||
|
||||
public int getUnknown05() {
|
||||
return this.unknown05;
|
||||
}
|
||||
|
||||
public void setUnknown05(int value) {
|
||||
this.unknown05 = value;
|
||||
}
|
||||
|
||||
public byte getUnknown06() {
|
||||
return this.unknown06;
|
||||
}
|
||||
|
||||
public void setUnknown06(byte value) {
|
||||
this.unknown06 = value;
|
||||
}
|
||||
@@ -255,10 +253,10 @@ public class ApplyEffectMsg extends ClientNetMsg {
|
||||
}
|
||||
|
||||
public void setEffectSourceType(int effectSourceType) {
|
||||
this.effectSourceType = effectSourceType;
|
||||
}
|
||||
this.effectSourceType = effectSourceType;
|
||||
}
|
||||
|
||||
public void setEffectSourceID(int effectSourceID) {
|
||||
this.effectSourceID = effectSourceID;
|
||||
}
|
||||
this.effectSourceID = effectSourceID;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,368 +26,368 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class ApplyRuneMsg extends ClientNetMsg {
|
||||
|
||||
private int targetType;
|
||||
private int targetID;
|
||||
private int removeRuneBase;
|
||||
private int runeBase;
|
||||
private int runeType;
|
||||
private int runeID;
|
||||
private Boolean isPromo;
|
||||
private int targetType;
|
||||
private int targetID;
|
||||
private int removeRuneBase;
|
||||
private int runeBase;
|
||||
private int runeType;
|
||||
private int runeID;
|
||||
private Boolean isPromo;
|
||||
|
||||
/**
|
||||
* This is the general purpose constructor.
|
||||
*/
|
||||
public ApplyRuneMsg(int targetType, int targetID, int runeBase, int runeType, int runeID, Boolean isPromo) {
|
||||
super(Protocol.SETRUNE);
|
||||
this.targetType = targetType;
|
||||
this.targetID = targetID;
|
||||
this.runeBase = runeBase;
|
||||
this.runeType = runeType;
|
||||
this.runeID = runeID;
|
||||
this.isPromo = isPromo;
|
||||
this.removeRuneBase = 0;
|
||||
}
|
||||
/**
|
||||
* This is the general purpose constructor.
|
||||
*/
|
||||
public ApplyRuneMsg(int targetType, int targetID, int runeBase, int runeType, int runeID, Boolean isPromo) {
|
||||
super(Protocol.SETRUNE);
|
||||
this.targetType = targetType;
|
||||
this.targetID = targetID;
|
||||
this.runeBase = runeBase;
|
||||
this.runeType = runeType;
|
||||
this.runeID = runeID;
|
||||
this.isPromo = isPromo;
|
||||
this.removeRuneBase = 0;
|
||||
}
|
||||
|
||||
public ApplyRuneMsg(int targetType, int targetID, int removeRuneBase) {
|
||||
super(Protocol.SETRUNE);
|
||||
this.targetType = targetType;
|
||||
this.targetID = targetID;
|
||||
this.runeBase = 0;
|
||||
this.runeType = 0;
|
||||
this.runeID = 0;
|
||||
this.isPromo = false;
|
||||
this.removeRuneBase = removeRuneBase;
|
||||
}
|
||||
public ApplyRuneMsg(int targetType, int targetID, int removeRuneBase) {
|
||||
super(Protocol.SETRUNE);
|
||||
this.targetType = targetType;
|
||||
this.targetID = targetID;
|
||||
this.runeBase = 0;
|
||||
this.runeType = 0;
|
||||
this.runeID = 0;
|
||||
this.isPromo = false;
|
||||
this.removeRuneBase = removeRuneBase;
|
||||
}
|
||||
|
||||
/**
|
||||
* This constructor is used by NetMsgFactory. It attempts to deserialize the
|
||||
* ByteBuffer into a message. If a BufferUnderflow occurs (based on reading
|
||||
* past the limit) then this constructor Throws that Exception to the
|
||||
* caller.
|
||||
*/
|
||||
public ApplyRuneMsg(AbstractConnection origin, ByteBufferReader reader) {
|
||||
super(Protocol.SETRUNE, origin, reader);
|
||||
}
|
||||
/**
|
||||
* This constructor is used by NetMsgFactory. It attempts to deserialize the
|
||||
* ByteBuffer into a message. If a BufferUnderflow occurs (based on reading
|
||||
* past the limit) then this constructor Throws that Exception to the
|
||||
* caller.
|
||||
*/
|
||||
public ApplyRuneMsg(AbstractConnection origin, ByteBufferReader reader) {
|
||||
super(Protocol.SETRUNE, origin, reader);
|
||||
}
|
||||
|
||||
/**
|
||||
* Serializes the subclass specific items to the supplied NetMsgWriter.
|
||||
*/
|
||||
@Override
|
||||
protected void _serialize(ByteBufferWriter writer) {
|
||||
writer.putInt(this.targetType);
|
||||
writer.putInt(this.targetID);
|
||||
writer.putInt(0);
|
||||
writer.putInt(this.removeRuneBase);
|
||||
writer.putInt(0);
|
||||
writer.putInt(this.runeBase);
|
||||
writer.putInt(this.runeType);
|
||||
writer.putInt(this.runeID);
|
||||
if (this.isPromo) {
|
||||
writer.put((byte) 1);
|
||||
} else {
|
||||
writer.put((byte) 0);
|
||||
}
|
||||
}
|
||||
public static boolean applyRune(int runeID, ClientConnection origin, PlayerCharacter playerCharacter) {
|
||||
|
||||
/**
|
||||
* Deserializes the subclass specific items from the supplied NetMsgReader.
|
||||
*/
|
||||
@Override
|
||||
protected void _deserialize(ByteBufferReader reader) {
|
||||
this.targetType = reader.getInt();
|
||||
this.targetID = reader.getInt();
|
||||
reader.getInt();
|
||||
this.removeRuneBase = reader.getInt();
|
||||
reader.getInt();
|
||||
this.runeBase = reader.getInt();
|
||||
this.runeType = reader.getInt();
|
||||
this.runeID = reader.getInt();
|
||||
this.isPromo = (reader.get() == 1) ? true : false;
|
||||
}
|
||||
RuneBase rb = RuneBase.getRuneBase(runeID);
|
||||
Dispatch dispatch;
|
||||
|
||||
public int getTargetType() {
|
||||
return targetType;
|
||||
}
|
||||
if (playerCharacter == null || origin == null || rb == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setTargetType(int value) {
|
||||
this.targetType = value;
|
||||
}
|
||||
//Check race is met
|
||||
ConcurrentHashMap<Integer, Boolean> races = rb.getRace();
|
||||
if (races.size() > 0) {
|
||||
int raceID = playerCharacter.getRaceID();
|
||||
boolean valid = false;
|
||||
for (int validID : races.keySet()) {
|
||||
if (validID == raceID) {
|
||||
valid = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!valid) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public int getTargetID() {
|
||||
return targetID;
|
||||
}
|
||||
//Check base class is met
|
||||
ConcurrentHashMap<Integer, Boolean> baseClasses = rb.getBaseClass();
|
||||
if (baseClasses.size() > 0) {
|
||||
int baseClassID = playerCharacter.getBaseClassID();
|
||||
boolean valid = false;
|
||||
for (int validID : baseClasses.keySet()) {
|
||||
if (validID == baseClassID) {
|
||||
valid = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!valid) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void setTargetID(int value) {
|
||||
this.targetID = value;
|
||||
}
|
||||
//Check promotion class is met
|
||||
ConcurrentHashMap<Integer, Boolean> promotionClasses = rb.getPromotionClass();
|
||||
if (promotionClasses.size() > 0) {
|
||||
int promotionClassID = playerCharacter.getPromotionClassID();
|
||||
boolean valid = false;
|
||||
for (int validID : promotionClasses.keySet()) {
|
||||
if (validID == promotionClassID) {
|
||||
valid = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!valid) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public int getRuneID() {
|
||||
return runeID;
|
||||
}
|
||||
//Check disciplines are met
|
||||
ArrayList<CharacterRune> runes = playerCharacter.getRunes();
|
||||
ConcurrentHashMap<Integer, Boolean> disciplines = rb.getDiscipline();
|
||||
if (disciplines.size() > 0) {
|
||||
for (CharacterRune cr : runes) {
|
||||
int runeBaseID = cr.getRuneBaseID();
|
||||
for (Integer prohID : disciplines.keySet()) {
|
||||
if (runeBaseID == prohID) {
|
||||
return false; //Prohibited rune
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setRuneID(int value) {
|
||||
this.runeID = value;
|
||||
}
|
||||
int discCount = 0;
|
||||
for (CharacterRune cr : runes) {
|
||||
int runeBaseID = cr.getRuneBaseID();
|
||||
//count number of discipline runes
|
||||
if (runeBaseID > 3000 && runeBaseID < 3049) {
|
||||
discCount++;
|
||||
}
|
||||
//see if rune is already applied
|
||||
if (runeBaseID == runeID) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean applyRune(int runeID, ClientConnection origin, PlayerCharacter playerCharacter) {
|
||||
//Check level is met
|
||||
if (playerCharacter.getLevel() < rb.getLevelRequired()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
RuneBase rb = RuneBase.getRuneBase(runeID);
|
||||
Dispatch dispatch;
|
||||
int strTotal = 0;
|
||||
int dexTotal = 0;
|
||||
int conTotal = 0;
|
||||
int intTotal = 0;
|
||||
int spiTotal = 0;
|
||||
int cost = 0;
|
||||
|
||||
if (playerCharacter == null || origin == null || rb == null) {
|
||||
return false;
|
||||
}
|
||||
//Check any attributes are met
|
||||
ArrayList<RuneBaseAttribute> attrs = rb.getAttrs();
|
||||
|
||||
//Check race is met
|
||||
ConcurrentHashMap<Integer, Boolean> races = rb.getRace();
|
||||
if (races.size() > 0) {
|
||||
int raceID = playerCharacter.getRaceID();
|
||||
boolean valid = false;
|
||||
for (int validID : races.keySet()) {
|
||||
if (validID == raceID) {
|
||||
valid = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!valid) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (rb.getAttrs() != null)
|
||||
for (RuneBaseAttribute rba : attrs) {
|
||||
int attrID = rba.getAttributeID();
|
||||
int mod = rba.getModValue();
|
||||
switch (attrID) {
|
||||
case MBServerStatics.RUNE_COST_ATTRIBUTE_ID:
|
||||
if (mod > playerCharacter.getUnusedStatPoints()) {
|
||||
return false;
|
||||
}
|
||||
cost = mod;
|
||||
break;
|
||||
case MBServerStatics.RUNE_STR_MIN_NEEDED_ATTRIBUTE_ID:
|
||||
if ((int) playerCharacter.statStrBase < mod) {
|
||||
return false;
|
||||
}
|
||||
strTotal = mod;
|
||||
break;
|
||||
case MBServerStatics.RUNE_DEX_MIN_NEEDED_ATTRIBUTE_ID:
|
||||
if ((int) playerCharacter.statDexBase < mod) {
|
||||
return false;
|
||||
}
|
||||
dexTotal = mod;
|
||||
break;
|
||||
case MBServerStatics.RUNE_CON_MIN_NEEDED_ATTRIBUTE_ID:
|
||||
if ((int) playerCharacter.statConBase < mod) {
|
||||
return false;
|
||||
}
|
||||
conTotal = mod;
|
||||
break;
|
||||
case MBServerStatics.RUNE_INT_MIN_NEEDED_ATTRIBUTE_ID:
|
||||
if ((int) playerCharacter.statIntBase < mod) {
|
||||
return false;
|
||||
}
|
||||
intTotal = mod;
|
||||
break;
|
||||
case MBServerStatics.RUNE_SPI_MIN_NEEDED_ATTRIBUTE_ID:
|
||||
if ((int) playerCharacter.statSpiBase < mod) {
|
||||
return false;
|
||||
}
|
||||
spiTotal = mod;
|
||||
break;
|
||||
case MBServerStatics.RUNE_STR_ATTRIBUTE_ID:
|
||||
strTotal += mod;
|
||||
break;
|
||||
case MBServerStatics.RUNE_DEX_ATTRIBUTE_ID:
|
||||
dexTotal += mod;
|
||||
break;
|
||||
case MBServerStatics.RUNE_CON_ATTRIBUTE_ID:
|
||||
conTotal += mod;
|
||||
break;
|
||||
case MBServerStatics.RUNE_INT_ATTRIBUTE_ID:
|
||||
intTotal += mod;
|
||||
break;
|
||||
case MBServerStatics.RUNE_SPI_ATTRIBUTE_ID:
|
||||
spiTotal += mod;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//Check base class is met
|
||||
ConcurrentHashMap<Integer, Boolean> baseClasses = rb.getBaseClass();
|
||||
if (baseClasses.size() > 0) {
|
||||
int baseClassID = playerCharacter.getBaseClassID();
|
||||
boolean valid = false;
|
||||
for (int validID : baseClasses.keySet()) {
|
||||
if (validID == baseClassID) {
|
||||
valid = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!valid) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
//Check if max number runes already reached
|
||||
if (runes.size() > 12) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//Check promotion class is met
|
||||
ConcurrentHashMap<Integer, Boolean> promotionClasses = rb.getPromotionClass();
|
||||
if (promotionClasses.size() > 0) {
|
||||
int promotionClassID = playerCharacter.getPromotionClassID();
|
||||
boolean valid = false;
|
||||
for (int validID : promotionClasses.keySet()) {
|
||||
if (validID == promotionClassID) {
|
||||
valid = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!valid) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
//if discipline, check number applied
|
||||
if (isDiscipline(runeID)) {
|
||||
if (playerCharacter.getLevel() < 70) {
|
||||
if (discCount > 2) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (discCount > 3) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Check disciplines are met
|
||||
ArrayList<CharacterRune> runes = playerCharacter.getRunes();
|
||||
ConcurrentHashMap<Integer, Boolean> disciplines = rb.getDiscipline();
|
||||
if (disciplines.size() > 0) {
|
||||
for (CharacterRune cr : runes) {
|
||||
int runeBaseID = cr.getRuneBaseID();
|
||||
for (Integer prohID : disciplines.keySet()) {
|
||||
if (runeBaseID == prohID) {
|
||||
return false; //Prohibited rune
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//Everything succeeded. Let's apply the rune
|
||||
//Attempt add rune to database
|
||||
CharacterRune runeWithoutID = new CharacterRune(rb, playerCharacter.getObjectUUID());
|
||||
CharacterRune cr;
|
||||
try {
|
||||
cr = DbManager.CharacterRuneQueries.ADD_CHARACTER_RUNE(runeWithoutID);
|
||||
} catch (Exception e) {
|
||||
cr = null;
|
||||
Logger.error(e);
|
||||
}
|
||||
if (cr == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int discCount = 0;
|
||||
for (CharacterRune cr : runes) {
|
||||
int runeBaseID = cr.getRuneBaseID();
|
||||
//count number of discipline runes
|
||||
if (runeBaseID > 3000 && runeBaseID < 3049) {
|
||||
discCount++;
|
||||
}
|
||||
//see if rune is already applied
|
||||
if (runeBaseID == runeID) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
//remove any overridden runes from player
|
||||
ArrayList<Integer> overwrite = rb.getOverwrite();
|
||||
CharacterRune toRemove = null;
|
||||
if (overwrite.size() > 0) {
|
||||
for (int overwriteID : overwrite) {
|
||||
toRemove = playerCharacter.removeRune(overwriteID);
|
||||
}
|
||||
}
|
||||
|
||||
//Check level is met
|
||||
if (playerCharacter.getLevel() < rb.getLevelRequired()) {
|
||||
return false;
|
||||
}
|
||||
//add rune to player
|
||||
playerCharacter.addRune(cr);
|
||||
|
||||
int strTotal = 0;
|
||||
int dexTotal = 0;
|
||||
int conTotal = 0;
|
||||
int intTotal = 0;
|
||||
int spiTotal = 0;
|
||||
int cost = 0;
|
||||
// recalculate all bonuses/formulas/skills/powers
|
||||
playerCharacter.recalculate();
|
||||
|
||||
//Check any attributes are met
|
||||
ArrayList<RuneBaseAttribute> attrs = rb.getAttrs();
|
||||
//if overwriting a stat rune, add any amount granted from previous rune.
|
||||
if (toRemove != null) {
|
||||
RuneBase rbs = toRemove.getRuneBase();
|
||||
if (rbs != null && rbs.getObjectUUID() > 249999 && rbs.getObjectUUID() < 250045) {
|
||||
//add any additional stats to match old amount
|
||||
int dif = strTotal - (int) playerCharacter.statStrBase;
|
||||
if (dif > 0 && strTotal < (int) playerCharacter.statStrMax) {
|
||||
playerCharacter.addStr(dif);
|
||||
}
|
||||
dif = dexTotal - (int) playerCharacter.statDexBase;
|
||||
if (dif > 0 && dexTotal < (int) playerCharacter.statDexMax) {
|
||||
playerCharacter.addDex(dif);
|
||||
}
|
||||
dif = conTotal - (int) playerCharacter.statConBase;
|
||||
if (dif > 0 && conTotal < (int) playerCharacter.statConMax) {
|
||||
playerCharacter.addCon(dif);
|
||||
}
|
||||
dif = intTotal - (int) playerCharacter.statIntBase;
|
||||
if (dif > 0 && intTotal < (int) playerCharacter.statIntMax) {
|
||||
playerCharacter.addInt(dif);
|
||||
}
|
||||
dif = spiTotal - (int) playerCharacter.statSpiBase;
|
||||
if (dif > 0 && spiTotal < (int) playerCharacter.statSpiMax) {
|
||||
playerCharacter.addSpi(dif);
|
||||
}
|
||||
|
||||
if (rb.getAttrs() != null)
|
||||
for (RuneBaseAttribute rba : attrs) {
|
||||
int attrID = rba.getAttributeID();
|
||||
int mod = rba.getModValue();
|
||||
switch (attrID) {
|
||||
case MBServerStatics.RUNE_COST_ATTRIBUTE_ID:
|
||||
if (mod > playerCharacter.getUnusedStatPoints()) {
|
||||
return false;
|
||||
}
|
||||
cost = mod;
|
||||
break;
|
||||
case MBServerStatics.RUNE_STR_MIN_NEEDED_ATTRIBUTE_ID:
|
||||
if ((int) playerCharacter.statStrBase < mod) {
|
||||
return false;
|
||||
}
|
||||
strTotal = mod;
|
||||
break;
|
||||
case MBServerStatics.RUNE_DEX_MIN_NEEDED_ATTRIBUTE_ID:
|
||||
if ((int) playerCharacter.statDexBase < mod) {
|
||||
return false;
|
||||
}
|
||||
dexTotal = mod;
|
||||
break;
|
||||
case MBServerStatics.RUNE_CON_MIN_NEEDED_ATTRIBUTE_ID:
|
||||
if ((int) playerCharacter.statConBase < mod) {
|
||||
return false;
|
||||
}
|
||||
conTotal = mod;
|
||||
break;
|
||||
case MBServerStatics.RUNE_INT_MIN_NEEDED_ATTRIBUTE_ID:
|
||||
if ((int) playerCharacter.statIntBase < mod) {
|
||||
return false;
|
||||
}
|
||||
intTotal = mod;
|
||||
break;
|
||||
case MBServerStatics.RUNE_SPI_MIN_NEEDED_ATTRIBUTE_ID:
|
||||
if ((int) playerCharacter.statSpiBase < mod) {
|
||||
return false;
|
||||
}
|
||||
spiTotal = mod;
|
||||
break;
|
||||
case MBServerStatics.RUNE_STR_ATTRIBUTE_ID:
|
||||
strTotal += mod;
|
||||
break;
|
||||
case MBServerStatics.RUNE_DEX_ATTRIBUTE_ID:
|
||||
dexTotal += mod;
|
||||
break;
|
||||
case MBServerStatics.RUNE_CON_ATTRIBUTE_ID:
|
||||
conTotal += mod;
|
||||
break;
|
||||
case MBServerStatics.RUNE_INT_ATTRIBUTE_ID:
|
||||
intTotal += mod;
|
||||
break;
|
||||
case MBServerStatics.RUNE_SPI_ATTRIBUTE_ID:
|
||||
spiTotal += mod;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// recalculate all bonuses/formulas/skills/powers
|
||||
playerCharacter.recalculate();
|
||||
}
|
||||
}
|
||||
|
||||
//Check if max number runes already reached
|
||||
if (runes.size() > 12) {
|
||||
return false;
|
||||
}
|
||||
if (cost > 0) {
|
||||
ModifyStatMsg msm = new ModifyStatMsg((0 - cost), 0, 3);
|
||||
dispatch = Dispatch.borrow(playerCharacter, msm);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
}
|
||||
|
||||
//if discipline, check number applied
|
||||
if (isDiscipline(runeID)) {
|
||||
if (playerCharacter.getLevel() < 70) {
|
||||
if (discCount > 2) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (discCount > 3) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Everything succeeded. Let's apply the rune
|
||||
//Attempt add rune to database
|
||||
CharacterRune runeWithoutID = new CharacterRune(rb, playerCharacter.getObjectUUID());
|
||||
CharacterRune cr;
|
||||
try {
|
||||
cr = DbManager.CharacterRuneQueries.ADD_CHARACTER_RUNE(runeWithoutID);
|
||||
} catch (Exception e) {
|
||||
cr = null;
|
||||
Logger.error(e);
|
||||
}
|
||||
if (cr == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//remove any overridden runes from player
|
||||
ArrayList<Integer> overwrite = rb.getOverwrite();
|
||||
CharacterRune toRemove = null;
|
||||
if (overwrite.size() > 0) {
|
||||
for (int overwriteID : overwrite) {
|
||||
toRemove = playerCharacter.removeRune(overwriteID);
|
||||
}
|
||||
}
|
||||
|
||||
//add rune to player
|
||||
playerCharacter.addRune(cr);
|
||||
|
||||
// recalculate all bonuses/formulas/skills/powers
|
||||
playerCharacter.recalculate();
|
||||
|
||||
//if overwriting a stat rune, add any amount granted from previous rune.
|
||||
if (toRemove != null) {
|
||||
RuneBase rbs = toRemove.getRuneBase();
|
||||
if (rbs != null && rbs.getObjectUUID() > 249999 && rbs.getObjectUUID() < 250045) {
|
||||
//add any additional stats to match old amount
|
||||
int dif = strTotal - (int) playerCharacter.statStrBase;
|
||||
if (dif > 0 && strTotal < (int) playerCharacter.statStrMax) {
|
||||
playerCharacter.addStr(dif);
|
||||
}
|
||||
dif = dexTotal - (int) playerCharacter.statDexBase;
|
||||
if (dif > 0 && dexTotal < (int) playerCharacter.statDexMax) {
|
||||
playerCharacter.addDex(dif);
|
||||
}
|
||||
dif = conTotal - (int) playerCharacter.statConBase;
|
||||
if (dif > 0 && conTotal < (int) playerCharacter.statConMax) {
|
||||
playerCharacter.addCon(dif);
|
||||
}
|
||||
dif = intTotal - (int) playerCharacter.statIntBase;
|
||||
if (dif > 0 && intTotal < (int) playerCharacter.statIntMax) {
|
||||
playerCharacter.addInt(dif);
|
||||
}
|
||||
dif = spiTotal - (int) playerCharacter.statSpiBase;
|
||||
if (dif > 0 && spiTotal < (int) playerCharacter.statSpiMax) {
|
||||
playerCharacter.addSpi(dif);
|
||||
}
|
||||
|
||||
// recalculate all bonuses/formulas/skills/powers
|
||||
playerCharacter.recalculate();
|
||||
}
|
||||
}
|
||||
|
||||
if (cost > 0) {
|
||||
ModifyStatMsg msm = new ModifyStatMsg((0 - cost), 0, 3);
|
||||
dispatch = Dispatch.borrow(playerCharacter, msm);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
}
|
||||
|
||||
//send apply rune message to client
|
||||
ApplyRuneMsg arm = new ApplyRuneMsg(playerCharacter.getObjectType().ordinal(), playerCharacter.getObjectUUID(), runeID, cr.getObjectType().ordinal(), cr.getObjectUUID(), false);
|
||||
dispatch = Dispatch.borrow(playerCharacter, arm);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
//send apply rune message to client
|
||||
ApplyRuneMsg arm = new ApplyRuneMsg(playerCharacter.getObjectType().ordinal(), playerCharacter.getObjectUUID(), runeID, cr.getObjectType().ordinal(), cr.getObjectUUID(), false);
|
||||
dispatch = Dispatch.borrow(playerCharacter, arm);
|
||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||
|
||||
|
||||
//alert them of success
|
||||
ErrorPopupMsg.sendErrorPopup(playerCharacter, 160);
|
||||
//alert them of success
|
||||
ErrorPopupMsg.sendErrorPopup(playerCharacter, 160);
|
||||
|
||||
//reapply bonuses
|
||||
playerCharacter.applyBonuses();
|
||||
//reapply bonuses
|
||||
playerCharacter.applyBonuses();
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean isDiscipline(int runeID) {
|
||||
public static boolean isDiscipline(int runeID) {
|
||||
|
||||
return runeID > 3000 && runeID < 3050;
|
||||
}
|
||||
return runeID > 3000 && runeID < 3050;
|
||||
}
|
||||
|
||||
/**
|
||||
* Serializes the subclass specific items to the supplied NetMsgWriter.
|
||||
*/
|
||||
@Override
|
||||
protected void _serialize(ByteBufferWriter writer) {
|
||||
writer.putInt(this.targetType);
|
||||
writer.putInt(this.targetID);
|
||||
writer.putInt(0);
|
||||
writer.putInt(this.removeRuneBase);
|
||||
writer.putInt(0);
|
||||
writer.putInt(this.runeBase);
|
||||
writer.putInt(this.runeType);
|
||||
writer.putInt(this.runeID);
|
||||
if (this.isPromo) {
|
||||
writer.put((byte) 1);
|
||||
} else {
|
||||
writer.put((byte) 0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deserializes the subclass specific items from the supplied NetMsgReader.
|
||||
*/
|
||||
@Override
|
||||
protected void _deserialize(ByteBufferReader reader) {
|
||||
this.targetType = reader.getInt();
|
||||
this.targetID = reader.getInt();
|
||||
reader.getInt();
|
||||
this.removeRuneBase = reader.getInt();
|
||||
reader.getInt();
|
||||
this.runeBase = reader.getInt();
|
||||
this.runeType = reader.getInt();
|
||||
this.runeID = reader.getInt();
|
||||
this.isPromo = (reader.get() == 1) ? true : false;
|
||||
}
|
||||
|
||||
public int getTargetType() {
|
||||
return targetType;
|
||||
}
|
||||
|
||||
public void setTargetType(int value) {
|
||||
this.targetType = value;
|
||||
}
|
||||
|
||||
public int getTargetID() {
|
||||
return targetID;
|
||||
}
|
||||
|
||||
public void setTargetID(int value) {
|
||||
this.targetID = value;
|
||||
}
|
||||
|
||||
public int getRuneID() {
|
||||
return runeID;
|
||||
}
|
||||
|
||||
public void setRuneID(int value) {
|
||||
this.runeID = value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,132 +17,127 @@ import engine.net.client.Protocol;
|
||||
|
||||
public class ArcLoginNotifyMsg extends ClientNetMsg {
|
||||
|
||||
private int unknown01;
|
||||
private int unknown02;
|
||||
private int unknown03;
|
||||
private short unknown04;
|
||||
private byte unknown05;
|
||||
private int unknown01;
|
||||
private int unknown02;
|
||||
private int unknown03;
|
||||
private short unknown04;
|
||||
private byte unknown05;
|
||||
|
||||
/**
|
||||
* This is the general purpose constructor.
|
||||
*/
|
||||
public ArcLoginNotifyMsg() {
|
||||
super(Protocol.ARCLOGINNOTIFY);
|
||||
this.unknown01 = 0x40A5BDB0;
|
||||
this.unknown02 = 0x342AA9F0;
|
||||
this.unknown03 = 0;
|
||||
this.unknown04 = (short) 0;
|
||||
this.unknown05 = (byte) 0;
|
||||
/**
|
||||
* This is the general purpose constructor.
|
||||
*/
|
||||
public ArcLoginNotifyMsg() {
|
||||
super(Protocol.ARCLOGINNOTIFY);
|
||||
this.unknown01 = 0x40A5BDB0;
|
||||
this.unknown02 = 0x342AA9F0;
|
||||
this.unknown03 = 0;
|
||||
this.unknown04 = (short) 0;
|
||||
this.unknown05 = (byte) 0;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This constructor is used by NetMsgFactory. It attempts to deserialize the
|
||||
* ByteBuffer into a message. If a BufferUnderflow occurs (based on reading
|
||||
* past the limit) then this constructor Throws that Exception to the
|
||||
* caller.
|
||||
*/
|
||||
public ArcLoginNotifyMsg(AbstractConnection origin, ByteBufferReader reader) {
|
||||
super(Protocol.ARCLOGINNOTIFY, origin, reader);
|
||||
}
|
||||
/**
|
||||
* This constructor is used by NetMsgFactory. It attempts to deserialize the
|
||||
* ByteBuffer into a message. If a BufferUnderflow occurs (based on reading
|
||||
* past the limit) then this constructor Throws that Exception to the
|
||||
* caller.
|
||||
*/
|
||||
public ArcLoginNotifyMsg(AbstractConnection origin, ByteBufferReader reader) {
|
||||
super(Protocol.ARCLOGINNOTIFY, origin, reader);
|
||||
}
|
||||
|
||||
/**
|
||||
* Serializes the subclass specific items to the supplied NetMsgWriter.
|
||||
*/
|
||||
@Override
|
||||
protected void _serialize(ByteBufferWriter writer) {
|
||||
writer.putInt(this.unknown01);
|
||||
writer.putInt(this.unknown02);
|
||||
writer.putInt(this.unknown03);
|
||||
writer.putShort(this.unknown04);
|
||||
writer.put(this.unknown05);
|
||||
}
|
||||
/**
|
||||
* Serializes the subclass specific items to the supplied NetMsgWriter.
|
||||
*/
|
||||
@Override
|
||||
protected void _serialize(ByteBufferWriter writer) {
|
||||
writer.putInt(this.unknown01);
|
||||
writer.putInt(this.unknown02);
|
||||
writer.putInt(this.unknown03);
|
||||
writer.putShort(this.unknown04);
|
||||
writer.put(this.unknown05);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deserializes the subclass specific items from the supplied NetMsgReader.
|
||||
*/
|
||||
@Override
|
||||
protected void _deserialize(ByteBufferReader reader) {
|
||||
this.unknown01 = reader.getInt();
|
||||
this.unknown02 = reader.getInt();
|
||||
this.unknown03 = reader.getInt();
|
||||
this.unknown04 = reader.getShort();
|
||||
this.unknown05 = reader.get();
|
||||
}
|
||||
/**
|
||||
* Deserializes the subclass specific items from the supplied NetMsgReader.
|
||||
*/
|
||||
@Override
|
||||
protected void _deserialize(ByteBufferReader reader) {
|
||||
this.unknown01 = reader.getInt();
|
||||
this.unknown02 = reader.getInt();
|
||||
this.unknown03 = reader.getInt();
|
||||
this.unknown04 = reader.getShort();
|
||||
this.unknown05 = reader.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the unknown01
|
||||
*/
|
||||
public int getUnknown01() {
|
||||
return unknown01;
|
||||
}
|
||||
/**
|
||||
* @return the unknown01
|
||||
*/
|
||||
public int getUnknown01() {
|
||||
return unknown01;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param unknown01
|
||||
* the unknown01 to set
|
||||
*/
|
||||
public void setUnknown01(int unknown01) {
|
||||
this.unknown01 = unknown01;
|
||||
}
|
||||
/**
|
||||
* @param unknown01 the unknown01 to set
|
||||
*/
|
||||
public void setUnknown01(int unknown01) {
|
||||
this.unknown01 = unknown01;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the unknown02
|
||||
*/
|
||||
public int getUnknown02() {
|
||||
return unknown02;
|
||||
}
|
||||
/**
|
||||
* @return the unknown02
|
||||
*/
|
||||
public int getUnknown02() {
|
||||
return unknown02;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param unknown02
|
||||
* the unknown02 to set
|
||||
*/
|
||||
public void setUnknown02(int unknown02) {
|
||||
this.unknown02 = unknown02;
|
||||
}
|
||||
/**
|
||||
* @param unknown02 the unknown02 to set
|
||||
*/
|
||||
public void setUnknown02(int unknown02) {
|
||||
this.unknown02 = unknown02;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the unknown03
|
||||
*/
|
||||
public int getUnknown03() {
|
||||
return unknown03;
|
||||
}
|
||||
/**
|
||||
* @return the unknown03
|
||||
*/
|
||||
public int getUnknown03() {
|
||||
return unknown03;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param unknown03
|
||||
* the unknown03 to set
|
||||
*/
|
||||
public void setUnknown03(int unknown03) {
|
||||
this.unknown03 = unknown03;
|
||||
}
|
||||
/**
|
||||
* @param unknown03 the unknown03 to set
|
||||
*/
|
||||
public void setUnknown03(int unknown03) {
|
||||
this.unknown03 = unknown03;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the unknown04
|
||||
*/
|
||||
public short getUnknown04() {
|
||||
return unknown04;
|
||||
}
|
||||
/**
|
||||
* @return the unknown04
|
||||
*/
|
||||
public short getUnknown04() {
|
||||
return unknown04;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param unknown04
|
||||
* the unknown04 to set
|
||||
*/
|
||||
public void setUnknown04(short unknown04) {
|
||||
this.unknown04 = unknown04;
|
||||
}
|
||||
/**
|
||||
* @param unknown04 the unknown04 to set
|
||||
*/
|
||||
public void setUnknown04(short unknown04) {
|
||||
this.unknown04 = unknown04;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the unknown05
|
||||
*/
|
||||
public byte getUnknown05() {
|
||||
return unknown05;
|
||||
}
|
||||
/**
|
||||
* @return the unknown05
|
||||
*/
|
||||
public byte getUnknown05() {
|
||||
return unknown05;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param unknown05
|
||||
* the unknown05 to set
|
||||
*/
|
||||
public void setUnknown05(byte unknown05) {
|
||||
this.unknown05 = unknown05;
|
||||
}
|
||||
/**
|
||||
* @param unknown05 the unknown05 to set
|
||||
*/
|
||||
public void setUnknown05(byte unknown05) {
|
||||
this.unknown05 = unknown05;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ public class ArcMineChangeProductionMsg extends ClientNetMsg {
|
||||
* past the limit) then this constructor Throws that Exception to the
|
||||
* caller.
|
||||
*/
|
||||
public ArcMineChangeProductionMsg(AbstractConnection origin, ByteBufferReader reader) {
|
||||
public ArcMineChangeProductionMsg(AbstractConnection origin, ByteBufferReader reader) {
|
||||
super(Protocol.ARCMINECHANGEPRODUCTION, origin, reader);
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ public class ArcMineChangeProductionMsg extends ClientNetMsg {
|
||||
* Deserializes the subclass specific items from the supplied NetMsgReader.
|
||||
*/
|
||||
@Override
|
||||
protected void _deserialize(ByteBufferReader reader) {
|
||||
protected void _deserialize(ByteBufferReader reader) {
|
||||
this.mineID = reader.getInt();
|
||||
this.resourceHash = reader.getInt();
|
||||
}
|
||||
|
||||
@@ -23,88 +23,88 @@ import org.joda.time.Seconds;
|
||||
|
||||
public class ArcMineWindowAvailableTimeMsg extends ClientNetMsg {
|
||||
|
||||
private int buildingUUID;
|
||||
private Building treeOfLife;
|
||||
private int buildingUUID;
|
||||
private Building treeOfLife;
|
||||
|
||||
private int currentMineHour;
|
||||
private Seconds secondsLeft;
|
||||
private DateTime lateTime;
|
||||
private int late;
|
||||
private int currentMineHour;
|
||||
private Seconds secondsLeft;
|
||||
private DateTime lateTime;
|
||||
private int late;
|
||||
|
||||
/**
|
||||
* This constructor is used by NetMsgFactory. It attempts to deserialize the
|
||||
* ByteBuffer into a message. If a BufferUnderflow occurs (based on reading
|
||||
* past the limit) then this constructor Throws that Exception to the
|
||||
* caller.
|
||||
*/
|
||||
public ArcMineWindowAvailableTimeMsg(AbstractConnection origin, ByteBufferReader reader) {
|
||||
super(Protocol.ARCMINEWINDOWAVAILABLETIME, origin, reader);
|
||||
}
|
||||
/**
|
||||
* This constructor is used by NetMsgFactory. It attempts to deserialize the
|
||||
* ByteBuffer into a message. If a BufferUnderflow occurs (based on reading
|
||||
* past the limit) then this constructor Throws that Exception to the
|
||||
* caller.
|
||||
*/
|
||||
public ArcMineWindowAvailableTimeMsg(AbstractConnection origin, ByteBufferReader reader) {
|
||||
super(Protocol.ARCMINEWINDOWAVAILABLETIME, origin, reader);
|
||||
}
|
||||
|
||||
public ArcMineWindowAvailableTimeMsg(Building treeOfLife, int timeLeft) {
|
||||
super(Protocol.ARCMINEWINDOWAVAILABLETIME);
|
||||
this.treeOfLife = treeOfLife;
|
||||
this.buildingUUID = treeOfLife.getObjectUUID();
|
||||
}
|
||||
public ArcMineWindowAvailableTimeMsg(Building treeOfLife, int timeLeft) {
|
||||
super(Protocol.ARCMINEWINDOWAVAILABLETIME);
|
||||
this.treeOfLife = treeOfLife;
|
||||
this.buildingUUID = treeOfLife.getObjectUUID();
|
||||
}
|
||||
|
||||
/**
|
||||
* Deserializes the subclass specific items from the supplied NetMsgReader.
|
||||
*/
|
||||
@Override
|
||||
protected void _deserialize(ByteBufferReader reader) {
|
||||
reader.getInt();
|
||||
reader.getInt();
|
||||
reader.getInt();
|
||||
reader.getInt(); // Object type padding (We know it's a building)
|
||||
this.buildingUUID = reader.getInt();
|
||||
reader.getInt();
|
||||
/**
|
||||
* Deserializes the subclass specific items from the supplied NetMsgReader.
|
||||
*/
|
||||
@Override
|
||||
protected void _deserialize(ByteBufferReader reader) {
|
||||
reader.getInt();
|
||||
reader.getInt();
|
||||
reader.getInt();
|
||||
reader.getInt(); // Object type padding (We know it's a building)
|
||||
this.buildingUUID = reader.getInt();
|
||||
reader.getInt();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Configures and pre-caches values for this message
|
||||
// so everything is already available during serialisation.
|
||||
// Configures and pre-caches values for this message
|
||||
// so everything is already available during serialisation.
|
||||
|
||||
public void configure() {
|
||||
public void configure() {
|
||||
|
||||
Guild guild;
|
||||
guild = this.treeOfLife.getGuild();
|
||||
Guild guild;
|
||||
guild = this.treeOfLife.getGuild();
|
||||
|
||||
if (guild != null)
|
||||
currentMineHour = guild.getMineTime();
|
||||
if (guild != null)
|
||||
currentMineHour = guild.getMineTime();
|
||||
|
||||
late = MBServerStatics.MINE_LATE_WINDOW;
|
||||
lateTime = DateTime.now();
|
||||
late = MBServerStatics.MINE_LATE_WINDOW;
|
||||
lateTime = DateTime.now();
|
||||
|
||||
if (late == 0)
|
||||
lateTime = lateTime.plusDays(1);
|
||||
if (late == 0)
|
||||
lateTime = lateTime.plusDays(1);
|
||||
|
||||
lateTime = lateTime.hourOfDay().setCopy(late);
|
||||
lateTime = lateTime.hourOfDay().setCopy(late);
|
||||
|
||||
late = ((late > 23) ? (late - 24) : late);
|
||||
secondsLeft = Seconds.secondsBetween(DateTime.now(), lateTime);
|
||||
}
|
||||
late = ((late > 23) ? (late - 24) : late);
|
||||
secondsLeft = Seconds.secondsBetween(DateTime.now(), lateTime);
|
||||
}
|
||||
|
||||
/**
|
||||
* Serializes the subclass specific items to the supplied NetMsgWriter.
|
||||
*/
|
||||
@Override
|
||||
protected void _serialize(ByteBufferWriter writer) throws SerializationException {
|
||||
/**
|
||||
* Serializes the subclass specific items to the supplied NetMsgWriter.
|
||||
*/
|
||||
@Override
|
||||
protected void _serialize(ByteBufferWriter writer) throws SerializationException {
|
||||
|
||||
writer.putInt(MBServerStatics.MINE_EARLY_WINDOW); //15);
|
||||
writer.putInt(late);
|
||||
writer.putInt(currentMineHour);
|
||||
writer.putInt(MBServerStatics.MINE_EARLY_WINDOW); //15);
|
||||
writer.putInt(late);
|
||||
writer.putInt(currentMineHour);
|
||||
|
||||
writer.putInt(this.treeOfLife.getObjectType().ordinal());
|
||||
writer.putInt(this.treeOfLife.getObjectUUID());
|
||||
writer.putInt(this.treeOfLife.getObjectType().ordinal());
|
||||
writer.putInt(this.treeOfLife.getObjectUUID());
|
||||
|
||||
writer.putInt((int)secondsLeft.getSeconds());
|
||||
}
|
||||
writer.putInt((int) secondsLeft.getSeconds());
|
||||
}
|
||||
|
||||
public int getBuildingUUID() {
|
||||
return buildingUUID;
|
||||
}
|
||||
public int getBuildingUUID() {
|
||||
return buildingUUID;
|
||||
}
|
||||
|
||||
public void setBuildingUUID(int buildingUUID) {
|
||||
this.buildingUUID = buildingUUID;
|
||||
}
|
||||
public void setBuildingUUID(int buildingUUID) {
|
||||
this.buildingUUID = buildingUUID;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ public class ArcMineWindowChangeMsg extends ClientNetMsg {
|
||||
* past the limit) then this constructor Throws that Exception to the
|
||||
* caller.
|
||||
*/
|
||||
public ArcMineWindowChangeMsg(AbstractConnection origin, ByteBufferReader reader) {
|
||||
public ArcMineWindowChangeMsg(AbstractConnection origin, ByteBufferReader reader) {
|
||||
super(Protocol.ARCMINEWINDOWCHANGE, origin, reader);
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ public class ArcMineWindowChangeMsg extends ClientNetMsg {
|
||||
* Deserializes the subclass specific items from the supplied NetMsgReader.
|
||||
*/
|
||||
@Override
|
||||
protected void _deserialize(ByteBufferReader reader) {
|
||||
protected void _deserialize(ByteBufferReader reader) {
|
||||
this.time = reader.getInt();
|
||||
this.buildingType = reader.getInt();
|
||||
this.buildingID = reader.getInt();
|
||||
@@ -56,14 +56,14 @@ public class ArcMineWindowChangeMsg extends ClientNetMsg {
|
||||
return this.time;
|
||||
}
|
||||
|
||||
public int getBuildingID() {
|
||||
return this.buildingID;
|
||||
}
|
||||
|
||||
public void setTime(int value) {
|
||||
this.time = value;
|
||||
}
|
||||
|
||||
public int getBuildingID() {
|
||||
return this.buildingID;
|
||||
}
|
||||
|
||||
public void setBuildingID(int value) {
|
||||
this.buildingID = value;
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ public class ArcOwnedMinesListMsg extends ClientNetMsg {
|
||||
* past the limit) then this constructor Throws that Exception to the
|
||||
* caller.
|
||||
*/
|
||||
public ArcOwnedMinesListMsg(AbstractConnection origin, ByteBufferReader reader) {
|
||||
public ArcOwnedMinesListMsg(AbstractConnection origin, ByteBufferReader reader) {
|
||||
super(Protocol.ARCOWNEDMINESLIST, origin, reader);
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ public class ArcOwnedMinesListMsg extends ClientNetMsg {
|
||||
* Deserializes the subclass specific items from the supplied NetMsgReader.
|
||||
*/
|
||||
@Override
|
||||
protected void _deserialize(ByteBufferReader reader) {
|
||||
protected void _deserialize(ByteBufferReader reader) {
|
||||
reader.getInt();
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
// www.magicbane.com
|
||||
|
||||
|
||||
|
||||
package engine.net.client.msg;
|
||||
|
||||
|
||||
@@ -28,7 +27,7 @@ public class ArcSiegeSpireMsg extends ClientNetMsg {
|
||||
* past the limit) then this constructor Throws that Exception to the
|
||||
* caller.
|
||||
*/
|
||||
public ArcSiegeSpireMsg(AbstractConnection origin, ByteBufferReader reader) {
|
||||
public ArcSiegeSpireMsg(AbstractConnection origin, ByteBufferReader reader) {
|
||||
super(Protocol.ARCSIEGESPIRE, origin, reader);
|
||||
}
|
||||
|
||||
@@ -40,7 +39,7 @@ public class ArcSiegeSpireMsg extends ClientNetMsg {
|
||||
* Deserializes the subclass specific items from the supplied NetMsgReader.
|
||||
*/
|
||||
@Override
|
||||
protected void _deserialize(ByteBufferReader reader) {
|
||||
protected void _deserialize(ByteBufferReader reader) {
|
||||
reader.getInt(); // object type padding
|
||||
this.buildingUUID = reader.getInt();
|
||||
}
|
||||
@@ -56,5 +55,5 @@ public class ArcSiegeSpireMsg extends ClientNetMsg {
|
||||
public int getBuildingUUID() {
|
||||
return buildingUUID;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -23,128 +23,129 @@ import java.util.ArrayList;
|
||||
|
||||
public class ArcViewAssetTransactionsMsg extends ClientNetMsg {
|
||||
|
||||
private int warehouseID;
|
||||
private Warehouse warehouse;
|
||||
private int transactionID;
|
||||
private ArrayList<Transaction> transactions;
|
||||
Building warehouseBuilding;
|
||||
Building warehouseBuilding;
|
||||
private int warehouseID;
|
||||
private Warehouse warehouse;
|
||||
private int transactionID;
|
||||
private ArrayList<Transaction> transactions;
|
||||
|
||||
/**
|
||||
* This constructor is used by NetMsgFactory. It attempts to deserialize the
|
||||
* ByteBuffer into a message. If a BufferUnderflow occurs (based on reading
|
||||
* past the limit) then this constructor Throws that Exception to the
|
||||
* caller.
|
||||
*/
|
||||
public ArcViewAssetTransactionsMsg(AbstractConnection origin, ByteBufferReader reader) {
|
||||
super(Protocol.ARCVIEWASSETTRANSACTIONS, origin, reader);
|
||||
}
|
||||
/**
|
||||
* This constructor is used by NetMsgFactory. It attempts to deserialize the
|
||||
* ByteBuffer into a message. If a BufferUnderflow occurs (based on reading
|
||||
* past the limit) then this constructor Throws that Exception to the
|
||||
* caller.
|
||||
*/
|
||||
public ArcViewAssetTransactionsMsg(AbstractConnection origin, ByteBufferReader reader) {
|
||||
super(Protocol.ARCVIEWASSETTRANSACTIONS, origin, reader);
|
||||
}
|
||||
|
||||
public ArcViewAssetTransactionsMsg(Warehouse warehouse, ArcViewAssetTransactionsMsg msg) {
|
||||
super(Protocol.ARCVIEWASSETTRANSACTIONS);
|
||||
public ArcViewAssetTransactionsMsg(Warehouse warehouse, ArcViewAssetTransactionsMsg msg) {
|
||||
super(Protocol.ARCVIEWASSETTRANSACTIONS);
|
||||
this.warehouseID = msg.warehouseID;
|
||||
this.transactionID = msg.transactionID;
|
||||
this.warehouse = warehouse;
|
||||
}
|
||||
this.warehouse = warehouse;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deserializes the subclass specific items from the supplied NetMsgReader.
|
||||
*/
|
||||
@Override
|
||||
protected void _deserialize(ByteBufferReader reader) {
|
||||
this.transactionID = reader.getInt(); //some odd type?
|
||||
this.warehouseID = reader.getInt();
|
||||
reader.getInt();
|
||||
}
|
||||
/**
|
||||
* Deserializes the subclass specific items from the supplied NetMsgReader.
|
||||
*/
|
||||
@Override
|
||||
protected void _deserialize(ByteBufferReader reader) {
|
||||
this.transactionID = reader.getInt(); //some odd type?
|
||||
this.warehouseID = reader.getInt();
|
||||
reader.getInt();
|
||||
}
|
||||
|
||||
// Method pre-caches and configures values so they are
|
||||
// available before we attempt serialization
|
||||
// Method pre-caches and configures values so they are
|
||||
// available before we attempt serialization
|
||||
|
||||
public void configure() {
|
||||
public void configure() {
|
||||
|
||||
warehouseBuilding = BuildingManager.getBuilding(this.warehouse.getBuildingUID());
|
||||
transactions = new ArrayList<>(50);
|
||||
warehouseBuilding = BuildingManager.getBuilding(this.warehouse.getBuildingUID());
|
||||
transactions = new ArrayList<>(50);
|
||||
|
||||
if (this.warehouse.getTransactions().size() > 150){
|
||||
transactions.addAll(this.warehouse.getTransactions().subList(this.warehouse.getTransactions().size() - 150, this.warehouse.getTransactions().size()));
|
||||
}else
|
||||
transactions = this.warehouse.getTransactions();
|
||||
if (this.warehouse.getTransactions().size() > 150) {
|
||||
transactions.addAll(this.warehouse.getTransactions().subList(this.warehouse.getTransactions().size() - 150, this.warehouse.getTransactions().size()));
|
||||
} else
|
||||
transactions = this.warehouse.getTransactions();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Serializes the subclass specific items to the supplied NetMsgWriter.
|
||||
*/
|
||||
@Override
|
||||
protected void _serialize(ByteBufferWriter writer) throws SerializationException {
|
||||
/**
|
||||
* Serializes the subclass specific items to the supplied NetMsgWriter.
|
||||
*/
|
||||
@Override
|
||||
protected void _serialize(ByteBufferWriter writer) throws SerializationException {
|
||||
|
||||
writer.putInt(this.transactionID);
|
||||
writer.putInt(this.warehouse.getBuildingUID());
|
||||
writer.putInt(transactions.size()); //list Size
|
||||
writer.putInt(this.transactionID);
|
||||
writer.putInt(this.warehouse.getBuildingUID());
|
||||
writer.putInt(transactions.size()); //list Size
|
||||
|
||||
for (Transaction transaction:transactions){
|
||||
String name = "No Name";
|
||||
switch (transaction.getTargetType()){
|
||||
case Building:
|
||||
Building building = BuildingManager.getBuildingFromCache(transaction.getTargetUUID());
|
||||
if (building != null)
|
||||
name = building.getName();
|
||||
Mine mine = Mine.getMineFromTower(transaction.getTargetUUID());
|
||||
//
|
||||
if (mine != null)
|
||||
name = mine.getZoneName();
|
||||
|
||||
if (transaction.getTransactionType().equals(TransactionType.TAXRESOURCE) || transaction.getTransactionType().equals(TransactionType.TAXRESOURCEDEPOSIT)){
|
||||
City city = building.getCity();
|
||||
|
||||
if (city != null)
|
||||
name = city.getCityName();
|
||||
}
|
||||
|
||||
break;
|
||||
case PlayerCharacter:
|
||||
PlayerCharacter pc = PlayerCharacter.getPlayerCharacter(transaction.getTargetUUID());
|
||||
if (pc != null)
|
||||
name = pc.getCombinedName();
|
||||
break;
|
||||
case NPC:
|
||||
NPC npc = NPC.getFromCache(transaction.getTargetUUID());
|
||||
if (npc != null){
|
||||
|
||||
if (npc.getBuilding() != null)
|
||||
name = npc.getBuilding().getName();
|
||||
else
|
||||
name = npc.getName();
|
||||
}
|
||||
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
writer.putInt(transaction.getTargetType().ordinal()); //Type
|
||||
writer.putInt(transaction.getTargetUUID()); //ID
|
||||
writer.putString(name); //Name of depositer/withdrawler or mine name
|
||||
writer.putInt(GameObjectType.Building.ordinal()); //Type
|
||||
writer.putInt(warehouse.getBuildingUID()); //ID
|
||||
writer.putString(warehouseBuilding.getName()); //warehouse
|
||||
writer.putInt(transaction.getTransactionType().getID()); //79,80 withdrew, 81 mine produced, 82 deposit
|
||||
writer.putInt(transaction.getAmount()); //amount
|
||||
writer.putString(transaction.getResource().name().toLowerCase()); //item type
|
||||
writer.putDateTime(transaction.getDate());
|
||||
}
|
||||
for (Transaction transaction : transactions) {
|
||||
String name = "No Name";
|
||||
switch (transaction.getTargetType()) {
|
||||
case Building:
|
||||
Building building = BuildingManager.getBuildingFromCache(transaction.getTargetUUID());
|
||||
if (building != null)
|
||||
name = building.getName();
|
||||
Mine mine = Mine.getMineFromTower(transaction.getTargetUUID());
|
||||
//
|
||||
if (mine != null)
|
||||
name = mine.getZoneName();
|
||||
|
||||
if (transaction.getTransactionType().equals(TransactionType.TAXRESOURCE) || transaction.getTransactionType().equals(TransactionType.TAXRESOURCEDEPOSIT)) {
|
||||
City city = building.getCity();
|
||||
|
||||
if (city != null)
|
||||
name = city.getCityName();
|
||||
}
|
||||
|
||||
break;
|
||||
case PlayerCharacter:
|
||||
PlayerCharacter pc = PlayerCharacter.getPlayerCharacter(transaction.getTargetUUID());
|
||||
if (pc != null)
|
||||
name = pc.getCombinedName();
|
||||
break;
|
||||
case NPC:
|
||||
NPC npc = NPC.getFromCache(transaction.getTargetUUID());
|
||||
if (npc != null) {
|
||||
|
||||
if (npc.getBuilding() != null)
|
||||
name = npc.getBuilding().getName();
|
||||
else
|
||||
name = npc.getName();
|
||||
}
|
||||
|
||||
|
||||
//writer.putString("balls");
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
writer.putInt(transaction.getTargetType().ordinal()); //Type
|
||||
writer.putInt(transaction.getTargetUUID()); //ID
|
||||
writer.putString(name); //Name of depositer/withdrawler or mine name
|
||||
writer.putInt(GameObjectType.Building.ordinal()); //Type
|
||||
writer.putInt(warehouse.getBuildingUID()); //ID
|
||||
writer.putString(warehouseBuilding.getName()); //warehouse
|
||||
writer.putInt(transaction.getTransactionType().getID()); //79,80 withdrew, 81 mine produced, 82 deposit
|
||||
writer.putInt(transaction.getAmount()); //amount
|
||||
writer.putString(transaction.getResource().name().toLowerCase()); //item type
|
||||
writer.putDateTime(transaction.getDate());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getPowerOfTwoBufferSize() {
|
||||
return (16); // 2^14 == 16384
|
||||
}
|
||||
|
||||
public int getWarehouseID() {
|
||||
return warehouseID;
|
||||
}
|
||||
public int getTransactionID() {
|
||||
return transactionID;
|
||||
}
|
||||
//writer.putString("balls");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getPowerOfTwoBufferSize() {
|
||||
return (16); // 2^14 == 16384
|
||||
}
|
||||
|
||||
public int getWarehouseID() {
|
||||
return warehouseID;
|
||||
}
|
||||
|
||||
public int getTransactionID() {
|
||||
return transactionID;
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user