package net.rustnotmc.loader; /** * Which side of the game a mod is meant to run on. * * The loader runs on the client today, but the value is part of the descriptor * from the first release: a mod jar that says BOTH today must not need a format * change tomorrow when the loader moves to the server. */ public enum ModEnv { CLIENT, SERVER, BOTH; /** True when a mod declaring this env should load on the given side. */ public boolean runsOn(ModEnv side) { if (side == null) { return false; } return this == BOTH || this == side; } /** The side we are running on right now. */ public static ModEnv current() { return CLIENT; } /** * Parses the descriptor value. Unreadable input is treated as BOTH rather * than rejected: refusing to start because of one bad character is worse * than loading a mod that may then find itself unusable. */ public static ModEnv parse(String raw) { if (raw == null) { return BOTH; } String v = raw.trim().toUpperCase(); if (v.length() == 0) { return BOTH; } if (v.equals("CLIENT") || v.equals("CLIENT_ONLY") || v.equals("CLIENTONLY")) { return CLIENT; } if (v.equals("SERVER") || v.equals("SERVER_ONLY") || v.equals("SERVERONLY")) { return SERVER; } return BOTH; } }