Bau version refactoring, Bau 1.20 starter
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Ursprung
3db61577b0
Commit
e5cc016652
@ -27,10 +27,8 @@ public class ServerStarter {
|
|||||||
private static final String EVENT_PATH = USER_HOME + "event/";
|
private static final String EVENT_PATH = USER_HOME + "event/";
|
||||||
public static final String TEMP_WORLD_PATH = USER_HOME + "arenaserver/";
|
public static final String TEMP_WORLD_PATH = USER_HOME + "arenaserver/";
|
||||||
public static final String TUTORIAL_PATH = USER_HOME + "tutorials/";
|
public static final String TUTORIAL_PATH = USER_HOME + "tutorials/";
|
||||||
public static final String WORLDS12_PATH = USER_HOME + "userworlds/";
|
|
||||||
public static final String WORLDS15_PATH = USER_HOME + "userworlds15/";
|
|
||||||
public static final String WORLDS19_PATH = USER_HOME + "userworlds19/";
|
|
||||||
|
|
||||||
|
public static final String WORLDS_BASE_PATH = USER_HOME + "userworlds";
|
||||||
public static final String BUILDER_BASE_PATH = USER_HOME + "builder";
|
public static final String BUILDER_BASE_PATH = USER_HOME + "builder";
|
||||||
|
|
||||||
private File directory = null;
|
private File directory = null;
|
||||||
@ -114,30 +112,32 @@ public class ServerStarter {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ServerStarter build19(UUID owner) {
|
public ServerStarter build(Version version, UUID owner) {
|
||||||
directory = new File(SERVER_PATH, "Bau19");
|
directory = version.getServerDirectory("Bau");
|
||||||
serverJar = "paper-1.19.3.jar";
|
serverJar = version.getServerJar();
|
||||||
worldDir = WORLDS19_PATH;
|
worldDir = version.getWorldFolder(WORLDS_BASE_PATH);
|
||||||
worldName = String.valueOf(SteamwarUser.get(owner).getId());
|
worldName = version != Version.SPIGOT_12 ? String.valueOf(SteamwarUser.get(owner).getId()) : owner.toString();
|
||||||
buildWithWorld(owner, new File(directory, "Bauwelt").getPath());
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ServerStarter build15(UUID owner) {
|
build(owner);
|
||||||
directory = new File(SERVER_PATH, "Bau15");
|
|
||||||
worldDir = WORLDS15_PATH;
|
worldSetup = () -> {
|
||||||
worldName = String.valueOf(SteamwarUser.get(owner).getId());
|
File world = new File(worldDir, worldName);
|
||||||
buildWithWorld(owner, new File(directory, "Bauwelt").getPath());
|
if (!world.exists())
|
||||||
return this;
|
copyWorld(node, new File(directory, "Bauwelt").getPath(), world.getPath());
|
||||||
}
|
};
|
||||||
|
|
||||||
|
// Send players to existing server
|
||||||
|
startCondition = () -> {
|
||||||
|
for(Subserver subserver : Subserver.getServerList()) {
|
||||||
|
if(subserver.getType() == Servertype.BAUSERVER && ((Bauserver)subserver).getOwner().equals(owner)) {
|
||||||
|
for(ProxiedPlayer p : playersToSend)
|
||||||
|
SubserverSystem.sendPlayer(subserver, p);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
public ServerStarter build12(UUID owner) {
|
|
||||||
directory = new File(SERVER_PATH, "Bau12");
|
|
||||||
serverJar = "spigot-1.12.2.jar";
|
|
||||||
xmx = "256M";
|
|
||||||
worldDir = WORLDS12_PATH;
|
|
||||||
worldName = owner.toString();
|
|
||||||
buildWithWorld(owner, new File(directory, "Bauwelt").getPath());
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -155,28 +155,6 @@ public class ServerStarter {
|
|||||||
worldCleanup = () -> SubserverSystem.deleteFolder(node, worldDir + worldName);
|
worldCleanup = () -> SubserverSystem.deleteFolder(node, worldDir + worldName);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buildWithWorld(UUID owner, String prototype) {
|
|
||||||
build(owner);
|
|
||||||
|
|
||||||
worldSetup = () -> {
|
|
||||||
File world = new File(worldDir, worldName);
|
|
||||||
if (!world.exists())
|
|
||||||
copyWorld(node, prototype, world.getPath());
|
|
||||||
};
|
|
||||||
|
|
||||||
// Send players to existing server
|
|
||||||
startCondition = () -> {
|
|
||||||
for(Subserver subserver : Subserver.getServerList()) {
|
|
||||||
if(subserver.getType() == Servertype.BAUSERVER && ((Bauserver)subserver).getOwner().equals(owner)) {
|
|
||||||
for(ProxiedPlayer p : playersToSend)
|
|
||||||
SubserverSystem.sendPlayer(subserver, p);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buildWithTemp(ProxiedPlayer owner) {
|
private void buildWithTemp(ProxiedPlayer owner) {
|
||||||
build(owner.getUniqueId());
|
build(owner.getUniqueId());
|
||||||
|
|
||||||
|
@ -24,13 +24,12 @@ import de.steamwar.bungeecore.inventory.SWInventory;
|
|||||||
import de.steamwar.bungeecore.inventory.SWItem;
|
import de.steamwar.bungeecore.inventory.SWItem;
|
||||||
import de.steamwar.bungeecore.network.NetworkSender;
|
import de.steamwar.bungeecore.network.NetworkSender;
|
||||||
import de.steamwar.bungeecore.util.BauLock;
|
import de.steamwar.bungeecore.util.BauLock;
|
||||||
|
import de.steamwar.bungeecore.util.BauLockState;
|
||||||
import de.steamwar.bungeecore.util.Chat19;
|
import de.steamwar.bungeecore.util.Chat19;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.command.TypeMapper;
|
import de.steamwar.command.TypeMapper;
|
||||||
import de.steamwar.command.TypeValidator;
|
import de.steamwar.command.TypeValidator;
|
||||||
import de.steamwar.messages.ChatSender;
|
|
||||||
import de.steamwar.network.packets.server.BaumemberUpdatePacket;
|
import de.steamwar.network.packets.server.BaumemberUpdatePacket;
|
||||||
import de.steamwar.bungeecore.util.BauLockState;
|
|
||||||
import de.steamwar.sql.BauweltMember;
|
import de.steamwar.sql.BauweltMember;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import net.md_5.bungee.api.CommandSender;
|
import net.md_5.bungee.api.CommandSender;
|
||||||
@ -57,61 +56,46 @@ public class BauCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Register
|
@Register
|
||||||
public void toBau(ProxiedPlayer p, @Mapper("version") @OptionalValue(value = "", onlyUINIG = true) int version) {
|
public void toBau(ProxiedPlayer p, @Mapper("version") @OptionalValue(value = "", onlyUINIG = true) ServerStarter.Version version) {
|
||||||
versionSelector(version,
|
new ServerStarter().build(version, p.getUniqueId()).send(p).start();
|
||||||
() -> new ServerStarter().build12(p.getUniqueId()).send(p).start(),
|
|
||||||
() -> new ServerStarter().build15(p.getUniqueId()).send(p).start(),
|
|
||||||
() -> new ServerStarter().build19(p.getUniqueId()).send(p).start()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void versionSelector(int version, Runnable r12, Runnable r15, Runnable r19) {
|
|
||||||
switch (version) {
|
|
||||||
case 12:
|
|
||||||
r12.run();
|
|
||||||
break;
|
|
||||||
case 15:
|
|
||||||
r15.run();
|
|
||||||
break;
|
|
||||||
case 19:
|
|
||||||
r19.run();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Mapper(value = "version", local = true)
|
@Mapper(value = "version", local = true)
|
||||||
public TypeMapper<Integer> versionMapper() {
|
public TypeMapper<ServerStarter.Version> versionMapper() {
|
||||||
Map<String, Integer> versionMap = new HashMap<>();
|
Map<String, ServerStarter.Version> versionMap = new HashMap<>();
|
||||||
versionMap.put("19", 19);
|
versionMap.put("20", ServerStarter.Version.PAPER_20);
|
||||||
versionMap.put("1.19", 19);
|
versionMap.put("1.20", ServerStarter.Version.PAPER_20);
|
||||||
versionMap.put("mwg", 19);
|
|
||||||
versionMap.put("miniwargear", 19);
|
|
||||||
versionMap.put("wg", 19);
|
|
||||||
versionMap.put("wargear", 19);
|
|
||||||
versionMap.put("ws", 15);
|
|
||||||
|
|
||||||
versionMap.put("15", 15);
|
versionMap.put("19", ServerStarter.Version.PAPER_19);
|
||||||
versionMap.put("1.15", 15);
|
versionMap.put("1.19", ServerStarter.Version.PAPER_19);
|
||||||
versionMap.put("warship", 15);
|
versionMap.put("mwg", ServerStarter.Version.PAPER_19);
|
||||||
versionMap.put("as", 15);
|
versionMap.put("miniwargear", ServerStarter.Version.PAPER_19);
|
||||||
versionMap.put("airship", 15);
|
versionMap.put("wg", ServerStarter.Version.PAPER_19);
|
||||||
|
versionMap.put("wargear", ServerStarter.Version.PAPER_19);
|
||||||
|
versionMap.put("ws", ServerStarter.Version.PAPER_19);
|
||||||
|
versionMap.put("warship", ServerStarter.Version.PAPER_19);
|
||||||
|
versionMap.put("as", ServerStarter.Version.PAPER_19);
|
||||||
|
versionMap.put("airship", ServerStarter.Version.PAPER_19);
|
||||||
|
|
||||||
versionMap.put("12", 12);
|
versionMap.put("15", ServerStarter.Version.SPIGOT_15);
|
||||||
versionMap.put("1.12", 12);
|
versionMap.put("1.15", ServerStarter.Version.SPIGOT_15);
|
||||||
|
|
||||||
return new TypeMapper<Integer>() {
|
versionMap.put("12", ServerStarter.Version.SPIGOT_12);
|
||||||
|
versionMap.put("1.12", ServerStarter.Version.SPIGOT_12);
|
||||||
|
|
||||||
|
return new TypeMapper<ServerStarter.Version>() {
|
||||||
@Override
|
@Override
|
||||||
public Integer map(CommandSender commandSender, String[] previousArguments, String s) {
|
public ServerStarter.Version map(CommandSender commandSender, String[] previousArguments, String s) {
|
||||||
if (commandSender == null) return null;
|
if (commandSender == null) return null;
|
||||||
ProxiedPlayer player = (ProxiedPlayer) commandSender;
|
ProxiedPlayer player = (ProxiedPlayer) commandSender;
|
||||||
if (s.isEmpty()) {
|
if (s.isEmpty()) {
|
||||||
int version = player.getPendingConnection().getVersion();
|
int version = player.getPendingConnection().getVersion();
|
||||||
if (version > 578) { // Version > 1.15.2
|
if (version > 578) { // Version > 1.15.2
|
||||||
return 19;
|
return ServerStarter.Version.PAPER_19;
|
||||||
} else if (version > 340) { // Version > 1.12.2
|
} else if (version > 340) { // Version > 1.12.2
|
||||||
return 15;
|
return ServerStarter.Version.SPIGOT_15;
|
||||||
} else {
|
} else {
|
||||||
return 12;
|
return ServerStarter.Version.SPIGOT_12;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return versionMap.get(s.toLowerCase());
|
return versionMap.get(s.toLowerCase());
|
||||||
@ -155,12 +139,8 @@ public class BauCommand extends SWCommand {
|
|||||||
|
|
||||||
@Register(value = "tp", description = "BAU_TP_USAGE")
|
@Register(value = "tp", description = "BAU_TP_USAGE")
|
||||||
@Register("teleport")
|
@Register("teleport")
|
||||||
public void teleport(ProxiedPlayer p, @Validator("teleportTarget") SteamwarUser worldOwner, @Mapper("version") @OptionalValue(value = "", onlyUINIG = true) int version) {
|
public void teleport(ProxiedPlayer p, @Validator("teleportTarget") SteamwarUser worldOwner, @Mapper("version") @OptionalValue(value = "", onlyUINIG = true) ServerStarter.Version version) {
|
||||||
versionSelector(version,
|
new ServerStarter().build(version, worldOwner.getUUID()).send(p).start();
|
||||||
() -> new ServerStarter().build12(worldOwner.getUUID()).send(p).start(),
|
|
||||||
() -> new ServerStarter().build15(worldOwner.getUUID()).send(p).start(),
|
|
||||||
() -> new ServerStarter().build19(worldOwner.getUUID()).send(p).start()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Validator(value = "teleportTarget", local = true)
|
@Validator(value = "teleportTarget", local = true)
|
||||||
@ -254,13 +234,8 @@ public class BauCommand extends SWCommand {
|
|||||||
|
|
||||||
@Register("resetall")
|
@Register("resetall")
|
||||||
@Register("delete")
|
@Register("delete")
|
||||||
public void delete(ProxiedPlayer p, @Mapper("version") @OptionalValue(value = "", onlyUINIG = true) int version) {
|
public void delete(ProxiedPlayer p, @Mapper("version") @OptionalValue(value = "", onlyUINIG = true) ServerStarter.Version version) {
|
||||||
SteamwarUser user = SteamwarUser.get(p.getUniqueId());
|
deleteConfirmation(p, () -> deleteWorld(p, version.getWorldFolder(ServerStarter.WORLDS_BASE_PATH) + (version != ServerStarter.Version.SPIGOT_12 ? SteamwarUser.get(p.getUniqueId()).getId() : p.getUniqueId().toString())));
|
||||||
versionSelector(version,
|
|
||||||
() -> deleteConfirmation(p, () -> deleteWorld(p, ServerStarter.WORLDS12_PATH + p.getUniqueId().toString())),
|
|
||||||
() -> deleteConfirmation(p, () -> deleteWorld(p, ServerStarter.WORLDS15_PATH + user.getId())),
|
|
||||||
() -> deleteConfirmation(p, () -> deleteWorld(p, ServerStarter.WORLDS19_PATH + user.getId()))
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void deleteConfirmation(ProxiedPlayer p, Runnable worldDeletion) {
|
private static void deleteConfirmation(ProxiedPlayer p, Runnable worldDeletion) {
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren