|
|
|
@@ -7,9 +7,6 @@
|
|
|
|
|
// www.magicbane.com
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
|
|
|
|
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
|
|
|
|
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
|
|
|
@@ -43,7 +40,6 @@ import java.sql.SQLException;
|
|
|
|
|
import java.sql.Timestamp;
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.concurrent.ConcurrentHashMap;
|
|
|
|
|
|
|
|
|
@@ -77,15 +73,15 @@ public class Guild extends AbstractWorldObject {
|
|
|
|
|
private ArrayList<Guild> subGuildList;
|
|
|
|
|
private int nationUUID = 0;
|
|
|
|
|
private GuildState guildState = GuildState.Errant;
|
|
|
|
|
private ConcurrentHashMap<Integer,Condemned> guildCondemned = new ConcurrentHashMap<>();
|
|
|
|
|
private final ConcurrentHashMap<Integer, Condemned> guildCondemned = new ConcurrentHashMap<>();
|
|
|
|
|
private String hash;
|
|
|
|
|
private boolean ownerIsNPC;
|
|
|
|
|
|
|
|
|
|
private static Guild errantGuild;
|
|
|
|
|
private static Guild errantNation;
|
|
|
|
|
|
|
|
|
|
public LocalDateTime lastWooEditTime;
|
|
|
|
|
public HashMap<Integer,GuildAlliances> guildAlliances = new HashMap<>();
|
|
|
|
|
public boolean wooWasModified;
|
|
|
|
|
public HashMap<Integer, GuildAlliances> guildAlliances = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* No Id Constructor
|
|
|
|
@@ -121,7 +117,7 @@ public class Guild extends AbstractWorldObject {
|
|
|
|
|
/**
|
|
|
|
|
* Normal Constructor
|
|
|
|
|
*/
|
|
|
|
|
public Guild( String name, Guild nat, int charter,
|
|
|
|
|
public Guild(String name, Guild nat, int charter,
|
|
|
|
|
String leadershipType, GuildTag gt, int newUUID) {
|
|
|
|
|
super(newUUID);
|
|
|
|
|
this.name = name;
|
|
|
|
@@ -182,11 +178,7 @@ public class Guild extends AbstractWorldObject {
|
|
|
|
|
this.teleportMax = rs.getInt("teleportMax");
|
|
|
|
|
|
|
|
|
|
this.mineTime = rs.getInt("mineTime");
|
|
|
|
|
|
|
|
|
|
Timestamp lastWooRequest = rs.getTimestamp("lastWooEditTime");
|
|
|
|
|
|
|
|
|
|
if (lastWooRequest != null)
|
|
|
|
|
this.lastWooEditTime = lastWooRequest.toLocalDateTime();
|
|
|
|
|
this.wooWasModified = false;
|
|
|
|
|
|
|
|
|
|
this.hash = rs.getString("hash");
|
|
|
|
|
}
|
|
|
|
@@ -333,9 +325,9 @@ public class Guild extends AbstractWorldObject {
|
|
|
|
|
if (this.isErrant())
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if (!DbManager.GuildQueries.SET_GUILD_LEADER(ac.getObjectUUID(), this.getObjectUUID())){
|
|
|
|
|
if (!DbManager.GuildQueries.SET_GUILD_LEADER(ac.getObjectUUID(), this.getObjectUUID())) {
|
|
|
|
|
if (ac.getObjectType().equals(GameObjectType.PlayerCharacter))
|
|
|
|
|
ChatManager.chatGuildError((PlayerCharacter)ac, "Failed to change guild leader!");
|
|
|
|
|
ChatManager.chatGuildError((PlayerCharacter) ac, "Failed to change guild leader!");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -346,7 +338,7 @@ public class Guild extends AbstractWorldObject {
|
|
|
|
|
oldGuildLeader.setGuildLeader(false);
|
|
|
|
|
|
|
|
|
|
if (ac.getObjectType().equals(GameObjectType.PlayerCharacter))
|
|
|
|
|
((PlayerCharacter)ac).setGuildLeader(true);
|
|
|
|
|
((PlayerCharacter) ac).setGuildLeader(true);
|
|
|
|
|
this.guildLeaderUUID = ac.getObjectUUID();
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
@@ -360,7 +352,7 @@ public class Guild extends AbstractWorldObject {
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if (ac.getObjectType().equals(GameObjectType.PlayerCharacter))
|
|
|
|
|
((PlayerCharacter)ac).setGuildLeader(true);
|
|
|
|
|
((PlayerCharacter) ac).setGuildLeader(true);
|
|
|
|
|
this.guildLeaderUUID = ac.getObjectUUID();
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
@@ -411,10 +403,9 @@ public class Guild extends AbstractWorldObject {
|
|
|
|
|
|
|
|
|
|
public boolean isErrant() {
|
|
|
|
|
return this.getObjectUUID() == Guild.errantGuild.getObjectUUID();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static boolean sameGuild(Guild a, Guild b) {
|
|
|
|
|
if (a == null || b == null)
|
|
|
|
|
return false;
|
|
|
|
@@ -475,14 +466,14 @@ public class Guild extends AbstractWorldObject {
|
|
|
|
|
public void removePlayer(PlayerCharacter pc, GuildHistoryType historyType) {
|
|
|
|
|
|
|
|
|
|
if (this.isErrant()) {
|
|
|
|
|
Logger.warn( "Attempted to remove a PlayerCharacter (" + pc.getObjectUUID() + ") from an errant guild.");
|
|
|
|
|
Logger.warn("Attempted to remove a PlayerCharacter (" + pc.getObjectUUID() + ") from an errant guild.");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Add to Guild History
|
|
|
|
|
if (pc.getGuild() != null){
|
|
|
|
|
if (DbManager.GuildQueries.ADD_TO_GUILDHISTORY(pc.getGuildUUID(), pc, DateTime.now(), historyType)){
|
|
|
|
|
GuildHistory guildHistory = new GuildHistory(pc.getGuildUUID(), pc.getGuild().name,DateTime.now(), historyType) ;
|
|
|
|
|
if (pc.getGuild() != null) {
|
|
|
|
|
if (DbManager.GuildQueries.ADD_TO_GUILDHISTORY(pc.getGuildUUID(), pc, DateTime.now(), historyType)) {
|
|
|
|
|
GuildHistory guildHistory = new GuildHistory(pc.getGuildUUID(), pc.getGuild().name, DateTime.now(), historyType);
|
|
|
|
|
pc.getGuildHistory().add(guildHistory);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@@ -496,12 +487,12 @@ public class Guild extends AbstractWorldObject {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void upgradeGuildState(boolean nation){
|
|
|
|
|
if (nation){
|
|
|
|
|
public void upgradeGuildState(boolean nation) {
|
|
|
|
|
if (nation) {
|
|
|
|
|
this.guildState = GuildState.Nation;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
switch(this.guildState){
|
|
|
|
|
switch (this.guildState) {
|
|
|
|
|
|
|
|
|
|
case Errant:
|
|
|
|
|
this.guildState = GuildState.Petitioner;
|
|
|
|
@@ -528,9 +519,9 @@ public class Guild extends AbstractWorldObject {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void downgradeGuildState(){
|
|
|
|
|
public void downgradeGuildState() {
|
|
|
|
|
|
|
|
|
|
switch(this.guildState){
|
|
|
|
|
switch (this.guildState) {
|
|
|
|
|
case Errant:
|
|
|
|
|
break;
|
|
|
|
|
case Sworn:
|
|
|
|
@@ -555,13 +546,13 @@ public class Guild extends AbstractWorldObject {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean canSubAGuild(Guild toSub){
|
|
|
|
|
public boolean canSubAGuild(Guild toSub) {
|
|
|
|
|
|
|
|
|
|
boolean canSub;
|
|
|
|
|
|
|
|
|
|
if (this.equals(toSub))
|
|
|
|
|
return false;
|
|
|
|
|
switch(this.guildState) {
|
|
|
|
|
switch (this.guildState) {
|
|
|
|
|
case Nation:
|
|
|
|
|
case Sovereign:
|
|
|
|
|
canSub = true;
|
|
|
|
@@ -570,7 +561,7 @@ public class Guild extends AbstractWorldObject {
|
|
|
|
|
canSub = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch(toSub.guildState){
|
|
|
|
|
switch (toSub.guildState) {
|
|
|
|
|
case Errant:
|
|
|
|
|
case Sovereign:
|
|
|
|
|
canSub = true;
|
|
|
|
@@ -585,11 +576,11 @@ public class Guild extends AbstractWorldObject {
|
|
|
|
|
return canSub;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static boolean canSwearIn(Guild toSub){
|
|
|
|
|
public static boolean canSwearIn(Guild toSub) {
|
|
|
|
|
|
|
|
|
|
boolean canSwear = false;
|
|
|
|
|
|
|
|
|
|
switch(toSub.guildState){
|
|
|
|
|
switch (toSub.guildState) {
|
|
|
|
|
|
|
|
|
|
case Protectorate:
|
|
|
|
|
case Petitioner:
|
|
|
|
@@ -607,7 +598,7 @@ public class Guild extends AbstractWorldObject {
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
public static void _serializeForClientMsg(Guild guild, ByteBufferWriter writer) {
|
|
|
|
|
Guild.serializeForClientMsg(guild,writer, null, false);
|
|
|
|
|
Guild.serializeForClientMsg(guild, writer, null, false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void serializeForClientMsg(Guild guild, ByteBufferWriter writer, PlayerCharacter pc, boolean reshowGuild) {
|
|
|
|
@@ -635,24 +626,24 @@ Guild.serializeForClientMsg(guild,writer, null, false);
|
|
|
|
|
|
|
|
|
|
City ownedCity = guild.getOwnedCity();
|
|
|
|
|
|
|
|
|
|
if (ownedCity != null){
|
|
|
|
|
if (ownedCity != null) {
|
|
|
|
|
Realm realm = guild.getOwnedCity().getRealm();
|
|
|
|
|
if (realm != null && realm.getRulingCity() != null){
|
|
|
|
|
if (realm.getRulingCity().equals(ownedCity)){
|
|
|
|
|
if (realm != null && realm.getRulingCity() != null) {
|
|
|
|
|
if (realm.getRulingCity().equals(ownedCity)) {
|
|
|
|
|
writer.putInt(realm.getCharterType());
|
|
|
|
|
}else
|
|
|
|
|
} else
|
|
|
|
|
writer.putInt(0);
|
|
|
|
|
}else{
|
|
|
|
|
} else {
|
|
|
|
|
writer.putInt(0);
|
|
|
|
|
}
|
|
|
|
|
}else
|
|
|
|
|
} else
|
|
|
|
|
writer.putInt(0);
|
|
|
|
|
|
|
|
|
|
writer.putFloat(200);
|
|
|
|
|
writer.putFloat(200); // Pad
|
|
|
|
|
|
|
|
|
|
GuildTag._serializeForDisplay(guild.guildTag,writer);
|
|
|
|
|
GuildTag._serializeForDisplay(guild.nation.guildTag,writer);
|
|
|
|
|
GuildTag._serializeForDisplay(guild.guildTag, writer);
|
|
|
|
|
GuildTag._serializeForDisplay(guild.nation.guildTag, writer);
|
|
|
|
|
if (reshowGuild) {
|
|
|
|
|
writer.putInt(1);
|
|
|
|
|
writer.putInt(guild.getObjectType().ordinal());
|
|
|
|
@@ -662,10 +653,10 @@ Guild.serializeForClientMsg(guild,writer, null, false);
|
|
|
|
|
writer.putInt(0); // Pad
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void serializeForTrack(Guild guild,ByteBufferWriter writer) {
|
|
|
|
|
Guild.serializeGuildForTrack(guild,writer);
|
|
|
|
|
public static void serializeForTrack(Guild guild, ByteBufferWriter writer) {
|
|
|
|
|
Guild.serializeGuildForTrack(guild, writer);
|
|
|
|
|
if (guild.nation != null)
|
|
|
|
|
Guild.serializeGuildForTrack(guild.nation,writer);
|
|
|
|
|
Guild.serializeGuildForTrack(guild.nation, writer);
|
|
|
|
|
else
|
|
|
|
|
Guild.addErrantForTrack(writer);
|
|
|
|
|
}
|
|
|
|
@@ -674,7 +665,7 @@ Guild.serializeForClientMsg(guild,writer, null, false);
|
|
|
|
|
writer.putInt(guild.getObjectType().ordinal());
|
|
|
|
|
writer.putInt(guild.getObjectUUID());
|
|
|
|
|
writer.put((byte) 1);
|
|
|
|
|
GuildTag._serializeForDisplay(guild.guildTag,writer);
|
|
|
|
|
GuildTag._serializeForDisplay(guild.guildTag, writer);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void serializeErrantForTrack(ByteBufferWriter writer) {
|
|
|
|
@@ -682,9 +673,9 @@ Guild.serializeForClientMsg(guild,writer, null, false);
|
|
|
|
|
addErrantForTrack(writer); //Nation
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int getRealmsOwnedFlag(){
|
|
|
|
|
public int getRealmsOwnedFlag() {
|
|
|
|
|
int flag = 0;
|
|
|
|
|
switch(realmsOwned){
|
|
|
|
|
switch (realmsOwned) {
|
|
|
|
|
case 0:
|
|
|
|
|
flag = 0;
|
|
|
|
|
case 1:
|
|
|
|
@@ -727,7 +718,7 @@ Guild.serializeForClientMsg(guild,writer, null, false);
|
|
|
|
|
public static Guild getErrantGuild() {
|
|
|
|
|
|
|
|
|
|
if (Guild.errantGuild == null)
|
|
|
|
|
Guild.errantGuild = new Guild( "None", Guild.getErrantNation(), 0,
|
|
|
|
|
Guild.errantGuild = new Guild("None", Guild.getErrantNation(), 0,
|
|
|
|
|
"Anarchy", GuildTag.ERRANT, 0);
|
|
|
|
|
|
|
|
|
|
return Guild.errantGuild;
|
|
|
|
@@ -793,13 +784,13 @@ Guild.serializeForClientMsg(guild,writer, null, false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//LOad Owners in Cache so we do not have to continuely look in the db for owner.
|
|
|
|
|
if (this.ownerIsNPC){
|
|
|
|
|
if (this.ownerIsNPC) {
|
|
|
|
|
if (NPC.getNPC(this.guildLeaderUUID) == null)
|
|
|
|
|
Logger.info( "Guild UID " + this.getObjectUUID() + " Failed to Load NPC Owner with ID " + this.guildLeaderUUID);
|
|
|
|
|
Logger.info("Guild UID " + this.getObjectUUID() + " Failed to Load NPC Owner with ID " + this.guildLeaderUUID);
|
|
|
|
|
|
|
|
|
|
}else if (this.guildLeaderUUID != 0){
|
|
|
|
|
} else if (this.guildLeaderUUID != 0) {
|
|
|
|
|
if (PlayerCharacter.getPlayerCharacter(this.guildLeaderUUID) == null)
|
|
|
|
|
Logger.info( "Guild UID " + this.getObjectUUID() + " Failed to Load Player Owner with ID " + this.guildLeaderUUID);
|
|
|
|
|
Logger.info("Guild UID " + this.getObjectUUID() + " Failed to Load Player Owner with ID " + this.guildLeaderUUID);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// If loading this guild for the first time write it's character record to disk
|
|
|
|
@@ -829,10 +820,10 @@ Guild.serializeForClientMsg(guild,writer, null, false);
|
|
|
|
|
//Get guild states.
|
|
|
|
|
try {
|
|
|
|
|
this.subGuildList = DbManager.GuildQueries.GET_SUB_GUILDS(this.getObjectUUID());
|
|
|
|
|
}catch(Exception e){
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
|
|
this.subGuildList = new ArrayList<>();
|
|
|
|
|
Logger.error( "FAILED TO LOAD SUB GUILDS FOR UUID " + this.getObjectUUID());
|
|
|
|
|
Logger.error("FAILED TO LOAD SUB GUILDS FOR UUID " + this.getObjectUUID());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (this.nation == this && subGuildList.size() > 0)
|
|
|
|
@@ -861,7 +852,7 @@ Guild.serializeForClientMsg(guild,writer, null, false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ConfigManager.serverType.equals(ServerType.WORLDSERVER)){
|
|
|
|
|
if (ConfigManager.serverType.equals(ServerType.WORLDSERVER)) {
|
|
|
|
|
|
|
|
|
|
//add alliance list, clear all lists as there seems to be a bug where alliances are doubled, need to find where.
|
|
|
|
|
//possible runAfterLoad being called twice?!?!
|
|
|
|
@@ -873,25 +864,25 @@ Guild.serializeForClientMsg(guild,writer, null, false);
|
|
|
|
|
this.enemyList.clear();
|
|
|
|
|
this.recommendList.clear();
|
|
|
|
|
|
|
|
|
|
try{
|
|
|
|
|
try {
|
|
|
|
|
DbManager.GuildQueries.LOAD_ALL_ALLIANCES_FOR_GUILD(this);
|
|
|
|
|
for (GuildAlliances guildAlliance:this.guildAlliances.values()){
|
|
|
|
|
if (guildAlliance.isRecommended()){
|
|
|
|
|
for (GuildAlliances guildAlliance : this.guildAlliances.values()) {
|
|
|
|
|
if (guildAlliance.isRecommended()) {
|
|
|
|
|
Guild recommendedGuild = Guild.getGuild(guildAlliance.getAllianceGuild());
|
|
|
|
|
if (recommendedGuild != null)
|
|
|
|
|
this.recommendList.add(recommendedGuild);
|
|
|
|
|
}else if (guildAlliance.isAlly()){
|
|
|
|
|
} else if (guildAlliance.isAlly()) {
|
|
|
|
|
Guild alliedGuild = Guild.getGuild(guildAlliance.getAllianceGuild());
|
|
|
|
|
if (alliedGuild != null)
|
|
|
|
|
this.allyList.add(alliedGuild);
|
|
|
|
|
}else{
|
|
|
|
|
} else {
|
|
|
|
|
Guild enemyGuild = Guild.getGuild(guildAlliance.getAllianceGuild());
|
|
|
|
|
if (enemyGuild != null)
|
|
|
|
|
this.enemyList.add(enemyGuild);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}catch(Exception e){
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
Logger.error(this.getObjectUUID() + e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@@ -937,8 +928,7 @@ Guild.serializeForClientMsg(guild,writer, null, false);
|
|
|
|
|
|
|
|
|
|
if (subGuild.getOwnedCity() == null) {
|
|
|
|
|
subGuild.nation = null;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
} else {
|
|
|
|
|
subGuild.nation = subGuild;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -959,7 +949,7 @@ Guild.serializeForClientMsg(guild,writer, null, false);
|
|
|
|
|
this.mineTime = mineTime;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ConcurrentHashMap<Integer,Condemned> getGuildCondemned() {
|
|
|
|
|
public ConcurrentHashMap<Integer, Condemned> getGuildCondemned() {
|
|
|
|
|
return guildCondemned;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -974,10 +964,10 @@ Guild.serializeForClientMsg(guild,writer, null, false);
|
|
|
|
|
DataWarehouse.writeHash(Enum.DataRecordType.GUILD, this.getObjectUUID());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Enum.GuildType getGuildType(){
|
|
|
|
|
try{
|
|
|
|
|
public Enum.GuildType getGuildType() {
|
|
|
|
|
try {
|
|
|
|
|
return Enum.GuildType.values()[this.charter];
|
|
|
|
|
}catch(Exception e){
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
Logger.error(e);
|
|
|
|
|
return Enum.GuildType.NONE;
|
|
|
|
|
}
|
|
|
|
@@ -992,7 +982,7 @@ Guild.serializeForClientMsg(guild,writer, null, false);
|
|
|
|
|
this.recommendList = recommendList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public synchronized boolean addGuildToAlliance(AllianceChangeMsg msg, final AllianceType allianceType, Guild toGuild, PlayerCharacter player){
|
|
|
|
|
public synchronized boolean addGuildToAlliance(AllianceChangeMsg msg, final AllianceType allianceType, Guild toGuild, PlayerCharacter player) {
|
|
|
|
|
|
|
|
|
|
Dispatch dispatch;
|
|
|
|
|
|
|
|
|
@@ -1002,7 +992,7 @@ Guild.serializeForClientMsg(guild,writer, null, false);
|
|
|
|
|
if (toGuild == null)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if (!Guild.sameGuild(player.getGuild(), this)){
|
|
|
|
|
if (!Guild.sameGuild(player.getGuild(), this)) {
|
|
|
|
|
msg.setMsgType(AllianceChangeMsg.ERROR_NOT_SAME_GUILD);
|
|
|
|
|
dispatch = Dispatch.borrow(player, msg);
|
|
|
|
|
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
|
|
|
@@ -1010,15 +1000,15 @@ Guild.serializeForClientMsg(guild,writer, null, false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (allianceType == AllianceType.Ally || allianceType == AllianceType.Enemy)
|
|
|
|
|
if (!GuildStatusController.isInnerCouncil(player.getGuildStatus()) && !GuildStatusController.isGuildLeader(player.getGuildStatus())){
|
|
|
|
|
if (!GuildStatusController.isInnerCouncil(player.getGuildStatus()) && !GuildStatusController.isGuildLeader(player.getGuildStatus())) {
|
|
|
|
|
msg.setMsgType(AllianceChangeMsg.ERROR_NOT_AUTHORIZED);
|
|
|
|
|
dispatch = Dispatch.borrow(player, msg);
|
|
|
|
|
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (allianceType == AllianceType.RecommendedAlly || allianceType == AllianceType.RecommendedEnemy){
|
|
|
|
|
if (!GuildStatusController.isFullMember(player.getGuildStatus())){
|
|
|
|
|
if (allianceType == AllianceType.RecommendedAlly || allianceType == AllianceType.RecommendedEnemy) {
|
|
|
|
|
if (!GuildStatusController.isFullMember(player.getGuildStatus())) {
|
|
|
|
|
msg.setMsgType(AllianceChangeMsg.ERROR_NOT_AUTHORIZED);
|
|
|
|
|
dispatch = Dispatch.borrow(player, msg);
|
|
|
|
|
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
|
|
|
@@ -1034,29 +1024,25 @@ Guild.serializeForClientMsg(guild,writer, null, false);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch(allianceType){
|
|
|
|
|
switch (allianceType) {
|
|
|
|
|
case RecommendedAlly:
|
|
|
|
|
if (recommendList.size() == 10){
|
|
|
|
|
if (recommendList.size() == 10) {
|
|
|
|
|
msg.setMsgType(AllianceChangeMsg.ERROR_TOO_MANY);
|
|
|
|
|
dispatch = Dispatch.borrow(player, msg);
|
|
|
|
|
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (recommendList.contains(toGuild)){
|
|
|
|
|
if (recommendList.contains(toGuild)) {
|
|
|
|
|
ErrorPopupMsg.sendErrorMsg(player, "This guild is already recommonded!");
|
|
|
|
|
msg.setMsgType((byte)15);
|
|
|
|
|
msg.setMsgType((byte) 15);
|
|
|
|
|
dispatch = Dispatch.borrow(player, msg);
|
|
|
|
|
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!DbManager.GuildQueries.ADD_TO_ALLIANCE_LIST(this.getObjectUUID(), toGuild.getObjectUUID(), true, true, player.getFirstName())){
|
|
|
|
|
msg.setMsgType((byte)15);
|
|
|
|
|
if (!DbManager.GuildQueries.ADD_TO_ALLIANCE_LIST(this.getObjectUUID(), toGuild.getObjectUUID(), true, true, player.getFirstName())) {
|
|
|
|
|
msg.setMsgType((byte) 15);
|
|
|
|
|
dispatch = Dispatch.borrow(player, msg);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
@@ -1068,27 +1054,26 @@ Guild.serializeForClientMsg(guild,writer, null, false);
|
|
|
|
|
this.recommendList.add(toGuild);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
case RecommendedEnemy:
|
|
|
|
|
if (recommendList.size() == 10){
|
|
|
|
|
if (recommendList.size() == 10) {
|
|
|
|
|
msg.setMsgType(AllianceChangeMsg.ERROR_TOO_MANY);
|
|
|
|
|
dispatch = Dispatch.borrow(player, msg);
|
|
|
|
|
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (recommendList.contains(toGuild)){
|
|
|
|
|
if (recommendList.contains(toGuild)) {
|
|
|
|
|
ErrorPopupMsg.sendErrorMsg(player, "This guild is already recommonded!");
|
|
|
|
|
msg.setMsgType((byte)15);
|
|
|
|
|
msg.setMsgType((byte) 15);
|
|
|
|
|
dispatch = Dispatch.borrow(player, msg);
|
|
|
|
|
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!DbManager.GuildQueries.ADD_TO_ALLIANCE_LIST(this.getObjectUUID(), toGuild.getObjectUUID(), true, false, player.getFirstName())){
|
|
|
|
|
msg.setMsgType((byte)15);
|
|
|
|
|
if (!DbManager.GuildQueries.ADD_TO_ALLIANCE_LIST(this.getObjectUUID(), toGuild.getObjectUUID(), true, false, player.getFirstName())) {
|
|
|
|
|
msg.setMsgType((byte) 15);
|
|
|
|
|
dispatch = Dispatch.borrow(player, msg);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
@@ -1102,35 +1087,35 @@ Guild.serializeForClientMsg(guild,writer, null, false);
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
case Ally:
|
|
|
|
|
if (allyList.size() == 10){
|
|
|
|
|
if (allyList.size() == 10) {
|
|
|
|
|
msg.setMsgType(AllianceChangeMsg.ERROR_TOO_MANY);
|
|
|
|
|
dispatch = Dispatch.borrow(player, msg);
|
|
|
|
|
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (allyList.contains(toGuild)){
|
|
|
|
|
if (allyList.contains(toGuild)) {
|
|
|
|
|
ErrorPopupMsg.sendErrorMsg(player, "This guild is already an Ally!");
|
|
|
|
|
msg.setMsgType((byte)15);
|
|
|
|
|
msg.setMsgType((byte) 15);
|
|
|
|
|
dispatch = Dispatch.borrow(player, msg);
|
|
|
|
|
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!this.guildAlliances.containsKey(toGuild.getObjectUUID())){
|
|
|
|
|
if (!this.guildAlliances.containsKey(toGuild.getObjectUUID())) {
|
|
|
|
|
ErrorPopupMsg.sendErrorMsg(player, "A Serious error has Occured. Please contact CCR!");
|
|
|
|
|
Logger.error(this.getObjectUUID() + " Could not find alliance Guild");
|
|
|
|
|
msg.setMsgType((byte)15);
|
|
|
|
|
msg.setMsgType((byte) 15);
|
|
|
|
|
dispatch = Dispatch.borrow(player, msg);
|
|
|
|
|
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GuildAlliances ally = this.guildAlliances.get(toGuild.getObjectUUID());
|
|
|
|
|
if (!ally.UpdateAlliance(AllianceType.Ally, this.recommendList.contains(toGuild))){
|
|
|
|
|
if (!ally.UpdateAlliance(AllianceType.Ally, this.recommendList.contains(toGuild))) {
|
|
|
|
|
ErrorPopupMsg.sendErrorMsg(player, "A Serious error has Occured. Please contact CCR!");
|
|
|
|
|
Logger.error( this.getObjectUUID() + " failed to update alliance Database");
|
|
|
|
|
msg.setMsgType((byte)15);
|
|
|
|
|
Logger.error(this.getObjectUUID() + " failed to update alliance Database");
|
|
|
|
|
msg.setMsgType((byte) 15);
|
|
|
|
|
dispatch = Dispatch.borrow(player, msg);
|
|
|
|
|
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
|
|
|
|
return false;
|
|
|
|
@@ -1146,35 +1131,35 @@ Guild.serializeForClientMsg(guild,writer, null, false);
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case Enemy:
|
|
|
|
|
if (enemyList.size() == 10){
|
|
|
|
|
if (enemyList.size() == 10) {
|
|
|
|
|
msg.setMsgType(AllianceChangeMsg.ERROR_TOO_MANY);
|
|
|
|
|
dispatch = Dispatch.borrow(player, msg);
|
|
|
|
|
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (enemyList.contains(toGuild)){
|
|
|
|
|
if (enemyList.contains(toGuild)) {
|
|
|
|
|
ErrorPopupMsg.sendErrorMsg(player, "This guild is already an Enemy!");
|
|
|
|
|
msg.setMsgType((byte)15);
|
|
|
|
|
msg.setMsgType((byte) 15);
|
|
|
|
|
dispatch = Dispatch.borrow(player, msg);
|
|
|
|
|
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!this.guildAlliances.containsKey(toGuild.getObjectUUID())){
|
|
|
|
|
if (!this.guildAlliances.containsKey(toGuild.getObjectUUID())) {
|
|
|
|
|
ErrorPopupMsg.sendErrorMsg(player, "A Serious error has Occured. Please contact CCR!");
|
|
|
|
|
Logger.error( this.getObjectUUID() + " Could not find alliance Guild");
|
|
|
|
|
msg.setMsgType((byte)15);
|
|
|
|
|
Logger.error(this.getObjectUUID() + " Could not find alliance Guild");
|
|
|
|
|
msg.setMsgType((byte) 15);
|
|
|
|
|
dispatch = Dispatch.borrow(player, msg);
|
|
|
|
|
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GuildAlliances enemy = this.guildAlliances.get(toGuild.getObjectUUID());
|
|
|
|
|
if (!enemy.UpdateAlliance(AllianceType.Enemy, this.recommendList.contains(toGuild))){
|
|
|
|
|
if (!enemy.UpdateAlliance(AllianceType.Enemy, this.recommendList.contains(toGuild))) {
|
|
|
|
|
ErrorPopupMsg.sendErrorMsg(player, "A Serious error has Occured. Please contact CCR!");
|
|
|
|
|
Logger.error(this.getObjectUUID() + " failed to update alliance Database");
|
|
|
|
|
msg.setMsgType((byte)15);
|
|
|
|
|
msg.setMsgType((byte) 15);
|
|
|
|
|
dispatch = Dispatch.borrow(player, msg);
|
|
|
|
|
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
|
|
|
|
return false;
|
|
|
|
@@ -1198,28 +1183,24 @@ Guild.serializeForClientMsg(guild,writer, null, false);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public synchronized boolean removeGuildFromAlliance(Guild toRemove){
|
|
|
|
|
if (this.allyList.contains(toRemove)){
|
|
|
|
|
public synchronized boolean removeGuildFromAlliance(Guild toRemove) {
|
|
|
|
|
this.allyList.remove(toRemove);
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
public synchronized boolean removeGuildFromEnemy(Guild toRemove){
|
|
|
|
|
if (this.enemyList.contains(toRemove)){
|
|
|
|
|
|
|
|
|
|
public synchronized boolean removeGuildFromEnemy(Guild toRemove) {
|
|
|
|
|
this.enemyList.remove(toRemove);
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
public synchronized boolean removeGuildFromRecommended(Guild toRemove){
|
|
|
|
|
if (this.recommendList.contains(toRemove)){
|
|
|
|
|
|
|
|
|
|
public synchronized boolean removeGuildFromRecommended(Guild toRemove) {
|
|
|
|
|
this.recommendList.remove(toRemove);
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public synchronized boolean removeGuildFromAllAlliances(Guild toRemove){
|
|
|
|
|
public synchronized boolean removeGuildFromAllAlliances(Guild toRemove) {
|
|
|
|
|
|
|
|
|
|
if (!this.guildAlliances.containsKey(toRemove.getObjectUUID())){
|
|
|
|
|
if (!this.guildAlliances.containsKey(toRemove.getObjectUUID())) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -1227,7 +1208,6 @@ Guild.serializeForClientMsg(guild,writer, null, false);
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.guildAlliances.remove(toRemove.getObjectUUID());
|
|
|
|
|
|
|
|
|
|
this.removeGuildFromAlliance(toRemove);
|
|
|
|
@@ -1241,14 +1221,13 @@ Guild.serializeForClientMsg(guild,writer, null, false);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void UpdateClientAlliances(Guild toUpdate){
|
|
|
|
|
public static void UpdateClientAlliances(Guild toUpdate) {
|
|
|
|
|
UpdateClientAlliancesMsg ucam = new UpdateClientAlliancesMsg(toUpdate);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (PlayerCharacter player : SessionManager.getAllActivePlayerCharacters()) {
|
|
|
|
|
|
|
|
|
|
if (Guild.sameGuild(player.getGuild(), toUpdate)){
|
|
|
|
|
if (Guild.sameGuild(player.getGuild(), toUpdate)) {
|
|
|
|
|
Dispatch dispatch = Dispatch.borrow(player, ucam);
|
|
|
|
|
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
|
|
|
|
}
|
|
|
|
@@ -1257,7 +1236,7 @@ Guild.serializeForClientMsg(guild,writer, null, false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void UpdateClientAlliancesForPlayer(PlayerCharacter toUpdate){
|
|
|
|
|
public static void UpdateClientAlliancesForPlayer(PlayerCharacter toUpdate) {
|
|
|
|
|
UpdateClientAlliancesMsg ucam = new UpdateClientAlliancesMsg(toUpdate.getGuild());
|
|
|
|
|
Dispatch dispatch = Dispatch.borrow(toUpdate, ucam);
|
|
|
|
|
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
|
|
|
@@ -1269,7 +1248,7 @@ Guild.serializeForClientMsg(guild,writer, null, false);
|
|
|
|
|
return (Guild) DbManager.getFromCache(GameObjectType.Guild, id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static ArrayList<PlayerCharacter> GuildRoster(Guild guild){
|
|
|
|
|
public static ArrayList<PlayerCharacter> GuildRoster(Guild guild) {
|
|
|
|
|
ArrayList<PlayerCharacter> roster = new ArrayList<>();
|
|
|
|
|
if (guild == null)
|
|
|
|
|
return roster;
|
|
|
|
@@ -1279,8 +1258,8 @@ Guild.serializeForClientMsg(guild,writer, null, false);
|
|
|
|
|
|
|
|
|
|
if (DbManager.getList(GameObjectType.PlayerCharacter) == null)
|
|
|
|
|
return roster;
|
|
|
|
|
for (AbstractGameObject ago : DbManager.getList(GameObjectType.PlayerCharacter)){
|
|
|
|
|
PlayerCharacter toAdd = (PlayerCharacter)ago;
|
|
|
|
|
for (AbstractGameObject ago : DbManager.getList(GameObjectType.PlayerCharacter)) {
|
|
|
|
|
PlayerCharacter toAdd = (PlayerCharacter) ago;
|
|
|
|
|
|
|
|
|
|
if (!toAdd.getGuild().equals(guild))
|
|
|
|
|
continue;
|
|
|
|
@@ -1295,5 +1274,4 @@ Guild.serializeForClientMsg(guild,writer, null, false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|