mirror of
https://github.com/Oth3r/Sit.git
synced 2025-09-20 00:13:21 +02:00
config to file package, and capitalize
This commit is contained in:
parent
8b78bf4651
commit
132c9dc55a
6 changed files with 46 additions and 44 deletions
|
@ -72,7 +72,7 @@ public class Events {
|
||||||
// get a hashmap of custom blocks
|
// get a hashmap of custom blocks
|
||||||
HashMap<String,HashMap<String,Object>> map = new HashMap<>();
|
HashMap<String,HashMap<String,Object>> map = new HashMap<>();
|
||||||
int i = 1;
|
int i = 1;
|
||||||
for (String s:config.customBlocks) {
|
for (String s: Config.customBlocks) {
|
||||||
String[] split = s.split("\\|");
|
String[] split = s.split("\\|");
|
||||||
HashMap<String,Object> data = new HashMap<>();
|
HashMap<String,Object> data = new HashMap<>();
|
||||||
data.put("block",split[0]);
|
data.put("block",split[0]);
|
||||||
|
@ -100,12 +100,12 @@ public class Events {
|
||||||
for (Entity entity:entities.values()) if (entity.getBlockPos().equals(pos) || entity.getBlockPos().add(0,1,0).equals(pos)) return false;
|
for (Entity entity:entities.values()) if (entity.getBlockPos().equals(pos) || entity.getBlockPos().add(0,1,0).equals(pos)) return false;
|
||||||
|
|
||||||
// return for the 4 default types
|
// return for the 4 default types
|
||||||
if (block instanceof StairsBlock && config.stairsOn) return blockState.get(StairsBlock.HALF) == BlockHalf.BOTTOM;
|
if (block instanceof StairsBlock && Config.stairsOn) return blockState.get(StairsBlock.HALF) == BlockHalf.BOTTOM;
|
||||||
if (block instanceof SlabBlock && config.slabsOn) return blockState.get(SlabBlock.TYPE) == SlabType.BOTTOM;
|
if (block instanceof SlabBlock && Config.slabsOn) return blockState.get(SlabBlock.TYPE) == SlabType.BOTTOM;
|
||||||
if (block instanceof CarpetBlock && config.carpetsOn) return true;
|
if (block instanceof CarpetBlock && Config.carpetsOn) return true;
|
||||||
if (blockState.isFullCube(world,pos.add(0,1,0)) && config.fullBlocksOn) return true;
|
if (blockState.isFullCube(world,pos.add(0,1,0)) && Config.fullBlocksOn) return true;
|
||||||
// custom checker
|
// custom checker
|
||||||
if (config.customOn && config.customBlocks.size() != 0) {
|
if (Config.customOn && Config.customBlocks.size() != 0) {
|
||||||
for (HashMap<String,Object> map:getCustomBlocks().values()) {
|
for (HashMap<String,Object> map:getCustomBlocks().values()) {
|
||||||
String blockID = Registries.BLOCK.getId(block).toString();
|
String blockID = Registries.BLOCK.getId(block).toString();
|
||||||
if (map.get("block").equals(blockID)) {
|
if (map.get("block").equals(blockID)) {
|
||||||
|
@ -149,7 +149,7 @@ public class Events {
|
||||||
entity.updatePositionAndAngles(pos.getX() + 0.5, pos.getY()+.78, pos.getZ() + 0.5, 0, 0);
|
entity.updatePositionAndAngles(pos.getX() + 0.5, pos.getY()+.78, pos.getZ() + 0.5, 0, 0);
|
||||||
hitBoxY = 2;
|
hitBoxY = 2;
|
||||||
}
|
}
|
||||||
if (config.customOn && config.customBlocks.size() != 0) {
|
if (Config.customOn && !Config.customBlocks.isEmpty()) {
|
||||||
for (HashMap<String,Object> map:getCustomBlocks().values()) {
|
for (HashMap<String,Object> map:getCustomBlocks().values()) {
|
||||||
String blockID = Registries.BLOCK.getId(block).toString();
|
String blockID = Registries.BLOCK.getId(block).toString();
|
||||||
if (map.get("block").equals(blockID)) {
|
if (map.get("block").equals(blockID)) {
|
||||||
|
@ -174,7 +174,7 @@ public class Events {
|
||||||
setEntity(pos,world,entity);
|
setEntity(pos,world,entity);
|
||||||
if (checkBlocks(pos,world,isAboveBlockheight(entity))) {
|
if (checkBlocks(pos,world,isAboveBlockheight(entity))) {
|
||||||
if (entities.containsKey(player)) {
|
if (entities.containsKey(player)) {
|
||||||
if (!config.sitWhileSeated) return false;
|
if (!Config.sitWhileSeated) return false;
|
||||||
entities.get(player).setRemoved(Entity.RemovalReason.DISCARDED);
|
entities.get(player).setRemoved(Entity.RemovalReason.DISCARDED);
|
||||||
entities.remove(player);
|
entities.remove(player);
|
||||||
}
|
}
|
||||||
|
@ -197,7 +197,7 @@ public class Events {
|
||||||
ServerPlayConnectionEvents.DISCONNECT.register((handler, server) -> {
|
ServerPlayConnectionEvents.DISCONNECT.register((handler, server) -> {
|
||||||
ServerPlayerEntity player = handler.player;
|
ServerPlayerEntity player = handler.player;
|
||||||
if (entities.containsKey(player)) {
|
if (entities.containsKey(player)) {
|
||||||
if (!config.keepActive) {
|
if (!Config.keepActive) {
|
||||||
player.dismountVehicle();
|
player.dismountVehicle();
|
||||||
entities.get(player).setRemoved(Entity.RemovalReason.DISCARDED);
|
entities.get(player).setRemoved(Entity.RemovalReason.DISCARDED);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import com.google.gson.Gson;
|
||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
import net.minecraft.text.MutableText;
|
import net.minecraft.text.MutableText;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
|
import one.oth3r.sit.file.Config;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
|
@ -77,10 +78,10 @@ public class LangReader {
|
||||||
public static void loadLanguageFile() {
|
public static void loadLanguageFile() {
|
||||||
try {
|
try {
|
||||||
ClassLoader classLoader = Sit.class.getClassLoader();
|
ClassLoader classLoader = Sit.class.getClassLoader();
|
||||||
InputStream inputStream = classLoader.getResourceAsStream("assets/sit/lang/"+ config.lang+".json");
|
InputStream inputStream = classLoader.getResourceAsStream("assets/sit/lang/"+ Config.lang+".json");
|
||||||
if (inputStream == null) {
|
if (inputStream == null) {
|
||||||
inputStream = classLoader.getResourceAsStream("assets/sit/lang/"+config.defaults.lang+".json");
|
inputStream = classLoader.getResourceAsStream("assets/sit/lang/"+ Config.defaults.lang+".json");
|
||||||
config.lang = config.defaults.lang;
|
Config.lang = Config.defaults.lang;
|
||||||
}
|
}
|
||||||
if (inputStream == null) throw new IllegalArgumentException("CANT LOAD THE LANGUAGE FILE. DIRECTIONHUD WILL BREAK.");
|
if (inputStream == null) throw new IllegalArgumentException("CANT LOAD THE LANGUAGE FILE. DIRECTIONHUD WILL BREAK.");
|
||||||
Type type = new TypeToken<Map<String, String>>(){}.getType();
|
Type type = new TypeToken<Map<String, String>>(){}.getType();
|
||||||
|
|
|
@ -10,6 +10,7 @@ import net.minecraft.text.MutableText;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
import net.minecraft.text.TextColor;
|
import net.minecraft.text.TextColor;
|
||||||
import net.minecraft.util.Formatting;
|
import net.minecraft.util.Formatting;
|
||||||
|
import one.oth3r.sit.file.Config;
|
||||||
|
|
||||||
public class ModMenu implements ModMenuApi {
|
public class ModMenu implements ModMenuApi {
|
||||||
private static MutableText lang(String key) {
|
private static MutableText lang(String key) {
|
||||||
|
@ -20,7 +21,7 @@ public class ModMenu implements ModMenuApi {
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public ConfigScreenFactory<?> getModConfigScreenFactory() {
|
public ConfigScreenFactory<?> getModConfigScreenFactory() {
|
||||||
return parent -> YetAnotherConfigLib.createBuilder().save(config::save)
|
return parent -> YetAnotherConfigLib.createBuilder().save(Config::save)
|
||||||
.title(Text.of("Sit!"))
|
.title(Text.of("Sit!"))
|
||||||
.category(ConfigCategory.createBuilder()
|
.category(ConfigCategory.createBuilder()
|
||||||
.name(lang("category.general"))
|
.name(lang("category.general"))
|
||||||
|
@ -28,13 +29,13 @@ public class ModMenu implements ModMenuApi {
|
||||||
.option(Option.<Boolean>createBuilder()
|
.option(Option.<Boolean>createBuilder()
|
||||||
.name(lang("general.keep_active"))
|
.name(lang("general.keep_active"))
|
||||||
.description(OptionDescription.of(lang("general.keep_active.description")))
|
.description(OptionDescription.of(lang("general.keep_active.description")))
|
||||||
.binding(config.defaults.keepActive, () -> config.keepActive, n -> config.keepActive = n)
|
.binding(Config.defaults.keepActive, () -> Config.keepActive, n -> Config.keepActive = n)
|
||||||
.controller(opt -> BooleanControllerBuilder.create(opt).trueFalseFormatter())
|
.controller(opt -> BooleanControllerBuilder.create(opt).trueFalseFormatter())
|
||||||
.build())
|
.build())
|
||||||
.option(Option.<Boolean>createBuilder()
|
.option(Option.<Boolean>createBuilder()
|
||||||
.name(lang("general.sit_while_seated"))
|
.name(lang("general.sit_while_seated"))
|
||||||
.description(OptionDescription.of(lang("general.sit_while_seated.description")))
|
.description(OptionDescription.of(lang("general.sit_while_seated.description")))
|
||||||
.binding(config.defaults.sitWhileSeated, () -> config.sitWhileSeated, n -> config.sitWhileSeated = n)
|
.binding(Config.defaults.sitWhileSeated, () -> Config.sitWhileSeated, n -> Config.sitWhileSeated = n)
|
||||||
.controller(opt -> BooleanControllerBuilder.create(opt).trueFalseFormatter())
|
.controller(opt -> BooleanControllerBuilder.create(opt).trueFalseFormatter())
|
||||||
.build())
|
.build())
|
||||||
.group(OptionGroup.createBuilder()
|
.group(OptionGroup.createBuilder()
|
||||||
|
@ -42,28 +43,28 @@ public class ModMenu implements ModMenuApi {
|
||||||
.description(OptionDescription.of(lang("general.sittable.description")))
|
.description(OptionDescription.of(lang("general.sittable.description")))
|
||||||
.option(Option.<Boolean>createBuilder()
|
.option(Option.<Boolean>createBuilder()
|
||||||
.name(lang("general.sittable.stairs"))
|
.name(lang("general.sittable.stairs"))
|
||||||
.binding(config.defaults.stairsOn, () -> config.stairsOn, n -> config.stairsOn = n)
|
.binding(Config.defaults.stairsOn, () -> Config.stairsOn, n -> Config.stairsOn = n)
|
||||||
.controller(opt -> BooleanControllerBuilder.create(opt).onOffFormatter())
|
.controller(opt -> BooleanControllerBuilder.create(opt).onOffFormatter())
|
||||||
.build())
|
.build())
|
||||||
.option(Option.<Boolean>createBuilder()
|
.option(Option.<Boolean>createBuilder()
|
||||||
.name(lang("general.sittable.slabs"))
|
.name(lang("general.sittable.slabs"))
|
||||||
.binding(config.defaults.slabsOn, () -> config.slabsOn, n -> config.slabsOn = n)
|
.binding(Config.defaults.slabsOn, () -> Config.slabsOn, n -> Config.slabsOn = n)
|
||||||
.controller(opt -> BooleanControllerBuilder.create(opt).onOffFormatter())
|
.controller(opt -> BooleanControllerBuilder.create(opt).onOffFormatter())
|
||||||
.build())
|
.build())
|
||||||
.option(Option.<Boolean>createBuilder()
|
.option(Option.<Boolean>createBuilder()
|
||||||
.name(lang("general.sittable.carpets"))
|
.name(lang("general.sittable.carpets"))
|
||||||
.binding(config.defaults.carpetsOn, () -> config.carpetsOn, n -> config.carpetsOn = n)
|
.binding(Config.defaults.carpetsOn, () -> Config.carpetsOn, n -> Config.carpetsOn = n)
|
||||||
.controller(opt -> BooleanControllerBuilder.create(opt).onOffFormatter())
|
.controller(opt -> BooleanControllerBuilder.create(opt).onOffFormatter())
|
||||||
.build())
|
.build())
|
||||||
.option(Option.<Boolean>createBuilder()
|
.option(Option.<Boolean>createBuilder()
|
||||||
.name(lang("general.sittable.full_blocks"))
|
.name(lang("general.sittable.full_blocks"))
|
||||||
.binding(config.defaults.fullBlocksOn, () -> config.fullBlocksOn, n -> config.fullBlocksOn = n)
|
.binding(Config.defaults.fullBlocksOn, () -> Config.fullBlocksOn, n -> Config.fullBlocksOn = n)
|
||||||
.controller(opt -> BooleanControllerBuilder.create(opt).onOffFormatter())
|
.controller(opt -> BooleanControllerBuilder.create(opt).onOffFormatter())
|
||||||
.build())
|
.build())
|
||||||
.option(Option.<Boolean>createBuilder()
|
.option(Option.<Boolean>createBuilder()
|
||||||
.name(lang("general.sittable.custom"))
|
.name(lang("general.sittable.custom"))
|
||||||
.description(OptionDescription.of(lang("general.sittable.custom.description")))
|
.description(OptionDescription.of(lang("general.sittable.custom.description")))
|
||||||
.binding(config.defaults.customOn, () -> config.customOn, n -> config.customOn = n)
|
.binding(Config.defaults.customOn, () -> Config.customOn, n -> Config.customOn = n)
|
||||||
.controller(opt -> BooleanControllerBuilder.create(opt).onOffFormatter())
|
.controller(opt -> BooleanControllerBuilder.create(opt).onOffFormatter())
|
||||||
.build())
|
.build())
|
||||||
.build())
|
.build())
|
||||||
|
@ -86,7 +87,7 @@ public class ModMenu implements ModMenuApi {
|
||||||
.append("\n").append(lang("general.sittable_blocks.description_6").styled(style -> style.withColor(TextColor.fromFormatting(Formatting.GREEN))))
|
.append("\n").append(lang("general.sittable_blocks.description_6").styled(style -> style.withColor(TextColor.fromFormatting(Formatting.GREEN))))
|
||||||
.append("\n").append(lang("general.sittable_blocks.description_7").styled(style -> style.withColor(TextColor.fromFormatting(Formatting.GOLD))))
|
.append("\n").append(lang("general.sittable_blocks.description_7").styled(style -> style.withColor(TextColor.fromFormatting(Formatting.GOLD))))
|
||||||
.append("\n\n").append(lang("general.sittable_blocks.description_8").styled(style -> style.withColor(TextColor.fromFormatting(Formatting.YELLOW))))))
|
.append("\n\n").append(lang("general.sittable_blocks.description_8").styled(style -> style.withColor(TextColor.fromFormatting(Formatting.YELLOW))))))
|
||||||
.binding(config.defaults.customBlocks, () -> config.customBlocks, n -> config.customBlocks = n)
|
.binding(Config.defaults.customBlocks, () -> Config.customBlocks, n -> Config.customBlocks = n)
|
||||||
.controller(StringControllerBuilder::create)
|
.controller(StringControllerBuilder::create)
|
||||||
.initial("")
|
.initial("")
|
||||||
.build())
|
.build())
|
||||||
|
@ -94,14 +95,14 @@ public class ModMenu implements ModMenuApi {
|
||||||
.category(ConfigCategory.createBuilder()
|
.category(ConfigCategory.createBuilder()
|
||||||
.name(lang("category.main_hand"))
|
.name(lang("category.main_hand"))
|
||||||
.tooltip(lang("category.main_hand.tooltip"))
|
.tooltip(lang("category.main_hand.tooltip"))
|
||||||
.option(Option.<config.HandRequirement>createBuilder()
|
.option(Option.<Config.HandRequirement>createBuilder()
|
||||||
.name(lang("hand.requirements"))
|
.name(lang("hand.requirements"))
|
||||||
.description(OptionDescription.of(lang("hand.requirements.description")
|
.description(OptionDescription.of(lang("hand.requirements.description")
|
||||||
.append("\n\n").append(lang("hand.requirements.description_2").styled(style -> style.withColor(TextColor.fromFormatting(Formatting.AQUA))))
|
.append("\n\n").append(lang("hand.requirements.description_2").styled(style -> style.withColor(TextColor.fromFormatting(Formatting.AQUA))))
|
||||||
.append("\n").append(lang("hand.requirements.description_3").styled(style -> style.withColor(TextColor.fromFormatting(Formatting.GREEN))))
|
.append("\n").append(lang("hand.requirements.description_3").styled(style -> style.withColor(TextColor.fromFormatting(Formatting.GREEN))))
|
||||||
.append("\n").append(lang("hand.requirements.description_4").styled(style -> style.withColor(TextColor.fromFormatting(Formatting.RED))))))
|
.append("\n").append(lang("hand.requirements.description_4").styled(style -> style.withColor(TextColor.fromFormatting(Formatting.RED))))))
|
||||||
.binding(config.defaults.mainReq, () -> config.mainReq, n -> config.mainReq = n)
|
.binding(Config.defaults.mainReq, () -> Config.mainReq, n -> Config.mainReq = n)
|
||||||
.controller(opt -> EnumControllerBuilder.create(opt).enumClass(config.HandRequirement.class)
|
.controller(opt -> EnumControllerBuilder.create(opt).enumClass(Config.HandRequirement.class)
|
||||||
.formatValue(v -> Text.translatable("config.sit."+v.name().toLowerCase())))
|
.formatValue(v -> Text.translatable("config.sit."+v.name().toLowerCase())))
|
||||||
.build())
|
.build())
|
||||||
.group(OptionGroup.createBuilder()
|
.group(OptionGroup.createBuilder()
|
||||||
|
@ -109,18 +110,18 @@ public class ModMenu implements ModMenuApi {
|
||||||
.description(OptionDescription.of(lang("hand.restrictions.description")))
|
.description(OptionDescription.of(lang("hand.restrictions.description")))
|
||||||
.option(Option.<Boolean>createBuilder()
|
.option(Option.<Boolean>createBuilder()
|
||||||
.name(lang("hand.restrictions.blocks"))
|
.name(lang("hand.restrictions.blocks"))
|
||||||
.binding(config.defaults.mainBlock,()-> config.mainBlock,n -> config.mainBlock = n)
|
.binding(Config.defaults.mainBlock,()-> Config.mainBlock, n -> Config.mainBlock = n)
|
||||||
.controller(opt -> BooleanControllerBuilder.create(opt).trueFalseFormatter())
|
.controller(opt -> BooleanControllerBuilder.create(opt).trueFalseFormatter())
|
||||||
.build())
|
.build())
|
||||||
.option(Option.<Boolean>createBuilder()
|
.option(Option.<Boolean>createBuilder()
|
||||||
.name(lang("hand.restrictions.food"))
|
.name(lang("hand.restrictions.food"))
|
||||||
.binding(config.defaults.mainFood,()-> config.mainFood,n -> config.mainFood = n)
|
.binding(Config.defaults.mainFood,()-> Config.mainFood, n -> Config.mainFood = n)
|
||||||
.controller(opt -> BooleanControllerBuilder.create(opt).trueFalseFormatter())
|
.controller(opt -> BooleanControllerBuilder.create(opt).trueFalseFormatter())
|
||||||
.build())
|
.build())
|
||||||
.option(Option.<Boolean>createBuilder()
|
.option(Option.<Boolean>createBuilder()
|
||||||
.name(lang("hand.restrictions.usable"))
|
.name(lang("hand.restrictions.usable"))
|
||||||
.description(OptionDescription.of(lang("hand.restrictions.usable.description")))
|
.description(OptionDescription.of(lang("hand.restrictions.usable.description")))
|
||||||
.binding(config.defaults.mainUsable,()-> config.mainUsable,n -> config.mainUsable = n)
|
.binding(Config.defaults.mainUsable,()-> Config.mainUsable, n -> Config.mainUsable = n)
|
||||||
.controller(opt -> BooleanControllerBuilder.create(opt).trueFalseFormatter())
|
.controller(opt -> BooleanControllerBuilder.create(opt).trueFalseFormatter())
|
||||||
.build())
|
.build())
|
||||||
.build())
|
.build())
|
||||||
|
@ -129,7 +130,7 @@ public class ModMenu implements ModMenuApi {
|
||||||
.description(OptionDescription.of(lang("hand.whitelist.description")
|
.description(OptionDescription.of(lang("hand.whitelist.description")
|
||||||
.append("\n\n").append(lang("hand.list.description"))
|
.append("\n\n").append(lang("hand.list.description"))
|
||||||
.append(lang("hand.list.description_2").styled(style -> style.withItalic(true).withColor(TextColor.fromFormatting(Formatting.GRAY))))))
|
.append(lang("hand.list.description_2").styled(style -> style.withItalic(true).withColor(TextColor.fromFormatting(Formatting.GRAY))))))
|
||||||
.binding(config.defaults.mainWhitelist, () -> config.mainWhitelist, n -> config.mainWhitelist = n)
|
.binding(Config.defaults.mainWhitelist, () -> Config.mainWhitelist, n -> Config.mainWhitelist = n)
|
||||||
.controller(StringControllerBuilder::create)
|
.controller(StringControllerBuilder::create)
|
||||||
.initial("")
|
.initial("")
|
||||||
.build())
|
.build())
|
||||||
|
@ -138,7 +139,7 @@ public class ModMenu implements ModMenuApi {
|
||||||
.description(OptionDescription.of(lang("hand.blacklist.description")
|
.description(OptionDescription.of(lang("hand.blacklist.description")
|
||||||
.append("\n\n").append(lang("hand.list.description"))
|
.append("\n\n").append(lang("hand.list.description"))
|
||||||
.append(lang("hand.list.description_2").styled(style -> style.withItalic(true).withColor(TextColor.fromFormatting(Formatting.GRAY))))))
|
.append(lang("hand.list.description_2").styled(style -> style.withItalic(true).withColor(TextColor.fromFormatting(Formatting.GRAY))))))
|
||||||
.binding(config.defaults.mainBlacklist, () -> config.mainBlacklist, n -> config.mainBlacklist = n)
|
.binding(Config.defaults.mainBlacklist, () -> Config.mainBlacklist, n -> Config.mainBlacklist = n)
|
||||||
.controller(StringControllerBuilder::create)
|
.controller(StringControllerBuilder::create)
|
||||||
.initial("")
|
.initial("")
|
||||||
.build())
|
.build())
|
||||||
|
@ -146,14 +147,14 @@ public class ModMenu implements ModMenuApi {
|
||||||
.category(ConfigCategory.createBuilder()
|
.category(ConfigCategory.createBuilder()
|
||||||
.name(lang("category.off_hand"))
|
.name(lang("category.off_hand"))
|
||||||
.tooltip(lang("category.off_hand.tooltip"))
|
.tooltip(lang("category.off_hand.tooltip"))
|
||||||
.option(Option.<config.HandRequirement>createBuilder()
|
.option(Option.<Config.HandRequirement>createBuilder()
|
||||||
.name(lang("hand.requirements"))
|
.name(lang("hand.requirements"))
|
||||||
.description(OptionDescription.of(lang("hand.requirements.description")
|
.description(OptionDescription.of(lang("hand.requirements.description")
|
||||||
.append("\n\n").append(lang("hand.requirements.description_2").styled(style -> style.withColor(TextColor.fromFormatting(Formatting.AQUA))))
|
.append("\n\n").append(lang("hand.requirements.description_2").styled(style -> style.withColor(TextColor.fromFormatting(Formatting.AQUA))))
|
||||||
.append("\n").append(lang("hand.requirements.description_3").styled(style -> style.withColor(TextColor.fromFormatting(Formatting.GREEN))))
|
.append("\n").append(lang("hand.requirements.description_3").styled(style -> style.withColor(TextColor.fromFormatting(Formatting.GREEN))))
|
||||||
.append("\n").append(lang("hand.requirements.description_4").styled(style -> style.withColor(TextColor.fromFormatting(Formatting.RED))))))
|
.append("\n").append(lang("hand.requirements.description_4").styled(style -> style.withColor(TextColor.fromFormatting(Formatting.RED))))))
|
||||||
.binding(config.defaults.offReq, () -> config.offReq, n -> config.offReq = n)
|
.binding(Config.defaults.offReq, () -> Config.offReq, n -> Config.offReq = n)
|
||||||
.controller(opt -> EnumControllerBuilder.create(opt).enumClass(config.HandRequirement.class)
|
.controller(opt -> EnumControllerBuilder.create(opt).enumClass(Config.HandRequirement.class)
|
||||||
.formatValue(v -> Text.translatable("config.sit."+v.name().toLowerCase())))
|
.formatValue(v -> Text.translatable("config.sit."+v.name().toLowerCase())))
|
||||||
.build())
|
.build())
|
||||||
.group(OptionGroup.createBuilder()
|
.group(OptionGroup.createBuilder()
|
||||||
|
@ -161,18 +162,18 @@ public class ModMenu implements ModMenuApi {
|
||||||
.description(OptionDescription.of(lang("hand.restrictions.description")))
|
.description(OptionDescription.of(lang("hand.restrictions.description")))
|
||||||
.option(Option.<Boolean>createBuilder()
|
.option(Option.<Boolean>createBuilder()
|
||||||
.name(lang("hand.restrictions.blocks"))
|
.name(lang("hand.restrictions.blocks"))
|
||||||
.binding(config.defaults.offBlock,()-> config.offBlock,n -> config.offBlock = n)
|
.binding(Config.defaults.offBlock,()-> Config.offBlock, n -> Config.offBlock = n)
|
||||||
.controller(opt -> BooleanControllerBuilder.create(opt).trueFalseFormatter())
|
.controller(opt -> BooleanControllerBuilder.create(opt).trueFalseFormatter())
|
||||||
.build())
|
.build())
|
||||||
.option(Option.<Boolean>createBuilder()
|
.option(Option.<Boolean>createBuilder()
|
||||||
.name(lang("hand.restrictions.food"))
|
.name(lang("hand.restrictions.food"))
|
||||||
.binding(config.defaults.offFood,()-> config.offFood,n -> config.offFood = n)
|
.binding(Config.defaults.offFood,()-> Config.offFood, n -> Config.offFood = n)
|
||||||
.controller(opt -> BooleanControllerBuilder.create(opt).trueFalseFormatter())
|
.controller(opt -> BooleanControllerBuilder.create(opt).trueFalseFormatter())
|
||||||
.build())
|
.build())
|
||||||
.option(Option.<Boolean>createBuilder()
|
.option(Option.<Boolean>createBuilder()
|
||||||
.name(lang("hand.restrictions.usable"))
|
.name(lang("hand.restrictions.usable"))
|
||||||
.description(OptionDescription.of(lang("hand.restrictions.usable.description")))
|
.description(OptionDescription.of(lang("hand.restrictions.usable.description")))
|
||||||
.binding(config.defaults.offUsable,()-> config.offUsable,n -> config.offUsable = n)
|
.binding(Config.defaults.offUsable,()-> Config.offUsable, n -> Config.offUsable = n)
|
||||||
.controller(opt -> BooleanControllerBuilder.create(opt).trueFalseFormatter())
|
.controller(opt -> BooleanControllerBuilder.create(opt).trueFalseFormatter())
|
||||||
.build())
|
.build())
|
||||||
.build())
|
.build())
|
||||||
|
@ -181,7 +182,7 @@ public class ModMenu implements ModMenuApi {
|
||||||
.description(OptionDescription.of(lang("hand.whitelist.description")
|
.description(OptionDescription.of(lang("hand.whitelist.description")
|
||||||
.append("\n\n").append(lang("hand.list.description"))
|
.append("\n\n").append(lang("hand.list.description"))
|
||||||
.append(lang("hand.list.description_2").styled(style -> style.withItalic(true).withColor(TextColor.fromFormatting(Formatting.GRAY))))))
|
.append(lang("hand.list.description_2").styled(style -> style.withItalic(true).withColor(TextColor.fromFormatting(Formatting.GRAY))))))
|
||||||
.binding(config.defaults.offWhitelist, () -> config.offWhitelist, n -> config.offWhitelist = n)
|
.binding(Config.defaults.offWhitelist, () -> Config.offWhitelist, n -> Config.offWhitelist = n)
|
||||||
.controller(StringControllerBuilder::create)
|
.controller(StringControllerBuilder::create)
|
||||||
.initial("")
|
.initial("")
|
||||||
.build())
|
.build())
|
||||||
|
@ -190,7 +191,7 @@ public class ModMenu implements ModMenuApi {
|
||||||
.description(OptionDescription.of(lang("hand.blacklist.description")
|
.description(OptionDescription.of(lang("hand.blacklist.description")
|
||||||
.append("\n\n").append(lang("hand.list.description"))
|
.append("\n\n").append(lang("hand.list.description"))
|
||||||
.append(lang("hand.list.description_2").styled(style -> style.withItalic(true).withColor(TextColor.fromFormatting(Formatting.GRAY))))))
|
.append(lang("hand.list.description_2").styled(style -> style.withItalic(true).withColor(TextColor.fromFormatting(Formatting.GRAY))))))
|
||||||
.binding(config.defaults.offBlacklist, () -> config.offBlacklist, n -> config.offBlacklist = n)
|
.binding(Config.defaults.offBlacklist, () -> Config.offBlacklist, n -> Config.offBlacklist = n)
|
||||||
.controller(StringControllerBuilder::create)
|
.controller(StringControllerBuilder::create)
|
||||||
.initial("")
|
.initial("")
|
||||||
.build())
|
.build())
|
||||||
|
|
|
@ -14,12 +14,11 @@ import net.minecraft.server.command.CommandManager;
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
import net.minecraft.text.MutableText;
|
import net.minecraft.text.MutableText;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
|
import one.oth3r.sit.file.Config;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
public class Sit implements ModInitializer {
|
public class Sit implements ModInitializer {
|
||||||
|
@ -36,7 +35,7 @@ public class Sit implements ModInitializer {
|
||||||
//todo future:
|
//todo future:
|
||||||
// make it so it updates the sitting height and pos based on the block so if it changed while offline it still works (or if stair changes shape)
|
// make it so it updates the sitting height and pos based on the block so if it changed while offline it still works (or if stair changes shape)
|
||||||
// inner stair offset & custom support for that ig
|
// inner stair offset & custom support for that ig
|
||||||
config.load();
|
Config.load();
|
||||||
Events.register();
|
Events.register();
|
||||||
//PACKETS
|
//PACKETS
|
||||||
ServerPlayNetworking.registerGlobalReceiver(PacketBuilder.getIdentifier(),
|
ServerPlayNetworking.registerGlobalReceiver(PacketBuilder.getIdentifier(),
|
||||||
|
|
|
@ -13,6 +13,7 @@ import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
import net.minecraft.text.TextColor;
|
import net.minecraft.text.TextColor;
|
||||||
import net.minecraft.util.Formatting;
|
import net.minecraft.util.Formatting;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import one.oth3r.sit.file.Config;
|
||||||
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
|
@ -45,7 +46,7 @@ public class SitCommand {
|
||||||
// if console
|
// if console
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
if (args[0].equalsIgnoreCase("reload")) {
|
if (args[0].equalsIgnoreCase("reload")) {
|
||||||
config.load();
|
Config.load();
|
||||||
Sit.LOGGER.info(Sit.lang("key.sit.command.reloaded").getString());
|
Sit.LOGGER.info(Sit.lang("key.sit.command.reloaded").getString());
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -62,7 +63,7 @@ public class SitCommand {
|
||||||
Events.sit(player,pos);
|
Events.sit(player,pos);
|
||||||
}
|
}
|
||||||
if (args[0].equalsIgnoreCase("reload")) {
|
if (args[0].equalsIgnoreCase("reload")) {
|
||||||
config.load();
|
Config.load();
|
||||||
player.sendMessage(Sit.lang("key.sit.command.reloaded").styled(style -> style.withColor(TextColor.fromFormatting(Formatting.GREEN))));
|
player.sendMessage(Sit.lang("key.sit.command.reloaded").styled(style -> style.withColor(TextColor.fromFormatting(Formatting.GREEN))));
|
||||||
}
|
}
|
||||||
if (args[0].equalsIgnoreCase("purgeChairEntities")) {
|
if (args[0].equalsIgnoreCase("purgeChairEntities")) {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package one.oth3r.sit;
|
package one.oth3r.sit.file;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
|
@ -14,7 +14,7 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
public class config {
|
public class Config {
|
||||||
public static String lang = defaults.lang;
|
public static String lang = defaults.lang;
|
||||||
public static boolean keepActive = defaults.keepActive;
|
public static boolean keepActive = defaults.keepActive;
|
||||||
public static boolean sitWhileSeated = defaults.sitWhileSeated;
|
public static boolean sitWhileSeated = defaults.sitWhileSeated;
|
Loading…
Add table
Add a link
Reference in a new issue