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/"; private static final String EVENT_PATH = BACKBONE + "event/";
public static final String TEMP_WORLD_PATH = BACKBONE + "arenaserver/"; public static final String TEMP_WORLD_PATH = BACKBONE + "arenaserver/";
public static final String TUTORIAL_PATH = BACKBONE + "tutorials/"; public static final String TUTORIAL_PATH = BACKBONE + "tutorials/";
public static final String WORLDS18_PATH = BACKBONE + "userworlds18/";
private File directory = null; private File directory = null;
private String worldDir = null; private String worldDir = null;
@ -100,6 +101,14 @@ public class ServerStarter {
return this; 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) { public ServerStarter build15(UUID owner) {
directory = new File(SERVER_PATH, "Bau15"); directory = new File(SERVER_PATH, "Bau15");
worldDir = BungeeCore.USERWORLDS15; worldDir = BungeeCore.USERWORLDS15;

Datei anzeigen

@ -33,7 +33,7 @@ import net.md_5.bungee.api.connection.ProxiedPlayer;
public class BauCommand extends BasicCommand { public class BauCommand extends BasicCommand {
public BauCommand(){ public BauCommand(){
super("bau", null, "b", "gs"); super("bau", null, "b", "build", "gs");
} }
@Override @Override
@ -44,28 +44,12 @@ public class BauCommand extends BasicCommand {
ProxiedPlayer p = (ProxiedPlayer) sender; ProxiedPlayer p = (ProxiedPlayer) sender;
if(args.length == 0){ versionSelector(p, args, 0,
(bau15(p, args, 0) ? new ServerStarter().build15(p.getUniqueId()) : new ServerStarter().build12(p.getUniqueId())).send(p).start(); () -> new ServerStarter().build18(p.getUniqueId()).send(p).start(),
return; () -> new ServerStarter().build15(p.getUniqueId()).send(p).start(),
} () -> new ServerStarter().build12(p.getUniqueId()).send(p).start(),
() -> {
switch (args[0].toLowerCase()) { 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": case "addmember":
addmember(p, args); addmember(p, args);
break; break;
@ -97,6 +81,8 @@ public class BauCommand extends BasicCommand {
HelpCommand.sendBauHelp(p); HelpCommand.sendBauHelp(p);
} }
} }
);
}
private static void addmember(ProxiedPlayer p, String[] args){ private static void addmember(ProxiedPlayer p, String[] args){
if (args.length == 1) { if (args.length == 1) {
@ -140,19 +126,31 @@ public class BauCommand extends BasicCommand {
return; 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){ private static void versionSelector(ProxiedPlayer p, String[] args, int pos, Runnable run18, Runnable run15, Runnable run12, Runnable runElse) {
if(args.length <= pos) if(args.length <= pos) {
return p.getPendingConnection().getVersion() > 340; // Version > 1.12.2 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 "ws":
case "warship": case "warship":
case "12":
case "1.12":
return false;
case "as": case "as":
case "airship": case "airship":
case "mwg": case "mwg":
@ -161,9 +159,14 @@ public class BauCommand extends BasicCommand {
case "wargear": case "wargear":
case "15": case "15":
case "1.15": case "1.15":
return true; run15.run();
break;
case "12":
case "1.12":
run12.run();
break;
default: 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){ 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)); 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.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 -> { inventory.addItem(0, new SWItem(Message.parse("BAU_DELETE_GUI_DELETE", p), 10), click ->
if(bau15(p, args, 1)){ worldDeletion.run()
SteamwarUser user = SteamwarUser.get(p.getUniqueId()); );
deleteWorld(p, BungeeCore.USERWORLDS15 + user.getId());
}else{
deleteWorld(p, BungeeCore.WORLD_FOLDER + p.getUniqueId().toString());
}
});
inventory.open(); inventory.open();
} }