Fixed Guild Alliances + minor Guild rework

All Guild Alliances system is now functional. Tweaked guilds in order to
sync MapleGuildCharacter objects that were supposed to be the same when
being accessed from both MapleGuild and MapleCharacter classes.
This commit is contained in:
ronancpl
2017-05-26 01:21:54 -03:00
parent a636f63114
commit 702c69897b
16 changed files with 260 additions and 127 deletions

View File

@@ -69,12 +69,12 @@ public class Server implements Runnable {
private IoAcceptor acceptor;
private List<Map<Integer, String>> channels = new LinkedList<>();
private List<World> worlds = new ArrayList<>();
private Properties subnetInfo = new Properties();
private final Properties subnetInfo = new Properties();
private static Server instance = null;
private List<Pair<Integer, String>> worldRecommendedList = new LinkedList<>();
private Map<Integer, MapleGuild> guilds = new LinkedHashMap<>();
private PlayerBuffStorage buffStorage = new PlayerBuffStorage();
private Map<Integer, MapleAlliance> alliances = new LinkedHashMap<>();
private final Map<Integer, MapleGuild> guilds = new LinkedHashMap<>();
private final PlayerBuffStorage buffStorage = new PlayerBuffStorage();
private final Map<Integer, MapleAlliance> alliances = new LinkedHashMap<>();
private boolean online = false;
public static long uptime = System.currentTimeMillis();
@@ -349,6 +349,18 @@ public class Server implements Runnable {
return MapleGuild.createGuild(leaderId, name);
}
public MapleGuild getGuildByName(String name) {
synchronized (guilds) {
for(MapleGuild mg: guilds.values()) {
if(mg.getName().equalsIgnoreCase(name)) {
return mg;
}
}
return null;
}
}
public MapleGuild getGuild(int id) {
synchronized (guilds) {
if (guilds.get(id) != null) {
@@ -359,7 +371,7 @@ public class Server implements Runnable {
}
}
public MapleGuild getGuild(int id, int world, MapleGuildCharacter mgc) {
public MapleGuild getGuild(int id, int world, MapleCharacter mc) {
synchronized (guilds) {
if (guilds.get(id) != null) {
return guilds.get(id);
@@ -368,9 +380,15 @@ public class Server implements Runnable {
if (g.getId() == -1) {
return null;
}
if (mgc != null) {
g.setOnline(mgc.getId(), true, mgc.getChannel());
if(mc != null) {
MapleGuildCharacter mgc = mc.getMGC();
if (mgc != null) {
g.setOnline(mgc.getId(), true, mgc.getChannel());
mc.setMGC(g.getMGC(mc.getId())); // i really REALLY must make player MGC the same as the guild MGC
}
}
guilds.put(id, g);
return g;
}
@@ -384,9 +402,9 @@ public class Server implements Runnable {
//reloadGuildCharacters();
}
public void setGuildMemberOnline(MapleGuildCharacter mgc, boolean bOnline, int channel) {
MapleGuild g = getGuild(mgc.getGuildId(), mgc.getWorld(), mgc);
g.setOnline(mgc.getId(), bOnline, channel);
public void setGuildMemberOnline(MapleCharacter mc, boolean bOnline, int channel) {
MapleGuild g = getGuild(mc.getGuildId(), mc.getWorld(), mc);
g.setOnline(mc.getId(), bOnline, channel);
}
public int addGuildMember(MapleGuildCharacter mgc) {
@@ -504,8 +522,17 @@ public class Server implements Runnable {
return buffStorage;
}
public void deleteGuildCharacter(MapleCharacter mc) {
setGuildMemberOnline(mc, false, (byte) -1);
if (mc.getMGC().getGuildRank() > 1) {
leaveGuild(mc.getMGC());
} else {
disbandGuild(mc.getMGC().getGuildId());
}
}
public void deleteGuildCharacter(MapleGuildCharacter mgc) {
setGuildMemberOnline(mgc, false, (byte) -1);
if(mgc.getCharacter() != null) setGuildMemberOnline(mgc.getCharacter(), false, (byte) -1);
if (mgc.getGuildRank() > 1) {
leaveGuild(mgc);
} else {
@@ -517,7 +544,7 @@ public class Server implements Runnable {
World worlda = getWorld(world);
for (MapleCharacter mc : worlda.getPlayerStorage().getAllCharacters()) {
if (mc.getGuildId() > 0) {
setGuildMemberOnline(mc.getMGC(), true, worlda.getId());
setGuildMemberOnline(mc, true, worlda.getId());
memberLevelJobUpdate(mc.getMGC());
}
}