Merge pull request 'Buildercloud rework, no automatic map generation, renaming, hidden worlds' (#477) from buildercloud2 into master
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Reviewed-on: #477 Reviewed-by: YoyoNow <jwsteam@nidido.de>
Dieser Commit ist enthalten in:
Commit
5da9d55cb8
@ -3,10 +3,13 @@ package de.steamwar.bungeecore.commands;
|
|||||||
import de.steamwar.bungeecore.ServerStarter;
|
import de.steamwar.bungeecore.ServerStarter;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.command.TypeMapper;
|
import de.steamwar.command.TypeMapper;
|
||||||
|
import de.steamwar.messages.ChatSender;
|
||||||
import net.md_5.bungee.api.CommandSender;
|
import net.md_5.bungee.api.CommandSender;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Files;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@ -25,11 +28,38 @@ public class BuilderCloudCommand extends SWCommand {
|
|||||||
versionMap.put("1.19.2", ServerStarter.Version.PAPER_19);
|
versionMap.put("1.19.2", ServerStarter.Version.PAPER_19);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register(description = "BUILDERCLOUD_USAGE")
|
@Register(value = "create", description = "BUILDERCLOUD_CREATE_USAGE")
|
||||||
public void genericCommand(ProxiedPlayer player, @ErrorMessage("BUILDERCLOUD_VERSION") ServerStarter.Version version, @Mapper("map") String map, @OptionalValue("") @Mapper("generator") @AllowNull File generator) {
|
public void create(ProxiedPlayer player, @ErrorMessage("BUILDERCLOUD_VERSION") ServerStarter.Version version, @Mapper("map") String map, @OptionalValue("") @Mapper("generator") @AllowNull File generator) {
|
||||||
new ServerStarter().builder(version, map, generator).send(player).start();
|
new ServerStarter().builder(version, map, generator).send(player).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Register(description = "BUILDERCLOUD_USAGE")
|
||||||
|
public void start(ProxiedPlayer player, @ErrorMessage("BUILDERCLOUD_VERSION") ServerStarter.Version version, @Mapper("map") String map) {
|
||||||
|
if(!mapFile(version, map).exists()) {
|
||||||
|
ChatSender.of(player).system("BUILDERCLOUD_UNKNOWN_MAP");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
new ServerStarter().builder(version, map, null).send(player).start();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Register(value = "rename", description = "BUILDERCLOUD_RENAME_USAGE")
|
||||||
|
public void rename(ProxiedPlayer player, @ErrorMessage("BUILDERCLOUD_VERSION") ServerStarter.Version version, @Mapper("map") String oldName, String newName) {
|
||||||
|
File newMap = mapFile(version, newName);
|
||||||
|
if(newMap.exists()) {
|
||||||
|
ChatSender.of(player).system("BUILDERCLOUD_EXISTING_MAP");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
Files.move(mapFile(version, oldName).toPath(), newMap.toPath());
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new SecurityException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
ChatSender.of(player).system("BUILDERCLOUD_RENAMED");
|
||||||
|
}
|
||||||
|
|
||||||
@ClassMapper(value = ServerStarter.Version.class, local = true)
|
@ClassMapper(value = ServerStarter.Version.class, local = true)
|
||||||
private TypeMapper<ServerStarter.Version> versionTypeMapper() {
|
private TypeMapper<ServerStarter.Version> versionTypeMapper() {
|
||||||
return new TypeMapper<ServerStarter.Version>() {
|
return new TypeMapper<ServerStarter.Version>() {
|
||||||
@ -72,7 +102,7 @@ public class BuilderCloudCommand extends SWCommand {
|
|||||||
if(folder == null || (files = folder.list()) == null)
|
if(folder == null || (files = folder.list()) == null)
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
|
|
||||||
return Arrays.stream(files).filter(file -> new File(folder, file).isDirectory()).collect(Collectors.toList());
|
return Arrays.stream(files).filter(file -> new File(folder, file).isDirectory()).filter(file -> s.startsWith(".") || !file.startsWith(".")).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -112,6 +142,10 @@ public class BuilderCloudCommand extends SWCommand {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private File mapFile(ServerStarter.Version version, String map) {
|
||||||
|
return new File(version.getWorldFolder(ServerStarter.BUILDER_BASE_PATH), map);
|
||||||
|
}
|
||||||
|
|
||||||
private File getWorldFolder(String[] previousArguments, int offset) {
|
private File getWorldFolder(String[] previousArguments, int offset) {
|
||||||
ServerStarter.Version v = versionMap.get(previousArguments[previousArguments.length - offset]);
|
ServerStarter.Version v = versionMap.get(previousArguments[previousArguments.length - offset]);
|
||||||
if(v == null)
|
if(v == null)
|
||||||
|
@ -659,8 +659,13 @@ FIGHT_MERGE_INFO=§e{0}§8: §e{1}
|
|||||||
LOCK_LOCALE_CHANGED=§aLanguage saved
|
LOCK_LOCALE_CHANGED=§aLanguage saved
|
||||||
|
|
||||||
#Builder Cloud
|
#Builder Cloud
|
||||||
BUILDERCLOUD_USAGE=§8/§7buildercloud §8[§eversion§8] §8[§emap§8] §8<§7generator§8>
|
BUILDERCLOUD_USAGE=§8/§7buildercloud §8[§eversion§8] §8[§emap§8]
|
||||||
|
BUILDERCLOUD_CREATE_USAGE=§8/§7buildercloud create §8[§eversion§8] §8[§emap§8] §8<§7generator§8>
|
||||||
|
BUILDERCLOUD_RENAME_USAGE=§8/§7buildercloud rename §8[§eversion§8] §8[§emap§8] §8[§enew name§8]
|
||||||
BUILDERCLOUD_VERSION=§cUnknown version.
|
BUILDERCLOUD_VERSION=§cUnknown version.
|
||||||
|
BUILDERCLOUD_EXISTING_MAP=§cMap already exists.
|
||||||
|
BUILDERCLOUD_UNKNOWN_MAP=§cUnknown map.
|
||||||
|
BUILDERCLOUD_RENAMED=§7Map rename successful.
|
||||||
|
|
||||||
# Advent Calendar
|
# Advent Calendar
|
||||||
ADVENT_CALENDAR_TITLE=§eAdvent Calendar
|
ADVENT_CALENDAR_TITLE=§eAdvent Calendar
|
||||||
|
@ -635,8 +635,13 @@ FIGHT_MERGE_OFFLINE=§7Die vorgeschlagene Arena wurde in der Zwischenzeit beende
|
|||||||
LOCK_LOCALE_CHANGED=§aSprache gespeichert
|
LOCK_LOCALE_CHANGED=§aSprache gespeichert
|
||||||
|
|
||||||
#Builder Cloud
|
#Builder Cloud
|
||||||
BUILDERCLOUD_USAGE=§8/§7buildercloud §8[§eVersion§8] §8[§eWelt§8] §8<§7Generator§8>
|
BUILDERCLOUD_USAGE=§8/§7buildercloud §8[§eVersion§8] §8[§eWelt§8]
|
||||||
|
BUILDERCLOUD_CREATE_USAGE=§8/§7buildercloud create §8[§eVersion§8] §8[§eWelt§8] §8<§7Generator§8>
|
||||||
|
BUILDERCLOUD_RENAME_USAGE=§8/§7buildercloud rename §8[§eVersion§8] §8[§eWElt§8] §8[§eNeuer Name§8]
|
||||||
BUILDERCLOUD_VERSION=§cUnbekannte Version.
|
BUILDERCLOUD_VERSION=§cUnbekannte Version.
|
||||||
|
BUILDERCLOUD_EXISTING_MAP=§cWelt existiert bereits.
|
||||||
|
BUILDERCLOUD_UNKNOWN_MAP=§cUnbekannte Welt.
|
||||||
|
BUILDERCLOUD_RENAMED=§7Umbenennung erfolgreich.
|
||||||
|
|
||||||
# Advent Calendar
|
# Advent Calendar
|
||||||
ADVENT_CALENDAR_TITLE=§eAdventskalender
|
ADVENT_CALENDAR_TITLE=§eAdventskalender
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren