undo next version

This commit is contained in:
Oth3r 2024-03-10 23:02:30 -05:00
commit 4a7624d595
9 changed files with 174 additions and 203 deletions

View file

@ -16,4 +16,4 @@ archives_base_name=sit!
# Dependencies
fabric_version=0.91.1+1.20.4
modmenu_version=9.0.0
yacl_version=3.3.2+1.20.4
yacl_version=3.3.1+1.20.4

View file

@ -24,8 +24,6 @@ import net.minecraft.util.math.Box;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import one.oth3r.sit.Utl.HandType;
import one.oth3r.sit.Utl.PlayerSettings;
import one.oth3r.sit.Utl.PlayerSettings.Setting;
import java.util.*;
@ -48,17 +46,17 @@ public class Events {
for (HandType type:HandType.values()) {
ItemStack targetStack = itemMap.get(type);
// if req is empty and the item isn't empty, false
if (PlayerSettings.getRequirement(player,type).equals(config.HandRequirement.empty) && !targetStack.isEmpty()) return false;
if (Utl.getReq(player,type).equals(config.HandRequirement.empty) && !targetStack.isEmpty()) return false;
// if req is restrictive
if (PlayerSettings.getRequirement(player,type).equals(config.HandRequirement.restrictive)) {
if (Utl.getReq(player,type).equals(config.HandRequirement.restrictive)) {
// if item is in blacklist, false
if (checkList(PlayerSettings.getList(player,type,Setting.blacklist),targetStack)) return false;
if (checkList(Utl.getList(player,type,"blacklist"),targetStack)) return false;
// if item is NOT in whitelist
if (!checkList(PlayerSettings.getList(player,type,Setting.whitelist),targetStack)) {
if (!checkList(Utl.getList(player,type,"whitelist"),targetStack)) {
// if block is restricted and items is block, false, ect
if (PlayerSettings.getToggle(player,type,Setting.block) && (targetStack.getItem() instanceof BlockItem)) return false;
if (PlayerSettings.getToggle(player,type,Setting.food) && food.contains(targetStack.getUseAction())) return false;
if (PlayerSettings.getToggle(player,type,Setting.usable) && !notUsable.contains(targetStack.getUseAction())) return false;
if (Utl.getBool(player,type,"block") && (targetStack.getItem() instanceof BlockItem)) return false;
if (Utl.getBool(player,type,"food") && food.contains(targetStack.getUseAction())) return false;
if (Utl.getBool(player,type,"usable") && !notUsable.contains(targetStack.getUseAction())) return false;
}
}
}
@ -107,7 +105,7 @@ public class Events {
if (block instanceof CarpetBlock && config.carpetsOn) return true;
if (blockState.isFullCube(world,pos.add(0,1,0)) && config.fullBlocksOn) return true;
// custom checker
if (config.customOn && !config.customBlocks.isEmpty()) {
if (config.customOn && config.customBlocks.size() != 0) {
for (HashMap<String,Object> map:getCustomBlocks().values()) {
String blockID = Registries.BLOCK.getId(block).toString();
if (map.get("block").equals(blockID)) {
@ -151,7 +149,7 @@ public class Events {
entity.updatePositionAndAngles(pos.getX() + 0.5, pos.getY()+.78, pos.getZ() + 0.5, 0, 0);
hitBoxY = 2;
}
if (config.customOn && !config.customBlocks.isEmpty()) {
if (config.customOn && config.customBlocks.size() != 0) {
for (HashMap<String,Object> map:getCustomBlocks().values()) {
String blockID = Registries.BLOCK.getId(block).toString();
if (map.get("block").equals(blockID)) {
@ -176,7 +174,7 @@ public class Events {
ServerPlayerEntity player = handler.player;
checkPlayers.put(player,2);
// put server settings in the player settings
Sit.playerSettings.put(player, PlayerSettings.getHandSettings());
Sit.playerSettings.put(player,Utl.getHandSettings());
});
ServerPlayConnectionEvents.DISCONNECT.register((handler, server) -> {
ServerPlayerEntity player = handler.player;

View file

@ -12,8 +12,11 @@ import net.minecraft.text.TextColor;
import net.minecraft.util.Formatting;
public class ModMenu implements ModMenuApi {
private static MutableText lang(String key) {
return Text.translatable("config.sit."+key);
}
private static MutableText lang(String key, Object... args) {
return Utl.lang("config."+key,args);
return Text.translatable("config.sit."+key,args);
}
@Override
public ConfigScreenFactory<?> getModConfigScreenFactory() {
@ -21,6 +24,7 @@ public class ModMenu implements ModMenuApi {
.title(Text.of("Sit!"))
.category(ConfigCategory.createBuilder()
.name(lang("category.general"))
.tooltip(lang("category.general.tooltip"))
.option(Option.<Boolean>createBuilder()
.name(lang("general.keep_active"))
.description(OptionDescription.of(lang("general.keep_active.description")))
@ -67,7 +71,7 @@ public class ModMenu implements ModMenuApi {
.name(lang("general.sittable_blocks"))
.description(OptionDescription.of(
lang("general.sittable_blocks.description")
.append("\n\n").append(lang("example",
.append("\n\n").append(lang("general.sittable_blocks.description_2",
Text.literal("\"")
.append(Text.literal("minecraft:campfire").styled(style -> style.withColor(TextColor.fromFormatting(Formatting.AQUA))))
.append("|")
@ -76,12 +80,12 @@ public class ModMenu implements ModMenuApi {
.append(Text.literal("1").styled(style -> style.withColor(TextColor.fromFormatting(Formatting.GREEN))))
.append("|")
.append(Text.literal("lit=false").styled(style -> style.withColor(TextColor.fromFormatting(Formatting.GOLD))))
.append("\"").styled(style -> style.withColor(TextColor.fromFormatting(Formatting.GRAY)))))
.append("\n\n").append(lang("general.sittable_blocks.description.2").styled(style -> style.withColor(TextColor.fromFormatting(Formatting.AQUA))))
.append("\n").append(lang("general.sittable_blocks.description.3").styled(style -> style.withColor(TextColor.fromFormatting(Formatting.RED))))
.append("\n").append(lang("general.sittable_blocks.description.4").styled(style -> style.withColor(TextColor.fromFormatting(Formatting.GREEN))))
.append("\n").append(lang("general.sittable_blocks.description.5").styled(style -> style.withColor(TextColor.fromFormatting(Formatting.GOLD))))
.append("\n\n").append(lang("general.sittable_blocks.description.6").styled(style -> style.withColor(TextColor.fromFormatting(Formatting.YELLOW))))))
.append("\"").styled(style -> style.withItalic(true).withColor(TextColor.fromFormatting(Formatting.GRAY)))))
.append("\n\n").append(lang("general.sittable_blocks.description_4").styled(style -> style.withColor(TextColor.fromFormatting(Formatting.AQUA))))
.append("\n").append(lang("general.sittable_blocks.description_5").styled(style -> style.withColor(TextColor.fromFormatting(Formatting.RED))))
.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\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)
.controller(StringControllerBuilder::create)
.initial("")
@ -89,50 +93,51 @@ public class ModMenu implements ModMenuApi {
.build())
.category(ConfigCategory.createBuilder()
.name(lang("category.main_hand"))
.tooltip(lang("category.main_hand.tooltip"))
.option(Option.<config.HandRequirement>createBuilder()
.name(lang("hand.requirement"))
.description(OptionDescription.of(lang("hand.requirement.description")
.append("\n\n").append(lang("hand.requirement.description.2",lang("hand.requirement.empty")).styled(style -> style.withColor(TextColor.fromFormatting(Formatting.AQUA))))
.append("\n").append(lang("hand.requirement.description.3",lang("hand.requirement.restrictive")).styled(style -> style.withColor(TextColor.fromFormatting(Formatting.GREEN))))
.append("\n").append(lang("hand.requirement.description.4",lang("hand.requirement.none")).styled(style -> style.withColor(TextColor.fromFormatting(Formatting.RED))))))
.name(lang("hand.requirements"))
.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").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))))))
.binding(config.defaults.mainReq, () -> config.mainReq, n -> config.mainReq = n)
.controller(opt -> EnumControllerBuilder.create(opt).enumClass(config.HandRequirement.class)
.formatValue(v -> lang("hand.requirement."+v.toString())))
.formatValue(v -> Text.translatable("config.sit."+v.name().toLowerCase())))
.build())
.group(OptionGroup.createBuilder()
.name(lang("hand.restriction"))
.description(OptionDescription.of(lang("hand.restriction.description")))
.name(lang("hand.restrictions"))
.description(OptionDescription.of(lang("hand.restrictions.description")))
.option(Option.<Boolean>createBuilder()
.name(lang("hand.restriction.blocks"))
.name(lang("hand.restrictions.blocks"))
.binding(config.defaults.mainBlock,()-> config.mainBlock,n -> config.mainBlock = n)
.controller(opt -> BooleanControllerBuilder.create(opt).trueFalseFormatter())
.build())
.option(Option.<Boolean>createBuilder()
.name(lang("hand.restriction.food"))
.name(lang("hand.restrictions.food"))
.binding(config.defaults.mainFood,()-> config.mainFood,n -> config.mainFood = n)
.controller(opt -> BooleanControllerBuilder.create(opt).trueFalseFormatter())
.build())
.option(Option.<Boolean>createBuilder()
.name(lang("hand.restriction.usable"))
.description(OptionDescription.of(lang("hand.restriction.usable.description")))
.name(lang("hand.restrictions.usable"))
.description(OptionDescription.of(lang("hand.restrictions.usable.description")))
.binding(config.defaults.mainUsable,()-> config.mainUsable,n -> config.mainUsable = n)
.controller(opt -> BooleanControllerBuilder.create(opt).trueFalseFormatter())
.build())
.build())
.group(ListOption.<String>createBuilder()
.name(lang("hand.restriction.whitelist"))
.description(OptionDescription.of(lang("hand.restriction.list.description")
.append("\n\n").append(lang("example",
Text.empty().append(Utl.Assets.LIST).styled(style -> style.withItalic(true).withColor(TextColor.fromFormatting(Formatting.GRAY)))))))
.name(lang("hand.whitelist"))
.description(OptionDescription.of(lang("hand.whitelist.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))))))
.binding(config.defaults.mainWhitelist, () -> config.mainWhitelist, n -> config.mainWhitelist = n)
.controller(StringControllerBuilder::create)
.initial("")
.build())
.group(ListOption.<String>createBuilder()
.name(lang("hand.restriction.blacklist"))
.description(OptionDescription.of(lang("hand.restriction.list.description")
.append("\n\n").append(lang("example",
Text.empty().append(Utl.Assets.LIST).styled(style -> style.withItalic(true).withColor(TextColor.fromFormatting(Formatting.GRAY)))))))
.name(lang("hand.blacklist"))
.description(OptionDescription.of(lang("hand.blacklist.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))))))
.binding(config.defaults.mainBlacklist, () -> config.mainBlacklist, n -> config.mainBlacklist = n)
.controller(StringControllerBuilder::create)
.initial("")
@ -140,50 +145,51 @@ public class ModMenu implements ModMenuApi {
.build())
.category(ConfigCategory.createBuilder()
.name(lang("category.off_hand"))
.tooltip(lang("category.off_hand.tooltip"))
.option(Option.<config.HandRequirement>createBuilder()
.name(lang("hand.requirement"))
.description(OptionDescription.of(lang("hand.requirement.description")
.append("\n\n").append(lang("hand.requirement.description.2",lang("hand.requirement.empty")).styled(style -> style.withColor(TextColor.fromFormatting(Formatting.AQUA))))
.append("\n").append(lang("hand.requirement.description.3",lang("hand.requirement.restrictive")).styled(style -> style.withColor(TextColor.fromFormatting(Formatting.GREEN))))
.append("\n").append(lang("hand.requirement.description.4",lang("hand.requirement.none")).styled(style -> style.withColor(TextColor.fromFormatting(Formatting.RED))))))
.name(lang("hand.requirements"))
.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").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))))))
.binding(config.defaults.offReq, () -> config.offReq, n -> config.offReq = n)
.controller(opt -> EnumControllerBuilder.create(opt).enumClass(config.HandRequirement.class)
.formatValue(v -> lang("hand.requirement."+v.toString())))
.formatValue(v -> Text.translatable("config.sit."+v.name().toLowerCase())))
.build())
.group(OptionGroup.createBuilder()
.name(lang("hand.restriction"))
.description(OptionDescription.of(lang("hand.restriction.description")))
.name(lang("hand.restrictions"))
.description(OptionDescription.of(lang("hand.restrictions.description")))
.option(Option.<Boolean>createBuilder()
.name(lang("hand.restriction.blocks"))
.name(lang("hand.restrictions.blocks"))
.binding(config.defaults.offBlock,()-> config.offBlock,n -> config.offBlock = n)
.controller(opt -> BooleanControllerBuilder.create(opt).trueFalseFormatter())
.build())
.option(Option.<Boolean>createBuilder()
.name(lang("hand.restriction.food"))
.name(lang("hand.restrictions.food"))
.binding(config.defaults.offFood,()-> config.offFood,n -> config.offFood = n)
.controller(opt -> BooleanControllerBuilder.create(opt).trueFalseFormatter())
.build())
.option(Option.<Boolean>createBuilder()
.name(lang("hand.restriction.usable"))
.description(OptionDescription.of(lang("hand.restriction.usable.description")))
.name(lang("hand.restrictions.usable"))
.description(OptionDescription.of(lang("hand.restrictions.usable.description")))
.binding(config.defaults.offUsable,()-> config.offUsable,n -> config.offUsable = n)
.controller(opt -> BooleanControllerBuilder.create(opt).trueFalseFormatter())
.build())
.build())
.group(ListOption.<String>createBuilder()
.name(lang("hand.restriction.whitelist"))
.description(OptionDescription.of(lang("hand.restriction.list.description")
.append("\n\n").append(lang("example",
Text.empty().append(Utl.Assets.LIST).styled(style -> style.withItalic(true).withColor(TextColor.fromFormatting(Formatting.GRAY)))))))
.name(lang("hand.whitelist"))
.description(OptionDescription.of(lang("hand.whitelist.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))))))
.binding(config.defaults.offWhitelist, () -> config.offWhitelist, n -> config.offWhitelist = n)
.controller(StringControllerBuilder::create)
.initial("")
.build())
.group(ListOption.<String>createBuilder()
.name(lang("hand.restriction.blacklist"))
.description(OptionDescription.of(lang("hand.restriction.list.description")
.append("\n\n").append(lang("example",
Text.empty().append(Utl.Assets.LIST).styled(style -> style.withItalic(true).withColor(TextColor.fromFormatting(Formatting.GRAY)))))))
.name(lang("hand.blacklist"))
.description(OptionDescription.of(lang("hand.blacklist.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))))))
.binding(config.defaults.offBlacklist, () -> config.offBlacklist, n -> config.offBlacklist = n)
.controller(StringControllerBuilder::create)
.initial("")

View file

@ -3,16 +3,23 @@ package one.oth3r.sit;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
import io.netty.buffer.ByteBuf;
import io.netty.util.ReferenceCountUtil;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.command.CommandManager;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.text.MutableText;
import net.minecraft.text.Text;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.lang.reflect.Type;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.HashMap;
public class Sit implements ModInitializer {
@ -43,4 +50,8 @@ public class Sit implements ModInitializer {
});
});
}
public static MutableText lang(String key, Object... args) {
if (isClient) return Text.translatable(key, args);
else return LangReader.of(key, args).getTxT();
}
}

View file

@ -20,6 +20,6 @@ public class SitClient implements ClientModInitializer {
}
public static void sendPackets() {
Gson gson = new GsonBuilder().disableHtmlEscaping().create();
new PacketBuilder(gson.toJson(Utl.PlayerSettings.getHandSettings())).send();
new PacketBuilder(gson.toJson(Utl.getHandSettings())).send();
}
}

View file

@ -49,7 +49,7 @@ public class SitCommand {
if (player == null) {
if (args[0].equalsIgnoreCase("reload")) {
config.load();
Sit.LOGGER.info(Utl.lang("msg.reloaded").getString());
Sit.LOGGER.info(Sit.lang("key.sit.command.reloaded").getString());
}
return 1;
}
@ -73,7 +73,7 @@ public class SitCommand {
}
if (args[0].equalsIgnoreCase("reload")) {
config.load();
player.sendMessage(Utl.lang("msg.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")) {
String cmd = "kill @e[type=minecraft:text_display,name=\""+Sit.ENTITY_NAME+"\"]";
@ -81,9 +81,9 @@ public class SitCommand {
ParseResults<ServerCommandSource> parse =
Sit.commandManager.getDispatcher().parse(cmd, player.getCommandSource());
Sit.commandManager.getDispatcher().execute(parse);
player.sendMessage(Utl.lang("msg.purged"));
player.sendMessage(Sit.lang("key.sit.command.purged"));
} catch (CommandSyntaxException e) {
player.sendMessage(Utl.lang("msg.purged"));
player.sendMessage(Sit.lang("key.sit.command.purged"));
e.printStackTrace();
}
}

View file

@ -4,8 +4,6 @@ import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.text.MutableText;
import net.minecraft.text.Text;
import java.lang.reflect.Type;
import java.util.ArrayList;
@ -13,62 +11,35 @@ import java.util.HashMap;
import java.util.List;
public class Utl {
public static MutableText lang(String key, Object... args) {
if (Sit.isClient) return Text.translatable(key, args);
else return LangReader.of(key, args).getTxT();
}
public enum HandType {
enum HandType {
main,
off
}
public static class PlayerSettings {
public enum Setting {
requirement,
block,
food,
usable,
whitelist,
blacklist
}
/**
* Gets a HashMap of all player configurable settings.
* @return a map with player hand settings.
*/
public static HashMap<String,String> getHandSettings() {
Gson gson = new GsonBuilder().disableHtmlEscaping().create();
HashMap<String,String> settings = new HashMap<>();
// main hand
settings.put("hand.main."+Setting.requirement,String.valueOf(config.mainReq));
settings.put("hand.main."+Setting.block,String.valueOf(config.mainBlock));
settings.put("hand.main."+Setting.food,String.valueOf(config.mainFood));
settings.put("hand.main."+Setting.usable,String.valueOf(config.mainUsable));
settings.put("hand.main."+Setting.whitelist,gson.toJson(config.mainWhitelist));
settings.put("hand.main."+Setting.blacklist,gson.toJson(config.mainBlacklist));
// copy but offhand
settings.put("hand.off."+Setting.requirement,String.valueOf(config.offReq));
settings.put("hand.off."+Setting.block,String.valueOf(config.offBlock));
settings.put("hand.off."+Setting.food,String.valueOf(config.offFood));
settings.put("hand.off."+Setting.usable,String.valueOf(config.offUsable));
settings.put("hand.off."+Setting.whitelist,gson.toJson(config.offWhitelist));
settings.put("hand.off."+Setting.blacklist,gson.toJson(config.offBlacklist));
settings.put("hand.main.requirement",String.valueOf(config.mainReq));
settings.put("hand.main.block",String.valueOf(config.mainBlock));
settings.put("hand.main.food",String.valueOf(config.mainFood));
settings.put("hand.main.usable",String.valueOf(config.mainUsable));
settings.put("hand.main.whitelist",gson.toJson(config.mainWhitelist));
settings.put("hand.main.blacklist",gson.toJson(config.mainBlacklist));
settings.put("hand.off.requirement",String.valueOf(config.offReq));
settings.put("hand.off.block",String.valueOf(config.offBlock));
settings.put("hand.off.food",String.valueOf(config.offFood));
settings.put("hand.off.usable",String.valueOf(config.offUsable));
settings.put("hand.off.whitelist",gson.toJson(config.offWhitelist));
settings.put("hand.off.blacklist",gson.toJson(config.offBlacklist));
return settings;
}
// returns specific items from the player config
public static config.HandRequirement getRequirement(ServerPlayerEntity player, HandType type) {
public static config.HandRequirement getReq(ServerPlayerEntity player, HandType type) {
return config.HandRequirement.get(Sit.playerSettings.get(player).get("hand."+type+".requirement"));
}
public static List<String> getList(ServerPlayerEntity player, HandType type, Setting setting) {
public static List<String> getList(ServerPlayerEntity player, HandType type, String setting) {
Type listType = new TypeToken<ArrayList<String>>() {}.getType();
return new Gson().fromJson(Sit.playerSettings.get(player).get("hand."+type+"."+setting),listType);
}
public static boolean getToggle(ServerPlayerEntity player, HandType type, Setting setting) {
public static boolean getBool(ServerPlayerEntity player, HandType type, String setting) {
return Boolean.parseBoolean(Sit.playerSettings.get(player).get("hand."+type+"."+setting));
}
}
public static class Assets {
public static final String CUSTOM_BLOCKS = "\"minecraft:campfire|0.255|1|lit=false\"";
public static final String REQUIREMENT_OPTIONS = String.format("%s, %s, %s",
config.HandRequirement.empty,config.HandRequirement.restrictive,config.HandRequirement.none);
public static final String LIST = "\"minecraft:torch\"";
}
}

View file

@ -24,7 +24,7 @@ public class config {
public static boolean fullBlocksOn = defaults.fullBlocksOn;
public static boolean customOn = defaults.customOn;
public static List<String> customBlocks = defaults.customBlocks;
public enum HandRequirement {
enum HandRequirement {
empty,
restrictive,
none;
@ -128,7 +128,7 @@ public class config {
}
}
public static String lang(String key, Object... args) {
return Utl.lang("config."+key, args).getString();
return LangReader.of("config.sit."+key, args).getTxT().getString();
}
public static void save() {
try (var file = Files.newBufferedWriter(configFile().toPath(), StandardCharsets.UTF_8)) {
@ -147,45 +147,34 @@ public class config {
file.write("\ncarpets=" + carpetsOn);
file.write("\nfull-blocks=" + fullBlocksOn);
file.write("\ncustom=" + customOn);
file.write("\n# "+ Utl.lang("config."+
file.write("\n# "+Sit.lang("config.sit."+
"general.sittable_blocks.description")
.append("\n# ").append(lang("example",Utl.Assets.CUSTOM_BLOCKS))
.append("\n# ").append(lang("general.sittable_blocks.description.2"))
.append("\n# ").append(lang("general.sittable_blocks.description.3"))
.append("\n# ").append(lang("general.sittable_blocks.description.4"))
.append("\n# ").append(lang("general.sittable_blocks.description.5"))
.append("\n# ").append(lang("general.sittable_blocks.description.6")).getString());
.append("\n# ").append(lang("general.sittable_blocks.description_2",
"\"minecraft:campfire|0.255|1|lit=false\""))
.append("\n# ").append(lang("general.sittable_blocks.description_4"))
.append("\n# ").append(lang("general.sittable_blocks.description_5"))
.append("\n# ").append(lang("general.sittable_blocks.description_6"))
.append("\n# ").append(lang("general.sittable_blocks.description_7"))
.append("\n# ").append(lang("general.sittable_blocks.description_8")).getString());
file.write("\ncustom-blocks="+gson.toJson(customBlocks));
file.write("\n\n# "+lang("hand"));
file.write("\n# "+ Utl.lang("config."+
"hand.requirement.description")
.append("\n# ").append(lang("hand.requirement.description.2",HandRequirement.empty))
.append("\n# ").append(lang("hand.requirement.description.3",HandRequirement.restrictive))
.append("\n# ").append(lang("hand.requirement.description.4",HandRequirement.none)).getString());
file.write("\n# "+lang("hand.requirement.options",Utl.Assets.REQUIREMENT_OPTIONS));
file.write("\n# "+Sit.lang("config.sit."+
"hand.requirements.description")
.append("\n# ").append(lang("hand.requirements.description_2"))
.append("\n# ").append(lang("hand.requirements.description_3"))
.append("\n# ").append(lang("hand.requirements.description_4")).getString());
file.write("\nhand.main.requirement=" + mainReq);
file.write("\n#");
file.write("\nhand.off.requirement=" + offReq);
file.write("\n\n# "+lang("hand.restriction"));
file.write("\n# "+lang("hand.restriction.description"));
file.write("\nhand.main.block=" + mainBlock);
file.write("\nhand.main.food=" + mainFood);
file.write("\nhand.main.usable=" + mainUsable);
file.write("\n#");
file.write("\nhand.main.whitelist="+gson.toJson(mainWhitelist));
file.write("\nhand.main.blacklist="+gson.toJson(mainBlacklist));
file.write("\nhand.off.requirement=" + offReq);
file.write("\nhand.off.block=" + offBlock);
file.write("\nhand.off.food=" + offFood);
file.write("\nhand.off.usable=" + offUsable);
file.write("\n\n# "+lang("hand.restriction.list"));
file.write("\n# "+lang("hand.restriction.list.description"));
file.write("\n# "+lang("example",Utl.Assets.LIST));
file.write("\nhand.main.whitelist="+gson.toJson(mainWhitelist));
file.write("\nhand.main.blacklist="+gson.toJson(mainBlacklist));
file.write("\n#");
file.write("\nhand.off.whitelist="+gson.toJson(offWhitelist));
file.write("\nhand.off.blacklist="+gson.toJson(offBlacklist));
// send packets to update the settings on the server
if (SitClient.inGame) SitClient.sendPackets();
} catch (Exception e) {

View file

@ -1,55 +1,51 @@
{
"category.sit": "Sit!",
"config.category.general": "General",
"config.category.main_hand": "Main Hand",
"config.category.off_hand": "Off Hand",
"config.general.keep_active": "Keep Active",
"config.general.keep_active.description": "Keeps the entities active even when logging off / shutting down",
"config.general.sittable": "Sittable Blocks",
"config.general.sittable.description": "Toggle the ability to sit on different block types.",
"config.general.sit_while_seated": "Sit While Seated",
"config.general.sit_while_seated.description": "Toggle the ability to sit on other blocks while already being seated on one.",
"config.general.sittable.stairs": "Stairs",
"config.general.sittable.slabs": "Slabs",
"config.general.sittable.carpets": "Carpets",
"config.general.sittable.full_blocks": "Full Blocks",
"config.general.sittable.custom": "Custom",
"config.general.sittable.custom.description": "Enables adding custom blocks to sit on.",
"config.general.sittable_blocks": "Custom Sittable Blocks",
"config.general.sittable_blocks.description": "Add custom sittable blocks!",
"config.general.sittable_blocks.description.2": "First entry: custom block id",
"config.general.sittable_blocks.description.3": "Second entry: sitting height (number from 0-1 eg 0.52)",
"config.general.sittable_blocks.description.4": "Third entry: hitbox size (where the player spawns above the entity when dismounting)",
"config.general.sittable_blocks.description.5": "Fourth entry (optional): required blockstate to sit (Put a \"!\" to exclude blockstates)",
"config.general.sittable_blocks.description.6": "Separate different entries with \"|\"!",
"config.hand": "Hand Settings",
"config.hand.requirement": "Requirements",
"config.hand.requirement.empty": "Empty",
"config.hand.requirement.restrictive": "Restrictive",
"config.hand.requirement.none": "None",
"config.hand.requirement.description": "Hand requirements for sitting.",
"config.hand.requirement.description.2": "%s: hand has to be empty",
"config.hand.requirement.description.3": "%s: set restrictions for hand state",
"config.hand.requirement.description.4": "%s: can sit whenever",
"config.hand.requirement.options": "Options: %s",
"config.hand.restriction": "Restrictions",
"config.hand.restriction.description": "Toggle custom hand restrictions for sitting.",
"config.hand.restriction.blocks": "Blocks",
"config.hand.restriction.food": "Food",
"config.hand.restriction.usable": "Usable",
"config.hand.restriction.usable.description": "eg. bows, tridents, shield",
"config.hand.restriction.list": "Item Restrictions",
"config.hand.restriction.list.description": "Allow or block certain items when the hand requirement is restrictive.",
"config.hand.restriction.whitelist": "Whitelist",
"config.hand.restriction.blacklist": "Blacklist",
"config.example": "Example: %s",
"msg.sit_toggle.on": "Enabled Sitting!",
"msg.sit_toggle.off": "Disabled Sitting!",
"msg.reloaded": "Reloaded the config!",
"msg.purged": "Purged all active chair entities!",
"key.toggle": "Toggle Sitting",
"key.sit": "Sit"
"config.sit.empty": "Empty",
"config.sit.restrictive": "Restrictive",
"config.sit.none": "None",
"config.sit.category.general": "General",
"config.sit.category.general.tooltip": "General settings",
"config.sit.category.main_hand": "Main Hand",
"config.sit.category.main_hand.tooltip": "Main hand settings",
"config.sit.category.off_hand": "Off Hand",
"config.sit.category.off_hand.tooltip": "Off hand settings",
"config.sit.general.keep_active": "Keep Active",
"config.sit.general.keep_active.description": "Keeps the entities active even when logging off / shutting down",
"config.sit.general.sittable": "Sittable Blocks",
"config.sit.general.sittable.description": "Toggle the ability to sit on different block types.",
"config.sit.general.sit_while_seated": "Sit While Seated",
"config.sit.general.sit_while_seated.description": "Toggle the ability to sit on other blocks while already being seated on one.",
"config.sit.general.sittable.stairs": "Stairs",
"config.sit.general.sittable.slabs": "Slabs",
"config.sit.general.sittable.carpets": "Carpets",
"config.sit.general.sittable.full_blocks": "Full Blocks",
"config.sit.general.sittable.custom": "Custom",
"config.sit.general.sittable.custom.description": "Enables adding custom blocks to sit on.",
"config.sit.general.sittable_blocks": "Custom Sittable Blocks",
"config.sit.general.sittable_blocks.description": "Add custom sittable blocks!",
"config.sit.general.sittable_blocks.description_2": "Example: %s",
"config.sit.general.sittable_blocks.description_4": "First entry: custom block",
"config.sit.general.sittable_blocks.description_5": "Second entry: sitting height (number from 0-1 eg 0.52)",
"config.sit.general.sittable_blocks.description_6": "Third entry: hitbox size (where the player spawns above the entity when dismounting)",
"config.sit.general.sittable_blocks.description_7": "Fourth entry (optional): required blockstate to sit (Put a \"!\" to exclude blockstates)",
"config.sit.general.sittable_blocks.description_8": "Separate different entries with \"|\"!",
"config.sit.hand": "Hand Settings",
"config.sit.hand.requirements": "Requirements",
"config.sit.hand.requirements.description": "Hand requirements for sitting.",
"config.sit.hand.requirements.description_2": "Empty = hand has to be empty",
"config.sit.hand.requirements.description_3": "Restrictive = set restrictions for hand state",
"config.sit.hand.requirements.description_4": "None = can sit whenever",
"config.sit.hand.restrictions": "Restrictions",
"config.sit.hand.restrictions.description": "Toggle preset hand restrictions for sitting.",
"config.sit.hand.restrictions.blocks": "Blocks",
"config.sit.hand.restrictions.food": "Food",
"config.sit.hand.restrictions.usable": "Usable",
"config.sit.hand.restrictions.usable.description": "eg. bows, tridents, shield",
"config.sit.hand.whitelist": "Whitelist",
"config.sit.hand.whitelist.description": "Make a custom whitelist for items that the player can use to sit with.",
"config.sit.hand.blacklist": "Blacklist",
"config.sit.hand.blacklist.description": "Make a custom blacklist for items that the player can't use to sit with.",
"config.sit.hand.list.description": "Example: ",
"config.sit.hand.list.description_2": "\"minecraft:torch\"",
"key.sit.command.reloaded": "Reloaded the config!",
"key.sit.command.purged": "Purged all active chair entities!"
}