├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md └── workflows │ ├── gradle.yml │ └── release.yml ├── .gitignore ├── LICENSE ├── README.md ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle └── src └── main ├── java └── us │ └── potatoboy │ └── invview │ ├── InvView.java │ ├── ViewCommand.java │ ├── gui │ ├── SavingPlayerDataGui.java │ └── UnmodifiableSlot.java │ └── mixin │ └── EntityAccessor.java └── resources ├── fabric.mod.json ├── invview.mixins.json └── logo.png /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Device Info(please complete the following information):** 27 | - OS: [e.g. Windows, Mac] 28 | - Minecraft Version[e.g. 1.16.2] 29 | - Version [e.g. 1.0.0] 30 | 31 | **Additional context** 32 | Add any other context about the problem here. 33 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: enhancement 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.github/workflows/gradle.yml: -------------------------------------------------------------------------------- 1 | # This workflow will build a Java project with Gradle 2 | # For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle 3 | 4 | name: Java CI with Gradle 5 | 6 | on: 7 | push: 8 | branches: [ master ] 9 | pull_request: 10 | branches: [ master ] 11 | 12 | jobs: 13 | build: 14 | 15 | runs-on: ubuntu-latest 16 | 17 | steps: 18 | - uses: actions/checkout@v4 19 | - name: Set up JDK 21 20 | uses: actions/setup-java@v4 21 | with: 22 | java-version: 21 23 | distribution: 'temurin' 24 | - name: Grant execute permission for gradlew 25 | run: chmod +x gradlew 26 | - name: Build with Gradle 27 | run: ./gradlew build --stacktrace --info 28 | - name: Upload a Build Artifact 29 | uses: actions/upload-artifact@v4 30 | with: 31 | name: InvView-Artifact 32 | path: build/libs/ 33 | if-no-files-found: error 34 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: release 2 | 3 | on: 4 | release: 5 | types: 6 | - published 7 | 8 | jobs: 9 | build: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: actions/checkout@v3 13 | 14 | - name: Set up JDK 21 15 | uses: actions/setup-java@v3 16 | with: 17 | distribution: temurin 18 | java-version: 21 19 | 20 | - name: Make gradlew executable 21 | run: chmod +x ./gradlew 22 | 23 | - name: Build artifacts 24 | run: ./gradlew clean build 25 | 26 | - name: Upload assets to GitHub, Modrinth and CurseForge 27 | uses: Kir-Antipov/mc-publish@v3.3 28 | with: 29 | modrinth-id: jrDKjZP7 30 | modrinth-featured: false 31 | modrinth-token: ${{ secrets.MODRINTH_TOKEN }} 32 | 33 | curseforge-id: 405159 34 | curseforge-token: ${{ secrets.CURSEFORGE_TOKEN }} 35 | 36 | github-token: ${{ secrets.GITHUB_TOKEN }} 37 | 38 | loaders: | 39 | fabric 40 | quilt 41 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # User-specific stuff 2 | .idea/ 3 | 4 | *.iml 5 | *.ipr 6 | *.iws 7 | 8 | # IntelliJ 9 | out/ 10 | # mpeltonen/sbt-idea plugin 11 | .idea_modules/ 12 | 13 | # JIRA plugin 14 | atlassian-ide-plugin.xml 15 | 16 | # Compiled class file 17 | *.class 18 | 19 | # Log file 20 | *.log 21 | 22 | # BlueJ files 23 | *.ctxt 24 | 25 | # Package Files # 26 | *.jar 27 | *.war 28 | *.nar 29 | *.ear 30 | *.zip 31 | *.tar.gz 32 | *.rar 33 | 34 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 35 | hs_err_pid* 36 | 37 | *~ 38 | 39 | # temporary files which can be created if a process still has a handle open of a deleted file 40 | .fuse_hidden* 41 | 42 | # KDE directory preferences 43 | .directory 44 | 45 | # Linux trash folder which might appear on any partition or disk 46 | .Trash-* 47 | 48 | # .nfs files are created when an open file is removed but is still being accessed 49 | .nfs* 50 | 51 | # General 52 | .DS_Store 53 | .AppleDouble 54 | .LSOverride 55 | 56 | # Icon must end with two \r 57 | Icon 58 | 59 | # Thumbnails 60 | ._* 61 | 62 | # Files that might appear in the root of a volume 63 | .DocumentRevisions-V100 64 | .fseventsd 65 | .Spotlight-V100 66 | .TemporaryItems 67 | .Trashes 68 | .VolumeIcon.icns 69 | .com.apple.timemachine.donotpresent 70 | 71 | # Directories potentially created on remote AFP share 72 | .AppleDB 73 | .AppleDesktop 74 | Network Trash Folder 75 | Temporary Items 76 | .apdisk 77 | 78 | # Windows thumbnail cache files 79 | Thumbs.db 80 | Thumbs.db:encryptable 81 | ehthumbs.db 82 | ehthumbs_vista.db 83 | 84 | # Dump file 85 | *.stackdump 86 | 87 | # Folder config file 88 | [Dd]esktop.ini 89 | 90 | # Recycle Bin used on file shares 91 | $RECYCLE.BIN/ 92 | 93 | # Windows Installer files 94 | *.cab 95 | *.msi 96 | *.msix 97 | *.msm 98 | *.msp 99 | 100 | # Windows shortcuts 101 | *.lnk 102 | 103 | .gradle 104 | build/ 105 | 106 | # Ignore Gradle GUI config 107 | gradle-app.setting 108 | 109 | # Cache of project 110 | .gradletasknamecache 111 | 112 | **/build/ 113 | 114 | # Common working directory 115 | run/ 116 | 117 | # Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) 118 | !gradle-wrapper.jar 119 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2020 Potatoboy9999 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # InvView 2 | Allows you to get the inventory and echest of other players 3 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'fabric-loom' version '1.10.+' 3 | id 'maven-publish' 4 | } 5 | 6 | repositories { 7 | maven { 8 | name = "TerraformersMC" 9 | url = "https://maven.terraformersmc.com/" 10 | } 11 | maven { 12 | name = "Ladysnake Libs" 13 | url = 'https://maven.ladysnake.org/releases' 14 | } 15 | maven { 16 | url = 'https://maven.cafeteria.dev' 17 | content { 18 | includeGroup 'net.adriantodt.fabricmc' 19 | } 20 | } 21 | maven { url "https://maven.jamieswhiteshirt.com/libs-release/" } 22 | maven { url "https://maven.shedaniel.me/" } 23 | maven { url 'https://maven.nucleoid.xyz' } 24 | maven { url 'https://oss.sonatype.org/content/repositories/snapshots' } 25 | mavenCentral() 26 | maven { url 'https://api.modrinth.com/maven' } 27 | maven { url 'https://jitpack.io' } 28 | maven { url 'https://maven.quiltmc.org/repository/release' } 29 | } 30 | 31 | sourceCompatibility = JavaVersion.VERSION_21 32 | targetCompatibility = JavaVersion.VERSION_21 33 | 34 | archivesBaseName = project.archives_base_name 35 | version = project.mod_version + "-" + project.minecraft_version + "+" 36 | group = project.maven_group 37 | 38 | dependencies { 39 | //to change the versions see the gradle.properties file 40 | minecraft "com.mojang:minecraft:${project.minecraft_version}" 41 | mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" 42 | modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" 43 | 44 | // Fabric API. This is technically optional, but you probably want it anyway. 45 | modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" 46 | 47 | // PSA: Some older mods, compiled on Loom 0.2.1, might have outdated Maven POMs. 48 | // You may need to force-disable transitiveness on them. 49 | modImplementation include("eu.pb4:sgui:${project.sgui_version}") 50 | 51 | // modImplementation "dev.emi:trinkets:${project.trinkets_version}" 52 | // modImplementation "com.github.apace100:apoli:${project.apoli_version}" 53 | 54 | modImplementation "me.lucko:fabric-permissions-api:0.2-SNAPSHOT" 55 | include "me.lucko:fabric-permissions-api:0.2-SNAPSHOT" 56 | 57 | // Dev Mods - These can be commented/uncommented to test compatibility 58 | //modLocalRuntime "maven.modrinth:cloth-config:9.0.94+fabric" 59 | //modLocalRuntime "maven.modrinth:expanded-enderchest:1.0.0+1.19.3" 60 | //modLocalRuntime "maven.modrinth:elytra-slot:6uCj1VmZ" 61 | //modLocalRuntime "maven.modrinth:origins:1.10.0" 62 | } 63 | 64 | processResources { 65 | inputs.property "version", project.version 66 | filesMatching("fabric.mod.json") { 67 | expand "version": project.version 68 | } 69 | } 70 | 71 | // ensure that the encoding is set to UTF-8, no matter what the system default is 72 | // this fixes some edge cases with special characters not displaying correctly 73 | // see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html 74 | tasks.withType(JavaCompile) { 75 | options.encoding = "UTF-8" 76 | } 77 | 78 | jar { 79 | from "LICENSE" 80 | } 81 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Done to increase the memory available to gradle. 2 | org.gradle.jvmargs=-Xmx1G 3 | # Fabric Properties 4 | # check these on https://fabricmc.net/develop/ 5 | minecraft_version=1.21.5 6 | yarn_mappings=1.21.5+build.1 7 | loader_version=0.16.11 8 | # Mod Properties 9 | mod_version=1.4.16 10 | maven_group=us.potatoboy 11 | archives_base_name=InvView 12 | # Dependencies 13 | # check this on https://fabricmc.net/develop/ 14 | fabric_version=0.119.6+1.21.5 15 | trinkets_version=3.10.0 16 | apoli_version=2.11.11 17 | sgui_version=1.9.0+1.21.5 18 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PotatoPresident/InvView/d148ac6f5ecb093657187d5865501d6d864a97ed/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip 4 | networkTimeout=10000 5 | validateDistributionUrl=true 6 | zipStoreBase=GRADLE_USER_HOME 7 | zipStorePath=wrapper/dists 8 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 4 | # Copyright © 2015-2021 the original authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | # 21 | # Gradle start up script for POSIX generated by Gradle. 22 | # 23 | # Important for running: 24 | # 25 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is 26 | # noncompliant, but you have some other compliant shell such as ksh or 27 | # bash, then to run this script, type that shell name before the whole 28 | # command line, like: 29 | # 30 | # ksh Gradle 31 | # 32 | # Busybox and similar reduced shells will NOT work, because this script 33 | # requires all of these POSIX shell features: 34 | # * functions; 35 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}», 36 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»; 37 | # * compound commands having a testable exit status, especially «case»; 38 | # * various built-in commands including «command», «set», and «ulimit». 39 | # 40 | # Important for patching: 41 | # 42 | # (2) This script targets any POSIX shell, so it avoids extensions provided 43 | # by Bash, Ksh, etc; in particular arrays are avoided. 44 | # 45 | # The "traditional" practice of packing multiple parameters into a 46 | # space-separated string is a well documented source of bugs and security 47 | # problems, so this is (mostly) avoided, by progressively accumulating 48 | # options in "$@", and eventually passing that to Java. 49 | # 50 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, 51 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; 52 | # see the in-line comments for details. 53 | # 54 | # There are tweaks for specific operating systems such as AIX, CygWin, 55 | # Darwin, MinGW, and NonStop. 56 | # 57 | # (3) This script is generated from the Groovy template 58 | # https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt 59 | # within the Gradle project. 60 | # 61 | # You can find Gradle at https://github.com/gradle/gradle/. 62 | # 63 | ############################################################################## 64 | 65 | # Attempt to set APP_HOME 66 | 67 | # Resolve links: $0 may be a link 68 | app_path=$0 69 | 70 | # Need this for daisy-chained symlinks. 71 | while 72 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path 73 | [ -h "$app_path" ] 74 | do 75 | ls=$( ls -ld "$app_path" ) 76 | link=${ls#*' -> '} 77 | case $link in #( 78 | /*) app_path=$link ;; #( 79 | *) app_path=$APP_HOME$link ;; 80 | esac 81 | done 82 | 83 | # This is normally unused 84 | # shellcheck disable=SC2034 85 | APP_BASE_NAME=${0##*/} 86 | # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) 87 | APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit 88 | 89 | # Use the maximum available, or set MAX_FD != -1 to use that value. 90 | MAX_FD=maximum 91 | 92 | warn () { 93 | echo "$*" 94 | } >&2 95 | 96 | die () { 97 | echo 98 | echo "$*" 99 | echo 100 | exit 1 101 | } >&2 102 | 103 | # OS specific support (must be 'true' or 'false'). 104 | cygwin=false 105 | msys=false 106 | darwin=false 107 | nonstop=false 108 | case "$( uname )" in #( 109 | CYGWIN* ) cygwin=true ;; #( 110 | Darwin* ) darwin=true ;; #( 111 | MSYS* | MINGW* ) msys=true ;; #( 112 | NONSTOP* ) nonstop=true ;; 113 | esac 114 | 115 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 116 | 117 | 118 | # Determine the Java command to use to start the JVM. 119 | if [ -n "$JAVA_HOME" ] ; then 120 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 121 | # IBM's JDK on AIX uses strange locations for the executables 122 | JAVACMD=$JAVA_HOME/jre/sh/java 123 | else 124 | JAVACMD=$JAVA_HOME/bin/java 125 | fi 126 | if [ ! -x "$JAVACMD" ] ; then 127 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 128 | 129 | Please set the JAVA_HOME variable in your environment to match the 130 | location of your Java installation." 131 | fi 132 | else 133 | JAVACMD=java 134 | if ! command -v java >/dev/null 2>&1 135 | then 136 | die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 137 | 138 | Please set the JAVA_HOME variable in your environment to match the 139 | location of your Java installation." 140 | fi 141 | fi 142 | 143 | # Increase the maximum file descriptors if we can. 144 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then 145 | case $MAX_FD in #( 146 | max*) 147 | # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. 148 | # shellcheck disable=SC2039,SC3045 149 | MAX_FD=$( ulimit -H -n ) || 150 | warn "Could not query maximum file descriptor limit" 151 | esac 152 | case $MAX_FD in #( 153 | '' | soft) :;; #( 154 | *) 155 | # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. 156 | # shellcheck disable=SC2039,SC3045 157 | ulimit -n "$MAX_FD" || 158 | warn "Could not set maximum file descriptor limit to $MAX_FD" 159 | esac 160 | fi 161 | 162 | # Collect all arguments for the java command, stacking in reverse order: 163 | # * args from the command line 164 | # * the main class name 165 | # * -classpath 166 | # * -D...appname settings 167 | # * --module-path (only if needed) 168 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. 169 | 170 | # For Cygwin or MSYS, switch paths to Windows format before running java 171 | if "$cygwin" || "$msys" ; then 172 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) 173 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) 174 | 175 | JAVACMD=$( cygpath --unix "$JAVACMD" ) 176 | 177 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 178 | for arg do 179 | if 180 | case $arg in #( 181 | -*) false ;; # don't mess with options #( 182 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath 183 | [ -e "$t" ] ;; #( 184 | *) false ;; 185 | esac 186 | then 187 | arg=$( cygpath --path --ignore --mixed "$arg" ) 188 | fi 189 | # Roll the args list around exactly as many times as the number of 190 | # args, so each arg winds up back in the position where it started, but 191 | # possibly modified. 192 | # 193 | # NB: a `for` loop captures its iteration list before it begins, so 194 | # changing the positional parameters here affects neither the number of 195 | # iterations, nor the values presented in `arg`. 196 | shift # remove old arg 197 | set -- "$@" "$arg" # push replacement arg 198 | done 199 | fi 200 | 201 | 202 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 203 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 204 | 205 | # Collect all arguments for the java command: 206 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, 207 | # and any embedded shellness will be escaped. 208 | # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be 209 | # treated as '${Hostname}' itself on the command line. 210 | 211 | set -- \ 212 | "-Dorg.gradle.appname=$APP_BASE_NAME" \ 213 | -classpath "$CLASSPATH" \ 214 | org.gradle.wrapper.GradleWrapperMain \ 215 | "$@" 216 | 217 | # Stop when "xargs" is not available. 218 | if ! command -v xargs >/dev/null 2>&1 219 | then 220 | die "xargs is not available" 221 | fi 222 | 223 | # Use "xargs" to parse quoted args. 224 | # 225 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed. 226 | # 227 | # In Bash we could simply go: 228 | # 229 | # readarray ARGS < <( xargs -n1 <<<"$var" ) && 230 | # set -- "${ARGS[@]}" "$@" 231 | # 232 | # but POSIX shell has neither arrays nor command substitution, so instead we 233 | # post-process each arg (as a line of input to sed) to backslash-escape any 234 | # character that might be a shell metacharacter, then use eval to reverse 235 | # that process (while maintaining the separation between arguments), and wrap 236 | # the whole thing up as a single "set" statement. 237 | # 238 | # This will of course break if any of these variables contains a newline or 239 | # an unmatched quote. 240 | # 241 | 242 | eval "set -- $( 243 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | 244 | xargs -n1 | 245 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | 246 | tr '\n' ' ' 247 | )" '"$@"' 248 | 249 | exec "$JAVACMD" "$@" 250 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%"=="" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%"=="" set DIRNAME=. 29 | @rem This is normally unused 30 | set APP_BASE_NAME=%~n0 31 | set APP_HOME=%DIRNAME% 32 | 33 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 34 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 35 | 36 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 37 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 38 | 39 | @rem Find java.exe 40 | if defined JAVA_HOME goto findJavaFromJavaHome 41 | 42 | set JAVA_EXE=java.exe 43 | %JAVA_EXE% -version >NUL 2>&1 44 | if %ERRORLEVEL% equ 0 goto execute 45 | 46 | echo. 1>&2 47 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 48 | echo. 1>&2 49 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2 50 | echo location of your Java installation. 1>&2 51 | 52 | goto fail 53 | 54 | :findJavaFromJavaHome 55 | set JAVA_HOME=%JAVA_HOME:"=% 56 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 57 | 58 | if exist "%JAVA_EXE%" goto execute 59 | 60 | echo. 1>&2 61 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 62 | echo. 1>&2 63 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2 64 | echo location of your Java installation. 1>&2 65 | 66 | goto fail 67 | 68 | :execute 69 | @rem Setup the command line 70 | 71 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 72 | 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if %ERRORLEVEL% equ 0 goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | set EXIT_CODE=%ERRORLEVEL% 85 | if %EXIT_CODE% equ 0 set EXIT_CODE=1 86 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% 87 | exit /b %EXIT_CODE% 88 | 89 | :mainEnd 90 | if "%OS%"=="Windows_NT" endlocal 91 | 92 | :omega 93 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories { 3 | maven { 4 | name = 'Fabric' 5 | url = 'https://maven.fabricmc.net/' 6 | } 7 | gradlePluginPortal() 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/us/potatoboy/invview/InvView.java: -------------------------------------------------------------------------------- 1 | package us.potatoboy.invview; 2 | 3 | import com.mojang.brigadier.tree.LiteralCommandNode; 4 | import me.lucko.fabric.api.permissions.v0.Permissions; 5 | import net.fabricmc.api.ModInitializer; 6 | import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback; 7 | import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents; 8 | import net.fabricmc.loader.api.FabricLoader; 9 | import net.minecraft.command.argument.GameProfileArgumentType; 10 | import net.minecraft.nbt.NbtCompound; 11 | import net.minecraft.nbt.NbtIo; 12 | import net.minecraft.server.MinecraftServer; 13 | import net.minecraft.server.command.CommandManager; 14 | import net.minecraft.server.command.ServerCommandSource; 15 | import net.minecraft.server.network.ServerPlayerEntity; 16 | import net.minecraft.util.Util; 17 | import net.minecraft.util.WorldSavePath; 18 | import org.apache.logging.log4j.LogManager; 19 | 20 | import java.io.File; 21 | import java.io.FileOutputStream; 22 | 23 | public class InvView implements ModInitializer { 24 | private static MinecraftServer minecraftServer; 25 | public static boolean isTrinkets = false; 26 | public static boolean isLuckPerms = false; 27 | public static boolean isApoli = false; 28 | 29 | @Override 30 | public void onInitialize() { 31 | isTrinkets = FabricLoader.getInstance().isModLoaded("trinkets"); 32 | isLuckPerms = FabricLoader.getInstance().isModLoaded("luckperms"); 33 | isApoli = FabricLoader.getInstance().isModLoaded("apoli"); 34 | 35 | CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> { 36 | 37 | LiteralCommandNode viewNode = CommandManager 38 | .literal("view") 39 | .requires(Permissions.require("invview.command.root", 2)) 40 | .build(); 41 | 42 | LiteralCommandNode invNode = CommandManager 43 | .literal("inv") 44 | .requires(Permissions.require("invview.command.inv", 2)) 45 | .then(CommandManager.argument("target", GameProfileArgumentType.gameProfile()) 46 | .executes(ViewCommand::inv)) 47 | .build(); 48 | 49 | LiteralCommandNode echestNode = CommandManager 50 | .literal("echest") 51 | .requires(Permissions.require("invview.command.echest", 2)) 52 | .then(CommandManager.argument("target", GameProfileArgumentType.gameProfile()) 53 | .executes(ViewCommand::eChest)) 54 | .build(); 55 | 56 | // LiteralCommandNode trinketNode = CommandManager 57 | // .literal("trinket") 58 | // .requires(Permissions.require("invview.command.trinket", 2)) 59 | // .then(CommandManager.argument("target", GameProfileArgumentType.gameProfile()) 60 | // .executes(ViewCommand::trinkets)) 61 | // .build(); 62 | // 63 | // LiteralCommandNode apoliNode = CommandManager 64 | // .literal("origin-inv") 65 | // .requires(Permissions.require("invview.command.origin", 2)) 66 | // .then(CommandManager.argument("target", GameProfileArgumentType.gameProfile()) 67 | // .executes(ViewCommand::apoli)) 68 | // .build(); 69 | 70 | dispatcher.getRoot().addChild(viewNode); 71 | viewNode.addChild(invNode); 72 | viewNode.addChild(echestNode); 73 | 74 | if (isTrinkets) { 75 | // viewNode.addChild(trinketNode); 76 | } 77 | if (isApoli) { 78 | // viewNode.addChild(apoliNode); 79 | } 80 | }); 81 | 82 | ServerLifecycleEvents.SERVER_STARTING.register(this::onLogicalServerStarting); 83 | } 84 | 85 | private void onLogicalServerStarting(MinecraftServer server) { 86 | minecraftServer = server; 87 | } 88 | 89 | public static MinecraftServer getMinecraftServer() { 90 | return minecraftServer; 91 | } 92 | 93 | public static void savePlayerData(ServerPlayerEntity player) { 94 | File playerDataDir = minecraftServer.getSavePath(WorldSavePath.PLAYERDATA).toFile(); 95 | try { 96 | NbtCompound compoundTag = player.writeNbt(new NbtCompound()); 97 | File file = File.createTempFile(player.getUuidAsString() + "-", ".dat", playerDataDir); 98 | final FileOutputStream fos = new FileOutputStream(file); 99 | NbtIo.writeCompressed(compoundTag, fos); 100 | File file2 = new File(playerDataDir, player.getUuidAsString() + ".dat"); 101 | File file3 = new File(playerDataDir, player.getUuidAsString() + ".dat_old"); 102 | Util.backupAndReplace(file2.toPath(), file.toPath(), file3.toPath()); 103 | } catch (Exception var6) { 104 | LogManager.getLogger().warn("Failed to save player data for {}", player.getName().getString()); 105 | } 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /src/main/java/us/potatoboy/invview/ViewCommand.java: -------------------------------------------------------------------------------- 1 | package us.potatoboy.invview; 2 | 3 | import com.mojang.authlib.GameProfile; 4 | import com.mojang.brigadier.context.CommandContext; 5 | import com.mojang.brigadier.exceptions.CommandSyntaxException; 6 | import com.mojang.serialization.Dynamic; 7 | import eu.pb4.sgui.api.elements.GuiElementBuilder; 8 | import eu.pb4.sgui.api.gui.SimpleGui; 9 | import me.lucko.fabric.api.permissions.v0.Permissions; 10 | import net.minecraft.command.argument.GameProfileArgumentType; 11 | import net.minecraft.inventory.EnderChestInventory; 12 | import net.minecraft.item.Items; 13 | import net.minecraft.nbt.NbtCompound; 14 | import net.minecraft.nbt.NbtOps; 15 | import net.minecraft.network.packet.c2s.common.SyncedClientOptions; 16 | import net.minecraft.screen.ScreenHandlerType; 17 | import net.minecraft.screen.slot.Slot; 18 | import net.minecraft.server.MinecraftServer; 19 | import net.minecraft.server.command.ServerCommandSource; 20 | import net.minecraft.server.network.ServerPlayerEntity; 21 | import net.minecraft.server.world.ServerWorld; 22 | import net.minecraft.text.Text; 23 | import net.minecraft.world.dimension.DimensionType; 24 | import us.potatoboy.invview.gui.SavingPlayerDataGui; 25 | import us.potatoboy.invview.gui.UnmodifiableSlot; 26 | import us.potatoboy.invview.mixin.EntityAccessor; 27 | 28 | import java.util.Optional; 29 | 30 | public class ViewCommand { 31 | private static final MinecraftServer minecraftServer = InvView.getMinecraftServer(); 32 | 33 | private static final String permProtected = "invview.protected"; 34 | private static final String permModify = "invview.can_modify"; 35 | private static final String msgProtected = "Requested inventory is protected"; 36 | 37 | public static int inv(CommandContext context) throws CommandSyntaxException { 38 | ServerPlayerEntity player = context.getSource().getPlayer(); 39 | ServerPlayerEntity requestedPlayer = getRequestedPlayer(context); 40 | 41 | boolean canModify = Permissions.check(context.getSource(), permModify, true); 42 | 43 | Permissions.check(requestedPlayer.getUuid(), permProtected, false).thenAcceptAsync(isProtected -> { 44 | if (isProtected) { 45 | context.getSource().sendError(Text.literal(msgProtected)); 46 | } else { 47 | SimpleGui gui = new SavingPlayerDataGui(ScreenHandlerType.GENERIC_9X5, player, requestedPlayer); 48 | gui.setTitle(requestedPlayer.getName()); 49 | addBackground(gui); 50 | for (int i = 0; i < requestedPlayer.getInventory().size(); i++) { 51 | gui.setSlotRedirect(i, canModify ? new Slot(requestedPlayer.getInventory(), i, 0, 0) : new UnmodifiableSlot(requestedPlayer.getInventory(), i)); 52 | } 53 | 54 | gui.open(); 55 | } 56 | }); 57 | 58 | return 1; 59 | } 60 | 61 | public static int eChest(CommandContext context) throws CommandSyntaxException { 62 | ServerPlayerEntity player = context.getSource().getPlayer(); 63 | ServerPlayerEntity requestedPlayer = getRequestedPlayer(context); 64 | EnderChestInventory requestedEchest = requestedPlayer.getEnderChestInventory(); 65 | 66 | boolean canModify = Permissions.check(context.getSource(), permModify, true); 67 | 68 | Permissions.check(requestedPlayer.getUuid(), permProtected, false).thenAcceptAsync(isProtected -> { 69 | if (isProtected) { 70 | context.getSource().sendError(Text.literal(msgProtected)); 71 | } else { 72 | ScreenHandlerType screenHandlerType = switch (requestedEchest.size()) { 73 | case 9 -> ScreenHandlerType.GENERIC_9X1; 74 | case 18 -> ScreenHandlerType.GENERIC_9X2; 75 | case 36 -> ScreenHandlerType.GENERIC_9X4; 76 | case 45 -> ScreenHandlerType.GENERIC_9X5; 77 | case 54 -> ScreenHandlerType.GENERIC_9X6; 78 | default -> ScreenHandlerType.GENERIC_9X3; 79 | }; 80 | SimpleGui gui = new SavingPlayerDataGui(screenHandlerType, player, requestedPlayer); 81 | gui.setTitle(requestedPlayer.getName()); 82 | addBackground(gui); 83 | for (int i = 0; i < requestedEchest.size(); i++) { 84 | gui.setSlotRedirect(i, canModify ? new Slot(requestedEchest, i, 0, 0) : new UnmodifiableSlot(requestedEchest, i)); 85 | } 86 | 87 | gui.open(); 88 | } 89 | }); 90 | 91 | return 1; 92 | } 93 | 94 | // public static int trinkets(CommandContext context) throws CommandSyntaxException { 95 | // ServerPlayerEntity player = context.getSource().getPlayer(); 96 | // ServerPlayerEntity requestedPlayer = getRequestedPlayer(context); 97 | // TrinketComponent requestedComponent = TrinketsApi.getTrinketComponent(requestedPlayer).get(); 98 | // 99 | // boolean canModify = Permissions.check(context.getSource(), permModify, true); 100 | // 101 | // Permissions.check(requestedPlayer.getUuid(), permProtected, false).thenAcceptAsync(isProtected -> { 102 | // if (isProtected) { 103 | // context.getSource().sendError(Text.literal(msgProtected)); 104 | // } else { 105 | // SimpleGui gui = new SavingPlayerDataGui(ScreenHandlerType.GENERIC_9X2, player, requestedPlayer); 106 | // addBackground(gui); 107 | // gui.setTitle(requestedPlayer.getName()); 108 | // int index = 0; 109 | // for (Map group : requestedComponent.getInventory().values()) { 110 | // for (TrinketInventory inventory : group.values()) { 111 | // for (int i = 0; i < inventory.size(); i++) { 112 | // gui.setSlotRedirect(index, canModify ? new Slot(inventory, i, 0, 0) : new UnmodifiableSlot(inventory, i)); 113 | // index += 1; 114 | // } 115 | // } 116 | // } 117 | // 118 | // gui.open(); 119 | // } 120 | // }); 121 | // 122 | // return 1; 123 | // } 124 | 125 | // public static int apoli(CommandContext context) throws CommandSyntaxException { 126 | // ServerPlayerEntity player = context.getSource().getPlayer(); 127 | // ServerPlayerEntity requestedPlayer = getRequestedPlayer(context); 128 | // 129 | // boolean canModify = Permissions.check(context.getSource(), permModify, true); 130 | // 131 | // Permissions.check(requestedPlayer.getUuid(), permProtected, false).thenAcceptAsync(isProtected -> { 132 | // if (isProtected) { 133 | // context.getSource().sendError(Text.literal(msgProtected)); 134 | // } else { 135 | // List inventories = PowerHolderComponent.getPowers(requestedPlayer, 136 | // InventoryPower.class); 137 | // if (inventories.isEmpty()) { 138 | // context.getSource().sendError(Text.literal("Requested player has no inventory power")); 139 | // } else { 140 | // SimpleGui gui = new SavingPlayerDataGui(ScreenHandlerType.GENERIC_9X5, player, requestedPlayer); 141 | // gui.setTitle(requestedPlayer.getName()); 142 | // addBackground(gui); 143 | // int index = 0; 144 | // for (InventoryPower inventory : inventories) { 145 | // for (int i = 0; i < inventory.size(); i++) { 146 | // gui.setSlotRedirect(index, canModify ? new Slot(inventory, i, 0, 0) : new UnmodifiableSlot(inventory, i)); 147 | // index += 1; 148 | // } 149 | // } 150 | // 151 | // gui.open(); 152 | // } 153 | // } 154 | // }); 155 | // 156 | // return 1; 157 | // } 158 | 159 | private static ServerPlayerEntity getRequestedPlayer(CommandContext context) 160 | throws CommandSyntaxException { 161 | GameProfile requestedProfile = GameProfileArgumentType.getProfileArgument(context, "target").iterator().next(); 162 | ServerPlayerEntity requestedPlayer = minecraftServer.getPlayerManager().getPlayer(requestedProfile.getName()); 163 | 164 | if (requestedPlayer == null) { 165 | requestedPlayer = minecraftServer.getPlayerManager().createPlayer(requestedProfile, SyncedClientOptions.createDefault()); 166 | Optional compoundOpt = minecraftServer.getPlayerManager().loadPlayerData(requestedPlayer); 167 | if (compoundOpt.isPresent()) { 168 | NbtCompound compound = compoundOpt.get(); 169 | if (compound.contains("Dimension")) { 170 | ServerWorld world = minecraftServer.getWorld( 171 | DimensionType.worldFromDimensionNbt(new Dynamic<>(NbtOps.INSTANCE, compound.get("Dimension"))) 172 | .result().get()); 173 | 174 | if (world != null) { 175 | ((EntityAccessor) requestedPlayer).callSetWorld(world); 176 | } 177 | } 178 | } 179 | } 180 | 181 | return requestedPlayer; 182 | } 183 | 184 | private static void addBackground(SimpleGui gui) { 185 | for (int i = 0; i < gui.getSize(); i++) { 186 | gui.setSlot(i, new GuiElementBuilder(Items.BARRIER).setName(Text.literal("")).build()); 187 | } 188 | } 189 | } 190 | -------------------------------------------------------------------------------- /src/main/java/us/potatoboy/invview/gui/SavingPlayerDataGui.java: -------------------------------------------------------------------------------- 1 | package us.potatoboy.invview.gui; 2 | 3 | import eu.pb4.sgui.api.gui.SimpleGui; 4 | import net.minecraft.screen.ScreenHandlerType; 5 | import net.minecraft.server.network.ServerPlayerEntity; 6 | import us.potatoboy.invview.InvView; 7 | 8 | public class SavingPlayerDataGui extends SimpleGui { 9 | private final ServerPlayerEntity savedPlayer; 10 | 11 | /** 12 | * Constructs a new simple container gui for the supplied player. 13 | * 14 | * @param type the screen handler that the client should display 15 | * @param player the player to server this gui to 16 | */ 17 | public SavingPlayerDataGui(ScreenHandlerType type, ServerPlayerEntity player, ServerPlayerEntity savedPlayer) { 18 | super(type, player, false); 19 | this.savedPlayer = savedPlayer; 20 | } 21 | 22 | @Override 23 | public void onClose() { 24 | InvView.savePlayerData(savedPlayer); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/us/potatoboy/invview/gui/UnmodifiableSlot.java: -------------------------------------------------------------------------------- 1 | package us.potatoboy.invview.gui; 2 | 3 | import net.minecraft.entity.player.PlayerEntity; 4 | import net.minecraft.inventory.Inventory; 5 | import net.minecraft.item.ItemStack; 6 | import net.minecraft.screen.slot.Slot; 7 | 8 | public class UnmodifiableSlot extends Slot { 9 | public UnmodifiableSlot(Inventory inventory, int index) { 10 | super(inventory, index, 0, 0); 11 | } 12 | 13 | @Override 14 | public boolean canInsert(ItemStack stack) { 15 | return false; 16 | } 17 | 18 | @Override 19 | public boolean canTakeItems(PlayerEntity playerEntity) { 20 | return false; 21 | } 22 | 23 | @Override 24 | public boolean canTakePartial(PlayerEntity player) { 25 | return false; 26 | } 27 | 28 | @Override 29 | public ItemStack takeStack(int amount) { 30 | return ItemStack.EMPTY; 31 | } 32 | 33 | @Override 34 | public ItemStack insertStack(ItemStack stack, int count) { 35 | return stack; 36 | } 37 | 38 | @Override 39 | public void setStack(ItemStack stack) { 40 | 41 | } 42 | 43 | @Override 44 | public void setStackNoCallbacks(ItemStack stack) { 45 | 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/us/potatoboy/invview/mixin/EntityAccessor.java: -------------------------------------------------------------------------------- 1 | package us.potatoboy.invview.mixin; 2 | 3 | import org.spongepowered.asm.mixin.Mixin; 4 | import org.spongepowered.asm.mixin.gen.Invoker; 5 | import net.minecraft.entity.Entity; 6 | import net.minecraft.world.World; 7 | 8 | @Mixin(Entity.class) 9 | public interface EntityAccessor { 10 | @Invoker 11 | public void callSetWorld(World world); 12 | } 13 | -------------------------------------------------------------------------------- /src/main/resources/fabric.mod.json: -------------------------------------------------------------------------------- 1 | { 2 | "schemaVersion": 1, 3 | "id": "invview", 4 | "version": "${version}", 5 | "name": "InvView", 6 | "description": "Allows you to open the inventory and ender chest of online and offline players", 7 | "authors": [ 8 | "Potatoboy9999" 9 | ], 10 | "contact": { 11 | "website": "https://www.curseforge.com/minecraft/mc-mods/inv-view", 12 | "sources": "https://github.com/PotatoPresident/InvView", 13 | "issues": "https://github.com/PotatoPresident/InvView/issues", 14 | "homepage": "https://www.curseforge.com/minecraft/mc-mods/inv-view" 15 | }, 16 | "custom": { 17 | "modmenu": { 18 | "links": { 19 | "modmenu.discord": "https://discord.gg/ByaVuebAPb" 20 | } 21 | } 22 | }, 23 | "license": "MIT", 24 | "icon": "logo.png", 25 | "environment": "*", 26 | "entrypoints": { 27 | "main": [ 28 | "us.potatoboy.invview.InvView" 29 | ] 30 | }, 31 | "mixins": [ 32 | "invview.mixins.json" 33 | ], 34 | "depends": { 35 | "fabricloader": ">=0.15.10", 36 | "fabric": "*", 37 | "minecraft": ">=1.21.5" 38 | } 39 | } -------------------------------------------------------------------------------- /src/main/resources/invview.mixins.json: -------------------------------------------------------------------------------- 1 | { 2 | "required": true, 3 | "minVersion": "0.8", 4 | "package": "us.potatoboy.invview.mixin", 5 | "compatibilityLevel": "JAVA_17", 6 | "mixins": [ 7 | "EntityAccessor" 8 | ], 9 | "injectors": { 10 | "defaultRequire": 1 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/main/resources/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PotatoPresident/InvView/d148ac6f5ecb093657187d5865501d6d864a97ed/src/main/resources/logo.png --------------------------------------------------------------------------------