From 61ff50a81d02d0604c98e498fea227a7abcc3d16 Mon Sep 17 00:00:00 2001 From: Oth3r <68134921+Oth3r@users.noreply.github.com> Date: Fri, 6 Jun 2025 20:01:52 -0500 Subject: [PATCH 01/16] add OtterLib dependency message, fixes #23 --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index b851d3a..2457022 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,8 @@ The mod also has full Geyser support! Enjoy sitting with everyone, weather they ### Where to install? **Sit!** works on the server (singleplayer included), also with support for clients that join in to use their own settings to sit. +\ +[Farbric API](https://modrinth.com/mod/fabric-api) and [OtterLib](https://modrinth.com/mod/otterlib) is required to for the mod to load. ## Help localize Sit! on [Crowdin](https://crowdin.com/project/oth3r-sit)! ![overview](https://github.com/Oth3r/Sit/blob/master/media/overview.gif?raw=true) From bc23a3d2c258f2d4dd3f65888d259003b302c8f9 Mon Sep 17 00:00:00 2001 From: Oth3r <68134921+Oth3r@users.noreply.github.com> Date: Fri, 6 Jun 2025 20:09:48 -0500 Subject: [PATCH 02/16] README refresh --- README.md | 74 +++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 47 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index 2457022..47fbea2 100644 --- a/README.md +++ b/README.md @@ -1,48 +1,68 @@ -# Sit! -[![github](https://img.shields.io/github/issues/oth3r/Sit?logo=github?label=Issues)](https://github.com/Oth3r/Sit/releases) [![Crowdin](https://badges.crowdin.net/oth3r-sit/localized.svg)](https://crowdin.com/project/oth3r-sit) [![discord](https://dcbadge.vercel.app/api/server/https://discord.gg/AVSTHCAUvn?style=flat)](https://www.oth3r.one/discord) + + +[![github](https://img.shields.io/github/issues/oth3r/Sit?logo=github?label=Issues)](https://github.com/Oth3r/Sit/releases) [![Crowdin](https://badges.crowdin.net/oth3r-sit/localized.svg)](https://crowdin.com/project/oth3r-sit) [![discord](https://dcbadge.vercel.app/api/server/https://discord.gg/AVSTHCAUvn?style=flat)](https://www.oth3r.one/discord) [![modrinth](https://img.shields.io/modrinth/dt/sit!?label=Modrinth&logo=modrinth)](https://modrinth.com/mod/sit!) [![curseforge](https://cf.way2muchnoise.eu/892424.svg)](https://www.curseforge.com/minecraft/mc-mods/Sit1) -**Sit!** is a minecraft mod that adds sitting in vanilla minecraft. -Sit on **stairs**, **slabs**, **carpets** by default, and sit on everything else using the config! -You can also customize hand restrictions to stop accidentally sitting down! -The mod also has full Geyser support! Enjoy sitting with everyone, weather they are on Bedrock or Java! + +### **Sit!** is a vanilla+ mod that adds sitting in minecraft. +* Sit on **stairs**, **slabs**, **carpets** by default, and sit on everything else by tweaking the config! +* You can also customize **hand restrictions** to stop accidentally sitting down! +* The mod also has full **Geyser** support! Enjoy sitting with everyone, whether they are on Bedrock or Java! +* If Sit! clients join a Sit! server they can use **their own hand settings** to sit. ### Where to install? -**Sit!** works on the server (singleplayer included), also with support for clients that join in to use their own settings to sit. +**Sit!** works on the server, without the players needing to install the mod *(singleplayer included!)*. \ -[Farbric API](https://modrinth.com/mod/fabric-api) and [OtterLib](https://modrinth.com/mod/otterlib) is required to for the mod to load. +[Fabric API](https://modrinth.com/mod/fabric-api) and [OtterLib](https://modrinth.com/mod/otterlib) is required to for the mod to load. -## Help localize Sit! on [Crowdin](https://crowdin.com/project/oth3r-sit)! -![overview](https://github.com/Oth3r/Sit/blob/master/media/overview.gif?raw=true) +### Help localize Sit! on [Crowdin](https://crowdin.com/project/oth3r-sit)! +Sit! is currently in English, Traditional Chinese, Italian, Brazilian Portuguese, and Turkish! Help expand this list via Crowdin so reach more people! ## Check out my other Projects! -[![Caligo badge](https://github.com/Oth3r/Caligo/blob/master/media/promo_badge.png?raw=true)](https://modrinth.com/mod/caligo) -[![DirectionHUD badge](https://github.com/Oth3r/DirectionHUD/blob/master/media/mod-badge.png?raw=true)](https://modrinth.com/mod/directionhud) -[![DirectionHUD Spigot badge](https://github.com/Oth3r/DirectionHUD/blob/master/media/plugin-badge.png?raw=true)](https://modrinth.com/plugin/directionhud-plugin) + + + Caligo badge + + + Directionhud badge + + + More Heart Types badge + # Features -### Hand Restrictions +### 🤚 Hand Restrictions Don't want to accidentally sit down? Set custom restrictions for each hand in the config! +\ +Use **player unique** hand restrictions when connecting to a `Sit!` server on a `Sit!` Client! -* Per player hand restrictions when connecting to a `Sit!` server on a `Sit!` Client! +per player hand restriction showcase -![hand restrictions](https://github.com/Oth3r/Sit/blob/master/media/hand-restrictions.gif?raw=true) +### 🟩 Custom Blocks +Want to sit on _**EVERY**_ block? With the config you can add more sitting options! +\ +With the new config system, block tags and custom blockstates can be used to mass select blocks at ease. -### Custom Blocks -Want to sit on _**EVERY**_ block? With the config you can add more options to sit on! Custom block states are also supported. +players sitting on a vast range of blocks -![custom blocks](https://github.com/Oth3r/Sit/blob/master/media/custom-blocks.gif?raw=true) +### ⌨️ Keybinds +Don't want to sit with the **just** the hand? Use a keybind or type a command to sit instead! -### Customizable Config -Configure to your hearts desire with the in-game config with **[ModMenu](https://modrinth.com/mod/modmenu)** & **[YetAnotherConfigLib](https://modrinth.com/mod/yacl)**, or use the provided config file for servers! +setting keybinds for the sit mod, and sitting by using them -![config](https://github.com/Oth3r/Sit/blob/master/media/config.gif?raw=true) -![custom blocks config](https://github.com/Oth3r/Sit/blob/master/media/custom-blocks-config.png?raw=true) +### 📃 Customizable Config +Don't like the default settings? Go wild in the config for yourself or your players! +the Sit! config wiki page ## Future Goals - * Forge Port (probably NeoForge 1.21) - * Custom dismounting logic - * better config (coming soon!) - * keybindings (next update) + * NeoForge Port + * Full config via [OtterLib](https://modrinth.com/mod/otterlib) From 6c02b090ac343ce3073271710a1225f0241f91ea Mon Sep 17 00:00:00 2001 From: Oth3r <68134921+Oth3r@users.noreply.github.com> Date: Sat, 14 Jun 2025 17:13:19 -0500 Subject: [PATCH 03/16] get the player's actual reach when checking sitting --- src/main/java/one/oth3r/sit/utl/Logic.java | 3 ++- src/main/java/one/oth3r/sit/utl/Utl.java | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main/java/one/oth3r/sit/utl/Logic.java b/src/main/java/one/oth3r/sit/utl/Logic.java index f07f822..b128b94 100644 --- a/src/main/java/one/oth3r/sit/utl/Logic.java +++ b/src/main/java/one/oth3r/sit/utl/Logic.java @@ -77,7 +77,8 @@ public class Logic { * @return true if sitting was successful */ public static boolean sitLooking(ServerPlayerEntity player) { - return sit(player, Utl.getBlockPosPlayerIsLookingAt(player.getServerWorld(),player,5),null); + return sit(player, Utl.getBlockPosPlayerIsLookingAt(player.getServerWorld(),player, + Utl.getPlayerReach(player)),null); } /** diff --git a/src/main/java/one/oth3r/sit/utl/Utl.java b/src/main/java/one/oth3r/sit/utl/Utl.java index ec16687..ea2fc19 100644 --- a/src/main/java/one/oth3r/sit/utl/Utl.java +++ b/src/main/java/one/oth3r/sit/utl/Utl.java @@ -10,6 +10,7 @@ import net.minecraft.block.*; import net.minecraft.block.enums.BlockHalf; import net.minecraft.block.enums.SlabType; import net.minecraft.entity.EntityType; +import net.minecraft.entity.attribute.EntityAttributes; import net.minecraft.entity.decoration.DisplayEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.BlockItem; @@ -482,4 +483,13 @@ public class Utl { return new BlockPos(player.getBlockPos()); } + + public static double getPlayerReach(PlayerEntity player) { + // use the BLOCK_INTERACTION_RANGE attribute if available + if (player.getAttributeInstance(EntityAttributes.BLOCK_INTERACTION_RANGE) != null) { + return player.getAttributeValue(EntityAttributes.BLOCK_INTERACTION_RANGE); + } + // fallback to 5 + return 5; + } } From e6eb46d7fa7ef5d9a26673b4cba75dd0bdc163e7 Mon Sep 17 00:00:00 2001 From: Oth3r <68134921+Oth3r@users.noreply.github.com> Date: Sat, 14 Jun 2025 17:41:08 -0500 Subject: [PATCH 04/16] lowercase locale --- .../workflows/crowdin-download-workflow.yml | 114 ++++++++++++++++-- .github/workflows/crowdin-upload-workflow.yml | 2 +- crowdin.yml | 2 +- .../java/one/oth3r/sit/file/ServerConfig.java | 11 +- .../sit-oth3r/lang/{en_US.json => en_us.json} | 0 5 files changed, 113 insertions(+), 16 deletions(-) rename src/main/resources/assets/sit-oth3r/lang/{en_US.json => en_us.json} (100%) diff --git a/.github/workflows/crowdin-download-workflow.yml b/.github/workflows/crowdin-download-workflow.yml index ddaec73..d09141d 100644 --- a/.github/workflows/crowdin-download-workflow.yml +++ b/.github/workflows/crowdin-download-workflow.yml @@ -3,31 +3,123 @@ name: Crowdin Download Action permissions: contents: write pull-requests: write - actions: read on: workflow_dispatch: + inputs: + localization_branch_name: + description: 'The branch to create for the translations PR.' + required: true + default: 'crowdin/translations' + pull_request_base_branch: + description: 'The base branch for the pull request.' + required: true + default: 'dev' jobs: - crowdin: + download-translations: runs-on: ubuntu-latest steps: - - name: Checkout + # Checkout the BASE branch first. The PR branch will be created later. + - name: Checkout Base Branch uses: actions/checkout@v4 + with: + ref: ${{ github.event.inputs.pull_request_base_branch }} - - name: Synchronize with Crowdin + - name: Configure Git User + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + + - name: Synchronize with Crowdin (Download Only) uses: crowdin/github-action@v2 with: upload_sources: false upload_translations: false download_translations: true - localization_branch_name: crowdin_translations - - create_pull_request: true - pull_request_title: 'Updated Crowdin translations' - pull_request_body: 'New Crowdin pull request with translations' - pull_request_base_branch_name: 'dev' + create_pull_request: false + localization_branch_name: ${{ github.event.inputs.localization_branch_name }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }} - CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }} \ No newline at end of file + CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }} + + rename-files: + needs: download-translations + runs-on: ubuntu-latest + steps: + - name: Checkout Localization Branch + uses: actions/checkout@v4 + with: + ref: ${{ github.event.inputs.localization_branch_name }} + + - name: Configure Git User + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + + - name: Rename JSON Files to Lowercase + env: + TARGET_DIR: "common/src/main/resources/assets/directionhud/lang/" + run: | + echo "Starting renaming process for JSON files within $TARGET_DIR..." + if [ ! -d "$TARGET_DIR" ]; then + echo "Warning: Target directory '$TARGET_DIR' does not exist. Skipping rename." + exit 0 + fi + find "$TARGET_DIR" -type f -name '*[A-Z]*.json' | while IFS= read -r file; do + original_path="$file" + dir_name=$(dirname "$original_path") + base_name=$(basename "$original_path") + new_base_name=$(echo "$base_name" | tr '[:upper:]' '[:lower:]') + new_path="$dir_name/$new_base_name" + if [ "$original_path" != "$new_path" ]; then + if [ -e "$new_path" ] && [ ! "$(readlink -f "$original_path")" = "$(readlink -f "$new_path")" ]; then + echo "::warning file=$original_path::Cannot rename '$original_path' to '$new_path' because it already exists. Skipping." + else + git mv "$original_path" "$new_path" + fi + fi + done + echo "JSON file renaming complete." + + - name: Commit Renamed Files + run: | + echo "Committing renamed files..." + git add -A + git commit -m "Rename JSON translation files to lowercase for consistency" + echo "Renames committed." + + - name: Push Changes to Localization Branch + run: | + echo "Pushing combined changes to ${{ github.event.inputs.localization_branch_name }}..." + git push origin ${{ github.event.inputs.localization_branch_name }} + + create-pr: + needs: [ download-translations, rename-files ] + runs-on: ubuntu-latest + steps: + - name: Checkout branch + uses: actions/checkout@v4 + with: + ref: ${{ github.event.inputs.localization_branch_name }} + + - name: Set up Git config + run: | + git config user.name "github-actions" + git config user.email "github-actions@github.com" + + - name: Install GitHub CLI + run: sudo apt-get install gh -y + + - name: Authenticate GitHub CLI + run: echo "${{ secrets.GITHUB_TOKEN }}" | gh auth login --with-token + + - name: Create Pull Request + run: | + gh pr create \ + --title "Update translations from Crowdin" \ + --body "This PR includes:\n- New translations from Crowdin\n- Renamed translation files to lowercase" \ + --head ${{ github.event.inputs.localization_branch_name }} \ + --base ${{ github.event.inputs.pull_request_base_branch }} \ + --label "localization" \ No newline at end of file diff --git a/.github/workflows/crowdin-upload-workflow.yml b/.github/workflows/crowdin-upload-workflow.yml index fe9194b..5516194 100644 --- a/.github/workflows/crowdin-upload-workflow.yml +++ b/.github/workflows/crowdin-upload-workflow.yml @@ -2,7 +2,7 @@ name: Crowdin Upload Action on: push: - paths: [ "src/main/resources/assets/sit-oth3r/lang/en_US.json"] + paths: [ "src/main/resources/assets/sit-oth3r/lang/en_us.json"] branches: [ dev ] workflow_dispatch: diff --git a/crowdin.yml b/crowdin.yml index 352acbc..bb81024 100644 --- a/crowdin.yml +++ b/crowdin.yml @@ -6,7 +6,7 @@ files: [ { - "source": "src/main/resources/assets/sit-oth3r/lang/en_US.json", + "source": "src/main/resources/assets/sit-oth3r/lang/en_us.json", "translation": "src/main/resources/assets/sit-oth3r/lang/%locale_with_underscore%.json", } ] \ No newline at end of file diff --git a/src/main/java/one/oth3r/sit/file/ServerConfig.java b/src/main/java/one/oth3r/sit/file/ServerConfig.java index e4bcccf..f4cd25e 100644 --- a/src/main/java/one/oth3r/sit/file/ServerConfig.java +++ b/src/main/java/one/oth3r/sit/file/ServerConfig.java @@ -27,12 +27,12 @@ import java.util.stream.Collectors; public class ServerConfig implements CustomFile { @SerializedName("version") - private Double version = 2.2; + private Double version = 2.3; @SerializedName("lang") - private String lang = "en_US"; + private String lang = "en_us"; @SerializedName("lang-options") - private final String langOptions = "en_US, it_IT, pt_BR, tr_TR, zh_TW, zh_CH, de_DE"; + private final String langOptions = "en_us, it_it, pt_br, tr_tr, zh_tw, zh_ch, de_de"; @SerializedName("keep-active") private Boolean keepActive = true; @@ -276,6 +276,11 @@ public class ServerConfig implements CustomFile { if (version >= 2.0 && version <= 2.1) { version = 2.2; } + if (version == 2.2) { + // make sure that the lang is all lowercase + version = 2.3; + this.lang = this.lang.substring(0,3)+this.lang.substring(3).toLowerCase(); + } } @Override diff --git a/src/main/resources/assets/sit-oth3r/lang/en_US.json b/src/main/resources/assets/sit-oth3r/lang/en_us.json similarity index 100% rename from src/main/resources/assets/sit-oth3r/lang/en_US.json rename to src/main/resources/assets/sit-oth3r/lang/en_us.json From dea8b5af3ebf3a5eca4c03d485d92e288630010d Mon Sep 17 00:00:00 2001 From: Oth3r <68134921+Oth3r@users.noreply.github.com> Date: Sat, 14 Jun 2025 17:48:17 -0500 Subject: [PATCH 05/16] fix target directory --- .github/workflows/crowdin-download-workflow.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/crowdin-download-workflow.yml b/.github/workflows/crowdin-download-workflow.yml index d09141d..b769f5f 100644 --- a/.github/workflows/crowdin-download-workflow.yml +++ b/.github/workflows/crowdin-download-workflow.yml @@ -60,7 +60,7 @@ jobs: - name: Rename JSON Files to Lowercase env: - TARGET_DIR: "common/src/main/resources/assets/directionhud/lang/" + TARGET_DIR: "src/main/resources/assets/sit-oth3r/lang/" run: | echo "Starting renaming process for JSON files within $TARGET_DIR..." if [ ! -d "$TARGET_DIR" ]; then From 235a0a61dbd5f6fd83dc8b92d1d63dfd33b82e7f Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sat, 14 Jun 2025 22:49:21 +0000 Subject: [PATCH 06/16] New Crowdin translations by GitHub Action --- src/main/resources/assets/sit-oth3r/lang/de_DE.json | 5 ----- src/main/resources/assets/sit-oth3r/lang/es_ES.json | 5 ----- src/main/resources/assets/sit-oth3r/lang/fr_FR.json | 5 ----- src/main/resources/assets/sit-oth3r/lang/it_IT.json | 5 ----- src/main/resources/assets/sit-oth3r/lang/pl_PL.json | 5 ----- src/main/resources/assets/sit-oth3r/lang/pt_BR.json | 5 ----- src/main/resources/assets/sit-oth3r/lang/pt_PT.json | 5 ----- src/main/resources/assets/sit-oth3r/lang/ru_RU.json | 5 ----- src/main/resources/assets/sit-oth3r/lang/tr_TR.json | 5 ----- src/main/resources/assets/sit-oth3r/lang/zh_CN.json | 5 ----- src/main/resources/assets/sit-oth3r/lang/zh_TW.json | 5 ----- 11 files changed, 55 deletions(-) diff --git a/src/main/resources/assets/sit-oth3r/lang/de_DE.json b/src/main/resources/assets/sit-oth3r/lang/de_DE.json index f0abba5..bc70ce4 100644 --- a/src/main/resources/assets/sit-oth3r/lang/de_DE.json +++ b/src/main/resources/assets/sit-oth3r/lang/de_DE.json @@ -68,13 +68,8 @@ "key.sit!.sit": "Sitzen", "key.sit!.config": "Konfiguration öffnen", "sit!.screen.config": "Sit! Konfiguration", - "sit!.gui.button.file": "Datei öffnen", - "sit!.gui.button.folder": "Ordner öffnen", - "sit!.gui.button.reset": "Zurücksetzen", "sit!.gui.button.issues": "Probleme", "sit!.gui.button.donate": "Spenden", - "sit!.gui.button.revert": "Änderungen rückgängig machen", - "sit!.gui.button.save": "Speichern und schließen", "sit!.gui.button.website": "Website", "sit!.console.connected": "Verbunden mit Sit! Server: %s", "sit!.console.player_settings": "Benutzerdefinierte Sitzungseinstellungen von %s erhalten!", diff --git a/src/main/resources/assets/sit-oth3r/lang/es_ES.json b/src/main/resources/assets/sit-oth3r/lang/es_ES.json index 4717b63..5edca97 100644 --- a/src/main/resources/assets/sit-oth3r/lang/es_ES.json +++ b/src/main/resources/assets/sit-oth3r/lang/es_ES.json @@ -68,13 +68,8 @@ "key.sit!.sit": "Sentarse", "key.sit!.config": "Abrir configuración", "sit!.screen.config": "Configuracion de Sit!", - "sit!.gui.button.file": "Abrir Archivo", - "sit!.gui.button.folder": "Abrir Carpeta", - "sit!.gui.button.reset": "Reiniciar", "sit!.gui.button.issues": "Problemas", "sit!.gui.button.donate": "Donar", - "sit!.gui.button.revert": "Revertir cambios", - "sit!.gui.button.save": "Guardar y salir", "sit!.gui.button.website": "Sitio web ", "sit!.console.player_settings": "¡Se recibió configuraciones personalizadas dé %s!", "modmenu.descriptionTranslation.sit-oth3r": "¡Añade la capacidad de sentarse a Minecraft! Configuración extensa para restricciones de mano y bloques sentables.\n ¡Los jugadores pueden tener su propia configuración cuando usan Sit! del lado del cliente en un servidor!" diff --git a/src/main/resources/assets/sit-oth3r/lang/fr_FR.json b/src/main/resources/assets/sit-oth3r/lang/fr_FR.json index 4c0a8cb..58935b5 100644 --- a/src/main/resources/assets/sit-oth3r/lang/fr_FR.json +++ b/src/main/resources/assets/sit-oth3r/lang/fr_FR.json @@ -68,13 +68,8 @@ "key.sit!.sit": "S'asseoir", "key.sit!.config": "Ouvrir la configuration", "sit!.screen.config": "Sit! Config", - "sit!.gui.button.file": "Ouvrir le fichier", - "sit!.gui.button.folder": "Ouvrir le dossier", - "sit!.gui.button.reset": "Restaurer", "sit!.gui.button.issues": "Problèmes", "sit!.gui.button.donate": "Faire un don", - "sit!.gui.button.revert": "Annuler les modifications", - "sit!.gui.button.save": "Enregistrer et fermer", "sit!.gui.button.website": "Site web", "sit!.console.connected": "Connecté au serveur Sit! : %s", "sit!.console.player_settings": "Reçu les paramètres de séance personnalisés de %s!", diff --git a/src/main/resources/assets/sit-oth3r/lang/it_IT.json b/src/main/resources/assets/sit-oth3r/lang/it_IT.json index 68ef576..00af775 100644 --- a/src/main/resources/assets/sit-oth3r/lang/it_IT.json +++ b/src/main/resources/assets/sit-oth3r/lang/it_IT.json @@ -68,13 +68,8 @@ "key.sit!.sit": "Siediti", "key.sit!.config": "Apri Impostazioni", "sit!.screen.config": "Impostazioni Sit!", - "sit!.gui.button.file": "Apri File", - "sit!.gui.button.folder": "Apri Cartella", - "sit!.gui.button.reset": "Resetta", "sit!.gui.button.issues": "Problemi", "sit!.gui.button.donate": "Dona", - "sit!.gui.button.revert": "Annulla i Cambiamenti", - "sit!.gui.button.save": "Salva ed Esci", "sit!.gui.button.website": "Sito Web", "sit!.console.connected": "Connesso al server Sit!: %s", "sit!.console.player_settings": "Ricevute impostazioni custom da %s!", diff --git a/src/main/resources/assets/sit-oth3r/lang/pl_PL.json b/src/main/resources/assets/sit-oth3r/lang/pl_PL.json index 4319acb..435432e 100644 --- a/src/main/resources/assets/sit-oth3r/lang/pl_PL.json +++ b/src/main/resources/assets/sit-oth3r/lang/pl_PL.json @@ -44,12 +44,7 @@ "key.sit!.toggle": "Przełącz możliwość siadania", "key.sit!.config": "Otwórz ustawienia", "sit!.screen.config": "Konfiguracja Sit!", - "sit!.gui.button.file": "Otwórz plik", - "sit!.gui.button.folder": "Otwórz folder", - "sit!.gui.button.reset": "Reset", "sit!.gui.button.donate": "Wesprzyj", - "sit!.gui.button.revert": "Cofnij zmiany", - "sit!.gui.button.save": "Zapisz i zamknij", "sit!.gui.button.website": "Strona", "sit!.console.connected": "Połączono z serwerem wspierającym Sit!: %s", "sit!.console.player_settings": "Otrzymano niestandardowe ustawienia z: %s!", diff --git a/src/main/resources/assets/sit-oth3r/lang/pt_BR.json b/src/main/resources/assets/sit-oth3r/lang/pt_BR.json index 986ada9..0977922 100644 --- a/src/main/resources/assets/sit-oth3r/lang/pt_BR.json +++ b/src/main/resources/assets/sit-oth3r/lang/pt_BR.json @@ -68,13 +68,8 @@ "key.sit!.sit": "Sentar", "key.sit!.config": "Abrir Configuração", "sit!.screen.config": "Configuração do Sit!", - "sit!.gui.button.file": "Abrir Arquivo", - "sit!.gui.button.folder": "Abrir Pasta", - "sit!.gui.button.reset": "Reiniciar", "sit!.gui.button.issues": "Problemas", "sit!.gui.button.donate": "Doar", - "sit!.gui.button.revert": "Reverter Alterações", - "sit!.gui.button.save": "Salvar e Fechar", "sit!.gui.button.website": "Website", "sit!.console.connected": "Conectado ao servidor Sit!: %s", "sit!.console.player_settings": "Recebidas configurações de sentar personalizadas de %s!", diff --git a/src/main/resources/assets/sit-oth3r/lang/pt_PT.json b/src/main/resources/assets/sit-oth3r/lang/pt_PT.json index 2dac62c..4846cb2 100644 --- a/src/main/resources/assets/sit-oth3r/lang/pt_PT.json +++ b/src/main/resources/assets/sit-oth3r/lang/pt_PT.json @@ -68,13 +68,8 @@ "key.sit!.sit": "Sentar", "key.sit!.config": "Abrir definições", "sit!.screen.config": "Definições do Sit!", - "sit!.gui.button.file": "Abrir ficheiro", - "sit!.gui.button.folder": "Abrir pasta", - "sit!.gui.button.reset": "Repor", "sit!.gui.button.issues": "Problemas", "sit!.gui.button.donate": "Doar", - "sit!.gui.button.revert": "Reverter alterações", - "sit!.gui.button.save": "Guardar e fechar", "sit!.gui.button.website": "Website", "sit!.console.connected": "Conectado ao servidor Sit!: %s", "sit!.console.player_settings": "Recebidas definições de sentar personalizadas de %s!", diff --git a/src/main/resources/assets/sit-oth3r/lang/ru_RU.json b/src/main/resources/assets/sit-oth3r/lang/ru_RU.json index 9179bbe..e8966ed 100644 --- a/src/main/resources/assets/sit-oth3r/lang/ru_RU.json +++ b/src/main/resources/assets/sit-oth3r/lang/ru_RU.json @@ -68,13 +68,8 @@ "key.sit!.sit": "Сесть", "key.sit!.config": "Открыть Конфигурацию", "sit!.screen.config": "Конфигурация Sit!", - "sit!.gui.button.file": "Открыть Файл", - "sit!.gui.button.folder": "Открыть Папку", - "sit!.gui.button.reset": "Сбросить", "sit!.gui.button.issues": "Баг‑трекер", "sit!.gui.button.donate": "Пожертвовать", - "sit!.gui.button.revert": "Отменить Изменения", - "sit!.gui.button.save": "Сохранить и Закрыть", "sit!.gui.button.website": "Веб-сайт", "sit!.console.connected": "Подключено к серверу Sit!: %s", "sit!.console.player_settings": "Получены пользовательские настройки сидения от %s!", diff --git a/src/main/resources/assets/sit-oth3r/lang/tr_TR.json b/src/main/resources/assets/sit-oth3r/lang/tr_TR.json index cd040d7..71b066a 100644 --- a/src/main/resources/assets/sit-oth3r/lang/tr_TR.json +++ b/src/main/resources/assets/sit-oth3r/lang/tr_TR.json @@ -68,13 +68,8 @@ "key.sit!.sit": "Otur", "key.sit!.config": "Ayarlandırmaları aç", "sit!.screen.config": "Sit! Ayarlandırmaları", - "sit!.gui.button.file": "Dosya Aç", - "sit!.gui.button.folder": "Klasörü Aç", - "sit!.gui.button.reset": "Sıfırla", "sit!.gui.button.issues": "Sorunlar", "sit!.gui.button.donate": "Bağış yap", - "sit!.gui.button.revert": "Değişiklikleri Geri Al", - "sit!.gui.button.save": "Kaydet ve Kapat", "sit!.gui.button.website": "İnternet Sitesi", "sit!.console.connected": "Sit! sunucusuna bağlanıldı: %s", "sit!.console.player_settings": "Özel oturma ayarları %s alındı!", diff --git a/src/main/resources/assets/sit-oth3r/lang/zh_CN.json b/src/main/resources/assets/sit-oth3r/lang/zh_CN.json index 195ed43..64c58e3 100644 --- a/src/main/resources/assets/sit-oth3r/lang/zh_CN.json +++ b/src/main/resources/assets/sit-oth3r/lang/zh_CN.json @@ -68,13 +68,8 @@ "key.sit!.sit": "坐下", "key.sit!.config": "打开配置", "sit!.screen.config": "Sit! 配置", - "sit!.gui.button.file": "打开文件", - "sit!.gui.button.folder": "打开文件夹", - "sit!.gui.button.reset": "重置", "sit!.gui.button.issues": "问题反馈", "sit!.gui.button.donate": "赞助", - "sit!.gui.button.revert": "还原更改", - "sit!.gui.button.save": "保存并关闭", "sit!.gui.button.website": "网站", "sit!.console.connected": "已连接到 Sit! 服务器: %s", "sit!.console.player_settings": "已从 %s 获得自定义坐下设置。", diff --git a/src/main/resources/assets/sit-oth3r/lang/zh_TW.json b/src/main/resources/assets/sit-oth3r/lang/zh_TW.json index d114075..9b235e8 100644 --- a/src/main/resources/assets/sit-oth3r/lang/zh_TW.json +++ b/src/main/resources/assets/sit-oth3r/lang/zh_TW.json @@ -68,13 +68,8 @@ "key.sit!.sit": "坐下", "key.sit!.config": "開啟設定", "sit!.screen.config": "坐下! 設定", - "sit!.gui.button.file": "開啟檔案", - "sit!.gui.button.folder": "開啟資料夾", - "sit!.gui.button.reset": "重置", "sit!.gui.button.issues": "問題", "sit!.gui.button.donate": "贊助", - "sit!.gui.button.revert": "還原變更", - "sit!.gui.button.save": "儲存並關閉", "sit!.gui.button.website": "網站", "sit!.console.connected": "已連線至 Sit! 伺服器: %s", "sit!.console.player_settings": "已從 %s 收到自訂坐下設定!", From cfcf68f463b0f08f9a4c4c0fbbb125ad07e266a1 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sat, 14 Jun 2025 22:49:33 +0000 Subject: [PATCH 07/16] Rename JSON translation files to lowercase for consistency --- .../resources/assets/sit-oth3r/lang/{ar_SA.json => ar_sa.json} | 0 .../resources/assets/sit-oth3r/lang/{bg_BG.json => bg_bg.json} | 0 .../resources/assets/sit-oth3r/lang/{cs_CZ.json => cs_cz.json} | 0 .../resources/assets/sit-oth3r/lang/{da_DK.json => da_dk.json} | 0 .../resources/assets/sit-oth3r/lang/{de_DE.json => de_de.json} | 0 .../resources/assets/sit-oth3r/lang/{el_GR.json => el_gr.json} | 0 .../resources/assets/sit-oth3r/lang/{es_ES.json => es_es.json} | 0 .../resources/assets/sit-oth3r/lang/{es_MX.json => es_mx.json} | 0 .../resources/assets/sit-oth3r/lang/{fi_FI.json => fi_fi.json} | 0 .../resources/assets/sit-oth3r/lang/{fr_FR.json => fr_fr.json} | 0 .../resources/assets/sit-oth3r/lang/{ga_IE.json => ga_ie.json} | 0 .../resources/assets/sit-oth3r/lang/{he_IL.json => he_il.json} | 0 .../resources/assets/sit-oth3r/lang/{hu_HU.json => hu_hu.json} | 0 .../resources/assets/sit-oth3r/lang/{it_IT.json => it_it.json} | 0 .../resources/assets/sit-oth3r/lang/{ja_JP.json => ja_jp.json} | 0 .../resources/assets/sit-oth3r/lang/{ko_KR.json => ko_kr.json} | 0 .../resources/assets/sit-oth3r/lang/{nl_NL.json => nl_nl.json} | 0 .../resources/assets/sit-oth3r/lang/{pl_PL.json => pl_pl.json} | 0 .../resources/assets/sit-oth3r/lang/{pt_BR.json => pt_br.json} | 0 .../resources/assets/sit-oth3r/lang/{pt_PT.json => pt_pt.json} | 0 .../resources/assets/sit-oth3r/lang/{ro_RO.json => ro_ro.json} | 0 .../resources/assets/sit-oth3r/lang/{ru_RU.json => ru_ru.json} | 0 .../resources/assets/sit-oth3r/lang/{sr_SP.json => sr_sp.json} | 0 .../resources/assets/sit-oth3r/lang/{sv_SE.json => sv_se.json} | 0 .../resources/assets/sit-oth3r/lang/{tr_TR.json => tr_tr.json} | 0 .../resources/assets/sit-oth3r/lang/{uk_UA.json => uk_ua.json} | 0 .../resources/assets/sit-oth3r/lang/{vi_VN.json => vi_vn.json} | 0 .../resources/assets/sit-oth3r/lang/{zh_CN.json => zh_cn.json} | 0 .../resources/assets/sit-oth3r/lang/{zh_TW.json => zh_tw.json} | 0 29 files changed, 0 insertions(+), 0 deletions(-) rename src/main/resources/assets/sit-oth3r/lang/{ar_SA.json => ar_sa.json} (100%) rename src/main/resources/assets/sit-oth3r/lang/{bg_BG.json => bg_bg.json} (100%) rename src/main/resources/assets/sit-oth3r/lang/{cs_CZ.json => cs_cz.json} (100%) rename src/main/resources/assets/sit-oth3r/lang/{da_DK.json => da_dk.json} (100%) rename src/main/resources/assets/sit-oth3r/lang/{de_DE.json => de_de.json} (100%) rename src/main/resources/assets/sit-oth3r/lang/{el_GR.json => el_gr.json} (100%) rename src/main/resources/assets/sit-oth3r/lang/{es_ES.json => es_es.json} (100%) rename src/main/resources/assets/sit-oth3r/lang/{es_MX.json => es_mx.json} (100%) rename src/main/resources/assets/sit-oth3r/lang/{fi_FI.json => fi_fi.json} (100%) rename src/main/resources/assets/sit-oth3r/lang/{fr_FR.json => fr_fr.json} (100%) rename src/main/resources/assets/sit-oth3r/lang/{ga_IE.json => ga_ie.json} (100%) rename src/main/resources/assets/sit-oth3r/lang/{he_IL.json => he_il.json} (100%) rename src/main/resources/assets/sit-oth3r/lang/{hu_HU.json => hu_hu.json} (100%) rename src/main/resources/assets/sit-oth3r/lang/{it_IT.json => it_it.json} (100%) rename src/main/resources/assets/sit-oth3r/lang/{ja_JP.json => ja_jp.json} (100%) rename src/main/resources/assets/sit-oth3r/lang/{ko_KR.json => ko_kr.json} (100%) rename src/main/resources/assets/sit-oth3r/lang/{nl_NL.json => nl_nl.json} (100%) rename src/main/resources/assets/sit-oth3r/lang/{pl_PL.json => pl_pl.json} (100%) rename src/main/resources/assets/sit-oth3r/lang/{pt_BR.json => pt_br.json} (100%) rename src/main/resources/assets/sit-oth3r/lang/{pt_PT.json => pt_pt.json} (100%) rename src/main/resources/assets/sit-oth3r/lang/{ro_RO.json => ro_ro.json} (100%) rename src/main/resources/assets/sit-oth3r/lang/{ru_RU.json => ru_ru.json} (100%) rename src/main/resources/assets/sit-oth3r/lang/{sr_SP.json => sr_sp.json} (100%) rename src/main/resources/assets/sit-oth3r/lang/{sv_SE.json => sv_se.json} (100%) rename src/main/resources/assets/sit-oth3r/lang/{tr_TR.json => tr_tr.json} (100%) rename src/main/resources/assets/sit-oth3r/lang/{uk_UA.json => uk_ua.json} (100%) rename src/main/resources/assets/sit-oth3r/lang/{vi_VN.json => vi_vn.json} (100%) rename src/main/resources/assets/sit-oth3r/lang/{zh_CN.json => zh_cn.json} (100%) rename src/main/resources/assets/sit-oth3r/lang/{zh_TW.json => zh_tw.json} (100%) diff --git a/src/main/resources/assets/sit-oth3r/lang/ar_SA.json b/src/main/resources/assets/sit-oth3r/lang/ar_sa.json similarity index 100% rename from src/main/resources/assets/sit-oth3r/lang/ar_SA.json rename to src/main/resources/assets/sit-oth3r/lang/ar_sa.json diff --git a/src/main/resources/assets/sit-oth3r/lang/bg_BG.json b/src/main/resources/assets/sit-oth3r/lang/bg_bg.json similarity index 100% rename from src/main/resources/assets/sit-oth3r/lang/bg_BG.json rename to src/main/resources/assets/sit-oth3r/lang/bg_bg.json diff --git a/src/main/resources/assets/sit-oth3r/lang/cs_CZ.json b/src/main/resources/assets/sit-oth3r/lang/cs_cz.json similarity index 100% rename from src/main/resources/assets/sit-oth3r/lang/cs_CZ.json rename to src/main/resources/assets/sit-oth3r/lang/cs_cz.json diff --git a/src/main/resources/assets/sit-oth3r/lang/da_DK.json b/src/main/resources/assets/sit-oth3r/lang/da_dk.json similarity index 100% rename from src/main/resources/assets/sit-oth3r/lang/da_DK.json rename to src/main/resources/assets/sit-oth3r/lang/da_dk.json diff --git a/src/main/resources/assets/sit-oth3r/lang/de_DE.json b/src/main/resources/assets/sit-oth3r/lang/de_de.json similarity index 100% rename from src/main/resources/assets/sit-oth3r/lang/de_DE.json rename to src/main/resources/assets/sit-oth3r/lang/de_de.json diff --git a/src/main/resources/assets/sit-oth3r/lang/el_GR.json b/src/main/resources/assets/sit-oth3r/lang/el_gr.json similarity index 100% rename from src/main/resources/assets/sit-oth3r/lang/el_GR.json rename to src/main/resources/assets/sit-oth3r/lang/el_gr.json diff --git a/src/main/resources/assets/sit-oth3r/lang/es_ES.json b/src/main/resources/assets/sit-oth3r/lang/es_es.json similarity index 100% rename from src/main/resources/assets/sit-oth3r/lang/es_ES.json rename to src/main/resources/assets/sit-oth3r/lang/es_es.json diff --git a/src/main/resources/assets/sit-oth3r/lang/es_MX.json b/src/main/resources/assets/sit-oth3r/lang/es_mx.json similarity index 100% rename from src/main/resources/assets/sit-oth3r/lang/es_MX.json rename to src/main/resources/assets/sit-oth3r/lang/es_mx.json diff --git a/src/main/resources/assets/sit-oth3r/lang/fi_FI.json b/src/main/resources/assets/sit-oth3r/lang/fi_fi.json similarity index 100% rename from src/main/resources/assets/sit-oth3r/lang/fi_FI.json rename to src/main/resources/assets/sit-oth3r/lang/fi_fi.json diff --git a/src/main/resources/assets/sit-oth3r/lang/fr_FR.json b/src/main/resources/assets/sit-oth3r/lang/fr_fr.json similarity index 100% rename from src/main/resources/assets/sit-oth3r/lang/fr_FR.json rename to src/main/resources/assets/sit-oth3r/lang/fr_fr.json diff --git a/src/main/resources/assets/sit-oth3r/lang/ga_IE.json b/src/main/resources/assets/sit-oth3r/lang/ga_ie.json similarity index 100% rename from src/main/resources/assets/sit-oth3r/lang/ga_IE.json rename to src/main/resources/assets/sit-oth3r/lang/ga_ie.json diff --git a/src/main/resources/assets/sit-oth3r/lang/he_IL.json b/src/main/resources/assets/sit-oth3r/lang/he_il.json similarity index 100% rename from src/main/resources/assets/sit-oth3r/lang/he_IL.json rename to src/main/resources/assets/sit-oth3r/lang/he_il.json diff --git a/src/main/resources/assets/sit-oth3r/lang/hu_HU.json b/src/main/resources/assets/sit-oth3r/lang/hu_hu.json similarity index 100% rename from src/main/resources/assets/sit-oth3r/lang/hu_HU.json rename to src/main/resources/assets/sit-oth3r/lang/hu_hu.json diff --git a/src/main/resources/assets/sit-oth3r/lang/it_IT.json b/src/main/resources/assets/sit-oth3r/lang/it_it.json similarity index 100% rename from src/main/resources/assets/sit-oth3r/lang/it_IT.json rename to src/main/resources/assets/sit-oth3r/lang/it_it.json diff --git a/src/main/resources/assets/sit-oth3r/lang/ja_JP.json b/src/main/resources/assets/sit-oth3r/lang/ja_jp.json similarity index 100% rename from src/main/resources/assets/sit-oth3r/lang/ja_JP.json rename to src/main/resources/assets/sit-oth3r/lang/ja_jp.json diff --git a/src/main/resources/assets/sit-oth3r/lang/ko_KR.json b/src/main/resources/assets/sit-oth3r/lang/ko_kr.json similarity index 100% rename from src/main/resources/assets/sit-oth3r/lang/ko_KR.json rename to src/main/resources/assets/sit-oth3r/lang/ko_kr.json diff --git a/src/main/resources/assets/sit-oth3r/lang/nl_NL.json b/src/main/resources/assets/sit-oth3r/lang/nl_nl.json similarity index 100% rename from src/main/resources/assets/sit-oth3r/lang/nl_NL.json rename to src/main/resources/assets/sit-oth3r/lang/nl_nl.json diff --git a/src/main/resources/assets/sit-oth3r/lang/pl_PL.json b/src/main/resources/assets/sit-oth3r/lang/pl_pl.json similarity index 100% rename from src/main/resources/assets/sit-oth3r/lang/pl_PL.json rename to src/main/resources/assets/sit-oth3r/lang/pl_pl.json diff --git a/src/main/resources/assets/sit-oth3r/lang/pt_BR.json b/src/main/resources/assets/sit-oth3r/lang/pt_br.json similarity index 100% rename from src/main/resources/assets/sit-oth3r/lang/pt_BR.json rename to src/main/resources/assets/sit-oth3r/lang/pt_br.json diff --git a/src/main/resources/assets/sit-oth3r/lang/pt_PT.json b/src/main/resources/assets/sit-oth3r/lang/pt_pt.json similarity index 100% rename from src/main/resources/assets/sit-oth3r/lang/pt_PT.json rename to src/main/resources/assets/sit-oth3r/lang/pt_pt.json diff --git a/src/main/resources/assets/sit-oth3r/lang/ro_RO.json b/src/main/resources/assets/sit-oth3r/lang/ro_ro.json similarity index 100% rename from src/main/resources/assets/sit-oth3r/lang/ro_RO.json rename to src/main/resources/assets/sit-oth3r/lang/ro_ro.json diff --git a/src/main/resources/assets/sit-oth3r/lang/ru_RU.json b/src/main/resources/assets/sit-oth3r/lang/ru_ru.json similarity index 100% rename from src/main/resources/assets/sit-oth3r/lang/ru_RU.json rename to src/main/resources/assets/sit-oth3r/lang/ru_ru.json diff --git a/src/main/resources/assets/sit-oth3r/lang/sr_SP.json b/src/main/resources/assets/sit-oth3r/lang/sr_sp.json similarity index 100% rename from src/main/resources/assets/sit-oth3r/lang/sr_SP.json rename to src/main/resources/assets/sit-oth3r/lang/sr_sp.json diff --git a/src/main/resources/assets/sit-oth3r/lang/sv_SE.json b/src/main/resources/assets/sit-oth3r/lang/sv_se.json similarity index 100% rename from src/main/resources/assets/sit-oth3r/lang/sv_SE.json rename to src/main/resources/assets/sit-oth3r/lang/sv_se.json diff --git a/src/main/resources/assets/sit-oth3r/lang/tr_TR.json b/src/main/resources/assets/sit-oth3r/lang/tr_tr.json similarity index 100% rename from src/main/resources/assets/sit-oth3r/lang/tr_TR.json rename to src/main/resources/assets/sit-oth3r/lang/tr_tr.json diff --git a/src/main/resources/assets/sit-oth3r/lang/uk_UA.json b/src/main/resources/assets/sit-oth3r/lang/uk_ua.json similarity index 100% rename from src/main/resources/assets/sit-oth3r/lang/uk_UA.json rename to src/main/resources/assets/sit-oth3r/lang/uk_ua.json diff --git a/src/main/resources/assets/sit-oth3r/lang/vi_VN.json b/src/main/resources/assets/sit-oth3r/lang/vi_vn.json similarity index 100% rename from src/main/resources/assets/sit-oth3r/lang/vi_VN.json rename to src/main/resources/assets/sit-oth3r/lang/vi_vn.json diff --git a/src/main/resources/assets/sit-oth3r/lang/zh_CN.json b/src/main/resources/assets/sit-oth3r/lang/zh_cn.json similarity index 100% rename from src/main/resources/assets/sit-oth3r/lang/zh_CN.json rename to src/main/resources/assets/sit-oth3r/lang/zh_cn.json diff --git a/src/main/resources/assets/sit-oth3r/lang/zh_TW.json b/src/main/resources/assets/sit-oth3r/lang/zh_tw.json similarity index 100% rename from src/main/resources/assets/sit-oth3r/lang/zh_TW.json rename to src/main/resources/assets/sit-oth3r/lang/zh_tw.json From 2eb69521446ae3f867313417044b319bbabaa85e Mon Sep 17 00:00:00 2001 From: Oth3r <68134921+Oth3r@users.noreply.github.com> Date: Sat, 14 Jun 2025 18:47:51 -0500 Subject: [PATCH 08/16] fix not(!) tag check logic --- .../java/one/oth3r/sit/file/CustomBlock.java | 24 ++++++++++++------- .../java/one/oth3r/sit/file/CustomItem.java | 21 +++++++++------- 2 files changed, 29 insertions(+), 16 deletions(-) diff --git a/src/main/java/one/oth3r/sit/file/CustomBlock.java b/src/main/java/one/oth3r/sit/file/CustomBlock.java index 0f17147..4940f70 100644 --- a/src/main/java/one/oth3r/sit/file/CustomBlock.java +++ b/src/main/java/one/oth3r/sit/file/CustomBlock.java @@ -91,19 +91,27 @@ public class CustomBlock { } // a boolean to check if one of the blocks are in a filtered tag - boolean tagCheck = false; + // & a switch for if there is only not(!) tags + boolean tagCheck = false, hasPositiveTags = false; - // for all the entered tags for (String tag : blockTags) { // substring to remove # and if needed, ! - // if there is a math for the NOT(!) tag, return false - if (tag.startsWith("!") && blockState.isIn(TagKey.of(Registries.BLOCK.getKey(), Identifier.of(tag.substring(2))))) return false; - // if there is a match, return true - if (blockState.isIn(TagKey.of(Registries.BLOCK.getKey(), Identifier.tryParse(tag.substring(1))))) tagCheck = true; + if (tag.startsWith("!")) { + // if there is a match for the NOT(!) tag, return false + Identifier id = Identifier.tryParse(tag.substring(2)); + if (id != null && blockState.isIn(TagKey.of(Registries.BLOCK.getKey(), id))) return false; + } else { + // flip the hasPositiveTags boolean + hasPositiveTags = true; + // if there is a match, return true + Identifier id = Identifier.tryParse(tag.substring(1)); + if (id != null && blockState.isIn(TagKey.of(Registries.BLOCK.getKey(), id))) tagCheck = true; + } } - // not returning true in the loop because there might be a (!) not tag that the block might fall into, after the block was already in another tag - return tagCheck; + // if there were any required tags, return whether we matched one + // if there were only not(!) tags, and we didn't violate any, return true + return hasPositiveTags? tagCheck : true; } @Override diff --git a/src/main/java/one/oth3r/sit/file/CustomItem.java b/src/main/java/one/oth3r/sit/file/CustomItem.java index 325fe19..4e4680d 100644 --- a/src/main/java/one/oth3r/sit/file/CustomItem.java +++ b/src/main/java/one/oth3r/sit/file/CustomItem.java @@ -51,22 +51,27 @@ public class CustomItem { } // a boolean to check if one of the items are in a filtered tag - boolean tagCheck = false; + // & a switch for if there is only not(!) tags + boolean tagCheck = false, hasPositiveTags = false; - // check the custom item tags for (String tag : itemTags) { // substring to remove # and if needed, "!" - // if a NOT tag if (tag.startsWith("!")) { // if there is a math for the NOT(!) tag, return false - if (itemStack.isIn(TagKey.of(Registries.ITEM.getKey(), Identifier.of(tag.substring(2))))) return false; + Identifier id = Identifier.tryParse(tag.substring(2)); + if (id != null && itemStack.isIn(TagKey.of(Registries.ITEM.getKey(), id))) return false; + } else { + // flip the hasPositiveTags boolean + hasPositiveTags = true; + // else (normal tag), if there is a match, set tagCheck to true + Identifier id = Identifier.tryParse(tag.substring(1)); + if (id != null && itemStack.isIn(TagKey.of(Registries.ITEM.getKey(), id))) tagCheck = true; } - // else (normal tag), if there is a match, set tagCheck to true - else if (itemStack.isIn(TagKey.of(Registries.ITEM.getKey(), Identifier.of(tag.substring(1))))) tagCheck = true; } - // not returning true in the loop because there might be a (!) not tag that the item might fall into, after the item was already in another tag - return tagCheck; + // if there were any required tags, return whether we matched one + // if there were only not(!) tags, and we didn't violate any, return true + return hasPositiveTags? tagCheck : true; } @Override From c675a24e94e5ccf8cdd7521e3f5dec6639b6043b Mon Sep 17 00:00:00 2001 From: Oth3r <68134921+Oth3r@users.noreply.github.com> Date: Sat, 14 Jun 2025 18:52:00 -0500 Subject: [PATCH 09/16] v1.2.4.2+1.21.5 --- changelog.md | 5 +++++ gradle.properties | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/changelog.md b/changelog.md index f7e4244..1c47516 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,8 @@ +# v1.2.4.2 +* fixed language file not loading (reverted uppercase locales) +* fixed block checking having a hardcoded player reach - now uses player reach +* 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 diff --git a/gradle.properties b/gradle.properties index 140b7fa..4fb1aeb 100644 --- a/gradle.properties +++ b/gradle.properties @@ -13,7 +13,7 @@ yarn_mappings=1.21.5+build.1 loader_version=0.16.14 # Mod Properties -mod_version=1.2.4.1+1.21.5 +mod_version=1.2.4.2+1.21.5 maven_group=one.oth3r file_name=sit! From 02a7157a931b37dc3a1819371ec031e4e2ea980f Mon Sep 17 00:00:00 2001 From: Oth3r <68134921+Oth3r@users.noreply.github.com> Date: Sat, 14 Jun 2025 18:56:08 -0500 Subject: [PATCH 10/16] add otterlib max version as the beta changes a lot of stuff --- build.gradle | 1 + gradle.properties | 1 + src/main/resources/fabric.mod.json | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 23b4044..bc9db2d 100644 --- a/build.gradle +++ b/build.gradle @@ -43,6 +43,7 @@ processResources { min_minecraft_version : min_minecraft_version, max_minecraft_version : max_minecraft_version, otterlib_version : otterlib_version, + otterlib_max_version : otterlib_max_version, loader_version : loader_version ] diff --git a/gradle.properties b/gradle.properties index 4fb1aeb..25bdb46 100644 --- a/gradle.properties +++ b/gradle.properties @@ -21,3 +21,4 @@ file_name=sit! fabric_version=0.124.0+1.21.5 modmenu_version=14.0.0-rc.2 otterlib_version=0.1.2.1+1.21.5-fabric +otterlib_max_version=0.2.0.0+1.21.5-fabric diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 2359a00..a7441d1 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -29,7 +29,7 @@ "fabricloader": ">=0.14.21", "minecraft": ">=${min_minecraft_version} <=${max_minecraft_version}", "fabric": "*", - "otterlib": ">=${otterlib_version}" + "otterlib": ">=${otterlib_version} <${otterlib_max_version}" }, "suggests": { "modmenu": "*" From 82c4b375d53d105ff79b80b6823aa9ce62954551 Mon Sep 17 00:00:00 2001 From: Oth3r <68134921+Oth3r@users.noreply.github.com> Date: Sat, 14 Jun 2025 18:57:37 -0500 Subject: [PATCH 11/16] v1.2.4.3 --- changelog.md | 3 +++ gradle.properties | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/changelog.md b/changelog.md index 1c47516..2b7e70c 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,6 @@ +# 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 diff --git a/gradle.properties b/gradle.properties index 25bdb46..2c59928 100644 --- a/gradle.properties +++ b/gradle.properties @@ -13,7 +13,7 @@ yarn_mappings=1.21.5+build.1 loader_version=0.16.14 # Mod Properties -mod_version=1.2.4.2+1.21.5 +mod_version=1.2.4.3+1.21.5 maven_group=one.oth3r file_name=sit! From ea7e42f8a567ab86a20fc7a66555b8c3bb98771b Mon Sep 17 00:00:00 2001 From: Oth3r <68134921+Oth3r@users.noreply.github.com> Date: Sat, 14 Jun 2025 19:13:19 -0500 Subject: [PATCH 12/16] changelog clarification --- changelog.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog.md b/changelog.md index 2b7e70c..cb30a6d 100644 --- a/changelog.md +++ b/changelog.md @@ -3,7 +3,7 @@ # v1.2.4.2 * fixed language file not loading (reverted uppercase locales) -* fixed block checking having a hardcoded player reach - now uses player reach +* 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 From c9cc00624528a21a28b62be82b73d97194888903 Mon Sep 17 00:00:00 2001 From: Oth3r <68134921+Oth3r@users.noreply.github.com> Date: Mon, 16 Jun 2025 15:07:37 -0500 Subject: [PATCH 13/16] otterlib 0.2 changes --- src/main/java/one/oth3r/sit/file/LangReader.java | 4 ++-- src/main/java/one/oth3r/sit/file/ServerConfig.java | 12 +++--------- src/main/java/one/oth3r/sit/file/SittingConfig.java | 2 +- src/main/java/one/oth3r/sit/utl/Data.java | 5 ++--- src/main/java/one/oth3r/sit/utl/Events.java | 2 +- 5 files changed, 9 insertions(+), 16 deletions(-) diff --git a/src/main/java/one/oth3r/sit/file/LangReader.java b/src/main/java/one/oth3r/sit/file/LangReader.java index d9fdaff..d503bfb 100644 --- a/src/main/java/one/oth3r/sit/file/LangReader.java +++ b/src/main/java/one/oth3r/sit/file/LangReader.java @@ -99,8 +99,8 @@ public class LangReader { Reader defaultReader = new InputStreamReader(getInputStream(true), StandardCharsets.UTF_8); defaultLangMap.putAll(new Gson().fromJson(defaultReader, tToken)); } catch (Exception e) { - Data.LOGGER.info("ERROR WITH LANGUAGE FILE - PLEASE REPORT WITH THE ERROR LOG"); - Data.LOGGER.info(e.getMessage()); + Data.LOGGER.error("ERROR WITH LANGUAGE FILE - PLEASE REPORT WITH THE ERROR LOG"); + Data.LOGGER.error(e.getMessage()); } } diff --git a/src/main/java/one/oth3r/sit/file/ServerConfig.java b/src/main/java/one/oth3r/sit/file/ServerConfig.java index f4cd25e..842572c 100644 --- a/src/main/java/one/oth3r/sit/file/ServerConfig.java +++ b/src/main/java/one/oth3r/sit/file/ServerConfig.java @@ -1,7 +1,6 @@ package one.oth3r.sit.file; import com.google.gson.Gson; -import com.google.gson.JsonElement; import com.google.gson.JsonSyntaxException; import com.google.gson.annotations.SerializedName; import com.google.gson.reflect.TypeToken; @@ -264,13 +263,8 @@ public class ServerConfig implements CustomFile { this.interactionBlocks = newFile.interactionBlocks.stream().map(CustomBlock::new).collect(Collectors.toCollection(ArrayList::new)); } - /** - * updates the file based on the version number of the current instance - * - * @param json - */ @Override - public void update(JsonElement json) { + public void updateInstance() { /// update to 2.1, just a new list, nothing to change /// update to 2.2, new settings, no changes if (version >= 2.0 && version <= 2.1) { @@ -341,7 +335,7 @@ public class ServerConfig implements CustomFile { loadVersion(properties,Double.parseDouble(ver)); } catch (Exception e) { - Data.LOGGER.error("Error loading legacy config file: {}", e.getMessage()); + Data.LOGGER.error("Error loading legacy config file: %s", e.getMessage()); } // delete the old file @@ -503,7 +497,7 @@ public class ServerConfig implements CustomFile { serverConfig.save(); sittingConfig.save(); } catch (Exception e) { - Data.LOGGER.error("Error loading legacy config: {}", e.getMessage()); + Data.LOGGER.error("Error loading legacy config: %s", e.getMessage()); } } } diff --git a/src/main/java/one/oth3r/sit/file/SittingConfig.java b/src/main/java/one/oth3r/sit/file/SittingConfig.java index 38564ce..2e7337b 100644 --- a/src/main/java/one/oth3r/sit/file/SittingConfig.java +++ b/src/main/java/one/oth3r/sit/file/SittingConfig.java @@ -101,7 +101,7 @@ public class SittingConfig implements CustomFile { } @Override - public void update(JsonElement jsonElement) { + public void updateInstance() { } diff --git a/src/main/java/one/oth3r/sit/utl/Data.java b/src/main/java/one/oth3r/sit/utl/Data.java index 8c67fde..5074908 100644 --- a/src/main/java/one/oth3r/sit/utl/Data.java +++ b/src/main/java/one/oth3r/sit/utl/Data.java @@ -4,14 +4,13 @@ import net.fabricmc.loader.api.FabricLoader; import net.minecraft.entity.decoration.DisplayEntity; import net.minecraft.server.MinecraftServer; import net.minecraft.server.network.ServerPlayerEntity; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import one.oth3r.otterlib.base.OtterLogger; import java.util.HashMap; public class Data { public static final String MOD_ID = "sit-oth3r"; - public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID); + public static final OtterLogger LOGGER = new OtterLogger(MOD_ID); public static final String CONFIG_DIR = FabricLoader.getInstance().getConfigDir().toFile()+"/sit!/"; diff --git a/src/main/java/one/oth3r/sit/utl/Events.java b/src/main/java/one/oth3r/sit/utl/Events.java index 0b5c5e6..f62ea77 100644 --- a/src/main/java/one/oth3r/sit/utl/Events.java +++ b/src/main/java/one/oth3r/sit/utl/Events.java @@ -192,7 +192,7 @@ public class Events { ParseResults parse = dispatcher.parse("sit", player.getCommandSource()); dispatcher.execute(parse); } catch (CommandSyntaxException e) { - Data.LOGGER.error("Error executing sit command for player {}", player.getName().getString()); + Data.LOGGER.error("Error executing sit command for player %s", player.getName().getString()); } } From b1907920642c1955e245ab72ef2b2997553a4f56 Mon Sep 17 00:00:00 2001 From: Oth3r <68134921+Oth3r@users.noreply.github.com> Date: Mon, 16 Jun 2025 20:30:38 -0500 Subject: [PATCH 14/16] switch to otterlib Num utility --- .../java/one/oth3r/sit/file/ServerConfig.java | 4 +- src/main/java/one/oth3r/sit/utl/Utl.java | 40 ------------------- 2 files changed, 2 insertions(+), 42 deletions(-) diff --git a/src/main/java/one/oth3r/sit/file/ServerConfig.java b/src/main/java/one/oth3r/sit/file/ServerConfig.java index 842572c..8a36ad3 100644 --- a/src/main/java/one/oth3r/sit/file/ServerConfig.java +++ b/src/main/java/one/oth3r/sit/file/ServerConfig.java @@ -5,10 +5,10 @@ import com.google.gson.JsonSyntaxException; import com.google.gson.annotations.SerializedName; import com.google.gson.reflect.TypeToken; import net.minecraft.util.Hand; +import one.oth3r.otterlib.base.Num; import one.oth3r.otterlib.file.CustomFile; import one.oth3r.otterlib.file.FileSettings; import one.oth3r.sit.utl.Data; -import one.oth3r.sit.utl.Utl; import org.jetbrains.annotations.NotNull; import java.io.File; @@ -370,7 +370,7 @@ public class ServerConfig implements CustomFile { // skip if not the right size if (split.length < 3 || split.length > 4) continue; // if the other entries aren't correct, skip - if (!Utl.Num.isNum(split[2])) continue; + if (!Num.isNum(split[2])) continue; // make the block states list if possible ArrayList blockstates = new ArrayList<>(); diff --git a/src/main/java/one/oth3r/sit/utl/Utl.java b/src/main/java/one/oth3r/sit/utl/Utl.java index ea2fc19..d39a95a 100644 --- a/src/main/java/one/oth3r/sit/utl/Utl.java +++ b/src/main/java/one/oth3r/sit/utl/Utl.java @@ -60,46 +60,6 @@ public class Utl { return Data.getSitEntities().values().stream().noneMatch(entity -> entity.getBlockPos().equals(pos)); } - public static class Num { - - public static boolean isInt(String string) { - try { - Integer.parseInt(string); - } catch (NumberFormatException nfe) { - return false; - } - return true; - } - - public static Integer toInt(String s) { - // return an int no matter what - try { - return Integer.parseInt(s); - } catch (NumberFormatException e) { - try { - return (int) Double.parseDouble(s); - } catch (NumberFormatException e2) { - return 0; - } - } - } - - public static boolean isNum(String s) { - // checks if int or a double - try { - Integer.parseInt(s); - return true; - } catch (NumberFormatException e1) { - try { - Double.parseDouble(s); - return true; - } catch (NumberFormatException e2) { - return false; - } - } - } - } - public static final double HALF_BLOCK = 0.5; public static final double CARPET = 0.062; From c8902c51385b247e790bb2c0c28135901b83d0c1 Mon Sep 17 00:00:00 2001 From: Oth3r <68134921+Oth3r@users.noreply.github.com> Date: Mon, 16 Jun 2025 20:31:42 -0500 Subject: [PATCH 15/16] remove unused utilities --- src/main/java/one/oth3r/sit/utl/Utl.java | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/src/main/java/one/oth3r/sit/utl/Utl.java b/src/main/java/one/oth3r/sit/utl/Utl.java index d39a95a..4470d4b 100644 --- a/src/main/java/one/oth3r/sit/utl/Utl.java +++ b/src/main/java/one/oth3r/sit/utl/Utl.java @@ -310,29 +310,6 @@ public class Utl { else return LangReader.of(key, args).getTxT(); } - public static class Enum { - - public static > T get(Object enumString, Class enumType) { - return get(enumString,enumType,enumType.getEnumConstants()[0]); - } - /** - * gets an enum from a string without returning null - * @param enumString the string of the enum - * @param enumType the class of enums - * @param defaultEnum the enum to return if a match isn't found - * @return an enum, if there isn't a match, it returns the first enum - */ - public static > T get(Object enumString, Class enumType, T defaultEnum) { - T[] values = enumType.getEnumConstants(); - for (T all : values) { - // check if there is a match for any of the enum names - if (enumString.toString().equals(all.name())) return all; - } - // if there's no match return the first entry - return defaultEnum; - } - } - /** * sends the settings packets to the server, if client & in game */ From 85cc76a022f201786089cc69f26ab30a852968eb Mon Sep 17 00:00:00 2001 From: Oth3r <68134921+Oth3r@users.noreply.github.com> Date: Mon, 16 Jun 2025 20:36:32 -0500 Subject: [PATCH 16/16] otterlib language system --- src/main/java/one/oth3r/sit/SitClient.java | 16 +-- .../one/oth3r/sit/command/SitCommand.java | 6 +- .../java/one/oth3r/sit/file/FileData.java | 30 +++++ .../java/one/oth3r/sit/file/LangReader.java | 124 ------------------ .../oth3r/sit/mixin/ReloadCommandMixin.java | 5 +- src/main/java/one/oth3r/sit/utl/Chat.java | 16 +++ src/main/java/one/oth3r/sit/utl/Events.java | 8 +- src/main/java/one/oth3r/sit/utl/Logic.java | 7 +- src/main/java/one/oth3r/sit/utl/Utl.java | 29 +--- 9 files changed, 69 insertions(+), 172 deletions(-) delete mode 100644 src/main/java/one/oth3r/sit/file/LangReader.java create mode 100644 src/main/java/one/oth3r/sit/utl/Chat.java diff --git a/src/main/java/one/oth3r/sit/SitClient.java b/src/main/java/one/oth3r/sit/SitClient.java index c39fbba..a1796ec 100644 --- a/src/main/java/one/oth3r/sit/SitClient.java +++ b/src/main/java/one/oth3r/sit/SitClient.java @@ -7,9 +7,9 @@ import one.oth3r.otterlib.client.screen.ConfigScreen; import one.oth3r.otterlib.client.screen.utl.CustomImage; import one.oth3r.otterlib.client.screen.utl.SimpleButton; import one.oth3r.sit.file.FileData; +import one.oth3r.sit.utl.Chat; import one.oth3r.sit.utl.Data; import one.oth3r.sit.utl.Events; -import one.oth3r.sit.utl.Utl; import java.net.URI; import java.util.List; @@ -23,17 +23,17 @@ public class SitClient implements ClientModInitializer { } public static Screen getConfigScreen(Screen parent) { - return new ConfigScreen(parent, Utl.lang("sit!.screen.config"), + return new ConfigScreen(parent, Chat.lang("sit!.screen.config"), new CustomImage(Identifier.of(Data.MOD_ID, "textures/gui/banner.png"),128, 72), List.of( - SimpleButton.Templates.fileEditor(Utl.lang("config.server"), FileData.getServerConfig(), new CustomImage(Identifier.of(Data.MOD_ID, "server_button"),246,26)).build(), - SimpleButton.Templates.fileEditor(Utl.lang("config.sitting"), FileData.getSittingConfig(), new CustomImage(Identifier.of(Data.MOD_ID, "sitting_button"), 246, 26)).build() + SimpleButton.Templates.fileEditor(Chat.lang("config.server"), FileData.getServerConfig(), new CustomImage(Identifier.of(Data.MOD_ID, "server_button"),246,26)).build(), + SimpleButton.Templates.fileEditor(Chat.lang("config.sitting"), FileData.getSittingConfig(), new CustomImage(Identifier.of(Data.MOD_ID, "sitting_button"), 246, 26)).build() ), List.of( - SimpleButton.Templates.warning(Utl.lang("sit!.gui.button.issues")).openLink("https://github.com/Oth3r/Sit/issues").build(), - new SimpleButton.Builder(Utl.lang("sit!.gui.button.website")).openLink("https://modrinth.com/mod/sit!").build(), - SimpleButton.Templates.done(Utl.lang("gui.done")).build(), - SimpleButton.Templates.donate(Utl.lang("sit!.gui.button.donate")).openLink(URI.create("https://ko-fi.com/oth3r")).build() + SimpleButton.Templates.warning(Chat.lang("sit!.gui.button.issues")).openLink("https://github.com/Oth3r/Sit/issues").build(), + new SimpleButton.Builder(Chat.lang("sit!.gui.button.website")).openLink("https://modrinth.com/mod/sit!").build(), + SimpleButton.Templates.done(Chat.lang("gui.done")).build(), + SimpleButton.Templates.donate(Chat.lang("sit!.gui.button.donate")).openLink(URI.create("https://ko-fi.com/oth3r")).build() )); } } diff --git a/src/main/java/one/oth3r/sit/command/SitCommand.java b/src/main/java/one/oth3r/sit/command/SitCommand.java index 7abd2f3..ad928ed 100644 --- a/src/main/java/one/oth3r/sit/command/SitCommand.java +++ b/src/main/java/one/oth3r/sit/command/SitCommand.java @@ -8,8 +8,8 @@ import com.mojang.brigadier.suggestion.SuggestionsBuilder; import net.minecraft.server.command.CommandManager; import net.minecraft.server.command.ServerCommandSource; import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.util.Formatting; import net.minecraft.util.math.BlockPos; +import one.oth3r.sit.utl.Chat; import one.oth3r.sit.utl.Data; import one.oth3r.sit.utl.Logic; import one.oth3r.sit.utl.Utl; @@ -50,7 +50,7 @@ public class SitCommand { if (player == null) { if (args[0].equalsIgnoreCase("reload")) { Logic.reload(); - Data.LOGGER.info(Utl.lang("sit!.chat.reloaded").toString()); + Data.LOGGER.info(Chat.lang("sit!.chat.reloaded").toString()); } return 1; } @@ -76,7 +76,7 @@ public class SitCommand { if (args[0].equalsIgnoreCase("reload")) { Logic.reload(); - player.sendMessage(Utl.messageTag().append(Utl.lang("sit!.chat.reloaded").color(Color.GREEN)).b()); + player.sendMessage(Chat.tag().append(Chat.lang("sit!.chat.reloaded").color(Color.GREEN)).b()); } if (args[0].equalsIgnoreCase("purgeChairEntities")) Utl.Entity.purge(player,true); diff --git a/src/main/java/one/oth3r/sit/file/FileData.java b/src/main/java/one/oth3r/sit/file/FileData.java index 4e95a66..e64879f 100644 --- a/src/main/java/one/oth3r/sit/file/FileData.java +++ b/src/main/java/one/oth3r/sit/file/FileData.java @@ -1,9 +1,15 @@ package one.oth3r.sit.file; import net.minecraft.server.network.ServerPlayerEntity; +import one.oth3r.otterlib.file.LanguageReader; +import one.oth3r.sit.Sit; import one.oth3r.sit.utl.Data; import one.oth3r.sit.utl.Utl; +import java.net.URISyntaxException; +import java.net.URL; +import java.nio.file.Path; +import java.nio.file.Paths; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -56,11 +62,21 @@ public class FileData { return playerSettings.getOrDefault(player, sittingConfig); } + /// the language / text system for the mod + private static final LanguageReader langReader = new LanguageReader( + getLangPath(),Path.of(Data.CONFIG_DIR),"en_us","en_us"); + + public static LanguageReader getLangReader() { + return langReader; + } + /** * loads all config files to memory */ public static void loadFiles() { getServerConfig().load(); + // load the language reader + langReader.updateLanguage(getServerConfig().getLang()); getSittingConfig().load(); // if loading file and is on supported server on client, send the new settings over @@ -77,6 +93,20 @@ public class FileData { getServerConfig().save(); } + private static Path getLangPath() { + ClassLoader classLoader = Sit.class.getClassLoader(); + URL resource = classLoader.getResource("assets/sit-oth3r/lang/"); + if (resource == null) { + throw new RuntimeException("Language file not found."); + } + + try { + return Paths.get(resource.toURI()); + } catch (URISyntaxException e) { + throw new RuntimeException(e); + } + } + public static class Defaults { public static final ArrayList SITTING_BLOCKS = new ArrayList<>(Arrays.asList( new SittingBlock(new ArrayList<>(),new ArrayList<>(Arrays.asList("#minecraft:campfires")), new ArrayList<>(Arrays.asList("lit=false")),.437), diff --git a/src/main/java/one/oth3r/sit/file/LangReader.java b/src/main/java/one/oth3r/sit/file/LangReader.java deleted file mode 100644 index d503bfb..0000000 --- a/src/main/java/one/oth3r/sit/file/LangReader.java +++ /dev/null @@ -1,124 +0,0 @@ -package one.oth3r.sit.file; - -import com.google.gson.Gson; -import com.google.gson.reflect.TypeToken; -import net.minecraft.text.MutableText; -import net.minecraft.text.Text; -import one.oth3r.otterlib.chat.CTxT; -import one.oth3r.sit.Sit; -import one.oth3r.sit.utl.Data; - -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.Reader; -import java.lang.reflect.Type; -import java.nio.charset.StandardCharsets; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -public class LangReader { - private static final Map defaultLangMap = new HashMap<>(); - private static final Map languageMap = new HashMap<>(); - - private final String translationKey; - - private final Object[] placeholders; - - public LangReader(String translationKey, Object... placeholders) { - this.translationKey = translationKey; - this.placeholders = placeholders; - } - - public CTxT getTxT() { - String translated = getLanguageValue(translationKey); - if (placeholders != null && placeholders.length > 0) { - //removed all double \\ and replaces with \ - translated = translated.replaceAll("\\\\\\\\", "\\\\"); - String regex = "%\\d*\\$?[dfs]"; - Matcher anyMatch = Pattern.compile(regex).matcher(translated); - Matcher endMatch = Pattern.compile(regex+"$").matcher(translated); - - // Arraylist with all the %(#$)[dfs] - ArrayList matches = new ArrayList<>(); - while (anyMatch.find()) { - String match = anyMatch.group(); - matches.add(match); - } - //SPLITS the text at each regex and remove the regex - String[] parts = translated.split(regex); - //if the last element of the array ends with regex, remove it and add an empty string to the end of the array - if (endMatch.find()) { - String[] newParts = Arrays.copyOf(parts, parts.length + 1); - newParts[parts.length] = ""; - parts = newParts; - } - //if there are placeholders specified, and the split is more than 1, it will replace %(dfs) with the placeholder objects - if (parts.length > 1) { - CTxT txt = new CTxT(""); - int i = 0; - for (String match : matches) { - int get = i; - //if the match is numbered, change GET to the number it wants - if (match.contains("$")) { - match = match.substring(1,match.indexOf('$')); - get = Integer.parseInt(match)-1; - } - if (parts.length != i) txt.append(parts[i]); - //convert the obj into txt - txt.append(getTxTFromObj(placeholders[get])); - i++; - } - if (parts.length != i) txt.append(parts[i]); - return new CTxT(txt); - } - } - return new CTxT(translated); - } - - private CTxT getTxTFromObj(Object obj) { - if (obj instanceof CTxT) return (((CTxT) obj)); - else if (obj instanceof Text) return new CTxT((MutableText) obj); - else return new CTxT(String.valueOf(obj)); - } - - public static LangReader of(String translationKey, Object... placeholders) { - return new LangReader(translationKey, placeholders); - } - - public static void loadLanguageFile() { - Type tToken = new TypeToken>(){}.getType(); - try { - // load the config language - Reader selectionReader = new InputStreamReader(getInputStream(false), StandardCharsets.UTF_8); - languageMap.putAll(new Gson().fromJson(selectionReader, tToken)); - // load the default language as well (fallback) - Reader defaultReader = new InputStreamReader(getInputStream(true), StandardCharsets.UTF_8); - defaultLangMap.putAll(new Gson().fromJson(defaultReader, tToken)); - } catch (Exception e) { - Data.LOGGER.error("ERROR WITH LANGUAGE FILE - PLEASE REPORT WITH THE ERROR LOG"); - Data.LOGGER.error(e.getMessage()); - } - } - - private static InputStream getInputStream(boolean english) { - ClassLoader classLoader = Sit.class.getClassLoader(); - InputStream inputStream = classLoader.getResourceAsStream("assets/sit-oth3r/lang/"+FileData.getServerConfig().getLang()+".json"); - // make null if english - if (english) inputStream = null; - - // if it cant read (null), try again, but with the english file - if (inputStream == null) inputStream = classLoader.getResourceAsStream("assets/sit-oth3r/lang/"+new ServerConfig().getLang()+".json"); - - // if null after that, throw an exception - if (inputStream == null) throw new IllegalArgumentException("CANT LOAD THE LANGUAGE FILE. SIT! WILL BREAK."); - return inputStream; - } - - public static String getLanguageValue(String key) { - return languageMap.getOrDefault(key, defaultLangMap.getOrDefault(key, key)); - } -} \ No newline at end of file diff --git a/src/main/java/one/oth3r/sit/mixin/ReloadCommandMixin.java b/src/main/java/one/oth3r/sit/mixin/ReloadCommandMixin.java index 81d15fb..6edd652 100644 --- a/src/main/java/one/oth3r/sit/mixin/ReloadCommandMixin.java +++ b/src/main/java/one/oth3r/sit/mixin/ReloadCommandMixin.java @@ -5,10 +5,9 @@ import net.minecraft.server.MinecraftServer; import net.minecraft.server.command.ReloadCommand; import net.minecraft.server.command.ServerCommandSource; import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.util.Formatting; +import one.oth3r.sit.utl.Chat; import one.oth3r.sit.utl.Data; import one.oth3r.sit.utl.Logic; -import one.oth3r.sit.utl.Utl; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -29,7 +28,7 @@ public class ReloadCommandMixin { // send a reloaded message to all players with permissions for (ServerPlayerEntity player : server.getPlayerManager().getPlayerList()) { if (player.isCreativeLevelTwoOp()) { - player.sendMessage(Utl.messageTag().append(Utl.lang("sit!.chat.reloaded").color(Color.GREEN)).b()); + player.sendMessage(Chat.tag().append(Chat.lang("sit!.chat.reloaded").color(Color.GREEN)).b()); } } } diff --git a/src/main/java/one/oth3r/sit/utl/Chat.java b/src/main/java/one/oth3r/sit/utl/Chat.java new file mode 100644 index 0000000..6dc2867 --- /dev/null +++ b/src/main/java/one/oth3r/sit/utl/Chat.java @@ -0,0 +1,16 @@ +package one.oth3r.sit.utl; + +import one.oth3r.otterlib.chat.CTxT; +import one.oth3r.sit.file.FileData; + +import java.awt.*; + +public class Chat { + public static CTxT tag() { + return new CTxT("Sit!").btn(true).color(Color.decode("#c400ff")).append(" "); + } + + public static CTxT lang(String key, Object... args) { + return FileData.getLangReader().dynamicTranslatable(key, args); + } +} diff --git a/src/main/java/one/oth3r/sit/utl/Events.java b/src/main/java/one/oth3r/sit/utl/Events.java index f62ea77..f4f2c64 100644 --- a/src/main/java/one/oth3r/sit/utl/Events.java +++ b/src/main/java/one/oth3r/sit/utl/Events.java @@ -23,7 +23,6 @@ import net.minecraft.util.ActionResult; import one.oth3r.sit.SitClient; import one.oth3r.sit.command.SitCommand; import one.oth3r.sit.file.FileData; -import one.oth3r.sit.file.LangReader; import one.oth3r.sit.file.SittingConfig; import one.oth3r.sit.packet.SitPayloads; import org.lwjgl.glfw.GLFW; @@ -78,7 +77,7 @@ public class Events { player.networkHandler.sendCommand("sit"); } else { // unsupported server message if not in a Sit! server - player.sendMessage(Utl.lang("sit!.chat.unsupported") + player.sendMessage(Chat.lang("sit!.chat.unsupported") .color(Color.RED).b(), true); } } @@ -104,7 +103,7 @@ public class Events { ServerPlayNetworking.send(context.player(),new SitPayloads.ResponsePayload(SitPayloads.ResponsePayload.VERSION)); // log the receiving of the packet from the player - Data.LOGGER.info(Utl.lang("sit!.console.player_settings",context.player().getName().getString()).toString()); + Data.LOGGER.info(Chat.lang("sit!.console.player_settings",context.player().getName().getString()).toString()); }))); } @@ -114,7 +113,7 @@ public class Events { // only update when needed if (!Data.isSupportedServer()) { Data.setSupportedServer(true); - Data.LOGGER.info(Utl.lang("sit!.console.connected",payload.value()).toString()); + Data.LOGGER.info(Chat.lang("sit!.console.connected",payload.value()).toString()); } })); } @@ -172,7 +171,6 @@ public class Events { private static void serverLifecycle() { ServerLifecycleEvents.SERVER_STARTED.register(s -> { Data.setServer(s); - LangReader.loadLanguageFile(); // right click on block event UseBlockCallback.EVENT.register((pl, world, hand, hitResult) -> { diff --git a/src/main/java/one/oth3r/sit/utl/Logic.java b/src/main/java/one/oth3r/sit/utl/Logic.java index b128b94..0433259 100644 --- a/src/main/java/one/oth3r/sit/utl/Logic.java +++ b/src/main/java/one/oth3r/sit/utl/Logic.java @@ -201,7 +201,6 @@ public class Logic { public static void reload() { FileData.loadFiles(); FileData.saveFiles(); - LangReader.loadLanguageFile(); } /** @@ -228,11 +227,11 @@ public class Logic { Formatting messageColor = config.getEnabled()?Formatting.GREEN:Formatting.RED; // send the player the actionbar message - return Utl.lang("sit!.chat.toggle_sit", - Utl.lang(messageKey).color(config.getEnabled()? Color.GREEN : Color.RED)).b(); + return Chat.lang("sit!.chat.toggle_sit", + Chat.lang(messageKey).color(config.getEnabled()? Color.GREEN : Color.RED)).b(); } else { // unsupported server message if not in a Sit! server - return Utl.lang("sit!.chat.unsupported") + return Chat.lang("sit!.chat.unsupported") .color(Color.RED).b(); } } diff --git a/src/main/java/one/oth3r/sit/utl/Utl.java b/src/main/java/one/oth3r/sit/utl/Utl.java index 4470d4b..d6d53bb 100644 --- a/src/main/java/one/oth3r/sit/utl/Utl.java +++ b/src/main/java/one/oth3r/sit/utl/Utl.java @@ -281,35 +281,14 @@ public class Utl { // send a message if needed if (message) { - player.sendMessage(messageTag() - .append(lang("sit!.chat.purged",lang("sit!.chat.purged.total",count).color(Color.gray).b()).color(Color.GREEN)).b()); + player.sendMessage(Chat.tag() + .append(Chat.lang("sit!.chat.purged", + Chat.lang("sit!.chat.purged.total",count).color(Color.gray).b() + ).color(Color.GREEN)).b()); } } } - public static CTxT messageTag() { - return new CTxT("Sit!").btn(true).color(Color.decode("#c400ff")).append(" "); - } - - /** - * gets a MutableText using the language key, if on server, using the custom lang reader - */ - public static CTxT lang(String key, Object... args) { - if (Data.isClient()) { - // we have to first convert all the CTxT's to the built version because minecraft lang reader doesn't know how to process it - // make a array with the same size of the args - Object[] fixedArgs = new Object[args.length]; - // for every arg, build & add if CTxT or just add if not - for (var i = 0; i < args.length; i++) { - if (args[i] instanceof CTxT) fixedArgs[i] = ((CTxT) args[i]).b(); - else fixedArgs[i] = args[i]; - } - // return the translated text - return new CTxT(Text.translatable(key,fixedArgs)); - } - else return LangReader.of(key, args).getTxT(); - } - /** * sends the settings packets to the server, if client & in game */