Last active
October 13, 2024 16:17
-
-
Save WesJD/10ea6b3dc7ec51f84b59 to your computer and use it in GitHub Desktop.
Simple class for changing Minecraft server properties easily.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Properties { | |
public static void savePropertiesFile() { | |
((DedicatedServer) MinecraftServer.getServer()).propertyManager.savePropertiesFile(); | |
} | |
public static void setServerProperty(ServerProperty property, Object value) { | |
((DedicatedServer) MinecraftServer.getServer()).propertyManager.setProperty(property.getPropertyName(), value); | |
} | |
public enum ServerProperty { | |
SPAWN_PROTECTION("spawn-protection"), | |
SERVER_NAME("server-name"), | |
FORCE_GAMEMODE("force-gamemode"), | |
NETHER("allow-nether"), | |
DEFAULT_GAMEMODE("gamemode"), | |
QUERY("enable-query"), | |
PLAYER_IDLE_TIMEOUT("player-idle-timeout"), | |
DIFFICULTY("difficulty"), | |
SPAWN_MONSTERS("spawn-monsters"), | |
OP_PERMISSION_LEVEL("op-permission-level"), | |
RESOURCE_PACK_HASH("resource-pack-hash"), | |
RESOURCE_PACK("resource-pack"), | |
ANNOUNCE_PLAYER_ACHIEVEMENTS("announce-player-achievements"), | |
PVP("pvp"), | |
SNOOPER("snooper-enabled"), | |
LEVEL_NAME("level-name"), | |
LEVEL_TYPE("level-type"), | |
LEVEL_SEED("level-seed"), | |
HARDCORE("hardcore"), | |
COMMAND_BLOCKS("enable-command-blocks"), | |
MAX_PLAYERS("max-players"), | |
PACKET_COMPRESSION_LIMIT("network-compression-threshold"), | |
MAX_WORLD_SIZE("max-world-size"), | |
IP("server-ip"), | |
PORT("server-port"), | |
DEBUG_MODE("debug"), | |
SPAWN_NPCS("spawn-npcs"), | |
SPAWN_ANIMALS("spawn-animals"), | |
FLIGHT("allow-flight"), | |
VIEW_DISTANCE("view-distance"), | |
WHITE_LIST("white-list"), | |
GENERATE_STRUCTURES("generate-structures"), | |
MAX_BUILD_HEIGHT("max-build-height"), | |
MOTD("motd"), | |
REMOTE_CONTROL("enable-rcon"); | |
private String propertyName; | |
ServerProperty(String propertyName) { | |
this.propertyName = propertyName; | |
} | |
public String getPropertyName() { | |
return propertyName; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment