geforkt von SteamWar/BungeeCore
Merge pull request 'Bau version refactoring, Bau 1.20 starter' (#480) from bau1.20 into master
Reviewed-on: SteamWar/BungeeCore#480 Reviewed-by: Chaoscaot <chaoscaot@zohomail.eu>
Dieser Commit ist enthalten in:
Commit
3980961b76
@ -27,10 +27,8 @@ public class ServerStarter {
|
||||
private static final String EVENT_PATH = USER_HOME + "event/";
|
||||
public static final String TEMP_WORLD_PATH = USER_HOME + "arenaserver/";
|
||||
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";
|
||||
|
||||
private File directory = null;
|
||||
@ -114,30 +112,32 @@ public class ServerStarter {
|
||||
return this;
|
||||
}
|
||||
|
||||
public ServerStarter build19(UUID owner) {
|
||||
directory = new File(SERVER_PATH, "Bau19");
|
||||
serverJar = "paper-1.19.3.jar";
|
||||
worldDir = WORLDS19_PATH;
|
||||
worldName = String.valueOf(SteamwarUser.get(owner).getId());
|
||||
buildWithWorld(owner, new File(directory, "Bauwelt").getPath());
|
||||
return this;
|
||||
}
|
||||
public ServerStarter build(Version version, UUID owner) {
|
||||
directory = version.getServerDirectory("Bau");
|
||||
serverJar = version.getServerJar();
|
||||
worldDir = version.getWorldFolder(WORLDS_BASE_PATH);
|
||||
worldName = version != Version.SPIGOT_12 ? String.valueOf(SteamwarUser.get(owner).getId()) : owner.toString();
|
||||
|
||||
public ServerStarter build15(UUID owner) {
|
||||
directory = new File(SERVER_PATH, "Bau15");
|
||||
worldDir = WORLDS15_PATH;
|
||||
worldName = String.valueOf(SteamwarUser.get(owner).getId());
|
||||
buildWithWorld(owner, new File(directory, "Bauwelt").getPath());
|
||||
return this;
|
||||
}
|
||||
build(owner);
|
||||
|
||||
worldSetup = () -> {
|
||||
File world = new File(worldDir, worldName);
|
||||
if (!world.exists())
|
||||
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;
|
||||
}
|
||||
|
||||
@ -155,28 +155,6 @@ public class ServerStarter {
|
||||
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) {
|
||||
build(owner.getUniqueId());
|
||||
|
||||
|
@ -24,13 +24,12 @@ import de.steamwar.bungeecore.inventory.SWInventory;
|
||||
import de.steamwar.bungeecore.inventory.SWItem;
|
||||
import de.steamwar.bungeecore.network.NetworkSender;
|
||||
import de.steamwar.bungeecore.util.BauLock;
|
||||
import de.steamwar.bungeecore.util.BauLockState;
|
||||
import de.steamwar.bungeecore.util.Chat19;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.command.TypeMapper;
|
||||
import de.steamwar.command.TypeValidator;
|
||||
import de.steamwar.messages.ChatSender;
|
||||
import de.steamwar.network.packets.server.BaumemberUpdatePacket;
|
||||
import de.steamwar.bungeecore.util.BauLockState;
|
||||
import de.steamwar.sql.BauweltMember;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
@ -57,61 +56,46 @@ public class BauCommand extends SWCommand {
|
||||
}
|
||||
|
||||
@Register
|
||||
public void toBau(ProxiedPlayer p, @Mapper("version") @OptionalValue(value = "", onlyUINIG = true) int version) {
|
||||
versionSelector(version,
|
||||
() -> 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;
|
||||
}
|
||||
public void toBau(ProxiedPlayer p, @Mapper("version") @OptionalValue(value = "", onlyUINIG = true) ServerStarter.Version version) {
|
||||
new ServerStarter().build(version, p.getUniqueId()).send(p).start();
|
||||
}
|
||||
|
||||
@Mapper(value = "version", local = true)
|
||||
public TypeMapper<Integer> versionMapper() {
|
||||
Map<String, Integer> versionMap = new HashMap<>();
|
||||
versionMap.put("19", 19);
|
||||
versionMap.put("1.19", 19);
|
||||
versionMap.put("mwg", 19);
|
||||
versionMap.put("miniwargear", 19);
|
||||
versionMap.put("wg", 19);
|
||||
versionMap.put("wargear", 19);
|
||||
versionMap.put("ws", 15);
|
||||
public TypeMapper<ServerStarter.Version> versionMapper() {
|
||||
Map<String, ServerStarter.Version> versionMap = new HashMap<>();
|
||||
versionMap.put("20", ServerStarter.Version.PAPER_20);
|
||||
versionMap.put("1.20", ServerStarter.Version.PAPER_20);
|
||||
|
||||
versionMap.put("15", 15);
|
||||
versionMap.put("1.15", 15);
|
||||
versionMap.put("warship", 15);
|
||||
versionMap.put("as", 15);
|
||||
versionMap.put("airship", 15);
|
||||
versionMap.put("19", ServerStarter.Version.PAPER_19);
|
||||
versionMap.put("1.19", ServerStarter.Version.PAPER_19);
|
||||
versionMap.put("mwg", ServerStarter.Version.PAPER_19);
|
||||
versionMap.put("miniwargear", ServerStarter.Version.PAPER_19);
|
||||
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("1.12", 12);
|
||||
versionMap.put("15", ServerStarter.Version.SPIGOT_15);
|
||||
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
|
||||
public Integer map(CommandSender commandSender, String[] previousArguments, String s) {
|
||||
public ServerStarter.Version map(CommandSender commandSender, String[] previousArguments, String s) {
|
||||
if (commandSender == null) return null;
|
||||
ProxiedPlayer player = (ProxiedPlayer) commandSender;
|
||||
if (s.isEmpty()) {
|
||||
int version = player.getPendingConnection().getVersion();
|
||||
if (version > 578) { // Version > 1.15.2
|
||||
return 19;
|
||||
return ServerStarter.Version.PAPER_19;
|
||||
} else if (version > 340) { // Version > 1.12.2
|
||||
return 15;
|
||||
return ServerStarter.Version.SPIGOT_15;
|
||||
} else {
|
||||
return 12;
|
||||
return ServerStarter.Version.SPIGOT_12;
|
||||
}
|
||||
}
|
||||
return versionMap.get(s.toLowerCase());
|
||||
@ -155,12 +139,8 @@ public class BauCommand extends SWCommand {
|
||||
|
||||
@Register(value = "tp", description = "BAU_TP_USAGE")
|
||||
@Register("teleport")
|
||||
public void teleport(ProxiedPlayer p, @Validator("teleportTarget") SteamwarUser worldOwner, @Mapper("version") @OptionalValue(value = "", onlyUINIG = true) int version) {
|
||||
versionSelector(version,
|
||||
() -> new ServerStarter().build12(worldOwner.getUUID()).send(p).start(),
|
||||
() -> new ServerStarter().build15(worldOwner.getUUID()).send(p).start(),
|
||||
() -> new ServerStarter().build19(worldOwner.getUUID()).send(p).start()
|
||||
);
|
||||
public void teleport(ProxiedPlayer p, @Validator("teleportTarget") SteamwarUser worldOwner, @Mapper("version") @OptionalValue(value = "", onlyUINIG = true) ServerStarter.Version version) {
|
||||
new ServerStarter().build(version, worldOwner.getUUID()).send(p).start();
|
||||
}
|
||||
|
||||
@Validator(value = "teleportTarget", local = true)
|
||||
@ -254,13 +234,8 @@ public class BauCommand extends SWCommand {
|
||||
|
||||
@Register("resetall")
|
||||
@Register("delete")
|
||||
public void delete(ProxiedPlayer p, @Mapper("version") @OptionalValue(value = "", onlyUINIG = true) int version) {
|
||||
SteamwarUser user = SteamwarUser.get(p.getUniqueId());
|
||||
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()))
|
||||
);
|
||||
public void delete(ProxiedPlayer p, @Mapper("version") @OptionalValue(value = "", onlyUINIG = true) ServerStarter.Version version) {
|
||||
deleteConfirmation(p, () -> deleteWorld(p, version.getWorldFolder(ServerStarter.WORLDS_BASE_PATH) + (version != ServerStarter.Version.SPIGOT_12 ? SteamwarUser.get(p.getUniqueId()).getId() : p.getUniqueId().toString())));
|
||||
}
|
||||
|
||||
private static void deleteConfirmation(ProxiedPlayer p, Runnable worldDeletion) {
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren