mirror of
https://github.com/Oth3r/Sit.git
synced 2025-09-19 07:53:22 +02:00
Compare commits
15 commits
9d6881d9f5
...
458333d347
Author | SHA1 | Date | |
---|---|---|---|
![]() |
458333d347 |
||
![]() |
1558f94a5d |
||
![]() |
360874357f |
||
![]() |
65f7f6f6e0 |
||
![]() |
9ac4cd5156 |
||
![]() |
91faaba5c8 |
||
![]() |
4f5acb76db |
||
![]() |
202d8ac171 |
||
![]() |
b52b96608d |
||
![]() |
ce9a88d56d |
||
![]() |
89536e3070 |
||
![]() |
1bb8409931 |
||
![]() |
e43273b172 |
||
![]() |
c7875aa9ea |
||
![]() |
65f0a77cfc |
11 changed files with 93 additions and 94 deletions
|
@ -52,7 +52,7 @@ With the new config system, block tags and custom blockstates can be used to mas
|
||||||

|

|
||||||
|
|
||||||
### ⌨️ Keybinds
|
### ⌨️ Keybinds
|
||||||
Don't want to sit with the **just** the hand? Use a keybind or type a command to sit instead!
|
Don't want to sit with **just** the hand? Use a keybind or type a command to sit instead!
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
plugins {
|
plugins {
|
||||||
id 'fabric-loom' version "1.10-SNAPSHOT"
|
id 'fabric-loom' version "1.11-SNAPSHOT"
|
||||||
id 'maven-publish'
|
id 'maven-publish'
|
||||||
id "me.modmuss50.mod-publish-plugin" version "0.8.4"
|
id "me.modmuss50.mod-publish-plugin" version "0.8.4"
|
||||||
id 'co.uzzu.dotenv.gradle' version '4.0.0'
|
id 'co.uzzu.dotenv.gradle' version '4.0.0'
|
||||||
|
|
30
changelog.md
30
changelog.md
|
@ -1,26 +1,6 @@
|
||||||
# v1.2.4.5
|
# v1.2.5.0
|
||||||
* bumped OtterLib version to `0.2.1.0`
|
New allowed-above-seat config option!
|
||||||
* fixed default languages files not being able to be loaded
|
|
||||||
|
|
||||||
# v1.2.4.4
|
* added new config option `allowed-above-seat` to allow certain blocks to be above the seat block
|
||||||
* bumped OtterLib version to `0.2.0.0`
|
* switched to OtterLib for language file loading
|
||||||
* now relies on OtterLib Language Reader
|
* switched to OtterLib for config file loading
|
||||||
|
|
||||||
# v1.2.4.3
|
|
||||||
* added a max OtterLib version as the beta will have breaking changes between major versions
|
|
||||||
|
|
||||||
# v1.2.4.2
|
|
||||||
* fixed language file not loading (reverted uppercase locales)
|
|
||||||
* fixed block checking having a hardcoded player reach - now uses player reach (1.20.6+)
|
|
||||||
* fixed block and item tag check logic for cases with only not(!) tags
|
|
||||||
|
|
||||||
# v1.2.4.1
|
|
||||||
* removed unused assets
|
|
||||||
* enabled file logging for easier debugging
|
|
||||||
|
|
||||||
# v1.2.4.0
|
|
||||||
Small changelog but big update!
|
|
||||||
\
|
|
||||||
Switching to OtterLib will allow for a simplified main mod and lead to more unified mod development across my projects! Download OtterLib today: [Link](https://modrinth.com/mod/otterlib)
|
|
||||||
* make sitting via hand execute the `/sit` command, to allow for universal sitting permission control
|
|
||||||
* switch to using OtterLib for file management, config screen management, and more to come
|
|
|
@ -4,23 +4,23 @@ org.gradle.parallel=true
|
||||||
|
|
||||||
# Fabric Properties
|
# Fabric Properties
|
||||||
# check these on https://fabricmc.net/develop
|
# check these on https://fabricmc.net/develop
|
||||||
min_minecraft_version=1.21.7
|
min_minecraft_version=1.21.6
|
||||||
max_minecraft_version=1.21.7
|
max_minecraft_version=1.21.8
|
||||||
minecraft_versions=1.21.7
|
minecraft_versions=1.21.6,1.21.7,1.21.8
|
||||||
|
|
||||||
minecraft_version=1.21.7
|
minecraft_version=1.21.8
|
||||||
yarn_mappings=1.21.7+build.1
|
yarn_mappings=1.21.8+build.1
|
||||||
loader_version=0.16.14
|
loader_version=0.16.14
|
||||||
|
|
||||||
# Mod Properties
|
# Mod Properties
|
||||||
mod_version=1.2.4.5+1.21.7
|
mod_version=1.2.5.0+1.21.8
|
||||||
maven_group=one.oth3r
|
maven_group=one.oth3r
|
||||||
file_name=sit!
|
file_name=sit!
|
||||||
|
|
||||||
# Dependencies
|
# Dependencies
|
||||||
fabric_version=0.128.1+1.21.7
|
fabric_version=0.129.0+1.21.8
|
||||||
otterlib_version=0.2.1.0+1.21.7-fabric
|
otterlib_version=0.2.2.0+1.21.8-fabric
|
||||||
otterlib_max_version=0.3.0.0+1.21.7-fabric
|
otterlib_max_version=0.3.0.0+1.21.8-fabric
|
||||||
|
|
||||||
modmenu_version=15.0.0-beta.1
|
modmenu_version=15.0.0-beta.1
|
||||||
devauth_version=1.2.1
|
devauth_version=1.2.1
|
||||||
|
|
|
@ -2,13 +2,31 @@ package one.oth3r.sit;
|
||||||
|
|
||||||
import net.fabricmc.api.ModInitializer;
|
import net.fabricmc.api.ModInitializer;
|
||||||
|
|
||||||
|
import one.oth3r.otterlib.file.LanguageReader;
|
||||||
|
import one.oth3r.otterlib.file.ResourceReader;
|
||||||
|
import one.oth3r.otterlib.registry.CustomFileReg;
|
||||||
|
import one.oth3r.otterlib.registry.LanguageReg;
|
||||||
import one.oth3r.sit.file.FileData;
|
import one.oth3r.sit.file.FileData;
|
||||||
|
import one.oth3r.sit.file.ServerConfig;
|
||||||
|
import one.oth3r.sit.file.SittingConfig;
|
||||||
|
import one.oth3r.sit.utl.Data;
|
||||||
import one.oth3r.sit.utl.Events;
|
import one.oth3r.sit.utl.Events;
|
||||||
|
|
||||||
public class Sit implements ModInitializer {
|
public class Sit implements ModInitializer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInitialize() {
|
public void onInitialize() {
|
||||||
|
LanguageReg.registerLang(Data.MOD_ID, new LanguageReader(
|
||||||
|
new ResourceReader("assets/sit-oth3r/lang/",Sit.class.getClassLoader()),
|
||||||
|
new ResourceReader(Data.CONFIG_DIR),"en_us","en_us"));
|
||||||
|
|
||||||
|
/// autoload is off, we will handle loading and saving manually
|
||||||
|
CustomFileReg.registerFile(Data.MOD_ID,new CustomFileReg.FileEntry(
|
||||||
|
ServerConfig.ID,new ServerConfig(),false,false));
|
||||||
|
CustomFileReg.registerFile(Data.MOD_ID,new CustomFileReg.FileEntry(
|
||||||
|
SittingConfig.ID,new SittingConfig(),false,false));
|
||||||
|
|
||||||
|
|
||||||
FileData.loadFiles();
|
FileData.loadFiles();
|
||||||
// save the files to populate all missing config options
|
// save the files to populate all missing config options
|
||||||
FileData.saveFiles();
|
FileData.saveFiles();
|
||||||
|
|
|
@ -1,41 +1,23 @@
|
||||||
package one.oth3r.sit.file;
|
package one.oth3r.sit.file;
|
||||||
|
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
import one.oth3r.otterlib.file.LanguageReader;
|
import one.oth3r.otterlib.registry.CustomFileReg;
|
||||||
import one.oth3r.otterlib.file.ResourceReader;
|
|
||||||
import one.oth3r.sit.Sit;
|
|
||||||
import one.oth3r.sit.utl.Data;
|
import one.oth3r.sit.utl.Data;
|
||||||
import one.oth3r.sit.utl.Utl;
|
import one.oth3r.sit.utl.Utl;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class FileData {
|
public class FileData {
|
||||||
/**
|
/// getters for Sit! config files
|
||||||
* Sit! config file
|
|
||||||
*/
|
|
||||||
private static ServerConfig serverConfig = new ServerConfig();
|
|
||||||
|
|
||||||
public static ServerConfig getServerConfig() {
|
public static ServerConfig getServerConfig() {
|
||||||
return serverConfig;
|
return (ServerConfig) CustomFileReg.getFile(Data.MOD_ID,ServerConfig.ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setServerConfig(ServerConfig newServerConfig) {
|
|
||||||
serverConfig = new ServerConfig(newServerConfig);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The default sitting config for all new players
|
|
||||||
*/
|
|
||||||
private static SittingConfig sittingConfig = new SittingConfig();
|
|
||||||
|
|
||||||
public static SittingConfig getSittingConfig() {
|
public static SittingConfig getSittingConfig() {
|
||||||
return sittingConfig;
|
return (SittingConfig) CustomFileReg.getFile(Data.MOD_ID,SittingConfig.ID);
|
||||||
}
|
|
||||||
|
|
||||||
public static void setSittingConfig(SittingConfig newSittingConfig) {
|
|
||||||
sittingConfig = new SittingConfig(newSittingConfig);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -56,16 +38,7 @@ public class FileData {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SittingConfig getPlayerSetting(ServerPlayerEntity player) {
|
public static SittingConfig getPlayerSetting(ServerPlayerEntity player) {
|
||||||
return playerSettings.getOrDefault(player, sittingConfig);
|
return playerSettings.getOrDefault(player, getSittingConfig());
|
||||||
}
|
|
||||||
|
|
||||||
/// the language / text system for the mod
|
|
||||||
private static final LanguageReader langReader = new LanguageReader(
|
|
||||||
new ResourceReader("assets/sit-oth3r/lang/",Sit.class.getClassLoader()),
|
|
||||||
new ResourceReader(Data.CONFIG_DIR),"en_us","en_us");
|
|
||||||
|
|
||||||
public static LanguageReader getLangReader() {
|
|
||||||
return langReader;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -73,9 +46,6 @@ public class FileData {
|
||||||
*/
|
*/
|
||||||
public static void loadFiles() {
|
public static void loadFiles() {
|
||||||
getServerConfig().load();
|
getServerConfig().load();
|
||||||
// load the language reader
|
|
||||||
langReader.updateLanguage(getServerConfig().getLang());
|
|
||||||
|
|
||||||
getSittingConfig().load();
|
getSittingConfig().load();
|
||||||
// if loading file and is on supported server on client, send the new settings over
|
// if loading file and is on supported server on client, send the new settings over
|
||||||
if (Data.isClient() && Data.isSupportedServer()) {
|
if (Data.isClient() && Data.isSupportedServer()) {
|
||||||
|
@ -95,22 +65,34 @@ public class FileData {
|
||||||
public static final ArrayList<SittingBlock> SITTING_BLOCKS = new ArrayList<>(Arrays.asList(
|
public static final ArrayList<SittingBlock> SITTING_BLOCKS = new ArrayList<>(Arrays.asList(
|
||||||
new SittingBlock(new ArrayList<>(),new ArrayList<>(Arrays.asList("#minecraft:campfires")), new ArrayList<>(Arrays.asList("lit=false")),.437),
|
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("!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)
|
new SittingBlock(new ArrayList<>(), new ArrayList<>(Arrays.asList("#minecraft:beds")), new ArrayList<>(Arrays.asList("part=foot","occupied=false")),.5625)
|
||||||
));
|
));
|
||||||
|
|
||||||
public static final ArrayList<CustomBlock> BLACKLISTED_BLOCKS = new ArrayList<>(Arrays.asList(
|
public static final ArrayList<CustomBlock> BLACKLISTED_BLOCKS = new ArrayList<>(List.of(
|
||||||
new CustomBlock(new ArrayList<>(),new ArrayList<>(Arrays.asList("#minecraft:shulker_boxes")),new ArrayList<>())
|
new CustomBlock(new ArrayList<>(), new ArrayList<>(List.of("#minecraft:shulker_boxes")), new ArrayList<>())
|
||||||
));
|
));
|
||||||
|
|
||||||
public static final ArrayList<CustomBlock> INTERACTION_BLOCKS = new ArrayList<>(Arrays.asList(
|
public static final ArrayList<CustomBlock> INTERACTION_BLOCKS = new ArrayList<>(List.of(
|
||||||
new CustomBlock(new ArrayList<>(Arrays.asList(
|
new CustomBlock(new ArrayList<>(Arrays.asList(
|
||||||
"minecraft:crafter","minecraft:repeating_command_block","minecraft:chain_command_block","minecraft:command_block")),
|
"minecraft:crafter", "minecraft:repeating_command_block", "minecraft:chain_command_block", "minecraft:command_block")),
|
||||||
new ArrayList<>(Arrays.asList(
|
new ArrayList<>(Arrays.asList(
|
||||||
"#minecraft:shulker_boxes","#c:player_workstations/furnaces","#c:player_workstations/crafting_tables",
|
"#minecraft:shulker_boxes", "#c:player_workstations/furnaces", "#c:player_workstations/crafting_tables",
|
||||||
"#c:villager_job_sites","#minecraft:trapdoors","#c:chests")),
|
"#c:villager_job_sites", "#minecraft:trapdoors", "#c:chests")),
|
||||||
new ArrayList<>())
|
new ArrayList<>())
|
||||||
));
|
));
|
||||||
|
|
||||||
|
public static final ArrayList<CustomBlock> ALLOWED_ABOVE_SEAT = new ArrayList<>(List.of(
|
||||||
|
new CustomBlock(
|
||||||
|
new ArrayList<>(),
|
||||||
|
new ArrayList<>(List.of("#minecraft:trapdoors")),
|
||||||
|
new ArrayList<>(List.of("open=true"))),
|
||||||
|
new CustomBlock(
|
||||||
|
new ArrayList<>(),
|
||||||
|
new ArrayList<>(List.of("#minecraft:doors")),
|
||||||
|
new ArrayList<>()
|
||||||
|
)
|
||||||
|
));
|
||||||
|
|
||||||
public static final HandSetting MAIN_HAND = new HandSetting(HandSetting.SittingRequirement.EMPTY, new HandSetting.Filter(
|
public static final HandSetting MAIN_HAND = new HandSetting(HandSetting.SittingRequirement.EMPTY, new HandSetting.Filter(
|
||||||
false,new HandSetting.Filter.Presets(),
|
false,new HandSetting.Filter.Presets(),
|
||||||
new CustomItem(
|
new CustomItem(
|
||||||
|
|
|
@ -8,6 +8,7 @@ import net.minecraft.util.Hand;
|
||||||
import one.oth3r.otterlib.base.Num;
|
import one.oth3r.otterlib.base.Num;
|
||||||
import one.oth3r.otterlib.file.CustomFile;
|
import one.oth3r.otterlib.file.CustomFile;
|
||||||
import one.oth3r.otterlib.file.FileSettings;
|
import one.oth3r.otterlib.file.FileSettings;
|
||||||
|
import one.oth3r.otterlib.registry.LanguageReg;
|
||||||
import one.oth3r.sit.utl.Data;
|
import one.oth3r.sit.utl.Data;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
@ -24,6 +25,7 @@ import java.util.Properties;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class ServerConfig implements CustomFile<ServerConfig> {
|
public class ServerConfig implements CustomFile<ServerConfig> {
|
||||||
|
public static final String ID = "server-config";
|
||||||
|
|
||||||
@SerializedName("version")
|
@SerializedName("version")
|
||||||
private Double version = 2.3;
|
private Double version = 2.3;
|
||||||
|
@ -52,6 +54,8 @@ public class ServerConfig implements CustomFile<ServerConfig> {
|
||||||
private ArrayList<CustomBlock> blacklistedBlocks = FileData.Defaults.BLACKLISTED_BLOCKS;
|
private ArrayList<CustomBlock> blacklistedBlocks = FileData.Defaults.BLACKLISTED_BLOCKS;
|
||||||
@SerializedName("interaction-blocks")
|
@SerializedName("interaction-blocks")
|
||||||
private ArrayList<CustomBlock> interactionBlocks = FileData.Defaults.INTERACTION_BLOCKS;
|
private ArrayList<CustomBlock> interactionBlocks = FileData.Defaults.INTERACTION_BLOCKS;
|
||||||
|
@SerializedName("allowed-above-seat")
|
||||||
|
private ArrayList<CustomBlock> allowedAboveSeat = FileData.Defaults.ALLOWED_ABOVE_SEAT;
|
||||||
|
|
||||||
public ServerConfig() {}
|
public ServerConfig() {}
|
||||||
|
|
||||||
|
@ -62,7 +66,7 @@ public class ServerConfig implements CustomFile<ServerConfig> {
|
||||||
public ServerConfig(Double version, String lang, boolean keepActive, boolean sitWhileSeated,
|
public ServerConfig(Double version, String lang, boolean keepActive, boolean sitWhileSeated,
|
||||||
PresetBlocks presetBlocks, boolean customEnabled,
|
PresetBlocks presetBlocks, boolean customEnabled,
|
||||||
ArrayList<SittingBlock> sittingBlocks, ArrayList<CustomBlock> blacklistedBlocks,
|
ArrayList<SittingBlock> sittingBlocks, ArrayList<CustomBlock> blacklistedBlocks,
|
||||||
ArrayList<CustomBlock> interactionBlocks) {
|
ArrayList<CustomBlock> interactionBlocks, ArrayList<CustomBlock> allowedAboveSeat) {
|
||||||
this.version = version;
|
this.version = version;
|
||||||
this.lang = lang;
|
this.lang = lang;
|
||||||
this.keepActive = keepActive;
|
this.keepActive = keepActive;
|
||||||
|
@ -72,6 +76,7 @@ public class ServerConfig implements CustomFile<ServerConfig> {
|
||||||
this.sittingBlocks = sittingBlocks;
|
this.sittingBlocks = sittingBlocks;
|
||||||
this.blacklistedBlocks = blacklistedBlocks;
|
this.blacklistedBlocks = blacklistedBlocks;
|
||||||
this.interactionBlocks = interactionBlocks;
|
this.interactionBlocks = interactionBlocks;
|
||||||
|
this.allowedAboveSeat = allowedAboveSeat;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Double getVersion() {
|
public Double getVersion() {
|
||||||
|
@ -114,6 +119,10 @@ public class ServerConfig implements CustomFile<ServerConfig> {
|
||||||
return interactionBlocks;
|
return interactionBlocks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ArrayList<CustomBlock> getAllowedAboveSeat() {
|
||||||
|
return allowedAboveSeat;
|
||||||
|
}
|
||||||
|
|
||||||
public static class PresetBlocks {
|
public static class PresetBlocks {
|
||||||
|
|
||||||
@SerializedName("stairs")
|
@SerializedName("stairs")
|
||||||
|
@ -261,6 +270,7 @@ public class ServerConfig implements CustomFile<ServerConfig> {
|
||||||
this.sittingBlocks = newFile.sittingBlocks.stream().map(SittingBlock::new).collect(Collectors.toCollection(ArrayList::new));
|
this.sittingBlocks = newFile.sittingBlocks.stream().map(SittingBlock::new).collect(Collectors.toCollection(ArrayList::new));
|
||||||
this.blacklistedBlocks = newFile.blacklistedBlocks.stream().map(CustomBlock::new).collect(Collectors.toCollection(ArrayList::new));
|
this.blacklistedBlocks = newFile.blacklistedBlocks.stream().map(CustomBlock::new).collect(Collectors.toCollection(ArrayList::new));
|
||||||
this.interactionBlocks = newFile.interactionBlocks.stream().map(CustomBlock::new).collect(Collectors.toCollection(ArrayList::new));
|
this.interactionBlocks = newFile.interactionBlocks.stream().map(CustomBlock::new).collect(Collectors.toCollection(ArrayList::new));
|
||||||
|
this.allowedAboveSeat = newFile.allowedAboveSeat.stream().map(CustomBlock::new).collect(Collectors.toCollection(ArrayList::new));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -275,6 +285,9 @@ public class ServerConfig implements CustomFile<ServerConfig> {
|
||||||
version = 2.3;
|
version = 2.3;
|
||||||
this.lang = this.lang.substring(0,3)+this.lang.substring(3).toLowerCase();
|
this.lang = this.lang.substring(0,3)+this.lang.substring(3).toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// update the language reader
|
||||||
|
LanguageReg.getLang(Data.MOD_ID).updateLanguage(lang);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -298,14 +311,17 @@ public class ServerConfig implements CustomFile<ServerConfig> {
|
||||||
public boolean equals(Object o) {
|
public boolean equals(Object o) {
|
||||||
if (o == null || getClass() != o.getClass()) return false;
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
ServerConfig that = (ServerConfig) o;
|
ServerConfig that = (ServerConfig) o;
|
||||||
return Objects.equals(version, that.version) && Objects.equals(lang, that.lang) && Objects.equals(keepActive, that.keepActive) && Objects.equals(sitWhileSeated, that.sitWhileSeated) && Objects.equals(presetBlocks, that.presetBlocks) && Objects.equals(yDifferenceLimit, that.yDifferenceLimit) && Objects.equals(customEnabled, that.customEnabled) && Objects.equals(sittingBlocks, that.sittingBlocks) && Objects.equals(blacklistedBlocks, that.blacklistedBlocks) && Objects.equals(interactionBlocks, that.interactionBlocks);
|
return Objects.equals(version, that.version) && Objects.equals(lang, that.lang) && Objects.equals(keepActive, that.keepActive) && Objects.equals(sitWhileSeated, that.sitWhileSeated) && Objects.equals(presetBlocks, that.presetBlocks) && Objects.equals(yDifferenceLimit, that.yDifferenceLimit) && Objects.equals(customEnabled, that.customEnabled) && Objects.equals(sittingBlocks, that.sittingBlocks) && Objects.equals(blacklistedBlocks, that.blacklistedBlocks) && Objects.equals(interactionBlocks, that.interactionBlocks) && Objects.equals(allowedAboveSeat, that.allowedAboveSeat);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hash(version, lang, langOptions, keepActive, sitWhileSeated, presetBlocks, yDifferenceLimit, customEnabled, sittingBlocks, blacklistedBlocks, interactionBlocks);
|
return Objects.hash(version, lang, langOptions, keepActive, sitWhileSeated, presetBlocks, yDifferenceLimit, customEnabled, sittingBlocks, blacklistedBlocks, interactionBlocks, allowedAboveSeat);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* legacy updater
|
||||||
|
*/
|
||||||
protected static class Legacy {
|
protected static class Legacy {
|
||||||
/**
|
/**
|
||||||
* gets the legacy file, from the old directory for fabric, and the same one for spigot
|
* gets the legacy file, from the old directory for fabric, and the same one for spigot
|
||||||
|
@ -345,6 +361,8 @@ public class ServerConfig implements CustomFile<ServerConfig> {
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Data.LOGGER.error("Failed to delete the old Sit! config.");
|
Data.LOGGER.error("Failed to delete the old Sit! config.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// continue loading as normal...
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -414,7 +432,7 @@ public class ServerConfig implements CustomFile<ServerConfig> {
|
||||||
Boolean.parseBoolean((String) properties.computeIfAbsent("custom", a -> String.valueOf(defaultConfig.isCustomEnabled()))),
|
Boolean.parseBoolean((String) properties.computeIfAbsent("custom", a -> String.valueOf(defaultConfig.isCustomEnabled()))),
|
||||||
getCustomBlocks(new Gson().fromJson((String)
|
getCustomBlocks(new Gson().fromJson((String)
|
||||||
properties.computeIfAbsent("custom-blocks", a -> "[]"), listType)),
|
properties.computeIfAbsent("custom-blocks", a -> "[]"), listType)),
|
||||||
new ArrayList<>(), FileData.Defaults.INTERACTION_BLOCKS
|
new ArrayList<>(), FileData.Defaults.INTERACTION_BLOCKS, FileData.Defaults.ALLOWED_ABOVE_SEAT
|
||||||
);
|
);
|
||||||
|
|
||||||
SittingConfig defaultSittingConfig = new SittingConfig();
|
SittingConfig defaultSittingConfig = new SittingConfig();
|
||||||
|
@ -492,10 +510,12 @@ public class ServerConfig implements CustomFile<ServerConfig> {
|
||||||
} catch (JsonSyntaxException ignored) {}
|
} catch (JsonSyntaxException ignored) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
FileData.setServerConfig(serverConfig);
|
// update and save the new files
|
||||||
FileData.setSittingConfig(sittingConfig);
|
FileData.getServerConfig().copyFileData(serverConfig);
|
||||||
serverConfig.save();
|
FileData.getServerConfig().save();
|
||||||
sittingConfig.save();
|
|
||||||
|
FileData.getSittingConfig().copyFileData(sittingConfig);
|
||||||
|
FileData.getSittingConfig().save();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Data.LOGGER.error("Error loading legacy config: %s", e.getMessage());
|
Data.LOGGER.error("Error loading legacy config: %s", e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package one.oth3r.sit.file;
|
package one.oth3r.sit.file;
|
||||||
|
|
||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
import com.google.gson.JsonElement;
|
|
||||||
import com.google.gson.annotations.SerializedName;
|
import com.google.gson.annotations.SerializedName;
|
||||||
import net.minecraft.util.Hand;
|
import net.minecraft.util.Hand;
|
||||||
import one.oth3r.otterlib.file.CustomFile;
|
import one.oth3r.otterlib.file.CustomFile;
|
||||||
|
@ -13,6 +12,7 @@ import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
|
|
||||||
public class SittingConfig implements CustomFile<SittingConfig> {
|
public class SittingConfig implements CustomFile<SittingConfig> {
|
||||||
|
public static final String ID = "sitting-config";
|
||||||
|
|
||||||
@SerializedName("version")
|
@SerializedName("version")
|
||||||
private Double version = 1.0;
|
private Double version = 1.0;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package one.oth3r.sit.utl;
|
package one.oth3r.sit.utl;
|
||||||
|
|
||||||
import one.oth3r.otterlib.chat.CTxT;
|
import one.oth3r.otterlib.chat.CTxT;
|
||||||
import one.oth3r.sit.file.FileData;
|
import one.oth3r.otterlib.registry.LanguageReg;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
|
||||||
|
@ -11,6 +11,6 @@ public class Chat {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CTxT lang(String key, Object... args) {
|
public static CTxT lang(String key, Object... args) {
|
||||||
return FileData.getLangReader().dynamicTranslatable(key, args);
|
return LanguageReg.getLang(Data.MOD_ID).dynamicTranslatable(key, args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -204,7 +204,7 @@ public class Logic {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* toggles the sit ablity config option
|
* toggles the sit ability config option
|
||||||
* @return returns a message, that can be sent to the player
|
* @return returns a message, that can be sent to the player
|
||||||
*/
|
*/
|
||||||
public static MutableText toggleSiting() {
|
public static MutableText toggleSiting() {
|
||||||
|
@ -213,9 +213,6 @@ public class Logic {
|
||||||
SittingConfig config = FileData.getSittingConfig();
|
SittingConfig config = FileData.getSittingConfig();
|
||||||
// toggle the setting
|
// toggle the setting
|
||||||
config.setEnabled(!config.getEnabled());
|
config.setEnabled(!config.getEnabled());
|
||||||
|
|
||||||
// set the sitting config to the new value
|
|
||||||
FileData.setSittingConfig(config);
|
|
||||||
// save the changes to the file
|
// save the changes to the file
|
||||||
config.save();
|
config.save();
|
||||||
// send the changes to the server
|
// send the changes to the server
|
||||||
|
|
|
@ -49,6 +49,8 @@ public class Utl {
|
||||||
public static boolean isNotObstructed(World world, BlockPos blockPos) {
|
public static boolean isNotObstructed(World world, BlockPos blockPos) {
|
||||||
// get the block state at the blockPos
|
// get the block state at the blockPos
|
||||||
BlockState state = world.getBlockState(blockPos);
|
BlockState state = world.getBlockState(blockPos);
|
||||||
|
// if block is allowed to be above seat, return true
|
||||||
|
if (blockIsInList(FileData.getServerConfig().getAllowedAboveSeat(), state)) return true;
|
||||||
// make sure it doesn't have a collision
|
// make sure it doesn't have a collision
|
||||||
return state.getCollisionShape(world,blockPos).isEmpty();
|
return state.getCollisionShape(world,blockPos).isEmpty();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue