Rename and clean up MapleAlliance

This commit is contained in:
P0nk
2021-09-09 21:33:36 +02:00
parent e75139e5e6
commit 5e5f7b12ca
11 changed files with 52 additions and 52 deletions

View File

@@ -48,7 +48,7 @@ import net.server.audit.locks.factory.MonitoredWriteLockFactory;
import net.server.channel.Channel;
import net.server.coordinator.session.IpAddresses;
import net.server.coordinator.session.SessionCoordinator;
import net.server.guild.MapleAlliance;
import net.server.guild.Alliance;
import net.server.guild.MapleGuild;
import net.server.guild.MapleGuildCharacter;
import net.server.task.*;
@@ -108,7 +108,7 @@ public class Server {
private final Map<Client, Long> inLoginState = new HashMap<>(100);
private final PlayerBuffStorage buffStorage = new PlayerBuffStorage();
private final Map<Integer, MapleAlliance> alliances = new HashMap<>(100);
private final Map<Integer, Alliance> alliances = new HashMap<>(100);
private final Map<Integer, NewYearCardRecord> newyears = new HashMap<>();
private final List<Client> processDiseaseAnnouncePlayers = new LinkedList<>();
private final List<Client> registeredDiseaseAnnouncePlayers = new LinkedList<>();
@@ -963,7 +963,7 @@ public class Server {
return subnetInfo;
}
public MapleAlliance getAlliance(int id) {
public Alliance getAlliance(int id) {
synchronized (alliances) {
if (alliances.containsKey(id)) {
return alliances.get(id);
@@ -972,7 +972,7 @@ public class Server {
}
}
public void addAlliance(int id, MapleAlliance alliance) {
public void addAlliance(int id, Alliance alliance) {
synchronized (alliances) {
if (!alliances.containsKey(id)) {
alliances.put(id, alliance);
@@ -982,7 +982,7 @@ public class Server {
public void disbandAlliance(int id) {
synchronized (alliances) {
MapleAlliance alliance = alliances.get(id);
Alliance alliance = alliances.get(id);
if (alliance != null) {
for (Integer gid : alliance.getGuilds()) {
guilds.get(gid).setAllianceId(0);
@@ -993,7 +993,7 @@ public class Server {
}
public void allianceMessage(int id, Packet packet, int exception, int guildex) {
MapleAlliance alliance = alliances.get(id);
Alliance alliance = alliances.get(id);
if (alliance != null) {
for (Integer gid : alliance.getGuilds()) {
if (guildex == gid) {
@@ -1008,7 +1008,7 @@ public class Server {
}
public boolean addGuildtoAlliance(int aId, int guildId) {
MapleAlliance alliance = alliances.get(aId);
Alliance alliance = alliances.get(aId);
if (alliance != null) {
alliance.addGuild(guildId);
guilds.get(guildId).setAllianceId(aId);
@@ -1018,7 +1018,7 @@ public class Server {
}
public boolean removeGuildFromAlliance(int aId, int guildId) {
MapleAlliance alliance = alliances.get(aId);
Alliance alliance = alliances.get(aId);
if (alliance != null) {
alliance.removeGuild(guildId);
guilds.get(guildId).setAllianceId(0);
@@ -1028,7 +1028,7 @@ public class Server {
}
public boolean setAllianceRanks(int aId, String[] ranks) {
MapleAlliance alliance = alliances.get(aId);
Alliance alliance = alliances.get(aId);
if (alliance != null) {
alliance.setRankTitle(ranks);
return true;
@@ -1037,7 +1037,7 @@ public class Server {
}
public boolean setAllianceNotice(int aId, String notice) {
MapleAlliance alliance = alliances.get(aId);
Alliance alliance = alliances.get(aId);
if (alliance != null) {
alliance.setNotice(notice);
return true;
@@ -1046,7 +1046,7 @@ public class Server {
}
public boolean increaseAllianceCapacity(int aId, int inc) {
MapleAlliance alliance = alliances.get(aId);
Alliance alliance = alliances.get(aId);
if (alliance != null) {
alliance.increaseCapacity(inc);
return true;

View File

@@ -26,8 +26,8 @@ import client.Client;
import net.AbstractPacketHandler;
import net.packet.InPacket;
import net.server.Server;
import net.server.guild.Alliance;
import net.server.guild.GuildPackets;
import net.server.guild.MapleAlliance;
import net.server.guild.MapleGuild;
import net.server.guild.MapleGuildCharacter;
import tools.PacketCreator;
@@ -40,7 +40,7 @@ public final class AllianceOperationHandler extends AbstractPacketHandler {
@Override
public final void handlePacket(InPacket p, Client c) {
MapleAlliance alliance = null;
Alliance alliance = null;
Character chr = c.getPlayer();
if (chr.getGuild() == null) {
@@ -81,7 +81,7 @@ public final class AllianceOperationHandler extends AbstractPacketHandler {
return;
}
MapleAlliance.removeGuildFromAlliance(chr.getGuild().getAllianceId(), chr.getGuildId(), chr.getWorld());
Alliance.removeGuildFromAlliance(chr.getGuild().getAllianceId(), chr.getGuildId(), chr.getWorld());
break;
}
case 0x03: // Send Invite
@@ -90,7 +90,7 @@ public final class AllianceOperationHandler extends AbstractPacketHandler {
if (alliance.getGuilds().size() == alliance.getCapacity()) {
chr.dropMessage(5, "Your alliance cannot comport any more guilds at the moment.");
} else {
MapleAlliance.sendInvitation(c, guildName, alliance.getId());
Alliance.sendInvitation(c, guildName, alliance.getId());
}
break;
@@ -108,7 +108,7 @@ public final class AllianceOperationHandler extends AbstractPacketHandler {
return;
}
if (!MapleAlliance.answerInvitation(c.getPlayer().getId(), guild.getName(), alliance.getId(), true)) {
if (!Alliance.answerInvitation(c.getPlayer().getId(), guild.getName(), alliance.getId(), true)) {
return;
}
@@ -200,7 +200,7 @@ public final class AllianceOperationHandler extends AbstractPacketHandler {
alliance.saveToDB();
}
private void changeLeaderAllianceRank(MapleAlliance alliance, Character newLeader) {
private void changeLeaderAllianceRank(Alliance alliance, Character newLeader) {
MapleGuildCharacter lmgc = alliance.getLeader();
Character leader = newLeader.getWorldServer().getPlayerStorage().getCharacterById(lmgc.getId());
leader.getMGC().setAllianceRank(2);
@@ -213,7 +213,7 @@ public final class AllianceOperationHandler extends AbstractPacketHandler {
alliance.dropMessage("'" + newLeader.getName() + "' has been appointed as the new head of this Alliance.");
}
private void changePlayerAllianceRank(MapleAlliance alliance, Character chr, boolean raise) {
private void changePlayerAllianceRank(Alliance alliance, Character chr, boolean raise) {
int newRank = chr.getAllianceRank() + (raise ? -1 : 1);
if(newRank < 3 || newRank > 5) return;

View File

@@ -23,7 +23,7 @@ import client.Character;
import client.Client;
import net.AbstractPacketHandler;
import net.packet.InPacket;
import net.server.guild.MapleAlliance;
import net.server.guild.Alliance;
/**
* @author Ronan
@@ -38,9 +38,9 @@ public final class DenyAllianceRequestHandler extends AbstractPacketHandler {
Character chr = c.getWorldServer().getPlayerStorage().getCharacterByName(inviterName);
if (chr != null) {
MapleAlliance alliance = chr.getAlliance();
Alliance alliance = chr.getAlliance();
if (alliance != null) {
MapleAlliance.answerInvitation(c.getPlayer().getId(), guildName, alliance.getId(), false);
Alliance.answerInvitation(c.getPlayer().getId(), guildName, alliance.getId(), false);
}
}
}

View File

@@ -29,8 +29,8 @@ import net.AbstractPacketHandler;
import net.packet.InPacket;
import net.server.Server;
import net.server.coordinator.matchchecker.MatchCheckerListenerFactory.MatchCheckerType;
import net.server.guild.Alliance;
import net.server.guild.GuildPackets;
import net.server.guild.MapleAlliance;
import net.server.guild.MapleGuild;
import net.server.guild.MapleGuildResponse;
import net.server.world.MapleParty;
@@ -224,7 +224,7 @@ public final class GuildOperationHandler extends AbstractPacketHandler {
Server.getInstance().setGuildEmblem(mc.getGuildId(), bg, bgcolor, logo, logocolor);
if (mc.getGuild() != null && mc.getGuild().getAllianceId() > 0) {
MapleAlliance alliance = mc.getAlliance();
Alliance alliance = mc.getAlliance();
Server.getInstance().allianceMessage(alliance.getId(), GuildPackets.getGuildAlliances(alliance, c.getWorld()), -1, -1);
}

View File

@@ -36,8 +36,8 @@ import net.server.channel.CharacterIdChannelPair;
import net.server.coordinator.session.Hwid;
import net.server.coordinator.session.SessionCoordinator;
import net.server.coordinator.world.EventRecallCoordinator;
import net.server.guild.Alliance;
import net.server.guild.GuildPackets;
import net.server.guild.MapleAlliance;
import net.server.guild.MapleGuild;
import net.server.world.MaplePartyCharacter;
import net.server.world.PartyOperation;
@@ -280,9 +280,9 @@ public final class PlayerLoggedinHandler extends AbstractPacketHandler {
c.sendPacket(GuildPackets.showGuildInfo(player));
int allianceId = player.getGuild().getAllianceId();
if (allianceId > 0) {
MapleAlliance newAlliance = server.getAlliance(allianceId);
Alliance newAlliance = server.getAlliance(allianceId);
if (newAlliance == null) {
newAlliance = MapleAlliance.loadAlliance(allianceId);
newAlliance = Alliance.loadAlliance(allianceId);
if (newAlliance != null) {
server.addAlliance(allianceId, newAlliance);
} else {

View File

@@ -43,7 +43,7 @@ import java.util.List;
* @author XoticStory
* @author Ronan
*/
public class MapleAlliance {
public class Alliance {
final private List<Integer> guilds = new LinkedList<>();
private int allianceId = -1;
@@ -52,7 +52,7 @@ public class MapleAlliance {
private String notice = "";
private String[] rankTitles = new String[5];
public MapleAlliance(String name, int id) {
public Alliance(String name, int id) {
this.name = name;
allianceId = id;
String[] ranks = {"Master", "Jr. Master", "Member", "Member", "Member"};
@@ -109,7 +109,7 @@ public class MapleAlliance {
return mcl;
}
public static MapleAlliance createAlliance(MapleParty party, String name) {
public static Alliance createAlliance(MapleParty party, String name) {
List<Character> guildMasters = getPartyGuildMasters(party);
if (guildMasters.size() != 2) {
return null;
@@ -119,7 +119,7 @@ public class MapleAlliance {
for (Character mc : guildMasters) {
guilds.add(mc.getGuildId());
}
MapleAlliance alliance = MapleAlliance.createAllianceOnDb(guilds, name);
Alliance alliance = Alliance.createAllianceOnDb(guilds, name);
if (alliance != null) {
alliance.setCapacity(guilds.size());
for (Integer g : guilds) {
@@ -152,7 +152,7 @@ public class MapleAlliance {
return alliance;
}
public static MapleAlliance createAllianceOnDb(List<Integer> guilds, String name) {
public static Alliance createAllianceOnDb(List<Integer> guilds, String name) {
// will create an alliance, where the first guild listed is the leader and the alliance name MUST BE already checked for unicity.
int id = -1;
@@ -178,14 +178,14 @@ public class MapleAlliance {
return null;
}
return new MapleAlliance(name, id);
return new Alliance(name, id);
}
public static MapleAlliance loadAlliance(int id) {
public static Alliance loadAlliance(int id) {
if (id <= 0) {
return null;
}
MapleAlliance alliance = new MapleAlliance(null, -1);
Alliance alliance = new Alliance(null, -1);
try (Connection con = DatabaseConnection.getConnection()) {
try (PreparedStatement ps = con.prepareStatement("SELECT * FROM alliance WHERE id = ?")) {
@@ -292,7 +292,7 @@ public class MapleAlliance {
public static boolean removeGuildFromAlliance(int allianceId, int guildId, int worldId) {
Server srv = Server.getInstance();
MapleAlliance alliance = srv.getAlliance(allianceId);
Alliance alliance = srv.getAlliance(allianceId);
if (alliance.getLeader().getGuildId() == guildId) {
return false;

View File

@@ -365,7 +365,7 @@ public class GuildPackets {
p.writeInt(guild.getAllianceId());
}
public static Packet getAllianceInfo(MapleAlliance alliance) {
public static Packet getAllianceInfo(Alliance alliance) {
OutPacket p = OutPacket.create(SendOpcode.ALLIANCE_OPERATION);
p.writeByte(0x0C);
p.writeByte(1);
@@ -383,7 +383,7 @@ public class GuildPackets {
return p;
}
public static Packet updateAllianceInfo(MapleAlliance alliance, int world) {
public static Packet updateAllianceInfo(Alliance alliance, int world) {
OutPacket p = OutPacket.create(SendOpcode.ALLIANCE_OPERATION);
p.writeByte(0x0F);
p.writeInt(alliance.getId());
@@ -403,7 +403,7 @@ public class GuildPackets {
return p;
}
public static Packet getGuildAlliances(MapleAlliance alliance, int worldId) {
public static Packet getGuildAlliances(Alliance alliance, int worldId) {
OutPacket p = OutPacket.create(SendOpcode.ALLIANCE_OPERATION);
p.writeByte(0x0D);
p.writeInt(alliance.getGuilds().size());
@@ -413,7 +413,7 @@ public class GuildPackets {
return p;
}
public static Packet addGuildToAlliance(MapleAlliance alliance, int newGuild, Client c) {
public static Packet addGuildToAlliance(Alliance alliance, int newGuild, Client c) {
OutPacket p = OutPacket.create(SendOpcode.ALLIANCE_OPERATION);
p.writeByte(0x12);
p.writeInt(alliance.getId());
@@ -471,7 +471,7 @@ public class GuildPackets {
return p;
}
public static Packet removeGuildFromAlliance(MapleAlliance alliance, int expelledGuild, int worldId) {
public static Packet removeGuildFromAlliance(Alliance alliance, int expelledGuild, int worldId) {
OutPacket p = OutPacket.create(SendOpcode.ALLIANCE_OPERATION);
p.writeByte(0x10);
p.writeInt(alliance.getId());

View File

@@ -634,8 +634,8 @@ public class MapleGuild {
public void disbandGuild() {
if (allianceId > 0) {
if (!MapleAlliance.removeGuildFromAlliance(allianceId, id, world)) {
MapleAlliance.disbandAlliance(allianceId);
if (!Alliance.removeGuildFromAlliance(allianceId, id, world)) {
Alliance.disbandAlliance(allianceId);
}
}