cleanup: replace anonymous inner class with lambda

This commit is contained in:
P0nk
2021-04-07 23:45:16 +02:00
parent 2d143d0afd
commit 6253169e35
65 changed files with 1204 additions and 2234 deletions

View File

@@ -45,23 +45,20 @@ public class ServerAddChannelCommand extends Command {
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 + ".");
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 {
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.");
}
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

@@ -38,20 +38,17 @@ public class ServerAddWorldCommand extends Command {
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();
ThreadManager.getInstance().newTask(() -> {
int wid = Server.getInstance().addWorld();
if(player.isLoggedinWorld()) {
if(wid >= 0) {
player.dropMessage(5, "NEW World " + wid + " successfully deployed.");
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 {
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.");
}
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

@@ -44,17 +44,14 @@ public class ServerRemoveChannelCommand extends Command {
}
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.");
}
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

@@ -44,20 +44,17 @@ public class ServerRemoveWorldCommand extends Command {
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.");
}
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.");
}
}
}