Archiviert
1
0
Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Lixfel 2022-03-30 11:38:29 +02:00
Ursprung d2d8e8af6d
Commit bc8db04edf
2 geänderte Dateien mit 88 neuen und 72 gelöschten Zeilen

Datei anzeigen

@ -26,6 +26,7 @@ public class ServerStarter {
private static final String EVENT_PATH = BACKBONE + "event/";
public static final String TEMP_WORLD_PATH = BACKBONE + "arenaserver/";
public static final String TUTORIAL_PATH = BACKBONE + "tutorials/";
public static final String WORLDS18_PATH = BACKBONE + "userworlds18/";
private File directory = null;
private String worldDir = null;
@ -100,6 +101,14 @@ public class ServerStarter {
return this;
}
public ServerStarter build18(UUID owner) {
directory = new File(SERVER_PATH, "Bau18");
worldDir = WORLDS18_PATH;
worldName = String.valueOf(SteamwarUser.get(owner).getId());
buildWithWorld(owner, new File(directory, "Bauwelt").getPath());
return this;
}
public ServerStarter build15(UUID owner) {
directory = new File(SERVER_PATH, "Bau15");
worldDir = BungeeCore.USERWORLDS15;

Datei anzeigen

@ -33,7 +33,7 @@ import net.md_5.bungee.api.connection.ProxiedPlayer;
public class BauCommand extends BasicCommand {
public BauCommand(){
super("bau", null, "b", "gs");
super("bau", null, "b", "build", "gs");
}
@Override
@ -44,58 +44,44 @@ public class BauCommand extends BasicCommand {
ProxiedPlayer p = (ProxiedPlayer) sender;
if(args.length == 0){
(bau15(p, args, 0) ? new ServerStarter().build15(p.getUniqueId()) : new ServerStarter().build12(p.getUniqueId())).send(p).start();
return;
}
switch(args[0].toLowerCase()){
case "12":
case "1.12":
new ServerStarter().build12(p.getUniqueId()).send(p).start();
break;
case "ws":
case "warship":
case "as":
case "airship":
case "mwg":
case "miniwargear":
case "wg":
case "wargear":
case "15":
case "1.15":
new ServerStarter().build15(p.getUniqueId()).send(p).start();
break;
case "addmember":
addmember(p, args);
break;
case "tp":
case "teleport":
teleport(p, args);
break;
case "info":
p.chat("/bauinfo");
break;
case "togglewe":
togglewe(p, args);
break;
case "toggleworld":
toggleworld(p, args);
break;
case "delmember":
delmember(p, args);
break;
case "resetall":
case "delete":
delete(p, args);
break;
case "testarena":
case "test":
testarena(p, args);
break;
default:
HelpCommand.sendBauHelp(p);
}
versionSelector(p, args, 0,
() -> new ServerStarter().build18(p.getUniqueId()).send(p).start(),
() -> new ServerStarter().build15(p.getUniqueId()).send(p).start(),
() -> new ServerStarter().build12(p.getUniqueId()).send(p).start(),
() -> {
switch (args[0].toLowerCase()) {
case "addmember":
addmember(p, args);
break;
case "tp":
case "teleport":
teleport(p, args);
break;
case "info":
p.chat("/bauinfo");
break;
case "togglewe":
togglewe(p, args);
break;
case "toggleworld":
toggleworld(p, args);
break;
case "delmember":
delmember(p, args);
break;
case "resetall":
case "delete":
delete(p, args);
break;
case "testarena":
case "test":
testarena(p, args);
break;
default:
HelpCommand.sendBauHelp(p);
}
}
);
}
private static void addmember(ProxiedPlayer p, String[] args){
@ -140,19 +126,31 @@ public class BauCommand extends BasicCommand {
return;
}
(bau15(p, args, 2) ? new ServerStarter().build15(worldOwner.getUuid()) : new ServerStarter().build12(worldOwner.getUuid())).send(p).start();
versionSelector(p, args, 2,
() -> new ServerStarter().build18(worldOwner.getUuid()).send(p).start(),
() -> new ServerStarter().build15(worldOwner.getUuid()).send(p).start(),
() -> new ServerStarter().build12(worldOwner.getUuid()).send(p).start(),
() -> HelpCommand.sendBauHelp(p));
}
private static boolean bau15(ProxiedPlayer p, String[] args, int pos){
if(args.length <= pos)
return p.getPendingConnection().getVersion() > 340; // Version > 1.12.2
private static void versionSelector(ProxiedPlayer p, String[] args, int pos, Runnable run18, Runnable run15, Runnable run12, Runnable runElse) {
if(args.length <= pos) {
int version = p.getPendingConnection().getVersion();
if(version > 340) { // Version > 1.12.2
run15.run();
} else {
run12.run();
}
return;
}
switch(args[pos].toLowerCase()){
switch (args[pos].toLowerCase()) {
case "18":
case "1.18":
run18.run();
break;
case "ws":
case "warship":
case "12":
case "1.12":
return false;
case "as":
case "airship":
case "mwg":
@ -161,9 +159,14 @@ public class BauCommand extends BasicCommand {
case "wargear":
case "15":
case "1.15":
return true;
run15.run();
break;
case "12":
case "1.12":
run12.run();
break;
default:
return p.getPendingConnection().getVersion() > 340; // Version > 1.12.2
runElse.run();
}
}
@ -225,18 +228,22 @@ public class BauCommand extends BasicCommand {
}
private static void delete(ProxiedPlayer p, String[] args){
SteamwarUser user = SteamwarUser.get(p.getUniqueId());
versionSelector(p, args, 1,
() -> deleteConfirmation(p, () -> deleteWorld(p, ServerStarter.WORLDS18_PATH + user.getId())),
() -> deleteConfirmation(p, () -> deleteWorld(p, BungeeCore.USERWORLDS15 + user.getId())),
() -> deleteConfirmation(p, () -> deleteWorld(p, BungeeCore.WORLD_FOLDER + p.getUniqueId().toString())),
() -> HelpCommand.sendBauHelp(p));
}
private static void deleteConfirmation(ProxiedPlayer p, Runnable worldDeletion) {
SWInventory inventory = new SWInventory(p, 9, Message.parse("BAU_DELETE_GUI_NAME", p));
inventory.addItem(8, new SWItem(Message.parse("BAU_DELETE_GUI_CANCEL", p), 1), click ->
inventory.close()
inventory.close()
);
inventory.addItem(0, new SWItem(Message.parse("BAU_DELETE_GUI_DELETE", p), 10), click ->
worldDeletion.run()
);
inventory.addItem(0, new SWItem(Message.parse("BAU_DELETE_GUI_DELETE", p), 10), click -> {
if(bau15(p, args, 1)){
SteamwarUser user = SteamwarUser.get(p.getUniqueId());
deleteWorld(p, BungeeCore.USERWORLDS15 + user.getId());
}else{
deleteWorld(p, BungeeCore.WORLD_FOLDER + p.getUniqueId().toString());
}
});
inventory.open();
}