Remove AddWorld,AddChannel,RemoveWorld,RemoveChannel cmds

These are incredibly error prone and hinder the database migration work.
This commit is contained in:
P0nk
2024-09-29 07:08:45 +02:00
parent 5595f5763b
commit 813768ec47
9 changed files with 0 additions and 590 deletions

View File

@@ -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<String>(), new ArrayList<String>());
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);

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
/*
@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 <worldid>");
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.");
}
}
}
});
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
/*
@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.");
}
}
}
});
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
/*
@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 <worldid>");
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.");
}
}
});
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
/*
@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.");
}
}
}
});
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
/*
@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 <worldid>");
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));
}
}
}