Refactor WOO change timer mechanics to use the same system as the mine claims. Moved both resets to the hourly job.
This commit is contained in:
@@ -115,13 +115,6 @@ public class dbGuildHandler extends dbHandlerBase {
|
|||||||
return outputStr;
|
return outputStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean SET_LAST_WOO_UPDATE(Guild guild, LocalDateTime lastEditTime) {
|
|
||||||
prepareCallable("UPDATE `obj_guild` SET `lastWooEditTime`=? WHERE `UID`=?");
|
|
||||||
setLocalDateTime(1, lastEditTime);
|
|
||||||
setLong(2, (long) guild.getObjectUUID());
|
|
||||||
return (executeUpdate() > 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ArrayList<Guild> GET_GUILD_ALLIES(final int id) {
|
public ArrayList<Guild> GET_GUILD_ALLIES(final int id) {
|
||||||
prepareCallable("SELECT g.* FROM `obj_guild` g, `dyn_guild_allianceenemylist` l "
|
prepareCallable("SELECT g.* FROM `obj_guild` g, `dyn_guild_allianceenemylist` l "
|
||||||
+ "WHERE l.isAlliance = 1 && l.OtherGuildID = g.UID && l.GuildID=?");
|
+ "WHERE l.isAlliance = 1 && l.OtherGuildID = g.UID && l.GuildID=?");
|
||||||
|
|||||||
@@ -81,10 +81,10 @@ public class MineWindowChangeHandler extends AbstractClientMsgHandler {
|
|||||||
if (newMineTime == 24)
|
if (newMineTime == 24)
|
||||||
newMineTime = 0;
|
newMineTime = 0;
|
||||||
|
|
||||||
// Enforce 15hr restriction between WOO edits
|
// Enforce time restriction between WOO edits
|
||||||
|
|
||||||
if (LocalDateTime.now().isBefore(mineGuild.lastWooEditTime.plusHours(14))) {
|
if (mineGuild.wooWasModified) {
|
||||||
ErrorPopupMsg.sendErrorMsg(playerCharacter, "You must wait 15 hours between WOO changes.");
|
ErrorPopupMsg.sendErrorMsg(playerCharacter, "You can only modify your WOO once per day.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,15 +110,7 @@ public class MineWindowChangeHandler extends AbstractClientMsgHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mineGuild.setMineTime(newMineTime);
|
mineGuild.setMineTime(newMineTime);
|
||||||
mineGuild.lastWooEditTime = LocalDateTime.now();
|
mineGuild.wooWasModified = true;
|
||||||
|
|
||||||
// Update guild WOO timer for reboot persistence
|
|
||||||
|
|
||||||
if (!DbManager.GuildQueries.SET_LAST_WOO_UPDATE(mineGuild, mineGuild.lastWooEditTime)) {
|
|
||||||
Logger.error("MineWindowChange", "Failed to update woo timer for guild " + mineGuild.getObjectUUID());
|
|
||||||
ChatManager.chatGuildError(playerCharacter, "A Serious error has for to occurred.");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
ChatManager.chatGuildInfo(playerCharacter, "Mine time updated.");
|
ChatManager.chatGuildInfo(playerCharacter, "Mine time updated.");
|
||||||
|
|
||||||
|
|||||||
+103
-125
@@ -7,9 +7,6 @@
|
|||||||
// www.magicbane.com
|
// www.magicbane.com
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ .
|
||||||
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
|
||||||
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
|
||||||
@@ -43,7 +40,6 @@ import java.sql.SQLException;
|
|||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
@@ -77,15 +73,15 @@ public class Guild extends AbstractWorldObject {
|
|||||||
private ArrayList<Guild> subGuildList;
|
private ArrayList<Guild> subGuildList;
|
||||||
private int nationUUID = 0;
|
private int nationUUID = 0;
|
||||||
private GuildState guildState = GuildState.Errant;
|
private GuildState guildState = GuildState.Errant;
|
||||||
private ConcurrentHashMap<Integer,Condemned> guildCondemned = new ConcurrentHashMap<>();
|
private final ConcurrentHashMap<Integer, Condemned> guildCondemned = new ConcurrentHashMap<>();
|
||||||
private String hash;
|
private String hash;
|
||||||
private boolean ownerIsNPC;
|
private boolean ownerIsNPC;
|
||||||
|
|
||||||
private static Guild errantGuild;
|
private static Guild errantGuild;
|
||||||
private static Guild errantNation;
|
private static Guild errantNation;
|
||||||
|
|
||||||
public LocalDateTime lastWooEditTime;
|
public boolean wooWasModified;
|
||||||
public HashMap<Integer,GuildAlliances> guildAlliances = new HashMap<>();
|
public HashMap<Integer, GuildAlliances> guildAlliances = new HashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* No Id Constructor
|
* No Id Constructor
|
||||||
@@ -121,7 +117,7 @@ public class Guild extends AbstractWorldObject {
|
|||||||
/**
|
/**
|
||||||
* Normal Constructor
|
* Normal Constructor
|
||||||
*/
|
*/
|
||||||
public Guild( String name, Guild nat, int charter,
|
public Guild(String name, Guild nat, int charter,
|
||||||
String leadershipType, GuildTag gt, int newUUID) {
|
String leadershipType, GuildTag gt, int newUUID) {
|
||||||
super(newUUID);
|
super(newUUID);
|
||||||
this.name = name;
|
this.name = name;
|
||||||
@@ -182,11 +178,7 @@ public class Guild extends AbstractWorldObject {
|
|||||||
this.teleportMax = rs.getInt("teleportMax");
|
this.teleportMax = rs.getInt("teleportMax");
|
||||||
|
|
||||||
this.mineTime = rs.getInt("mineTime");
|
this.mineTime = rs.getInt("mineTime");
|
||||||
|
this.wooWasModified = false;
|
||||||
Timestamp lastWooRequest = rs.getTimestamp("lastWooEditTime");
|
|
||||||
|
|
||||||
if (lastWooRequest != null)
|
|
||||||
this.lastWooEditTime = lastWooRequest.toLocalDateTime();
|
|
||||||
|
|
||||||
this.hash = rs.getString("hash");
|
this.hash = rs.getString("hash");
|
||||||
}
|
}
|
||||||
@@ -333,9 +325,9 @@ public class Guild extends AbstractWorldObject {
|
|||||||
if (this.isErrant())
|
if (this.isErrant())
|
||||||
return false;
|
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))
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -346,7 +338,7 @@ public class Guild extends AbstractWorldObject {
|
|||||||
oldGuildLeader.setGuildLeader(false);
|
oldGuildLeader.setGuildLeader(false);
|
||||||
|
|
||||||
if (ac.getObjectType().equals(GameObjectType.PlayerCharacter))
|
if (ac.getObjectType().equals(GameObjectType.PlayerCharacter))
|
||||||
((PlayerCharacter)ac).setGuildLeader(true);
|
((PlayerCharacter) ac).setGuildLeader(true);
|
||||||
this.guildLeaderUUID = ac.getObjectUUID();
|
this.guildLeaderUUID = ac.getObjectUUID();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -360,7 +352,7 @@ public class Guild extends AbstractWorldObject {
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (ac.getObjectType().equals(GameObjectType.PlayerCharacter))
|
if (ac.getObjectType().equals(GameObjectType.PlayerCharacter))
|
||||||
((PlayerCharacter)ac).setGuildLeader(true);
|
((PlayerCharacter) ac).setGuildLeader(true);
|
||||||
this.guildLeaderUUID = ac.getObjectUUID();
|
this.guildLeaderUUID = ac.getObjectUUID();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -411,10 +403,9 @@ public class Guild extends AbstractWorldObject {
|
|||||||
|
|
||||||
public boolean isErrant() {
|
public boolean isErrant() {
|
||||||
return this.getObjectUUID() == Guild.errantGuild.getObjectUUID();
|
return this.getObjectUUID() == Guild.errantGuild.getObjectUUID();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static boolean sameGuild(Guild a, Guild b) {
|
public static boolean sameGuild(Guild a, Guild b) {
|
||||||
if (a == null || b == null)
|
if (a == null || b == null)
|
||||||
return false;
|
return false;
|
||||||
@@ -475,14 +466,14 @@ public class Guild extends AbstractWorldObject {
|
|||||||
public void removePlayer(PlayerCharacter pc, GuildHistoryType historyType) {
|
public void removePlayer(PlayerCharacter pc, GuildHistoryType historyType) {
|
||||||
|
|
||||||
if (this.isErrant()) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Add to Guild History
|
//Add to Guild History
|
||||||
if (pc.getGuild() != null){
|
if (pc.getGuild() != null) {
|
||||||
if (DbManager.GuildQueries.ADD_TO_GUILDHISTORY(pc.getGuildUUID(), pc, DateTime.now(), historyType)){
|
if (DbManager.GuildQueries.ADD_TO_GUILDHISTORY(pc.getGuildUUID(), pc, DateTime.now(), historyType)) {
|
||||||
GuildHistory guildHistory = new GuildHistory(pc.getGuildUUID(), pc.getGuild().name,DateTime.now(), historyType) ;
|
GuildHistory guildHistory = new GuildHistory(pc.getGuildUUID(), pc.getGuild().name, DateTime.now(), historyType);
|
||||||
pc.getGuildHistory().add(guildHistory);
|
pc.getGuildHistory().add(guildHistory);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -496,12 +487,12 @@ public class Guild extends AbstractWorldObject {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void upgradeGuildState(boolean nation){
|
public void upgradeGuildState(boolean nation) {
|
||||||
if (nation){
|
if (nation) {
|
||||||
this.guildState = GuildState.Nation;
|
this.guildState = GuildState.Nation;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
switch(this.guildState){
|
switch (this.guildState) {
|
||||||
|
|
||||||
case Errant:
|
case Errant:
|
||||||
this.guildState = GuildState.Petitioner;
|
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:
|
case Errant:
|
||||||
break;
|
break;
|
||||||
case Sworn:
|
case Sworn:
|
||||||
@@ -555,13 +546,13 @@ public class Guild extends AbstractWorldObject {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canSubAGuild(Guild toSub){
|
public boolean canSubAGuild(Guild toSub) {
|
||||||
|
|
||||||
boolean canSub;
|
boolean canSub;
|
||||||
|
|
||||||
if (this.equals(toSub))
|
if (this.equals(toSub))
|
||||||
return false;
|
return false;
|
||||||
switch(this.guildState) {
|
switch (this.guildState) {
|
||||||
case Nation:
|
case Nation:
|
||||||
case Sovereign:
|
case Sovereign:
|
||||||
canSub = true;
|
canSub = true;
|
||||||
@@ -570,7 +561,7 @@ public class Guild extends AbstractWorldObject {
|
|||||||
canSub = false;
|
canSub = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(toSub.guildState){
|
switch (toSub.guildState) {
|
||||||
case Errant:
|
case Errant:
|
||||||
case Sovereign:
|
case Sovereign:
|
||||||
canSub = true;
|
canSub = true;
|
||||||
@@ -585,11 +576,11 @@ public class Guild extends AbstractWorldObject {
|
|||||||
return canSub;
|
return canSub;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean canSwearIn(Guild toSub){
|
public static boolean canSwearIn(Guild toSub) {
|
||||||
|
|
||||||
boolean canSwear = false;
|
boolean canSwear = false;
|
||||||
|
|
||||||
switch(toSub.guildState){
|
switch (toSub.guildState) {
|
||||||
|
|
||||||
case Protectorate:
|
case Protectorate:
|
||||||
case Petitioner:
|
case Petitioner:
|
||||||
@@ -607,7 +598,7 @@ public class Guild extends AbstractWorldObject {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
public static void _serializeForClientMsg(Guild guild, ByteBufferWriter writer) {
|
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) {
|
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();
|
City ownedCity = guild.getOwnedCity();
|
||||||
|
|
||||||
if (ownedCity != null){
|
if (ownedCity != null) {
|
||||||
Realm realm = guild.getOwnedCity().getRealm();
|
Realm realm = guild.getOwnedCity().getRealm();
|
||||||
if (realm != null && realm.getRulingCity() != null){
|
if (realm != null && realm.getRulingCity() != null) {
|
||||||
if (realm.getRulingCity().equals(ownedCity)){
|
if (realm.getRulingCity().equals(ownedCity)) {
|
||||||
writer.putInt(realm.getCharterType());
|
writer.putInt(realm.getCharterType());
|
||||||
}else
|
} else
|
||||||
writer.putInt(0);
|
writer.putInt(0);
|
||||||
}else{
|
} else {
|
||||||
writer.putInt(0);
|
writer.putInt(0);
|
||||||
}
|
}
|
||||||
}else
|
} else
|
||||||
writer.putInt(0);
|
writer.putInt(0);
|
||||||
|
|
||||||
writer.putFloat(200);
|
writer.putFloat(200);
|
||||||
writer.putFloat(200); // Pad
|
writer.putFloat(200); // Pad
|
||||||
|
|
||||||
GuildTag._serializeForDisplay(guild.guildTag,writer);
|
GuildTag._serializeForDisplay(guild.guildTag, writer);
|
||||||
GuildTag._serializeForDisplay(guild.nation.guildTag,writer);
|
GuildTag._serializeForDisplay(guild.nation.guildTag, writer);
|
||||||
if (reshowGuild) {
|
if (reshowGuild) {
|
||||||
writer.putInt(1);
|
writer.putInt(1);
|
||||||
writer.putInt(guild.getObjectType().ordinal());
|
writer.putInt(guild.getObjectType().ordinal());
|
||||||
@@ -662,10 +653,10 @@ Guild.serializeForClientMsg(guild,writer, null, false);
|
|||||||
writer.putInt(0); // Pad
|
writer.putInt(0); // Pad
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void serializeForTrack(Guild guild,ByteBufferWriter writer) {
|
public static void serializeForTrack(Guild guild, ByteBufferWriter writer) {
|
||||||
Guild.serializeGuildForTrack(guild,writer);
|
Guild.serializeGuildForTrack(guild, writer);
|
||||||
if (guild.nation != null)
|
if (guild.nation != null)
|
||||||
Guild.serializeGuildForTrack(guild.nation,writer);
|
Guild.serializeGuildForTrack(guild.nation, writer);
|
||||||
else
|
else
|
||||||
Guild.addErrantForTrack(writer);
|
Guild.addErrantForTrack(writer);
|
||||||
}
|
}
|
||||||
@@ -674,7 +665,7 @@ Guild.serializeForClientMsg(guild,writer, null, false);
|
|||||||
writer.putInt(guild.getObjectType().ordinal());
|
writer.putInt(guild.getObjectType().ordinal());
|
||||||
writer.putInt(guild.getObjectUUID());
|
writer.putInt(guild.getObjectUUID());
|
||||||
writer.put((byte) 1);
|
writer.put((byte) 1);
|
||||||
GuildTag._serializeForDisplay(guild.guildTag,writer);
|
GuildTag._serializeForDisplay(guild.guildTag, writer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void serializeErrantForTrack(ByteBufferWriter writer) {
|
public static void serializeErrantForTrack(ByteBufferWriter writer) {
|
||||||
@@ -682,9 +673,9 @@ Guild.serializeForClientMsg(guild,writer, null, false);
|
|||||||
addErrantForTrack(writer); //Nation
|
addErrantForTrack(writer); //Nation
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getRealmsOwnedFlag(){
|
public int getRealmsOwnedFlag() {
|
||||||
int flag = 0;
|
int flag = 0;
|
||||||
switch(realmsOwned){
|
switch (realmsOwned) {
|
||||||
case 0:
|
case 0:
|
||||||
flag = 0;
|
flag = 0;
|
||||||
case 1:
|
case 1:
|
||||||
@@ -727,7 +718,7 @@ Guild.serializeForClientMsg(guild,writer, null, false);
|
|||||||
public static Guild getErrantGuild() {
|
public static Guild getErrantGuild() {
|
||||||
|
|
||||||
if (Guild.errantGuild == null)
|
if (Guild.errantGuild == null)
|
||||||
Guild.errantGuild = new Guild( "None", Guild.getErrantNation(), 0,
|
Guild.errantGuild = new Guild("None", Guild.getErrantNation(), 0,
|
||||||
"Anarchy", GuildTag.ERRANT, 0);
|
"Anarchy", GuildTag.ERRANT, 0);
|
||||||
|
|
||||||
return Guild.errantGuild;
|
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.
|
//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)
|
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)
|
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
|
// 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.
|
//Get guild states.
|
||||||
try {
|
try {
|
||||||
this.subGuildList = DbManager.GuildQueries.GET_SUB_GUILDS(this.getObjectUUID());
|
this.subGuildList = DbManager.GuildQueries.GET_SUB_GUILDS(this.getObjectUUID());
|
||||||
}catch(Exception e){
|
} catch (Exception e) {
|
||||||
|
|
||||||
this.subGuildList = new ArrayList<>();
|
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)
|
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.
|
//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?!?!
|
//possible runAfterLoad being called twice?!?!
|
||||||
@@ -873,25 +864,25 @@ Guild.serializeForClientMsg(guild,writer, null, false);
|
|||||||
this.enemyList.clear();
|
this.enemyList.clear();
|
||||||
this.recommendList.clear();
|
this.recommendList.clear();
|
||||||
|
|
||||||
try{
|
try {
|
||||||
DbManager.GuildQueries.LOAD_ALL_ALLIANCES_FOR_GUILD(this);
|
DbManager.GuildQueries.LOAD_ALL_ALLIANCES_FOR_GUILD(this);
|
||||||
for (GuildAlliances guildAlliance:this.guildAlliances.values()){
|
for (GuildAlliances guildAlliance : this.guildAlliances.values()) {
|
||||||
if (guildAlliance.isRecommended()){
|
if (guildAlliance.isRecommended()) {
|
||||||
Guild recommendedGuild = Guild.getGuild(guildAlliance.getAllianceGuild());
|
Guild recommendedGuild = Guild.getGuild(guildAlliance.getAllianceGuild());
|
||||||
if (recommendedGuild != null)
|
if (recommendedGuild != null)
|
||||||
this.recommendList.add(recommendedGuild);
|
this.recommendList.add(recommendedGuild);
|
||||||
}else if (guildAlliance.isAlly()){
|
} else if (guildAlliance.isAlly()) {
|
||||||
Guild alliedGuild = Guild.getGuild(guildAlliance.getAllianceGuild());
|
Guild alliedGuild = Guild.getGuild(guildAlliance.getAllianceGuild());
|
||||||
if (alliedGuild != null)
|
if (alliedGuild != null)
|
||||||
this.allyList.add(alliedGuild);
|
this.allyList.add(alliedGuild);
|
||||||
}else{
|
} else {
|
||||||
Guild enemyGuild = Guild.getGuild(guildAlliance.getAllianceGuild());
|
Guild enemyGuild = Guild.getGuild(guildAlliance.getAllianceGuild());
|
||||||
if (enemyGuild != null)
|
if (enemyGuild != null)
|
||||||
this.enemyList.add(enemyGuild);
|
this.enemyList.add(enemyGuild);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}catch(Exception e){
|
} catch (Exception e) {
|
||||||
Logger.error(this.getObjectUUID() + e.getMessage());
|
Logger.error(this.getObjectUUID() + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -937,8 +928,7 @@ Guild.serializeForClientMsg(guild,writer, null, false);
|
|||||||
|
|
||||||
if (subGuild.getOwnedCity() == null) {
|
if (subGuild.getOwnedCity() == null) {
|
||||||
subGuild.nation = null;
|
subGuild.nation = null;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
subGuild.nation = subGuild;
|
subGuild.nation = subGuild;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -959,7 +949,7 @@ Guild.serializeForClientMsg(guild,writer, null, false);
|
|||||||
this.mineTime = mineTime;
|
this.mineTime = mineTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConcurrentHashMap<Integer,Condemned> getGuildCondemned() {
|
public ConcurrentHashMap<Integer, Condemned> getGuildCondemned() {
|
||||||
return guildCondemned;
|
return guildCondemned;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -974,10 +964,10 @@ Guild.serializeForClientMsg(guild,writer, null, false);
|
|||||||
DataWarehouse.writeHash(Enum.DataRecordType.GUILD, this.getObjectUUID());
|
DataWarehouse.writeHash(Enum.DataRecordType.GUILD, this.getObjectUUID());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Enum.GuildType getGuildType(){
|
public Enum.GuildType getGuildType() {
|
||||||
try{
|
try {
|
||||||
return Enum.GuildType.values()[this.charter];
|
return Enum.GuildType.values()[this.charter];
|
||||||
}catch(Exception e){
|
} catch (Exception e) {
|
||||||
Logger.error(e);
|
Logger.error(e);
|
||||||
return Enum.GuildType.NONE;
|
return Enum.GuildType.NONE;
|
||||||
}
|
}
|
||||||
@@ -992,7 +982,7 @@ Guild.serializeForClientMsg(guild,writer, null, false);
|
|||||||
this.recommendList = recommendList;
|
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;
|
Dispatch dispatch;
|
||||||
|
|
||||||
@@ -1002,7 +992,7 @@ Guild.serializeForClientMsg(guild,writer, null, false);
|
|||||||
if (toGuild == null)
|
if (toGuild == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!Guild.sameGuild(player.getGuild(), this)){
|
if (!Guild.sameGuild(player.getGuild(), this)) {
|
||||||
msg.setMsgType(AllianceChangeMsg.ERROR_NOT_SAME_GUILD);
|
msg.setMsgType(AllianceChangeMsg.ERROR_NOT_SAME_GUILD);
|
||||||
dispatch = Dispatch.borrow(player, msg);
|
dispatch = Dispatch.borrow(player, msg);
|
||||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||||
@@ -1010,15 +1000,15 @@ Guild.serializeForClientMsg(guild,writer, null, false);
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (allianceType == AllianceType.Ally || allianceType == AllianceType.Enemy)
|
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);
|
msg.setMsgType(AllianceChangeMsg.ERROR_NOT_AUTHORIZED);
|
||||||
dispatch = Dispatch.borrow(player, msg);
|
dispatch = Dispatch.borrow(player, msg);
|
||||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (allianceType == AllianceType.RecommendedAlly || allianceType == AllianceType.RecommendedEnemy){
|
if (allianceType == AllianceType.RecommendedAlly || allianceType == AllianceType.RecommendedEnemy) {
|
||||||
if (!GuildStatusController.isFullMember(player.getGuildStatus())){
|
if (!GuildStatusController.isFullMember(player.getGuildStatus())) {
|
||||||
msg.setMsgType(AllianceChangeMsg.ERROR_NOT_AUTHORIZED);
|
msg.setMsgType(AllianceChangeMsg.ERROR_NOT_AUTHORIZED);
|
||||||
dispatch = Dispatch.borrow(player, msg);
|
dispatch = Dispatch.borrow(player, msg);
|
||||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||||
@@ -1034,29 +1024,25 @@ Guild.serializeForClientMsg(guild,writer, null, false);
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
switch (allianceType) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
switch(allianceType){
|
|
||||||
case RecommendedAlly:
|
case RecommendedAlly:
|
||||||
if (recommendList.size() == 10){
|
if (recommendList.size() == 10) {
|
||||||
msg.setMsgType(AllianceChangeMsg.ERROR_TOO_MANY);
|
msg.setMsgType(AllianceChangeMsg.ERROR_TOO_MANY);
|
||||||
dispatch = Dispatch.borrow(player, msg);
|
dispatch = Dispatch.borrow(player, msg);
|
||||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (recommendList.contains(toGuild)){
|
if (recommendList.contains(toGuild)) {
|
||||||
ErrorPopupMsg.sendErrorMsg(player, "This guild is already recommonded!");
|
ErrorPopupMsg.sendErrorMsg(player, "This guild is already recommonded!");
|
||||||
msg.setMsgType((byte)15);
|
msg.setMsgType((byte) 15);
|
||||||
dispatch = Dispatch.borrow(player, msg);
|
dispatch = Dispatch.borrow(player, msg);
|
||||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!DbManager.GuildQueries.ADD_TO_ALLIANCE_LIST(this.getObjectUUID(), toGuild.getObjectUUID(), true, true, player.getFirstName())){
|
if (!DbManager.GuildQueries.ADD_TO_ALLIANCE_LIST(this.getObjectUUID(), toGuild.getObjectUUID(), true, true, player.getFirstName())) {
|
||||||
msg.setMsgType((byte)15);
|
msg.setMsgType((byte) 15);
|
||||||
dispatch = Dispatch.borrow(player, msg);
|
dispatch = Dispatch.borrow(player, msg);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -1068,27 +1054,26 @@ Guild.serializeForClientMsg(guild,writer, null, false);
|
|||||||
this.recommendList.add(toGuild);
|
this.recommendList.add(toGuild);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case RecommendedEnemy:
|
case RecommendedEnemy:
|
||||||
if (recommendList.size() == 10){
|
if (recommendList.size() == 10) {
|
||||||
msg.setMsgType(AllianceChangeMsg.ERROR_TOO_MANY);
|
msg.setMsgType(AllianceChangeMsg.ERROR_TOO_MANY);
|
||||||
dispatch = Dispatch.borrow(player, msg);
|
dispatch = Dispatch.borrow(player, msg);
|
||||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (recommendList.contains(toGuild)){
|
if (recommendList.contains(toGuild)) {
|
||||||
ErrorPopupMsg.sendErrorMsg(player, "This guild is already recommonded!");
|
ErrorPopupMsg.sendErrorMsg(player, "This guild is already recommonded!");
|
||||||
msg.setMsgType((byte)15);
|
msg.setMsgType((byte) 15);
|
||||||
dispatch = Dispatch.borrow(player, msg);
|
dispatch = Dispatch.borrow(player, msg);
|
||||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!DbManager.GuildQueries.ADD_TO_ALLIANCE_LIST(this.getObjectUUID(), toGuild.getObjectUUID(), true, false, player.getFirstName())){
|
if (!DbManager.GuildQueries.ADD_TO_ALLIANCE_LIST(this.getObjectUUID(), toGuild.getObjectUUID(), true, false, player.getFirstName())) {
|
||||||
msg.setMsgType((byte)15);
|
msg.setMsgType((byte) 15);
|
||||||
dispatch = Dispatch.borrow(player, msg);
|
dispatch = Dispatch.borrow(player, msg);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -1102,35 +1087,35 @@ Guild.serializeForClientMsg(guild,writer, null, false);
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
case Ally:
|
case Ally:
|
||||||
if (allyList.size() == 10){
|
if (allyList.size() == 10) {
|
||||||
msg.setMsgType(AllianceChangeMsg.ERROR_TOO_MANY);
|
msg.setMsgType(AllianceChangeMsg.ERROR_TOO_MANY);
|
||||||
dispatch = Dispatch.borrow(player, msg);
|
dispatch = Dispatch.borrow(player, msg);
|
||||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (allyList.contains(toGuild)){
|
if (allyList.contains(toGuild)) {
|
||||||
ErrorPopupMsg.sendErrorMsg(player, "This guild is already an Ally!");
|
ErrorPopupMsg.sendErrorMsg(player, "This guild is already an Ally!");
|
||||||
msg.setMsgType((byte)15);
|
msg.setMsgType((byte) 15);
|
||||||
dispatch = Dispatch.borrow(player, msg);
|
dispatch = Dispatch.borrow(player, msg);
|
||||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||||
return false;
|
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!");
|
ErrorPopupMsg.sendErrorMsg(player, "A Serious error has Occured. Please contact CCR!");
|
||||||
Logger.error(this.getObjectUUID() + " Could not find alliance Guild");
|
Logger.error(this.getObjectUUID() + " Could not find alliance Guild");
|
||||||
msg.setMsgType((byte)15);
|
msg.setMsgType((byte) 15);
|
||||||
dispatch = Dispatch.borrow(player, msg);
|
dispatch = Dispatch.borrow(player, msg);
|
||||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
GuildAlliances ally = this.guildAlliances.get(toGuild.getObjectUUID());
|
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!");
|
ErrorPopupMsg.sendErrorMsg(player, "A Serious error has Occured. Please contact CCR!");
|
||||||
Logger.error( this.getObjectUUID() + " failed to update alliance Database");
|
Logger.error(this.getObjectUUID() + " failed to update alliance Database");
|
||||||
msg.setMsgType((byte)15);
|
msg.setMsgType((byte) 15);
|
||||||
dispatch = Dispatch.borrow(player, msg);
|
dispatch = Dispatch.borrow(player, msg);
|
||||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||||
return false;
|
return false;
|
||||||
@@ -1146,35 +1131,35 @@ Guild.serializeForClientMsg(guild,writer, null, false);
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
case Enemy:
|
case Enemy:
|
||||||
if (enemyList.size() == 10){
|
if (enemyList.size() == 10) {
|
||||||
msg.setMsgType(AllianceChangeMsg.ERROR_TOO_MANY);
|
msg.setMsgType(AllianceChangeMsg.ERROR_TOO_MANY);
|
||||||
dispatch = Dispatch.borrow(player, msg);
|
dispatch = Dispatch.borrow(player, msg);
|
||||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (enemyList.contains(toGuild)){
|
if (enemyList.contains(toGuild)) {
|
||||||
ErrorPopupMsg.sendErrorMsg(player, "This guild is already an Enemy!");
|
ErrorPopupMsg.sendErrorMsg(player, "This guild is already an Enemy!");
|
||||||
msg.setMsgType((byte)15);
|
msg.setMsgType((byte) 15);
|
||||||
dispatch = Dispatch.borrow(player, msg);
|
dispatch = Dispatch.borrow(player, msg);
|
||||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||||
return false;
|
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!");
|
ErrorPopupMsg.sendErrorMsg(player, "A Serious error has Occured. Please contact CCR!");
|
||||||
Logger.error( this.getObjectUUID() + " Could not find alliance Guild");
|
Logger.error(this.getObjectUUID() + " Could not find alliance Guild");
|
||||||
msg.setMsgType((byte)15);
|
msg.setMsgType((byte) 15);
|
||||||
dispatch = Dispatch.borrow(player, msg);
|
dispatch = Dispatch.borrow(player, msg);
|
||||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
GuildAlliances enemy = this.guildAlliances.get(toGuild.getObjectUUID());
|
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!");
|
ErrorPopupMsg.sendErrorMsg(player, "A Serious error has Occured. Please contact CCR!");
|
||||||
Logger.error(this.getObjectUUID() + " failed to update alliance Database");
|
Logger.error(this.getObjectUUID() + " failed to update alliance Database");
|
||||||
msg.setMsgType((byte)15);
|
msg.setMsgType((byte) 15);
|
||||||
dispatch = Dispatch.borrow(player, msg);
|
dispatch = Dispatch.borrow(player, msg);
|
||||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||||
return false;
|
return false;
|
||||||
@@ -1198,28 +1183,24 @@ Guild.serializeForClientMsg(guild,writer, null, false);
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized boolean removeGuildFromAlliance(Guild toRemove){
|
public synchronized boolean removeGuildFromAlliance(Guild toRemove) {
|
||||||
if (this.allyList.contains(toRemove)){
|
|
||||||
this.allyList.remove(toRemove);
|
this.allyList.remove(toRemove);
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
public synchronized boolean removeGuildFromEnemy(Guild toRemove){
|
|
||||||
if (this.enemyList.contains(toRemove)){
|
public synchronized boolean removeGuildFromEnemy(Guild toRemove) {
|
||||||
this.enemyList.remove(toRemove);
|
this.enemyList.remove(toRemove);
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
public synchronized boolean removeGuildFromRecommended(Guild toRemove){
|
|
||||||
if (this.recommendList.contains(toRemove)){
|
public synchronized boolean removeGuildFromRecommended(Guild toRemove) {
|
||||||
this.recommendList.remove(toRemove);
|
this.recommendList.remove(toRemove);
|
||||||
}
|
|
||||||
return true;
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1227,7 +1208,6 @@ Guild.serializeForClientMsg(guild,writer, null, false);
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
this.guildAlliances.remove(toRemove.getObjectUUID());
|
this.guildAlliances.remove(toRemove.getObjectUUID());
|
||||||
|
|
||||||
this.removeGuildFromAlliance(toRemove);
|
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);
|
UpdateClientAlliancesMsg ucam = new UpdateClientAlliancesMsg(toUpdate);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for (PlayerCharacter player : SessionManager.getAllActivePlayerCharacters()) {
|
for (PlayerCharacter player : SessionManager.getAllActivePlayerCharacters()) {
|
||||||
|
|
||||||
if (Guild.sameGuild(player.getGuild(), toUpdate)){
|
if (Guild.sameGuild(player.getGuild(), toUpdate)) {
|
||||||
Dispatch dispatch = Dispatch.borrow(player, ucam);
|
Dispatch dispatch = Dispatch.borrow(player, ucam);
|
||||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
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());
|
UpdateClientAlliancesMsg ucam = new UpdateClientAlliancesMsg(toUpdate.getGuild());
|
||||||
Dispatch dispatch = Dispatch.borrow(toUpdate, ucam);
|
Dispatch dispatch = Dispatch.borrow(toUpdate, ucam);
|
||||||
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
DispatchMessage.dispatchMsgDispatch(dispatch, Enum.DispatchChannel.SECONDARY);
|
||||||
@@ -1269,7 +1248,7 @@ Guild.serializeForClientMsg(guild,writer, null, false);
|
|||||||
return (Guild) DbManager.getFromCache(GameObjectType.Guild, id);
|
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<>();
|
ArrayList<PlayerCharacter> roster = new ArrayList<>();
|
||||||
if (guild == null)
|
if (guild == null)
|
||||||
return roster;
|
return roster;
|
||||||
@@ -1279,8 +1258,8 @@ Guild.serializeForClientMsg(guild,writer, null, false);
|
|||||||
|
|
||||||
if (DbManager.getList(GameObjectType.PlayerCharacter) == null)
|
if (DbManager.getList(GameObjectType.PlayerCharacter) == null)
|
||||||
return roster;
|
return roster;
|
||||||
for (AbstractGameObject ago : DbManager.getList(GameObjectType.PlayerCharacter)){
|
for (AbstractGameObject ago : DbManager.getList(GameObjectType.PlayerCharacter)) {
|
||||||
PlayerCharacter toAdd = (PlayerCharacter)ago;
|
PlayerCharacter toAdd = (PlayerCharacter) ago;
|
||||||
|
|
||||||
if (!toAdd.getGuild().equals(guild))
|
if (!toAdd.getGuild().equals(guild))
|
||||||
continue;
|
continue;
|
||||||
@@ -1295,5 +1274,4 @@ Guild.serializeForClientMsg(guild,writer, null, false);
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -793,7 +793,7 @@ public class MBServerStatics {
|
|||||||
public static final int MAX_PLAYER_LOAD_SIZE = 1000;
|
public static final int MAX_PLAYER_LOAD_SIZE = 1000;
|
||||||
|
|
||||||
// Mine related
|
// Mine related
|
||||||
public static final int MINE_EARLY_WINDOW = 16; // 3pm
|
public static final int MINE_EARLY_WINDOW = 16; // 4pm
|
||||||
public static final int MINE_LATE_WINDOW = 0; // Midnight
|
public static final int MINE_LATE_WINDOW = 0; // Midnight
|
||||||
|
|
||||||
// Race
|
// Race
|
||||||
|
|||||||
@@ -22,9 +22,11 @@ import java.time.LocalDateTime;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
import static engine.server.MBServerStatics.MINE_LATE_WINDOW;
|
||||||
|
|
||||||
public class HourlyJobThread implements Runnable {
|
public class HourlyJobThread implements Runnable {
|
||||||
|
|
||||||
private static int hotzoneCount = 0;
|
private static final int hotzoneCount = 0;
|
||||||
|
|
||||||
public HourlyJobThread() {
|
public HourlyJobThread() {
|
||||||
|
|
||||||
@@ -42,20 +44,22 @@ public class HourlyJobThread implements Runnable {
|
|||||||
Zone hotzone = ZoneManager.getHotZone();
|
Zone hotzone = ZoneManager.getHotZone();
|
||||||
|
|
||||||
if (hotzone == null) {
|
if (hotzone == null) {
|
||||||
Logger.error( "Null hotzone returned from mapmanager");
|
Logger.error("Null hotzone returned from mapmanager");
|
||||||
} else {
|
} else {
|
||||||
Logger.info( "new hotzone: " + hotzone.getName());
|
Logger.info("new hotzone: " + hotzone.getName());
|
||||||
WorldServer.setLastHZChange(System.currentTimeMillis());
|
WorldServer.setLastHZChange(System.currentTimeMillis());
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Logger.error( e.toString());
|
Logger.error(e.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Open or Close mines for the current mine window.
|
// Open or Close mines for the current mine window.
|
||||||
|
|
||||||
processMineWindow();
|
processMineWindow();
|
||||||
|
|
||||||
|
// Deposit mine resources to Guilds
|
||||||
|
|
||||||
for (Mine mine : Mine.getMines()) {
|
for (Mine mine : Mine.getMines()) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -65,6 +69,33 @@ public class HourlyJobThread implements Runnable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Reset time-gated access to WOO slider.
|
||||||
|
// *** Do this after the mines open/close!
|
||||||
|
|
||||||
|
if (LocalDateTime.now().getHour() == MINE_LATE_WINDOW) {
|
||||||
|
Guild guild;
|
||||||
|
|
||||||
|
for (AbstractGameObject dbObject : DbManager.getList(Enum.GameObjectType.Guild)) {
|
||||||
|
guild = (Guild) dbObject;
|
||||||
|
|
||||||
|
if (guild != null)
|
||||||
|
guild.wooWasModified = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Mines can only be claimed once per cycle.
|
||||||
|
// This will reset at 1am after the last mine
|
||||||
|
// window closes.
|
||||||
|
|
||||||
|
if (LocalDateTime.now().getHour() == MINE_LATE_WINDOW + 1) {
|
||||||
|
|
||||||
|
for (Mine mine : Mine.getMines()) {
|
||||||
|
|
||||||
|
if (mine.wasClaimed == true)
|
||||||
|
mine.wasClaimed = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Update city population values
|
// Update city population values
|
||||||
|
|
||||||
@@ -72,9 +103,9 @@ public class HourlyJobThread implements Runnable {
|
|||||||
|
|
||||||
if (map != null) {
|
if (map != null) {
|
||||||
|
|
||||||
for (AbstractGameObject ago : map.values()){
|
for (AbstractGameObject ago : map.values()) {
|
||||||
|
|
||||||
City city = (City)ago;
|
City city = (City) ago;
|
||||||
|
|
||||||
if (city != null)
|
if (city != null)
|
||||||
if (city.getGuild() != null) {
|
if (city.getGuild() != null) {
|
||||||
@@ -88,9 +119,9 @@ public class HourlyJobThread implements Runnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Log metrics to console
|
// Log metrics to console
|
||||||
Logger.info( WorldServer.getUptimeString());
|
Logger.info(WorldServer.getUptimeString());
|
||||||
Logger.info( SimulationManager.getPopulationString());
|
Logger.info(SimulationManager.getPopulationString());
|
||||||
Logger.info( MessageDispatcher.getNetstatString());
|
Logger.info(MessageDispatcher.getNetstatString());
|
||||||
Logger.info(PurgeOprhans.recordsDeleted.toString() + "orphaned items deleted");
|
Logger.info(PurgeOprhans.recordsDeleted.toString() + "orphaned items deleted");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,20 +132,9 @@ public class HourlyJobThread implements Runnable {
|
|||||||
ArrayList<Mine> mines = Mine.getMines();
|
ArrayList<Mine> mines = Mine.getMines();
|
||||||
|
|
||||||
for (Mine mine : mines) {
|
for (Mine mine : mines) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
// Mines can only be claimed once a cycle.
|
|
||||||
// The cycle resets at 01:00hrs after the
|
|
||||||
// Last mine window closes.
|
|
||||||
|
|
||||||
if (mine.wasClaimed == true) {
|
|
||||||
|
|
||||||
if (LocalDateTime.now().getHour() == 01)
|
|
||||||
mine.wasClaimed = false;
|
|
||||||
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Open Errant Mines
|
// Open Errant Mines
|
||||||
|
|
||||||
if (mine.getOwningGuild().isErrant()) {
|
if (mine.getOwningGuild().isErrant()) {
|
||||||
@@ -138,11 +158,11 @@ public class HourlyJobThread implements Runnable {
|
|||||||
Mine.setLastChange(System.currentTimeMillis());
|
Mine.setLastChange(System.currentTimeMillis());
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Logger.error ("mineID: " + mine.getObjectUUID(), e.toString());
|
Logger.error("mineID: " + mine.getObjectUUID(), e.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Logger.error( e.toString());
|
Logger.error(e.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user