2024-07-11 13:43:54 -05:00
|
|
|
package one.oth3r.sit.file;
|
|
|
|
|
|
|
|
import net.minecraft.server.network.ServerPlayerEntity;
|
2024-08-07 12:45:53 -05:00
|
|
|
import one.oth3r.sit.utl.Data;
|
|
|
|
import one.oth3r.sit.utl.Utl;
|
2024-07-11 13:43:54 -05:00
|
|
|
|
2024-08-07 12:45:53 -05:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Arrays;
|
2024-07-11 13:43:54 -05:00
|
|
|
import java.util.HashMap;
|
|
|
|
|
2024-07-23 12:27:01 -05:00
|
|
|
public class FileData {
|
2024-07-11 13:43:54 -05:00
|
|
|
/**
|
|
|
|
* Sit! config file
|
|
|
|
*/
|
|
|
|
private static ServerConfig serverConfig = new ServerConfig();
|
|
|
|
|
|
|
|
public static ServerConfig getServerConfig() {
|
2024-08-26 14:46:01 -05:00
|
|
|
return serverConfig;
|
2024-07-11 13:43:54 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
public static void setServerConfig(ServerConfig newServerConfig) {
|
|
|
|
serverConfig = new ServerConfig(newServerConfig);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2024-07-23 11:27:06 -05:00
|
|
|
* The default sitting config for all new players
|
2024-07-11 13:43:54 -05:00
|
|
|
*/
|
2024-07-23 11:27:06 -05:00
|
|
|
private static SittingConfig sittingConfig = new SittingConfig();
|
2024-07-11 13:43:54 -05:00
|
|
|
|
2024-07-23 11:27:06 -05:00
|
|
|
public static SittingConfig getSittingConfig() {
|
2024-08-26 14:46:01 -05:00
|
|
|
return sittingConfig;
|
2024-07-11 13:43:54 -05:00
|
|
|
}
|
|
|
|
|
2024-07-23 11:27:06 -05:00
|
|
|
public static void setSittingConfig(SittingConfig newSittingConfig) {
|
|
|
|
sittingConfig = new SittingConfig(newSittingConfig);
|
2024-07-11 13:43:54 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2024-07-23 11:27:06 -05:00
|
|
|
* the sitting config stored per player on the server
|
2024-07-11 13:43:54 -05:00
|
|
|
*/
|
2024-07-23 11:27:06 -05:00
|
|
|
private static final HashMap<ServerPlayerEntity, SittingConfig> playerSettings = new HashMap<>();
|
2024-07-11 13:43:54 -05:00
|
|
|
|
|
|
|
public static void clearPlayerSettings() {
|
|
|
|
playerSettings.clear();
|
|
|
|
}
|
|
|
|
|
2024-07-23 11:27:06 -05:00
|
|
|
public static void setPlayerSetting(ServerPlayerEntity player, SittingConfig config) {
|
2024-07-11 13:43:54 -05:00
|
|
|
playerSettings.put(player, config);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void removePlayerSetting(ServerPlayerEntity player) {
|
|
|
|
playerSettings.remove(player);
|
|
|
|
}
|
|
|
|
|
2024-07-23 11:27:06 -05:00
|
|
|
public static SittingConfig getPlayerSetting(ServerPlayerEntity player) {
|
|
|
|
return playerSettings.getOrDefault(player, sittingConfig);
|
2024-07-11 13:43:54 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* loads all config files to memory
|
|
|
|
*/
|
2024-08-26 14:46:01 -05:00
|
|
|
public static void loadFiles() {
|
|
|
|
getServerConfig().load();
|
|
|
|
|
|
|
|
getSittingConfig().load();
|
2024-08-07 12:45:24 -05:00
|
|
|
// if loading file and is on supported server on client, send the new settings over
|
|
|
|
if (Data.isClient() && Data.isSupportedServer()) {
|
|
|
|
Utl.sendSettingsPackets();
|
|
|
|
}
|
2024-07-11 13:43:54 -05:00
|
|
|
}
|
2024-08-07 12:45:53 -05:00
|
|
|
|
2024-12-02 12:51:43 -06:00
|
|
|
/**
|
|
|
|
* saves all config files
|
|
|
|
*/
|
|
|
|
public static void saveFiles() {
|
|
|
|
getSittingConfig().save();
|
|
|
|
getServerConfig().save();
|
|
|
|
}
|
|
|
|
|
2024-08-07 12:45:53 -05:00
|
|
|
public static class Defaults {
|
2024-09-20 22:24:17 -05:00
|
|
|
public static final ArrayList<SittingBlock> SITTING_BLOCKS = new ArrayList<>(Arrays.asList(
|
2024-09-28 17:55:02 -05:00
|
|
|
new SittingBlock(new ArrayList<>(),new ArrayList<>(Arrays.asList("#minecraft:campfires")), new ArrayList<>(Arrays.asList("lit=false")),.437),
|
|
|
|
new SittingBlock(new ArrayList<>(Arrays.asList("!minecraft:crimson_stem","!minecraft:warped_stem","minecraft:polished_basalt")), new ArrayList<>(Arrays.asList("#minecraft:logs","!#minecraft:oak_logs")), new ArrayList<>(Arrays.asList("!axis=y")),1.0),
|
|
|
|
new SittingBlock(new ArrayList<>(Arrays.asList()), new ArrayList<>(Arrays.asList("#minecraft:beds")), new ArrayList<>(Arrays.asList("part=foot","occupied=false")),.5625)
|
2024-08-07 12:45:53 -05:00
|
|
|
));
|
|
|
|
|
2024-10-19 17:40:59 -05:00
|
|
|
public static final ArrayList<CustomBlock> BLACKLISTED_BLOCKS = new ArrayList<>(Arrays.asList(
|
|
|
|
new CustomBlock(new ArrayList<>(),new ArrayList<>(Arrays.asList("#minecraft:shulker_boxes")),new ArrayList<>())
|
|
|
|
));
|
|
|
|
|
2024-12-02 12:52:53 -06:00
|
|
|
public static final ArrayList<CustomBlock> INTERACTION_BLOCKS = new ArrayList<>(Arrays.asList(
|
2024-12-15 12:09:01 -06:00
|
|
|
new CustomBlock(new ArrayList<>(Arrays.asList(
|
|
|
|
"minecraft:crafter","minecraft:repeating_command_block","minecraft:chain_command_block","minecraft:command_block")),
|
|
|
|
new ArrayList<>(Arrays.asList(
|
2024-12-02 12:52:53 -06:00
|
|
|
"#minecraft:shulker_boxes","#c:player_workstations/furnaces","#c:player_workstations/crafting_tables",
|
2024-12-15 12:09:01 -06:00
|
|
|
"#c:villager_job_sites","#minecraft:trapdoors","#c:chests")),
|
|
|
|
new ArrayList<>())
|
2024-12-02 12:52:53 -06:00
|
|
|
));
|
|
|
|
|
2024-08-07 12:45:53 -05:00
|
|
|
public static final HandSetting MAIN_HAND = new HandSetting(HandSetting.SittingRequirement.EMPTY, new HandSetting.Filter(
|
2024-11-10 11:18:42 -06:00
|
|
|
false,new HandSetting.Filter.Presets(),
|
|
|
|
new CustomItem(
|
|
|
|
new ArrayList<>(),
|
|
|
|
new ArrayList<>(Arrays.asList("#minecraft:bookshelf_books","!#minecraft:lectern_books")))));
|
2024-08-07 12:45:53 -05:00
|
|
|
|
|
|
|
public static final HandSetting OFF_HAND = new HandSetting(HandSetting.SittingRequirement.FILTER, new HandSetting.Filter(
|
2024-11-10 11:18:42 -06:00
|
|
|
false, new HandSetting.Filter.Presets(false, true, false),
|
|
|
|
new CustomItem(new ArrayList<>(Arrays.asList("minecraft:filled_map",
|
|
|
|
"minecraft:torch", "minecraft:soul_torch","minecraft:redstone_torch",
|
|
|
|
"minecraft:lantern", "minecraft:soul_lantern")),
|
|
|
|
new ArrayList<>())));
|
2024-08-07 12:45:53 -05:00
|
|
|
}
|
2024-07-11 13:43:54 -05:00
|
|
|
}
|