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());
}
}

View File

@@ -26,6 +26,7 @@ import client.MapleClient;
import net.AbstractMaplePacketHandler;
import net.SendOpcode;
import net.server.Server;
import net.server.guild.MapleGuild;
import net.server.guild.MapleGuildCharacter;
import net.server.guild.MapleAlliance;
import tools.MaplePacketCreator;
@@ -40,8 +41,6 @@ public final class AllianceOperationHandler extends AbstractMaplePacketHandler {
@Override
public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
System.out.print("aop ");
MapleAlliance alliance = null;
if (c.getPlayer().getGuild() != null && c.getPlayer().getGuild().getAllianceId() > 0) {
alliance = c.getPlayer().getAlliance();
@@ -55,14 +54,11 @@ public final class AllianceOperationHandler extends AbstractMaplePacketHandler {
}
byte b = slea.readByte();
System.out.print(b);
switch (b) {
case 0x01:
System.out.print(" case 1");
Server.getInstance().allianceMessage(alliance.getId(), sendShowInfo(c.getPlayer().getGuild().getAllianceId(), c.getPlayer().getId()), -1, -1);
break;
case 0x02: { // Leave Alliance
System.out.print(" case 2");
if (c.getPlayer().getGuild().getAllianceId() == 0 || c.getPlayer().getGuildId() < 1 || c.getPlayer().getGuildRank() != 1) {
return;
}
@@ -72,35 +68,52 @@ public final class AllianceOperationHandler extends AbstractMaplePacketHandler {
Server.getInstance().removeGuildFromAlliance(alliance.getId(), guildid);
Server.getInstance().allianceMessage(alliance.getId(), MaplePacketCreator.getGuildAlliances(alliance, c), -1, -1);
Server.getInstance().allianceMessage(alliance.getId(), MaplePacketCreator.allianceNotice(alliance.getId(), alliance.getNotice()), -1, -1);
Server.getInstance().guildMessage(guildid, MaplePacketCreator.disbandAlliance(alliance.getId()));
alliance.dropMessage("[" + c.getPlayer().getGuild().getName() + "] guild has left the union.");
break;
}
case 0x03: // send alliance invite
System.out.print(" case 3 avail is " + slea.available());
String charName = slea.readMapleAsciiString();
case 0x03: // send alliance invite... or at least it would be this way if i could find the right way to call it!
String guildName = slea.readMapleAsciiString();
if(alliance.getGuilds().size() == alliance.getCapacity()) {
c.getPlayer().dropMessage("Your alliance can not comport any more guild at the moment.");
} else {
int channel;
channel = c.getWorldServer().find(charName);
if (channel == -1) {
c.getPlayer().dropMessage("The player is not online.");
} else {
MapleCharacter victim = Server.getInstance().getChannel(c.getWorld(), channel).getPlayerStorage().getCharacterByName(charName);
if (victim.getGuildId() == 0) {
c.getPlayer().dropMessage("The person you are trying to invite does not have a guild.");
} else if (victim.getGuildRank() != 1) {
c.getPlayer().dropMessage("The player is not the leader of his/her guild.");
MapleGuild mg = Server.getInstance().getGuildByName(guildName);
if(mg == null) {
c.getPlayer().dropMessage("The entered guild does not exist.");
}
else {
MapleCharacter victim = mg.getMGC(mg.getLeaderId()).getCharacter();
if (victim == null) {
c.getPlayer().dropMessage("The master of the guild that you offered an invitation is currently not online.");
} else {
Server.getInstance().allianceMessage(alliance.getId(), sendInvitation(c.getPlayer().getGuild().getAllianceId(), c.getPlayer().getId(), charName), -1, -1);
// this doesn't seem to work...
//Server.getInstance().allianceMessage(alliance.getId(), sendInvitation(c.getPlayer().getGuild().getAllianceId(), victim.getId(), guildName), -1, -1);
//victim.getClient().announce(sendInvitation(c.getPlayer().getGuild().getAllianceId(), c.getPlayer().getId(), guildName));
if(!c.getPlayer().isPartyMember(victim)) {
c.getPlayer().dropMessage("The master of the guild that you offered a invitation must be in the same party as yours.");
}
else {
int guildid = victim.getGuildId();
Server.getInstance().addGuildtoAlliance(alliance.getId(), guildid);
Server.getInstance().resetAllianceGuildPlayersRank(guildid);
Server.getInstance().allianceMessage(alliance.getId(), MaplePacketCreator.addGuildToAlliance(alliance, guildid, c), -1, -1);
Server.getInstance().allianceMessage(alliance.getId(), MaplePacketCreator.updateAllianceInfo(alliance, c), -1, -1);
Server.getInstance().allianceMessage(alliance.getId(), MaplePacketCreator.allianceNotice(alliance.getId(), alliance.getNotice()), -1, -1);
victim.getGuild().dropMessage("Your guild has joined in the [" + alliance.getName() + "] union.");
}
}
}
}
break;
case 0x04: {
System.out.print(" case 4");
int guildid = slea.readInt();
// slea.readMapleAsciiString();//guild name
if (c.getPlayer().getGuild().getAllianceId() != 0 || c.getPlayer().getGuildRank() != 1 || c.getPlayer().getGuildId() < 1) {
@@ -110,7 +123,6 @@ public final class AllianceOperationHandler extends AbstractMaplePacketHandler {
break;
}
case 0x06: { // Expel Guild
System.out.print(" case 6");
int guildid = slea.readInt();
int allianceid = slea.readInt();
if (c.getPlayer().getGuild().getAllianceId() == 0 || c.getPlayer().getGuild().getAllianceId() != allianceid) {
@@ -121,13 +133,13 @@ public final class AllianceOperationHandler extends AbstractMaplePacketHandler {
Server.getInstance().removeGuildFromAlliance(alliance.getId(), guildid);
Server.getInstance().allianceMessage(alliance.getId(), MaplePacketCreator.getGuildAlliances(alliance, c), -1, -1);
Server.getInstance().allianceMessage(alliance.getId(), MaplePacketCreator.allianceNotice(alliance.getId(), alliance.getNotice()), -1, -1);
Server.getInstance().guildMessage(guildid, MaplePacketCreator.disbandAlliance(allianceid));
alliance.dropMessage("[" + Server.getInstance().getGuild(guildid).getName() + "] guild has been expelled from the union.");
break;
}
case 0x07: { // Change Alliance Leader
System.out.print(" case 7");
if (c.getPlayer().getGuild().getAllianceId() == 0 || c.getPlayer().getGuildId() < 1) {
return;
}
@@ -139,7 +151,6 @@ public final class AllianceOperationHandler extends AbstractMaplePacketHandler {
break;
}
case 0x08:
System.out.print(" case 8");
String ranks[] = new String[5];
for (int i = 0; i < 5; i++) {
ranks[i] = slea.readMapleAsciiString();
@@ -148,7 +159,6 @@ public final class AllianceOperationHandler extends AbstractMaplePacketHandler {
Server.getInstance().allianceMessage(alliance.getId(), MaplePacketCreator.changeAllianceRankTitle(alliance.getId(), ranks), -1, -1);
break;
case 0x09: {
System.out.print(" case 9");
int int1 = slea.readInt();
byte byte1 = slea.readByte();
@@ -159,7 +169,6 @@ public final class AllianceOperationHandler extends AbstractMaplePacketHandler {
break;
}
case 0x0A:
System.out.print(" case A");
String notice = slea.readMapleAsciiString();
Server.getInstance().setAllianceNotice(alliance.getId(), notice);
Server.getInstance().allianceMessage(alliance.getId(), MaplePacketCreator.allianceNotice(alliance.getId(), notice), -1, -1);
@@ -167,7 +176,6 @@ public final class AllianceOperationHandler extends AbstractMaplePacketHandler {
default:
c.getPlayer().dropMessage("Feature not available");
}
System.out.println("end");
alliance.saveToDB();
}
@@ -175,25 +183,25 @@ public final class AllianceOperationHandler extends AbstractMaplePacketHandler {
private void changeLeaderAllianceRank(MapleAlliance alliance, MapleCharacter newLeader) {
MapleGuildCharacter lmgc = alliance.getLeader();
MapleCharacter leader = Server.getInstance().getWorld(newLeader.getWorld()).getPlayerStorage().getCharacterById(lmgc.getId());
leader.setAllianceRank(2);
leader.getMGC().setAllianceRank(2);
leader.saveGuildStatus();
newLeader.setAllianceRank(1);
newLeader.getMGC().setAllianceRank(1);
newLeader.saveGuildStatus();
Server.getInstance().allianceMessage(alliance.getId(), MaplePacketCreator.getGuildAlliances(alliance, newLeader.getClient()), -1, -1);
alliance.dropAllianceMessage("'" + newLeader.getName() + "' has been appointed as the new head of this Alliance.");
alliance.dropMessage("'" + newLeader.getName() + "' has been appointed as the new head of this Alliance.");
}
private void changePlayerAllianceRank(MapleAlliance alliance, MapleCharacter chr, boolean raise) {
int newRank = chr.getAllianceRank() + (raise ? -1 : 1);
if(newRank < 2 || newRank > 5) return;
if(newRank < 3 || newRank > 5) return;
chr.setAllianceRank(newRank);
chr.getMGC().setAllianceRank(newRank);
chr.saveGuildStatus();
Server.getInstance().allianceMessage(alliance.getId(), MaplePacketCreator.getGuildAlliances(alliance, chr.getClient()), -1, -1);
alliance.dropAllianceMessage("'" + chr.getName() + "' has moved ranks to '" + alliance.getRankTitle(newRank) + "' in this Alliance.");
alliance.dropMessage("'" + chr.getName() + "' has been reassigned as '" + alliance.getRankTitle(newRank) + "' in this Alliance.");
}
private static byte[] sendShowInfo(int allianceid, int playerid) {

View File

@@ -30,6 +30,7 @@ import java.util.Iterator;
import tools.MaplePacketCreator;
import client.MapleCharacter;
import net.server.Server;
import net.server.guild.MapleAlliance;
public final class GuildOperationHandler extends AbstractMaplePacketHandler {
private boolean isGuildNameAcceptable(String name) {
@@ -95,6 +96,7 @@ public final class GuildOperationHandler extends AbstractMaplePacketHandler {
}
MapleCharacter mc = c.getPlayer();
byte type = slea.readByte();
int allianceId = -1;
switch (type) {
case 0x00:
//c.announce(MaplePacketCreator.showGuildInfo(mc));
@@ -123,8 +125,12 @@ public final class GuildOperationHandler extends AbstractMaplePacketHandler {
mc.gainMeso(-MapleGuild.CREATE_GUILD_COST, true, false, true);
mc.setGuildId(gid);
mc.setGuildRank(1);
mc.saveGuildStatus();
mc.setAllianceRank(5);
MapleGuild guild = Server.getInstance().getGuild(mc.getGuildId(), c.getWorld(), mc); // initialize guild structure
guild.getMGC(guild.getLeaderId()).setCharacter(mc);
c.announce(MaplePacketCreator.showGuildInfo(mc));
c.getPlayer().dropMessage(1, "You have successfully created a Guild.");
respawnPlayer(mc);
break;
@@ -171,6 +177,7 @@ public final class GuildOperationHandler extends AbstractMaplePacketHandler {
}
mc.setGuildId(gid); // joins the guild
mc.setGuildRank(5); // start at lowest rank
mc.setAllianceRank(5);
int s;
s = Server.getInstance().addGuildMember(mc.getMGC());
@@ -179,11 +186,18 @@ public final class GuildOperationHandler extends AbstractMaplePacketHandler {
mc.setGuildId(0);
return;
}
c.announce(MaplePacketCreator.showGuildInfo(mc));
allianceId = mc.getGuild().getAllianceId();
if(allianceId > 0) Server.getInstance().getAlliance(allianceId).updateAlliancePackets(mc);
mc.saveGuildStatus(); // update database
respawnPlayer(mc);
break;
case 0x07:
allianceId = mc.getGuild().getAllianceId();
cid = slea.readInt();
name = slea.readMapleAsciiString();
if (cid != mc.getId() || !name.equals(mc.getName()) || mc.getGuildId() <= 0) {
@@ -192,12 +206,17 @@ public final class GuildOperationHandler extends AbstractMaplePacketHandler {
}
c.announce(MaplePacketCreator.updateGP(mc.getGuildId(), 0));
Server.getInstance().leaveGuild(mc.getMGC());
c.announce(MaplePacketCreator.showGuildInfo(null));
if(allianceId > 0) Server.getInstance().getAlliance(allianceId).updateAlliancePackets(mc);
mc.setGuildId(0);
mc.saveGuildStatus();
respawnPlayer(mc);
break;
case 0x08:
allianceId = mc.getGuild().getAllianceId();
cid = slea.readInt();
name = slea.readMapleAsciiString();
if (mc.getGuildRank() > 2 || mc.getGuildId() <= 0) {
@@ -206,6 +225,7 @@ public final class GuildOperationHandler extends AbstractMaplePacketHandler {
}
Server.getInstance().expelMember(mc.getMGC(), name, cid);
if(allianceId > 0) Server.getInstance().getAlliance(allianceId).updateAlliancePackets(mc);
break;
case 0x0d:
if (mc.getGuildId() <= 0 || mc.getGuildRank() != 1) {
@@ -237,7 +257,7 @@ public final class GuildOperationHandler extends AbstractMaplePacketHandler {
return;
}
if (mc.getMeso() < MapleGuild.CHANGE_EMBLEM_COST) {
c.announce(MaplePacketCreator.serverNotice(1, "You do not have enough mesos to create a Guild."));
c.announce(MaplePacketCreator.serverNotice(1, "You do not have enough mesos to change the Guild emblem."));
return;
}
short bg = slea.readShort();

View File

@@ -183,15 +183,15 @@ public final class PlayerLoggedinHandler extends AbstractMaplePacketHandler {
c.announce(MaplePacketCreator.getFamilyInfo(f.getMember(player.getId())));
}
if (player.getGuildId() > 0) {
MapleGuild playerGuild = server.getGuild(player.getGuildId(), player.getWorld(), player.getMGC());
MapleGuild playerGuild = server.getGuild(player.getGuildId(), player.getWorld(), player);
if (playerGuild == null) {
player.deleteGuild(player.getGuildId());
player.resetMGC(null);
player.setMGC(null);
player.setGuildId(0);
} else {
playerGuild.getMGC(player.getId()).setCharacter(player);
player.resetMGC(playerGuild.getMGC(player.getId()));
server.setGuildMemberOnline(player.getMGC(), true, c.getChannel());
player.setMGC(playerGuild.getMGC(player.getId()));
server.setGuildMemberOnline(player, true, c.getChannel());
c.announce(MaplePacketCreator.showGuildInfo(player));
int allianceId = player.getGuild().getAllianceId();
if (allianceId > 0) {
@@ -205,8 +205,9 @@ public final class PlayerLoggedinHandler extends AbstractMaplePacketHandler {
}
}
if (newAlliance != null) {
c.announce(MaplePacketCreator.getAllianceInfo(newAlliance));
c.announce(MaplePacketCreator.getGuildAlliances(newAlliance, c));
c.announce(MaplePacketCreator.updateAllianceInfo(newAlliance, c));
c.announce(MaplePacketCreator.allianceNotice(newAlliance.getId(), newAlliance.getNotice()));
server.allianceMessage(allianceId, MaplePacketCreator.allianceMemberOnline(player, true), player.getId(), -1);
}
}

View File

@@ -32,8 +32,6 @@ import client.MapleCharacter;
import net.server.Server;
import net.server.world.MapleParty;
import net.server.world.MaplePartyCharacter;
import net.server.guild.MapleGuild;
import net.server.guild.MapleGuildCharacter;
import tools.DatabaseConnection;
import tools.MaplePacketCreator;
@@ -122,12 +120,12 @@ public class MapleAlliance {
Server.getInstance().resetAllianceGuildPlayersRank(guilds.get(i));
MapleCharacter chr = guildMasters.get(i);
chr.setAllianceRank((i == 0) ? 1 : 2);
chr.getMGC().setAllianceRank((i == 0) ? 1 : 2);
chr.saveGuildStatus();
}
Server.getInstance().addAlliance(id, alliance);
Server.getInstance().allianceMessage(id, MaplePacketCreator.makeNewAlliance(alliance, guildMasters.get(0).getClient()), -1, -1);
Server.getInstance().allianceMessage(id, MaplePacketCreator.updateAllianceInfo(alliance, guildMasters.get(0).getClient()), -1, -1);
} catch (Exception e) {
e.printStackTrace();
return null;
@@ -194,6 +192,14 @@ public class MapleAlliance {
alliance.name = rs.getString("name");
alliance.notice = rs.getString("notice");
String ranks[] = new String[5];
ranks[0] = rs.getString("rank1");
ranks[1] = rs.getString("rank2");
ranks[2] = rs.getString("rank3");
ranks[3] = rs.getString("rank4");
ranks[4] = rs.getString("rank5");
alliance.rankTitles = ranks;
ps.close();
rs.close();
@@ -218,10 +224,17 @@ public class MapleAlliance {
public void saveToDB() {
try {
Connection con = DatabaseConnection.getConnection();
PreparedStatement ps = con.prepareStatement("UPDATE `alliance` SET capacity = ?, notice = ? WHERE id = ?");
PreparedStatement ps = con.prepareStatement("UPDATE `alliance` SET capacity = ?, notice = ?, rank1 = ?, rank2 = ?, rank3 = ?, rank4 = ?, rank5 = ? WHERE id = ?");
ps.setInt(1, this.capacity);
ps.setString(2, this.notice);
ps.setInt(3, this.allianceId);
ps.setString(3, this.rankTitles[0]);
ps.setString(4, this.rankTitles[1]);
ps.setString(5, this.rankTitles[2]);
ps.setString(6, this.rankTitles[3]);
ps.setString(7, this.rankTitles[4]);
ps.setInt(8, this.allianceId);
ps.executeUpdate();
ps.close();
@@ -246,6 +259,48 @@ public class MapleAlliance {
}
}
public static void disbandAlliance(int allianceId) {
PreparedStatement ps = null;
Connection con = null;
try {
con = DatabaseConnection.getConnection();
ps = con.prepareStatement("DELETE FROM `alliance` WHERE id = ?");
ps.setInt(1, allianceId);
ps.executeUpdate();
ps.close();
ps = con.prepareStatement("DELETE FROM `allianceguilds` WHERE allianceid = ?");
ps.setInt(1, allianceId);
ps.executeUpdate();
ps.close();
con.close();
Server.getInstance().allianceMessage(allianceId, MaplePacketCreator.disbandAlliance(allianceId), -1, -1);
Server.getInstance().disbandAlliance(allianceId);
} catch (SQLException sqle) {
sqle.printStackTrace();
} finally {
try {
if (ps != null && !ps.isClosed()) {
ps.close();
}
if (con != null && !con.isClosed()) {
con.close();
}
} catch (SQLException ex) {
ex.printStackTrace();
}
}
}
public void updateAlliancePackets(MapleCharacter chr) {
if (allianceId > 0) {
this.broadcastMessage(MaplePacketCreator.updateAllianceInfo(this, chr.getClient()));
this.broadcastMessage(MaplePacketCreator.allianceNotice(this.getId(), this.getNotice()));
}
}
public boolean removeGuild(int gid) {
synchronized (guilds) {
int index = getGuildIndex(gid);
@@ -334,14 +389,18 @@ public class MapleAlliance {
return null;
}
public void dropAllianceMessage(String message) {
dropAllianceMessage(5, message);
public void dropMessage(String message) {
dropMessage(5, message);
}
public void dropAllianceMessage(int type, String message) {
public void dropMessage(int type, String message) {
for(Integer gId: guilds) {
MapleGuild guild = Server.getInstance().getGuild(gId);
guild.dropGuildMessage(type, message);
guild.dropMessage(type, message);
}
}
public void broadcastMessage(byte[] packet) {
Server.getInstance().allianceMessage(allianceId, packet, -1, -1);
}
}

View File

@@ -180,6 +180,10 @@ public class MapleGuild {
public int getLeaderId() {
return leader;
}
public int setLeaderId(int charId) {
return leader = charId;
}
public int getGP() {
return gp;
@@ -283,15 +287,20 @@ public class MapleGuild {
}
}
public void dropGuildMessage(String message) {
dropGuildMessage(5, message);
public void dropMessage(String message) {
dropMessage(5, message);
}
public void dropGuildMessage(int type, String message) {
public void dropMessage(int type, String message) {
for (MapleGuildCharacter mgc : members) {
mgc.getCharacter().dropMessage(type, message);
if(mgc.getCharacter() != null)
mgc.getCharacter().dropMessage(type, message);
}
}
public void broadcastMessage(byte[] packet) {
Server.getInstance().guildMessage(id, packet);
}
public final void setOnline(int cid, boolean online, int channel) {
boolean bBroadcast = true;
@@ -332,20 +341,30 @@ public class MapleGuild {
}
ps.close();
rs.close();
ps = con.prepareStatement("INSERT INTO guilds (`leader`, `name`, `signature`) VALUES (?, ?, ?)");
ps.setInt(1, leaderId);
ps.setString(2, name);
ps.setInt(3, (int) System.currentTimeMillis());
ps.execute();
ps.close();
ps = con.prepareStatement("SELECT guildid FROM guilds WHERE leader = ?");
ps.setInt(1, leaderId);
rs = ps.executeQuery();
rs.first();
int guildid = rs.getInt("guildid");
int guildId = rs.getInt("guildid");
rs.close();
ps.close();
return guildid;
ps = con.prepareStatement("UPDATE characters SET guildid = ? WHERE id = ?");
ps.setInt(1, guildId);
ps.setInt(2, leaderId);
ps.executeUpdate();
ps.close();
con.close();
return guildId;
} catch (Exception e) {
e.printStackTrace();
return 0;

View File

@@ -135,6 +135,7 @@ public class MapleGuildCharacter {
public void setAllianceRank(int rank) {
allianceRank = rank;
if(character != null) character.setAllianceRank(rank);
}
public int getAllianceRank() {

View File

@@ -196,7 +196,7 @@ public class World {
public MapleGuild getGuild(MapleGuildCharacter mgc) {
int gid = mgc.getGuildId();
MapleGuild g;
g = Server.getInstance().getGuild(gid, mgc.getWorld(), mgc);
g = Server.getInstance().getGuild(gid, mgc.getWorld(), mgc.getCharacter());
if (gsStore.get(gid) == null) {
gsStore.put(gid, new MapleGuildSummary(g));
}