2024-07-23 13:49:43 -05:00
|
|
|
package one.oth3r.sit.utl;
|
|
|
|
|
|
|
|
import net.fabricmc.loader.api.FabricLoader;
|
2024-08-17 13:27:26 -05:00
|
|
|
import net.minecraft.entity.decoration.DisplayEntity;
|
2024-07-23 13:49:43 -05:00
|
|
|
import net.minecraft.server.MinecraftServer;
|
2024-08-17 13:27:26 -05:00
|
|
|
import net.minecraft.server.network.ServerPlayerEntity;
|
2024-07-23 13:49:43 -05:00
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
2024-08-17 13:27:26 -05:00
|
|
|
import java.util.HashMap;
|
|
|
|
|
2024-07-23 13:49:43 -05:00
|
|
|
public class Data {
|
|
|
|
public static final String MOD_ID = "sit-oth3r";
|
|
|
|
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
|
|
|
|
|
|
|
|
public static final String CONFIG_DIR = FabricLoader.getInstance().getConfigDir().toFile()+"/sit!/";
|
|
|
|
|
|
|
|
public static final String ENTITY_NAME = "-sit!-entity-";
|
|
|
|
|
|
|
|
// init on server load
|
|
|
|
private static MinecraftServer server;
|
|
|
|
|
|
|
|
public static MinecraftServer getServer() {
|
|
|
|
return server;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void setServer(MinecraftServer server) {
|
|
|
|
Data.server = server;
|
|
|
|
}
|
|
|
|
|
|
|
|
// client booleans
|
|
|
|
private static boolean client = false;
|
|
|
|
private static boolean inGame = false;
|
|
|
|
private static boolean singleplayer = false;
|
|
|
|
private static boolean supportedServer = false;
|
|
|
|
|
|
|
|
public static boolean isClient() {
|
|
|
|
return client;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void setClient(boolean client) {
|
|
|
|
Data.client = client;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static boolean isInGame() {
|
|
|
|
return inGame;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void setInGame(boolean inGame) {
|
|
|
|
Data.inGame = inGame;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static boolean isSingleplayer() {
|
|
|
|
return singleplayer;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void setSingleplayer(boolean singleplayer) {
|
|
|
|
Data.singleplayer = singleplayer;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static boolean isSupportedServer() {
|
|
|
|
return supportedServer;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void setSupportedServer(boolean supportedServer) {
|
|
|
|
Data.supportedServer = supportedServer;
|
|
|
|
}
|
2024-08-17 13:27:26 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* a list of players who just joined, to check if they are mounted to a Sit! entity
|
|
|
|
*/
|
|
|
|
private static final HashMap<ServerPlayerEntity, Integer> checkPlayers = new HashMap<>();
|
|
|
|
|
|
|
|
public static void setCheckPlayer(ServerPlayerEntity player, Integer time) {
|
|
|
|
checkPlayers.put(player, time);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void removeCheckPlayer(ServerPlayerEntity player) {
|
|
|
|
checkPlayers.remove(player);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static HashMap<ServerPlayerEntity, Integer> getCheckPlayers() {
|
|
|
|
return new HashMap<>(checkPlayers);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2024-08-29 16:28:46 -05:00
|
|
|
* a list of players that need a sit entity spawned for them, on the server loop to stop crashing with other mods (ASYNC)
|
2024-08-17 13:27:26 -05:00
|
|
|
*/
|
|
|
|
private static final HashMap<ServerPlayerEntity, DisplayEntity.TextDisplayEntity> spawnList = new HashMap<>();
|
|
|
|
|
|
|
|
public static void setSpawnList(ServerPlayerEntity player, DisplayEntity.TextDisplayEntity entity) {
|
|
|
|
spawnList.put(player, entity);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void removeSpawnList(ServerPlayerEntity player) {
|
|
|
|
spawnList.remove(player);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static HashMap<ServerPlayerEntity, DisplayEntity.TextDisplayEntity> getSpawnList() {
|
|
|
|
return new HashMap<>(spawnList);
|
|
|
|
}
|
2024-07-23 13:49:43 -05:00
|
|
|
}
|