Switch to Maven file structure

This commit is contained in:
P0nk
2021-03-30 21:07:35 +02:00
parent 4acc5675d6
commit 813643036b
817 changed files with 16 additions and 0 deletions

View File

@@ -0,0 +1,42 @@
/*
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.command.Command;
import client.MapleClient;
import client.MapleCharacter;
import server.quest.MapleQuest;
public class ClearQuestCacheCommand extends Command {
{
setDescription("");
}
@Override
public void execute(MapleClient c, String[] params) {
MapleCharacter player = c.getPlayer();
MapleQuest.clearCache();
player.dropMessage(5, "Quest Cache Cleared.");
}
}

View File

@@ -0,0 +1,47 @@
/*
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.command.Command;
import client.MapleClient;
import client.MapleCharacter;
import server.quest.MapleQuest;
public class ClearQuestCommand extends Command {
{
setDescription("");
}
@Override
public void execute(MapleClient c, String[] params) {
MapleCharacter player = c.getPlayer();
if (params.length < 1) {
player.dropMessage(5, "Please include a quest ID.");
return;
}
MapleQuest.clearCache(Integer.parseInt(params[0]));
player.dropMessage(5, "Quest Cache for quest " + params[0] + " cleared.");
}
}

View File

@@ -0,0 +1,49 @@
/*
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.command.Command;
import client.MapleClient;
import client.MapleCharacter;
import net.server.Server;
import net.server.world.World;
public class DCAllCommand extends Command {
{
setDescription("");
}
@Override
public void execute(MapleClient c, String[] params) {
MapleCharacter player = c.getPlayer();
for (World world : Server.getInstance().getWorlds()) {
for (MapleCharacter chr : world.getPlayerStorage().getAllCharacters()) {
if (!chr.isGM()) {
chr.getClient().disconnect(false, false);
}
}
}
player.message("All players successfully disconnected.");
}
}

View File

@@ -0,0 +1,39 @@
/*
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.command.Command;
import client.MapleClient;
import server.life.MaplePlayerNPC;
public class EraseAllPNpcsCommand extends Command {
{
setDescription("");
}
@Override
public void execute(MapleClient c, String[] params) {
MaplePlayerNPC.removeAllPlayerNPC();
}
}

View File

@@ -0,0 +1,49 @@
/*
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.command.Command;
import client.MapleClient;
import client.MapleCharacter;
public class GetAccCommand extends Command {
{
setDescription("");
}
@Override
public void execute(MapleClient c, String[] params) {
MapleCharacter player = c.getPlayer();
if (params.length < 1) {
player.yellowMessage("Syntax: !getacc <playername>");
return;
}
MapleCharacter victim = c.getWorldServer().getPlayerStorage().getCharacterByName(params[0]);
if (victim != null) {
player.message(victim.getName() + "'s account name is " + victim.getClient().getAccountName() + ".");
} else {
player.message("Player '" + params[0] + "' could not be found on this world.");
}
}
}

View File

@@ -0,0 +1,55 @@
/*
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.command.Command;
import client.MapleClient;
import client.MapleCharacter;
import net.server.Server;
import net.server.world.World;
public class MapPlayersCommand extends Command {
{
setDescription("");
}
@Override
public void execute(MapleClient c, String[] params) {
MapleCharacter player = c.getPlayer();
String names = "";
int map = player.getMapId();
for (World world : Server.getInstance().getWorlds()) {
for (MapleCharacter chr : world.getPlayerStorage().getAllCharacters()) {
int curMap = chr.getMapId();
String hp = Integer.toString(chr.getHp());
String maxhp = Integer.toString(chr.getCurrentMaxHp());
String name = chr.getName() + ": " + hp + "/" + maxhp;
if (map == curMap) {
names = names.equals("") ? name : (names + ", " + name);
}
}
}
player.message("Players on mapid " + map + ": " + names);
}
}

View File

@@ -0,0 +1,50 @@
/*
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.command.Command;
import client.MapleClient;
import client.MapleCharacter;
import net.server.Server;
import net.server.world.World;
import tools.MaplePacketCreator;
public class SaveAllCommand extends Command {
{
setDescription("");
}
@Override
public void execute(MapleClient c, String[] params) {
MapleCharacter player = c.getPlayer();
for (World world : Server.getInstance().getWorlds()) {
for (MapleCharacter chr : world.getPlayerStorage().getAllCharacters()) {
chr.saveCharToDB();
}
}
String message = player.getName() + " used !saveall.";
Server.getInstance().broadcastGMMessage(c.getWorld(), MaplePacketCreator.serverNotice(5, message));
player.message("All players saved successfully.");
}
}

View File

@@ -0,0 +1,70 @@
/*
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.MapleCharacter;
import client.command.Command;
import client.MapleClient;
import net.server.Server;
import server.ThreadManager;
public class ServerAddChannelCommand extends Command {
{
setDescription("");
}
@Override
public void execute(MapleClient c, String[] params) {
final MapleCharacter player = c.getPlayer();
if (params.length < 1) {
player.dropMessage(5, "Syntax: @addchannel <worldid>");
return;
}
final int worldid = Integer.parseInt(params[0]);
ThreadManager.getInstance().newTask(new Runnable() {
@Override
public void run() {
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

@@ -0,0 +1,60 @@
/*
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.MapleCharacter;
import client.command.Command;
import client.MapleClient;
import net.server.Server;
import server.ThreadManager;
public class ServerAddWorldCommand extends Command {
{
setDescription("");
}
@Override
public void execute(MapleClient c, String[] params) {
final MapleCharacter player = c.getPlayer();
ThreadManager.getInstance().newTask(new Runnable() {
@Override
public void run() {
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

@@ -0,0 +1,62 @@
/*
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.MapleCharacter;
import client.command.Command;
import client.MapleClient;
import net.server.Server;
import server.ThreadManager;
public class ServerRemoveChannelCommand extends Command {
{
setDescription("");
}
@Override
public void execute(MapleClient c, String[] params) {
final MapleCharacter player = c.getPlayer();
if (params.length < 1) {
player.dropMessage(5, "Syntax: @removechannel <worldid>");
return;
}
final int worldId = Integer.parseInt(params[0]);
ThreadManager.getInstance().newTask(new Runnable() {
@Override
public void run() {
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

@@ -0,0 +1,66 @@
/*
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.MapleCharacter;
import client.command.Command;
import client.MapleClient;
import net.server.Server;
import server.ThreadManager;
public class ServerRemoveWorldCommand extends Command {
{
setDescription("");
}
@Override
public void execute(MapleClient c, String[] params) {
final MapleCharacter 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(new Runnable() {
@Override
public void run() {
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

@@ -0,0 +1,55 @@
/*
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.command.Command;
import client.MapleClient;
import client.MapleCharacter;
public class SetGmLevelCommand extends Command {
{
setDescription("");
}
@Override
public void execute(MapleClient c, String[] params) {
MapleCharacter player = c.getPlayer();
if (params.length < 2) {
player.yellowMessage("Syntax: !setgmlevel <playername> <newlevel>");
return;
}
int newLevel = Integer.parseInt(params[1]);
MapleCharacter target = c.getChannelServer().getPlayerStorage().getCharacterByName(params[0]);
if (target != null) {
target.setGMLevel(newLevel);
target.getClient().setGMLevel(newLevel);
target.dropMessage("You are now a level " + newLevel + " GM. See @commands for a list of available commands.");
player.dropMessage(target + " is now a level " + newLevel + " GM.");
} else {
player.dropMessage("Player '" + params[0] + "' was not found on this channel.");
}
}
}

View File

@@ -0,0 +1,74 @@
/*
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.command.Command;
import client.MapleClient;
import client.MapleCharacter;
import net.server.Server;
import net.server.world.World;
import server.TimerManager;
public class ShutdownCommand extends Command {
{
setDescription("");
}
@Override
public void execute(MapleClient c, String[] params) {
MapleCharacter player = c.getPlayer();
if (params.length < 1){
player.yellowMessage("Syntax: !shutdown [<time>|NOW]");
return;
}
int time = 60000;
if (params[0].equalsIgnoreCase("now")){
time = 1;
} else {
time *= Integer.parseInt(params[0]);
}
if (time > 1) {
int seconds = (int) (time / 1000) % 60;
int minutes = (int) ((time / (1000 * 60)) % 60);
int hours = (int) ((time / (1000 * 60 * 60)) % 24);
int days = (int) ((time / (1000 * 60 * 60 * 24)));
String strTime = "";
if (days > 0) strTime += days + " days, ";
if (hours > 0) strTime += hours + " hours, ";
strTime += minutes + " minutes, ";
strTime += seconds + " seconds";
for (World w : Server.getInstance().getWorlds()) {
for (MapleCharacter chr : w.getPlayerStorage().getAllCharacters()) {
chr.dropMessage("Server is undergoing maintenance process, and will be shutdown in " + strTime + ". Prepare yourself to quit safely in the mean time.");
}
}
}
TimerManager.getInstance().schedule(Server.getInstance().shutdown(false), time);
}
}

View File

@@ -0,0 +1,41 @@
/*
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.command.Command;
import client.MapleClient;
import client.MapleCharacter;
import server.life.MaplePlayerNPC;
public class SpawnAllPNpcsCommand extends Command {
{
setDescription("");
}
@Override
public void execute(MapleClient c, String[] params) {
MapleCharacter player = c.getPlayer();
MaplePlayerNPC.multicastSpawnPlayerNPC(player.getMapId(), player.getWorld());
}
}

View File

@@ -0,0 +1,43 @@
/*
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/>.
*/
package client.command.commands.gm6;
import client.MapleCharacter;
import client.MapleClient;
import client.command.Command;
import config.YamlConfig;
public class SupplyRateCouponCommand extends Command {
{
setDescription("");
}
@Override
public void execute(MapleClient c, String[] params) {
MapleCharacter player = c.getPlayer();
if (params.length < 1) {
player.dropMessage(5, "Syntax: !supplyratecoupon <yes|no>");
return;
}
YamlConfig.config.server.USE_SUPPLY_RATE_COUPONS = params[0].compareToIgnoreCase("no") != 0;
player.dropMessage(5, "Rate coupons are now " + (YamlConfig.config.server.USE_SUPPLY_RATE_COUPONS ? "enabled" : "disabled") + " for purchase at the Cash Shop.");
}
}

View File

@@ -0,0 +1,68 @@
/*
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.command.Command;
import client.MapleClient;
import client.MapleCharacter;
import net.server.Server;
import tools.MaplePacketCreator;
import java.net.InetAddress;
import java.net.UnknownHostException;
public class WarpWorldCommand extends Command {
{
setDescription("");
}
@Override
public void execute(MapleClient c, String[] params) {
MapleCharacter 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(worldb, c.getChannel());
c.getWorldServer().removePlayer(player);
player.getMap().removePlayer(player);//LOL FORGOT THIS ><
player.setSessionTransitionState();
player.setWorld(worldb);
player.saveCharToDB();//To set the new world :O (true because else 2 player instances are created, one in both worlds)
c.announce(MaplePacketCreator.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));
}
}
}