forked from SteamWar/SteamWar
Add world-based permissions and migration commands
- Switch bau logic from owner-scoped to world-scoped data - Add CLI commands for world migration, templating, and archiving - Extend world storage with team worlds and lock state support
This commit is contained in:
@@ -20,14 +20,54 @@
|
||||
package de.steamwar.providers;
|
||||
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
import de.steamwar.sql.WorldType;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class BauServerInfo {
|
||||
private static Integer bauOwner = null;
|
||||
private static Integer bauTeam = null;
|
||||
private static UUID bauWorld = null;
|
||||
private static WorldType bauType = null;
|
||||
|
||||
static {
|
||||
String ownerProperty = System.getProperty("bauOwner");
|
||||
if (ownerProperty != null && !ownerProperty.isBlank()) {
|
||||
try {
|
||||
bauOwner = Integer.parseInt(ownerProperty);
|
||||
} catch (NumberFormatException ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
String teamProperty = System.getProperty("bauTeam");
|
||||
if (teamProperty != null && !teamProperty.isBlank()) {
|
||||
try {
|
||||
bauTeam = Integer.parseInt(teamProperty);
|
||||
} catch (NumberFormatException ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
String worldProperty = System.getProperty("bauWorld");
|
||||
if (worldProperty != null && !worldProperty.isBlank()) {
|
||||
try {
|
||||
bauWorld = UUID.fromString(worldProperty);
|
||||
} catch (IllegalArgumentException ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
String typeProperty = System.getProperty("bauType");
|
||||
if (typeProperty != null && !typeProperty.isBlank()) {
|
||||
try {
|
||||
bauType = WorldType.valueOf(typeProperty);
|
||||
} catch (IllegalArgumentException ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
bauOwner = Integer.parseInt(Bukkit.getWorlds().get(0).getName());
|
||||
if (bauOwner == null) {
|
||||
bauOwner = Integer.parseInt(Bukkit.getWorlds().get(0).getName());
|
||||
}
|
||||
} catch (NumberFormatException ignored) {
|
||||
}
|
||||
}
|
||||
@@ -37,11 +77,23 @@ public class BauServerInfo {
|
||||
}
|
||||
|
||||
public static boolean isBauServer() {
|
||||
return bauOwner != null;
|
||||
return bauOwner != null || bauWorld != null || bauTeam != null;
|
||||
}
|
||||
|
||||
public static SteamwarUser getOwnerUser() {
|
||||
if (bauOwner == null) return null;
|
||||
return SteamwarUser.byId(bauOwner);
|
||||
}
|
||||
|
||||
public static UUID getWorldId() {
|
||||
return bauWorld;
|
||||
}
|
||||
|
||||
public static Integer getTeamId() {
|
||||
return bauTeam;
|
||||
}
|
||||
|
||||
public static WorldType getWorldType() {
|
||||
return bauType;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user