Partial solution on Guild Alliances
Revamped DB tables and enabled some functionalities on Guild Alliances, such as create one, expel/quit one and rank players.
This commit is contained in:
@@ -243,3 +243,7 @@ Foi retirado o gargalo no sistema sempre que jogador incorpora um novo card ao m
|
|||||||
Consertado bug em potencial ao tentar completar quest que requer item equipado.
|
Consertado bug em potencial ao tentar completar quest que requer item equipado.
|
||||||
Adição de scrolls: Scroll for cold protection, Scroll for spike for shoes.
|
Adição de scrolls: Scroll for cold protection, Scroll for spike for shoes.
|
||||||
Consertado quest-evento Dollhouse.
|
Consertado quest-evento Dollhouse.
|
||||||
|
|
||||||
|
23 - 24 Maio 2017,
|
||||||
|
Revamp na DB referente às Alliances.
|
||||||
|
Solução parcial ao problema das Guild Alliances. Pode-se criar uma, sair, expulsar e trocar ranks de jogadores.
|
||||||
@@ -3,37 +3,16 @@
|
|||||||
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
|
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
|
||||||
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
|
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
|
||||||
<group>
|
<group>
|
||||||
<file>file:/C:/Nexon/MapleSolaxia/MapleSolaxiaV2/src/client/command/Commands.java</file>
|
<file>file:/C:/Nexon/MapleSolaxia/MapleSolaxiaV2/src/net/server/channel/handlers/AllianceOperationHandler.java</file>
|
||||||
<file>file:/C:/Nexon/MapleSolaxia/MapleSolaxiaV2/src/server/maps/HiredMerchant.java</file>
|
<file>file:/C:/Nexon/MapleSolaxia/MapleSolaxiaV2/src/net/server/guild/MapleGuild.java</file>
|
||||||
<file>file:/C:/Nexon/MapleSolaxia/MapleSolaxiaV2/src/server/MapleStatEffect.java</file>
|
<file>file:/C:/Nexon/MapleSolaxia/MapleSolaxiaV2/src/net/server/guild/MapleAlliance.java</file>
|
||||||
<file>file:/C:/Nexon/MapleSolaxia/MapleSolaxiaV2/src/scripting/AbstractPlayerInteraction.java</file>
|
<file>file:/C:/Nexon/MapleSolaxia/MapleSolaxiaV2/src/net/server/guild/MapleGuildCharacter.java</file>
|
||||||
<file>file:/C:/Nexon/MapleSolaxia/MapleSolaxiaV2/scripts/npc/world0/2040020.js</file>
|
<file>file:/C:/Nexon/MapleSolaxia/MapleSolaxiaV2/src/net/server/Server.java</file>
|
||||||
<file>file:/C:/Nexon/MapleSolaxia/MapleSolaxiaV2/scripts/npc/world0/2040002.js</file>
|
<file>file:/C:/Nexon/MapleSolaxia/MapleSolaxiaV2/src/net/server/world/World.java</file>
|
||||||
<file>file:/C:/Nexon/MapleSolaxia/MapleSolaxiaV2/src/net/server/channel/handlers/PlayerInteractionHandler.java</file>
|
|
||||||
<file>file:/C:/Nexon/MapleSolaxia/MapleSolaxiaV2/src/server/MapleItemInformationProvider.java</file>
|
|
||||||
<file>file:/C:/Nexon/MapleSolaxia/MapleSolaxiaV2/src/net/server/channel/handlers/StorageHandler.java</file>
|
|
||||||
<file>file:/C:/Nexon/MapleSolaxia/MapleSolaxiaV2/src/net/server/channel/handlers/UseCashItemHandler.java</file>
|
|
||||||
<file>file:/C:/Nexon/MapleSolaxia/MapleSolaxiaV2/src/client/inventory/Equip.java</file>
|
|
||||||
<file>file:/C:/Nexon/MapleSolaxia/MapleSolaxiaV2/src/scripting/event/EventInstanceManager.java</file>
|
|
||||||
<file>file:/C:/Nexon/MapleSolaxia/MapleSolaxiaV2/src/client/MapleBuffStat.java</file>
|
|
||||||
<file>file:/C:/Nexon/MapleSolaxia/MapleSolaxiaV2/src/server/maps/MapleMap.java</file>
|
|
||||||
<file>file:/C:/Nexon/MapleSolaxia/MapleSolaxiaV2/src/client/MapleCharacter.java</file>
|
|
||||||
<file>file:/C:/Nexon/MapleSolaxia/MapleSolaxiaV2/scripts/npc/world0/2040028.js</file>
|
|
||||||
<file>file:/C:/Nexon/MapleSolaxia/MapleSolaxiaV2/src/net/server/channel/handlers/PlayerLoggedinHandler.java</file>
|
|
||||||
<file>file:/C:/Nexon/MapleSolaxia/MapleSolaxiaV2/scripts/event/EllinPQ.js</file>
|
|
||||||
<file>file:/C:/Nexon/MapleSolaxia/MapleSolaxiaV2/src/constants/ItemConstants.java</file>
|
|
||||||
<file>file:/C:/Nexon/MapleSolaxia/MapleSolaxiaV2/src/server/maps/MapleReactor.java</file>
|
|
||||||
<file>file:/C:/Nexon/MapleSolaxia/MapleSolaxiaV2/src/server/maps/MapleDragon.java</file>
|
|
||||||
<file>file:/C:/Nexon/MapleSolaxia/MapleSolaxiaV2/scripts/npc/world0/2133000.js</file>
|
|
||||||
<file>file:/C:/Nexon/MapleSolaxia/MapleSolaxiaV2/src/client/inventory/MapleInventory.java</file>
|
|
||||||
<file>file:/C:/Nexon/MapleSolaxia/MapleSolaxiaV2/scripts/event/DollHouse.js</file>
|
|
||||||
<file>file:/C:/Nexon/MapleSolaxia/MapleSolaxiaV2/src/net/server/channel/handlers/ScrollHandler.java</file>
|
|
||||||
<file>file:/C:/Nexon/MapleSolaxia/MapleSolaxiaV2/src/server/maps/AbstractMapleMapObject.java</file>
|
|
||||||
<file>file:/C:/Nexon/MapleSolaxia/MapleSolaxiaV2/src/server/quest/MapleQuestRequirementType.java</file>
|
|
||||||
<file>file:/C:/Nexon/MapleSolaxia/MapleSolaxiaV2/src/scripting/npc/NPCConversationManager.java</file>
|
<file>file:/C:/Nexon/MapleSolaxia/MapleSolaxiaV2/src/scripting/npc/NPCConversationManager.java</file>
|
||||||
<file>file:/C:/Nexon/MapleSolaxia/MapleSolaxiaV2/src/server/MapleInventoryManipulator.java</file>
|
<file>file:/C:/Nexon/MapleSolaxia/MapleSolaxiaV2/src/client/MapleCharacter.java</file>
|
||||||
<file>file:/C:/Nexon/MapleSolaxia/MapleSolaxiaV2/src/server/quest/actions/PetSkillAction.java</file>
|
<file>file:/C:/Nexon/MapleSolaxia/MapleSolaxiaV2/src/net/server/handlers/login/GuestLoginHandler.java</file>
|
||||||
<file>file:/C:/Nexon/MapleSolaxia/MapleSolaxiaV2/src/server/quest/MapleQuest.java</file>
|
<file>file:/C:/Nexon/MapleSolaxia/MapleSolaxiaV2/src/tools/MaplePacketCreator.java</file>
|
||||||
</group>
|
</group>
|
||||||
</open-files>
|
</open-files>
|
||||||
</project-private>
|
</project-private>
|
||||||
|
|||||||
@@ -24,6 +24,10 @@ var choice;
|
|||||||
var guildName;
|
var guildName;
|
||||||
var partymembers;
|
var partymembers;
|
||||||
|
|
||||||
|
var allianceCost = 2000000;
|
||||||
|
var increaseCost = 1000000;
|
||||||
|
var allianceLimit = 5;
|
||||||
|
|
||||||
function start() {
|
function start() {
|
||||||
partymembers = cm.getPartyMembers();
|
partymembers = cm.getPartyMembers();
|
||||||
status = -1;
|
status = -1;
|
||||||
@@ -37,22 +41,40 @@ function action(mode, type, selection) {
|
|||||||
cm.dispose();
|
cm.dispose();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (status == 0)
|
if (status == 0) {
|
||||||
cm.sendSimple("Hello there! I'm #bLenario#k\r\n#b#L0#Can you please tell me what Guild Union is all about?#l\r\n#L1#How do I make a Guild Union?#l\r\n#L2#I want to make a Guild Union.#l\r\n#L3#I want to add more guilds for the Guild Union.#l\r\n#L4#I want to break up the Guild Union.#l");
|
if(cm.getPlayer().getGuildId() < 1 || cm.getPlayer().getGuildRank() != 1) {
|
||||||
|
cm.sendNext("Hello there! I'm #bLenario#k. Just guild masters can attempt to form guild unions.");
|
||||||
|
cm.dispose();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(!cm.isLeader()) {
|
||||||
|
cm.sendNext("Hello there! I'm #bLenario#k. If you want to form a guild, please tell your party leader to talk to me. He/She will be assigned as the Leader of the Guild Union.");
|
||||||
|
cm.dispose();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
cm.sendSimple("Hello there! I'm #bLenario#k.\r\n#b#L0#Can you please tell me what Guild Union is all about?#l\r\n#L1#How do I make a Guild Union?#l\r\n#L2#I want to make a Guild Union.#l\r\n#L3#I want to add more guilds for the Guild Union.#l\r\n#L4#I want to break up the Guild Union.#l");
|
||||||
|
}
|
||||||
else if (status == 1) {
|
else if (status == 1) {
|
||||||
choice = selection;
|
choice = selection;
|
||||||
if (selection == 0) {
|
if (selection == 0) {
|
||||||
cm.sendNext("Guild Union is just as it says, a union of a number of guilds to form a super group. I am in charge of managing these Guild Unions.");
|
cm.sendNext("Guild Union is just as it says, a union of a number of guilds to form a super group. I am in charge of managing these Guild Unions.");
|
||||||
cm.dispose();
|
cm.dispose();
|
||||||
} else if (selection == 1) {
|
} else if (selection == 1) {
|
||||||
cm.sendNext("To make a Guild Union, 2 Guild Masters need to be in a party. The leader of this party will be assigned as the Guild Union Master.");
|
cm.sendNext("To make a Guild Union, two and only two Guild Masters need to be in a party and both must be present on this room on the same channel. The leader of this party will be assigned as the Guild Union Master.");
|
||||||
cm.dispose();
|
cm.dispose();
|
||||||
} else if(selection == 2) {
|
} else if(selection == 2) {
|
||||||
cm.sendYesNo("Oh, are you interested in forming a Guild Union?");
|
if(cm.getPlayer().getGuild().getAllianceId() > 0) {
|
||||||
|
cm.sendOk("You can not create a Guild Union while your guild is already registered in another.");
|
||||||
|
cm.dispose();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
cm.sendYesNo("Oh, are you interested in forming a Guild Union? The current fee for this operation is #b" + allianceCost + " mesos#k.");
|
||||||
} else if (selection == 3) {
|
} else if (selection == 3) {
|
||||||
var rank = cm.getPlayer().getMGC().getAllianceRank();
|
var rank = cm.getPlayer().getMGC().getAllianceRank();
|
||||||
if (rank == 1)
|
if (rank == 1)
|
||||||
cm.sendOk("Not done yet"); //ExpandGuild Text
|
cm.sendYesNo("Do you want to increase your Alliance by one guild slot? The fee for this procedure is #b" + increaseCost + " mesos#k.");
|
||||||
else {
|
else {
|
||||||
cm.sendNext("Only the Guild Union Master can expand the number of guilds in the Union.");
|
cm.sendNext("Only the Guild Union Master can expand the number of guilds in the Union.");
|
||||||
cm.dispose();
|
cm.dispose();
|
||||||
@@ -68,12 +90,29 @@ function action(mode, type, selection) {
|
|||||||
}
|
}
|
||||||
} else if(status == 2) {
|
} else if(status == 2) {
|
||||||
if (choice == 2) {
|
if (choice == 2) {
|
||||||
cm.sendGetText("Now please enter the name of your new Guild Union. (max. 12 letters)");
|
if(cm.getMeso() < allianceCost) {
|
||||||
} else if (choice == 4) {
|
cm.sendOk("You don't have enough mesos for this request.");
|
||||||
if (cm.getPlayer().getGuild() == null) {
|
|
||||||
cm.sendNext("You cannot disband a non-existant Guild Union.");
|
|
||||||
cm.dispose();
|
cm.dispose();
|
||||||
} else if (cm.getPlayer().getGuild().getAllianceId() <= 0) {
|
return;
|
||||||
|
}
|
||||||
|
cm.sendGetText("Now please enter the name of your new Guild Union. (max. 12 letters)");
|
||||||
|
} else if (choice == 3) {
|
||||||
|
if(cm.getAllianceCapacity() == allianceLimit) {
|
||||||
|
cm.sendOk("Your alliance already reached the maximum capacity for guilds.");
|
||||||
|
cm.dispose();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(cm.getMeso() < increaseCost) {
|
||||||
|
cm.sendOk("You don't have enough mesos for this request.");
|
||||||
|
cm.dispose();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
cm.upgradeAlliance();
|
||||||
|
cm.gainMeso(-increaseCost);
|
||||||
|
cm.sendOk("Your alliance can now accept one more guild.");
|
||||||
|
} else if (choice == 4) {
|
||||||
|
if (cm.getPlayer().getGuild() == null || cm.getPlayer().getGuild().getAllianceId() <= 0) {
|
||||||
cm.sendNext("You cannot disband a non-existant Guild Union.");
|
cm.sendNext("You cannot disband a non-existant Guild Union.");
|
||||||
cm.dispose();
|
cm.dispose();
|
||||||
} else {
|
} else {
|
||||||
@@ -84,17 +123,19 @@ function action(mode, type, selection) {
|
|||||||
}
|
}
|
||||||
} else if (status == 3) {
|
} else if (status == 3) {
|
||||||
guildName = cm.getText();
|
guildName = cm.getText();
|
||||||
cm.sendYesNo("Will "+ guildName + " be the name of your Guild Union?");
|
cm.sendYesNo("Will '"+ guildName + "' be the name of your Guild Union?");
|
||||||
} else if (status == 4) {
|
} else if (status == 4) {
|
||||||
if (!cm.canBeUsedAllianceName(guildName)) {
|
if (!cm.canBeUsedAllianceName(guildName)) {
|
||||||
cm.sendNext("This name is unavailable, please choose another one"); //Not real text
|
cm.sendNext("This name is unavailable, please choose another one."); //Not real text
|
||||||
status = 1;
|
status = 1;
|
||||||
choice = 2;
|
choice = 2;
|
||||||
} else {
|
} else {
|
||||||
if (cm.createAlliance(partymembers.get(0), partymembers.get(1), guildName) == null)
|
if (cm.createAlliance(guildName) == null)
|
||||||
cm.sendOk("An unknown system error has occured.");
|
cm.sendOk("Please check if you and the other one guild leader in your party are both here on this room right now. No other guild leaders should be present with you 2 on this process.");
|
||||||
else
|
else {
|
||||||
|
cm.gainMeso(-allianceCost);
|
||||||
cm.sendOk("You have successfully formed a Guild Union.");
|
cm.sendOk("You have successfully formed a Guild Union.");
|
||||||
|
}
|
||||||
cm.dispose();
|
cm.dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-10
@@ -52,16 +52,13 @@ CREATE TABLE IF NOT EXISTS `alliance` (
|
|||||||
`name` varchar(13) NOT NULL,
|
`name` varchar(13) NOT NULL,
|
||||||
`notice` varchar(128) NOT NULL DEFAULT '',
|
`notice` varchar(128) NOT NULL DEFAULT '',
|
||||||
`capacity` int(10) unsigned NOT NULL DEFAULT '2',
|
`capacity` int(10) unsigned NOT NULL DEFAULT '2',
|
||||||
`rank_title1` varchar(45) NOT NULL DEFAULT 'Master',
|
PRIMARY KEY (`id`)
|
||||||
`rank_title2` varchar(45) NOT NULL DEFAULT 'Jr.Master',
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
|
||||||
`rank_title3` varchar(45) NOT NULL DEFAULT 'Member',
|
|
||||||
`rank_title4` varchar(45) NOT NULL DEFAULT 'Member',
|
CREATE TABLE IF NOT EXISTS `allianceguilds` (
|
||||||
`rank_title5` varchar(45) NOT NULL DEFAULT 'Member',
|
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
`guild1` int(10) NOT NULL DEFAULT '-1',
|
`allianceid` int(10) NOT NULL DEFAULT '-1',
|
||||||
`guild2` int(10) NOT NULL DEFAULT '-1',
|
`guildid` int(10) NOT NULL DEFAULT '-1',
|
||||||
`guild3` int(10) NOT NULL DEFAULT '-1',
|
|
||||||
`guild4` int(10) NOT NULL DEFAULT '-1',
|
|
||||||
`guild5` int(10) NOT NULL DEFAULT '-1',
|
|
||||||
PRIMARY KEY (`id`)
|
PRIMARY KEY (`id`)
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
|
||||||
|
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ import net.server.PlayerCoolDownValueHolder;
|
|||||||
import net.server.PlayerDiseaseValueHolder;
|
import net.server.PlayerDiseaseValueHolder;
|
||||||
import net.server.Server;
|
import net.server.Server;
|
||||||
import net.server.channel.Channel;
|
import net.server.channel.Channel;
|
||||||
|
import net.server.guild.MapleAlliance;
|
||||||
import net.server.guild.MapleGuild;
|
import net.server.guild.MapleGuild;
|
||||||
import net.server.guild.MapleGuildCharacter;
|
import net.server.guild.MapleGuildCharacter;
|
||||||
import net.server.world.MapleMessenger;
|
import net.server.world.MapleMessenger;
|
||||||
@@ -2206,6 +2207,18 @@ public class MapleCharacter extends AbstractAnimatedMapleMapObject {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MapleAlliance getAlliance() {
|
||||||
|
if(mgc != null) {
|
||||||
|
try {
|
||||||
|
return Server.getInstance().getAlliance(getGuild().getAllianceId());
|
||||||
|
} catch (Exception ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public int getGuildId() {
|
public int getGuildId() {
|
||||||
return guildid;
|
return guildid;
|
||||||
}
|
}
|
||||||
@@ -3351,7 +3364,7 @@ public class MapleCharacter extends AbstractAnimatedMapleMapObject {
|
|||||||
ret.dojoStage = rs.getInt("lastDojoStage");
|
ret.dojoStage = rs.getInt("lastDojoStage");
|
||||||
ret.dataString = rs.getString("dataString");
|
ret.dataString = rs.getString("dataString");
|
||||||
if (ret.guildid > 0) {
|
if (ret.guildid > 0) {
|
||||||
ret.mgc = new MapleGuildCharacter(ret);
|
ret.mgc = new MapleGuildCharacter(ret); // oh boy, that's quite funny
|
||||||
}
|
}
|
||||||
int buddyCapacity = rs.getInt("buddyCapacity");
|
int buddyCapacity = rs.getInt("buddyCapacity");
|
||||||
ret.buddylist = new BuddyList(buddyCapacity);
|
ret.buddylist = new BuddyList(buddyCapacity);
|
||||||
@@ -4147,8 +4160,8 @@ public class MapleCharacter extends AbstractAnimatedMapleMapObject {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void resetMGC() {
|
public void resetMGC(MapleGuildCharacter mgc) {
|
||||||
this.mgc = null;
|
this.mgc = mgc;
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void saveCooldowns() {
|
public synchronized void saveCooldowns() {
|
||||||
@@ -4179,7 +4192,7 @@ public class MapleCharacter extends AbstractAnimatedMapleMapObject {
|
|||||||
ps.setInt(2, guildrank);
|
ps.setInt(2, guildrank);
|
||||||
ps.setInt(3, allianceRank);
|
ps.setInt(3, allianceRank);
|
||||||
ps.setInt(4, id);
|
ps.setInt(4, id);
|
||||||
ps.execute();
|
ps.executeUpdate();
|
||||||
}
|
}
|
||||||
} catch (SQLException se) {
|
} catch (SQLException se) {
|
||||||
se.printStackTrace();
|
se.printStackTrace();
|
||||||
|
|||||||
@@ -786,6 +786,8 @@ public class MapleClient {
|
|||||||
final MapleGuild guild = player.getGuild();
|
final MapleGuild guild = player.getGuild();
|
||||||
|
|
||||||
if (channel == -1 || shutdown) {
|
if (channel == -1 || shutdown) {
|
||||||
|
chrg.setCharacter(null);
|
||||||
|
|
||||||
removePlayer();
|
removePlayer();
|
||||||
player.saveCooldowns();
|
player.saveCooldowns();
|
||||||
player.saveToDB();
|
player.saveToDB();
|
||||||
@@ -944,7 +946,7 @@ public class MapleClient {
|
|||||||
}
|
}
|
||||||
if (rs.getInt("guildid") > 0) {
|
if (rs.getInt("guildid") > 0) {
|
||||||
try {
|
try {
|
||||||
Server.getInstance().deleteGuildCharacter(new MapleGuildCharacter(cid, 0, rs.getString("name"), (byte) -1, (byte) -1, 0, rs.getInt("guildrank"), rs.getInt("guildid"), false, rs.getInt("allianceRank")));
|
Server.getInstance().deleteGuildCharacter(new MapleGuildCharacter(player, cid, 0, rs.getString("name"), (byte) -1, (byte) -1, 0, rs.getInt("guildrank"), rs.getInt("guildid"), false, rs.getInt("allianceRank")));
|
||||||
} catch (Exception re) {
|
} catch (Exception re) {
|
||||||
re.printStackTrace();
|
re.printStackTrace();
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -316,7 +316,12 @@ public class Commands {
|
|||||||
switch (sub[0]) {
|
switch (sub[0]) {
|
||||||
case "help":
|
case "help":
|
||||||
case "commands":
|
case "commands":
|
||||||
player.yellowMessage("After you vote, talk to Rooney to get a leaf and redeem it for prizes!");
|
|
||||||
|
|
||||||
|
case "playercommands":
|
||||||
|
player.message("============================================================");
|
||||||
|
player.message("MapleSolaxiaV2 Player Commands");
|
||||||
|
player.message("============================================================");
|
||||||
player.message("@dispose: Fixes your character if it is stuck.");
|
player.message("@dispose: Fixes your character if it is stuck.");
|
||||||
player.message("@online: Displays a list of all online players.");
|
player.message("@online: Displays a list of all online players.");
|
||||||
player.message("@time: Displays the current server time.");
|
player.message("@time: Displays the current server time.");
|
||||||
@@ -368,10 +373,6 @@ public class Commands {
|
|||||||
player.yellowMessage("Solaxia has been online for " + days + " days " + hours + " hours " + minutes + " minutes and " + seconds + " seconds.");
|
player.yellowMessage("Solaxia has been online for " + days + " days " + hours + " hours " + minutes + " minutes and " + seconds + " seconds.");
|
||||||
break;
|
break;
|
||||||
case "gacha":
|
case "gacha":
|
||||||
if (player.gmLevel() == 0) { // Sigh, need it for now...
|
|
||||||
player.yellowMessage("Player Command " + heading + sub[0] + " does not exist, see @help for a list of commands.");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
Gachapon gacha = null;
|
Gachapon gacha = null;
|
||||||
String search = joinStringFrom(sub, 1);
|
String search = joinStringFrom(sub, 1);
|
||||||
String gachaName = "";
|
String gachaName = "";
|
||||||
@@ -478,7 +479,11 @@ public class Commands {
|
|||||||
player.message("You've been disposed.");
|
player.message("You've been disposed.");
|
||||||
break;
|
break;
|
||||||
case "rates":
|
case "rates":
|
||||||
c.resetVoteTime();
|
//c.resetVoteTime();
|
||||||
|
player.yellowMessage("BOSSDROP RATE");
|
||||||
|
player.message(">>Total BOSSDROP Rate: " + c.getWorldServer().getBossDropRate() + "x");
|
||||||
|
player.message(">>------------------------------------------------");
|
||||||
|
|
||||||
player.yellowMessage("DROP RATE");
|
player.yellowMessage("DROP RATE");
|
||||||
player.message(">>Base DROP Rate: " + c.getWorldServer().getDropRate() + "x");
|
player.message(">>Base DROP Rate: " + c.getWorldServer().getDropRate() + "x");
|
||||||
player.message(">>Your DROP Rate: " + player.getDropRate() / c.getWorldServer().getDropRate() + "x");
|
player.message(">>Your DROP Rate: " + player.getDropRate() / c.getWorldServer().getDropRate() + "x");
|
||||||
@@ -671,7 +676,7 @@ public class Commands {
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
if (player.gmLevel() == 0) {
|
if (player.gmLevel() == 0) {
|
||||||
player.yellowMessage("Player Command " + heading + sub[0] + " does not exist, see @help for a list of commands.");
|
player.yellowMessage("Player Command " + heading + sub[0] + " does not exist, see @playercommands for a list of commands.");
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -683,7 +688,12 @@ public class Commands {
|
|||||||
Channel cserv = c.getChannelServer();
|
Channel cserv = c.getChannelServer();
|
||||||
Server srv = Server.getInstance();
|
Server srv = Server.getInstance();
|
||||||
|
|
||||||
if (sub[0].equals("sp")) {
|
if (sub[0].equals("commands")) {
|
||||||
|
player.message("============================================================");
|
||||||
|
player.message("MapleSolaxiaV2 GM/Admin Commands Available");
|
||||||
|
player.message("============================================================");
|
||||||
|
}
|
||||||
|
else if (sub[0].equals("sp")) {
|
||||||
if (sub.length < 2){
|
if (sub.length < 2){
|
||||||
player.yellowMessage("Syntax: !sp [<playername>] <newsp>");
|
player.yellowMessage("Syntax: !sp [<playername>] <newsp>");
|
||||||
return true;
|
return true;
|
||||||
@@ -1571,7 +1581,6 @@ public class Commands {
|
|||||||
SkillFactory.getSkill(9101004).getEffect(SkillFactory.getSkill(9101004).getMaxLevel()).applyTo(player);
|
SkillFactory.getSkill(9101004).getEffect(SkillFactory.getSkill(9101004).getMaxLevel()).applyTo(player);
|
||||||
} else if (sub[0].equals("unhide")) {
|
} else if (sub[0].equals("unhide")) {
|
||||||
SkillFactory.getSkill(9101004).getEffect(SkillFactory.getSkill(9101004).getMaxLevel()).applyTo(player);
|
SkillFactory.getSkill(9101004).getEffect(SkillFactory.getSkill(9101004).getMaxLevel()).applyTo(player);
|
||||||
|
|
||||||
} else if (sub[0].equals("healmap")) {
|
} else if (sub[0].equals("healmap")) {
|
||||||
for (MapleCharacter mch : player.getMap().getCharacters()) {
|
for (MapleCharacter mch : player.getMap().getCharacters()) {
|
||||||
if (mch != null) {
|
if (mch != null) {
|
||||||
@@ -1581,6 +1590,39 @@ public class Commands {
|
|||||||
mch.updateSingleStat(MapleStat.MP, mch.getMaxMp());
|
mch.updateSingleStat(MapleStat.MP, mch.getMaxMp());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if (sub[0].equals("healperson")) {
|
||||||
|
MapleCharacter victim = cserv.getPlayerStorage().getCharacterByName(sub[1]);
|
||||||
|
victim.setHp(victim.getMaxHp());
|
||||||
|
victim.updateSingleStat(MapleStat.HP, victim.getMaxHp());
|
||||||
|
victim.setMp(victim.getMaxMp());
|
||||||
|
victim.updateSingleStat(MapleStat.MP, victim.getMaxMp());
|
||||||
|
} else if (sub[0].equals("hurt")) {
|
||||||
|
MapleCharacter victim = cserv.getPlayerStorage().getCharacterByName(sub[1]);
|
||||||
|
victim.setHp(1);
|
||||||
|
victim.updateSingleStat(MapleStat.HP, 1);
|
||||||
|
} else if (sub[0].equals("killmap")) {
|
||||||
|
for (MapleCharacter mch : player.getMap().getCharacters()) {
|
||||||
|
mch.setHp(0);
|
||||||
|
mch.updateSingleStat(MapleStat.HP, 0);
|
||||||
|
}
|
||||||
|
} else if (sub[0].equals("mesorate")) {
|
||||||
|
if (sub.length < 2){
|
||||||
|
player.yellowMessage("Syntax: !mesorate <newrate>");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
c.getWorldServer().setMesoRate(Integer.parseInt(sub[1]));
|
||||||
|
} else if (sub[0].equals("droprate")) {
|
||||||
|
if (sub.length < 2){
|
||||||
|
player.yellowMessage("Syntax: !droprate <newrate>");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
c.getWorldServer().setDropRate(Integer.parseInt(sub[1]));
|
||||||
|
} else if (sub[0].equals("bossdroprate")) {
|
||||||
|
if (sub.length < 2){
|
||||||
|
player.yellowMessage("Syntax: !bossdroprate <newrate>");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
c.getWorldServer().setBossDropRate(Integer.parseInt(sub[1]));
|
||||||
} else if (sub[0].equalsIgnoreCase("night")) {
|
} else if (sub[0].equalsIgnoreCase("night")) {
|
||||||
player.getMap().broadcastNightEffect();
|
player.getMap().broadcastNightEffect();
|
||||||
player.yellowMessage("Done.");
|
player.yellowMessage("Done.");
|
||||||
@@ -1806,14 +1848,14 @@ public class Commands {
|
|||||||
break;
|
break;
|
||||||
case "clearquest":
|
case "clearquest":
|
||||||
if(sub.length < 1) {
|
if(sub.length < 1) {
|
||||||
player.dropMessage(5, "Plese include a quest ID.");
|
player.dropMessage(5, "Please include a quest ID.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
MapleQuest.clearCache(Integer.parseInt(sub[1]));
|
MapleQuest.clearCache(Integer.parseInt(sub[1]));
|
||||||
player.dropMessage(5, "Quest Cache for quest " + sub[1] + " cleared.");
|
player.dropMessage(5, "Quest Cache for quest " + sub[1] + " cleared.");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
player.yellowMessage("Command " + heading + sub[0] + " does not exist.");
|
player.yellowMessage("Command " + heading + sub[0] + " does not exist. See !commands for a list of available commands.");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -130,6 +130,8 @@ public class MapleServerHandler extends IoHandlerAdapter {
|
|||||||
SeekableLittleEndianAccessor slea = new GenericSeekableLittleEndianAccessor(new ByteArrayByteStream(content));
|
SeekableLittleEndianAccessor slea = new GenericSeekableLittleEndianAccessor(new ByteArrayByteStream(content));
|
||||||
short packetId = slea.readShort();
|
short packetId = slea.readShort();
|
||||||
MapleClient client = (MapleClient) session.getAttribute(MapleClient.CLIENT_KEY);
|
MapleClient client = (MapleClient) session.getAttribute(MapleClient.CLIENT_KEY);
|
||||||
|
|
||||||
|
//System.out.println("Received packet id " + packetId);
|
||||||
final MaplePacketHandler packetHandler = processor.getHandler(packetId);
|
final MaplePacketHandler packetHandler = processor.getHandler(packetId);
|
||||||
if (packetHandler != null && packetHandler.validateState(client)) {
|
if (packetHandler != null && packetHandler.validateState(client)) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -134,11 +134,11 @@ public enum RecvOpcode {
|
|||||||
RPS_ACTION(0x88),
|
RPS_ACTION(0x88),
|
||||||
RING_ACTION(0x89),
|
RING_ACTION(0x89),
|
||||||
WEDDING_ACTION(0x8A),
|
WEDDING_ACTION(0x8A),
|
||||||
|
ALLIANCE_OPERATION(0x8F),
|
||||||
OPEN_FAMILY(0x92),
|
OPEN_FAMILY(0x92),
|
||||||
ADD_FAMILY(0x93),
|
ADD_FAMILY(0x93),
|
||||||
ACCEPT_FAMILY(0x96),
|
ACCEPT_FAMILY(0x96),
|
||||||
USE_FAMILY(0x97),
|
USE_FAMILY(0x97),
|
||||||
ALLIANCE_OPERATION(0x98),
|
|
||||||
BBS_OPERATION(0x9B),
|
BBS_OPERATION(0x9B),
|
||||||
ENTER_MTS(0x9C),
|
ENTER_MTS(0x9C),
|
||||||
USE_SOLOMON_ITEM(0x9D),
|
USE_SOLOMON_ITEM(0x9D),
|
||||||
|
|||||||
@@ -287,6 +287,7 @@ public class Server implements Runnable {
|
|||||||
MapleAlliance alliance = alliances.get(aId);
|
MapleAlliance alliance = alliances.get(aId);
|
||||||
if (alliance != null) {
|
if (alliance != null) {
|
||||||
alliance.addGuild(guildId);
|
alliance.addGuild(guildId);
|
||||||
|
guilds.get(guildId).setAllianceId(aId);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -296,6 +297,7 @@ public class Server implements Runnable {
|
|||||||
MapleAlliance alliance = alliances.get(aId);
|
MapleAlliance alliance = alliances.get(aId);
|
||||||
if (alliance != null) {
|
if (alliance != null) {
|
||||||
alliance.removeGuild(guildId);
|
alliance.removeGuild(guildId);
|
||||||
|
guilds.get(guildId).setAllianceId(0);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -347,6 +349,16 @@ public class Server implements Runnable {
|
|||||||
return MapleGuild.createGuild(leaderId, name);
|
return MapleGuild.createGuild(leaderId, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MapleGuild getGuild(int id) {
|
||||||
|
synchronized (guilds) {
|
||||||
|
if (guilds.get(id) != null) {
|
||||||
|
return guilds.get(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public MapleGuild getGuild(int id, int world, MapleGuildCharacter mgc) {
|
public MapleGuild getGuild(int id, int world, MapleGuildCharacter mgc) {
|
||||||
synchronized (guilds) {
|
synchronized (guilds) {
|
||||||
if (guilds.get(id) != null) {
|
if (guilds.get(id) != null) {
|
||||||
@@ -394,6 +406,10 @@ public class Server implements Runnable {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void resetAllianceGuildPlayersRank(int gId) {
|
||||||
|
guilds.get(gId).resetAllianceGuildPlayersRank();
|
||||||
|
}
|
||||||
|
|
||||||
public void leaveGuild(MapleGuildCharacter mgc) {
|
public void leaveGuild(MapleGuildCharacter mgc) {
|
||||||
MapleGuild g = guilds.get(mgc.getGuildId());
|
MapleGuild g = guilds.get(mgc.getGuildId());
|
||||||
if (g != null) {
|
if (g != null) {
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import client.MapleClient;
|
|||||||
import net.AbstractMaplePacketHandler;
|
import net.AbstractMaplePacketHandler;
|
||||||
import net.SendOpcode;
|
import net.SendOpcode;
|
||||||
import net.server.Server;
|
import net.server.Server;
|
||||||
|
import net.server.guild.MapleGuildCharacter;
|
||||||
import net.server.guild.MapleAlliance;
|
import net.server.guild.MapleAlliance;
|
||||||
import tools.MaplePacketCreator;
|
import tools.MaplePacketCreator;
|
||||||
import tools.data.input.SeekableLittleEndianAccessor;
|
import tools.data.input.SeekableLittleEndianAccessor;
|
||||||
@@ -39,31 +40,48 @@ public final class AllianceOperationHandler extends AbstractMaplePacketHandler {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
|
public final void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
|
||||||
|
System.out.print("aop ");
|
||||||
|
|
||||||
MapleAlliance alliance = null;
|
MapleAlliance alliance = null;
|
||||||
if (c.getPlayer().getGuild() != null && c.getPlayer().getGuild().getAllianceId() > 0) {
|
if (c.getPlayer().getGuild() != null && c.getPlayer().getGuild().getAllianceId() > 0) {
|
||||||
alliance = Server.getInstance().getAlliance(c.getPlayer().getGuild().getAllianceId());
|
alliance = c.getPlayer().getAlliance();
|
||||||
}
|
}
|
||||||
if (alliance == null) {
|
if (alliance == null) {
|
||||||
c.getPlayer().dropMessage("You are not in an alliance.");
|
|
||||||
c.announce(MaplePacketCreator.enableActions());
|
c.announce(MaplePacketCreator.enableActions());
|
||||||
return;
|
return;
|
||||||
} else if (c.getPlayer().getMGC().getAllianceRank() > 2 || !alliance.getGuilds().contains(c.getPlayer().getGuildId())) {
|
} else if (c.getPlayer().getMGC().getAllianceRank() > 2 || !alliance.getGuilds().contains(c.getPlayer().getGuildId())) {
|
||||||
c.announce(MaplePacketCreator.enableActions());
|
c.announce(MaplePacketCreator.enableActions());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
switch (slea.readByte()) {
|
|
||||||
|
byte b = slea.readByte();
|
||||||
|
System.out.print(b);
|
||||||
|
switch (b) {
|
||||||
case 0x01:
|
case 0x01:
|
||||||
|
System.out.print(" case 1");
|
||||||
Server.getInstance().allianceMessage(alliance.getId(), sendShowInfo(c.getPlayer().getGuild().getAllianceId(), c.getPlayer().getId()), -1, -1);
|
Server.getInstance().allianceMessage(alliance.getId(), sendShowInfo(c.getPlayer().getGuild().getAllianceId(), c.getPlayer().getId()), -1, -1);
|
||||||
break;
|
break;
|
||||||
case 0x02: { // Leave Alliance
|
case 0x02: { // Leave Alliance
|
||||||
|
System.out.print(" case 2");
|
||||||
if (c.getPlayer().getGuild().getAllianceId() == 0 || c.getPlayer().getGuildId() < 1 || c.getPlayer().getGuildRank() != 1) {
|
if (c.getPlayer().getGuild().getAllianceId() == 0 || c.getPlayer().getGuildId() < 1 || c.getPlayer().getGuildRank() != 1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Server.getInstance().allianceMessage(alliance.getId(), sendChangeGuild(c.getPlayer().getGuildId(), c.getPlayer().getId(), c.getPlayer().getGuildId(), 2), -1, -1);
|
int guildid = c.getPlayer().getGuildId();
|
||||||
|
|
||||||
|
Server.getInstance().allianceMessage(alliance.getId(), MaplePacketCreator.removeGuildFromAlliance(alliance, guildid, c), -1, -1);
|
||||||
|
Server.getInstance().removeGuildFromAlliance(alliance.getId(), guildid);
|
||||||
|
|
||||||
|
Server.getInstance().allianceMessage(alliance.getId(), MaplePacketCreator.getGuildAlliances(alliance, c), -1, -1);
|
||||||
|
Server.getInstance().guildMessage(guildid, MaplePacketCreator.disbandAlliance(alliance.getId()));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 0x03: // send alliance invite
|
case 0x03: // send alliance invite
|
||||||
|
System.out.print(" case 3 avail is " + slea.available());
|
||||||
String charName = slea.readMapleAsciiString();
|
String charName = 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;
|
int channel;
|
||||||
channel = c.getWorldServer().find(charName);
|
channel = c.getWorldServer().find(charName);
|
||||||
if (channel == -1) {
|
if (channel == -1) {
|
||||||
@@ -75,11 +93,14 @@ public final class AllianceOperationHandler extends AbstractMaplePacketHandler {
|
|||||||
} else if (victim.getGuildRank() != 1) {
|
} else if (victim.getGuildRank() != 1) {
|
||||||
c.getPlayer().dropMessage("The player is not the leader of his/her guild.");
|
c.getPlayer().dropMessage("The player is not the leader of his/her guild.");
|
||||||
} else {
|
} else {
|
||||||
Server.getInstance().allianceMessage(alliance.getId(), sendInvitation(c.getPlayer().getGuild().getAllianceId(), c.getPlayer().getId(), slea.readMapleAsciiString()), -1, -1);
|
Server.getInstance().allianceMessage(alliance.getId(), sendInvitation(c.getPlayer().getGuild().getAllianceId(), c.getPlayer().getId(), charName), -1, -1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 0x04: {
|
case 0x04: {
|
||||||
|
System.out.print(" case 4");
|
||||||
int guildid = slea.readInt();
|
int guildid = slea.readInt();
|
||||||
// slea.readMapleAsciiString();//guild name
|
// slea.readMapleAsciiString();//guild name
|
||||||
if (c.getPlayer().getGuild().getAllianceId() != 0 || c.getPlayer().getGuildRank() != 1 || c.getPlayer().getGuildId() < 1) {
|
if (c.getPlayer().getGuild().getAllianceId() != 0 || c.getPlayer().getGuildRank() != 1 || c.getPlayer().getGuildId() < 1) {
|
||||||
@@ -89,22 +110,36 @@ public final class AllianceOperationHandler extends AbstractMaplePacketHandler {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 0x06: { // Expel Guild
|
case 0x06: { // Expel Guild
|
||||||
|
System.out.print(" case 6");
|
||||||
int guildid = slea.readInt();
|
int guildid = slea.readInt();
|
||||||
int allianceid = slea.readInt();
|
int allianceid = slea.readInt();
|
||||||
if (c.getPlayer().getGuild().getAllianceId() == 0 || c.getPlayer().getGuild().getAllianceId() != allianceid) {
|
if (c.getPlayer().getGuild().getAllianceId() == 0 || c.getPlayer().getGuild().getAllianceId() != allianceid) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Server.getInstance().allianceMessage(alliance.getId(), sendChangeGuild(allianceid, c.getPlayer().getId(), guildid, 1), -1, -1);
|
|
||||||
|
Server.getInstance().allianceMessage(alliance.getId(), MaplePacketCreator.removeGuildFromAlliance(alliance, guildid, c), -1, -1);
|
||||||
|
Server.getInstance().removeGuildFromAlliance(alliance.getId(), guildid);
|
||||||
|
|
||||||
|
Server.getInstance().allianceMessage(alliance.getId(), MaplePacketCreator.getGuildAlliances(alliance, c), -1, -1);
|
||||||
|
Server.getInstance().guildMessage(guildid, MaplePacketCreator.disbandAlliance(allianceid));
|
||||||
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 0x07: { // Change Alliance Leader
|
case 0x07: { // Change Alliance Leader
|
||||||
|
System.out.print(" case 7");
|
||||||
if (c.getPlayer().getGuild().getAllianceId() == 0 || c.getPlayer().getGuildId() < 1) {
|
if (c.getPlayer().getGuild().getAllianceId() == 0 || c.getPlayer().getGuildId() < 1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Server.getInstance().allianceMessage(alliance.getId(), sendChangeLeader(c.getPlayer().getGuild().getAllianceId(), c.getPlayer().getId(), slea.readInt()), -1, -1);
|
int victimid = slea.readInt();
|
||||||
|
MapleCharacter player = Server.getInstance().getWorld(c.getWorld()).getPlayerStorage().getCharacterById(victimid);
|
||||||
|
|
||||||
|
//Server.getInstance().allianceMessage(alliance.getId(), sendChangeLeader(c.getPlayer().getGuild().getAllianceId(), c.getPlayer().getId(), slea.readInt()), -1, -1);
|
||||||
|
changeLeaderAllianceRank(alliance, player);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 0x08:
|
case 0x08:
|
||||||
|
System.out.print(" case 8");
|
||||||
String ranks[] = new String[5];
|
String ranks[] = new String[5];
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
ranks[i] = slea.readMapleAsciiString();
|
ranks[i] = slea.readMapleAsciiString();
|
||||||
@@ -113,12 +148,18 @@ public final class AllianceOperationHandler extends AbstractMaplePacketHandler {
|
|||||||
Server.getInstance().allianceMessage(alliance.getId(), MaplePacketCreator.changeAllianceRankTitle(alliance.getId(), ranks), -1, -1);
|
Server.getInstance().allianceMessage(alliance.getId(), MaplePacketCreator.changeAllianceRankTitle(alliance.getId(), ranks), -1, -1);
|
||||||
break;
|
break;
|
||||||
case 0x09: {
|
case 0x09: {
|
||||||
|
System.out.print(" case 9");
|
||||||
int int1 = slea.readInt();
|
int int1 = slea.readInt();
|
||||||
byte byte1 = slea.readByte();
|
byte byte1 = slea.readByte();
|
||||||
Server.getInstance().allianceMessage(alliance.getId(), sendChangeRank(c.getPlayer().getGuild().getAllianceId(), c.getPlayer().getId(), int1, byte1), -1, -1);
|
|
||||||
|
//Server.getInstance().allianceMessage(alliance.getId(), sendChangeRank(c.getPlayer().getGuild().getAllianceId(), c.getPlayer().getId(), int1, byte1), -1, -1);
|
||||||
|
MapleCharacter player = Server.getInstance().getWorld(c.getWorld()).getPlayerStorage().getCharacterById(int1);
|
||||||
|
changePlayerAllianceRank(alliance, player, (byte1 > 0));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 0x0A:
|
case 0x0A:
|
||||||
|
System.out.print(" case A");
|
||||||
String notice = slea.readMapleAsciiString();
|
String notice = slea.readMapleAsciiString();
|
||||||
Server.getInstance().setAllianceNotice(alliance.getId(), notice);
|
Server.getInstance().setAllianceNotice(alliance.getId(), notice);
|
||||||
Server.getInstance().allianceMessage(alliance.getId(), MaplePacketCreator.allianceNotice(alliance.getId(), notice), -1, -1);
|
Server.getInstance().allianceMessage(alliance.getId(), MaplePacketCreator.allianceNotice(alliance.getId(), notice), -1, -1);
|
||||||
@@ -126,10 +167,35 @@ public final class AllianceOperationHandler extends AbstractMaplePacketHandler {
|
|||||||
default:
|
default:
|
||||||
c.getPlayer().dropMessage("Feature not available");
|
c.getPlayer().dropMessage("Feature not available");
|
||||||
}
|
}
|
||||||
|
System.out.println("end");
|
||||||
|
|
||||||
alliance.saveToDB();
|
alliance.saveToDB();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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.saveGuildStatus();
|
||||||
|
|
||||||
|
newLeader.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.");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void changePlayerAllianceRank(MapleAlliance alliance, MapleCharacter chr, boolean raise) {
|
||||||
|
int newRank = chr.getAllianceRank() + (raise ? -1 : 1);
|
||||||
|
if(newRank < 2 || newRank > 5) return;
|
||||||
|
|
||||||
|
chr.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.");
|
||||||
|
}
|
||||||
|
|
||||||
private static byte[] sendShowInfo(int allianceid, int playerid) {
|
private static byte[] sendShowInfo(int allianceid, int playerid) {
|
||||||
MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();
|
MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();
|
||||||
mplew.writeShort(SendOpcode.ALLIANCE_OPERATION.getValue());
|
mplew.writeShort(SendOpcode.ALLIANCE_OPERATION.getValue());
|
||||||
|
|||||||
@@ -186,9 +186,11 @@ public final class PlayerLoggedinHandler extends AbstractMaplePacketHandler {
|
|||||||
MapleGuild playerGuild = server.getGuild(player.getGuildId(), player.getWorld(), player.getMGC());
|
MapleGuild playerGuild = server.getGuild(player.getGuildId(), player.getWorld(), player.getMGC());
|
||||||
if (playerGuild == null) {
|
if (playerGuild == null) {
|
||||||
player.deleteGuild(player.getGuildId());
|
player.deleteGuild(player.getGuildId());
|
||||||
player.resetMGC();
|
player.resetMGC(null);
|
||||||
player.setGuildId(0);
|
player.setGuildId(0);
|
||||||
} else {
|
} else {
|
||||||
|
playerGuild.getMGC(player.getId()).setCharacter(player);
|
||||||
|
player.resetMGC(playerGuild.getMGC(player.getId()));
|
||||||
server.setGuildMemberOnline(player.getMGC(), true, c.getChannel());
|
server.setGuildMemberOnline(player.getMGC(), true, c.getChannel());
|
||||||
c.announce(MaplePacketCreator.showGuildInfo(player));
|
c.announce(MaplePacketCreator.showGuildInfo(player));
|
||||||
int allianceId = player.getGuild().getAllianceId();
|
int allianceId = player.getGuild().getAllianceId();
|
||||||
|
|||||||
@@ -27,57 +27,188 @@ import java.sql.SQLException;
|
|||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
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.DatabaseConnection;
|
||||||
|
import tools.MaplePacketCreator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author XoticStory.
|
* @author XoticStory, Ronan.
|
||||||
*/
|
*/
|
||||||
public class MapleAlliance {
|
public class MapleAlliance {
|
||||||
private int[] guilds = new int[5];
|
final private List<Integer> guilds = new LinkedList<>();
|
||||||
|
|
||||||
private int allianceId = -1;
|
private int allianceId = -1;
|
||||||
private int capacity;
|
private int capacity;
|
||||||
private String name;
|
private String name;
|
||||||
private String notice = "";
|
private String notice = "";
|
||||||
private String rankTitles[] = new String[5];
|
private String rankTitles[] = new String[5];
|
||||||
|
|
||||||
public MapleAlliance(String name, int id, int guild1, int guild2) {
|
public MapleAlliance(String name, int id) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
allianceId = id;
|
allianceId = id;
|
||||||
int[] guild = {guild1, guild2, -1, -1, -1};
|
|
||||||
String[] ranks = {"Master", "Jr.Master", "Member", "Member", "Member"};
|
String[] ranks = {"Master", "Jr.Master", "Member", "Member", "Member"};
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
guilds[i] = guild[i];
|
|
||||||
rankTitles[i] = ranks[i];
|
rankTitles[i] = ranks[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean canBeUsedAllianceName(String name) {
|
||||||
|
if (name.contains(" ") || name.length() > 12) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
ResultSet rs;
|
||||||
|
try (PreparedStatement ps = DatabaseConnection.getConnection().prepareStatement("SELECT name FROM alliance WHERE name = ?")) {
|
||||||
|
ps.setString(1, name);
|
||||||
|
rs = ps.executeQuery();
|
||||||
|
if (rs.next()) {
|
||||||
|
ps.close();
|
||||||
|
rs.close();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rs.close();
|
||||||
|
return true;
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static List<MapleCharacter> getPartyGuildMasters(MapleParty party) {
|
||||||
|
List<MapleCharacter> mcl = new LinkedList<>();
|
||||||
|
|
||||||
|
for(MaplePartyCharacter mpc: party.getMembers()) {
|
||||||
|
if(mpc.getPlayer().getGuildRank() == 1 && mpc.getPlayer().getMapId() == party.getLeader().getPlayer().getMapId())
|
||||||
|
mcl.add(mpc.getPlayer());
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!mcl.isEmpty() && !mcl.get(0).isPartyLeader()) {
|
||||||
|
for(int i = 1; i < mcl.size(); i++) {
|
||||||
|
if(mcl.get(i).isPartyLeader()) {
|
||||||
|
MapleCharacter temp = mcl.get(0);
|
||||||
|
mcl.set(0, mcl.get(i));
|
||||||
|
mcl.set(i, temp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return mcl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static MapleAlliance createAlliance(MapleParty party, String name) {
|
||||||
|
List<MapleCharacter> guildMasters = getPartyGuildMasters(party);
|
||||||
|
if(guildMasters.size() != 2) return null;
|
||||||
|
|
||||||
|
List<Integer> guilds = new LinkedList<>();
|
||||||
|
for(MapleCharacter mc: guildMasters) guilds.add(mc.getGuildId());
|
||||||
|
MapleAlliance alliance = MapleAlliance.createAllianceOnDb(guilds, name);
|
||||||
|
if(alliance != null) {
|
||||||
|
alliance.setCapacity(guilds.size());
|
||||||
|
for(Integer g: guilds)
|
||||||
|
alliance.addGuild(g);
|
||||||
|
|
||||||
|
int id = alliance.getId();
|
||||||
|
try {
|
||||||
|
for(int i = 0; i < guildMasters.size(); i++) {
|
||||||
|
Server.getInstance().setGuildAllianceId(guilds.get(i), id);
|
||||||
|
Server.getInstance().resetAllianceGuildPlayersRank(guilds.get(i));
|
||||||
|
|
||||||
|
MapleCharacter chr = guildMasters.get(i);
|
||||||
|
chr.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);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return alliance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static MapleAlliance 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;
|
||||||
|
try {
|
||||||
|
Connection con = DatabaseConnection.getConnection();
|
||||||
|
PreparedStatement ps = con.prepareStatement("INSERT INTO `alliance` (`name`) VALUES (?)", PreparedStatement.RETURN_GENERATED_KEYS);
|
||||||
|
|
||||||
|
ps.setString(1, name);
|
||||||
|
ps.executeUpdate();
|
||||||
|
try (ResultSet rs = ps.getGeneratedKeys()) {
|
||||||
|
rs.next();
|
||||||
|
id = rs.getInt(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
for(int i = 0; i < guilds.size(); i++) {
|
||||||
|
int guild = guilds.get(i);
|
||||||
|
|
||||||
|
ps = con.prepareStatement("INSERT INTO `allianceguilds` (`allianceid`, `guildid`) VALUES (?, ?)");
|
||||||
|
ps.setInt(1, id);
|
||||||
|
ps.setInt(2, guild);
|
||||||
|
ps.executeUpdate();
|
||||||
|
ps.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
ps.close();
|
||||||
|
con.close();
|
||||||
|
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (new MapleAlliance(name, id));
|
||||||
|
}
|
||||||
|
|
||||||
public static MapleAlliance loadAlliance(int id) {
|
public static MapleAlliance loadAlliance(int id) {
|
||||||
if (id <= 0) {
|
if (id <= 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
MapleAlliance alliance = new MapleAlliance(null, -1, -1, -1);
|
MapleAlliance alliance = new MapleAlliance(null, -1);
|
||||||
try {
|
try {
|
||||||
PreparedStatement ps = DatabaseConnection.getConnection().prepareStatement("SELECT * FROM alliance WHERE id = ?");
|
Connection con = DatabaseConnection.getConnection();
|
||||||
|
PreparedStatement ps = con.prepareStatement("SELECT * FROM alliance WHERE id = ?");
|
||||||
ps.setInt(1, id);
|
ps.setInt(1, id);
|
||||||
ResultSet rs = ps.executeQuery();
|
ResultSet rs = ps.executeQuery();
|
||||||
if (!rs.next()) {
|
if (!rs.next()) {
|
||||||
rs.close();
|
rs.close();
|
||||||
ps.close();
|
ps.close();
|
||||||
|
con.close();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
alliance.allianceId = id;
|
alliance.allianceId = id;
|
||||||
alliance.capacity = rs.getInt("capacity");
|
alliance.capacity = rs.getInt("capacity");
|
||||||
alliance.name = rs.getString("name");
|
alliance.name = rs.getString("name");
|
||||||
alliance.notice = rs.getString("notice");
|
alliance.notice = rs.getString("notice");
|
||||||
for (int i = 1; i <= 5; i++) {
|
|
||||||
alliance.rankTitles[i - 1] = rs.getString("rank_title" + i);
|
|
||||||
}
|
|
||||||
for (int i = 1; i <= 5; i++) {
|
|
||||||
alliance.guilds[i - 1] = rs.getInt("guild" + i);
|
|
||||||
}
|
|
||||||
ps.close();
|
ps.close();
|
||||||
rs.close();
|
rs.close();
|
||||||
|
|
||||||
|
ps = con.prepareStatement("SELECT * FROM allianceguilds WHERE allianceid = ?");
|
||||||
|
ps.setInt(1, id);
|
||||||
|
rs = ps.executeQuery();
|
||||||
|
|
||||||
|
while(rs.next()) {
|
||||||
|
alliance.addGuild(rs.getInt("guildid"));
|
||||||
|
}
|
||||||
|
|
||||||
|
ps.close();
|
||||||
|
rs.close();
|
||||||
|
|
||||||
|
con.close();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@@ -85,100 +216,57 @@ public class MapleAlliance {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void saveToDB() {
|
public void saveToDB() {
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
sb.append("capacity = ?, ");
|
|
||||||
sb.append("notice = ?, ");
|
|
||||||
for (int i = 1; i <= 5; i++) {
|
|
||||||
sb.append("rank_title").append(i).append(" = ?, ");
|
|
||||||
}
|
|
||||||
for (int i = 1; i <= 5; i++) {
|
|
||||||
sb.append("guild").append(i).append(" = ?, ");
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
PreparedStatement ps = DatabaseConnection.getConnection().prepareStatement("UPDATE `alliance` SET " + sb.toString() + " WHERE id = ?");
|
Connection con = DatabaseConnection.getConnection();
|
||||||
|
PreparedStatement ps = con.prepareStatement("UPDATE `alliance` SET capacity = ?, notice = ? WHERE id = ?");
|
||||||
ps.setInt(1, this.capacity);
|
ps.setInt(1, this.capacity);
|
||||||
ps.setString(2, this.notice);
|
ps.setString(2, this.notice);
|
||||||
for (int i = 0; i < rankTitles.length; i++) {
|
ps.setInt(3, this.allianceId);
|
||||||
ps.setString(i + 3, rankTitles[i]);
|
ps.executeUpdate();
|
||||||
}
|
ps.close();
|
||||||
for (int i = 0; i < guilds.length; i++) {
|
|
||||||
ps.setInt(i + 8, guilds[i]);
|
ps = con.prepareStatement("DELETE FROM `allianceguilds` WHERE allianceid = ?");
|
||||||
}
|
ps.setInt(1, this.allianceId);
|
||||||
ps.setInt(13, this.allianceId);
|
ps.executeUpdate();
|
||||||
ps.executeQuery();
|
ps.close();
|
||||||
|
|
||||||
|
for(int i = 0; i < guilds.size(); i++) {
|
||||||
|
int guild = guilds.get(i);
|
||||||
|
|
||||||
|
ps = con.prepareStatement("INSERT INTO `allianceguilds` (`allianceid`, `guildid`) VALUES (?, ?)");
|
||||||
|
ps.setInt(1, this.allianceId);
|
||||||
|
ps.setInt(2, guild);
|
||||||
|
ps.executeUpdate();
|
||||||
ps.close();
|
ps.close();
|
||||||
} catch (SQLException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean addRemGuildFromDB(int gid, boolean add) {
|
con.close();
|
||||||
Connection con = DatabaseConnection.getConnection();
|
|
||||||
boolean ret = false;
|
|
||||||
try {
|
|
||||||
PreparedStatement ps = con.prepareStatement("SELECT * FROM alliance WHERE id = ?");
|
|
||||||
ps.setInt(1, this.allianceId);
|
|
||||||
ResultSet rs = ps.executeQuery();
|
|
||||||
if (rs.next()) {
|
|
||||||
int avail = -1;
|
|
||||||
for (int i = 1; i <= 5; i++) {
|
|
||||||
int guildId = rs.getInt("guild" + i);
|
|
||||||
if (add) {
|
|
||||||
if (guildId == -1) {
|
|
||||||
avail = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else if (guildId == gid) {
|
|
||||||
avail = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
rs.close();
|
|
||||||
if (avail != -1) { // empty slot
|
|
||||||
ps = con.prepareStatement("UPDATE alliance SET guild" + avail + " = ? WHERE id = ?");
|
|
||||||
if (add) {
|
|
||||||
ps.setInt(1, gid);
|
|
||||||
} else {
|
|
||||||
ps.setInt(1, -1);
|
|
||||||
}
|
|
||||||
ps.setInt(2, this.allianceId);
|
|
||||||
ps.executeUpdate();
|
|
||||||
ret = true;
|
|
||||||
}
|
|
||||||
ps.close();
|
|
||||||
}
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean removeGuild(int gid) {
|
public boolean removeGuild(int gid) {
|
||||||
synchronized (guilds) {
|
synchronized (guilds) {
|
||||||
int gIndex = getGuildIndex(gid);
|
int index = getGuildIndex(gid);
|
||||||
if (gIndex != -1) {
|
if(index == -1) return false;
|
||||||
guilds[gIndex] = -1;
|
|
||||||
}
|
guilds.remove(index);
|
||||||
return addRemGuildFromDB(gid, false);
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean addGuild(int gid) {
|
public boolean addGuild(int gid) {
|
||||||
synchronized (guilds) {
|
synchronized (guilds) {
|
||||||
if (getGuildIndex(gid) == -1) {
|
if(guilds.size() == capacity || getGuildIndex(gid) > -1) return false;
|
||||||
int emptyIndex = getGuildIndex(-1);
|
guilds.add(gid);
|
||||||
if (emptyIndex != -1) {
|
|
||||||
guilds[emptyIndex] = gid;
|
|
||||||
return addRemGuildFromDB(gid, true);
|
|
||||||
}
|
}
|
||||||
}
|
return true;
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getGuildIndex(int gid) {
|
private int getGuildIndex(int gid) {
|
||||||
for (int i = 0; i < guilds.length; i++) {
|
for (int i = 0; i < guilds.size(); i++) {
|
||||||
if (guilds[i] == gid) {
|
if (guilds.get(i) == gid) {
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -189,10 +277,44 @@ public class MapleAlliance {
|
|||||||
rankTitles = ranks;
|
rankTitles = ranks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getRankTitle(int rank) {
|
||||||
|
return rankTitles[rank - 1];
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Integer> getGuilds() {
|
||||||
|
List<Integer> guilds_ = new LinkedList<>();
|
||||||
|
for (int guild : guilds) {
|
||||||
|
if (guild != -1) {
|
||||||
|
guilds_.add(guild);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return guilds_;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAllianceNotice() {
|
||||||
|
return notice;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNotice() {
|
||||||
|
return notice;
|
||||||
|
}
|
||||||
|
|
||||||
public void setNotice(String notice) {
|
public void setNotice(String notice) {
|
||||||
this.notice = notice;
|
this.notice = notice;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void increaseCapacity(int inc) {
|
||||||
|
this.capacity += inc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCapacity(int newCapacity) {
|
||||||
|
this.capacity = newCapacity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCapacity() {
|
||||||
|
return this.capacity;
|
||||||
|
}
|
||||||
|
|
||||||
public int getId() {
|
public int getId() {
|
||||||
return allianceId;
|
return allianceId;
|
||||||
}
|
}
|
||||||
@@ -201,33 +323,25 @@ public class MapleAlliance {
|
|||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getRankTitle(int rank) {
|
public MapleGuildCharacter getLeader() {
|
||||||
return rankTitles[rank - 1];
|
for(Integer gId: guilds) {
|
||||||
|
MapleGuild guild = Server.getInstance().getGuild(gId);
|
||||||
|
MapleGuildCharacter mgc = guild.getMGC(guild.getLeaderId());
|
||||||
|
|
||||||
|
if(mgc.getAllianceRank() == 1) return mgc;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getAllianceNotice() {
|
return null;
|
||||||
return notice;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Integer> getGuilds() {
|
public void dropAllianceMessage(String message) {
|
||||||
List<Integer> guilds_ = new LinkedList<Integer>();
|
dropAllianceMessage(5, message);
|
||||||
for (int guild : guilds) {
|
|
||||||
if (guild != -1) {
|
|
||||||
guilds_.add(guild);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return guilds_;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getNotice() {
|
public void dropAllianceMessage(int type, String message) {
|
||||||
return notice;
|
for(Integer gId: guilds) {
|
||||||
|
MapleGuild guild = Server.getInstance().getGuild(gId);
|
||||||
|
guild.dropGuildMessage(type, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void increaseCapacity(int inc) {
|
|
||||||
capacity += inc;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getCapacity() {
|
|
||||||
return capacity;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,6 @@ import java.util.Set;
|
|||||||
|
|
||||||
import net.server.Server;
|
import net.server.Server;
|
||||||
import net.server.channel.Channel;
|
import net.server.channel.Channel;
|
||||||
import tools.LogHelper;
|
|
||||||
import tools.DatabaseConnection;
|
import tools.DatabaseConnection;
|
||||||
import tools.MaplePacketCreator;
|
import tools.MaplePacketCreator;
|
||||||
|
|
||||||
@@ -46,7 +45,7 @@ public class MapleGuild {
|
|||||||
public final static int CHANGE_EMBLEM_COST = 5000000;
|
public final static int CHANGE_EMBLEM_COST = 5000000;
|
||||||
|
|
||||||
private enum BCOp {
|
private enum BCOp {
|
||||||
NONE, DISBAND, EMBELMCHANGE
|
NONE, DISBAND, EMBLEMCHANGE
|
||||||
}
|
}
|
||||||
private List<MapleGuildCharacter> members;
|
private List<MapleGuildCharacter> members;
|
||||||
private String rankTitles[] = new String[5]; // 1 = master, 2 = jr, 5 = lowest member
|
private String rankTitles[] = new String[5]; // 1 = master, 2 = jr, 5 = lowest member
|
||||||
@@ -56,8 +55,6 @@ public class MapleGuild {
|
|||||||
private Map<Integer, List<Integer>> notifications = new LinkedHashMap<>();
|
private Map<Integer, List<Integer>> notifications = new LinkedHashMap<>();
|
||||||
private boolean bDirty = true;
|
private boolean bDirty = true;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public MapleGuild(int guildid, int world) {
|
public MapleGuild(int guildid, int world) {
|
||||||
this.world = world;
|
this.world = world;
|
||||||
members = new ArrayList<>();
|
members = new ArrayList<>();
|
||||||
@@ -97,14 +94,14 @@ public class MapleGuild {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
do {
|
do {
|
||||||
members.add(new MapleGuildCharacter(rs.getInt("id"), rs.getInt("level"), rs.getString("name"), (byte) -1, world, rs.getInt("job"), rs.getInt("guildrank"), guildid, false, rs.getInt("allianceRank")));
|
members.add(new MapleGuildCharacter(null, rs.getInt("id"), rs.getInt("level"), rs.getString("name"), (byte) -1, world, rs.getInt("job"), rs.getInt("guildrank"), guildid, false, rs.getInt("allianceRank")));
|
||||||
} while (rs.next());
|
} while (rs.next());
|
||||||
|
|
||||||
ps.close();
|
ps.close();
|
||||||
rs.close();
|
rs.close();
|
||||||
} catch (SQLException se) {
|
} catch (SQLException se) {
|
||||||
se.printStackTrace();
|
se.printStackTrace();
|
||||||
System.out.println("unable to read guild information from sql" + se);
|
System.out.println("Unable to read guild information from sql" + se);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -261,7 +258,7 @@ public class MapleGuild {
|
|||||||
if (notifications.get(b).size() > 0) {
|
if (notifications.get(b).size() > 0) {
|
||||||
if (bcop == BCOp.DISBAND) {
|
if (bcop == BCOp.DISBAND) {
|
||||||
Server.getInstance().getWorld(world).setGuildAndRank(notifications.get(b), 0, 5, exceptionId);
|
Server.getInstance().getWorld(world).setGuildAndRank(notifications.get(b), 0, 5, exceptionId);
|
||||||
} else if (bcop == BCOp.EMBELMCHANGE) {
|
} else if (bcop == BCOp.EMBLEMCHANGE) {
|
||||||
Server.getInstance().getWorld(world).changeEmblem(this.id, notifications.get(b), new MapleGuildSummary(this));
|
Server.getInstance().getWorld(world).changeEmblem(this.id, notifications.get(b), new MapleGuildSummary(this));
|
||||||
} else {
|
} else {
|
||||||
Server.getInstance().getWorld(world).sendPacket(notifications.get(b), packet, exceptionId);
|
Server.getInstance().getWorld(world).sendPacket(notifications.get(b), packet, exceptionId);
|
||||||
@@ -286,6 +283,16 @@ public class MapleGuild {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void dropGuildMessage(String message) {
|
||||||
|
dropGuildMessage(5, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void dropGuildMessage(int type, String message) {
|
||||||
|
for (MapleGuildCharacter mgc : members) {
|
||||||
|
mgc.getCharacter().dropMessage(type, message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public final void setOnline(int cid, boolean online, int channel) {
|
public final void setOnline(int cid, boolean online, int channel) {
|
||||||
boolean bBroadcast = true;
|
boolean bBroadcast = true;
|
||||||
for (MapleGuildCharacter mgc : members) {
|
for (MapleGuildCharacter mgc : members) {
|
||||||
@@ -480,7 +487,7 @@ public class MapleGuild {
|
|||||||
this.logo = logo;
|
this.logo = logo;
|
||||||
this.logoColor = logocolor;
|
this.logoColor = logocolor;
|
||||||
this.writeToDB(false);
|
this.writeToDB(false);
|
||||||
this.broadcast(null, -1, BCOp.EMBELMCHANGE);
|
this.broadcast(null, -1, BCOp.EMBLEMCHANGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public MapleGuildCharacter getMGC(int cid) {
|
public MapleGuildCharacter getMGC(int cid) {
|
||||||
@@ -558,6 +565,20 @@ public class MapleGuild {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void resetAllianceGuildPlayersRank() {
|
||||||
|
try {
|
||||||
|
for(MapleGuildCharacter mgc: members) mgc.setAllianceRank(5);
|
||||||
|
|
||||||
|
try (PreparedStatement ps = DatabaseConnection.getConnection().prepareStatement("UPDATE characters SET allianceRank = ? WHERE guildid = ?")) {
|
||||||
|
ps.setInt(1, 5);
|
||||||
|
ps.setInt(2, id);
|
||||||
|
ps.executeUpdate();
|
||||||
|
}
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public int getIncreaseGuildCost(int size) {
|
public int getIncreaseGuildCost(int size) {
|
||||||
return 500000 * (size - 6) / 6;
|
return 500000 * (size - 6) / 6;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ package net.server.guild;
|
|||||||
import client.MapleCharacter;
|
import client.MapleCharacter;
|
||||||
|
|
||||||
public class MapleGuildCharacter {
|
public class MapleGuildCharacter {
|
||||||
|
private MapleCharacter character;
|
||||||
private int level;
|
private int level;
|
||||||
private int id;
|
private int id;
|
||||||
private int world, channel;
|
private int world, channel;
|
||||||
@@ -35,6 +36,7 @@ public class MapleGuildCharacter {
|
|||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
public MapleGuildCharacter(MapleCharacter c) {
|
public MapleGuildCharacter(MapleCharacter c) {
|
||||||
|
this.character = c;
|
||||||
this.name = c.getName();
|
this.name = c.getName();
|
||||||
this.level = c.getLevel();
|
this.level = c.getLevel();
|
||||||
this.id = c.getId();
|
this.id = c.getId();
|
||||||
@@ -47,7 +49,8 @@ public class MapleGuildCharacter {
|
|||||||
this.allianceRank = c.getAllianceRank();
|
this.allianceRank = c.getAllianceRank();
|
||||||
}
|
}
|
||||||
|
|
||||||
public MapleGuildCharacter(int _id, int _lv, String _name, int _channel, int _world, int _job, int _rank, int _gid, boolean _on, int _allianceRank) {
|
public MapleGuildCharacter(MapleCharacter c, int _id, int _lv, String _name, int _channel, int _world, int _job, int _rank, int _gid, boolean _on, int _allianceRank) {
|
||||||
|
this.character = c;
|
||||||
this.level = _lv;
|
this.level = _lv;
|
||||||
this.id = _id;
|
this.id = _id;
|
||||||
this.name = _name;
|
this.name = _name;
|
||||||
@@ -62,6 +65,14 @@ public class MapleGuildCharacter {
|
|||||||
this.allianceRank = _allianceRank;
|
this.allianceRank = _allianceRank;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setCharacter(MapleCharacter ch) {
|
||||||
|
this.character = ch;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MapleCharacter getCharacter() {
|
||||||
|
return character;
|
||||||
|
}
|
||||||
|
|
||||||
public int getLevel() {
|
public int getLevel() {
|
||||||
return level;
|
return level;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -153,6 +153,16 @@ public class World {
|
|||||||
return bossdroprate;
|
return bossdroprate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setBossDropRate(int bossdrop) {
|
||||||
|
for(MapleCharacter chr : getPlayerStorage().getAllCharacters()) {
|
||||||
|
chr.revertRates(false);
|
||||||
|
}
|
||||||
|
this.bossdroprate = bossdrop;
|
||||||
|
for(MapleCharacter chr : getPlayerStorage().getAllCharacters()) {
|
||||||
|
chr.setRates();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public PlayerStorage getPlayerStorage() {
|
public PlayerStorage getPlayerStorage() {
|
||||||
return players;
|
return players;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ import java.io.File;
|
|||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
|
||||||
import net.server.Server;
|
import net.server.Server;
|
||||||
import net.server.guild.MapleAlliance;
|
import net.server.guild.MapleAlliance;
|
||||||
@@ -345,6 +347,11 @@ public class NPCConversationManager extends AbstractPlayerInteraction {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void upgradeAlliance() {
|
||||||
|
MapleAlliance alliance = Server.getInstance().getAlliance(c.getPlayer().getGuild().getAllianceId());
|
||||||
|
alliance.increaseCapacity(1);
|
||||||
|
}
|
||||||
|
|
||||||
public void disbandAlliance(MapleClient c, int allianceId) {
|
public void disbandAlliance(MapleClient c, int allianceId) {
|
||||||
PreparedStatement ps = null;
|
PreparedStatement ps = null;
|
||||||
try {
|
try {
|
||||||
@@ -368,62 +375,15 @@ public class NPCConversationManager extends AbstractPlayerInteraction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean canBeUsedAllianceName(String name) {
|
public boolean canBeUsedAllianceName(String name) {
|
||||||
if (name.contains(" ") || name.length() > 12) {
|
return MapleAlliance.canBeUsedAllianceName(name);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
ResultSet rs;
|
|
||||||
try (PreparedStatement ps = DatabaseConnection.getConnection().prepareStatement("SELECT name FROM alliance WHERE name = ?")) {
|
|
||||||
ps.setString(1, name);
|
|
||||||
rs = ps.executeQuery();
|
|
||||||
if (rs.next()) {
|
|
||||||
ps.close();
|
|
||||||
rs.close();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
rs.close();
|
|
||||||
return true;
|
|
||||||
} catch (SQLException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MapleAlliance createAlliance(MapleCharacter chr1, MapleCharacter chr2, String name) {
|
public MapleAlliance createAlliance(String name) {
|
||||||
int id;
|
return MapleAlliance.createAlliance(getParty(), name);
|
||||||
int guild1 = chr1.getGuildId();
|
|
||||||
int guild2 = chr2.getGuildId();
|
|
||||||
try {
|
|
||||||
try (PreparedStatement ps = DatabaseConnection.getConnection().prepareStatement("INSERT INTO `alliance` (`name`, `guild1`, `guild2`) VALUES (?, ?, ?)", PreparedStatement.RETURN_GENERATED_KEYS)) {
|
|
||||||
ps.setString(1, name);
|
|
||||||
ps.setInt(2, guild1);
|
|
||||||
ps.setInt(3, guild2);
|
|
||||||
ps.executeUpdate();
|
|
||||||
try (ResultSet rs = ps.getGeneratedKeys()) {
|
|
||||||
rs.next();
|
|
||||||
id = rs.getInt(1);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} catch (SQLException e) {
|
public int getAllianceCapacity() {
|
||||||
e.printStackTrace();
|
return Server.getInstance().getAlliance(getPlayer().getGuild().getAllianceId()).getCapacity();
|
||||||
return null;
|
|
||||||
}
|
|
||||||
MapleAlliance alliance = new MapleAlliance(name, id, guild1, guild2);
|
|
||||||
try {
|
|
||||||
Server.getInstance().setGuildAllianceId(guild1, id);
|
|
||||||
Server.getInstance().setGuildAllianceId(guild2, id);
|
|
||||||
chr1.setAllianceRank(1);
|
|
||||||
chr1.saveGuildStatus();
|
|
||||||
chr2.setAllianceRank(2);
|
|
||||||
chr2.saveGuildStatus();
|
|
||||||
Server.getInstance().addAlliance(id, alliance);
|
|
||||||
Server.getInstance().allianceMessage(id, MaplePacketCreator.makeNewAlliance(alliance, chr1.getClient()), -1, -1);
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return alliance;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasMerchant() {
|
public boolean hasMerchant() {
|
||||||
|
|||||||
@@ -5891,6 +5891,7 @@ public class MaplePacketCreator {
|
|||||||
mplew.writeInt(mgc.isOnline() ? 1 : 0);
|
mplew.writeInt(mgc.isOnline() ? 1 : 0);
|
||||||
mplew.writeInt(guild.getSignature());
|
mplew.writeInt(guild.getSignature());
|
||||||
mplew.writeInt(mgc.getAllianceRank());
|
mplew.writeInt(mgc.getAllianceRank());
|
||||||
|
System.out.println("alliance rank found " + mgc.getAllianceRank());
|
||||||
}
|
}
|
||||||
mplew.writeInt(guild.getCapacity());
|
mplew.writeInt(guild.getCapacity());
|
||||||
mplew.writeShort(guild.getLogoBG());
|
mplew.writeShort(guild.getLogoBG());
|
||||||
|
|||||||
Reference in New Issue
Block a user