diff --git a/src/main/java/client/command/CommandsExecutor.java b/src/main/java/client/command/CommandsExecutor.java index 5ce0afcc98..9109c6c410 100644 --- a/src/main/java/client/command/CommandsExecutor.java +++ b/src/main/java/client/command/CommandsExecutor.java @@ -185,15 +185,10 @@ import client.command.commands.gm6.EraseAllPNpcsCommand; import client.command.commands.gm6.GetAccCommand; import client.command.commands.gm6.MapPlayersCommand; import client.command.commands.gm6.SaveAllCommand; -import client.command.commands.gm6.ServerAddChannelCommand; -import client.command.commands.gm6.ServerAddWorldCommand; -import client.command.commands.gm6.ServerRemoveChannelCommand; -import client.command.commands.gm6.ServerRemoveWorldCommand; import client.command.commands.gm6.SetGmLevelCommand; import client.command.commands.gm6.ShutdownCommand; import client.command.commands.gm6.SpawnAllPNpcsCommand; import client.command.commands.gm6.SupplyRateCouponCommand; -import client.command.commands.gm6.WarpWorldCommand; import constants.id.MapId; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -535,7 +530,6 @@ public class CommandsExecutor { levelCommandsCursor = new Pair<>(new ArrayList(), new ArrayList()); addCommand("setgmlevel", 6, SetGmLevelCommand.class); - addCommand("warpworld", 6, WarpWorldCommand.class); addCommand("saveall", 6, SaveAllCommand.class); addCommand("dcall", 6, DCAllCommand.class); addCommand("mapplayers", 6, MapPlayersCommand.class); @@ -546,10 +540,6 @@ public class CommandsExecutor { addCommand("supplyratecoupon", 6, SupplyRateCouponCommand.class); addCommand("spawnallpnpcs", 6, SpawnAllPNpcsCommand.class); addCommand("eraseallpnpcs", 6, EraseAllPNpcsCommand.class); - addCommand("addchannel", 6, ServerAddChannelCommand.class); - addCommand("addworld", 6, ServerAddWorldCommand.class); - addCommand("removechannel", 6, ServerRemoveChannelCommand.class); - addCommand("removeworld", 6, ServerRemoveWorldCommand.class); addCommand("devtest", 6, DevtestCommand.class); commandsNameDesc.add(levelCommandsCursor); diff --git a/src/main/java/client/command/commands/gm6/ServerAddChannelCommand.java b/src/main/java/client/command/commands/gm6/ServerAddChannelCommand.java deleted file mode 100644 index 1565f442b6..0000000000 --- a/src/main/java/client/command/commands/gm6/ServerAddChannelCommand.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - This file is part of the HeavenMS MapleStory Server, commands OdinMS-based - Copyleft (L) 2016 - 2019 RonanLana - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as - published by the Free Software Foundation version 3 as published by - the Free Software Foundation. You may not use, modify or distribute - this program under any other version of the GNU Affero General Public - License. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . -*/ - -/* - @Author: Arthur L - Refactored command content into modules -*/ -package client.command.commands.gm6; - -import client.Character; -import client.Client; -import client.command.Command; -import client.command.CommandContext; -import net.server.Server; -import server.ThreadManager; - -public class ServerAddChannelCommand extends Command { - { - setDescription("Add a new channel to a world."); - } - - @Override - public void execute(Client c, String[] params, CommandContext ctx) { - final Character player = c.getPlayer(); - - if (params.length < 1) { - player.dropMessage(5, "Syntax: @addchannel "); - return; - } - - final int worldid = Integer.parseInt(params[0]); - - ThreadManager.getInstance().newTask(() -> { - int chid = Server.getInstance().addChannel(worldid); - if (player.isLoggedinWorld()) { - if (chid >= 0) { - player.dropMessage(5, "NEW Channel " + chid + " successfully deployed on world " + worldid + "."); - } else { - if (chid == -3) { - player.dropMessage(5, "Invalid worldid detected. Channel creation aborted."); - } else if (chid == -2) { - player.dropMessage(5, "Reached channel limit on worldid " + worldid + ". Channel creation aborted."); - } else if (chid == -1) { - player.dropMessage(5, "Error detected when loading the 'world.ini' file. Channel creation aborted."); - } else { - player.dropMessage(5, "NEW Channel failed to be deployed. Check if the needed port is already in use or other limitations are taking place."); - } - } - } - }); - } -} diff --git a/src/main/java/client/command/commands/gm6/ServerAddWorldCommand.java b/src/main/java/client/command/commands/gm6/ServerAddWorldCommand.java deleted file mode 100644 index 9036888cf3..0000000000 --- a/src/main/java/client/command/commands/gm6/ServerAddWorldCommand.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - This file is part of the HeavenMS MapleStory Server, commands OdinMS-based - Copyleft (L) 2016 - 2019 RonanLana - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as - published by the Free Software Foundation version 3 as published by - the Free Software Foundation. You may not use, modify or distribute - this program under any other version of the GNU Affero General Public - License. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . -*/ - -/* - @Author: Arthur L - Refactored command content into modules -*/ -package client.command.commands.gm6; - -import client.Character; -import client.Client; -import client.command.Command; -import client.command.CommandContext; -import net.server.Server; -import server.ThreadManager; - -public class ServerAddWorldCommand extends Command { - { - setDescription("Add a new world."); - } - - @Override - public void execute(Client c, String[] params, CommandContext ctx) { - final Character player = c.getPlayer(); - - ThreadManager.getInstance().newTask(() -> { - int wid = Server.getInstance().addWorld(); - - if (player.isLoggedinWorld()) { - if (wid >= 0) { - player.dropMessage(5, "NEW World " + wid + " successfully deployed."); - } else { - if (wid == -2) { - player.dropMessage(5, "Error detected when loading the 'world.ini' file. World creation aborted."); - } else { - player.dropMessage(5, "NEW World failed to be deployed. Check if needed ports are already in use or maximum world count has been reached."); - } - } - } - }); - } -} diff --git a/src/main/java/client/command/commands/gm6/ServerRemoveChannelCommand.java b/src/main/java/client/command/commands/gm6/ServerRemoveChannelCommand.java deleted file mode 100644 index e2f5b5949a..0000000000 --- a/src/main/java/client/command/commands/gm6/ServerRemoveChannelCommand.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - This file is part of the HeavenMS MapleStory Server, commands OdinMS-based - Copyleft (L) 2016 - 2019 RonanLana - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as - published by the Free Software Foundation version 3 as published by - the Free Software Foundation. You may not use, modify or distribute - this program under any other version of the GNU Affero General Public - License. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . -*/ - -/* - @Author: Arthur L - Refactored command content into modules -*/ -package client.command.commands.gm6; - -import client.Character; -import client.Client; -import client.command.Command; -import client.command.CommandContext; -import net.server.Server; -import server.ThreadManager; - -public class ServerRemoveChannelCommand extends Command { - { - setDescription("Remove channel from a world."); - } - - @Override - public void execute(Client c, String[] params, CommandContext ctx) { - final Character player = c.getPlayer(); - - if (params.length < 1) { - player.dropMessage(5, "Syntax: @removechannel "); - return; - } - - final int worldId = Integer.parseInt(params[0]); - ThreadManager.getInstance().newTask(() -> { - if (Server.getInstance().removeChannel(worldId)) { - if (player.isLoggedinWorld()) { - player.dropMessage(5, "Successfully removed a channel on World " + worldId + ". Current channel count: " + Server.getInstance().getWorld(worldId).getChannelsSize() + "."); - } - } else { - if (player.isLoggedinWorld()) { - player.dropMessage(5, "Failed to remove last Channel on world " + worldId + ". Check if either that world exists or there are people currently playing there."); - } - } - }); - } -} diff --git a/src/main/java/client/command/commands/gm6/ServerRemoveWorldCommand.java b/src/main/java/client/command/commands/gm6/ServerRemoveWorldCommand.java deleted file mode 100644 index 155de40be6..0000000000 --- a/src/main/java/client/command/commands/gm6/ServerRemoveWorldCommand.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - This file is part of the HeavenMS MapleStory Server, commands OdinMS-based - Copyleft (L) 2016 - 2019 RonanLana - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as - published by the Free Software Foundation version 3 as published by - the Free Software Foundation. You may not use, modify or distribute - this program under any other version of the GNU Affero General Public - License. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . -*/ - -/* - @Author: Arthur L - Refactored command content into modules -*/ -package client.command.commands.gm6; - -import client.Character; -import client.Client; -import client.command.Command; -import client.command.CommandContext; -import net.server.Server; -import server.ThreadManager; - -public class ServerRemoveWorldCommand extends Command { - { - setDescription("Remove a world."); - } - - @Override - public void execute(Client c, String[] params, CommandContext ctx) { - final Character player = c.getPlayer(); - - final int rwid = Server.getInstance().getWorldsSize() - 1; - if (rwid <= 0) { - player.dropMessage(5, "Unable to remove world 0."); - return; - } - - ThreadManager.getInstance().newTask(() -> { - if (Server.getInstance().removeWorld()) { - if (player.isLoggedinWorld()) { - player.dropMessage(5, "Successfully removed a world. Current world count: " + Server.getInstance().getWorldsSize() + "."); - } - } else { - if (player.isLoggedinWorld()) { - if (rwid < 0) { - player.dropMessage(5, "No registered worlds to remove."); - } else { - player.dropMessage(5, "Failed to remove world " + rwid + ". Check if there are people currently playing there."); - } - } - } - }); - } -} diff --git a/src/main/java/client/command/commands/gm6/WarpWorldCommand.java b/src/main/java/client/command/commands/gm6/WarpWorldCommand.java deleted file mode 100644 index 51ce2d0ba0..0000000000 --- a/src/main/java/client/command/commands/gm6/WarpWorldCommand.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - This file is part of the HeavenMS MapleStory Server, commands OdinMS-based - Copyleft (L) 2016 - 2019 RonanLana - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as - published by the Free Software Foundation version 3 as published by - the Free Software Foundation. You may not use, modify or distribute - this program under any other version of the GNU Affero General Public - License. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . -*/ - -/* - @Author: Arthur L - Refactored command content into modules -*/ -package client.command.commands.gm6; - -import client.Character; -import client.Client; -import client.command.Command; -import client.command.CommandContext; -import net.server.Server; -import tools.PacketCreator; - -import java.net.InetAddress; -import java.net.UnknownHostException; - -public class WarpWorldCommand extends Command { - { - setDescription("Warp to a different world."); - } - - @Override - public void execute(Client c, String[] params, CommandContext ctx) { - Character player = c.getPlayer(); - if (params.length < 1) { - player.yellowMessage("Syntax: !warpworld "); - return; - } - - Server server = Server.getInstance(); - byte worldb = Byte.parseByte(params[0]); - if (worldb <= (server.getWorldsSize() - 1)) { - try { - String[] socket = server.getInetSocket(c, worldb, c.getChannel()); - c.getWorldServer().removePlayer(player); - player.getMap().removePlayer(player);//LOL FORGOT THIS >< - player.setSessionTransitionState(); - player.setWorld(worldb); - ctx.characterSaver().save(player);//To set the new world :O (true because else 2 player instances are created, one in both worlds) - c.sendPacket(PacketCreator.getChannelChange(InetAddress.getByName(socket[0]), Integer.parseInt(socket[1]))); - } catch (UnknownHostException | NumberFormatException ex) { - ex.printStackTrace(); - player.message("Unexpected error when changing worlds, are you sure the world you are trying to warp to has the same amount of channels?"); - } - - } else { - player.message("Invalid world; highest number available: " + (server.getWorldsSize() - 1)); - } - } -} diff --git a/src/main/java/net/server/Server.java b/src/main/java/net/server/Server.java index 89e6556aa8..d84f5f73df 100644 --- a/src/main/java/net/server/Server.java +++ b/src/main/java/net/server/Server.java @@ -358,82 +358,6 @@ public class Server { } } - - private void dumpData() { - wldRLock.lock(); - try { - log.debug("Worlds: {}", worlds); - log.debug("Channels: {}", channels); - log.debug("World recommended list: {}", worldRecommendedList); - log.debug("---------------------"); - } finally { - wldRLock.unlock(); - } - } - - public int addChannel(int worldid) { - World world; - Map channelInfo; - int channelid; - - wldRLock.lock(); - try { - if (worldid >= worlds.size()) { - return -3; - } - - channelInfo = channels.get(worldid); - if (channelInfo == null) { - return -3; - } - - channelid = channelInfo.size(); - if (channelid >= YamlConfig.config.server.CHANNEL_SIZE) { - return -2; - } - - channelid++; - world = this.getWorld(worldid); - } finally { - wldRLock.unlock(); - } - - Channel channel = new Channel(worldid, channelid, getCurrentTime(), channelDependencies); - channel.setServerMessage(YamlConfig.config.worlds.get(worldid).why_am_i_recommended); - - if (world.addChannel(channel)) { - wldWLock.lock(); - try { - channelInfo.put(channelid, channel.getIP()); - } finally { - wldWLock.unlock(); - } - } - - return channelid; - } - - public int addWorld() { - int newWorld = initWorld(); - if (newWorld > -1) { - installWorldPlayerRanking(newWorld); - - Set accounts; - lgnRLock.lock(); - try { - accounts = new HashSet<>(accountChars.keySet()); - } finally { - lgnRLock.unlock(); - } - - for (Integer accId : accounts) { - loadAccountCharactersView(accId, 0, newWorld); - } - } - - return newWorld; - } - private int initWorld() { int i; @@ -501,74 +425,6 @@ public class Server { } } - public boolean removeChannel(int worldid) { //lol don't! - World world; - - wldRLock.lock(); - try { - if (worldid >= worlds.size()) { - return false; - } - world = worlds.get(worldid); - } finally { - wldRLock.unlock(); - } - - if (world != null) { - int channel = world.removeChannel(); - wldWLock.lock(); - try { - Map m = channels.get(worldid); - if (m != null) { - m.remove(channel); - } - } finally { - wldWLock.unlock(); - } - - return channel > -1; - } - - return false; - } - - public boolean removeWorld() { //lol don't! - World w; - int worldid; - - wldRLock.lock(); - try { - worldid = worlds.size() - 1; - if (worldid < 0) { - return false; - } - - w = worlds.get(worldid); - } finally { - wldRLock.unlock(); - } - - if (w == null || !w.canUninstall()) { - return false; - } - - removeWorldPlayerRanking(); - w.shutdown(); - - wldWLock.lock(); - try { - if (worldid == worlds.size() - 1) { - worlds.remove(worldid); - channels.remove(worldid); - worldRecommendedList.remove(worldid); - } - } finally { - wldWLock.unlock(); - } - - return true; - } - private void resetServerWorlds() { // thanks maple006 for noticing proprietary lists assigned to null wldWLock.lock(); try { @@ -750,50 +606,6 @@ public class Server { } } - private void installWorldPlayerRanking(int worldid) { - List>>> ranking = loadPlayerRankingFromDB(worldid); - if (!ranking.isEmpty()) { - wldWLock.lock(); - try { - if (!YamlConfig.config.server.USE_WHOLE_SERVER_RANKING) { - for (int i = playerRanking.size(); i <= worldid; i++) { - playerRanking.add(new ArrayList<>(0)); - } - - playerRanking.add(worldid, ranking.get(0).getRight()); - } else { - playerRanking.add(0, ranking.get(0).getRight()); - } - } finally { - wldWLock.unlock(); - } - } - } - - private void removeWorldPlayerRanking() { - if (!YamlConfig.config.server.USE_WHOLE_SERVER_RANKING) { - wldWLock.lock(); - try { - if (playerRanking.size() < worlds.size()) { - return; - } - - playerRanking.remove(playerRanking.size() - 1); - } finally { - wldWLock.unlock(); - } - } else { - List>>> ranking = loadPlayerRankingFromDB(-1 * (this.getWorldsSize() - 2)); // update ranking list - - wldWLock.lock(); - try { - playerRanking.add(0, ranking.get(0).getRight()); - } finally { - wldWLock.unlock(); - } - } - } - public void updateWorldPlayerRanking() { List>>> rankUpdates = loadPlayerRankingFromDB(-1 * (this.getWorldsSize() - 1)); if (rankUpdates.isEmpty()) { @@ -1357,15 +1169,6 @@ public class Server { return buffStorage; } - public void deleteGuildCharacter(Character mc) { - setGuildMemberOnline(mc, false, (byte) -1); - if (mc.getMGC().getGuildRank() > 1) { - leaveGuild(mc.getMGC()); - } else { - disbandGuild(mc.getMGC().getGuildId()); - } - } - public void deleteGuildCharacter(GuildCharacter mgc) { if (mgc.getCharacter() != null) { setGuildMemberOnline(mgc.getCharacter(), false, (byte) -1); @@ -1377,17 +1180,6 @@ public class Server { } } - public void reloadGuildCharacters(int world) { - World worlda = getWorld(world); - for (Character mc : worlda.getPlayerStorage().getAllCharacters()) { - if (mc.getGuildId() > 0) { - setGuildMemberOnline(mc, true, worlda.getId()); - memberLevelJobUpdate(mc.getMGC()); - } - } - worlda.reloadGuildSummary(); - } - public void broadcastMessage(int world, Packet packet) { for (Channel ch : getChannelsFromWorld(world)) { ch.broadcastPacket(packet); diff --git a/src/main/java/net/server/channel/Channel.java b/src/main/java/net/server/channel/Channel.java index 58b2ac4d06..420b71f386 100644 --- a/src/main/java/net/server/channel/Channel.java +++ b/src/main/java/net/server/channel/Channel.java @@ -350,10 +350,6 @@ public final class Channel { playersAway.remove(chrId); } - public boolean canUninstall() { - return players.getSize() == 0 && playersAway.isEmpty(); - } - private void disconnectAwayPlayers() { World wserv = getWorldServer(); for (Integer cid : playersAway) { diff --git a/src/main/java/net/server/world/World.java b/src/main/java/net/server/world/World.java index bfdc959f8c..e72270a4fb 100644 --- a/src/main/java/net/server/world/World.java +++ b/src/main/java/net/server/world/World.java @@ -296,55 +296,6 @@ public class World { } } - public int removeChannel() { - Channel ch; - int chIdx; - - chnRLock.lock(); - try { - chIdx = channels.size() - 1; - if (chIdx < 0) { - return -1; - } - - ch = channels.get(chIdx); - } finally { - chnRLock.unlock(); - } - - if (ch == null || !ch.canUninstall()) { - return -1; - } - - chnWLock.lock(); - try { - if (chIdx == channels.size() - 1) { - channels.remove(chIdx); - } else { - return -1; - } - } finally { - chnWLock.unlock(); - } - - ch.shutdown(); - return ch.getId(); - } - - public boolean canUninstall() { - if (players.getSize() > 0) { - return false; - } - - for (Channel ch : this.getChannels()) { - if (!ch.canUninstall()) { - return false; - } - } - - return true; - } - public void setFlag(byte b) { this.flag = b; }