mirror of
https://github.com/AtlasMediaGroup/Scissors.git
synced 2025-07-15 21:04:04 +00:00
Compare commits
33 Commits
archive/1.
...
archive/1.
Author | SHA1 | Date | |
---|---|---|---|
cedb59e831 | |||
3000da112b | |||
ebdedbed25 | |||
2733597c72 | |||
72fa0ce340 | |||
b90b32ca54 | |||
8274f52923 | |||
f3b3ef9f03 | |||
|
a7dbe8a38e | ||
|
63e980e13b | ||
|
8c0deddbe1 | ||
|
ade230ed68 | ||
|
f940a6bb8f | ||
|
f403924ca0 | ||
|
ba694be2bc | ||
|
d382eb52e7 | ||
|
3ea91b9dbc | ||
|
b30b7223e5 | ||
|
2b687d9eda | ||
ad72d5928e | |||
907c5f4ed1 | |||
|
ff6ceb1094 | ||
|
acb9c23149 | ||
3330671737 | |||
0abae227cb | |||
|
6b64fc6c2c | ||
310c7a953b | |||
c09d7fa208 | |||
219e834ffd | |||
3eb4c190e4 | |||
6be48a491b | |||
e34e6c62e6 | |||
fe1c388702 |
26
.github/workflows/build.yml
vendored
26
.github/workflows/build.yml
vendored
@@ -1,10 +1,5 @@
|
|||||||
name: Patch and Build
|
name: Patch and Build
|
||||||
|
on: [ push, pull_request ]
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: [ "**" ]
|
|
||||||
pull_request:
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
# Only run on PRs if the source branch is on someone else's repo
|
# Only run on PRs if the source branch is on someone else's repo
|
||||||
@@ -12,19 +7,26 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Git Repository
|
- name: Checkout Git Repository
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v2
|
||||||
- name: Validate Gradle wrapper
|
- name: Validate Gradle wrapper
|
||||||
uses: gradle/wrapper-validation-action@v1
|
uses: gradle/wrapper-validation-action@v1
|
||||||
- name: Setup Gradle
|
- name: Cache Gradle
|
||||||
uses: gradle/gradle-build-action@v2
|
uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
~/.gradle/caches
|
||||||
|
~/.gradle/wrapper
|
||||||
|
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties', '**/gradle.properties') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-gradle-
|
||||||
- name: Set up JDK
|
- name: Set up JDK
|
||||||
uses: actions/setup-java@v3
|
uses: actions/setup-java@v2.3.0
|
||||||
with:
|
with:
|
||||||
distribution: 'temurin'
|
distribution: 'temurin'
|
||||||
java-version: '17'
|
java-version: '17'
|
||||||
- name: Configure Git User Details
|
- name: Configure Git User Details
|
||||||
run: git config --global user.email "actions@github.com" && git config --global user.name "Github Actions"
|
run: git config --global user.email "actions@github.com" && git config --global user.name "Github Actions"
|
||||||
- name: Apply Patches
|
- name: Apply Patches
|
||||||
run: ./gradlew applyPatches
|
run: ./gradlew applyPatches --stacktrace
|
||||||
- name: Build
|
- name: Build
|
||||||
run: ./gradlew build
|
run: ./gradlew build --stacktrace
|
||||||
|
@@ -1,11 +1,11 @@
|
|||||||
# Scissors [](https://ci.scissors.gg/job/Scissors/job/1.20/)
|
# Scissors [](https://ci.scissors.gg/job/Scissors/job/1.18.2/)
|
||||||
|
|
||||||
Scissors is a fork of Paper that aims to fix exploits possible in Creative Mode. Many of these exploits are ones that
|
Scissors is a fork of Paper that aims to fix exploits possible in Creative Mode. Many of these exploits are ones that
|
||||||
Paper's own team has either refused to fix or would have.
|
Paper's own team has either refused to fix or would have.
|
||||||
|
|
||||||
## Links
|
## Links
|
||||||
### [Scissors Download](https://ci.plex.us.org/job/Scissors)
|
### [Scissors Download](https://ci.plex.us.org/job/Scissors)
|
||||||
### [Scissors Javadoc](https://javadoc.scissors.gg/1.20)
|
### [Scissors Javadoc](https://javadoc.scissors.gg/1.18.2)
|
||||||
### [Scissors Announcements](https://totalfreedom.me/forum/board/139)
|
### [Scissors Announcements](https://totalfreedom.me/forum/board/139)
|
||||||
### [Scissors General Discussion](https://totalfreedom.me/forum/board/140)
|
### [Scissors General Discussion](https://totalfreedom.me/forum/board/140)
|
||||||
|
|
||||||
|
@@ -8,9 +8,3 @@
|
|||||||
# To import classes from the vanilla Minecraft jar use `minecraft` as the artifactId:
|
# To import classes from the vanilla Minecraft jar use `minecraft` as the artifactId:
|
||||||
# minecraft net.minecraft.world.level.entity.LevelEntityGetterAdapter
|
# minecraft net.minecraft.world.level.entity.LevelEntityGetterAdapter
|
||||||
# minecraft net/minecraft/world/level/entity/LevelEntityGetter.java
|
# minecraft net/minecraft/world/level/entity/LevelEntityGetter.java
|
||||||
|
|
||||||
## Used in Scissors 1.19
|
|
||||||
#minecraft net/minecraft/world/ContainerHelper
|
|
||||||
#minecraft net/minecraft/network/chat/contents/NbtContents
|
|
||||||
#minecraft net/minecraft/network/chat/ComponentUtils
|
|
||||||
#minecraft net/minecraft/network/chat/contents/EntityDataSource
|
|
@@ -1,11 +1,11 @@
|
|||||||
plugins {
|
plugins {
|
||||||
java
|
java
|
||||||
`maven-publish`
|
`maven-publish`
|
||||||
id("com.github.johnrengelman.shadow") version "8.1.1" apply false
|
id("com.github.johnrengelman.shadow") version "7.1.2" apply false
|
||||||
id("io.papermc.paperweight.patcher") version "1.5.5"
|
id("io.papermc.paperweight.patcher") version "1.3.6"
|
||||||
}
|
}
|
||||||
|
|
||||||
val paperMavenPublicUrl = "https://repo.papermc.io/repository/maven-public/"
|
val paperMavenPublicUrl = "https://papermc.io/repo/repository/maven-public/"
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
@@ -15,9 +15,9 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
remapper("net.fabricmc:tiny-remapper:0.8.6:fat")
|
remapper("net.fabricmc:tiny-remapper:0.8.2:fat")
|
||||||
decompiler("net.minecraftforge:forgeflower:2.0.627.2")
|
decompiler("net.minecraftforge:forgeflower:1.5.498.29")
|
||||||
paperclip("io.papermc:paperclip:3.0.3")
|
paperclip("io.papermc:paperclip:3.0.2")
|
||||||
}
|
}
|
||||||
|
|
||||||
allprojects {
|
allprojects {
|
||||||
@@ -42,10 +42,7 @@ subprojects {
|
|||||||
tasks.withType<ProcessResources> {
|
tasks.withType<ProcessResources> {
|
||||||
filteringCharset = Charsets.UTF_8.name()
|
filteringCharset = Charsets.UTF_8.name()
|
||||||
}
|
}
|
||||||
tasks.withType<Test> {
|
|
||||||
minHeapSize = "2g"
|
|
||||||
maxHeapSize = "4g"
|
|
||||||
}
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
maven(paperMavenPublicUrl)
|
maven(paperMavenPublicUrl)
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
group=me.totalfreedom.scissors
|
group=me.totalfreedom.scissors
|
||||||
version=1.20-R0.1-SNAPSHOT
|
version=1.18.2-R0.1-SNAPSHOT
|
||||||
|
|
||||||
mcVersion=1.20
|
mcVersion=1.18.2
|
||||||
paperRef=de19eb8c4a490ff4f427e9ad8b8bbe181c368cc1
|
paperRef=fc9ee65a32622d03a91db39364b6f106cf88335b
|
||||||
|
|
||||||
org.gradle.caching=true
|
org.gradle.caching=true
|
||||||
org.gradle.parallel=true
|
org.gradle.parallel=true
|
||||||
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
3
gradle/wrapper/gradle-wrapper.properties
vendored
3
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,6 +1,5 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
|
||||||
networkTimeout=10000
|
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
18
gradlew
vendored
18
gradlew
vendored
@@ -55,7 +55,7 @@
|
|||||||
# Darwin, MinGW, and NonStop.
|
# Darwin, MinGW, and NonStop.
|
||||||
#
|
#
|
||||||
# (3) This script is generated from the Groovy template
|
# (3) This script is generated from the Groovy template
|
||||||
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||||
# within the Gradle project.
|
# within the Gradle project.
|
||||||
#
|
#
|
||||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||||
@@ -80,11 +80,11 @@ do
|
|||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
# This is normally unused
|
|
||||||
# shellcheck disable=SC2034
|
|
||||||
APP_BASE_NAME=${0##*/}
|
|
||||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||||
|
|
||||||
|
APP_NAME="Gradle"
|
||||||
|
APP_BASE_NAME=${0##*/}
|
||||||
|
|
||||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||||
|
|
||||||
@@ -143,16 +143,12 @@ fi
|
|||||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||||
case $MAX_FD in #(
|
case $MAX_FD in #(
|
||||||
max*)
|
max*)
|
||||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
|
||||||
# shellcheck disable=SC3045
|
|
||||||
MAX_FD=$( ulimit -H -n ) ||
|
MAX_FD=$( ulimit -H -n ) ||
|
||||||
warn "Could not query maximum file descriptor limit"
|
warn "Could not query maximum file descriptor limit"
|
||||||
esac
|
esac
|
||||||
case $MAX_FD in #(
|
case $MAX_FD in #(
|
||||||
'' | soft) :;; #(
|
'' | soft) :;; #(
|
||||||
*)
|
*)
|
||||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
|
||||||
# shellcheck disable=SC3045
|
|
||||||
ulimit -n "$MAX_FD" ||
|
ulimit -n "$MAX_FD" ||
|
||||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||||
esac
|
esac
|
||||||
@@ -209,12 +205,6 @@ set -- \
|
|||||||
org.gradle.wrapper.GradleWrapperMain \
|
org.gradle.wrapper.GradleWrapperMain \
|
||||||
"$@"
|
"$@"
|
||||||
|
|
||||||
# Stop when "xargs" is not available.
|
|
||||||
if ! command -v xargs >/dev/null 2>&1
|
|
||||||
then
|
|
||||||
die "xargs is not available"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Use "xargs" to parse quoted args.
|
# Use "xargs" to parse quoted args.
|
||||||
#
|
#
|
||||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||||
|
15
gradlew.bat
vendored
15
gradlew.bat
vendored
@@ -14,7 +14,7 @@
|
|||||||
@rem limitations under the License.
|
@rem limitations under the License.
|
||||||
@rem
|
@rem
|
||||||
|
|
||||||
@if "%DEBUG%"=="" @echo off
|
@if "%DEBUG%" == "" @echo off
|
||||||
@rem ##########################################################################
|
@rem ##########################################################################
|
||||||
@rem
|
@rem
|
||||||
@rem Gradle startup script for Windows
|
@rem Gradle startup script for Windows
|
||||||
@@ -25,8 +25,7 @@
|
|||||||
if "%OS%"=="Windows_NT" setlocal
|
if "%OS%"=="Windows_NT" setlocal
|
||||||
|
|
||||||
set DIRNAME=%~dp0
|
set DIRNAME=%~dp0
|
||||||
if "%DIRNAME%"=="" set DIRNAME=.
|
if "%DIRNAME%" == "" set DIRNAME=.
|
||||||
@rem This is normally unused
|
|
||||||
set APP_BASE_NAME=%~n0
|
set APP_BASE_NAME=%~n0
|
||||||
set APP_HOME=%DIRNAME%
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
@@ -41,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
|
|||||||
|
|
||||||
set JAVA_EXE=java.exe
|
set JAVA_EXE=java.exe
|
||||||
%JAVA_EXE% -version >NUL 2>&1
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
if %ERRORLEVEL% equ 0 goto execute
|
if "%ERRORLEVEL%" == "0" goto execute
|
||||||
|
|
||||||
echo.
|
echo.
|
||||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
@@ -76,15 +75,13 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
|||||||
|
|
||||||
:end
|
:end
|
||||||
@rem End local scope for the variables with windows NT shell
|
@rem End local scope for the variables with windows NT shell
|
||||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||||
|
|
||||||
:fail
|
:fail
|
||||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||||
rem the _cmd.exe /c_ return code!
|
rem the _cmd.exe /c_ return code!
|
||||||
set EXIT_CODE=%ERRORLEVEL%
|
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
exit /b 1
|
||||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
|
||||||
exit /b %EXIT_CODE%
|
|
||||||
|
|
||||||
:mainEnd
|
:mainEnd
|
||||||
if "%OS%"=="Windows_NT" endlocal
|
if "%OS%"=="Windows_NT" endlocal
|
||||||
|
@@ -6,7 +6,7 @@ Subject: [PATCH] Add MasterBlockFireEvent
|
|||||||
|
|
||||||
diff --git a/src/main/java/me/totalfreedom/scissors/event/block/MasterBlockFireEvent.java b/src/main/java/me/totalfreedom/scissors/event/block/MasterBlockFireEvent.java
|
diff --git a/src/main/java/me/totalfreedom/scissors/event/block/MasterBlockFireEvent.java b/src/main/java/me/totalfreedom/scissors/event/block/MasterBlockFireEvent.java
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000000000000000000000000000000000000..a24cb52a5af62012c5d5acc29e4c3558e92ae572
|
index 0000000000000000000000000000000000000000..812e6ae9f1c8eb9558e5109c522d3ce3a7deb35c
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/src/main/java/me/totalfreedom/scissors/event/block/MasterBlockFireEvent.java
|
+++ b/src/main/java/me/totalfreedom/scissors/event/block/MasterBlockFireEvent.java
|
||||||
@@ -0,0 +1,51 @@
|
@@ -0,0 +1,51 @@
|
||||||
|
@@ -1,12 +1,12 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
From: Allink <arclicious@vivaldi.net>
|
From: Allink <arclicious@vivaldi.net>
|
||||||
Date: Tue, 5 Jul 2022 04:10:29 +0100
|
Date: Tue, 5 Jul 2022 03:59:18 +0100
|
||||||
Subject: [PATCH] Add spectator teleport event
|
Subject: [PATCH] Add spectator teleport event
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/me/totalfreedom/scissors/event/player/SpectatorTeleportEvent.java b/src/main/java/me/totalfreedom/scissors/event/player/SpectatorTeleportEvent.java
|
diff --git a/src/main/java/me/totalfreedom/scissors/event/player/SpectatorTeleportEvent.java b/src/main/java/me/totalfreedom/scissors/event/player/SpectatorTeleportEvent.java
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000000000000000000000000000000000000..d7efa63c316ed99c3eccfeadc1b0873b2ccb5d8a
|
index 0000000000000000000000000000000000000000..e4c9256c78f8b395aea86e9ea1a112f8e7426c1f
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/src/main/java/me/totalfreedom/scissors/event/player/SpectatorTeleportEvent.java
|
+++ b/src/main/java/me/totalfreedom/scissors/event/player/SpectatorTeleportEvent.java
|
||||||
@@ -0,0 +1,60 @@
|
@@ -0,0 +1,60 @@
|
||||||
|
@@ -1,14 +1,14 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
From: Allink <arclicious@vivaldi.net>
|
From: Allink <arclicious@vivaldi.net>
|
||||||
Date: Sun, 10 Jul 2022 10:12:04 +0100
|
Date: Sun, 10 Jul 2022 09:56:34 +0100
|
||||||
Subject: [PATCH] Add Scissors configuration file
|
Subject: [PATCH] Add Scissors configuration file
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
|
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
|
||||||
index 1d1a1d087dabc9794e0062a064da2cced4062309..1770de3705aa14232b133bce9fac56dfe89faa37 100644
|
index 79b26045a68ebb9b01e5bd06abbccaaef5489777..eb66a2cf4785c9f8ef4bdebee59f29777bf9fa50 100644
|
||||||
--- a/src/main/java/org/bukkit/Server.java
|
--- a/src/main/java/org/bukkit/Server.java
|
||||||
+++ b/src/main/java/org/bukkit/Server.java
|
+++ b/src/main/java/org/bukkit/Server.java
|
||||||
@@ -1994,6 +1994,13 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
|
@@ -1897,6 +1897,13 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
|
||||||
}
|
}
|
||||||
// Paper end
|
// Paper end
|
||||||
|
|
||||||
|
@@ -89,13 +89,12 @@ index 0000000000000000000000000000000000000000..722f5839600954998cbbf799e68477d4
|
|||||||
+}
|
+}
|
||||||
diff --git a/src/main/java/me/totalfreedom/scissors/event/block/CommandMinecartPlayerEditEvent.java b/src/main/java/me/totalfreedom/scissors/event/block/CommandMinecartPlayerEditEvent.java
|
diff --git a/src/main/java/me/totalfreedom/scissors/event/block/CommandMinecartPlayerEditEvent.java b/src/main/java/me/totalfreedom/scissors/event/block/CommandMinecartPlayerEditEvent.java
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000000000000000000000000000000000000..4282f24deb87e52ee19a13b172ec80c6a6017e28
|
index 0000000000000000000000000000000000000000..4248563a590c76dc0d211fec99f6c98becf42b57
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/src/main/java/me/totalfreedom/scissors/event/block/CommandMinecartPlayerEditEvent.java
|
+++ b/src/main/java/me/totalfreedom/scissors/event/block/CommandMinecartPlayerEditEvent.java
|
||||||
@@ -0,0 +1,78 @@
|
@@ -0,0 +1,77 @@
|
||||||
+package me.totalfreedom.scissors.event.block;
|
+package me.totalfreedom.scissors.event.block;
|
||||||
+
|
+
|
||||||
+import org.bukkit.block.CommandBlock;
|
|
||||||
+import org.bukkit.entity.Player;
|
+import org.bukkit.entity.Player;
|
||||||
+import org.bukkit.entity.minecart.CommandMinecart;
|
+import org.bukkit.entity.minecart.CommandMinecart;
|
||||||
+import org.bukkit.event.Cancellable;
|
+import org.bukkit.event.Cancellable;
|
||||||
|
@@ -1,27 +1,25 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
From: Telesphoreo <me@telesphoreo.me>
|
From: Telesphoreo <me@telesphoreo.me>
|
||||||
Date: Wed, 27 Jul 2022 22:09:00 -0500
|
Date: Tue, 19 Apr 2022 18:17:43 -0500
|
||||||
Subject: [PATCH] Build changes
|
Subject: [PATCH] Build changes
|
||||||
|
|
||||||
|
|
||||||
diff --git a/build.gradle.kts b/build.gradle.kts
|
diff --git a/build.gradle.kts b/build.gradle.kts
|
||||||
index a3a76b9b7efa773117d2ee1ce53ef784b09b277d..fad5e021f1282cd478f6ce484edbc135494b81b3 100644
|
index 0282e3b75470e1a68ea1fc228082483514ba432e..9e78384fdd5727143d3be5f189478ed701fbd0bd 100644
|
||||||
--- a/build.gradle.kts
|
--- a/build.gradle.kts
|
||||||
+++ b/build.gradle.kts
|
+++ b/build.gradle.kts
|
||||||
@@ -7,8 +7,10 @@ plugins {
|
@@ -9,8 +9,8 @@ plugins {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
- implementation(project(":paper-api"))
|
- implementation(project(":paper-api"))
|
||||||
- implementation(project(":paper-mojangapi"))
|
- implementation(project(":paper-mojangapi"))
|
||||||
+ implementation(project(":Scissors-API"))
|
+ implementation(project(":Scissors-API"))
|
||||||
+ implementation("io.papermc.paper:paper-mojangapi:1.20-R0.1-SNAPSHOT") {
|
+ implementation("io.papermc.paper:paper-mojangapi:1.18.2-R0.1-SNAPSHOT") // Scissors
|
||||||
+ exclude("io.papermc.paper", "paper-api")
|
|
||||||
+ }
|
|
||||||
// Paper start
|
// Paper start
|
||||||
implementation("org.jline:jline-terminal-jansi:3.21.0")
|
implementation("org.jline:jline-terminal-jansi:3.21.0")
|
||||||
implementation("net.minecrell:terminalconsoleappender:1.3.0")
|
implementation("net.minecrell:terminalconsoleappender:1.3.0")
|
||||||
@@ -58,11 +60,17 @@ tasks.jar {
|
@@ -56,11 +56,17 @@ tasks.jar {
|
||||||
val gitHash = git("rev-parse", "--short=7", "HEAD").getText().trim()
|
val gitHash = git("rev-parse", "--short=7", "HEAD").getText().trim()
|
||||||
val implementationVersion = System.getenv("BUILD_NUMBER") ?: "\"$gitHash\""
|
val implementationVersion = System.getenv("BUILD_NUMBER") ?: "\"$gitHash\""
|
||||||
val date = git("show", "-s", "--format=%ci", gitHash).getText().trim() // Paper
|
val date = git("show", "-s", "--format=%ci", gitHash).getText().trim() // Paper
|
||||||
@@ -41,7 +39,7 @@ index a3a76b9b7efa773117d2ee1ce53ef784b09b277d..fad5e021f1282cd478f6ce484edbc135
|
|||||||
"Implementation-Vendor" to date, // Paper
|
"Implementation-Vendor" to date, // Paper
|
||||||
"Specification-Title" to "Bukkit",
|
"Specification-Title" to "Bukkit",
|
||||||
"Specification-Version" to project.version,
|
"Specification-Version" to project.version,
|
||||||
@@ -134,7 +142,7 @@ fun TaskContainer.registerRunTask(
|
@@ -148,7 +154,7 @@ fun TaskContainer.registerRunTask(
|
||||||
name: String,
|
name: String,
|
||||||
block: JavaExec.() -> Unit
|
block: JavaExec.() -> Unit
|
||||||
): TaskProvider<JavaExec> = register<JavaExec>(name) {
|
): TaskProvider<JavaExec> = register<JavaExec>(name) {
|
||||||
@@ -51,7 +49,7 @@ index a3a76b9b7efa773117d2ee1ce53ef784b09b277d..fad5e021f1282cd478f6ce484edbc135
|
|||||||
standardInput = System.`in`
|
standardInput = System.`in`
|
||||||
workingDir = rootProject.layout.projectDirectory
|
workingDir = rootProject.layout.projectDirectory
|
||||||
diff --git a/src/main/java/com/destroystokyo/paper/Metrics.java b/src/main/java/com/destroystokyo/paper/Metrics.java
|
diff --git a/src/main/java/com/destroystokyo/paper/Metrics.java b/src/main/java/com/destroystokyo/paper/Metrics.java
|
||||||
index 4b002e8b75d117b726b0de274a76d3596fce015b..5ff11b9bcef76cb767f0b03ffc326d3f7a361371 100644
|
index 218f5bafeed8551b55b91c7fccaf6935c8b631ca..1434060d64bca5931749278d72c3eca6b0cd5189 100644
|
||||||
--- a/src/main/java/com/destroystokyo/paper/Metrics.java
|
--- a/src/main/java/com/destroystokyo/paper/Metrics.java
|
||||||
+++ b/src/main/java/com/destroystokyo/paper/Metrics.java
|
+++ b/src/main/java/com/destroystokyo/paper/Metrics.java
|
||||||
@@ -593,7 +593,7 @@ public class Metrics {
|
@@ -593,7 +593,7 @@ public class Metrics {
|
||||||
@@ -63,38 +61,20 @@ index 4b002e8b75d117b726b0de274a76d3596fce015b..5ff11b9bcef76cb767f0b03ffc326d3f
|
|||||||
|
|
||||||
metrics.addCustomChart(new Metrics.SimplePie("minecraft_version", () -> {
|
metrics.addCustomChart(new Metrics.SimplePie("minecraft_version", () -> {
|
||||||
String minecraftVersion = Bukkit.getVersion();
|
String minecraftVersion = Bukkit.getVersion();
|
||||||
@@ -607,11 +607,11 @@ public class Metrics {
|
@@ -603,7 +603,7 @@ public class Metrics {
|
||||||
final String implVersion = org.bukkit.craftbukkit.Main.class.getPackage().getImplementationVersion();
|
|
||||||
if (implVersion != null) {
|
metrics.addCustomChart(new Metrics.SingleLineChart("players", () -> Bukkit.getOnlinePlayers().size()));
|
||||||
final String buildOrHash = implVersion.substring(implVersion.lastIndexOf('-') + 1);
|
metrics.addCustomChart(new Metrics.SimplePie("online_mode", () -> Bukkit.getOnlineMode() ? "online" : "offline"));
|
||||||
- paperVersion = "git-Paper-%s-%s".formatted(Bukkit.getServer().getMinecraftVersion(), buildOrHash);
|
- metrics.addCustomChart(new Metrics.SimplePie("paper_version", () -> (Metrics.class.getPackage().getImplementationVersion() != null) ? Metrics.class.getPackage().getImplementationVersion() : "unknown"));
|
||||||
+ paperVersion = "git-Scissors-%s-%s".formatted(Bukkit.getServer().getMinecraftVersion(), buildOrHash);
|
+ metrics.addCustomChart(new Metrics.SimplePie("scissors_version", () -> (Metrics.class.getPackage().getImplementationVersion() != null) ? Metrics.class.getPackage().getImplementationVersion() : "unknown"));
|
||||||
} else {
|
|
||||||
paperVersion = "unknown";
|
|
||||||
}
|
|
||||||
- metrics.addCustomChart(new Metrics.SimplePie("paper_version", () -> paperVersion));
|
|
||||||
+ metrics.addCustomChart(new Metrics.SimplePie("scissors_version", () -> paperVersion));
|
|
||||||
|
|
||||||
metrics.addCustomChart(new Metrics.DrilldownPie("java_version", () -> {
|
metrics.addCustomChart(new Metrics.DrilldownPie("java_version", () -> {
|
||||||
Map<String, Map<String, Integer>> map = new HashMap<>();
|
Map<String, Map<String, Integer>> map = new HashMap<>();
|
||||||
diff --git a/src/main/java/com/destroystokyo/paper/console/PaperConsole.java b/src/main/java/com/destroystokyo/paper/console/PaperConsole.java
|
|
||||||
index c5d5648f4ca603ef2b1df723b58f9caf4dd3c722..2fbb5fc19e6d7f3767c7c6eedcbc6af2b0877ae5 100644
|
|
||||||
--- a/src/main/java/com/destroystokyo/paper/console/PaperConsole.java
|
|
||||||
+++ b/src/main/java/com/destroystokyo/paper/console/PaperConsole.java
|
|
||||||
@@ -17,7 +17,7 @@ public final class PaperConsole extends SimpleTerminalConsole {
|
|
||||||
@Override
|
|
||||||
protected LineReader buildReader(LineReaderBuilder builder) {
|
|
||||||
builder
|
|
||||||
- .appName("Paper")
|
|
||||||
+ .appName("Scissors")
|
|
||||||
.variable(LineReader.HISTORY_FILE, java.nio.file.Paths.get(".console_history"))
|
|
||||||
.completer(new ConsoleCommandCompleter(this.server))
|
|
||||||
.option(LineReader.Option.COMPLETE_IN_WORD, true);
|
|
||||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||||
index fb82bb52f219e7683fe1d3c0fb3acbe2251de8d4..0f9928bf68f8bc5abfe02f41c98c63888987d9b9 100644
|
index da15a224b8b974e78b9d8d5f514229b3b2a5a63e..8ca2e2e3d2564ec0cc081ff52334484dd5561e5c 100644
|
||||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||||
@@ -1681,7 +1681,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
@@ -1696,7 +1696,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||||
|
|
||||||
@DontObfuscate
|
@DontObfuscate
|
||||||
public String getServerModName() {
|
public String getServerModName() {
|
||||||
@@ -104,15 +84,15 @@ index fb82bb52f219e7683fe1d3c0fb3acbe2251de8d4..0f9928bf68f8bc5abfe02f41c98c6388
|
|||||||
|
|
||||||
public SystemReport fillSystemReport(SystemReport details) {
|
public SystemReport fillSystemReport(SystemReport details) {
|
||||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||||
index aefbb6a3f49a74a4c8fd004aa6a4ab1ab907e878..777b727a360683a72cef8c06ab7ab1439d69ac0a 100644
|
index 8a248e34fce1e04de4460f98b7627df495c66af1..ebd5aeceb4ac1a6300bbfa70218421f0d91b7614 100644
|
||||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||||
@@ -262,7 +262,7 @@ import javax.annotation.Nullable; // Paper
|
@@ -249,7 +249,7 @@ import javax.annotation.Nullable; // Paper
|
||||||
import javax.annotation.Nonnull; // Paper
|
import javax.annotation.Nonnull; // Paper
|
||||||
|
|
||||||
public final class CraftServer implements Server {
|
public final class CraftServer implements Server {
|
||||||
- private final String serverName = "Paper"; // Paper
|
- private final String serverName = "Paper"; // Paper
|
||||||
+ private final String serverName = "Scissors"; // Scissors > // Paper
|
+ private final String serverName = "Scissors"; // Scissors // Paper
|
||||||
private final String serverVersion;
|
private final String serverVersion;
|
||||||
private final String bukkitVersion = Versioning.getBukkitVersion();
|
private final String bukkitVersion = Versioning.getBukkitVersion();
|
||||||
private final Logger logger = Logger.getLogger("Minecraft");
|
private final Logger logger = Logger.getLogger("Minecraft");
|
||||||
|
@@ -1,17 +1,17 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
From: Telesphoreo <me@telesphoreo.me>
|
From: Video <videogamesm12@gmail.com>
|
||||||
Date: Sat, 10 Dec 2022 22:25:38 -0600
|
Date: Sat, 12 Mar 2022 19:34:59 -0700
|
||||||
Subject: [PATCH] Return null when a show_entity hover event's UUID isn't valid
|
Subject: [PATCH] Return null when a show_entity hover event's UUID isn't valid
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/network/chat/HoverEvent.java b/src/main/java/net/minecraft/network/chat/HoverEvent.java
|
diff --git a/src/main/java/net/minecraft/network/chat/HoverEvent.java b/src/main/java/net/minecraft/network/chat/HoverEvent.java
|
||||||
index 3ad05bbab726c59e7b67d9614af4b208d4520cb3..c0633f9553fb5aa52e8ffc863159521d09cb3bd5 100644
|
index b31ff9d237f593e58b42b453632aa2c2af74f986..67feb4e688d049e9f74f0deabb1ec583336a29be 100644
|
||||||
--- a/src/main/java/net/minecraft/network/chat/HoverEvent.java
|
--- a/src/main/java/net/minecraft/network/chat/HoverEvent.java
|
||||||
+++ b/src/main/java/net/minecraft/network/chat/HoverEvent.java
|
+++ b/src/main/java/net/minecraft/network/chat/HoverEvent.java
|
||||||
@@ -174,7 +174,14 @@ public class HoverEvent {
|
@@ -174,7 +174,14 @@ public class HoverEvent {
|
||||||
} else {
|
} else {
|
||||||
JsonObject jsonObject = json.getAsJsonObject();
|
JsonObject jsonObject = json.getAsJsonObject();
|
||||||
EntityType<?> entityType = BuiltInRegistries.ENTITY_TYPE.get(new ResourceLocation(GsonHelper.getAsString(jsonObject, "type")));
|
EntityType<?> entityType = Registry.ENTITY_TYPE.get(new ResourceLocation(GsonHelper.getAsString(jsonObject, "type")));
|
||||||
- UUID uUID = UUID.fromString(GsonHelper.getAsString(jsonObject, "id"));
|
- UUID uUID = UUID.fromString(GsonHelper.getAsString(jsonObject, "id"));
|
||||||
+ // Scissors start
|
+ // Scissors start
|
||||||
+ UUID uUID;
|
+ UUID uUID;
|
||||||
@@ -27,7 +27,7 @@ index 3ad05bbab726c59e7b67d9614af4b208d4520cb3..c0633f9553fb5aa52e8ffc863159521d
|
|||||||
@@ -186,7 +193,14 @@ public class HoverEvent {
|
@@ -186,7 +193,14 @@ public class HoverEvent {
|
||||||
CompoundTag compoundTag = TagParser.parseTag(text.getString());
|
CompoundTag compoundTag = TagParser.parseTag(text.getString());
|
||||||
Component component = Component.Serializer.fromJson(compoundTag.getString("name"));
|
Component component = Component.Serializer.fromJson(compoundTag.getString("name"));
|
||||||
EntityType<?> entityType = BuiltInRegistries.ENTITY_TYPE.get(new ResourceLocation(compoundTag.getString("type")));
|
EntityType<?> entityType = Registry.ENTITY_TYPE.get(new ResourceLocation(compoundTag.getString("type")));
|
||||||
- UUID uUID = UUID.fromString(compoundTag.getString("id"));
|
- UUID uUID = UUID.fromString(compoundTag.getString("id"));
|
||||||
+ // Scissors start
|
+ // Scissors start
|
||||||
+ UUID uUID;
|
+ UUID uUID;
|
||||||
|
@@ -1,25 +1,25 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
From: Video <videogamesm12@gmail.com>
|
From: Video <videogamesm12@gmail.com>
|
||||||
Date: Fri, 10 Jun 2022 22:55:01 -0500
|
Date: Sun, 13 Mar 2022 07:39:26 -0600
|
||||||
Subject: [PATCH] Fixes invalid LootTables causing problems when applied to
|
Subject: [PATCH] Fixes invalid LootTables causing problems when applied to
|
||||||
Minecart entities
|
Minecart entities
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/com/destroystokyo/paper/loottable/PaperContainerEntityLootableInventory.java b/src/main/java/com/destroystokyo/paper/loottable/PaperContainerEntityLootableInventory.java
|
diff --git a/src/main/java/com/destroystokyo/paper/loottable/PaperMinecartLootableInventory.java b/src/main/java/com/destroystokyo/paper/loottable/PaperMinecartLootableInventory.java
|
||||||
index d4a8c1bbb8fef27ac42bdf27dde495b4c649e6cb..865c61accf211d28be3c82dcf158fec9778b50c1 100644
|
index 83dd3c254fd10e4596e454cc75c8e5e976b73ac0..1b2533bbbc62bcb0d00789312ba72a49f8f49f42 100644
|
||||||
--- a/src/main/java/com/destroystokyo/paper/loottable/PaperContainerEntityLootableInventory.java
|
--- a/src/main/java/com/destroystokyo/paper/loottable/PaperMinecartLootableInventory.java
|
||||||
+++ b/src/main/java/com/destroystokyo/paper/loottable/PaperContainerEntityLootableInventory.java
|
+++ b/src/main/java/com/destroystokyo/paper/loottable/PaperMinecartLootableInventory.java
|
||||||
@@ -17,7 +17,7 @@ public class PaperContainerEntityLootableInventory implements PaperLootableEntit
|
@@ -16,7 +16,7 @@ public class PaperMinecartLootableInventory implements PaperLootableEntityInvent
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public org.bukkit.loot.LootTable getLootTable() {
|
public org.bukkit.loot.LootTable getLootTable() {
|
||||||
- return entity.getLootTable() != null && !entity.getLootTable().getPath().isEmpty() ? Bukkit.getLootTable(CraftNamespacedKey.fromMinecraft(entity.getLootTable())) : null;
|
- return entity.lootTable != null && !entity.lootTable.getPath().isEmpty() ? Bukkit.getLootTable(CraftNamespacedKey.fromMinecraft(entity.lootTable)) : null;
|
||||||
+ return entity.getLootTable() != null && !entity.getLootTable().getPath().isEmpty() && entity.getLootTable().toString().length() < 256 ? Bukkit.getLootTable(CraftNamespacedKey.fromMinecraft(entity.getLootTable())) : null; // Scissors - Validate length of loot tables before even trying
|
+ return entity.lootTable != null && !entity.lootTable.getPath().isEmpty() && entity.lootTable.toString().length() < 256 ? Bukkit.getLootTable(CraftNamespacedKey.fromMinecraft(entity.lootTable)) : null; // Scissors - Validate length of loot tables before even trying
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
diff --git a/src/main/java/com/destroystokyo/paper/loottable/PaperTileEntityLootableInventory.java b/src/main/java/com/destroystokyo/paper/loottable/PaperTileEntityLootableInventory.java
|
diff --git a/src/main/java/com/destroystokyo/paper/loottable/PaperTileEntityLootableInventory.java b/src/main/java/com/destroystokyo/paper/loottable/PaperTileEntityLootableInventory.java
|
||||||
index 2ee4ee14ab3345486dad6b24fd9a4fcc6c746b99..c5ac6cda91a81d3075f5c763e30dc009b6be7936 100644
|
index 94dc68182ec5f6dc1294ad15523427836228086a..07075cea760562c901d4469a7f88271c3ffa30bb 100644
|
||||||
--- a/src/main/java/com/destroystokyo/paper/loottable/PaperTileEntityLootableInventory.java
|
--- a/src/main/java/com/destroystokyo/paper/loottable/PaperTileEntityLootableInventory.java
|
||||||
+++ b/src/main/java/com/destroystokyo/paper/loottable/PaperTileEntityLootableInventory.java
|
+++ b/src/main/java/com/destroystokyo/paper/loottable/PaperTileEntityLootableInventory.java
|
||||||
@@ -15,7 +15,7 @@ public class PaperTileEntityLootableInventory implements PaperLootableBlockInven
|
@@ -15,7 +15,7 @@ public class PaperTileEntityLootableInventory implements PaperLootableBlockInven
|
||||||
@@ -31,16 +31,16 @@ index 2ee4ee14ab3345486dad6b24fd9a4fcc6c746b99..c5ac6cda91a81d3075f5c763e30dc009
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java
|
diff --git a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java
|
||||||
index b9f0dae1ec96194fe78c086b63d8a18b1d0cfcf7..bdc49a9965fd3add3dfca31fb0517c14597fb076 100644
|
index 8a07d5d25086d7544757bb86181fbe2b5e743d29..ef50d9747f2a027e356b05ad8d94ffb2fd4a423e 100644
|
||||||
--- a/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java
|
--- a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java
|
||||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java
|
+++ b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java
|
||||||
@@ -46,7 +46,7 @@ public abstract class RandomizableContainerBlockEntity extends BaseContainerBloc
|
@@ -219,7 +219,7 @@ public abstract class AbstractMinecartContainer extends AbstractMinecart impleme
|
||||||
protected boolean tryLoadLootTable(CompoundTag nbt) {
|
|
||||||
this.lootableData.loadNbt(nbt); // Paper
|
this.lootableData.loadNbt(nbt); // Paper
|
||||||
|
this.itemStacks = NonNullList.withSize(this.getContainerSize(), ItemStack.EMPTY);
|
||||||
if (nbt.contains("LootTable", 8)) {
|
if (nbt.contains("LootTable", 8)) {
|
||||||
- this.lootTable = new ResourceLocation(nbt.getString("LootTable"));
|
- this.lootTable = new ResourceLocation(nbt.getString("LootTable"));
|
||||||
+ this.lootTable = ResourceLocation.tryParse(nbt.getString("LootTable")); // Scissors - Validate loot tables
|
+ this.lootTable = ResourceLocation.tryParse(nbt.getString("LootTable")); // Scissors - Validate loot tables
|
||||||
try { org.bukkit.craftbukkit.util.CraftNamespacedKey.fromMinecraft(this.lootTable); } catch (IllegalArgumentException ex) { this.lootTable = null; } // Paper - validate
|
|
||||||
this.lootTableSeed = nbt.getLong("LootTableSeed");
|
this.lootTableSeed = nbt.getLong("LootTableSeed");
|
||||||
return false; // Paper - always load the items, table may still remain
|
} if (true) { // Paper - always load the items, table may still remain
|
||||||
|
ContainerHelper.loadAllItems(nbt, this.itemStacks);
|
||||||
|
@@ -5,7 +5,7 @@ Subject: [PATCH] Fixes log spam caused by invalid entities in beehives
|
|||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java
|
diff --git a/src/main/java/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java
|
||||||
index 41c9f074203915c31c1ae7a160ce509c13383f84..79a7fff759f062b783a540079cb43f2942799715 100644
|
index 483dc52c793d9f90a35b1d091dd8ce71115e4640..61097643950b1182e3751c6a4629cf5661dcf3b8 100644
|
||||||
--- a/src/main/java/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java
|
--- a/src/main/java/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java
|
||||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java
|
+++ b/src/main/java/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java
|
||||||
@@ -11,6 +11,7 @@ import net.minecraft.nbt.CompoundTag;
|
@@ -11,6 +11,7 @@ import net.minecraft.nbt.CompoundTag;
|
||||||
@@ -16,7 +16,7 @@ index 41c9f074203915c31c1ae7a160ce509c13383f84..79a7fff759f062b783a540079cb43f29
|
|||||||
import net.minecraft.sounds.SoundEvents;
|
import net.minecraft.sounds.SoundEvents;
|
||||||
import net.minecraft.sounds.SoundSource;
|
import net.minecraft.sounds.SoundSource;
|
||||||
import net.minecraft.tags.BlockTags;
|
import net.minecraft.tags.BlockTags;
|
||||||
@@ -370,6 +371,13 @@ public class BeehiveBlockEntity extends BlockEntity {
|
@@ -367,6 +368,13 @@ public class BeehiveBlockEntity extends BlockEntity {
|
||||||
|
|
||||||
for (int i = 0; i < nbttaglist.size(); ++i) {
|
for (int i = 0; i < nbttaglist.size(); ++i) {
|
||||||
CompoundTag nbttagcompound1 = nbttaglist.getCompound(i);
|
CompoundTag nbttagcompound1 = nbttaglist.getCompound(i);
|
||||||
|
@@ -5,20 +5,20 @@ Subject: [PATCH] Fixes the Blank SkullOwner exploit
|
|||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java
|
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java
|
||||||
index deed77a3d44bc55681483d7f47f148b5220135f2..053cb78362006a94ee0d82b9b1f665c5f86a4458 100644
|
index 292ae4a68093b7d939a755e1062cee57da186ab1..4ae030580131252b849fd356717d0323c29cf773 100644
|
||||||
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java
|
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java
|
||||||
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java
|
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java
|
||||||
@@ -11,6 +11,9 @@ import net.minecraft.nbt.CompoundTag;
|
@@ -7,6 +7,9 @@ import java.util.UUID;
|
||||||
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.nbt.NbtUtils;
|
import net.minecraft.nbt.NbtUtils;
|
||||||
import net.minecraft.resources.ResourceLocation;
|
|
||||||
import net.minecraft.world.level.block.entity.SkullBlockEntity;
|
import net.minecraft.world.level.block.entity.SkullBlockEntity;
|
||||||
+// Scissors start
|
+// Scissors start
|
||||||
+import org.apache.commons.lang3.StringUtils;
|
+import org.apache.commons.lang3.StringUtils;
|
||||||
+// Scissors end
|
+// Scissors end
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.NamespacedKey;
|
import org.bukkit.OfflinePlayer;
|
||||||
@@ -73,7 +76,9 @@ class CraftMetaSkull extends CraftMetaItem implements SkullMeta {
|
@@ -45,7 +48,9 @@ class CraftMetaSkull extends CraftMetaItem implements SkullMeta {
|
||||||
|
|
||||||
if (tag.contains(SKULL_OWNER.NBT, CraftMagicNumbers.NBT.TAG_COMPOUND)) {
|
if (tag.contains(SKULL_OWNER.NBT, CraftMagicNumbers.NBT.TAG_COMPOUND)) {
|
||||||
this.setProfile(NbtUtils.readGameProfile(tag.getCompound(SKULL_OWNER.NBT)));
|
this.setProfile(NbtUtils.readGameProfile(tag.getCompound(SKULL_OWNER.NBT)));
|
||||||
@@ -28,4 +28,4 @@ index deed77a3d44bc55681483d7f47f148b5220135f2..053cb78362006a94ee0d82b9b1f665c5
|
|||||||
+ // Scissors end
|
+ // Scissors end
|
||||||
this.setProfile(new GameProfile(null, tag.getString(SKULL_OWNER.NBT)));
|
this.setProfile(new GameProfile(null, tag.getString(SKULL_OWNER.NBT)));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
@@ -0,0 +1,23 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Luna <lunahatesgogle@gmail.com>
|
||||||
|
Date: Sun, 13 Mar 2022 11:07:34 -0300
|
||||||
|
Subject: [PATCH] Ignore null/air bundle items in CraftMetaBundle
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBundle.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBundle.java
|
||||||
|
index 8fd1e392258eba9dbe2194c024ad7e0ca3e43cf8..28be42594857f2d8320a035c1f8b95cdc300ddd5 100644
|
||||||
|
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBundle.java
|
||||||
|
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBundle.java
|
||||||
|
@@ -49,7 +49,11 @@ public class CraftMetaBundle extends CraftMetaItem implements BundleMeta {
|
||||||
|
for (int i = 0; i < list.size(); i++) {
|
||||||
|
CompoundTag nbttagcompound1 = list.getCompound(i);
|
||||||
|
|
||||||
|
- this.addItem(CraftItemStack.asCraftMirror(net.minecraft.world.item.ItemStack.of(nbttagcompound1)));
|
||||||
|
+ // Scissors start
|
||||||
|
+ CraftItemStack item = CraftItemStack.asCraftMirror(net.minecraft.world.item.ItemStack.of(nbttagcompound1));
|
||||||
|
+ if(item == null || item.getType().isAir()) continue;
|
||||||
|
+ this.addItem(item);
|
||||||
|
+ // Scissors end
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -1,14 +1,22 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
From: Video <videogamesm12@gmail.com>
|
From: Video <videogamesm12@gmail.com>
|
||||||
Date: Fri, 10 Jun 2022 23:26:03 -0500
|
Date: Sun, 13 Mar 2022 07:47:20 -0600
|
||||||
Subject: [PATCH] Removes useless spammy error logging
|
Subject: [PATCH] Removes useless spammy error logging
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
||||||
index 4caf272f065a681bd7101d52fedf2642cc78d3bc..af5a1111a06789e1401f8c60bb4c8838587f2376 100644
|
index 5607dc10dc1c9d2dbf4e3007890e5e89a175605e..bc30df2009cf0d8edf0040f6fe16587d109cebdb 100644
|
||||||
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
||||||
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
||||||
@@ -1798,8 +1798,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
@@ -1769,6 +1769,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
||||||
|
try {
|
||||||
|
blockParser = blockParser.parse(false);
|
||||||
|
} catch (com.mojang.brigadier.exceptions.CommandSyntaxException e) {
|
||||||
|
+ // Scissors - Don't log errors thrown by Brigadier when an error is thrown
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -1794,8 +1795,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
||||||
resource = CraftNamespacedKey.fromMinecraft(key);
|
resource = CraftNamespacedKey.fromMinecraft(key);
|
||||||
}
|
}
|
||||||
} catch (IllegalArgumentException ex) {
|
} catch (IllegalArgumentException ex) {
|
@@ -1,22 +1,22 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
From: Telesphoreo <me@telesphoreo.me>
|
From: Video <videogamesm12@gmail.com>
|
||||||
Date: Thu, 8 Jun 2023 19:19:37 -0500
|
Date: Sun, 13 Mar 2022 08:14:44 -0600
|
||||||
Subject: [PATCH] Ignore errors thrown when trying to remove minecart entities
|
Subject: [PATCH] Ignore errors thrown when trying to remove minecart entities
|
||||||
with content in them
|
with content in them
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java
|
diff --git a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java
|
||||||
index 272095d7a09ab41227d741172735f66fd2798ce1..ea966ea94062be3ed9b6b2c460a316378c016fa7 100644
|
index ef50d9747f2a027e356b05ad8d94ffb2fd4a423e..cd8ede69be1f728663a670085113d842ec0209af 100644
|
||||||
--- a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java
|
--- a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java
|
||||||
+++ b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java
|
+++ b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java
|
||||||
@@ -139,7 +139,12 @@ public abstract class AbstractMinecartContainer extends AbstractMinecart impleme
|
@@ -192,7 +192,12 @@ public abstract class AbstractMinecartContainer extends AbstractMinecart impleme
|
||||||
@Override
|
@Override
|
||||||
public void remove(Entity.RemovalReason reason) {
|
public void remove(Entity.RemovalReason reason) {
|
||||||
if (!this.level().isClientSide && reason.shouldDestroy()) {
|
if (!this.level.isClientSide && reason.shouldDestroy()) {
|
||||||
- Containers.dropContents(this.level(), (Entity) this, (Container) this);
|
- Containers.dropContents(this.level, (Entity) this, (Container) this);
|
||||||
+ // Scissors start - Ignore errors thrown when trying to remove minecart entities with content in them
|
+ // Scissors start - Ignore errors thrown when trying to remove minecart entities with content in them
|
||||||
+ try {
|
+ try {
|
||||||
+ Containers.dropContents(this.level(), (Entity) this, (Container) this);
|
+ Containers.dropContents(this.level, (Entity) this, (Container) this);
|
||||||
+ } catch (Exception ignored) {
|
+ } catch (Exception ignored) {
|
||||||
+ }
|
+ }
|
||||||
+ // Scissors end
|
+ // Scissors end
|
@@ -5,23 +5,21 @@ Subject: [PATCH] ItemEntity - Check if items are air before calling setItem
|
|||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
|
diff --git a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
|
||||||
index 3d41dbe0285f8fec8adae1e93010cf464df9b08c..7ee2c5beaaca9deb61589074f55e4004d1dd76b5 100644
|
index 9ca37cbf829ff4240ae79fc283bcf9e7f2c728d2..bc71ca6e082a137d17ee0bf43de72095bd19ab3d 100644
|
||||||
--- a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
|
--- a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
|
||||||
+++ b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
|
+++ b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
|
||||||
@@ -420,11 +420,15 @@ public class ItemEntity extends Entity implements TraceableEntity {
|
@@ -379,11 +379,14 @@ public class ItemEntity extends Entity {
|
||||||
|
|
||||||
CompoundTag nbttagcompound1 = nbt.getCompound("Item");
|
CompoundTag nbttagcompound1 = nbt.getCompound("Item");
|
||||||
|
|
||||||
- this.setItem(ItemStack.of(nbttagcompound1));
|
- this.setItem(ItemStack.of(nbttagcompound1));
|
||||||
- if (this.getItem().isEmpty()) {
|
|
||||||
+ // Scissors start
|
+ // Scissors start
|
||||||
+ ItemStack item = ItemStack.of(nbttagcompound1);
|
if (this.getItem().isEmpty()) {
|
||||||
+ if (item.isEmpty()) {
|
|
||||||
this.discard();
|
this.discard();
|
||||||
+ return;
|
+ return;
|
||||||
}
|
}
|
||||||
|
|
||||||
+ this.setItem(item);
|
+ this.setItem(ItemStack.of(nbttagcompound1));
|
||||||
+ // Scissors end
|
+ // Scissors end
|
||||||
}
|
}
|
||||||
|
|
@@ -31,10 +31,10 @@ index b79f4ce38a42e4dba8ebdfc97dadc531b7245c7a..9c49be7c53a1f2a8c203341b8ded9cd2
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaKnowledgeBook.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaKnowledgeBook.java
|
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaKnowledgeBook.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaKnowledgeBook.java
|
||||||
index 50fdb086ffec84edc5138737c95f08ed4757a6f3..bb0f673a619810850df0d78bb4abd9d7c49ecbe4 100644
|
index e816e505cd292d6c5138dff0aeae0e9592c09de0..0f6438dfe0a6620eb87233b9eefbe2340dfc347b 100644
|
||||||
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaKnowledgeBook.java
|
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaKnowledgeBook.java
|
||||||
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaKnowledgeBook.java
|
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaKnowledgeBook.java
|
||||||
@@ -41,7 +41,12 @@ public class CraftMetaKnowledgeBook extends CraftMetaItem implements KnowledgeBo
|
@@ -42,7 +42,12 @@ public class CraftMetaKnowledgeBook extends CraftMetaItem implements KnowledgeBo
|
||||||
for (int i = 0; i < pages.size(); i++) {
|
for (int i = 0; i < pages.size(); i++) {
|
||||||
String recipe = pages.getString(i);
|
String recipe = pages.getString(i);
|
||||||
|
|
@@ -1,32 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Telesphoreo <me@telesphoreo.me>
|
|
||||||
Date: Sat, 10 Dec 2022 22:46:24 -0600
|
|
||||||
Subject: [PATCH] Validate BlockState and SoundEvent values
|
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/nbt/NbtUtils.java b/src/main/java/net/minecraft/nbt/NbtUtils.java
|
|
||||||
index 6dac24354192bea79a4b9eb721543110826790b2..b87999106b5068a243c064fa3c30968411996e2b 100644
|
|
||||||
--- a/src/main/java/net/minecraft/nbt/NbtUtils.java
|
|
||||||
+++ b/src/main/java/net/minecraft/nbt/NbtUtils.java
|
|
||||||
@@ -231,7 +231,7 @@ public final class NbtUtils {
|
|
||||||
if (!nbt.contains("Name", 8)) {
|
|
||||||
return Blocks.AIR.defaultBlockState();
|
|
||||||
} else {
|
|
||||||
- ResourceLocation resourceLocation = new ResourceLocation(nbt.getString("Name"));
|
|
||||||
+ ResourceLocation resourceLocation = ResourceLocation.tryParse(nbt.getString("Name")); // Scissors - Validate BlockState
|
|
||||||
Optional<? extends Holder<Block>> optional = blockLookup.get(ResourceKey.create(Registries.BLOCK, resourceLocation));
|
|
||||||
if (optional.isEmpty()) {
|
|
||||||
return Blocks.AIR.defaultBlockState();
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java b/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java
|
|
||||||
index 5d6d26cfe8f0ab68a3145214b3fc126ca7a71a66..7e0559cdcabeb33ff383be1a23f4ed04fa091867 100644
|
|
||||||
--- a/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java
|
|
||||||
+++ b/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java
|
|
||||||
@@ -541,7 +541,7 @@ public abstract class AbstractArrow extends Projectile {
|
|
||||||
this.setCritArrow(nbt.getBoolean("crit"));
|
|
||||||
this.setPierceLevel(nbt.getByte("PierceLevel"));
|
|
||||||
if (nbt.contains("SoundEvent", 8)) {
|
|
||||||
- this.soundEvent = (SoundEvent) BuiltInRegistries.SOUND_EVENT.getOptional(new ResourceLocation(nbt.getString("SoundEvent"))).orElse(this.getDefaultHitGroundSoundEvent());
|
|
||||||
+ this.soundEvent = (SoundEvent) BuiltInRegistries.SOUND_EVENT.getOptional(ResourceLocation.tryParse(nbt.getString("SoundEvent"))).orElse(this.getDefaultHitGroundSoundEvent()); // Scissors - Validate SoundEvents before trying to play them
|
|
||||||
}
|
|
||||||
|
|
||||||
this.setShotFromCrossbow(nbt.getBoolean("ShotFromCrossbow"));
|
|
@@ -0,0 +1,32 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Video <videogamesm12@gmail.com>
|
||||||
|
Date: Sun, 13 Mar 2022 21:56:29 -0600
|
||||||
|
Subject: [PATCH] Validate BlockState and SoundEvent values
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/nbt/NbtUtils.java b/src/main/java/net/minecraft/nbt/NbtUtils.java
|
||||||
|
index 050ee055b9a2a0767f58d6677ad7f2d927fbaa54..9ec5bc2c29fc98ac2fbf9ff6231e8c3215ff11a1 100644
|
||||||
|
--- a/src/main/java/net/minecraft/nbt/NbtUtils.java
|
||||||
|
+++ b/src/main/java/net/minecraft/nbt/NbtUtils.java
|
||||||
|
@@ -229,7 +229,7 @@ public final class NbtUtils {
|
||||||
|
if (!compound.contains("Name", 8)) {
|
||||||
|
return Blocks.AIR.defaultBlockState();
|
||||||
|
} else {
|
||||||
|
- Block block = Registry.BLOCK.get(new ResourceLocation(compound.getString("Name")));
|
||||||
|
+ Block block = Registry.BLOCK.get(ResourceLocation.tryParse(compound.getString("Name"))); // Scissors - Validate BlockState
|
||||||
|
BlockState blockState = block.defaultBlockState();
|
||||||
|
if (compound.contains("Properties", 10)) {
|
||||||
|
CompoundTag compoundTag = compound.getCompound("Properties");
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java b/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java
|
||||||
|
index 53d0024daf6963ac4dab575666b0d6a74a39a958..ce13ba13c30428558391defbb09a49429dd10422 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java
|
||||||
|
@@ -549,7 +549,7 @@ public abstract class AbstractArrow extends Projectile {
|
||||||
|
this.setCritArrow(nbt.getBoolean("crit"));
|
||||||
|
this.setPierceLevel(nbt.getByte("PierceLevel"));
|
||||||
|
if (nbt.contains("SoundEvent", 8)) {
|
||||||
|
- this.soundEvent = (SoundEvent) Registry.SOUND_EVENT.getOptional(new ResourceLocation(nbt.getString("SoundEvent"))).orElse(this.getDefaultHitGroundSoundEvent());
|
||||||
|
+ this.soundEvent = (SoundEvent) Registry.SOUND_EVENT.getOptional(ResourceLocation.tryParse(nbt.getString("SoundEvent"))).orElse(this.getDefaultHitGroundSoundEvent()); // Scissors - Validate SoundEvents before trying to play them
|
||||||
|
}
|
||||||
|
|
||||||
|
this.setShotFromCrossbow(nbt.getBoolean("ShotFromCrossbow"));
|
@@ -5,12 +5,12 @@ Subject: [PATCH] Even more ResourceLocation validation and log spam fixes
|
|||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/entity/AreaEffectCloud.java b/src/main/java/net/minecraft/world/entity/AreaEffectCloud.java
|
diff --git a/src/main/java/net/minecraft/world/entity/AreaEffectCloud.java b/src/main/java/net/minecraft/world/entity/AreaEffectCloud.java
|
||||||
index fa724cd34a7c469ca12068e64295cd00ad215a3c..168b60fda38a7172f4473017ccc42447b36faab2 100644
|
index 7e1885d9cc568a544e934cede32bff05c20b567a..2481c50d8eb58a003e30e2d957b877bce5123a3a 100644
|
||||||
--- a/src/main/java/net/minecraft/world/entity/AreaEffectCloud.java
|
--- a/src/main/java/net/minecraft/world/entity/AreaEffectCloud.java
|
||||||
+++ b/src/main/java/net/minecraft/world/entity/AreaEffectCloud.java
|
+++ b/src/main/java/net/minecraft/world/entity/AreaEffectCloud.java
|
||||||
@@ -425,7 +425,7 @@ public class AreaEffectCloud extends Entity implements TraceableEntity {
|
@@ -420,7 +420,7 @@ public class AreaEffectCloud extends Entity {
|
||||||
try {
|
try {
|
||||||
this.setParticle(ParticleArgument.readParticle(new StringReader(nbt.getString("Particle")), (HolderLookup) BuiltInRegistries.PARTICLE_TYPE.asLookup()));
|
this.setParticle(ParticleArgument.readParticle(new StringReader(nbt.getString("Particle"))));
|
||||||
} catch (CommandSyntaxException commandsyntaxexception) {
|
} catch (CommandSyntaxException commandsyntaxexception) {
|
||||||
- AreaEffectCloud.LOGGER.warn("Couldn't load custom particle {}", nbt.getString("Particle"), commandsyntaxexception);
|
- AreaEffectCloud.LOGGER.warn("Couldn't load custom particle {}", nbt.getString("Particle"), commandsyntaxexception);
|
||||||
+ // Scissors - Don't log custom particle errors
|
+ // Scissors - Don't log custom particle errors
|
||||||
@@ -60,10 +60,10 @@ index 0dd0ce9a9b3253e87eda12354249ec2fd2a33cf2..b6920f9432ca1736afbe775186fbbcf1
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java
|
||||||
index 620d918e302a00d5a6640648e3096988d15535a0..ac6831248b7c4f25d48391432afb613f25d7e23a 100644
|
index d775e19402188e35f79affb4ed636b6533f90ab5..29f5ab80ffbc421da911046678427755c6156894 100644
|
||||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java
|
||||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java
|
||||||
@@ -80,8 +80,18 @@ public abstract class CraftMob extends CraftLivingEntity implements Mob {
|
@@ -63,8 +63,18 @@ public abstract class CraftMob extends CraftLivingEntity implements Mob {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LootTable getLootTable() {
|
public LootTable getLootTable() {
|
@@ -5,7 +5,7 @@ Subject: [PATCH] Do not log invalid items in HoverEvent and ItemFrame
|
|||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/network/chat/HoverEvent.java b/src/main/java/net/minecraft/network/chat/HoverEvent.java
|
diff --git a/src/main/java/net/minecraft/network/chat/HoverEvent.java b/src/main/java/net/minecraft/network/chat/HoverEvent.java
|
||||||
index c0633f9553fb5aa52e8ffc863159521d09cb3bd5..7449a024265c42f28a6c9a1ed8d8f4b9e3096aac 100644
|
index 67feb4e688d049e9f74f0deabb1ec583336a29be..63dbbc0f027ab66d183f81d6a8e0f9e0b85ea562 100644
|
||||||
--- a/src/main/java/net/minecraft/network/chat/HoverEvent.java
|
--- a/src/main/java/net/minecraft/network/chat/HoverEvent.java
|
||||||
+++ b/src/main/java/net/minecraft/network/chat/HoverEvent.java
|
+++ b/src/main/java/net/minecraft/network/chat/HoverEvent.java
|
||||||
@@ -314,7 +314,7 @@ public class HoverEvent {
|
@@ -314,7 +314,7 @@ public class HoverEvent {
|
||||||
@@ -27,10 +27,10 @@ index c0633f9553fb5aa52e8ffc863159521d09cb3bd5..7449a024265c42f28a6c9a1ed8d8f4b9
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
diff --git a/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java b/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java
|
diff --git a/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java b/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java
|
||||||
index 955316687e2e29ad75a0052317a7b0f89034c82a..2537c48d1269d8ea51222412b2eeaac26a7dc4d4 100644
|
index f134a2e68d50fba021b19fac4c75fb35d0e252c6..5e79ce09bf8ba48eb7f5dfdcf1511a2964c3281d 100644
|
||||||
--- a/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java
|
--- a/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java
|
||||||
+++ b/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java
|
+++ b/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java
|
||||||
@@ -431,7 +431,7 @@ public class ItemFrame extends HangingEntity {
|
@@ -396,7 +396,7 @@ public class ItemFrame extends HangingEntity {
|
||||||
ItemStack itemstack = ItemStack.of(nbttagcompound1);
|
ItemStack itemstack = ItemStack.of(nbttagcompound1);
|
||||||
|
|
||||||
if (itemstack.isEmpty()) {
|
if (itemstack.isEmpty()) {
|
@@ -1,54 +1,54 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
From: Telesphoreo <me@telesphoreo.me>
|
From: Video <videogamesm12@gmail.com>
|
||||||
Date: Sat, 10 Dec 2022 23:02:48 -0600
|
Date: Fri, 22 Apr 2022 01:19:49 -0500
|
||||||
Subject: [PATCH] Even more resource location validation
|
Subject: [PATCH] Even more resource location validation
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/entity/AreaEffectCloud.java b/src/main/java/net/minecraft/world/entity/AreaEffectCloud.java
|
diff --git a/src/main/java/net/minecraft/world/entity/AreaEffectCloud.java b/src/main/java/net/minecraft/world/entity/AreaEffectCloud.java
|
||||||
index db3cddf8b227453c9b08e481b21101c5d2e0472d..77ae3bc5fd6cf34aae7bd3baa563f3e23e57de26 100644
|
index 2481c50d8eb58a003e30e2d957b877bce5123a3a..6b284666eae8b7e0ef8f54dfe9311a0979b420fe 100644
|
||||||
--- a/src/main/java/net/minecraft/world/entity/AreaEffectCloud.java
|
--- a/src/main/java/net/minecraft/world/entity/AreaEffectCloud.java
|
||||||
+++ b/src/main/java/net/minecraft/world/entity/AreaEffectCloud.java
|
+++ b/src/main/java/net/minecraft/world/entity/AreaEffectCloud.java
|
||||||
@@ -145,7 +145,7 @@ public class AreaEffectCloud extends Entity implements TraceableEntity {
|
@@ -143,7 +143,7 @@ public class AreaEffectCloud extends Entity {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPotionType(String string) {
|
public void setPotionType(String string) {
|
||||||
- this.setPotion(BuiltInRegistries.POTION.get(new ResourceLocation(string)));
|
- this.setPotion(Registry.POTION.get(new ResourceLocation(string)));
|
||||||
+ this.setPotion(BuiltInRegistries.POTION.get(ResourceLocation.tryParse(string))); // Scissors - Validate resource locations
|
+ this.setPotion(Registry.POTION.get(ResourceLocation.tryParse(string))); // Scissors - Validate resource locations
|
||||||
}
|
}
|
||||||
// CraftBukkit end
|
// CraftBukkit end
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/entity/EntityType.java b/src/main/java/net/minecraft/world/entity/EntityType.java
|
diff --git a/src/main/java/net/minecraft/world/entity/EntityType.java b/src/main/java/net/minecraft/world/entity/EntityType.java
|
||||||
index 9afc81ccb237c3655d64cdbe8a0db9a4d7791043..ffcb77755b28bcdb3eae981fc735e6dde664bb6e 100644
|
index 79abd84696ef099f6b12ddeaa6e398f18c53316a..7070b64c0c66b5c9d09bf7764ce506f4461dbac5 100644
|
||||||
--- a/src/main/java/net/minecraft/world/entity/EntityType.java
|
--- a/src/main/java/net/minecraft/world/entity/EntityType.java
|
||||||
+++ b/src/main/java/net/minecraft/world/entity/EntityType.java
|
+++ b/src/main/java/net/minecraft/world/entity/EntityType.java
|
||||||
@@ -588,7 +588,7 @@ public class EntityType<T extends Entity> implements FeatureElement, EntityTypeT
|
@@ -514,7 +514,7 @@ public class EntityType<T extends Entity> implements EntityTypeTest<Entity, T> {
|
||||||
}), (entity) -> {
|
}), (entity) -> {
|
||||||
entity.load(nbt);
|
entity.load(nbt);
|
||||||
}, () -> {
|
}, () -> {
|
||||||
- EntityType.LOGGER.warn("Skipping Entity with id {}", nbt.getString("id"));
|
- EntityType.LOGGER.warn("Skipping Entity with id {}", nbt.getString("id"));
|
||||||
+ /*EntityType.LOGGER.warn("Skipping Entity with id {}", nbt.getString("id"));*/ // Scissors - Don't log invalid entities
|
+ // Scissors - Don't log invalid entities
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -607,7 +607,7 @@ public class EntityType<T extends Entity> implements FeatureElement, EntityTypeT
|
@@ -538,7 +538,7 @@ public class EntityType<T extends Entity> implements EntityTypeTest<Entity, T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Optional<EntityType<?>> by(CompoundTag nbt) {
|
public static Optional<EntityType<?>> by(CompoundTag nbt) {
|
||||||
- return BuiltInRegistries.ENTITY_TYPE.getOptional(new ResourceLocation(nbt.getString("id")));
|
- return Registry.ENTITY_TYPE.getOptional(new ResourceLocation(nbt.getString("id")));
|
||||||
+ return BuiltInRegistries.ENTITY_TYPE.getOptional(ResourceLocation.tryParse(nbt.getString("id")));
|
+ return Registry.ENTITY_TYPE.getOptional(ResourceLocation.tryParse(nbt.getString("id"))); // Scissors - Validate resource locations
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java
|
diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java
|
||||||
index e2a25c29ec74147b3e66aa0b3deb85a8f6ee53a5..b0c953ad8275740679c847e348b311de93d64965 100644
|
index e3227a806d9e19923783122ea94ae19e7dbe71da..473dba5213f6aed7573e970119f4b6ad0e4f6367 100644
|
||||||
--- a/src/main/java/net/minecraft/world/entity/Mob.java
|
--- a/src/main/java/net/minecraft/world/entity/Mob.java
|
||||||
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
|
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
|
||||||
@@ -618,7 +618,7 @@ public abstract class Mob extends LivingEntity implements Targeting {
|
@@ -572,7 +572,7 @@ public abstract class Mob extends LivingEntity {
|
||||||
|
|
||||||
this.setLeftHanded(nbt.getBoolean("LeftHanded"));
|
this.setLeftHanded(nbt.getBoolean("LeftHanded"));
|
||||||
if (nbt.contains("DeathLootTable", 8)) {
|
if (nbt.contains("DeathLootTable", 8)) {
|
||||||
- this.lootTable = new ResourceLocation(nbt.getString("DeathLootTable"));
|
- this.lootTable = new ResourceLocation(nbt.getString("DeathLootTable"));
|
||||||
+ this.lootTable = ResourceLocation.tryParse(nbt.getString("DeathLootTable"));
|
+ this.lootTable = ResourceLocation.tryParse(nbt.getString("DeathLootTable")); // Scissors - Validate resource locations
|
||||||
this.lootTableSeed = nbt.getLong("DeathLootTableSeed");
|
this.lootTableSeed = nbt.getLong("DeathLootTableSeed");
|
||||||
}
|
}
|
||||||
|
|
@@ -1,33 +1,28 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
From: Telesphoreo <me@telesphoreo.me>
|
From: Telesphoreo <me@telesphoreo.me>
|
||||||
Date: Fri, 7 Apr 2023 15:35:35 -0500
|
Date: Sat, 26 Mar 2022 21:51:07 -0500
|
||||||
Subject: [PATCH] Change version fetcher to AMG
|
Subject: [PATCH] Change version fetcher to AMG
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java b/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java
|
diff --git a/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java b/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java
|
||||||
index 9d687da5bdf398bb3f6c84cdf1249a7213d09f2e..0a8fda6939152d393f07e5d2812409ad38855646 100644
|
index bf42969859545a8a520923ef1836ffa4a5cc24a0..2ee707e109f146c83cdea162c119ea96c0ff4f8f 100644
|
||||||
--- a/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java
|
--- a/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java
|
||||||
+++ b/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java
|
+++ b/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java
|
||||||
@@ -4,11 +4,13 @@ import com.destroystokyo.paper.util.VersionFetcher;
|
@@ -4,6 +4,8 @@ import com.destroystokyo.paper.util.VersionFetcher;
|
||||||
import com.google.common.base.Charsets;
|
import com.google.common.base.Charsets;
|
||||||
import com.google.common.io.Resources;
|
import com.google.common.io.Resources;
|
||||||
import com.google.gson.*;
|
import com.google.gson.*;
|
||||||
+import io.papermc.paper.util.JarManifests;
|
+import io.papermc.paper.util.JarManifests;
|
||||||
|
+import java.util.Map;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.event.ClickEvent;
|
import net.kyori.adventure.text.event.ClickEvent;
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import net.kyori.adventure.text.format.TextDecoration;
|
|
||||||
import net.kyori.adventure.text.TextComponent;
|
|
||||||
+import org.bukkit.Bukkit;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
@@ -19,8 +21,8 @@ import java.util.stream.StreamSupport;
|
@@ -19,8 +21,8 @@ import java.util.stream.StreamSupport;
|
||||||
|
|
||||||
public class PaperVersionFetcher implements VersionFetcher {
|
public class PaperVersionFetcher implements VersionFetcher {
|
||||||
private static final java.util.regex.Pattern VER_PATTERN = java.util.regex.Pattern.compile("^([0-9\\.]*)\\-.*R"); // R is an anchor, will always give '-R' at end
|
private static final java.util.regex.Pattern VER_PATTERN = java.util.regex.Pattern.compile("^([0-9\\.]*)\\-.*R"); // R is an anchor, will always give '-R' at end
|
||||||
- private static final String GITHUB_BRANCH_NAME = "master";
|
- private static final String GITHUB_BRANCH_NAME = "master";
|
||||||
- private static final String DOWNLOAD_PAGE = "https://papermc.io/downloads/paper";
|
- private static final String DOWNLOAD_PAGE = "https://papermc.io/downloads";
|
||||||
+ private static final String GITHUB_BRANCH_NAME = getBranch();
|
+ private static final String GITHUB_BRANCH_NAME = getBranch();
|
||||||
+ private static final String DOWNLOAD_PAGE = "https://ci.scissors.gg/job/Scissors/job/" + GITHUB_BRANCH_NAME;
|
+ private static final String DOWNLOAD_PAGE = "https://ci.scissors.gg/job/Scissors/job/" + GITHUB_BRANCH_NAME;
|
||||||
private static @Nullable String mcVer;
|
private static @Nullable String mcVer;
|
||||||
@@ -50,13 +45,13 @@ index 9d687da5bdf398bb3f6c84cdf1249a7213d09f2e..0a8fda6939152d393f07e5d2812409ad
|
|||||||
|
|
||||||
+ // Scissors start - Allow getting git information
|
+ // Scissors start - Allow getting git information
|
||||||
+ public static String getCommit() {
|
+ public static String getCommit() {
|
||||||
+ final var manifest = JarManifests.manifest(Bukkit.getServer().getClass());
|
+ Map<String, String> attributes = JarManifests.MANIFEST_MAP;
|
||||||
+ return manifest == null ? null : manifest.getMainAttributes().getValue("Git-Commit");
|
+ return attributes.get("Git-Commit");
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ public static String getBranch() {
|
+ public static String getBranch() {
|
||||||
+ final var manifest = JarManifests.manifest(Bukkit.getServer().getClass());
|
+ Map<String, String> attributes = JarManifests.MANIFEST_MAP;
|
||||||
+ return manifest == null ? null : manifest.getMainAttributes().getValue("Git-Branch");
|
+ return attributes.get("Git-Branch");
|
||||||
+ }
|
+ }
|
||||||
+ // Scissors end
|
+ // Scissors end
|
||||||
+
|
+
|
||||||
@@ -77,14 +72,14 @@ index 9d687da5bdf398bb3f6c84cdf1249a7213d09f2e..0a8fda6939152d393f07e5d2812409ad
|
|||||||
switch (distance) {
|
switch (distance) {
|
||||||
case -1:
|
case -1:
|
||||||
diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java
|
diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java
|
||||||
index bfa091f72d6f477bcaf63d364639a1b4df9b1987..1fe26cb620e8b550790c3e110e2a1180cf0838fd 100644
|
index fbe68bd4739d9a0e7d9bc4c3d5ba8ecfd2d13954..40313b014b4ed5f7e9505bde2827383c19d4377a 100644
|
||||||
--- a/src/main/java/org/bukkit/craftbukkit/Main.java
|
--- a/src/main/java/org/bukkit/craftbukkit/Main.java
|
||||||
+++ b/src/main/java/org/bukkit/craftbukkit/Main.java
|
+++ b/src/main/java/org/bukkit/craftbukkit/Main.java
|
||||||
@@ -292,7 +292,7 @@ public class Main {
|
@@ -265,7 +265,7 @@ public class Main {
|
||||||
if (buildDate.before(deadline.getTime())) {
|
if (buildDate.before(deadline.getTime())) {
|
||||||
// Paper start - This is some stupid bullshit
|
// Paper start - This is some stupid bullshit
|
||||||
System.err.println("*** Warning, you've not updated in a while! ***");
|
System.err.println("*** Warning, you've not updated in a while! ***");
|
||||||
- System.err.println("*** Please download a new build as per instructions from https://papermc.io/downloads/paper ***"); // Paper
|
- System.err.println("*** Please download a new build as per instructions from https://papermc.io/downloads ***"); // Paper
|
||||||
+ System.err.println("*** Please download a new build from https://ci.scissors.gg/job/Scissors ***"); // Scissors > // Paper
|
+ System.err.println("*** Please download a new build from https://ci.scissors.gg/job/Scissors ***"); // Scissors > // Paper
|
||||||
//System.err.println("*** Server will start in 20 seconds ***");
|
//System.err.println("*** Server will start in 20 seconds ***");
|
||||||
//Thread.sleep(TimeUnit.SECONDS.toMillis(20));
|
//Thread.sleep(TimeUnit.SECONDS.toMillis(20));
|
@@ -6,18 +6,18 @@ Subject: [PATCH] Prevent attributes with invalid namespaces from being applied
|
|||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
||||||
index af5a1111a06789e1401f8c60bb4c8838587f2376..bfcdc18f9b06023a5c461e06abbb93eea32bcdba 100644
|
index 65844bb02bd3d9ef566d4779106a1f9ef2a2b7bc..f856ac2dfe55a1f1f63725ec20e7b8dd3d394acf 100644
|
||||||
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
||||||
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
||||||
@@ -46,6 +46,7 @@ import net.minecraft.nbt.NbtIo;
|
@@ -46,6 +46,7 @@ import net.minecraft.nbt.NbtIo;
|
||||||
import net.minecraft.nbt.StringTag;
|
import net.minecraft.nbt.StringTag;
|
||||||
import net.minecraft.nbt.Tag;
|
import net.minecraft.nbt.Tag;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.TextComponent;
|
||||||
+import net.minecraft.resources.ResourceLocation;
|
+import net.minecraft.resources.ResourceLocation; // Scissors
|
||||||
import net.minecraft.world.item.BlockItem;
|
import net.minecraft.world.item.BlockItem;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
|
||||||
import org.apache.commons.lang.Validate;
|
import org.apache.commons.lang.Validate;
|
||||||
@@ -485,7 +486,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
import org.apache.commons.lang3.EnumUtils;
|
||||||
|
@@ -481,7 +482,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
||||||
AttributeModifier attribMod = CraftAttributeInstance.convert(nmsModifier);
|
AttributeModifier attribMod = CraftAttributeInstance.convert(nmsModifier);
|
||||||
|
|
||||||
String attributeName = CraftAttributeMap.convertIfNeeded(entry.getString(ATTRIBUTES_IDENTIFIER.NBT)); // Paper
|
String attributeName = CraftAttributeMap.convertIfNeeded(entry.getString(ATTRIBUTES_IDENTIFIER.NBT)); // Paper
|
@@ -1,27 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Video <videogamesm12@gmail.com>
|
|
||||||
Date: Sat, 9 Apr 2022 13:00:27 -0600
|
|
||||||
Subject: [PATCH] Don't query player data in the `nbt` component
|
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/network/chat/contents/EntityDataSource.java b/src/main/java/net/minecraft/network/chat/contents/EntityDataSource.java
|
|
||||||
index 8a6799b50062c1b7b141ee1568dc523f9ee7ecfd..e5a2bb129100f0f935c8f10682204e7cb6277142 100644
|
|
||||||
--- a/src/main/java/net/minecraft/network/chat/contents/EntityDataSource.java
|
|
||||||
+++ b/src/main/java/net/minecraft/network/chat/contents/EntityDataSource.java
|
|
||||||
@@ -11,6 +11,7 @@ import net.minecraft.commands.arguments.selector.EntitySelector;
|
|
||||||
import net.minecraft.commands.arguments.selector.EntitySelectorParser;
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
|
||||||
import net.minecraft.world.entity.Entity;
|
|
||||||
+import net.minecraft.world.entity.player.Player;
|
|
||||||
|
|
||||||
public record EntityDataSource(String selectorPattern, @Nullable EntitySelector compiledSelector) implements DataSource {
|
|
||||||
public EntityDataSource(String rawPath) {
|
|
||||||
@@ -31,7 +32,7 @@ public record EntityDataSource(String selectorPattern, @Nullable EntitySelector
|
|
||||||
public Stream<CompoundTag> getData(CommandSourceStack source) throws CommandSyntaxException {
|
|
||||||
if (this.compiledSelector != null) {
|
|
||||||
List<? extends Entity> list = this.compiledSelector.findEntities(source);
|
|
||||||
- return list.stream().map(NbtPredicate::getEntityTagToCompare);
|
|
||||||
+ return list.stream().filter((entity) -> !(entity instanceof Player)).map(NbtPredicate::getEntityTagToCompare); // Scissors - Don't query NBT from players
|
|
||||||
} else {
|
|
||||||
return Stream.empty();
|
|
||||||
}
|
|
@@ -6,17 +6,17 @@ Subject: [PATCH] Validate String UUIDs during the CompoundTag -> GameProfile
|
|||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/nbt/NbtUtils.java b/src/main/java/net/minecraft/nbt/NbtUtils.java
|
diff --git a/src/main/java/net/minecraft/nbt/NbtUtils.java b/src/main/java/net/minecraft/nbt/NbtUtils.java
|
||||||
index b87999106b5068a243c064fa3c30968411996e2b..596baf1bc372875b8b82904d9d5bd53f4bedc0fb 100644
|
index 9ec5bc2c29fc98ac2fbf9ff6231e8c3215ff11a1..9ef6b0a861a2b0f6e6d54775c6b0496689d12d66 100644
|
||||||
--- a/src/main/java/net/minecraft/nbt/NbtUtils.java
|
--- a/src/main/java/net/minecraft/nbt/NbtUtils.java
|
||||||
+++ b/src/main/java/net/minecraft/nbt/NbtUtils.java
|
+++ b/src/main/java/net/minecraft/nbt/NbtUtils.java
|
||||||
@@ -78,7 +78,12 @@ public final class NbtUtils {
|
@@ -76,7 +76,12 @@ public final class NbtUtils {
|
||||||
}
|
}
|
||||||
// Paper start - support string UUID's
|
// Paper start - support string UUID's
|
||||||
if (nbt.contains("Id", 8)) {
|
if (compound.contains("Id", 8)) {
|
||||||
- uUID = UUID.fromString(nbt.getString("Id"));
|
- uUID = UUID.fromString(compound.getString("Id"));
|
||||||
+ // Scissors start - Validate String UUIDs in game profiles
|
+ // Scissors start - Validate String UUIDs in game profiles
|
||||||
+ try {
|
+ try {
|
||||||
+ uUID = UUID.fromString(nbt.getString("Id"));
|
+ uUID = UUID.fromString(compound.getString("Id"));
|
||||||
+ } catch (Exception ignored) {
|
+ } catch (Exception ignored) {
|
||||||
+ }
|
+ }
|
||||||
+ // Scissors end
|
+ // Scissors end
|
@@ -0,0 +1,27 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Video <videogamesm12@gmail.com>
|
||||||
|
Date: Sat, 9 Apr 2022 13:00:27 -0600
|
||||||
|
Subject: [PATCH] Don't query player data in the `nbt` component
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/network/chat/NbtComponent.java b/src/main/java/net/minecraft/network/chat/NbtComponent.java
|
||||||
|
index 8e658eeb4edc83db72c187baa52b7ada7b848af8..e3dc56de3f91e03b1543257f72448a734d914ed7 100644
|
||||||
|
--- a/src/main/java/net/minecraft/network/chat/NbtComponent.java
|
||||||
|
+++ b/src/main/java/net/minecraft/network/chat/NbtComponent.java
|
||||||
|
@@ -23,6 +23,7 @@ import net.minecraft.nbt.Tag;
|
||||||
|
import net.minecraft.resources.ResourceLocation;
|
||||||
|
import net.minecraft.server.level.ServerLevel;
|
||||||
|
import net.minecraft.world.entity.Entity;
|
||||||
|
+import net.minecraft.world.entity.player.Player;
|
||||||
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
|
@@ -217,7 +218,7 @@ public abstract class NbtComponent extends BaseComponent implements ContextAware
|
||||||
|
protected Stream<CompoundTag> getData(CommandSourceStack source) throws CommandSyntaxException {
|
||||||
|
if (this.compiledSelector != null) {
|
||||||
|
List<? extends Entity> list = this.compiledSelector.findEntities(source);
|
||||||
|
- return list.stream().map(NbtPredicate::getEntityTagToCompare);
|
||||||
|
+ return list.stream().filter((entity) -> !(entity instanceof Player)).map(NbtPredicate::getEntityTagToCompare); // Scissors - Don't query NBT from players
|
||||||
|
} else {
|
||||||
|
return Stream.empty();
|
||||||
|
}
|
@@ -5,10 +5,10 @@ Subject: [PATCH] Limit ListTags to 1024 elements
|
|||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/nbt/ListTag.java b/src/main/java/net/minecraft/nbt/ListTag.java
|
diff --git a/src/main/java/net/minecraft/nbt/ListTag.java b/src/main/java/net/minecraft/nbt/ListTag.java
|
||||||
index 749d3e67a877d7d1ed47b5fef511a604ee6589b6..fe7a7fd77c7dd1750144fb57e181c51ccda26329 100644
|
index ea68b26e506e48d8238b7ee4266e61b211d52bd2..10d3a1b31233f884823ee9a4bb27d70eac3914df 100644
|
||||||
--- a/src/main/java/net/minecraft/nbt/ListTag.java
|
--- a/src/main/java/net/minecraft/nbt/ListTag.java
|
||||||
+++ b/src/main/java/net/minecraft/nbt/ListTag.java
|
+++ b/src/main/java/net/minecraft/nbt/ListTag.java
|
||||||
@@ -31,6 +31,7 @@ public class ListTag extends CollectionTag<Tag> {
|
@@ -33,6 +33,7 @@ public class ListTag extends CollectionTag<Tag> {
|
||||||
list.add(tagType.load(dataInput, i + 1, nbtAccounter));
|
list.add(tagType.load(dataInput, i + 1, nbtAccounter));
|
||||||
}
|
}
|
||||||
|
|
24
patches/server/0020-Fix-lectern-quick-move.patch
Normal file
24
patches/server/0020-Fix-lectern-quick-move.patch
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Kevin Raneri <kevin.raneri@gmail.com>
|
||||||
|
Date: Sat, 2 Apr 2022 02:12:13 -0400
|
||||||
|
Subject: [PATCH] Fix lectern quick move
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/inventory/LecternMenu.java b/src/main/java/net/minecraft/world/inventory/LecternMenu.java
|
||||||
|
index ff79925bc6437222f9ceb133e21bbc0600cc74ed..e5498a5703f282160b8171a0b81711cfc24d323a 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/inventory/LecternMenu.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/inventory/LecternMenu.java
|
||||||
|
@@ -120,6 +120,13 @@ public class LecternMenu extends AbstractContainerMenu {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
+ // Paper start
|
||||||
|
+ @Override
|
||||||
|
+ public ItemStack quickMoveStack(net.minecraft.world.entity.player.Player player, int index) {
|
||||||
|
+ return ItemStack.EMPTY;
|
||||||
|
+ }
|
||||||
|
+ // Paper end
|
||||||
|
+
|
||||||
|
@Override
|
||||||
|
public void setData(int id, int value) {
|
||||||
|
super.setData(id, value);
|
@@ -1,210 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Telesphoreo <me@telesphoreo.me>
|
|
||||||
Date: Sat, 11 Jun 2022 22:56:59 -0500
|
|
||||||
Subject: [PATCH] Add custom classes used by Scissors
|
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/me/totalfreedom/scissors/MathUtility.java b/src/main/java/me/totalfreedom/scissors/MathUtility.java
|
|
||||||
new file mode 100644
|
|
||||||
index 0000000000000000000000000000000000000000..754b578b575137a9c48cb20dee965a9388fedb3c
|
|
||||||
--- /dev/null
|
|
||||||
+++ b/src/main/java/me/totalfreedom/scissors/MathUtility.java
|
|
||||||
@@ -0,0 +1,29 @@
|
|
||||||
+package me.totalfreedom.scissors;
|
|
||||||
+
|
|
||||||
+public class MathUtility
|
|
||||||
+{
|
|
||||||
+ public static int clampInt(int number, int minimum, int maximum)
|
|
||||||
+ {
|
|
||||||
+ return Math.min(Math.max(number, minimum), maximum);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ public static long clampLong(long number, long minimum, long maximum)
|
|
||||||
+ {
|
|
||||||
+ return Math.min(Math.max(number, minimum), maximum);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ public static double clampDouble(double number, double minimum, double maximum)
|
|
||||||
+ {
|
|
||||||
+ return Math.min(Math.max(number, minimum), maximum);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ public static int safeDoubleToInt(double number)
|
|
||||||
+ {
|
|
||||||
+ return (int) clampDouble(number, Integer.MIN_VALUE, Integer.MAX_VALUE);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ public static int safeLongToInt(long number)
|
|
||||||
+ {
|
|
||||||
+ return (int) clampLong(number, Integer.MIN_VALUE, Integer.MAX_VALUE);
|
|
||||||
+ }
|
|
||||||
+}
|
|
||||||
diff --git a/src/main/java/me/totalfreedom/scissors/NbtUtility.java b/src/main/java/me/totalfreedom/scissors/NbtUtility.java
|
|
||||||
new file mode 100644
|
|
||||||
index 0000000000000000000000000000000000000000..b724baaef8d565e41db1af6393d0890e919a5aa8
|
|
||||||
--- /dev/null
|
|
||||||
+++ b/src/main/java/me/totalfreedom/scissors/NbtUtility.java
|
|
||||||
@@ -0,0 +1,74 @@
|
|
||||||
+package me.totalfreedom.scissors;
|
|
||||||
+
|
|
||||||
+import java.nio.charset.StandardCharsets;
|
|
||||||
+import javax.annotation.Nullable;
|
|
||||||
+import net.minecraft.nbt.CompoundTag;
|
|
||||||
+import net.minecraft.nbt.ListTag;
|
|
||||||
+import net.minecraft.nbt.Tag;
|
|
||||||
+
|
|
||||||
+public class NbtUtility
|
|
||||||
+{
|
|
||||||
+ public static final long MAXIMUM_SIZE = (256 * 1024);
|
|
||||||
+
|
|
||||||
+ public static long getTagSize(@Nullable Tag tag, int depth)
|
|
||||||
+ {
|
|
||||||
+ if (depth > 512)
|
|
||||||
+ {
|
|
||||||
+ return 0;
|
|
||||||
+ }
|
|
||||||
+ if (tag == null)
|
|
||||||
+ {
|
|
||||||
+ return 0;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ long size = 0;
|
|
||||||
+
|
|
||||||
+ if (tag.getType() == CompoundTag.TYPE)
|
|
||||||
+ {
|
|
||||||
+ CompoundTag compoundTag = (CompoundTag) tag;
|
|
||||||
+ for (String key : compoundTag.getAllKeys())
|
|
||||||
+ {
|
|
||||||
+ size += getTagSize(compoundTag.get(key), depth + 1);
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+ else if (tag.getType() == ListTag.TYPE)
|
|
||||||
+ {
|
|
||||||
+ ListTag listTag = (ListTag) tag;
|
|
||||||
+ for (Tag tag1 : listTag)
|
|
||||||
+ {
|
|
||||||
+ size += getTagSize(tag1, depth + 1);
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+ else
|
|
||||||
+ {
|
|
||||||
+ size += tag.getAsString().getBytes(StandardCharsets.UTF_8).length;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ return size;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ public static long getTagSize(@Nullable CompoundTag tag)
|
|
||||||
+ {
|
|
||||||
+ return getTagSize(tag, 0);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ public static boolean isTooLarge(@Nullable CompoundTag tag)
|
|
||||||
+ {
|
|
||||||
+ if (tag == null)
|
|
||||||
+ {
|
|
||||||
+ return false;
|
|
||||||
+ }
|
|
||||||
+ return getTagSize(tag) > MAXIMUM_SIZE;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ public static class Item
|
|
||||||
+ {
|
|
||||||
+ public static CompoundTag removeItemData(CompoundTag tag)
|
|
||||||
+ {
|
|
||||||
+ CompoundTag cleaned = new CompoundTag();
|
|
||||||
+ cleaned.putString("id", tag.getString("id"));
|
|
||||||
+ cleaned.putByte("Count", tag.getByte("Count"));
|
|
||||||
+ return cleaned;
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+}
|
|
||||||
diff --git a/src/main/java/me/totalfreedom/scissors/PositionUtility.java b/src/main/java/me/totalfreedom/scissors/PositionUtility.java
|
|
||||||
new file mode 100644
|
|
||||||
index 0000000000000000000000000000000000000000..c54535042a7ac12fe46b3b37db8d7b116e9469d5
|
|
||||||
--- /dev/null
|
|
||||||
+++ b/src/main/java/me/totalfreedom/scissors/PositionUtility.java
|
|
||||||
@@ -0,0 +1,83 @@
|
|
||||||
+package me.totalfreedom.scissors;
|
|
||||||
+
|
|
||||||
+import net.minecraft.core.BlockPos;
|
|
||||||
+import net.minecraft.world.entity.Entity;
|
|
||||||
+import net.minecraft.world.level.Level;
|
|
||||||
+import net.minecraft.world.level.border.WorldBorder;
|
|
||||||
+import net.minecraft.world.phys.Vec3;
|
|
||||||
+
|
|
||||||
+public class PositionUtility
|
|
||||||
+{
|
|
||||||
+ public static Vec3 getValidVec3(double x, double y, double z, Entity entity)
|
|
||||||
+ {
|
|
||||||
+ final Level level = entity.level;
|
|
||||||
+
|
|
||||||
+ try
|
|
||||||
+ {
|
|
||||||
+ if (level.isInWorldBounds(new BlockPos(Math.floor(MathUtility.safeDoubleToInt(x)), Math.floor(MathUtility.safeDoubleToInt(y)), Math.floor(MathUtility.safeDoubleToInt(z)))))
|
|
||||||
+ {
|
|
||||||
+ return new Vec3(x, y, z);
|
|
||||||
+ }
|
|
||||||
+ else
|
|
||||||
+ {
|
|
||||||
+ final WorldBorder worldBorder = level.getWorldBorder();
|
|
||||||
+
|
|
||||||
+ final double maxX = worldBorder.getMaxX();
|
|
||||||
+ final double maxY = level.getMaxBuildHeight();
|
|
||||||
+ final double maxZ = worldBorder.getMaxZ();
|
|
||||||
+
|
|
||||||
+ final double minX = worldBorder.getMinX();
|
|
||||||
+ final double minY = level.getMinBuildHeight();
|
|
||||||
+ final double minZ = worldBorder.getMinZ();
|
|
||||||
+
|
|
||||||
+ return new Vec3(MathUtility.clampDouble(x, minX, maxX), MathUtility.clampDouble(y, minY, maxY), MathUtility.clampDouble(z, minZ, maxZ));
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+ catch (Exception e)
|
|
||||||
+ { // If we throw some sort of exception due to the position being crazy, catch it
|
|
||||||
+ return new Vec3(0, 0, 0);
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ public static Vec3 getValidVec3FromBlockPos(BlockPos blockPos, Entity entity)
|
|
||||||
+ {
|
|
||||||
+ final BlockPos validBlockPos = getValidBlockPos(blockPos, entity);
|
|
||||||
+
|
|
||||||
+ return new Vec3(validBlockPos.getX(), validBlockPos.getY(), validBlockPos.getZ());
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ public static BlockPos getValidBlockPos(BlockPos blockPos, Entity entity)
|
|
||||||
+ {
|
|
||||||
+ final Level level = entity.level();
|
|
||||||
+
|
|
||||||
+ try
|
|
||||||
+ {
|
|
||||||
+ if (level.isInWorldBounds(blockPos))
|
|
||||||
+ {
|
|
||||||
+ return blockPos;
|
|
||||||
+ }
|
|
||||||
+ else
|
|
||||||
+ {
|
|
||||||
+ final int x = blockPos.getX();
|
|
||||||
+ final int y = blockPos.getY();
|
|
||||||
+ final int z = blockPos.getZ();
|
|
||||||
+
|
|
||||||
+ final WorldBorder worldBorder = level.getWorldBorder();
|
|
||||||
+
|
|
||||||
+ final int maxX = MathUtility.safeDoubleToInt(worldBorder.getMaxX());
|
|
||||||
+ final int maxY = level.getMaxBuildHeight();
|
|
||||||
+ final int maxZ = MathUtility.safeDoubleToInt(worldBorder.getMaxZ());
|
|
||||||
+
|
|
||||||
+ final int minX = MathUtility.safeDoubleToInt(worldBorder.getMinX());
|
|
||||||
+ final int minY = level.getMinBuildHeight();
|
|
||||||
+ final int minZ = MathUtility.safeDoubleToInt(worldBorder.getMinZ());
|
|
||||||
+
|
|
||||||
+ return new BlockPos(MathUtility.clampInt(x, minX, maxX), MathUtility.clampInt(y, minY, maxY), MathUtility.clampInt(z, minZ, maxZ));
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+ catch (Exception e)
|
|
||||||
+ { // If we throw some sort of exception due to the position being crazy, catch it
|
|
||||||
+ return new BlockPos(0, 0, 0);
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+}
|
|
@@ -1,34 +1,36 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
From: Telesphoreo <me@telesphoreo.me>
|
From: Video <videogamesm12@gmail.com>
|
||||||
Date: Fri, 25 Nov 2022 22:25:24 -0600
|
Date: Mon, 28 Mar 2022 16:49:17 -0600
|
||||||
Subject: [PATCH] Reject oversized components from updating
|
Subject: [PATCH] Reject oversized components from updating
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/network/chat/ComponentUtils.java b/src/main/java/net/minecraft/network/chat/ComponentUtils.java
|
diff --git a/src/main/java/net/minecraft/network/chat/ComponentUtils.java b/src/main/java/net/minecraft/network/chat/ComponentUtils.java
|
||||||
index 584a58659fae6ba3d8b53858890bc6ec509ffb0e..0dcee5b53740126e0886058dacc43e447836b8d8 100644
|
index 8f4c83837d0b01a3dbca2607ea718c371db48ef4..fe2717679f84fbef1b8ff1f9a3c3bf0fba8965f1 100644
|
||||||
--- a/src/main/java/net/minecraft/network/chat/ComponentUtils.java
|
--- a/src/main/java/net/minecraft/network/chat/ComponentUtils.java
|
||||||
+++ b/src/main/java/net/minecraft/network/chat/ComponentUtils.java
|
+++ b/src/main/java/net/minecraft/network/chat/ComponentUtils.java
|
||||||
@@ -39,8 +39,10 @@ public class ComponentUtils {
|
@@ -37,8 +37,11 @@ public class ComponentUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MutableComponent updateForEntity(@Nullable CommandSourceStack source, Component text, @Nullable Entity sender, int depth) throws CommandSyntaxException {
|
public static MutableComponent updateForEntity(@Nullable CommandSourceStack source, Component text, @Nullable Entity sender, int depth) throws CommandSyntaxException {
|
||||||
+ // Scissors start - Reject oversized components
|
+ // Scissors start - Reject oversized components
|
||||||
+ MutableComponent result;
|
+ MutableComponent result;
|
||||||
|
+
|
||||||
if (depth > 100) {
|
if (depth > 100) {
|
||||||
- return text.copy();
|
- return text.copy();
|
||||||
+ result = text.copy();
|
+ result = text.copy();
|
||||||
} else {
|
} else {
|
||||||
// Paper start
|
MutableComponent mutableComponent = text instanceof ContextAwareComponent ? ((ContextAwareComponent)text).resolve(source, sender, depth + 1) : text.plainCopy();
|
||||||
if (text instanceof io.papermc.paper.adventure.AdventureComponent adventureComponent) {
|
|
||||||
@@ -53,8 +55,11 @@ public class ComponentUtils {
|
@@ -46,8 +49,12 @@ public class ComponentUtils {
|
||||||
mutableComponent.append(updateForEntity(source, component, sender, depth + 1));
|
mutableComponent.append(updateForEntity(source, component, sender, depth + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
- return mutableComponent.withStyle(resolveStyle(source, text.getStyle(), sender, depth));
|
- return mutableComponent.withStyle(resolveStyle(source, text.getStyle(), sender, depth));
|
||||||
+ result = mutableComponent.withStyle(resolveStyle(source, text.getStyle(), sender, depth));
|
+ result = mutableComponent.withStyle(resolveStyle(source, text.getStyle(), sender, depth));
|
||||||
}
|
}
|
||||||
|
+
|
||||||
+ // Would the resulting component exceed 65535 bytes when encoded as a string?
|
+ // Would the resulting component exceed 65535 bytes when encoded as a string?
|
||||||
+ return Component.Serializer.toJson(result).length() > 65535 ? Component.empty() : result;
|
+ return Component.Serializer.toJson(result).length() > 65535 ? new TextComponent("") : result;
|
||||||
+ // Scissors end
|
+ // Scissors end
|
||||||
}
|
}
|
||||||
|
|
@@ -1,64 +1,41 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
From: Video <videogamesm12@gmail.com>
|
From: Video <videogamesm12@gmail.com>
|
||||||
Date: Wed, 27 Jul 2022 22:30:39 -0500
|
Date: Fri, 22 Apr 2022 01:24:05 -0500
|
||||||
Subject: [PATCH] Validate coordinates before attempting to get block entities
|
Subject: [PATCH] Validate coordinates before attempting to get block entities
|
||||||
when handling Creative Inventory packets
|
when handling Creative Inventory packets
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||||
index 1288f651fa83d5ab99a88858f52a6d3212284df0..61f6b51b9d868ae6bd79185cc066976a094da8ce 100644
|
index 901fa17d0f0a3f66923f68f13f183bc4c17f7748..dc9199c0b1fa9b8779afc51d7af4c516d217ddb3 100644
|
||||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||||
@@ -1920,6 +1920,18 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
@@ -2991,20 +2991,25 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
||||||
}
|
if (this.player.gameMode.isCreative()) {
|
||||||
// Spigot end
|
boolean flag = packet.getSlotNum() < 0;
|
||||||
|
ItemStack itemstack = packet.getItem();
|
||||||
|
- CompoundTag nbttagcompound = BlockItem.getBlockEntityData(itemstack);
|
||||||
|
|
||||||
+ // Scissors start - Readd the following Paper code
|
+ CompoundTag nbttagcompound = BlockItem.getBlockEntityData(itemstack);
|
||||||
+ // Paper start
|
|
||||||
+ private static final int SURVIVAL_PLACE_DISTANCE_SQUARED = 6 * 6;
|
|
||||||
+ private static final int CREATIVE_PLACE_DISTANCE_SQUARED = 7 * 7;
|
|
||||||
+ private boolean isOutsideOfReach(double x, double y, double z) {
|
|
||||||
+ Location eyeLoc = this.getCraftPlayer().getEyeLocation();
|
|
||||||
+ double reachDistance = org.bukkit.util.NumberConversions.square(eyeLoc.getX() - x) + org.bukkit.util.NumberConversions.square(eyeLoc.getY() - y) + org.bukkit.util.NumberConversions.square(eyeLoc.getZ() - z);
|
|
||||||
+ return reachDistance > (this.getCraftPlayer().getGameMode() == org.bukkit.GameMode.CREATIVE ? CREATIVE_PLACE_DISTANCE_SQUARED : SURVIVAL_PLACE_DISTANCE_SQUARED);
|
|
||||||
+ }
|
|
||||||
+ // Paper end
|
|
||||||
+ // Scissors end
|
|
||||||
+
|
|
||||||
@Override
|
|
||||||
public void handleUseItemOn(ServerboundUseItemOnPacket packet) {
|
|
||||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
|
|
||||||
@@ -3344,17 +3356,24 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
|
||||||
if (!itemstack.isEmpty() && nbttagcompound != null && nbttagcompound.contains("x") && nbttagcompound.contains("y") && nbttagcompound.contains("z") && this.player.getBukkitEntity().hasPermission("minecraft.nbt.copy")) { // Spigot
|
if (!itemstack.isEmpty() && nbttagcompound != null && nbttagcompound.contains("x") && nbttagcompound.contains("y") && nbttagcompound.contains("z") && this.player.getBukkitEntity().hasPermission("minecraft.nbt.copy")) { // Spigot
|
||||||
BlockPos blockposition = BlockEntity.getPosFromTag(nbttagcompound);
|
BlockPos blockposition = BlockEntity.getPosFromTag(nbttagcompound);
|
||||||
|
// Paper start
|
||||||
- if (this.player.level().isLoaded(blockposition)) {
|
|
||||||
- // Paper start
|
|
||||||
- BlockEntity tileentity = null;
|
- BlockEntity tileentity = null;
|
||||||
- if (this.player.distanceToSqr(blockposition.getX(), blockposition.getY(), blockposition.getZ()) < 32 * 32 && this.player.serverLevel().isLoadedAndInBounds(blockposition)) {
|
+ // Scissors start - Validate coordinates and whether or not the player can reach them
|
||||||
- tileentity = this.player.level().getBlockEntity(blockposition);
|
+ if (Level.isInSpawnableBounds(blockposition) && !isOutsideOfReach(blockposition.getX(), blockposition.getY(), blockposition.getZ())) {
|
||||||
- }
|
|
||||||
- // Paper end
|
|
||||||
+ if (this.player.level().isLoaded(blockposition))
|
|
||||||
+ {
|
|
||||||
+ // Scissors start - Validate coordinates and whether the player can reach them
|
|
||||||
+ if (Level.isInSpawnableBounds(blockposition) && !isOutsideOfReach(blockposition.getX(), blockposition.getY(), blockposition.getZ()))
|
|
||||||
+ {
|
|
||||||
+ BlockEntity tileentity = null;
|
+ BlockEntity tileentity = null;
|
||||||
+ if (this.player.distanceToSqr(blockposition.getX(), blockposition.getY(), blockposition.getZ()) < 32 * 32 && this.player.serverLevel().isLoadedAndInBounds(blockposition))
|
if (this.player.distanceToSqr(blockposition.getX(), blockposition.getY(), blockposition.getZ()) < 32 * 32 && this.player.getLevel().isLoadedAndInBounds(blockposition)) {
|
||||||
+ {
|
tileentity = this.player.level.getBlockEntity(blockposition);
|
||||||
+ tileentity = this.player.level().getBlockEntity(blockposition);
|
}
|
||||||
+ }
|
// Paper end
|
||||||
+ // Paper end
|
|
||||||
|
|
||||||
- if (tileentity != null) {
|
- if (tileentity != null) {
|
||||||
- tileentity.saveToItem(itemstack);
|
- tileentity.saveToItem(itemstack);
|
||||||
+ if (tileentity != null)
|
+ if (tileentity != null) {
|
||||||
+ {
|
+ tileentity.saveToItem(
|
||||||
+ tileentity.saveToItem(itemstack);
|
+ itemstack);
|
||||||
+ }
|
+ }
|
||||||
}
|
}
|
||||||
+ // Scissors end
|
+ // Scissors end
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
boolean flag1 = packet.getSlotNum() >= 1 && packet.getSlotNum() <= 45;
|
||||||
|
@@ -1,23 +1,24 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
From: Telesphoreo <me@telesphoreo.me>
|
From: Video <videogamesm12@gmail.com>
|
||||||
Date: Sat, 10 Dec 2022 23:48:28 -0600
|
Date: Fri, 22 Apr 2022 01:26:55 -0500
|
||||||
Subject: [PATCH] Better handling of invalid JSON components
|
Subject: [PATCH] Better handling of invalid JSON components
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/network/chat/Component.java b/src/main/java/net/minecraft/network/chat/Component.java
|
diff --git a/src/main/java/net/minecraft/network/chat/Component.java b/src/main/java/net/minecraft/network/chat/Component.java
|
||||||
index 37fc353c3e59dd5af2fd6c58ac084fb0e6e155d7..3c0ee4e1f42f6056ca86a6f9f129d467e29a2fbc 100644
|
index 984105c226f16746b43bb2d2932e0b87f3a6a70c..faa41d102c06b52bc758ebe3484820376c482093 100644
|
||||||
--- a/src/main/java/net/minecraft/network/chat/Component.java
|
--- a/src/main/java/net/minecraft/network/chat/Component.java
|
||||||
+++ b/src/main/java/net/minecraft/network/chat/Component.java
|
+++ b/src/main/java/net/minecraft/network/chat/Component.java
|
||||||
@@ -26,6 +26,7 @@ import java.util.List;
|
@@ -24,6 +24,8 @@ import java.util.List;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
+
|
||||||
+import net.minecraft.ChatFormatting;
|
+import net.minecraft.ChatFormatting;
|
||||||
import net.minecraft.Util;
|
import net.minecraft.Util;
|
||||||
import net.minecraft.network.chat.contents.BlockDataSource;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.network.chat.contents.DataSource;
|
import net.minecraft.util.FormattedCharSequence;
|
||||||
@@ -522,6 +523,26 @@ public interface Component extends Message, FormattedText, Iterable<Component> {
|
@@ -427,6 +429,26 @@ public interface Component extends Message, FormattedText, Iterable<Component> {
|
||||||
return GsonHelper.toStableString(Serializer.toJsonTree(text));
|
return Component.Serializer.GSON.toJsonTree(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
+ // Scissors start
|
+ // Scissors start
|
||||||
@@ -26,7 +27,7 @@ index 37fc353c3e59dd5af2fd6c58ac084fb0e6e155d7..3c0ee4e1f42f6056ca86a6f9f129d467
|
|||||||
+ try {
|
+ try {
|
||||||
+ return fromJson(json);
|
+ return fromJson(json);
|
||||||
+ } catch (Exception ex) {
|
+ } catch (Exception ex) {
|
||||||
+ return Component.empty().append("** Invalid JSON Component **").withStyle(ChatFormatting.RED);
|
+ return new TextComponent("** Invalid JSON Component **").withStyle(ChatFormatting.RED);
|
||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
@@ -35,16 +36,16 @@ index 37fc353c3e59dd5af2fd6c58ac084fb0e6e155d7..3c0ee4e1f42f6056ca86a6f9f129d467
|
|||||||
+ try {
|
+ try {
|
||||||
+ return fromJson(json);
|
+ return fromJson(json);
|
||||||
+ } catch (Exception ex) {
|
+ } catch (Exception ex) {
|
||||||
+ return Component.empty().append("** Invalid JSON Component **").withStyle(ChatFormatting.RED);
|
+ return new TextComponent("** Invalid JSON Component **").withStyle(ChatFormatting.RED);
|
||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
+ // Scissors end
|
+ // Scissors end
|
||||||
+
|
+
|
||||||
public static JsonElement toJsonTree(Component text) {
|
@Nullable
|
||||||
return Component.Serializer.GSON.toJsonTree(text);
|
public static MutableComponent fromJson(String json) {
|
||||||
}
|
return (MutableComponent) GsonHelper.fromJson(Component.Serializer.GSON, json, MutableComponent.class, false);
|
||||||
diff --git a/src/main/java/net/minecraft/network/chat/HoverEvent.java b/src/main/java/net/minecraft/network/chat/HoverEvent.java
|
diff --git a/src/main/java/net/minecraft/network/chat/HoverEvent.java b/src/main/java/net/minecraft/network/chat/HoverEvent.java
|
||||||
index 7449a024265c42f28a6c9a1ed8d8f4b9e3096aac..487c68abc3eb5c18dc7fee762b2164001283cab7 100644
|
index 63dbbc0f027ab66d183f81d6a8e0f9e0b85ea562..21ee39172b3efb6414d1cf8fbf36cd463194abab 100644
|
||||||
--- a/src/main/java/net/minecraft/network/chat/HoverEvent.java
|
--- a/src/main/java/net/minecraft/network/chat/HoverEvent.java
|
||||||
+++ b/src/main/java/net/minecraft/network/chat/HoverEvent.java
|
+++ b/src/main/java/net/minecraft/network/chat/HoverEvent.java
|
||||||
@@ -79,7 +79,7 @@ public class HoverEvent {
|
@@ -79,7 +79,7 @@ public class HoverEvent {
|
||||||
@@ -80,40 +81,44 @@ index 7449a024265c42f28a6c9a1ed8d8f4b9e3096aac..487c68abc3eb5c18dc7fee762b216400
|
|||||||
CompoundTag compoundTag = TagParser.parseTag(text.getString());
|
CompoundTag compoundTag = TagParser.parseTag(text.getString());
|
||||||
- Component component = Component.Serializer.fromJson(compoundTag.getString("name"));
|
- Component component = Component.Serializer.fromJson(compoundTag.getString("name"));
|
||||||
+ Component component = Component.Serializer.fromJsonSafe(compoundTag.getString("name")); // Scissors - Use safer method for getting Components from JSON
|
+ Component component = Component.Serializer.fromJsonSafe(compoundTag.getString("name")); // Scissors - Use safer method for getting Components from JSON
|
||||||
EntityType<?> entityType = BuiltInRegistries.ENTITY_TYPE.get(new ResourceLocation(compoundTag.getString("type")));
|
EntityType<?> entityType = Registry.ENTITY_TYPE.get(new ResourceLocation(compoundTag.getString("type")));
|
||||||
// Scissors start
|
// Scissors start
|
||||||
UUID uUID;
|
UUID uUID;
|
||||||
diff --git a/src/main/java/net/minecraft/network/chat/contents/NbtContents.java b/src/main/java/net/minecraft/network/chat/contents/NbtContents.java
|
diff --git a/src/main/java/net/minecraft/network/chat/NbtComponent.java b/src/main/java/net/minecraft/network/chat/NbtComponent.java
|
||||||
index 97a2657bc98d41c3c1e376b266d2c85f685acc88..7b6476455e095eed15c92797ce3a3e1146dbdc3f 100644
|
index e3dc56de3f91e03b1543257f72448a734d914ed7..f518e47818a47be0dfd7cccc4845ba9736c6cd8b 100644
|
||||||
--- a/src/main/java/net/minecraft/network/chat/contents/NbtContents.java
|
--- a/src/main/java/net/minecraft/network/chat/NbtComponent.java
|
||||||
+++ b/src/main/java/net/minecraft/network/chat/contents/NbtContents.java
|
+++ b/src/main/java/net/minecraft/network/chat/NbtComponent.java
|
||||||
@@ -8,6 +8,7 @@ import java.util.Optional;
|
@@ -78,13 +78,14 @@ public abstract class NbtComponent extends BaseComponent implements ContextAware
|
||||||
import java.util.stream.Collectors;
|
if (this.interpreting) {
|
||||||
import java.util.stream.Stream;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
+import net.kyori.adventure.text.TextComponent;
|
|
||||||
import net.minecraft.commands.CommandSourceStack;
|
|
||||||
import net.minecraft.commands.arguments.NbtPathArgument;
|
|
||||||
import net.minecraft.nbt.Tag;
|
|
||||||
@@ -107,10 +108,11 @@ public class NbtContents implements ComponentContents {
|
|
||||||
Component component = DataFixUtils.orElse(ComponentUtils.updateForEntity(source, this.separator, sender, depth), ComponentUtils.DEFAULT_NO_STYLE_SEPARATOR);
|
Component component = DataFixUtils.orElse(ComponentUtils.updateForEntity(source, this.separator, sender, depth), ComponentUtils.DEFAULT_NO_STYLE_SEPARATOR);
|
||||||
return stream.flatMap((text) -> {
|
return stream.flatMap((text) -> {
|
||||||
|
+ // Scissors start - Use safer method for getting Components from JSON
|
||||||
try {
|
try {
|
||||||
- MutableComponent mutableComponent = Component.Serializer.fromJson(text);
|
- MutableComponent mutableComponent = Component.Serializer.fromJson(text);
|
||||||
+ MutableComponent mutableComponent = Component.Serializer.fromJsonSafe(text); // Scissors
|
+ MutableComponent mutableComponent = Component.Serializer.fromJsonSafe(text);
|
||||||
return Stream.of(ComponentUtils.updateForEntity(source, mutableComponent, sender, depth));
|
return Stream.of(ComponentUtils.updateForEntity(source, mutableComponent, sender, depth));
|
||||||
} catch (Exception var5) {
|
} catch (Exception var5) {
|
||||||
- LOGGER.warn("Failed to parse component: {}", text, var5);
|
- LOGGER.warn("Failed to parse component: {}", text, var5);
|
||||||
+ // Scissors - don't log
|
|
||||||
+ // LOGGER.warn("Failed to parse component: {}", text, var5);
|
|
||||||
return Stream.of();
|
return Stream.of();
|
||||||
}
|
}
|
||||||
|
+ // Scissors end
|
||||||
}).reduce((accumulator, current) -> {
|
}).reduce((accumulator, current) -> {
|
||||||
|
return accumulator.append(component).append(current);
|
||||||
|
}).orElseGet(() -> {
|
||||||
|
@@ -95,7 +96,7 @@ public abstract class NbtComponent extends BaseComponent implements ContextAware
|
||||||
|
return stream.map((string) -> {
|
||||||
|
return new TextComponent(string);
|
||||||
|
}).reduce((accumulator, current) -> {
|
||||||
|
- return accumulator.append(text).append(current);
|
||||||
|
+ return (TextComponent) accumulator.append(text).append(current);
|
||||||
|
}).orElseGet(() -> {
|
||||||
|
return new TextComponent("");
|
||||||
|
});
|
||||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||||
index 92202262eff01ae3bbeff0e6ebdcf26ad613c169..38c027c0fbddf58136b7d67eb7156403a79de4d1 100644
|
index dfd1f37757af1bd808cc2e2d8bf97123adf638bb..876e8f83fab4e255959948e59cabf05478446e4d 100644
|
||||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||||
@@ -2473,12 +2473,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
@@ -2215,12 +2215,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||||
this.setRot(this.getYRot(), this.getXRot());
|
this.setRot(this.getYRot(), this.getXRot());
|
||||||
if (nbt.contains("CustomName", 8)) {
|
if (nbt.contains("CustomName", 8)) {
|
||||||
String s = nbt.getString("CustomName");
|
String s = nbt.getString("CustomName");
|
||||||
@@ -128,33 +133,33 @@ index 92202262eff01ae3bbeff0e6ebdcf26ad613c169..38c027c0fbddf58136b7d67eb7156403
|
|||||||
|
|
||||||
this.setCustomNameVisible(nbt.getBoolean("CustomNameVisible"));
|
this.setCustomNameVisible(nbt.getBoolean("CustomNameVisible"));
|
||||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/BeaconBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BeaconBlockEntity.java
|
diff --git a/src/main/java/net/minecraft/world/level/block/entity/BeaconBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BeaconBlockEntity.java
|
||||||
index 59246e24558569f7f50b4d4d508616798091c888..5005a0ad5f703727ea9c618ae4b769a77d5655b5 100644
|
index 8d5c9813010a0256bd2712a1eabbc91f0f473a41..6ec48f834f5fef8678c690fd5d1ea530ebd2720f 100644
|
||||||
--- a/src/main/java/net/minecraft/world/level/block/entity/BeaconBlockEntity.java
|
--- a/src/main/java/net/minecraft/world/level/block/entity/BeaconBlockEntity.java
|
||||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/BeaconBlockEntity.java
|
+++ b/src/main/java/net/minecraft/world/level/block/entity/BeaconBlockEntity.java
|
||||||
@@ -410,7 +410,7 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider, Name
|
@@ -402,7 +402,7 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider {
|
||||||
this.levels = nbt.getInt("Levels"); // SPIGOT-5053, use where available
|
this.levels = nbt.getInt("Levels"); // SPIGOT-5053, use where available
|
||||||
// CraftBukkit end
|
// CraftBukkit end
|
||||||
if (nbt.contains("CustomName", 8)) {
|
if (nbt.contains("CustomName", 8)) {
|
||||||
- this.name = io.papermc.paper.util.MCUtil.getBaseComponentFromNbt("CustomName", nbt); // Paper - Catch ParseException
|
- this.name = net.minecraft.server.MCUtil.getBaseComponentFromNbt("CustomName", nbt); // Paper - Catch ParseException
|
||||||
+ this.name = Component.Serializer.fromJsonSafe(nbt.getString("CustomName")); // Scissors - Use safer method for getting Components from JSON
|
+ this.name = Component.Serializer.fromJsonSafe(nbt.getString("CustomName")); // Scissors - Use safer method for getting Components from JSON
|
||||||
}
|
}
|
||||||
|
|
||||||
this.lockKey = LockCode.fromTag(nbt);
|
this.lockKey = LockCode.fromTag(nbt);
|
||||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/EnchantmentTableBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/EnchantmentTableBlockEntity.java
|
diff --git a/src/main/java/net/minecraft/world/level/block/entity/EnchantmentTableBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/EnchantmentTableBlockEntity.java
|
||||||
index 65e1381bb2d10bd212463feb602c60f8fdb9ade1..3e23451066894ebd88cad7022970cb2c0e9b75db 100644
|
index 1eccf9424bd8a4bcbeed4ebb1795fd113fe5af18..fcc3d2fbc679fdb70da27d20d19380fa238ba7ea 100644
|
||||||
--- a/src/main/java/net/minecraft/world/level/block/entity/EnchantmentTableBlockEntity.java
|
--- a/src/main/java/net/minecraft/world/level/block/entity/EnchantmentTableBlockEntity.java
|
||||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/EnchantmentTableBlockEntity.java
|
+++ b/src/main/java/net/minecraft/world/level/block/entity/EnchantmentTableBlockEntity.java
|
||||||
@@ -42,7 +42,7 @@ public class EnchantmentTableBlockEntity extends BlockEntity implements Nameable
|
@@ -43,7 +43,7 @@ public class EnchantmentTableBlockEntity extends BlockEntity implements Nameable
|
||||||
public void load(CompoundTag nbt) {
|
public void load(CompoundTag nbt) {
|
||||||
super.load(nbt);
|
super.load(nbt);
|
||||||
if (nbt.contains("CustomName", 8)) {
|
if (nbt.contains("CustomName", 8)) {
|
||||||
- this.name = io.papermc.paper.util.MCUtil.getBaseComponentFromNbt("CustomName", nbt); // Paper - Catch ParseException
|
- this.name = net.minecraft.server.MCUtil.getBaseComponentFromNbt("CustomName", nbt); // Paper - Catch ParseException
|
||||||
+ this.name = Component.Serializer.fromJsonSafe(nbt.getString("CustomName")); // Scissors - Use safer method for getting Components from JSON
|
+ this.name = Component.Serializer.fromJsonSafe(nbt.getString("CustomName")); // Scissors - Use safer method for getting Components from JSON
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
diff --git a/src/main/java/net/minecraft/world/scores/ScoreboardSaveData.java b/src/main/java/net/minecraft/world/scores/ScoreboardSaveData.java
|
diff --git a/src/main/java/net/minecraft/world/scores/ScoreboardSaveData.java b/src/main/java/net/minecraft/world/scores/ScoreboardSaveData.java
|
||||||
index 2be7a697f08045b974579e6942b38571e744efac..84ec21c38bb44db1e9ff26c01d5c8af1a2417616 100644
|
index 0efb63d1a4cefede25712daf9cea0f5c3256980f..07fe4043184eda6fa11e0680930100eb914f64c1 100644
|
||||||
--- a/src/main/java/net/minecraft/world/scores/ScoreboardSaveData.java
|
--- a/src/main/java/net/minecraft/world/scores/ScoreboardSaveData.java
|
||||||
+++ b/src/main/java/net/minecraft/world/scores/ScoreboardSaveData.java
|
+++ b/src/main/java/net/minecraft/world/scores/ScoreboardSaveData.java
|
||||||
@@ -35,7 +35,7 @@ public class ScoreboardSaveData extends SavedData {
|
@@ -35,7 +35,7 @@ public class ScoreboardSaveData extends SavedData {
|
@@ -1,54 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Telesphoreo <me@telesphoreo.me>
|
|
||||||
Date: Sat, 10 Dec 2022 23:38:53 -0600
|
|
||||||
Subject: [PATCH] Reset large tags
|
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java
|
|
||||||
index b367ec1feaccbd67e9e28c0d0515e163f37135fe..d1547b9ba36baec925751b9bb0498c8a8cac12f8 100644
|
|
||||||
--- a/src/main/java/net/minecraft/world/item/ItemStack.java
|
|
||||||
+++ b/src/main/java/net/minecraft/world/item/ItemStack.java
|
|
||||||
@@ -21,6 +21,7 @@ import java.util.function.Predicate;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
+import me.totalfreedom.scissors.NbtUtility;
|
|
||||||
import net.minecraft.ChatFormatting;
|
|
||||||
import net.minecraft.Util;
|
|
||||||
import net.minecraft.advancements.CriteriaTriggers;
|
|
||||||
@@ -253,6 +254,12 @@ public final class ItemStack {
|
|
||||||
|
|
||||||
// CraftBukkit - break into own method
|
|
||||||
private void load(CompoundTag nbttagcompound) {
|
|
||||||
+ // Scissors start - Reset large tags
|
|
||||||
+ if (NbtUtility.isTooLarge(nbttagcompound)) {
|
|
||||||
+ // Reset tag without destroying item
|
|
||||||
+ nbttagcompound = NbtUtility.Item.removeItemData(nbttagcompound);
|
|
||||||
+ }
|
|
||||||
+ // Scissors end
|
|
||||||
this.item = (Item) BuiltInRegistries.ITEM.get(new ResourceLocation(nbttagcompound.getString("id")));
|
|
||||||
this.count = nbttagcompound.getByte("Count");
|
|
||||||
if (nbttagcompound.contains("tag", 10)) {
|
|
||||||
@@ -550,7 +557,11 @@ public final class ItemStack {
|
|
||||||
nbt.putString("id", minecraftkey == null ? "minecraft:air" : minecraftkey.toString());
|
|
||||||
nbt.putByte("Count", (byte) this.count);
|
|
||||||
if (this.tag != null) {
|
|
||||||
- nbt.put("tag", this.tag.copy());
|
|
||||||
+ // Scissors start - Don't save large tags
|
|
||||||
+ if (!NbtUtility.isTooLarge(this.tag)) {
|
|
||||||
+ nbt.put("tag", this.tag.copy());
|
|
||||||
+ }
|
|
||||||
+ // Scissors end
|
|
||||||
}
|
|
||||||
|
|
||||||
return nbt;
|
|
||||||
@@ -880,6 +891,9 @@ public final class ItemStack {
|
|
||||||
// Paper end
|
|
||||||
|
|
||||||
public void setTag(@Nullable CompoundTag nbt) {
|
|
||||||
+ // Scissors start - Ignore large tags
|
|
||||||
+ if (NbtUtility.isTooLarge(nbt)) return;
|
|
||||||
+ // Scissors end
|
|
||||||
this.tag = nbt;
|
|
||||||
this.processEnchantOrder(this.tag); // Paper
|
|
||||||
if (this.getItem().canBeDepleted()) {
|
|
@@ -6,10 +6,10 @@ Subject: [PATCH] Fixes creative-killing potion effects and certain potion
|
|||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/effect/MobEffect.java b/src/main/java/net/minecraft/world/effect/MobEffect.java
|
diff --git a/src/main/java/net/minecraft/world/effect/MobEffect.java b/src/main/java/net/minecraft/world/effect/MobEffect.java
|
||||||
index 2cc714585fc3790b70a7ad1ab8034543462e2b3b..2d3706d8d0dbed3b3588066eaa6b9ce1b266294f 100644
|
index 8bbb9bdcf95989f1737714655f6f6a269d46d7f2..3f5df0a365ddafe4277988767f8366536b928dab 100644
|
||||||
--- a/src/main/java/net/minecraft/world/effect/MobEffect.java
|
--- a/src/main/java/net/minecraft/world/effect/MobEffect.java
|
||||||
+++ b/src/main/java/net/minecraft/world/effect/MobEffect.java
|
+++ b/src/main/java/net/minecraft/world/effect/MobEffect.java
|
||||||
@@ -58,6 +58,7 @@ public class MobEffect {
|
@@ -47,6 +47,7 @@ public class MobEffect {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void applyEffectTick(LivingEntity entity, int amplifier) {
|
public void applyEffectTick(LivingEntity entity, int amplifier) {
|
||||||
@@ -17,7 +17,7 @@ index 2cc714585fc3790b70a7ad1ab8034543462e2b3b..2d3706d8d0dbed3b3588066eaa6b9ce1
|
|||||||
if (this == MobEffects.REGENERATION) {
|
if (this == MobEffects.REGENERATION) {
|
||||||
if (entity.getHealth() < entity.getMaxHealth()) {
|
if (entity.getHealth() < entity.getMaxHealth()) {
|
||||||
entity.heal(1.0F, RegainReason.MAGIC_REGEN); // CraftBukkit
|
entity.heal(1.0F, RegainReason.MAGIC_REGEN); // CraftBukkit
|
||||||
@@ -86,17 +87,31 @@ public class MobEffect {
|
@@ -75,17 +76,31 @@ public class MobEffect {
|
||||||
// CraftBukkit end
|
// CraftBukkit end
|
||||||
}
|
}
|
||||||
} else if ((this != MobEffects.HEAL || entity.isInvertedHealAndHarm()) && (this != MobEffects.HARM || !entity.isInvertedHealAndHarm())) {
|
} else if ((this != MobEffects.HEAL || entity.isInvertedHealAndHarm()) && (this != MobEffects.HARM || !entity.isInvertedHealAndHarm())) {
|
||||||
@@ -25,7 +25,7 @@ index 2cc714585fc3790b70a7ad1ab8034543462e2b3b..2d3706d8d0dbed3b3588066eaa6b9ce1
|
|||||||
+ // Scissors start
|
+ // Scissors start
|
||||||
+ amplifier = Math.min(Math.abs(amplifier), 124);
|
+ amplifier = Math.min(Math.abs(amplifier), 124);
|
||||||
+ if (!god && (this == MobEffects.HARM && !entity.isInvertedHealAndHarm() || this == MobEffects.HEAL && entity.isInvertedHealAndHarm())) {
|
+ if (!god && (this == MobEffects.HARM && !entity.isInvertedHealAndHarm() || this == MobEffects.HEAL && entity.isInvertedHealAndHarm())) {
|
||||||
entity.hurt(entity.damageSources().magic(), (float) (6 << amplifier));
|
entity.hurt(DamageSource.MAGIC, (float) (6 << amplifier));
|
||||||
}
|
}
|
||||||
+ // Scissors end
|
+ // Scissors end
|
||||||
} else {
|
} else {
|
@@ -1,19 +1,19 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
From: Telesphoreo <me@telesphoreo.me>
|
From: Business Goose <arclicious@vivaldi.net>
|
||||||
Date: Thu, 8 Jun 2023 19:24:05 -0500
|
Date: Fri, 3 Jun 2022 19:30:14 -0500
|
||||||
Subject: [PATCH] Fix negative death times
|
Subject: [PATCH] Fix negative death times
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||||
index 67627bbf84f5aab2872f636b1dcb6728c8494147..468f64afb7e9b3ef579205d3beea025deb31b460 100644
|
index d6ef140bcc35b10f78f2ec2f10c8a153395fc9df..d8393887cc98930815864eca28b07ef89b26f39e 100644
|
||||||
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||||
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||||
@@ -630,7 +630,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
@@ -620,7 +620,7 @@ public abstract class LivingEntity extends Entity {
|
||||||
|
|
||||||
protected void tickDeath() {
|
protected void tickDeath() {
|
||||||
++this.deathTime;
|
++this.deathTime;
|
||||||
- if (this.deathTime >= 20 && !this.level().isClientSide() && !this.isRemoved()) {
|
- if (this.deathTime == 20 && !this.level.isClientSide()) {
|
||||||
+ if ((this.deathTime >= 20 || this.deathTime <= 0) && !this.level().isClientSide() && !this.isRemoved()) {
|
+ if ((this.deathTime >= 20 || this.deathTime <= 0) && !this.level.isClientSide()) {
|
||||||
this.level().broadcastEntityEvent(this, (byte) 60);
|
this.level.broadcastEntityEvent(this, (byte) 60);
|
||||||
this.remove(Entity.RemovalReason.KILLED);
|
this.remove(Entity.RemovalReason.KILLED);
|
||||||
}
|
}
|
53
patches/server/0026-Update-for-1.18.2.patch
Normal file
53
patches/server/0026-Update-for-1.18.2.patch
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Telesphoreo <me@telesphoreo.me>
|
||||||
|
Date: Fri, 22 Apr 2022 01:27:54 -0500
|
||||||
|
Subject: [PATCH] Update for 1.18.2
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java b/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java
|
||||||
|
index f92610edcfb724374c69e66443eab60919ee955a..69cc277e4b737ff5a7424cd9afc5573e6eaec3d3 100644
|
||||||
|
--- a/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java
|
||||||
|
+++ b/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java
|
||||||
|
@@ -18,6 +18,7 @@ import java.io.*;
|
||||||
|
import java.net.HttpURLConnection;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.util.stream.StreamSupport;
|
||||||
|
+import org.bukkit.Bukkit;
|
||||||
|
|
||||||
|
public class PaperVersionFetcher implements VersionFetcher {
|
||||||
|
private static final java.util.regex.Pattern VER_PATTERN = java.util.regex.Pattern.compile("^([0-9\\.]*)\\-.*R"); // R is an anchor, will always give '-R' at end
|
||||||
|
@@ -56,15 +57,14 @@ public class PaperVersionFetcher implements VersionFetcher {
|
||||||
|
return mcVer;
|
||||||
|
}
|
||||||
|
|
||||||
|
- // Scissors start - Allow getting git information
|
||||||
|
- public static String getCommit() {
|
||||||
|
- Map<String, String> attributes = JarManifests.MANIFEST_MAP;
|
||||||
|
- return attributes.get("Git-Commit");
|
||||||
|
+ // Scissors start - Allow getting Git information
|
||||||
|
+ private static String getCommit() {
|
||||||
|
+ final var manifest = JarManifests.manifest(Bukkit.getServer().getClass());
|
||||||
|
+ return manifest == null ? null : manifest.getMainAttributes().getValue("Git-Commit");
|
||||||
|
}
|
||||||
|
-
|
||||||
|
- public static String getBranch() {
|
||||||
|
- Map<String, String> attributes = JarManifests.MANIFEST_MAP;
|
||||||
|
- return attributes.get("Git-Branch");
|
||||||
|
+ private static String getBranch() {
|
||||||
|
+ final var manifest = JarManifests.manifest(Bukkit.getServer().getClass());
|
||||||
|
+ return manifest == null ? null : manifest.getMainAttributes().getValue("Git-Branch");
|
||||||
|
}
|
||||||
|
// Scissors end
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/network/chat/NbtComponent.java b/src/main/java/net/minecraft/network/chat/NbtComponent.java
|
||||||
|
index f518e47818a47be0dfd7cccc4845ba9736c6cd8b..218525ba1742d68cde10f6caf09ee30eb2d01d50 100644
|
||||||
|
--- a/src/main/java/net/minecraft/network/chat/NbtComponent.java
|
||||||
|
+++ b/src/main/java/net/minecraft/network/chat/NbtComponent.java
|
||||||
|
@@ -96,6 +96,7 @@ public abstract class NbtComponent extends BaseComponent implements ContextAware
|
||||||
|
return stream.map((string) -> {
|
||||||
|
return new TextComponent(string);
|
||||||
|
}).reduce((accumulator, current) -> {
|
||||||
|
+ // Scissors - untested, likely needs fixing
|
||||||
|
return (TextComponent) accumulator.append(text).append(current);
|
||||||
|
}).orElseGet(() -> {
|
||||||
|
return new TextComponent("");
|
158
patches/server/0027-Reset-large-tags.patch
Normal file
158
patches/server/0027-Reset-large-tags.patch
Normal file
@@ -0,0 +1,158 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Business Goose <arclicious@vivaldi.net>
|
||||||
|
Date: Fri, 22 Apr 2022 01:56:03 -0500
|
||||||
|
Subject: [PATCH] Reset large tags
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/com/github/atlasmediagroup/scissors/NbtUtility.java b/src/main/java/com/github/atlasmediagroup/scissors/NbtUtility.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000000000000000000000000000..058203440fd071ce5edbe18391ea60f0a5fbee3a
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/com/github/atlasmediagroup/scissors/NbtUtility.java
|
||||||
|
@@ -0,0 +1,28 @@
|
||||||
|
+package com.github.atlasmediagroup.scissors;
|
||||||
|
+
|
||||||
|
+import net.minecraft.nbt.CompoundTag;
|
||||||
|
+
|
||||||
|
+import javax.annotation.Nullable;
|
||||||
|
+import java.nio.charset.StandardCharsets;
|
||||||
|
+
|
||||||
|
+public class NbtUtility
|
||||||
|
+{
|
||||||
|
+
|
||||||
|
+ public static boolean isTooLarge(@Nullable CompoundTag tag)
|
||||||
|
+ {
|
||||||
|
+ if (tag == null) return false;
|
||||||
|
+ return tag.toString().getBytes(StandardCharsets.UTF_8).length > (256 * 1024);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public static class Item
|
||||||
|
+ {
|
||||||
|
+
|
||||||
|
+ public static CompoundTag removeItemData(CompoundTag tag)
|
||||||
|
+ {
|
||||||
|
+ CompoundTag cleaned = new CompoundTag();
|
||||||
|
+ cleaned.putString("id", tag.getString("id"));
|
||||||
|
+ cleaned.putByte("Count", tag.getByte("Count"));
|
||||||
|
+ return cleaned;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java
|
||||||
|
index 6837c965592d4584cfc958a1008b98791a0fc780..0f7d7248be0aa99dd759d12ed956a98822a2749b 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/item/ItemStack.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/item/ItemStack.java
|
||||||
|
@@ -1,5 +1,6 @@
|
||||||
|
package net.minecraft.world.item;
|
||||||
|
|
||||||
|
+import com.github.atlasmediagroup.scissors.NbtUtility;
|
||||||
|
import com.google.common.collect.HashMultimap;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import com.google.common.collect.Multimap;
|
||||||
|
@@ -8,13 +9,13 @@ import com.mojang.brigadier.StringReader;
|
||||||
|
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||||
|
import com.mojang.logging.LogUtils;
|
||||||
|
import com.mojang.serialization.Codec;
|
||||||
|
+import com.mojang.serialization.Dynamic;
|
||||||
|
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||||
|
import java.text.DecimalFormat;
|
||||||
|
import java.text.DecimalFormatSymbols;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
-import java.util.Collections;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
@@ -50,11 +51,7 @@ import net.minecraft.util.datafix.fixes.References;
|
||||||
|
import net.minecraft.world.InteractionHand;
|
||||||
|
import net.minecraft.world.InteractionResult;
|
||||||
|
import net.minecraft.world.InteractionResultHolder;
|
||||||
|
-import net.minecraft.world.entity.Entity;
|
||||||
|
-import net.minecraft.world.entity.EquipmentSlot;
|
||||||
|
-import net.minecraft.world.entity.LivingEntity;
|
||||||
|
-import net.minecraft.world.entity.MobType;
|
||||||
|
-import net.minecraft.world.entity.SlotAccess;
|
||||||
|
+import net.minecraft.world.entity.*;
|
||||||
|
import net.minecraft.world.entity.ai.attributes.Attribute;
|
||||||
|
import net.minecraft.world.entity.ai.attributes.AttributeModifier;
|
||||||
|
import net.minecraft.world.entity.ai.attributes.Attributes;
|
||||||
|
@@ -75,8 +72,6 @@ import net.minecraft.world.level.block.Block;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
|
// CraftBukkit start
|
||||||
|
-import com.mojang.serialization.Dynamic;
|
||||||
|
-import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
import net.minecraft.server.MinecraftServer;
|
||||||
|
@@ -251,6 +246,13 @@ public final class ItemStack {
|
||||||
|
|
||||||
|
// CraftBukkit - break into own method
|
||||||
|
private void load(CompoundTag nbttagcompound) {
|
||||||
|
+ // Scissors start - Reset large tags
|
||||||
|
+ if (NbtUtility.isTooLarge(nbttagcompound)) {
|
||||||
|
+ // Reset tag without destroying item
|
||||||
|
+ nbttagcompound = NbtUtility.Item.removeItemData(nbttagcompound);
|
||||||
|
+ }
|
||||||
|
+ // Scissors end
|
||||||
|
+
|
||||||
|
this.item = (Item) Registry.ITEM.get(new ResourceLocation(nbttagcompound.getString("id")));
|
||||||
|
this.count = nbttagcompound.getByte("Count");
|
||||||
|
if (nbttagcompound.contains("tag", 10)) {
|
||||||
|
@@ -495,7 +497,11 @@ public final class ItemStack {
|
||||||
|
nbt.putString("id", minecraftkey == null ? "minecraft:air" : minecraftkey.toString());
|
||||||
|
nbt.putByte("Count", (byte) this.count);
|
||||||
|
if (this.tag != null) {
|
||||||
|
- nbt.put("tag", this.tag.copy());
|
||||||
|
+ // Scissors start - Don't save large tags
|
||||||
|
+ if (!NbtUtility.isTooLarge(this.tag)) {
|
||||||
|
+ nbt.put("tag", this.tag.copy());
|
||||||
|
+ }
|
||||||
|
+ // Scissors end
|
||||||
|
}
|
||||||
|
|
||||||
|
return nbt;
|
||||||
|
@@ -827,6 +833,9 @@ public final class ItemStack {
|
||||||
|
// Paper end
|
||||||
|
|
||||||
|
public void setTag(@Nullable CompoundTag nbt) {
|
||||||
|
+ // Scissors start - Ignore large tags
|
||||||
|
+ if (NbtUtility.isTooLarge(nbt)) return;
|
||||||
|
+ // Scissors end
|
||||||
|
this.tag = nbt;
|
||||||
|
this.processEnchantOrder(this.tag); // Paper
|
||||||
|
if (this.getItem().canBeDepleted()) {
|
||||||
|
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
|
||||||
|
index 226d9ac01c601fc8954a88bea93a521cdce79eda..9bfa2deca1258dd9c294422a0ea032142cd11789 100644
|
||||||
|
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
|
||||||
|
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
|
||||||
|
@@ -1,16 +1,12 @@
|
||||||
|
package org.bukkit.craftbukkit.inventory;
|
||||||
|
|
||||||
|
-import static org.bukkit.craftbukkit.inventory.CraftMetaItem.*;
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
-import java.util.Map;
|
||||||
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
import net.minecraft.nbt.ListTag;
|
||||||
|
import net.minecraft.world.item.Item;
|
||||||
|
import org.apache.commons.lang.Validate;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
-import org.bukkit.NamespacedKey;
|
||||||
|
import org.bukkit.configuration.serialization.DelegateDeserialization;
|
||||||
|
-import org.bukkit.craftbukkit.enchantments.CraftEnchantment;
|
||||||
|
import org.bukkit.craftbukkit.util.CraftLegacy;
|
||||||
|
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
||||||
|
import org.bukkit.craftbukkit.util.CraftNamespacedKey;
|
||||||
|
@@ -19,6 +15,11 @@ import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
import org.bukkit.material.MaterialData;
|
||||||
|
|
||||||
|
+import java.util.Map;
|
||||||
|
+
|
||||||
|
+import static org.bukkit.craftbukkit.inventory.CraftMetaItem.ENCHANTMENTS_ID;
|
||||||
|
+import static org.bukkit.craftbukkit.inventory.CraftMetaItem.ENCHANTMENTS_LVL;
|
||||||
|
+
|
||||||
|
@DelegateDeserialization(ItemStack.class)
|
||||||
|
public final class CraftItemStack extends ItemStack {
|
||||||
|
|
@@ -1,22 +1,21 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
From: Business Goose <arclicious@vivaldi.net>
|
From: Business Goose <arclicious@vivaldi.net>
|
||||||
Date: Sat, 11 Jun 2022 23:33:13 -0500
|
Date: Sun, 1 May 2022 01:20:13 +0100
|
||||||
Subject: [PATCH] Account for items inside containers
|
Subject: [PATCH] Account for items inside containers
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/ContainerHelper.java b/src/main/java/net/minecraft/world/ContainerHelper.java
|
diff --git a/src/main/java/net/minecraft/world/ContainerHelper.java b/src/main/java/net/minecraft/world/ContainerHelper.java
|
||||||
index 4092c7a8c2b0d9d26e6f4d97386735236300d132..9e0ab51dd7a4f9fed8f9edde962d42d4bbf604c1 100644
|
index 4092c7a8c2b0d9d26e6f4d97386735236300d132..ad3af6d90b68bc55c29243da8814516575299bf0 100644
|
||||||
--- a/src/main/java/net/minecraft/world/ContainerHelper.java
|
--- a/src/main/java/net/minecraft/world/ContainerHelper.java
|
||||||
+++ b/src/main/java/net/minecraft/world/ContainerHelper.java
|
+++ b/src/main/java/net/minecraft/world/ContainerHelper.java
|
||||||
@@ -2,6 +2,7 @@ package net.minecraft.world;
|
@@ -1,5 +1,6 @@
|
||||||
|
package net.minecraft.world;
|
||||||
|
|
||||||
|
+import com.github.atlasmediagroup.scissors.NbtUtility;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
+import me.totalfreedom.scissors.NbtUtility;
|
|
||||||
import net.minecraft.core.NonNullList;
|
import net.minecraft.core.NonNullList;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
@@ -22,10 +23,14 @@ public class ContainerHelper {
|
||||||
import net.minecraft.nbt.ListTag;
|
|
||||||
@@ -22,10 +23,13 @@ public class ContainerHelper {
|
|
||||||
|
|
||||||
public static CompoundTag saveAllItems(CompoundTag nbt, NonNullList<ItemStack> stacks, boolean setIfEmpty) {
|
public static CompoundTag saveAllItems(CompoundTag nbt, NonNullList<ItemStack> stacks, boolean setIfEmpty) {
|
||||||
ListTag listTag = new ListTag();
|
ListTag listTag = new ListTag();
|
||||||
@@ -25,21 +24,22 @@ index 4092c7a8c2b0d9d26e6f4d97386735236300d132..9e0ab51dd7a4f9fed8f9edde962d42d4
|
|||||||
|
|
||||||
for(int i = 0; i < stacks.size(); ++i) {
|
for(int i = 0; i < stacks.size(); ++i) {
|
||||||
ItemStack itemStack = stacks.get(i);
|
ItemStack itemStack = stacks.get(i);
|
||||||
|
+
|
||||||
if (!itemStack.isEmpty()) {
|
if (!itemStack.isEmpty()) {
|
||||||
+ total += NbtUtility.getTagSize(itemStack.getTag()); // Scissors
|
+ total += NbtUtility.getTagSize(itemStack.getTag());
|
||||||
CompoundTag compoundTag = new CompoundTag();
|
CompoundTag compoundTag = new CompoundTag();
|
||||||
compoundTag.putByte("Slot", (byte)i);
|
compoundTag.putByte("Slot", (byte)i);
|
||||||
itemStack.save(compoundTag);
|
itemStack.save(compoundTag);
|
||||||
@@ -33,7 +37,7 @@ public class ContainerHelper {
|
@@ -33,7 +38,7 @@ public class ContainerHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- if (!listTag.isEmpty() || setIfEmpty) {
|
- if (!listTag.isEmpty() || setIfEmpty) {
|
||||||
+ if ((!listTag.isEmpty() || setIfEmpty) && !(total > NbtUtility.MAXIMUM_SIZE)) { // Scissors
|
+ if ((!listTag.isEmpty() || setIfEmpty) && !(total > NbtUtility.MAXIMUM_SIZE)) {
|
||||||
nbt.put("Items", listTag);
|
nbt.put("Items", listTag);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -42,11 +46,18 @@ public class ContainerHelper {
|
@@ -42,11 +47,18 @@ public class ContainerHelper {
|
||||||
|
|
||||||
public static void loadAllItems(CompoundTag nbt, NonNullList<ItemStack> stacks) {
|
public static void loadAllItems(CompoundTag nbt, NonNullList<ItemStack> stacks) {
|
||||||
ListTag listTag = nbt.getList("Items", 10);
|
ListTag listTag = nbt.getList("Items", 10);
|
||||||
@@ -59,18 +59,17 @@ index 4092c7a8c2b0d9d26e6f4d97386735236300d132..9e0ab51dd7a4f9fed8f9edde962d42d4
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java
|
diff --git a/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java
|
||||||
index 2a786c9fd29dc2139cf487fa645cd43345d60167..dbdc66620ae4284cfe96f633b1f4db46866b597b 100644
|
index 888e1f2bc6ea4ddbbcc5466f177233f25b290459..0f19ef250a2f82e49730cb58ea43ee6bf407455a 100644
|
||||||
--- a/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java
|
--- a/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java
|
||||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java
|
+++ b/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java
|
||||||
@@ -9,6 +9,7 @@ import java.util.Iterator;
|
@@ -1,5 +1,6 @@
|
||||||
import java.util.List;
|
package net.minecraft.world.level.block.entity;
|
||||||
import java.util.Map;
|
|
||||||
import javax.annotation.Nullable;
|
+import com.github.atlasmediagroup.scissors.NbtUtility;
|
||||||
+import me.totalfreedom.scissors.NbtUtility;
|
import com.google.common.collect.Lists;
|
||||||
import net.minecraft.SharedConstants;
|
import com.google.common.collect.Maps;
|
||||||
import net.minecraft.Util;
|
import it.unimi.dsi.fastutil.objects.Object2IntMap.Entry;
|
||||||
import net.minecraft.core.BlockPos;
|
@@ -211,6 +212,17 @@ public abstract class AbstractFurnaceBlockEntity extends BaseContainerBlockEntit
|
||||||
@@ -212,6 +213,16 @@ public abstract class AbstractFurnaceBlockEntity extends BaseContainerBlockEntit
|
|
||||||
public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
|
public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
|
||||||
|
|
||||||
public List<ItemStack> getContents() {
|
public List<ItemStack> getContents() {
|
||||||
@@ -84,21 +83,22 @@ index 2a786c9fd29dc2139cf487fa645cd43345d60167..dbdc66620ae4284cfe96f633b1f4db46
|
|||||||
+ if (total > NbtUtility.MAXIMUM_SIZE) {
|
+ if (total > NbtUtility.MAXIMUM_SIZE) {
|
||||||
+ this.items.clear();
|
+ this.items.clear();
|
||||||
+ }
|
+ }
|
||||||
|
+
|
||||||
return this.items;
|
return this.items;
|
||||||
}
|
}
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/BarrelBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BarrelBlockEntity.java
|
diff --git a/src/main/java/net/minecraft/world/level/block/entity/BarrelBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BarrelBlockEntity.java
|
||||||
index 416aa989ebb18a8741cc9d605a1180ab830f6643..893cf89dd2b022e2b785318e7e86eb5d75be8ed8 100644
|
index 5a47d58071b83ea911e4cb5e1cc5468801ad0d55..c6f25cb62335fda65596ba3f4a55734a88b75bd4 100644
|
||||||
--- a/src/main/java/net/minecraft/world/level/block/entity/BarrelBlockEntity.java
|
--- a/src/main/java/net/minecraft/world/level/block/entity/BarrelBlockEntity.java
|
||||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/BarrelBlockEntity.java
|
+++ b/src/main/java/net/minecraft/world/level/block/entity/BarrelBlockEntity.java
|
||||||
@@ -1,5 +1,6 @@
|
@@ -1,5 +1,6 @@
|
||||||
package net.minecraft.world.level.block.entity;
|
package net.minecraft.world.level.block.entity;
|
||||||
|
|
||||||
+import me.totalfreedom.scissors.NbtUtility;
|
+import com.github.atlasmediagroup.scissors.NbtUtility;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.core.NonNullList;
|
import net.minecraft.core.NonNullList;
|
||||||
@@ -34,6 +35,16 @@ public class BarrelBlockEntity extends RandomizableContainerBlockEntity {
|
@@ -35,6 +36,17 @@ public class BarrelBlockEntity extends RandomizableContainerBlockEntity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ItemStack> getContents() {
|
public List<ItemStack> getContents() {
|
||||||
@@ -112,22 +112,22 @@ index 416aa989ebb18a8741cc9d605a1180ab830f6643..893cf89dd2b022e2b785318e7e86eb5d
|
|||||||
+ if (total > NbtUtility.MAXIMUM_SIZE) {
|
+ if (total > NbtUtility.MAXIMUM_SIZE) {
|
||||||
+ this.items.clear();
|
+ this.items.clear();
|
||||||
+ }
|
+ }
|
||||||
|
+
|
||||||
return this.items;
|
return this.items;
|
||||||
}
|
}
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java
|
diff --git a/src/main/java/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java
|
||||||
index c57efcb9a79337ec791e4e8f6671612f0a82b441..2963b72061a9ede734842d6fb46a67a1c41d4740 100644
|
index 5c0f1488c8a8100cd39a03adeccded9984722249..d1e1b29298e1e074df1966498d7f3c94b20c77f4 100644
|
||||||
--- a/src/main/java/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java
|
--- a/src/main/java/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java
|
||||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java
|
+++ b/src/main/java/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java
|
||||||
@@ -3,6 +3,7 @@ package net.minecraft.world.level.block.entity;
|
@@ -1,5 +1,6 @@
|
||||||
|
package net.minecraft.world.level.block.entity;
|
||||||
|
|
||||||
|
+import com.github.atlasmediagroup.scissors.NbtUtility;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
+import me.totalfreedom.scissors.NbtUtility;
|
@@ -72,6 +73,17 @@ public class BrewingStandBlockEntity extends BaseContainerBlockEntity implements
|
||||||
import net.minecraft.core.BlockPos;
|
|
||||||
import net.minecraft.core.Direction;
|
|
||||||
import net.minecraft.core.NonNullList;
|
|
||||||
@@ -73,6 +74,16 @@ public class BrewingStandBlockEntity extends BaseContainerBlockEntity implements
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ItemStack> getContents() {
|
public List<ItemStack> getContents() {
|
||||||
@@ -141,21 +141,22 @@ index c57efcb9a79337ec791e4e8f6671612f0a82b441..2963b72061a9ede734842d6fb46a67a1
|
|||||||
+ if (total > NbtUtility.MAXIMUM_SIZE) {
|
+ if (total > NbtUtility.MAXIMUM_SIZE) {
|
||||||
+ this.items.clear();
|
+ this.items.clear();
|
||||||
+ }
|
+ }
|
||||||
|
+
|
||||||
return this.items;
|
return this.items;
|
||||||
}
|
}
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/ChestBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/ChestBlockEntity.java
|
diff --git a/src/main/java/net/minecraft/world/level/block/entity/ChestBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/ChestBlockEntity.java
|
||||||
index a71414397bd45ee7bcacfeef0041d80dfa25f114..1b6f91055eb01627761e83e5e99e1731029b32ab 100644
|
index e56f7d76b501dab7d549efd2fafd514a9625c24e..153c70defdd6c25203764035c97ed3d20bc9c17e 100644
|
||||||
--- a/src/main/java/net/minecraft/world/level/block/entity/ChestBlockEntity.java
|
--- a/src/main/java/net/minecraft/world/level/block/entity/ChestBlockEntity.java
|
||||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/ChestBlockEntity.java
|
+++ b/src/main/java/net/minecraft/world/level/block/entity/ChestBlockEntity.java
|
||||||
@@ -1,5 +1,6 @@
|
@@ -1,5 +1,6 @@
|
||||||
package net.minecraft.world.level.block.entity;
|
package net.minecraft.world.level.block.entity;
|
||||||
|
|
||||||
+import me.totalfreedom.scissors.NbtUtility;
|
+import com.github.atlasmediagroup.scissors.NbtUtility;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
import net.minecraft.core.NonNullList;
|
import net.minecraft.core.NonNullList;
|
||||||
@@ -40,6 +41,16 @@ public class ChestBlockEntity extends RandomizableContainerBlockEntity implement
|
@@ -41,6 +42,17 @@ public class ChestBlockEntity extends RandomizableContainerBlockEntity implement
|
||||||
private int maxStack = MAX_STACK;
|
private int maxStack = MAX_STACK;
|
||||||
|
|
||||||
public List<ItemStack> getContents() {
|
public List<ItemStack> getContents() {
|
||||||
@@ -169,21 +170,22 @@ index a71414397bd45ee7bcacfeef0041d80dfa25f114..1b6f91055eb01627761e83e5e99e1731
|
|||||||
+ if (total > NbtUtility.MAXIMUM_SIZE) {
|
+ if (total > NbtUtility.MAXIMUM_SIZE) {
|
||||||
+ this.items.clear();
|
+ this.items.clear();
|
||||||
+ }
|
+ }
|
||||||
|
+
|
||||||
return this.items;
|
return this.items;
|
||||||
}
|
}
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/DispenserBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/DispenserBlockEntity.java
|
diff --git a/src/main/java/net/minecraft/world/level/block/entity/DispenserBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/DispenserBlockEntity.java
|
||||||
index 881379681c39230a00b3a1f11cd87498984396c7..1be5d600573f7632e6630224530dd76522e1b191 100644
|
index f74c5bb8e1ba42c77c59d481b871fd992483b128..10393d499fa6a5e36750ed9305d22454ef98e6cf 100644
|
||||||
--- a/src/main/java/net/minecraft/world/level/block/entity/DispenserBlockEntity.java
|
--- a/src/main/java/net/minecraft/world/level/block/entity/DispenserBlockEntity.java
|
||||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/DispenserBlockEntity.java
|
+++ b/src/main/java/net/minecraft/world/level/block/entity/DispenserBlockEntity.java
|
||||||
@@ -1,5 +1,6 @@
|
@@ -1,5 +1,6 @@
|
||||||
package net.minecraft.world.level.block.entity;
|
package net.minecraft.world.level.block.entity;
|
||||||
|
|
||||||
+import me.totalfreedom.scissors.NbtUtility;
|
+import com.github.atlasmediagroup.scissors.NbtUtility;
|
||||||
|
import java.util.Random;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.NonNullList;
|
import net.minecraft.core.NonNullList;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
@@ -30,6 +31,17 @@ public class DispenserBlockEntity extends RandomizableContainerBlockEntity {
|
||||||
@@ -28,6 +29,16 @@ public class DispenserBlockEntity extends RandomizableContainerBlockEntity {
|
|
||||||
private int maxStack = MAX_STACK;
|
private int maxStack = MAX_STACK;
|
||||||
|
|
||||||
public List<ItemStack> getContents() {
|
public List<ItemStack> getContents() {
|
||||||
@@ -197,22 +199,22 @@ index 881379681c39230a00b3a1f11cd87498984396c7..1be5d600573f7632e6630224530dd765
|
|||||||
+ if (total > NbtUtility.MAXIMUM_SIZE) {
|
+ if (total > NbtUtility.MAXIMUM_SIZE) {
|
||||||
+ this.items.clear();
|
+ this.items.clear();
|
||||||
+ }
|
+ }
|
||||||
|
+
|
||||||
return this.items;
|
return this.items;
|
||||||
}
|
}
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
|
diff --git a/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
|
||||||
index 789e5458f4a137694563a22612455506807de51b..84c721da46b7786857677b56f439c2b9448ba4b8 100644
|
index d241b25acc223982109495542fd17e0fbdf53437..ab952ef090ca5183340b014e0aae3aef553a4803 100644
|
||||||
--- a/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
|
--- a/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
|
||||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
|
+++ b/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
|
||||||
@@ -6,6 +6,7 @@ import java.util.function.BooleanSupplier;
|
@@ -1,5 +1,6 @@
|
||||||
import java.util.stream.Collectors;
|
package net.minecraft.world.level.block.entity;
|
||||||
import java.util.stream.IntStream;
|
|
||||||
import javax.annotation.Nullable;
|
+import com.github.atlasmediagroup.scissors.NbtUtility;
|
||||||
+import me.totalfreedom.scissors.NbtUtility;
|
import java.util.Iterator;
|
||||||
import net.minecraft.core.BlockPos;
|
import java.util.List;
|
||||||
import net.minecraft.core.Direction;
|
import java.util.function.BooleanSupplier;
|
||||||
import net.minecraft.core.NonNullList;
|
@@ -53,7 +54,19 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
|
||||||
@@ -56,6 +57,16 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
|
|
||||||
private int maxStack = MAX_STACK;
|
private int maxStack = MAX_STACK;
|
||||||
|
|
||||||
public List<ItemStack> getContents() {
|
public List<ItemStack> getContents() {
|
||||||
@@ -226,25 +228,27 @@ index 789e5458f4a137694563a22612455506807de51b..84c721da46b7786857677b56f439c2b9
|
|||||||
+ if (total > NbtUtility.MAXIMUM_SIZE) {
|
+ if (total > NbtUtility.MAXIMUM_SIZE) {
|
||||||
+ this.items.clear();
|
+ this.items.clear();
|
||||||
+ }
|
+ }
|
||||||
|
+
|
||||||
return this.items;
|
return this.items;
|
||||||
|
+
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onOpen(CraftHumanEntity who) {
|
||||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java
|
diff --git a/src/main/java/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java
|
||||||
index b7686fd63b7c5d88c3a12ec4ee9bc01a17f997e0..c2904048625bb4439c7f0ba8a2605d3194b66070 100644
|
index b4d38a9aa8792e979c99bedc20906679ba7991c6..5bdff2d3b13b3dbd0f3f83d9ece5a42173fb7e6c 100644
|
||||||
--- a/src/main/java/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java
|
--- a/src/main/java/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java
|
||||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java
|
+++ b/src/main/java/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java
|
||||||
@@ -3,6 +3,7 @@ package net.minecraft.world.level.block.entity;
|
@@ -1,5 +1,6 @@
|
||||||
|
package net.minecraft.world.level.block.entity;
|
||||||
|
|
||||||
|
+import com.github.atlasmediagroup.scissors.NbtUtility;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.IntStream;
|
import java.util.stream.IntStream;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
+import me.totalfreedom.scissors.NbtUtility;
|
@@ -252,7 +253,19 @@ public class ShulkerBoxBlockEntity extends RandomizableContainerBlockEntity impl
|
||||||
import net.minecraft.core.BlockPos;
|
|
||||||
import net.minecraft.core.Direction;
|
|
||||||
import net.minecraft.core.NonNullList;
|
|
||||||
@@ -60,6 +61,16 @@ public class ShulkerBoxBlockEntity extends RandomizableContainerBlockEntity impl
|
|
||||||
public boolean opened;
|
|
||||||
|
|
||||||
public List<ItemStack> getContents() {
|
@Override
|
||||||
|
protected NonNullList<ItemStack> getItems() {
|
||||||
+ // Scissors - Account for items inside containers
|
+ // Scissors - Account for items inside containers
|
||||||
+ long total = 0;
|
+ long total = 0;
|
||||||
+
|
+
|
||||||
@@ -255,6 +259,9 @@ index b7686fd63b7c5d88c3a12ec4ee9bc01a17f997e0..c2904048625bb4439c7f0ba8a2605d31
|
|||||||
+ if (total > NbtUtility.MAXIMUM_SIZE) {
|
+ if (total > NbtUtility.MAXIMUM_SIZE) {
|
||||||
+ this.itemStacks.clear();
|
+ this.itemStacks.clear();
|
||||||
+ }
|
+ }
|
||||||
|
+
|
||||||
return this.itemStacks;
|
return this.itemStacks;
|
||||||
|
+
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
@@ -1,12 +1,12 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
From: Telesphoreo <me@telesphoreo.me>
|
From: Business Goose <arclicious@vivaldi.net>
|
||||||
Date: Sat, 10 Dec 2022 23:44:05 -0600
|
Date: Sun, 1 May 2022 14:23:35 -0500
|
||||||
Subject: [PATCH] Limit amount of vehicle collision checks to 3 and discard
|
Subject: [PATCH] Limit amount of vehicle collision checks to 3 and discard
|
||||||
vehicles if they collide with more than 15 other entities
|
vehicles if they collide with more than 15 other entities
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java
|
diff --git a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java
|
||||||
index 9948a28dae4edba877c13ef0156be5ff58df3fa2..93f359c71659c0b2fdf25b1c76c072bf9209db2a 100644
|
index 96a7bfd921e59f298f0ee502d356cc3552c30ce8..6c1a489f03ecd7dfef161822cf6910f6119c082b 100644
|
||||||
--- a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java
|
--- a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java
|
||||||
+++ b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java
|
+++ b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java
|
||||||
@@ -8,6 +8,7 @@ import com.mojang.datafixers.util.Pair;
|
@@ -8,6 +8,7 @@ import com.mojang.datafixers.util.Pair;
|
||||||
@@ -17,7 +17,7 @@ index 9948a28dae4edba877c13ef0156be5ff58df3fa2..93f359c71659c0b2fdf25b1c76c072bf
|
|||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import net.minecraft.BlockUtil;
|
import net.minecraft.BlockUtil;
|
||||||
import net.minecraft.Util;
|
import net.minecraft.Util;
|
||||||
@@ -107,6 +108,7 @@ public abstract class AbstractMinecart extends Entity {
|
@@ -106,6 +107,7 @@ public abstract class AbstractMinecart extends Entity {
|
||||||
private double flyingX = 0.949999988079071D; // Paper - restore vanilla precision
|
private double flyingX = 0.949999988079071D; // Paper - restore vanilla precision
|
||||||
private double flyingY = 0.949999988079071D; // Paper - restore vanilla precision
|
private double flyingY = 0.949999988079071D; // Paper - restore vanilla precision
|
||||||
private double flyingZ = 0.949999988079071D; // Paper - restore vanilla precision
|
private double flyingZ = 0.949999988079071D; // Paper - restore vanilla precision
|
||||||
@@ -25,9 +25,9 @@ index 9948a28dae4edba877c13ef0156be5ff58df3fa2..93f359c71659c0b2fdf25b1c76c072bf
|
|||||||
public double maxSpeed = 0.4D;
|
public double maxSpeed = 0.4D;
|
||||||
// CraftBukkit end
|
// CraftBukkit end
|
||||||
|
|
||||||
@@ -434,8 +436,10 @@ public abstract class AbstractMinecart extends Entity {
|
@@ -422,8 +424,10 @@ public abstract class AbstractMinecart extends Entity {
|
||||||
if (this.getMinecartType() == AbstractMinecart.Type.RIDEABLE && this.getDeltaMovement().horizontalDistanceSqr() > 0.01D) {
|
if (this.getMinecartType() == AbstractMinecart.Type.RIDEABLE && this.getDeltaMovement().horizontalDistanceSqr() > 0.01D) {
|
||||||
List<Entity> list = this.level().getEntities((Entity) this, this.getBoundingBox().inflate(0.20000000298023224D, 0.0D, 0.20000000298023224D), EntitySelector.pushableBy(this));
|
List<Entity> list = this.level.getEntities((Entity) this, this.getBoundingBox().inflate(0.20000000298023224D, 0.0D, 0.20000000298023224D), EntitySelector.pushableBy(this));
|
||||||
|
|
||||||
- if (!list.isEmpty()) {
|
- if (!list.isEmpty()) {
|
||||||
- for (int l = 0; l < list.size(); ++l) {
|
- for (int l = 0; l < list.size(); ++l) {
|
||||||
@@ -38,7 +38,7 @@ index 9948a28dae4edba877c13ef0156be5ff58df3fa2..93f359c71659c0b2fdf25b1c76c072bf
|
|||||||
Entity entity = (Entity) list.get(l);
|
Entity entity = (Entity) list.get(l);
|
||||||
|
|
||||||
if (!(entity instanceof Player) && !(entity instanceof IronGolem) && !(entity instanceof AbstractMinecart) && !this.isVehicle() && !entity.isPassenger()) {
|
if (!(entity instanceof Player) && !(entity instanceof IronGolem) && !(entity instanceof AbstractMinecart) && !this.isVehicle() && !entity.isPassenger()) {
|
||||||
@@ -462,6 +466,16 @@ public abstract class AbstractMinecart extends Entity {
|
@@ -450,6 +454,16 @@ public abstract class AbstractMinecart extends Entity {
|
||||||
entity.push(this);
|
entity.push(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -54,20 +54,20 @@ index 9948a28dae4edba877c13ef0156be5ff58df3fa2..93f359c71659c0b2fdf25b1c76c072bf
|
|||||||
+ }
|
+ }
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Iterator iterator = this.level().getEntities(this, this.getBoundingBox().inflate(0.20000000298023224D, 0.0D, 0.20000000298023224D)).iterator();
|
Iterator iterator = this.level.getEntities(this, this.getBoundingBox().inflate(0.20000000298023224D, 0.0D, 0.20000000298023224D)).iterator();
|
||||||
diff --git a/src/main/java/net/minecraft/world/entity/vehicle/Boat.java b/src/main/java/net/minecraft/world/entity/vehicle/Boat.java
|
diff --git a/src/main/java/net/minecraft/world/entity/vehicle/Boat.java b/src/main/java/net/minecraft/world/entity/vehicle/Boat.java
|
||||||
index 35aeba4e8430e6419caa9db4a0b931a994228618..11b337298ac824adce04cf0608f8f960e59640c9 100644
|
index 0dbc85c450797d7384e641f80e1b1f8c56fd14fc..99e9867dfc0b3ba8b11dd95c264794f2f0079994 100644
|
||||||
--- a/src/main/java/net/minecraft/world/entity/vehicle/Boat.java
|
--- a/src/main/java/net/minecraft/world/entity/vehicle/Boat.java
|
||||||
+++ b/src/main/java/net/minecraft/world/entity/vehicle/Boat.java
|
+++ b/src/main/java/net/minecraft/world/entity/vehicle/Boat.java
|
||||||
@@ -5,6 +5,7 @@ import com.google.common.collect.UnmodifiableIterator;
|
@@ -4,6 +4,7 @@ import com.google.common.collect.Lists;
|
||||||
|
import com.google.common.collect.UnmodifiableIterator;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.IntFunction;
|
|
||||||
+import java.util.concurrent.TimeUnit;
|
+import java.util.concurrent.TimeUnit;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import net.minecraft.BlockUtil;
|
import net.minecraft.BlockUtil;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
@@ -109,6 +110,7 @@ public class Boat extends Entity implements VariantHolder<Boat.Type> {
|
@@ -106,6 +107,7 @@ public class Boat extends Entity {
|
||||||
public double unoccupiedDeceleration = -1;
|
public double unoccupiedDeceleration = -1;
|
||||||
public boolean landBoats = false;
|
public boolean landBoats = false;
|
||||||
// CraftBukkit end
|
// CraftBukkit end
|
||||||
@@ -75,14 +75,14 @@ index 35aeba4e8430e6419caa9db4a0b931a994228618..11b337298ac824adce04cf0608f8f960
|
|||||||
|
|
||||||
public Boat(EntityType<? extends Boat> type, Level world) {
|
public Boat(EntityType<? extends Boat> type, Level world) {
|
||||||
super(type, world);
|
super(type, world);
|
||||||
@@ -421,10 +423,12 @@ public class Boat extends Entity implements VariantHolder<Boat.Type> {
|
@@ -398,10 +400,12 @@ public class Boat extends Entity {
|
||||||
this.checkInsideBlocks();
|
this.checkInsideBlocks();
|
||||||
List<Entity> list = this.level().getEntities((Entity) this, this.getBoundingBox().inflate(0.20000000298023224D, -0.009999999776482582D, 0.20000000298023224D), EntitySelector.pushableBy(this));
|
List<Entity> list = this.level.getEntities((Entity) this, this.getBoundingBox().inflate(0.20000000298023224D, -0.009999999776482582D, 0.20000000298023224D), EntitySelector.pushableBy(this));
|
||||||
|
|
||||||
- if (!list.isEmpty()) {
|
- if (!list.isEmpty()) {
|
||||||
+ // Scissors - Add collision debounce
|
+ // Scissors - Add collision debounce
|
||||||
+ if (!list.isEmpty() && (System.currentTimeMillis() - lastLargeCollision) >= TimeUnit.SECONDS.toMillis(5)) { // Using TimeUnit for better code readability
|
+ if (!list.isEmpty() && (System.currentTimeMillis() - lastLargeCollision) >= TimeUnit.SECONDS.toMillis(5)) { // Using TimeUnit for better code readability
|
||||||
boolean flag = !this.level().isClientSide && !(this.getControllingPassenger() instanceof Player);
|
boolean flag = !this.level.isClientSide && !(this.getControllingPassenger() instanceof Player);
|
||||||
|
|
||||||
- for (int j = 0; j < list.size(); ++j) {
|
- for (int j = 0; j < list.size(); ++j) {
|
||||||
+ // Scissors - Limit amount of vehicle collision checks to 3 maximum
|
+ // Scissors - Limit amount of vehicle collision checks to 3 maximum
|
||||||
@@ -90,7 +90,7 @@ index 35aeba4e8430e6419caa9db4a0b931a994228618..11b337298ac824adce04cf0608f8f960
|
|||||||
Entity entity = (Entity) list.get(j);
|
Entity entity = (Entity) list.get(j);
|
||||||
|
|
||||||
if (!entity.hasPassenger((Entity) this)) {
|
if (!entity.hasPassenger((Entity) this)) {
|
||||||
@@ -435,6 +439,16 @@ public class Boat extends Entity implements VariantHolder<Boat.Type> {
|
@@ -412,6 +416,16 @@ public class Boat extends Entity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -1,173 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Telesphoreo <me@telesphoreo.me>
|
|
||||||
Date: Thu, 8 Jun 2023 19:41:10 -0500
|
|
||||||
Subject: [PATCH] Block server side chunkbans
|
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/network/PacketEncoder.java b/src/main/java/net/minecraft/network/PacketEncoder.java
|
|
||||||
index fbfadeb83719b81f42724e79c59e92ed88fdece7..bcb9d99359fb3e03c86d7429d9bcfe63b6c0f5d5 100644
|
|
||||||
--- a/src/main/java/net/minecraft/network/PacketEncoder.java
|
|
||||||
+++ b/src/main/java/net/minecraft/network/PacketEncoder.java
|
|
||||||
@@ -6,9 +6,18 @@ import io.netty.channel.ChannelHandlerContext;
|
|
||||||
import io.netty.handler.codec.MessageToByteEncoder;
|
|
||||||
import io.papermc.paper.adventure.PaperAdventure; // Paper
|
|
||||||
import java.io.IOException;
|
|
||||||
+import java.util.Collections;
|
|
||||||
+
|
|
||||||
+import net.minecraft.ChatFormatting;
|
|
||||||
+import net.minecraft.core.NonNullList;
|
|
||||||
+import net.minecraft.nbt.CompoundTag;
|
|
||||||
+import net.minecraft.network.chat.Component;
|
|
||||||
+import net.minecraft.network.chat.SignedMessageBody;
|
|
||||||
import net.minecraft.network.protocol.Packet;
|
|
||||||
import net.minecraft.network.protocol.PacketFlow;
|
|
||||||
+import net.minecraft.network.protocol.game.*;
|
|
||||||
import net.minecraft.util.profiling.jfr.JvmProfiler;
|
|
||||||
+import net.minecraft.world.item.ItemStack;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
|
|
||||||
public class PacketEncoder extends MessageToByteEncoder<Packet<?>> {
|
|
||||||
@@ -19,6 +28,23 @@ public class PacketEncoder extends MessageToByteEncoder<Packet<?>> {
|
|
||||||
this.flow = side;
|
|
||||||
}
|
|
||||||
|
|
||||||
+ // Scissors start
|
|
||||||
+ private static int tryWrite(Packet packet, FriendlyByteBuf friendlyByteBuf, ChannelHandlerContext channelHandlerContext, int i) {
|
|
||||||
+ friendlyByteBuf.writeVarInt(i);
|
|
||||||
+ friendlyByteBuf.adventure$locale = channelHandlerContext.channel().attr(PaperAdventure.LOCALE_ATTRIBUTE).get();
|
|
||||||
+
|
|
||||||
+ int j = friendlyByteBuf.writerIndex();
|
|
||||||
+ packet.write(friendlyByteBuf);
|
|
||||||
+ int k = friendlyByteBuf.writerIndex() - j;
|
|
||||||
+ int packetLength = friendlyByteBuf.readableBytes();
|
|
||||||
+ if (k > 8388608 || packetLength > MAX_PACKET_SIZE) {
|
|
||||||
+ throw new SkipPacketException(new IllegalArgumentException("Packet too big (is " + k + "): " + packet));
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ return k;
|
|
||||||
+ }
|
|
||||||
+ // Scissors end
|
|
||||||
+
|
|
||||||
protected void encode(ChannelHandlerContext channelHandlerContext, Packet<?> packet, ByteBuf byteBuf) throws Exception {
|
|
||||||
ConnectionProtocol connectionProtocol = channelHandlerContext.channel().attr(Connection.ATTRIBUTE_PROTOCOL).get();
|
|
||||||
if (connectionProtocol == null) {
|
|
||||||
@@ -33,38 +59,66 @@ public class PacketEncoder extends MessageToByteEncoder<Packet<?>> {
|
|
||||||
throw new IOException("Can't serialize unregistered packet");
|
|
||||||
} else {
|
|
||||||
FriendlyByteBuf friendlyByteBuf = new FriendlyByteBuf(byteBuf);
|
|
||||||
- friendlyByteBuf.writeVarInt(i);
|
|
||||||
- friendlyByteBuf.adventure$locale = channelHandlerContext.channel().attr(PaperAdventure.LOCALE_ATTRIBUTE).get(); // Paper
|
|
||||||
|
|
||||||
+ // Scissors start
|
|
||||||
+ int k;
|
|
||||||
try {
|
|
||||||
- int j = friendlyByteBuf.writerIndex();
|
|
||||||
- packet.write(friendlyByteBuf);
|
|
||||||
- int k = friendlyByteBuf.writerIndex() - j;
|
|
||||||
- if (false && k > 8388608) { // Paper - disable
|
|
||||||
- throw new IllegalArgumentException("Packet too big (is " + k + ", should be less than 8388608): " + packet);
|
|
||||||
- } else {
|
|
||||||
- int l = channelHandlerContext.channel().attr(Connection.ATTRIBUTE_PROTOCOL).get().getId();
|
|
||||||
- JvmProfiler.INSTANCE.onPacketSent(l, i, channelHandlerContext.channel().remoteAddress(), k);
|
|
||||||
- }
|
|
||||||
+ k = tryWrite(packet, friendlyByteBuf, channelHandlerContext, i);
|
|
||||||
} catch (Throwable var10) {
|
|
||||||
- LOGGER.error("Packet encoding of packet ID {} threw (skippable? {})", i, packet.isSkippable(), var10); // Paper - Give proper error message
|
|
||||||
- if (packet.isSkippable()) {
|
|
||||||
- throw new SkipPacketException(var10);
|
|
||||||
- } else {
|
|
||||||
- throw var10;
|
|
||||||
+ packet = capPacket(packet, i);
|
|
||||||
+ if (packet == null) {
|
|
||||||
+ throw new SkipPacketException(new IllegalArgumentException("Packet too big: " + packet));
|
|
||||||
}
|
|
||||||
+ friendlyByteBuf.clear();
|
|
||||||
+ k = tryWrite(packet, friendlyByteBuf, channelHandlerContext, i);
|
|
||||||
}
|
|
||||||
|
|
||||||
- // Paper start
|
|
||||||
- int packetLength = friendlyByteBuf.readableBytes();
|
|
||||||
- if (packetLength > MAX_PACKET_SIZE) {
|
|
||||||
- throw new PacketTooLargeException(packet, packetLength);
|
|
||||||
- }
|
|
||||||
- // Paper end
|
|
||||||
+ int l = channelHandlerContext.channel().attr(Connection.ATTRIBUTE_PROTOCOL).get().getId();
|
|
||||||
+ JvmProfiler.INSTANCE.onPacketSent(l, i, channelHandlerContext.channel().remoteAddress(), k);
|
|
||||||
+ // Scissors end
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
+ // Scissors start
|
|
||||||
+ private static Packet capPacket(Packet packet, int i) {
|
|
||||||
+ if (packet instanceof ClientboundBlockEntityDataPacket blockEntityDataPacket) {
|
|
||||||
+ packet = new ClientboundBlockEntityDataPacket(blockEntityDataPacket.getPos(), blockEntityDataPacket.getType(), new CompoundTag());
|
|
||||||
+ } else if (packet instanceof ClientboundLevelChunkPacketData chunkPacket) {
|
|
||||||
+ chunkPacket.clearNBT();
|
|
||||||
+ } else if (packet instanceof ClientboundSetEntityDataPacket) {
|
|
||||||
+ return null; // Skip
|
|
||||||
+ } else if (packet instanceof ClientboundContainerSetContentPacket containerSetContentPacket) {
|
|
||||||
+ packet = new ClientboundContainerSetContentPacket(containerSetContentPacket.getContainerId(), containerSetContentPacket.getStateId(), NonNullList.create(), ItemStack.EMPTY);
|
|
||||||
+ } else if (packet instanceof ClientboundSetEquipmentPacket setEquipmentPacket) {
|
|
||||||
+ packet = new ClientboundSetEquipmentPacket(setEquipmentPacket.getEntity(), Collections.emptyList());
|
|
||||||
+ } else if (packet instanceof ClientboundContainerSetSlotPacket containerSetSlotPacket) {
|
|
||||||
+ packet = new ClientboundContainerSetSlotPacket(containerSetSlotPacket.getContainerId(), containerSetSlotPacket.getStateId(), containerSetSlotPacket.getSlot(), ItemStack.EMPTY);
|
|
||||||
+ } else if (packet instanceof ClientboundMapItemDataPacket mapItemDataPacket) {
|
|
||||||
+ packet = new ClientboundMapItemDataPacket(mapItemDataPacket.getMapId(), mapItemDataPacket.getScale(), mapItemDataPacket.isLocked(), null, null);
|
|
||||||
+ } else if (packet instanceof ClientboundSystemChatPacket) {
|
|
||||||
+ return null;
|
|
||||||
+ } else if (packet instanceof ClientboundDisguisedChatPacket) {
|
|
||||||
+ return null;
|
|
||||||
+ } else if (packet instanceof ClientboundPlayerChatPacket playerChatPacket) {
|
|
||||||
+ final SignedMessageBody.Packed body = playerChatPacket.body();
|
|
||||||
+ packet = new ClientboundPlayerChatPacket(playerChatPacket.sender(), // Not sending this packet results in a kick when someone says something.
|
|
||||||
+ playerChatPacket.index(),
|
|
||||||
+ playerChatPacket.signature(),
|
|
||||||
+ playerChatPacket.body(),
|
|
||||||
+ Component.empty().append("** Message too large **").withStyle(ChatFormatting.RED),
|
|
||||||
+ playerChatPacket.filterMask(),
|
|
||||||
+ playerChatPacket.chatType()
|
|
||||||
+ );
|
|
||||||
+ } else {
|
|
||||||
+ LOGGER.error("Packet with ID {} was too large and was not caught. Please report this to the Scissors developers.", i);
|
|
||||||
+ return null;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ return packet;
|
|
||||||
+ }
|
|
||||||
+ // Scissors end
|
|
||||||
+
|
|
||||||
// Paper start
|
|
||||||
private static int MAX_PACKET_SIZE = 8388608;
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundBlockEntityDataPacket.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundBlockEntityDataPacket.java
|
|
||||||
index 3944852921335c78a04a9dc301882ab5b152b1ed..96ee53c7cc862e059328c5cdf5e07f309df6a79e 100644
|
|
||||||
--- a/src/main/java/net/minecraft/network/protocol/game/ClientboundBlockEntityDataPacket.java
|
|
||||||
+++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundBlockEntityDataPacket.java
|
|
||||||
@@ -24,7 +24,7 @@ public class ClientboundBlockEntityDataPacket implements Packet<ClientGamePacket
|
|
||||||
return create(blockEntity, BlockEntity::getUpdateTag);
|
|
||||||
}
|
|
||||||
|
|
||||||
- private ClientboundBlockEntityDataPacket(BlockPos pos, BlockEntityType<?> blockEntityType, CompoundTag nbt) {
|
|
||||||
+ public ClientboundBlockEntityDataPacket(BlockPos pos, BlockEntityType<?> blockEntityType, CompoundTag nbt) { // Scissors - private -> public
|
|
||||||
this.pos = pos;
|
|
||||||
this.type = blockEntityType;
|
|
||||||
this.tag = nbt.isEmpty() ? null : nbt;
|
|
||||||
diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java
|
|
||||||
index 39b879f21f958dbd91ab0f74e5d4f3c74928fc33..c5d568ce15879be812207f4cd7819f2f6e7d0f7e 100644
|
|
||||||
--- a/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java
|
|
||||||
+++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java
|
|
||||||
@@ -33,6 +33,13 @@ public class ClientboundLevelChunkPacketData {
|
|
||||||
}
|
|
||||||
// Paper end
|
|
||||||
|
|
||||||
+ // Scissors start
|
|
||||||
+ public void clearNBT() {
|
|
||||||
+ this.blockEntitiesData.clear();
|
|
||||||
+ this.extraPackets.clear();
|
|
||||||
+ }
|
|
||||||
+ // Scissors end
|
|
||||||
+
|
|
||||||
// Paper start - Anti-Xray - Add chunk packet info
|
|
||||||
@Deprecated @io.papermc.paper.annotation.DoNotUse public ClientboundLevelChunkPacketData(LevelChunk chunk) { this(chunk, null); }
|
|
||||||
public ClientboundLevelChunkPacketData(LevelChunk chunk, com.destroystokyo.paper.antixray.ChunkPacketInfo<net.minecraft.world.level.block.state.BlockState> chunkPacketInfo) {
|
|
@@ -0,0 +1,63 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Business Goose <arclicious@vivaldi.net>
|
||||||
|
Date: Sun, 1 May 2022 01:19:36 +0100
|
||||||
|
Subject: [PATCH] Make the maximum tag size a constant & add a method for
|
||||||
|
getting tag size
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/com/github/atlasmediagroup/scissors/NbtUtility.java b/src/main/java/com/github/atlasmediagroup/scissors/NbtUtility.java
|
||||||
|
index 058203440fd071ce5edbe18391ea60f0a5fbee3a..978cb98c81195640fb3704d2077148f2be0dca36 100644
|
||||||
|
--- a/src/main/java/com/github/atlasmediagroup/scissors/NbtUtility.java
|
||||||
|
+++ b/src/main/java/com/github/atlasmediagroup/scissors/NbtUtility.java
|
||||||
|
@@ -1,17 +1,49 @@
|
||||||
|
package com.github.atlasmediagroup.scissors;
|
||||||
|
|
||||||
|
-import net.minecraft.nbt.CompoundTag;
|
||||||
|
+import com.google.common.base.Strings;
|
||||||
|
+import com.google.common.collect.Lists;
|
||||||
|
+import net.minecraft.nbt.*;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
+import java.util.Collections;
|
||||||
|
+import java.util.List;
|
||||||
|
|
||||||
|
public class NbtUtility
|
||||||
|
{
|
||||||
|
+ public static final long MAXIMUM_SIZE = (256 * 1024);
|
||||||
|
+
|
||||||
|
+ public static long getTagSize(@Nullable Tag tag, int depth) {
|
||||||
|
+ if(depth > 512) return 0;
|
||||||
|
+ if(tag == null) return 0;
|
||||||
|
+
|
||||||
|
+ long size = 0;
|
||||||
|
+
|
||||||
|
+ if(tag.getType() == CompoundTag.TYPE) {
|
||||||
|
+ CompoundTag compoundTag = (CompoundTag) tag;
|
||||||
|
+ for(String key : compoundTag.getAllKeys()) {
|
||||||
|
+ size += getTagSize(compoundTag.get(key), depth + 1);
|
||||||
|
+ }
|
||||||
|
+ } else if(tag.getType() == ListTag.TYPE) {
|
||||||
|
+ ListTag listTag = (ListTag) tag;
|
||||||
|
+ for (Tag tag1 : listTag) {
|
||||||
|
+ size += getTagSize(tag1, depth + 1);
|
||||||
|
+ }
|
||||||
|
+ } else {
|
||||||
|
+ size += tag.getAsString().getBytes(StandardCharsets.UTF_8).length;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ return size;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public static long getTagSize(@Nullable CompoundTag tag) {
|
||||||
|
+ return getTagSize(tag, 0);
|
||||||
|
+ }
|
||||||
|
|
||||||
|
public static boolean isTooLarge(@Nullable CompoundTag tag)
|
||||||
|
{
|
||||||
|
if (tag == null) return false;
|
||||||
|
- return tag.toString().getBytes(StandardCharsets.UTF_8).length > (256 * 1024);
|
||||||
|
+ return getTagSize(tag) > MAXIMUM_SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Item
|
@@ -1,15 +1,15 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
From: Telesphoreo <me@telesphoreo.me>
|
From: Allink <arclicious@vivaldi.net>
|
||||||
Date: Thu, 8 Jun 2023 19:32:11 -0500
|
Date: Tue, 17 May 2022 05:57:52 +0100
|
||||||
Subject: [PATCH] Don't log invalid teams to console
|
Subject: [PATCH] Don't log invalid teams to console
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||||
index 468f64afb7e9b3ef579205d3beea025deb31b460..71a32f8dfdf043f55f092225a13884ae8935e67c 100644
|
index d8393887cc98930815864eca28b07ef89b26f39e..3b5c48bfb7e7bcd0be9ad6d0357213c7adde08ad 100644
|
||||||
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||||
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||||
@@ -862,7 +862,9 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
@@ -813,7 +813,9 @@ public abstract class LivingEntity extends Entity {
|
||||||
boolean flag = scoreboardteam != null && this.level().getScoreboard().addPlayerToTeam(this.getStringUUID(), scoreboardteam);
|
boolean flag = scoreboardteam != null && this.level.getScoreboard().addPlayerToTeam(this.getStringUUID(), scoreboardteam);
|
||||||
|
|
||||||
if (!flag) {
|
if (!flag) {
|
||||||
- LivingEntity.LOGGER.warn("Unable to add mob to team \"{}\" (that team probably doesn't exist)", s);
|
- LivingEntity.LOGGER.warn("Unable to add mob to team \"{}\" (that team probably doesn't exist)", s);
|
@@ -1,21 +1,23 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
From: Allink <arclicious@vivaldi.net>
|
From: Allink <arclicious@vivaldi.net>
|
||||||
Date: Mon, 4 Jul 2022 22:12:19 +0100
|
Date: Mon, 4 Jul 2022 21:43:40 +0100
|
||||||
Subject: [PATCH] Add MasterBlockFireEvent
|
Subject: [PATCH] Add MasterBlockFireEvent
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/level/block/CommandBlock.java b/src/main/java/net/minecraft/world/level/block/CommandBlock.java
|
diff --git a/src/main/java/net/minecraft/world/level/block/CommandBlock.java b/src/main/java/net/minecraft/world/level/block/CommandBlock.java
|
||||||
index 2e7c03b00bc941b86df6a7f1b2b188c9f0aede22..333f9bcccbe9ecd88c1fd13e2956f69414d6e295 100644
|
index 1a48c5ea1f2f755abfa85469e26f37ea5f02d6da..d6ed6b04792c4766ed5111fb83d52b76967d6856 100644
|
||||||
--- a/src/main/java/net/minecraft/world/level/block/CommandBlock.java
|
--- a/src/main/java/net/minecraft/world/level/block/CommandBlock.java
|
||||||
+++ b/src/main/java/net/minecraft/world/level/block/CommandBlock.java
|
+++ b/src/main/java/net/minecraft/world/level/block/CommandBlock.java
|
||||||
@@ -1,5 +1,6 @@
|
@@ -1,7 +1,7 @@
|
||||||
package net.minecraft.world.level.block;
|
package net.minecraft.world.level.block;
|
||||||
|
|
||||||
+import me.totalfreedom.scissors.event.block.MasterBlockFireEvent;
|
|
||||||
import com.mojang.logging.LogUtils;
|
import com.mojang.logging.LogUtils;
|
||||||
|
-import java.util.Random;
|
||||||
|
+import me.totalfreedom.scissors.event.block.MasterBlockFireEvent;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.Direction;
|
import net.minecraft.core.Direction;
|
||||||
@@ -25,10 +26,10 @@ import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
|
@@ -25,9 +25,11 @@ import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
||||||
import net.minecraft.world.level.block.state.properties.BooleanProperty;
|
import net.minecraft.world.level.block.state.properties.BooleanProperty;
|
||||||
import net.minecraft.world.level.block.state.properties.DirectionProperty;
|
import net.minecraft.world.level.block.state.properties.DirectionProperty;
|
||||||
import net.minecraft.world.phys.BlockHitResult;
|
import net.minecraft.world.phys.BlockHitResult;
|
||||||
@@ -24,11 +26,11 @@ index 2e7c03b00bc941b86df6a7f1b2b188c9f0aede22..333f9bcccbe9ecd88c1fd13e2956f694
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
-import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit
|
-import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit
|
||||||
-
|
+import java.util.Random;
|
||||||
|
|
||||||
public class CommandBlock extends BaseEntityBlock implements GameMasterBlock {
|
public class CommandBlock extends BaseEntityBlock implements GameMasterBlock {
|
||||||
|
|
||||||
private static final Logger LOGGER = LogUtils.getLogger();
|
@@ -117,6 +119,15 @@ public class CommandBlock extends BaseEntityBlock implements GameMasterBlock {
|
||||||
@@ -117,6 +118,15 @@ public class CommandBlock extends BaseEntityBlock implements GameMasterBlock {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void execute(BlockState state, Level world, BlockPos pos, BaseCommandBlock executor, boolean hasCommand) {
|
private void execute(BlockState state, Level world, BlockPos pos, BaseCommandBlock executor, boolean hasCommand) {
|
||||||
@@ -44,46 +46,32 @@ index 2e7c03b00bc941b86df6a7f1b2b188c9f0aede22..333f9bcccbe9ecd88c1fd13e2956f694
|
|||||||
if (hasCommand) {
|
if (hasCommand) {
|
||||||
executor.performCommand(world);
|
executor.performCommand(world);
|
||||||
} else {
|
} else {
|
||||||
diff --git a/src/main/java/net/minecraft/world/level/block/StructureBlock.java b/src/main/java/net/minecraft/world/level/block/StructureBlock.java
|
|
||||||
index a3dac53b07618819b322b48339d850d80a1c55ba..4dd21b7ea247b3ced3d3ee6c67746cc6811d5bb8 100644
|
|
||||||
--- a/src/main/java/net/minecraft/world/level/block/StructureBlock.java
|
|
||||||
+++ b/src/main/java/net/minecraft/world/level/block/StructureBlock.java
|
|
||||||
@@ -1,6 +1,7 @@
|
|
||||||
package net.minecraft.world.level.block;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
+
|
|
||||||
import net.minecraft.core.BlockPos;
|
|
||||||
import net.minecraft.server.level.ServerLevel;
|
|
||||||
import net.minecraft.world.InteractionHand;
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/JigsawBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/JigsawBlockEntity.java
|
diff --git a/src/main/java/net/minecraft/world/level/block/entity/JigsawBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/JigsawBlockEntity.java
|
||||||
index 182e16c1d968707a11329150d71b7d01df6c6e52..fa5cade3f5f2fecc37cc065b96403d0a1c1a2553 100644
|
index 4bed3a1f353ada478c93e3e6f94aa7ea9d228730..02a9c902a2ec8994ebc8c639864aa0d231aab61a 100644
|
||||||
--- a/src/main/java/net/minecraft/world/level/block/entity/JigsawBlockEntity.java
|
--- a/src/main/java/net/minecraft/world/level/block/entity/JigsawBlockEntity.java
|
||||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/JigsawBlockEntity.java
|
+++ b/src/main/java/net/minecraft/world/level/block/entity/JigsawBlockEntity.java
|
||||||
@@ -2,6 +2,8 @@ package net.minecraft.world.level.block.entity;
|
@@ -1,5 +1,6 @@
|
||||||
|
package net.minecraft.world.level.block.entity;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Optional;
|
|
||||||
+
|
|
||||||
+import me.totalfreedom.scissors.event.block.MasterBlockFireEvent;
|
+import me.totalfreedom.scissors.event.block.MasterBlockFireEvent;
|
||||||
import net.minecraft.core.BlockPos;
|
import com.google.common.collect.Lists;
|
||||||
import net.minecraft.core.Holder;
|
import java.util.Arrays;
|
||||||
import net.minecraft.core.Registry;
|
import java.util.List;
|
||||||
@@ -17,6 +19,7 @@ import net.minecraft.world.level.block.JigsawBlock;
|
@@ -27,6 +28,7 @@ import net.minecraft.world.level.levelgen.structure.pools.SinglePoolElement;
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
import net.minecraft.world.level.levelgen.structure.pools.StructurePoolElement;
|
||||||
import net.minecraft.world.level.levelgen.structure.pools.JigsawPlacement;
|
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureManager;
|
||||||
import net.minecraft.world.level.levelgen.structure.pools.StructureTemplatePool;
|
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate;
|
||||||
+import org.bukkit.Location;
|
+import org.bukkit.Location;
|
||||||
|
|
||||||
public class JigsawBlockEntity extends BlockEntity {
|
public class JigsawBlockEntity extends BlockEntity {
|
||||||
public static final String TARGET = "target";
|
public static final String TARGET = "target";
|
||||||
@@ -107,6 +110,16 @@ public class JigsawBlockEntity extends BlockEntity {
|
@@ -117,11 +119,21 @@ public class JigsawBlockEntity extends BlockEntity {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void generate(ServerLevel world, int maxDepth, boolean keepJigsaws) {
|
public void generate(ServerLevel world, int maxDepth, boolean keepJigsaws) {
|
||||||
+ // Scissors - Add master block fire event
|
+ // Scissors - Add master block fire event
|
||||||
+ final BlockPos pos = this.getBlockPos();
|
+ final BlockPos blockPos = this.getBlockPos();
|
||||||
+ final MasterBlockFireEvent event = new MasterBlockFireEvent(new Location(this.getLevel().getWorld(), pos.getX(), pos.getY(), pos.getZ()));
|
+ final MasterBlockFireEvent event = new MasterBlockFireEvent(new Location(this.getLevel().getWorld(), blockPos.getX(), blockPos.getY(), blockPos.getZ()));
|
||||||
+
|
+
|
||||||
+ if (!event.callEvent())
|
+ if (!event.callEvent())
|
||||||
+ {
|
+ {
|
||||||
@@ -91,15 +79,21 @@ index 182e16c1d968707a11329150d71b7d01df6c6e52..fa5cade3f5f2fecc37cc065b96403d0a
|
|||||||
+ }
|
+ }
|
||||||
+ // Scissors end
|
+ // Scissors end
|
||||||
+
|
+
|
||||||
BlockPos blockPos = this.getBlockPos().relative(this.getBlockState().getValue(JigsawBlock.ORIENTATION).front());
|
ChunkGenerator chunkGenerator = world.getChunkSource().getGenerator();
|
||||||
Registry<StructureTemplatePool> registry = world.registryAccess().registryOrThrow(Registries.TEMPLATE_POOL);
|
StructureManager structureManager = world.getStructureManager();
|
||||||
// Paper start - Replace getHolderOrThrow with a null check
|
StructureFeatureManager structureFeatureManager = world.structureFeatureManager();
|
||||||
|
Random random = world.getRandom();
|
||||||
|
- BlockPos blockPos = this.getBlockPos();
|
||||||
|
+ // BlockPos blockPos = this.getBlockPos(); // Scissors - We've already defined this in the scope
|
||||||
|
List<PoolElementStructurePiece> list = Lists.newArrayList();
|
||||||
|
StructureTemplate structureTemplate = new StructureTemplate();
|
||||||
|
structureTemplate.fillFromWorld(world, blockPos, new Vec3i(1, 1, 1), false, (Block)null);
|
||||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/StructureBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/StructureBlockEntity.java
|
diff --git a/src/main/java/net/minecraft/world/level/block/entity/StructureBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/StructureBlockEntity.java
|
||||||
index 9792bf3ee083f571f1f4089d30beb586839f5f6b..e9d584b0ca984f9b7c70f99e1665cdedecb710e1 100644
|
index 9a65ed7e5ed76a320c8602b0a4edeff6615d9e0b..e46727ee13550d4ab5473dc5ac28abddf822c9ee 100644
|
||||||
--- a/src/main/java/net/minecraft/world/level/block/entity/StructureBlockEntity.java
|
--- a/src/main/java/net/minecraft/world/level/block/entity/StructureBlockEntity.java
|
||||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/StructureBlockEntity.java
|
+++ b/src/main/java/net/minecraft/world/level/block/entity/StructureBlockEntity.java
|
||||||
@@ -5,6 +5,8 @@ import java.util.Objects;
|
@@ -6,6 +6,8 @@ import java.util.Optional;
|
||||||
import java.util.Optional;
|
import java.util.Random;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
+
|
+
|
||||||
@@ -108,9 +102,9 @@ index 9792bf3ee083f571f1f4089d30beb586839f5f6b..e9d584b0ca984f9b7c70f99e1665cded
|
|||||||
import net.minecraft.Util;
|
import net.minecraft.Util;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
@@ -29,6 +31,7 @@ import net.minecraft.world.level.levelgen.structure.templatesystem.BlockRotProce
|
@@ -29,6 +31,7 @@ import net.minecraft.world.level.levelgen.structure.templatesystem.BlockRotProce
|
||||||
|
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureManager;
|
||||||
import net.minecraft.world.level.levelgen.structure.templatesystem.StructurePlaceSettings;
|
import net.minecraft.world.level.levelgen.structure.templatesystem.StructurePlaceSettings;
|
||||||
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate;
|
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate;
|
||||||
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplateManager;
|
|
||||||
+import org.bukkit.Location;
|
+import org.bukkit.Location;
|
||||||
|
|
||||||
public class StructureBlockEntity extends BlockEntity {
|
public class StructureBlockEntity extends BlockEntity {
|
||||||
@@ -139,7 +133,7 @@ index 9792bf3ee083f571f1f4089d30beb586839f5f6b..e9d584b0ca984f9b7c70f99e1665cded
|
|||||||
+
|
+
|
||||||
BlockPos blockPos = this.getBlockPos().offset(this.structurePos);
|
BlockPos blockPos = this.getBlockPos().offset(this.structurePos);
|
||||||
ServerLevel serverLevel = (ServerLevel)this.level;
|
ServerLevel serverLevel = (ServerLevel)this.level;
|
||||||
StructureTemplateManager structureTemplateManager = serverLevel.getStructureManager();
|
StructureManager structureManager = serverLevel.getStructureManager();
|
||||||
@@ -358,6 +370,16 @@ public class StructureBlockEntity extends BlockEntity {
|
@@ -358,6 +370,16 @@ public class StructureBlockEntity extends BlockEntity {
|
||||||
|
|
||||||
public boolean loadStructure(ServerLevel world, boolean bl) {
|
public boolean loadStructure(ServerLevel world, boolean bl) {
|
||||||
@@ -154,7 +148,7 @@ index 9792bf3ee083f571f1f4089d30beb586839f5f6b..e9d584b0ca984f9b7c70f99e1665cded
|
|||||||
+ }
|
+ }
|
||||||
+ // Scissors end
|
+ // Scissors end
|
||||||
+
|
+
|
||||||
StructureTemplateManager structureTemplateManager = world.getStructureManager();
|
StructureManager structureManager = world.getStructureManager();
|
||||||
|
|
||||||
Optional<StructureTemplate> optional;
|
Optional<StructureTemplate> optional;
|
||||||
@@ -403,6 +425,16 @@ public class StructureBlockEntity extends BlockEntity {
|
@@ -403,6 +425,16 @@ public class StructureBlockEntity extends BlockEntity {
|
||||||
@@ -173,4 +167,4 @@ index 9792bf3ee083f571f1f4089d30beb586839f5f6b..e9d584b0ca984f9b7c70f99e1665cded
|
|||||||
+
|
+
|
||||||
if (this.structureName != null) {
|
if (this.structureName != null) {
|
||||||
ServerLevel serverLevel = (ServerLevel)this.level;
|
ServerLevel serverLevel = (ServerLevel)this.level;
|
||||||
StructureTemplateManager structureTemplateManager = serverLevel.getStructureManager();
|
StructureManager structureManager = serverLevel.getStructureManager();
|
@@ -1,11 +1,11 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
From: Allink <arclicious@vivaldi.net>
|
From: Allink <arclicious@vivaldi.net>
|
||||||
Date: Tue, 5 Jul 2022 04:12:31 +0100
|
Date: Tue, 5 Jul 2022 04:00:42 +0100
|
||||||
Subject: [PATCH] Add spectator teleport event
|
Subject: [PATCH] Add spectator teleport event
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||||
index 61f6b51b9d868ae6bd79185cc066976a094da8ce..2807dbb730974ca4d3a7c7fd1358e2438628bc50 100644
|
index 64c438459f150af1cabdd3cea29c2951d42d69a0..b0bd0412010320cc624535d6abffe417a135a4dc 100644
|
||||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||||
@@ -1,5 +1,6 @@
|
@@ -1,5 +1,6 @@
|
||||||
@@ -15,7 +15,7 @@ index 61f6b51b9d868ae6bd79185cc066976a094da8ce..2807dbb730974ca4d3a7c7fd1358e243
|
|||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.common.primitives.Floats;
|
import com.google.common.primitives.Floats;
|
||||||
import com.mojang.brigadier.ParseResults;
|
import com.mojang.brigadier.ParseResults;
|
||||||
@@ -2066,6 +2067,14 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
@@ -1948,6 +1949,14 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
||||||
Entity entity = packet.getEntity(worldserver);
|
Entity entity = packet.getEntity(worldserver);
|
||||||
|
|
||||||
if (entity != null) {
|
if (entity != null) {
|
@@ -1,14 +1,14 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
From: Allink <arclicious@vivaldi.net>
|
From: Allink <arclicious@vivaldi.net>
|
||||||
Date: Sun, 10 Jul 2022 02:55:01 +0100
|
Date: Sun, 10 Jul 2022 02:44:05 +0100
|
||||||
Subject: [PATCH] Prevent invalid container events
|
Subject: [PATCH] Prevent invalid container events
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||||
index 2807dbb730974ca4d3a7c7fd1358e2438628bc50..37fcbdcddaa6cbfd6ae37d70cffab957c90f4e07 100644
|
index b0bd0412010320cc624535d6abffe417a135a4dc..65e9791d7e613d039f93184cde717bff8e97000c 100644
|
||||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||||
@@ -30,6 +30,8 @@ import java.util.function.UnaryOperator;
|
@@ -24,6 +24,8 @@ import java.util.function.UnaryOperator;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
@@ -17,15 +17,15 @@ index 2807dbb730974ca4d3a7c7fd1358e2438628bc50..37fcbdcddaa6cbfd6ae37d70cffab957
|
|||||||
import net.minecraft.ChatFormatting;
|
import net.minecraft.ChatFormatting;
|
||||||
import net.minecraft.CrashReport;
|
import net.minecraft.CrashReport;
|
||||||
import net.minecraft.CrashReportCategory;
|
import net.minecraft.CrashReportCategory;
|
||||||
@@ -2985,6 +2987,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
@@ -2642,6 +2644,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
||||||
public void handleContainerClick(ServerboundContainerClickPacket packet) {
|
public void handleContainerClick(ServerboundContainerClickPacket packet) {
|
||||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
|
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel());
|
||||||
if (this.player.isImmobile()) return; // CraftBukkit
|
if (this.player.isImmobile()) return; // CraftBukkit
|
||||||
+
|
+
|
||||||
this.player.resetLastActionTime();
|
this.player.resetLastActionTime();
|
||||||
if (this.player.containerMenu.containerId == packet.getContainerId() && this.player.containerMenu.stillValid(this.player)) { // CraftBukkit
|
if (this.player.containerMenu.containerId == packet.getContainerId() && this.player.containerMenu.stillValid(this.player)) { // CraftBukkit
|
||||||
boolean cancelled = this.player.isSpectator(); // CraftBukkit - see below if
|
boolean cancelled = this.player.isSpectator(); // CraftBukkit - see below if
|
||||||
@@ -3006,6 +3009,18 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
@@ -2661,6 +2664,18 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@@ -0,0 +1,24 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Allink <arclicious@vivaldi.net>
|
||||||
|
Date: Sun, 10 Jul 2022 02:45:15 +0100
|
||||||
|
Subject: [PATCH] Do not attempt to cast items to recipes
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java
|
||||||
|
index 0f19ef250a2f82e49730cb58ea43ee6bf407455a..764b56c2d5cdf5a57fced106d196ef866f70e885 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java
|
||||||
|
@@ -634,6 +634,13 @@ public abstract class AbstractFurnaceBlockEntity extends BaseContainerBlockEntit
|
||||||
|
Entry<ResourceLocation> entry = (Entry) objectiterator.next();
|
||||||
|
|
||||||
|
worldserver.getRecipeManager().byKey((ResourceLocation) entry.getKey()).ifPresent((irecipe) -> {
|
||||||
|
+ // Scissors start - Do not attempt to cast items to recipes
|
||||||
|
+ if (!(irecipe instanceof AbstractCookingRecipe))
|
||||||
|
+ {
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+ // Scissors end
|
||||||
|
+
|
||||||
|
list.add(irecipe);
|
||||||
|
AbstractFurnaceBlockEntity.createExperience(worldserver, vec3d, entry.getIntValue(), ((AbstractCookingRecipe) irecipe).getExperience(), blockposition, entityplayer, itemstack, amount); // CraftBukkit
|
||||||
|
});
|
@@ -1,24 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Telesphoreo <me@telesphoreo.me>
|
|
||||||
Date: Mon, 22 Aug 2022 21:33:37 -0500
|
|
||||||
Subject: [PATCH] Fixes out of bounds HangingEntity crash exploit
|
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/entity/decoration/HangingEntity.java b/src/main/java/net/minecraft/world/entity/decoration/HangingEntity.java
|
|
||||||
index 66cf0a6cd1525ecf2615809210a26d55f445d07d..74fb79d4ea11f88f2c0de65b492a5fecc49684f1 100644
|
|
||||||
--- a/src/main/java/net/minecraft/world/entity/decoration/HangingEntity.java
|
|
||||||
+++ b/src/main/java/net/minecraft/world/entity/decoration/HangingEntity.java
|
|
||||||
@@ -270,6 +270,13 @@ public abstract class HangingEntity extends Entity {
|
|
||||||
public void readAdditionalSaveData(CompoundTag nbt) {
|
|
||||||
BlockPos blockposition = new BlockPos(nbt.getInt("TileX"), nbt.getInt("TileY"), nbt.getInt("TileZ"));
|
|
||||||
|
|
||||||
+ // Scissors start - Fixes exploit where bad TileX, TileY, and TileZ coordinates can crash servers
|
|
||||||
+ if (level().isLoadedAndInBounds(blockposition))
|
|
||||||
+ {
|
|
||||||
+ this.pos = blockposition;
|
|
||||||
+ }
|
|
||||||
+ // Scissors end
|
|
||||||
+
|
|
||||||
if (!blockposition.closerThan(this.blockPosition(), 16.0D)) {
|
|
||||||
HangingEntity.LOGGER.error("Hanging entity at invalid position: {}", blockposition);
|
|
||||||
} else {
|
|
@@ -0,0 +1,456 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Allink <arclicious@vivaldi.net>
|
||||||
|
Date: Sun, 10 Jul 2022 09:57:10 +0100
|
||||||
|
Subject: [PATCH] Add Scissors configuration file & command
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/co/aikar/timings/TimingsExport.java b/src/main/java/co/aikar/timings/TimingsExport.java
|
||||||
|
index 06bff37e4c1fddd3be6343049a66787c63fb420c..c7f93f7b8531c0783eba0c77e319d9a08588c184 100644
|
||||||
|
--- a/src/main/java/co/aikar/timings/TimingsExport.java
|
||||||
|
+++ b/src/main/java/co/aikar/timings/TimingsExport.java
|
||||||
|
@@ -23,6 +23,7 @@
|
||||||
|
*/
|
||||||
|
package co.aikar.timings;
|
||||||
|
|
||||||
|
+import com.github.atlasmediagroup.scissors.ScissorsConfig;
|
||||||
|
import com.google.common.collect.Sets;
|
||||||
|
import io.papermc.paper.adventure.PaperAdventure;
|
||||||
|
import net.kyori.adventure.text.event.ClickEvent;
|
||||||
|
@@ -241,7 +242,8 @@ public class TimingsExport extends Thread {
|
||||||
|
parent.put("config", createObject(
|
||||||
|
pair("spigot", mapAsJSON(Bukkit.spigot().getSpigotConfig(), null)),
|
||||||
|
pair("bukkit", mapAsJSON(Bukkit.spigot().getBukkitConfig(), null)),
|
||||||
|
- pair("paper", mapAsJSON(Bukkit.spigot().getPaperConfig(), null))
|
||||||
|
+ pair("paper", mapAsJSON(Bukkit.spigot().getPaperConfig(), null)),
|
||||||
|
+ pair("scissors", mapAsJSON(ScissorsConfig.config, null)) // Scissors
|
||||||
|
));
|
||||||
|
|
||||||
|
new TimingsExport(listeners, parent, history).start();
|
||||||
|
diff --git a/src/main/java/com/github/atlasmediagroup/scissors/ScissorsCommand.java b/src/main/java/com/github/atlasmediagroup/scissors/ScissorsCommand.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000000000000000000000000000..2085c48fa4dda81bf275aee0b92c9e8206dba8e2
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/com/github/atlasmediagroup/scissors/ScissorsCommand.java
|
||||||
|
@@ -0,0 +1,156 @@
|
||||||
|
+package com.github.atlasmediagroup.scissors;
|
||||||
|
+
|
||||||
|
+import com.google.common.base.Functions;
|
||||||
|
+import com.google.common.base.Joiner;
|
||||||
|
+import com.google.common.collect.ImmutableSet;
|
||||||
|
+import com.google.common.collect.Iterables;
|
||||||
|
+import com.google.common.collect.Lists;
|
||||||
|
+import java.io.File;
|
||||||
|
+import java.util.ArrayList;
|
||||||
|
+import java.util.Arrays;
|
||||||
|
+import java.util.Collection;
|
||||||
|
+import java.util.Collections;
|
||||||
|
+import java.util.Iterator;
|
||||||
|
+import java.util.List;
|
||||||
|
+import java.util.Locale;
|
||||||
|
+import java.util.stream.Collectors;
|
||||||
|
+import net.minecraft.resources.ResourceLocation;
|
||||||
|
+import net.minecraft.server.MinecraftServer;
|
||||||
|
+import org.bukkit.Bukkit;
|
||||||
|
+import org.bukkit.ChatColor;
|
||||||
|
+import org.bukkit.Location;
|
||||||
|
+import org.bukkit.command.Command;
|
||||||
|
+import org.bukkit.command.CommandSender;
|
||||||
|
+
|
||||||
|
+public class ScissorsCommand extends Command
|
||||||
|
+{
|
||||||
|
+
|
||||||
|
+ private static final String BASE_PERM = "bukkit.command.scissors.";
|
||||||
|
+ private static final ImmutableSet<String> SUBCOMMANDS = ImmutableSet.<String>builder().add("reload", "version").build();
|
||||||
|
+
|
||||||
|
+ public ScissorsCommand(String name)
|
||||||
|
+ {
|
||||||
|
+ super(name);
|
||||||
|
+ this.description = "Scissors related commands";
|
||||||
|
+ this.usageMessage = "/scissors [" + Joiner.on(" | ").join(SUBCOMMANDS) + "]";
|
||||||
|
+ this.setPermission("bukkit.command.scissors;" + Joiner.on(';').join(SUBCOMMANDS.stream().map(s -> BASE_PERM + s).collect(
|
||||||
|
+ Collectors.toSet())));
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private static boolean testPermission(CommandSender commandSender, String permission)
|
||||||
|
+ {
|
||||||
|
+ if (commandSender.hasPermission(BASE_PERM + permission) || commandSender.hasPermission("bukkit.command.scissors"))
|
||||||
|
+ return true;
|
||||||
|
+ commandSender.sendMessage(Bukkit.getPermissionMessage()); // Sorry, kashike
|
||||||
|
+ return false;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ // Code from Mojang - copyright them
|
||||||
|
+ public static List<String> getListMatchingLast(CommandSender sender, String[] args, String... matches)
|
||||||
|
+ {
|
||||||
|
+ return getListMatchingLast(sender, args, Arrays.asList(matches));
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public static boolean matches(String s, String s1)
|
||||||
|
+ {
|
||||||
|
+ return s1.regionMatches(true, 0, s, 0, s.length());
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public static List<String> getListMatchingLast(CommandSender sender, String[] strings, Collection<?> collection)
|
||||||
|
+ {
|
||||||
|
+ String last = strings[strings.length - 1];
|
||||||
|
+ ArrayList<String> results = Lists.newArrayList();
|
||||||
|
+
|
||||||
|
+ if (!collection.isEmpty())
|
||||||
|
+ {
|
||||||
|
+ Iterator iterator = Iterables.transform(collection, Functions.toStringFunction()).iterator();
|
||||||
|
+
|
||||||
|
+ while (iterator.hasNext())
|
||||||
|
+ {
|
||||||
|
+ String s1 = (String) iterator.next();
|
||||||
|
+
|
||||||
|
+ if (matches(last, s1) && (sender.hasPermission(BASE_PERM + s1) || sender.hasPermission("bukkit.command.scissors")))
|
||||||
|
+ {
|
||||||
|
+ results.add(s1);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (results.isEmpty())
|
||||||
|
+ {
|
||||||
|
+ iterator = collection.iterator();
|
||||||
|
+
|
||||||
|
+ while (iterator.hasNext())
|
||||||
|
+ {
|
||||||
|
+ Object object = iterator.next();
|
||||||
|
+
|
||||||
|
+ if (object instanceof ResourceLocation && matches(last, ((ResourceLocation) object).getPath()))
|
||||||
|
+ {
|
||||||
|
+ results.add(String.valueOf(object));
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ return results;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public List<String> tabComplete(CommandSender sender, String alias, String[] args, Location location) throws IllegalArgumentException
|
||||||
|
+ {
|
||||||
|
+ if (args.length <= 1)
|
||||||
|
+ return getListMatchingLast(sender, args, SUBCOMMANDS);
|
||||||
|
+
|
||||||
|
+ return Collections.emptyList();
|
||||||
|
+ }
|
||||||
|
+ // end copy stuff
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public boolean execute(CommandSender sender, String commandLabel, String[] args)
|
||||||
|
+ {
|
||||||
|
+ if (!testPermission(sender)) return true;
|
||||||
|
+
|
||||||
|
+ if (args.length == 0)
|
||||||
|
+ {
|
||||||
|
+ sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage);
|
||||||
|
+ return false;
|
||||||
|
+ }
|
||||||
|
+ if (SUBCOMMANDS.contains(args[0].toLowerCase(Locale.ENGLISH)))
|
||||||
|
+ {
|
||||||
|
+ if (!testPermission(sender, args[0].toLowerCase(Locale.ENGLISH))) return true;
|
||||||
|
+ }
|
||||||
|
+ switch (args[0].toLowerCase(Locale.ENGLISH))
|
||||||
|
+ {
|
||||||
|
+ case "reload":
|
||||||
|
+ doReload(sender);
|
||||||
|
+ break;
|
||||||
|
+ case "ver":
|
||||||
|
+ if (!testPermission(sender, "version"))
|
||||||
|
+ break; // "ver" needs a special check because it's an alias. All other commands are checked up before the switch statement (because they are present in the SUBCOMMANDS set)
|
||||||
|
+ case "version":
|
||||||
|
+ Command ver = MinecraftServer.getServer().server.getCommandMap().getCommand("version");
|
||||||
|
+ if (ver != null)
|
||||||
|
+ {
|
||||||
|
+ ver.execute(sender, commandLabel, new String[0]);
|
||||||
|
+ break;
|
||||||
|
+ }
|
||||||
|
+ // else - fall through to default
|
||||||
|
+ default:
|
||||||
|
+ sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage);
|
||||||
|
+ return false;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ return true;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private void doReload(CommandSender sender)
|
||||||
|
+ {
|
||||||
|
+ Command.broadcastCommandMessage(sender, ChatColor.RED + "Please note that this command is not supported and may cause issues.");
|
||||||
|
+ Command.broadcastCommandMessage(sender, ChatColor.RED + "If you encounter any issues please use the /stop command to restart your server.");
|
||||||
|
+
|
||||||
|
+ MinecraftServer console = MinecraftServer.getServer();
|
||||||
|
+ ScissorsConfig.init((File) console.options.valueOf("scissors-settings"));
|
||||||
|
+ console.server.reloadCount++;
|
||||||
|
+
|
||||||
|
+ Command.broadcastCommandMessage(sender, ChatColor.GREEN + "Scissors config reload complete.");
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
diff --git a/src/main/java/com/github/atlasmediagroup/scissors/ScissorsConfig.java b/src/main/java/com/github/atlasmediagroup/scissors/ScissorsConfig.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000000000000000000000000000000000000..9612d02814d6ae45d7087c34e0c8549e6c9aecf9
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/com/github/atlasmediagroup/scissors/ScissorsConfig.java
|
||||||
|
@@ -0,0 +1,175 @@
|
||||||
|
+package com.github.atlasmediagroup.scissors;
|
||||||
|
+
|
||||||
|
+import com.google.common.base.Throwables;
|
||||||
|
+import java.io.File;
|
||||||
|
+import java.io.IOException;
|
||||||
|
+import java.lang.reflect.InvocationTargetException;
|
||||||
|
+import java.lang.reflect.Method;
|
||||||
|
+import java.lang.reflect.Modifier;
|
||||||
|
+import java.util.HashMap;
|
||||||
|
+import java.util.List;
|
||||||
|
+import java.util.Map;
|
||||||
|
+import java.util.logging.Level;
|
||||||
|
+import java.util.regex.Pattern;
|
||||||
|
+import net.minecraft.server.MinecraftServer;
|
||||||
|
+import org.bukkit.Bukkit;
|
||||||
|
+import org.bukkit.command.Command;
|
||||||
|
+import org.bukkit.configuration.InvalidConfigurationException;
|
||||||
|
+import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
+
|
||||||
|
+public class ScissorsConfig
|
||||||
|
+{
|
||||||
|
+
|
||||||
|
+ private static final String HEADER = """
|
||||||
|
+ This is the main configuration file for Scissors.
|
||||||
|
+ As you can see, there's tons to configure. Some options may impact gameplay, so use
|
||||||
|
+ with caution, and make sure you know what each option does before configuring.
|
||||||
|
+
|
||||||
|
+ If you need help with the configuration or have any questions related to Scissors,
|
||||||
|
+ join us in our Discord.
|
||||||
|
+
|
||||||
|
+ Discord: https://discord.com/invite/mtVQcHn58h
|
||||||
|
+ Website: https://scissors.gg/\s
|
||||||
|
+ Docs: https://scissors.gg/javadoc/1.18.2/\s
|
||||||
|
+ """;
|
||||||
|
+ private static final Pattern SPACE = Pattern.compile(" ");
|
||||||
|
+ private static final Pattern NOT_NUMERIC = Pattern.compile("[^-\\d.]");
|
||||||
|
+ /*========================================================================*/
|
||||||
|
+ public static YamlConfiguration config;
|
||||||
|
+ static int version;
|
||||||
|
+ /*========================================================================*/
|
||||||
|
+ static Map<String, Command> commands;
|
||||||
|
+ private static File CONFIG_FILE;
|
||||||
|
+
|
||||||
|
+ public static void init(File configFile)
|
||||||
|
+ {
|
||||||
|
+ CONFIG_FILE = configFile;
|
||||||
|
+ config = new YamlConfiguration();
|
||||||
|
+ try
|
||||||
|
+ {
|
||||||
|
+ config.load(CONFIG_FILE);
|
||||||
|
+ }
|
||||||
|
+ catch (IOException ex)
|
||||||
|
+ {
|
||||||
|
+ }
|
||||||
|
+ catch (InvalidConfigurationException ex)
|
||||||
|
+ {
|
||||||
|
+ Bukkit.getLogger().log(Level.SEVERE, "Could not load scissors.yml, please correct your syntax errors", ex);
|
||||||
|
+ throw Throwables.propagate(ex);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ commands = new HashMap<>();
|
||||||
|
+ commands.put("scissors", new ScissorsCommand("scissors"));
|
||||||
|
+
|
||||||
|
+ config.options().header(HEADER);
|
||||||
|
+ config.options().copyDefaults(true);
|
||||||
|
+
|
||||||
|
+ version = getInt("config-version", 1);
|
||||||
|
+ set("config-version", 1);
|
||||||
|
+ readConfig(ScissorsConfig.class, null);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ protected static void logError(String s)
|
||||||
|
+ {
|
||||||
|
+ Bukkit.getLogger().severe(s);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ protected static void fatal(String s)
|
||||||
|
+ {
|
||||||
|
+ throw new RuntimeException("Fatal scissors.yml config error: " + s);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public static void registerCommands()
|
||||||
|
+ {
|
||||||
|
+ for (Map.Entry<String, Command> entry : commands.entrySet())
|
||||||
|
+ {
|
||||||
|
+ MinecraftServer.getServer().server.getCommandMap().register(entry.getKey(), "Scissors", entry.getValue());
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ static void readConfig(Class<?> clazz, Object instance)
|
||||||
|
+ {
|
||||||
|
+ for (Method method : clazz.getDeclaredMethods())
|
||||||
|
+ {
|
||||||
|
+ if (Modifier.isPrivate(method.getModifiers()))
|
||||||
|
+ {
|
||||||
|
+ if (method.getParameterTypes().length == 0 && method.getReturnType() == Void.TYPE)
|
||||||
|
+ {
|
||||||
|
+ try
|
||||||
|
+ {
|
||||||
|
+ method.setAccessible(true);
|
||||||
|
+ method.invoke(instance);
|
||||||
|
+ }
|
||||||
|
+ catch (InvocationTargetException ex)
|
||||||
|
+ {
|
||||||
|
+ throw Throwables.propagate(ex.getCause());
|
||||||
|
+ }
|
||||||
|
+ catch (Exception ex)
|
||||||
|
+ {
|
||||||
|
+ Bukkit.getLogger().log(Level.SEVERE, "Error invoking " + method, ex);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ saveConfig();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ static void saveConfig()
|
||||||
|
+ {
|
||||||
|
+ try
|
||||||
|
+ {
|
||||||
|
+ config.save(CONFIG_FILE);
|
||||||
|
+ }
|
||||||
|
+ catch (IOException ex)
|
||||||
|
+ {
|
||||||
|
+ Bukkit.getLogger().log(Level.SEVERE, "Could not save " + CONFIG_FILE, ex);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public static boolean runCommandsInBooks = false;
|
||||||
|
+
|
||||||
|
+ private static void runCommandsInBooks() {
|
||||||
|
+ runCommandsInBooks = getBoolean("runCommandsInBooks", false);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private static void set(String path, Object val)
|
||||||
|
+ {
|
||||||
|
+ config.set(path, val);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private static boolean getBoolean(String path, boolean def)
|
||||||
|
+ {
|
||||||
|
+ config.addDefault(path, def);
|
||||||
|
+ return config.getBoolean(path, config.getBoolean(path));
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private static double getDouble(String path, double def)
|
||||||
|
+ {
|
||||||
|
+ config.addDefault(path, def);
|
||||||
|
+ return config.getDouble(path, config.getDouble(path));
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private static float getFloat(String path, float def)
|
||||||
|
+ {
|
||||||
|
+ // TODO: Figure out why getFloat() always returns the default value.
|
||||||
|
+ return (float) getDouble(path, def);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private static int getInt(String path, int def)
|
||||||
|
+ {
|
||||||
|
+ config.addDefault(path, def);
|
||||||
|
+ return config.getInt(path, config.getInt(path));
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private static <T> List getList(String path, T def)
|
||||||
|
+ {
|
||||||
|
+ config.addDefault(path, def);
|
||||||
|
+ return config.getList(path, config.getList(path));
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ private static String getString(String path, String def)
|
||||||
|
+ {
|
||||||
|
+ config.addDefault(path, def);
|
||||||
|
+ return config.getString(path, config.getString(path));
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/Main.java b/src/main/java/net/minecraft/server/Main.java
|
||||||
|
index 1e0d261439255091a6f61485c0747231fbd5b1db..63861ff0c0e942dfafad7ceedfa17864c100b301 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/Main.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/Main.java
|
||||||
|
@@ -114,6 +114,7 @@ public class Main {
|
||||||
|
org.bukkit.configuration.file.YamlConfiguration bukkitConfiguration = loadConfigFile((File) optionset.valueOf("bukkit-settings"));
|
||||||
|
org.bukkit.configuration.file.YamlConfiguration spigotConfiguration = loadConfigFile((File) optionset.valueOf("spigot-settings"));
|
||||||
|
org.bukkit.configuration.file.YamlConfiguration paperConfiguration = loadConfigFile((File) optionset.valueOf("paper-settings"));
|
||||||
|
+ org.bukkit.configuration.file.YamlConfiguration scissorsConfiguration = loadConfigFile((File) optionset.valueOf("scissors-settings")); // Scissors
|
||||||
|
// Paper end
|
||||||
|
|
||||||
|
Path path1 = Paths.get("eula.txt");
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||||
|
index 257c94f7c1cb00c9a91ab82e311dfd8eca29c538..605602ca03bd0d974b559881ab0ad4da66640002 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||||
|
@@ -235,7 +235,15 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
||||||
|
io.papermc.paper.util.ObfHelper.INSTANCE.getClass(); // load mappings for stacktrace deobf and etc.
|
||||||
|
io.papermc.paper.brigadier.PaperBrigadierProviderImpl.INSTANCE.getClass(); // init PaperBrigadierProvider
|
||||||
|
// Paper end
|
||||||
|
-
|
||||||
|
+ // Scissors start
|
||||||
|
+ try {
|
||||||
|
+ com.github.atlasmediagroup.scissors.ScissorsConfig.init((java.io.File) options.valueOf("scissors-settings"));
|
||||||
|
+ } catch (Exception e) {
|
||||||
|
+ DedicatedServer.LOGGER.error("Unable to load server configuration", e);
|
||||||
|
+ return false;
|
||||||
|
+ }
|
||||||
|
+ com.github.atlasmediagroup.scissors.ScissorsConfig.registerCommands();
|
||||||
|
+ // Scissors end
|
||||||
|
this.setPvpAllowed(dedicatedserverproperties.pvp);
|
||||||
|
this.setFlightAllowed(dedicatedserverproperties.allowFlight);
|
||||||
|
this.setResourcePack(dedicatedserverproperties.resourcePack, this.getPackHash());
|
||||||
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||||
|
index ebd5aeceb4ac1a6300bbfa70218421f0d91b7614..b17f788c982a5c46e493edd447c07bedfcefd2fd 100644
|
||||||
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||||
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||||
|
@@ -956,6 +956,7 @@ public final class CraftServer implements Server {
|
||||||
|
|
||||||
|
org.spigotmc.SpigotConfig.init((File) console.options.valueOf("spigot-settings")); // Spigot
|
||||||
|
com.destroystokyo.paper.PaperConfig.init((File) console.options.valueOf("paper-settings")); // Paper
|
||||||
|
+ com.github.atlasmediagroup.scissors.ScissorsConfig.init(((File) console.options.valueOf("scissors-settings"))); // Scissors
|
||||||
|
for (ServerLevel world : this.console.getAllLevels()) {
|
||||||
|
// world.serverLevelData.setDifficulty(config.difficulty); // Paper - per level difficulty
|
||||||
|
world.setSpawnSettings(world.serverLevelData.getDifficulty() != Difficulty.PEACEFUL && config.spawnMonsters, config.spawnAnimals); // Paper - per level difficulty (from MinecraftServer#setDifficulty(ServerLevel, Difficulty, boolean))
|
||||||
|
@@ -987,6 +988,7 @@ public final class CraftServer implements Server {
|
||||||
|
this.reloadData();
|
||||||
|
org.spigotmc.SpigotConfig.registerCommands(); // Spigot
|
||||||
|
com.destroystokyo.paper.PaperConfig.registerCommands(); // Paper
|
||||||
|
+ com.github.atlasmediagroup.scissors.ScissorsConfig.registerCommands(); // Scissors
|
||||||
|
this.overrideAllCommandBlockCommands = this.commandsConfiguration.getStringList("command-block-overrides").contains("*");
|
||||||
|
this.ignoreVanillaPermissions = this.commandsConfiguration.getBoolean("ignore-vanilla-permissions");
|
||||||
|
|
||||||
|
@@ -2714,6 +2716,12 @@ public final class CraftServer implements Server {
|
||||||
|
return com.destroystokyo.paper.PaperConfig.config;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ @Override
|
||||||
|
+ public YamlConfiguration getScissorsConfig()
|
||||||
|
+ {
|
||||||
|
+ return com.github.atlasmediagroup.scissors.ScissorsConfig.config;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
@Override
|
||||||
|
public void restart() {
|
||||||
|
org.spigotmc.RestartCommand.restart();
|
||||||
|
diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java
|
||||||
|
index 40313b014b4ed5f7e9505bde2827383c19d4377a..d88a755e18c1da5e5a64ff88d96be33e3dd3dcc3 100644
|
||||||
|
--- a/src/main/java/org/bukkit/craftbukkit/Main.java
|
||||||
|
+++ b/src/main/java/org/bukkit/craftbukkit/Main.java
|
||||||
|
@@ -160,6 +160,14 @@ public class Main {
|
||||||
|
.defaultsTo("Unknown Server")
|
||||||
|
.describedAs("Name");
|
||||||
|
// Paper end
|
||||||
|
+
|
||||||
|
+ // Scissors start
|
||||||
|
+ acceptsAll(asList("scissors", "scissors-settings"), "File for scissors settings")
|
||||||
|
+ .withRequiredArg()
|
||||||
|
+ .ofType(File.class)
|
||||||
|
+ .defaultsTo(new File("scissors.yml"))
|
||||||
|
+ .describedAs("Yml file");
|
||||||
|
+ // Scissors end
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
@@ -1,736 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Allink <arclicious@vivaldi.net>
|
|
||||||
Date: Wed, 15 Mar 2023 23:13:56 -0500
|
|
||||||
Subject: [PATCH] Add Scissors configuration file & command
|
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/co/aikar/timings/TimingsExport.java b/src/main/java/co/aikar/timings/TimingsExport.java
|
|
||||||
index a2f71a6d1a9e98133dff6cd0f625da9435a8af14..f83b2c4298bd1a5f65487f64bd6a11fb190a622d 100644
|
|
||||||
--- a/src/main/java/co/aikar/timings/TimingsExport.java
|
|
||||||
+++ b/src/main/java/co/aikar/timings/TimingsExport.java
|
|
||||||
@@ -25,6 +25,7 @@ package co.aikar.timings;
|
|
||||||
|
|
||||||
import com.google.common.collect.Sets;
|
|
||||||
import io.papermc.paper.adventure.PaperAdventure;
|
|
||||||
+import me.totalfreedom.scissors.ScissorsConfig;
|
|
||||||
import net.kyori.adventure.text.event.ClickEvent;
|
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
|
||||||
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
|
||||||
@@ -242,7 +243,8 @@ public class TimingsExport extends Thread {
|
|
||||||
parent.put("config", createObject(
|
|
||||||
pair("spigot", mapAsJSON(Bukkit.spigot().getSpigotConfig(), null)),
|
|
||||||
pair("bukkit", mapAsJSON(Bukkit.spigot().getBukkitConfig(), null)),
|
|
||||||
- pair("paper", mapAsJSON(Bukkit.spigot().getPaperConfig(), null))
|
|
||||||
+ pair("paper", mapAsJSON(Bukkit.spigot().getPaperConfig(), null)),
|
|
||||||
+ pair("scissors", mapAsJSON(ScissorsConfig.config, null)) // Scissors
|
|
||||||
));
|
|
||||||
|
|
||||||
new TimingsExport(listeners, parent, history).start();
|
|
||||||
diff --git a/src/main/java/me/totalfreedom/scissors/PositionUtility.java b/src/main/java/me/totalfreedom/scissors/PositionUtility.java
|
|
||||||
index c54535042a7ac12fe46b3b37db8d7b116e9469d5..62bb706e6a11749f588b3f0c3ffb1fbd70f15d64 100644
|
|
||||||
--- a/src/main/java/me/totalfreedom/scissors/PositionUtility.java
|
|
||||||
+++ b/src/main/java/me/totalfreedom/scissors/PositionUtility.java
|
|
||||||
@@ -8,7 +8,7 @@ import net.minecraft.world.phys.Vec3;
|
|
||||||
|
|
||||||
public class PositionUtility
|
|
||||||
{
|
|
||||||
- public static Vec3 getValidVec3(double x, double y, double z, Entity entity)
|
|
||||||
+ /*public static Vec3 getValidVec3(double x, double y, double z, Entity entity)
|
|
||||||
{
|
|
||||||
final Level level = entity.level;
|
|
||||||
|
|
||||||
@@ -37,7 +37,7 @@ public class PositionUtility
|
|
||||||
{ // If we throw some sort of exception due to the position being crazy, catch it
|
|
||||||
return new Vec3(0, 0, 0);
|
|
||||||
}
|
|
||||||
- }
|
|
||||||
+ }*/
|
|
||||||
|
|
||||||
public static Vec3 getValidVec3FromBlockPos(BlockPos blockPos, Entity entity)
|
|
||||||
{
|
|
||||||
diff --git a/src/main/java/me/totalfreedom/scissors/ScissorsCommand.java b/src/main/java/me/totalfreedom/scissors/ScissorsCommand.java
|
|
||||||
new file mode 100644
|
|
||||||
index 0000000000000000000000000000000000000000..797677d892d83cf54d9a60af1e277b67ed3d6e95
|
|
||||||
--- /dev/null
|
|
||||||
+++ b/src/main/java/me/totalfreedom/scissors/ScissorsCommand.java
|
|
||||||
@@ -0,0 +1,150 @@
|
|
||||||
+package me.totalfreedom.scissors;
|
|
||||||
+
|
|
||||||
+import com.google.common.base.Functions;
|
|
||||||
+import com.google.common.base.Joiner;
|
|
||||||
+import com.google.common.collect.ImmutableSet;
|
|
||||||
+import com.google.common.collect.Iterables;
|
|
||||||
+import com.google.common.collect.Lists;
|
|
||||||
+import net.minecraft.resources.ResourceLocation;
|
|
||||||
+import net.minecraft.server.MinecraftServer;
|
|
||||||
+import org.bukkit.Bukkit;
|
|
||||||
+import org.bukkit.ChatColor;
|
|
||||||
+import org.bukkit.Location;
|
|
||||||
+import org.bukkit.command.Command;
|
|
||||||
+import org.bukkit.command.CommandSender;
|
|
||||||
+
|
|
||||||
+import java.io.File;
|
|
||||||
+import java.util.*;
|
|
||||||
+import java.util.stream.Collectors;
|
|
||||||
+
|
|
||||||
+public class ScissorsCommand extends Command
|
|
||||||
+{
|
|
||||||
+
|
|
||||||
+ private static final String BASE_PERM = "bukkit.command.scissors.";
|
|
||||||
+ private static final ImmutableSet<String> SUBCOMMANDS = ImmutableSet.<String>builder().add("reload", "version").build();
|
|
||||||
+
|
|
||||||
+ public ScissorsCommand(String name)
|
|
||||||
+ {
|
|
||||||
+ super(name);
|
|
||||||
+ this.description = "Scissors related commands";
|
|
||||||
+ this.usageMessage = "/scissors [" + Joiner.on(" | ").join(SUBCOMMANDS) + "]";
|
|
||||||
+ this.setPermission("bukkit.command.scissors;" + Joiner.on(';').join(SUBCOMMANDS.stream().map(s -> BASE_PERM + s).collect(Collectors.toSet())));
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ private static boolean testPermission(CommandSender commandSender, String permission)
|
|
||||||
+ {
|
|
||||||
+ if (commandSender.hasPermission(BASE_PERM + permission) || commandSender.hasPermission("bukkit.command.scissors"))
|
|
||||||
+ return true;
|
|
||||||
+ commandSender.sendMessage(Bukkit.getPermissionMessage()); // Sorry, kashike
|
|
||||||
+ return false;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ // Code from Mojang - copyright them
|
|
||||||
+ public static List<String> getListMatchingLast(CommandSender sender, String[] args, String... matches)
|
|
||||||
+ {
|
|
||||||
+ return getListMatchingLast(sender, args, Arrays.asList(matches));
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ public static boolean matches(String s, String s1)
|
|
||||||
+ {
|
|
||||||
+ return s1.regionMatches(true, 0, s, 0, s.length());
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ public static List<String> getListMatchingLast(CommandSender sender, String[] strings, Collection<?> collection)
|
|
||||||
+ {
|
|
||||||
+ String last = strings[strings.length - 1];
|
|
||||||
+ ArrayList<String> results = Lists.newArrayList();
|
|
||||||
+
|
|
||||||
+ if (!collection.isEmpty())
|
|
||||||
+ {
|
|
||||||
+ Iterator iterator = Iterables.transform(collection, Functions.toStringFunction()).iterator();
|
|
||||||
+
|
|
||||||
+ while (iterator.hasNext())
|
|
||||||
+ {
|
|
||||||
+ String s1 = (String) iterator.next();
|
|
||||||
+
|
|
||||||
+ if (matches(last, s1) && (sender.hasPermission(BASE_PERM + s1) || sender.hasPermission("bukkit.command.scissors")))
|
|
||||||
+ {
|
|
||||||
+ results.add(s1);
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ if (results.isEmpty())
|
|
||||||
+ {
|
|
||||||
+ iterator = collection.iterator();
|
|
||||||
+
|
|
||||||
+ while (iterator.hasNext())
|
|
||||||
+ {
|
|
||||||
+ Object object = iterator.next();
|
|
||||||
+
|
|
||||||
+ if (object instanceof ResourceLocation && matches(last, ((ResourceLocation) object).getPath()))
|
|
||||||
+ {
|
|
||||||
+ results.add(String.valueOf(object));
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ return results;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ @Override
|
|
||||||
+ public List<String> tabComplete(CommandSender sender, String alias, String[] args, Location location) throws IllegalArgumentException
|
|
||||||
+ {
|
|
||||||
+ if (args.length <= 1)
|
|
||||||
+ return getListMatchingLast(sender, args, SUBCOMMANDS);
|
|
||||||
+
|
|
||||||
+ return Collections.emptyList();
|
|
||||||
+ }
|
|
||||||
+ // end copy stuff
|
|
||||||
+
|
|
||||||
+ @Override
|
|
||||||
+ public boolean execute(CommandSender sender, String commandLabel, String[] args)
|
|
||||||
+ {
|
|
||||||
+ if (!testPermission(sender)) return true;
|
|
||||||
+
|
|
||||||
+ if (args.length == 0)
|
|
||||||
+ {
|
|
||||||
+ sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage);
|
|
||||||
+ return false;
|
|
||||||
+ }
|
|
||||||
+ if (SUBCOMMANDS.contains(args[0].toLowerCase(Locale.ENGLISH)))
|
|
||||||
+ {
|
|
||||||
+ if (!testPermission(sender, args[0].toLowerCase(Locale.ENGLISH))) return true;
|
|
||||||
+ }
|
|
||||||
+ switch (args[0].toLowerCase(Locale.ENGLISH))
|
|
||||||
+ {
|
|
||||||
+ case "reload":
|
|
||||||
+ doReload(sender);
|
|
||||||
+ break;
|
|
||||||
+ case "ver":
|
|
||||||
+ if (!testPermission(sender, "version"))
|
|
||||||
+ break; // "ver" needs a special check because it's an alias. All other commands are checked up before the switch statement (because they are present in the SUBCOMMANDS set)
|
|
||||||
+ case "version":
|
|
||||||
+ Command ver = MinecraftServer.getServer().server.getCommandMap().getCommand("version");
|
|
||||||
+ if (ver != null)
|
|
||||||
+ {
|
|
||||||
+ ver.execute(sender, commandLabel, new String[0]);
|
|
||||||
+ break;
|
|
||||||
+ }
|
|
||||||
+ // else - fall through to default
|
|
||||||
+ default:
|
|
||||||
+ sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage);
|
|
||||||
+ return false;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ return true;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ private void doReload(CommandSender sender)
|
|
||||||
+ {
|
|
||||||
+ Command.broadcastCommandMessage(sender, ChatColor.RED + "Please note that this command is not supported and may cause issues.");
|
|
||||||
+ Command.broadcastCommandMessage(sender, ChatColor.RED + "If you encounter any issues please use the /stop command to restart your server.");
|
|
||||||
+
|
|
||||||
+ MinecraftServer console = MinecraftServer.getServer();
|
|
||||||
+ ScissorsConfig.init((File) console.options.valueOf("scissors-settings"));
|
|
||||||
+ console.server.reloadCount++;
|
|
||||||
+
|
|
||||||
+ Command.broadcastCommandMessage(sender, ChatColor.GREEN + "Scissors config reload complete.");
|
|
||||||
+ }
|
|
||||||
+}
|
|
||||||
diff --git a/src/main/java/me/totalfreedom/scissors/ScissorsConfig.java b/src/main/java/me/totalfreedom/scissors/ScissorsConfig.java
|
|
||||||
new file mode 100644
|
|
||||||
index 0000000000000000000000000000000000000000..8ac0e938ccc83c2e71da419b33556090d5083d9e
|
|
||||||
--- /dev/null
|
|
||||||
+++ b/src/main/java/me/totalfreedom/scissors/ScissorsConfig.java
|
|
||||||
@@ -0,0 +1,213 @@
|
|
||||||
+package me.totalfreedom.scissors;
|
|
||||||
+
|
|
||||||
+
|
|
||||||
+import com.google.common.base.Throwables;
|
|
||||||
+import net.minecraft.server.MinecraftServer;
|
|
||||||
+import net.minecraft.server.dedicated.DedicatedServer;
|
|
||||||
+import org.bukkit.Bukkit;
|
|
||||||
+import org.bukkit.command.Command;
|
|
||||||
+import org.bukkit.configuration.InvalidConfigurationException;
|
|
||||||
+import org.bukkit.configuration.file.YamlConfiguration;
|
|
||||||
+
|
|
||||||
+import java.io.File;
|
|
||||||
+import java.io.IOException;
|
|
||||||
+import java.lang.reflect.InvocationTargetException;
|
|
||||||
+import java.lang.reflect.Method;
|
|
||||||
+import java.lang.reflect.Modifier;
|
|
||||||
+import java.nio.file.Files;
|
|
||||||
+import java.nio.file.Path;
|
|
||||||
+import java.util.HashMap;
|
|
||||||
+import java.util.List;
|
|
||||||
+import java.util.Map;
|
|
||||||
+import java.util.logging.Level;
|
|
||||||
+import java.util.regex.Pattern;
|
|
||||||
+
|
|
||||||
+// TODO - Migrate to new format
|
|
||||||
+public class ScissorsConfig
|
|
||||||
+{
|
|
||||||
+
|
|
||||||
+ private static final String HEADER = """
|
|
||||||
+ This is the main configuration file for Scissors.
|
|
||||||
+ As you can see, there's tons to configure. Some options may impact gameplay, so use
|
|
||||||
+ with caution, and make sure you know what each option does before configuring.
|
|
||||||
+
|
|
||||||
+ If you need help with the configuration or have any questions related to Scissors,
|
|
||||||
+ join us in our Discord.
|
|
||||||
+
|
|
||||||
+ Discord: https://discord.com/invite/mtVQcHn58h
|
|
||||||
+ Website: https://scissors.gg/\s
|
|
||||||
+ Docs: https://javadoc.scissors.gg/1.20/\s
|
|
||||||
+ """;
|
|
||||||
+ private static final Pattern SPACE = Pattern.compile(" ");
|
|
||||||
+ private static final Pattern NOT_NUMERIC = Pattern.compile("[^-\\d.]");
|
|
||||||
+ /*========================================================================*/
|
|
||||||
+ public static YamlConfiguration config;
|
|
||||||
+ static int version;
|
|
||||||
+ /*========================================================================*/
|
|
||||||
+ static Map<String, Command> commands;
|
|
||||||
+ private static File CONFIG_FILE;
|
|
||||||
+
|
|
||||||
+ public static void init(File configFile)
|
|
||||||
+ {
|
|
||||||
+ final File configFolder = (File) DedicatedServer.getServer().options.valueOf("scissors-settings" + "-directory");
|
|
||||||
+ final Path configFolderPath = configFolder.toPath();
|
|
||||||
+ final Path oldConfigFilePath = configFile.toPath();
|
|
||||||
+ final Path newConfigFilePath = configFolderPath.resolve(configFile.toPath());
|
|
||||||
+
|
|
||||||
+ if (configFile.exists())
|
|
||||||
+ {
|
|
||||||
+ try
|
|
||||||
+ {
|
|
||||||
+ Files.move(oldConfigFilePath, newConfigFilePath);
|
|
||||||
+ }
|
|
||||||
+ catch (IOException e)
|
|
||||||
+ {
|
|
||||||
+ throw new RuntimeException("Error migrating configuration file to new directory!", e);
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ CONFIG_FILE = newConfigFilePath.toFile();
|
|
||||||
+ config = new YamlConfiguration();
|
|
||||||
+ try
|
|
||||||
+ {
|
|
||||||
+ config.load(CONFIG_FILE);
|
|
||||||
+ }
|
|
||||||
+ catch (IOException ex)
|
|
||||||
+ {
|
|
||||||
+ }
|
|
||||||
+ catch (InvalidConfigurationException ex)
|
|
||||||
+ {
|
|
||||||
+ Bukkit.getLogger().log(Level.SEVERE, "Could not load scissors.yml, please correct your syntax errors", ex);
|
|
||||||
+ throw Throwables.propagate(ex);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ commands = new HashMap<>();
|
|
||||||
+ commands.put("scissors", new ScissorsCommand("scissors"));
|
|
||||||
+
|
|
||||||
+ config.options().header(HEADER);
|
|
||||||
+ config.options().copyDefaults(true);
|
|
||||||
+
|
|
||||||
+ version = getInt("config-version", 3);
|
|
||||||
+ set("config-version", 3);
|
|
||||||
+ readConfig(ScissorsConfig.class, null);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ protected static void logError(String s)
|
|
||||||
+ {
|
|
||||||
+ Bukkit.getLogger().severe(s);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ protected static void fatal(String s)
|
|
||||||
+ {
|
|
||||||
+ throw new RuntimeException("Fatal scissors.yml config error: " + s);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ public static void registerCommands()
|
|
||||||
+ {
|
|
||||||
+ for (Map.Entry<String, Command> entry : commands.entrySet())
|
|
||||||
+ {
|
|
||||||
+ MinecraftServer.getServer().server.getCommandMap().register(entry.getKey(), "Scissors", entry.getValue());
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ static void readConfig(Class<?> clazz, Object instance)
|
|
||||||
+ {
|
|
||||||
+ for (Method method : clazz.getDeclaredMethods())
|
|
||||||
+ {
|
|
||||||
+ if (Modifier.isPrivate(method.getModifiers()))
|
|
||||||
+ {
|
|
||||||
+ if (method.getParameterTypes().length == 0 && method.getReturnType() == Void.TYPE)
|
|
||||||
+ {
|
|
||||||
+ try
|
|
||||||
+ {
|
|
||||||
+ method.setAccessible(true);
|
|
||||||
+ method.invoke(instance);
|
|
||||||
+ }
|
|
||||||
+ catch (InvocationTargetException ex)
|
|
||||||
+ {
|
|
||||||
+ throw Throwables.propagate(ex.getCause());
|
|
||||||
+ }
|
|
||||||
+ catch (Exception ex)
|
|
||||||
+ {
|
|
||||||
+ Bukkit.getLogger().log(Level.SEVERE, "Error invoking " + method, ex);
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+ saveConfig();
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ static void saveConfig()
|
|
||||||
+ {
|
|
||||||
+ try
|
|
||||||
+ {
|
|
||||||
+ config.save(CONFIG_FILE);
|
|
||||||
+ }
|
|
||||||
+ catch (IOException ex)
|
|
||||||
+ {
|
|
||||||
+ Bukkit.getLogger().log(Level.SEVERE, "Could not save " + CONFIG_FILE, ex);
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ public static boolean runCommandsInBooks = false;
|
|
||||||
+
|
|
||||||
+ private static void runCommandsInBooks()
|
|
||||||
+ {
|
|
||||||
+ runCommandsInBooks = getBoolean("runCommandsInBooks", false);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ // people still may want them to bypass permissions for warps
|
|
||||||
+ public static boolean commandSignsBypassPermissions = false;
|
|
||||||
+ private static void commandSignsBypassPermissions()
|
|
||||||
+ {
|
|
||||||
+ commandSignsBypassPermissions = getBoolean("commandSignsBypassPermissions", false);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ public static boolean chatSignaturesEnabled = true;
|
|
||||||
+ private static void chatSignaturesEnabled()
|
|
||||||
+ {
|
|
||||||
+ chatSignaturesEnabled = getBoolean("chatSignaturesEnabled", true);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ private static void set(String path, Object val)
|
|
||||||
+ {
|
|
||||||
+ config.set(path, val);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ private static boolean getBoolean(String path, boolean def)
|
|
||||||
+ {
|
|
||||||
+ config.addDefault(path, def);
|
|
||||||
+ return config.getBoolean(path, config.getBoolean(path));
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ private static double getDouble(String path, double def)
|
|
||||||
+ {
|
|
||||||
+ config.addDefault(path, def);
|
|
||||||
+ return config.getDouble(path, config.getDouble(path));
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ private static float getFloat(String path, float def)
|
|
||||||
+ {
|
|
||||||
+ // TODO: Figure out why getFloat() always returns the default value.
|
|
||||||
+ return (float) getDouble(path, def);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ private static int getInt(String path, int def)
|
|
||||||
+ {
|
|
||||||
+ config.addDefault(path, def);
|
|
||||||
+ return config.getInt(path, config.getInt(path));
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ private static <T> List getList(String path, T def)
|
|
||||||
+ {
|
|
||||||
+ config.addDefault(path, def);
|
|
||||||
+ return config.getList(path, config.getList(path));
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ private static String getString(String path, String def)
|
|
||||||
+ {
|
|
||||||
+ config.addDefault(path, def);
|
|
||||||
+ return config.getString(path, config.getString(path));
|
|
||||||
+ }
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
diff --git a/src/main/java/net/minecraft/network/chat/OutgoingChatMessage.java b/src/main/java/net/minecraft/network/chat/OutgoingChatMessage.java
|
|
||||||
index 74cf1c043beef03cfd5adf481414a5ee78bef2a6..182f68359a7a8c0b331acd103ed3952ea3c33b93 100644
|
|
||||||
--- a/src/main/java/net/minecraft/network/chat/OutgoingChatMessage.java
|
|
||||||
+++ b/src/main/java/net/minecraft/network/chat/OutgoingChatMessage.java
|
|
||||||
@@ -1,5 +1,6 @@
|
|
||||||
package net.minecraft.network.chat;
|
|
||||||
|
|
||||||
+import me.totalfreedom.scissors.ScissorsConfig;
|
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
|
||||||
|
|
||||||
public interface OutgoingChatMessage {
|
|
||||||
@@ -42,12 +43,16 @@ public interface OutgoingChatMessage {
|
|
||||||
}
|
|
||||||
public void sendToPlayer(ServerPlayer sender, boolean filterMaskEnabled, ChatType.Bound params, @javax.annotation.Nullable Component unsigned) {
|
|
||||||
// Paper end
|
|
||||||
+ // Scissors start - Add configuration option to disable chat signatures
|
|
||||||
PlayerChatMessage playerChatMessage = this.message.filter(filterMaskEnabled);
|
|
||||||
playerChatMessage = unsigned != null ? playerChatMessage.withUnsignedContent(unsigned) : playerChatMessage; // Paper
|
|
||||||
- if (!playerChatMessage.isFullyFiltered()) {
|
|
||||||
+ if (!playerChatMessage.isFullyFiltered() && /* Scissors */ ScissorsConfig.chatSignaturesEnabled) {
|
|
||||||
sender.connection.sendPlayerChatMessage(playerChatMessage, params);
|
|
||||||
+ return;
|
|
||||||
}
|
|
||||||
|
|
||||||
+ sender.connection.sendDisguisedChatMessage(playerChatMessage.decoratedContent(), params);
|
|
||||||
+ // Scissors end
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
diff --git a/src/main/java/net/minecraft/server/Main.java b/src/main/java/net/minecraft/server/Main.java
|
|
||||||
index dae36c6452ccd57a436dd918547b64d59957ab0a..d450cf3cf8ab5cbb5d32a28ee2e4a6717941adef 100644
|
|
||||||
--- a/src/main/java/net/minecraft/server/Main.java
|
|
||||||
+++ b/src/main/java/net/minecraft/server/Main.java
|
|
||||||
@@ -136,6 +136,7 @@ public class Main {
|
|
||||||
// Paper start - load config files for access below if needed
|
|
||||||
org.bukkit.configuration.file.YamlConfiguration bukkitConfiguration = io.papermc.paper.configuration.PaperConfigurations.loadLegacyConfigFile((File) optionset.valueOf("bukkit-settings"));
|
|
||||||
org.bukkit.configuration.file.YamlConfiguration spigotConfiguration = io.papermc.paper.configuration.PaperConfigurations.loadLegacyConfigFile((File) optionset.valueOf("spigot-settings"));
|
|
||||||
+ org.bukkit.configuration.file.YamlConfiguration scissorsConfiguration = io.papermc.paper.configuration.PaperConfigurations.loadLegacyConfigFile((File) optionset.valueOf("scissors-settings")); // Scissors - TODO Change this
|
|
||||||
// Paper end
|
|
||||||
|
|
||||||
if (optionset.has("initSettings")) { // CraftBukkit
|
|
||||||
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
|
||||||
index 9f422cbeaa52b3e6a0a27af4f8ad4ddb7808483f..bbfb536ddec7f44d2a75d35ab495be26104678a1 100644
|
|
||||||
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
|
||||||
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
|
||||||
@@ -222,6 +222,16 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
|
||||||
io.papermc.paper.brigadier.PaperBrigadierProviderImpl.INSTANCE.getClass(); // init PaperBrigadierProvider
|
|
||||||
// Paper end
|
|
||||||
|
|
||||||
+ // Scissors start
|
|
||||||
+ try {
|
|
||||||
+ me.totalfreedom.scissors.ScissorsConfig.init((java.io.File) options.valueOf("scissors-settings"));
|
|
||||||
+ } catch (Exception e) {
|
|
||||||
+ DedicatedServer.LOGGER.error("Unable to load server configuration", e);
|
|
||||||
+ return false;
|
|
||||||
+ }
|
|
||||||
+ me.totalfreedom.scissors.ScissorsConfig.registerCommands();
|
|
||||||
+ // Scissors end
|
|
||||||
+
|
|
||||||
this.setPvpAllowed(dedicatedserverproperties.pvp);
|
|
||||||
this.setFlightAllowed(dedicatedserverproperties.allowFlight);
|
|
||||||
this.setMotd(dedicatedserverproperties.motd);
|
|
||||||
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
||||||
index 4946d476a26e1441cea5904cde7c433da4e60717..182291e66717b7e42a500856e99b599daeeae926 100644
|
|
||||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
||||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
||||||
@@ -1,5 +1,6 @@
|
|
||||||
package net.minecraft.server.network;
|
|
||||||
|
|
||||||
+import me.totalfreedom.scissors.ScissorsConfig;
|
|
||||||
import me.totalfreedom.scissors.event.player.SpectatorTeleportEvent;
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import com.google.common.primitives.Floats;
|
|
||||||
@@ -2375,6 +2376,12 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
|
||||||
Optional<LastSeenMessages> optional = this.lastSeenMessages.applyUpdate(acknowledgment);
|
|
||||||
|
|
||||||
if (optional.isEmpty()) {
|
|
||||||
+ // Scissors start - Add configuration option to disable chat signatures
|
|
||||||
+ if (!ScissorsConfig.chatSignaturesEnabled)
|
|
||||||
+ {
|
|
||||||
+ return optional;
|
|
||||||
+ }
|
|
||||||
+ // Scissors end
|
|
||||||
ServerGamePacketListenerImpl.LOGGER.warn("Failed to validate message acknowledgements from {}", this.player.getName().getString());
|
|
||||||
this.disconnect(ServerGamePacketListenerImpl.CHAT_VALIDATION_FAILED, org.bukkit.event.player.PlayerKickEvent.Cause.CHAT_VALIDATION_FAILED); // Paper - kick event causes
|
|
||||||
}
|
|
||||||
@@ -2607,11 +2614,16 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
|
||||||
@Override
|
|
||||||
public void handleChatAck(ServerboundChatAckPacket packet) {
|
|
||||||
LastSeenMessagesValidator lastseenmessagesvalidator = this.lastSeenMessages;
|
|
||||||
-
|
|
||||||
- synchronized (this.lastSeenMessages) {
|
|
||||||
if (!this.lastSeenMessages.applyOffset(packet.offset())) {
|
|
||||||
- ServerGamePacketListenerImpl.LOGGER.warn("Failed to validate message acknowledgements from {}", this.player.getName().getString());
|
|
||||||
- this.disconnect(ServerGamePacketListenerImpl.CHAT_VALIDATION_FAILED, org.bukkit.event.player.PlayerKickEvent.Cause.CHAT_VALIDATION_FAILED); // Paper - kick event causes
|
|
||||||
+ synchronized (this.lastSeenMessages) {
|
|
||||||
+ // Scissors start - Add configuration option to disable chat signatures
|
|
||||||
+ if (!ScissorsConfig.chatSignaturesEnabled)
|
|
||||||
+ {
|
|
||||||
+ return;
|
|
||||||
+ }
|
|
||||||
+ // Scissors end
|
|
||||||
+ ServerGamePacketListenerImpl.LOGGER.warn("Failed to validate message acknowledgements from {}", this.player.getName().getString());
|
|
||||||
+ this.disconnect(ServerGamePacketListenerImpl.CHAT_VALIDATION_FAILED, org.bukkit.event.player.PlayerKickEvent.Cause.CHAT_VALIDATION_FAILED); // Paper - kick event causes
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/item/WrittenBookItem.java b/src/main/java/net/minecraft/world/item/WrittenBookItem.java
|
|
||||||
index 31911c09fe15753ae32fa39417bdc9e9de552a88..97ce45c6e44b1400b8d60b52397617038f8fe911 100644
|
|
||||||
--- a/src/main/java/net/minecraft/world/item/WrittenBookItem.java
|
|
||||||
+++ b/src/main/java/net/minecraft/world/item/WrittenBookItem.java
|
|
||||||
@@ -2,6 +2,8 @@ package net.minecraft.world.item;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
+
|
|
||||||
+import me.totalfreedom.scissors.ScissorsConfig;
|
|
||||||
import net.minecraft.ChatFormatting;
|
|
||||||
import net.minecraft.commands.CommandSourceStack;
|
|
||||||
import net.minecraft.core.BlockPos;
|
|
||||||
@@ -9,8 +11,7 @@ import net.minecraft.nbt.CompoundTag;
|
|
||||||
import net.minecraft.nbt.ListTag;
|
|
||||||
import net.minecraft.nbt.StringTag;
|
|
||||||
import net.minecraft.nbt.Tag;
|
|
||||||
-import net.minecraft.network.chat.Component;
|
|
||||||
-import net.minecraft.network.chat.ComponentUtils;
|
|
||||||
+import net.minecraft.network.chat.*;
|
|
||||||
import net.minecraft.stats.Stats;
|
|
||||||
import net.minecraft.util.StringUtil;
|
|
||||||
import net.minecraft.world.InteractionHand;
|
|
||||||
@@ -111,8 +112,7 @@ public class WrittenBookItem extends Item {
|
|
||||||
|
|
||||||
public static boolean resolveBookComponents(ItemStack book, @Nullable CommandSourceStack commandSource, @Nullable Player player) {
|
|
||||||
CompoundTag compoundTag = book.getTag();
|
|
||||||
- if (io.papermc.paper.configuration.GlobalConfiguration.get().itemValidation.resolveSelectorsInBooks && compoundTag != null && !compoundTag.getBoolean("resolved")) { // Paper
|
|
||||||
- compoundTag.putBoolean("resolved", true);
|
|
||||||
+ if (compoundTag != null) { // Paper
|
|
||||||
if (!makeSureTagIsValid(compoundTag)) {
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
@@ -161,8 +161,42 @@ public class WrittenBookItem extends Item {
|
|
||||||
component2 = Component.literal(text);
|
|
||||||
}
|
|
||||||
|
|
||||||
- return Component.Serializer.toJson(component2);
|
|
||||||
+ return Component.Serializer.toJson(!ScissorsConfig.runCommandsInBooks ? sanitize(component2, 0) : component2); // Scissors - Allow server owners to disable run command in books
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ // Scissors start - Allow server owners to disable run command in books
|
|
||||||
+ public static Component sanitize(Component component, int depth)
|
|
||||||
+ {
|
|
||||||
+ if (depth > 128)
|
|
||||||
+ {
|
|
||||||
+ return Component.nullToEmpty("Sanitization function depth limit exceeded");
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ MutableComponent component2 = component.copy();
|
|
||||||
+
|
|
||||||
+ final Style style = component2.getStyle();
|
|
||||||
+ final ClickEvent clickEvent = style.getClickEvent();
|
|
||||||
+
|
|
||||||
+ if (clickEvent != null && clickEvent.getAction().equals(ClickEvent.Action.RUN_COMMAND))
|
|
||||||
+ {
|
|
||||||
+ final String clickEventValue = clickEvent.getValue();
|
|
||||||
+
|
|
||||||
+ component2 = component2.copy().setStyle(style
|
|
||||||
+ .withClickEvent(null)
|
|
||||||
+ .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.nullToEmpty("Would've " + (clickEventValue.startsWith("/") ? "ran" : "said") + ": " + clickEvent.getValue())))
|
|
||||||
+ );
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ final List<Component> processedExtra = component2.getSiblings()
|
|
||||||
+ .stream()
|
|
||||||
+ .map(comp -> sanitize(comp, depth + 1))
|
|
||||||
+ .toList();
|
|
||||||
+ component2.getSiblings().clear();
|
|
||||||
+ component2.getSiblings().addAll(processedExtra);
|
|
||||||
+
|
|
||||||
+ return component2;
|
|
||||||
}
|
|
||||||
+ // Scissors end
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isFoil(ItemStack stack) {
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java
|
|
||||||
index ba6f0ba00cd2635bcd19889dca0349b363b079fe..59fe6f9aba094f8e5393de44d8977e5e48ed76d8 100644
|
|
||||||
--- a/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java
|
|
||||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java
|
|
||||||
@@ -8,8 +8,11 @@ import java.util.Objects;
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.function.UnaryOperator;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
+
|
|
||||||
+import me.totalfreedom.scissors.ScissorsConfig;
|
|
||||||
import net.minecraft.commands.CommandSource;
|
|
||||||
import net.minecraft.commands.CommandSourceStack;
|
|
||||||
+import net.minecraft.commands.Commands;
|
|
||||||
import net.minecraft.core.BlockPos;
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
|
||||||
import net.minecraft.nbt.NbtOps;
|
|
||||||
@@ -19,6 +22,7 @@ import net.minecraft.network.chat.Component;
|
|
||||||
import net.minecraft.network.chat.ComponentUtils;
|
|
||||||
import net.minecraft.network.chat.Style;
|
|
||||||
import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket;
|
|
||||||
+import net.minecraft.server.MinecraftServer;
|
|
||||||
import net.minecraft.server.level.ServerLevel;
|
|
||||||
import net.minecraft.server.level.ServerPlayer;
|
|
||||||
import net.minecraft.server.network.FilteredText;
|
|
||||||
@@ -30,13 +34,14 @@ import net.minecraft.world.level.block.SignBlock;
|
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
|
||||||
import net.minecraft.world.phys.Vec2;
|
|
||||||
import net.minecraft.world.phys.Vec3;
|
|
||||||
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.bukkit.block.sign.Side;
|
|
||||||
import org.bukkit.craftbukkit.block.CraftBlock;
|
|
||||||
-import org.bukkit.craftbukkit.util.CraftChatMessage;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.block.SignChangeEvent;
|
|
||||||
// CraftBukkit end
|
|
||||||
+import org.bukkit.craftbukkit.CraftServer;
|
|
||||||
|
|
||||||
public class SignBlockEntity extends BlockEntity implements CommandSource { // CraftBukkit - implements
|
|
||||||
|
|
||||||
@@ -285,6 +290,21 @@ public class SignBlockEntity extends BlockEntity implements CommandSource { // C
|
|
||||||
}
|
|
||||||
player.getServer().getCommands().performPrefixedCommand(this.createCommandSourceStack(((org.bukkit.craftbukkit.entity.CraftPlayer) event.getPlayer()).getHandle(), world, pos), event.getMessage());
|
|
||||||
// Paper end
|
|
||||||
+ // Scissors start - Add optional permissions to command signs
|
|
||||||
+ final MinecraftServer vanillaServer = player.getServer();
|
|
||||||
+ final CraftServer craftServer = vanillaServer.server;
|
|
||||||
+ final CraftHumanEntity craftPlayer = player.getBukkitEntity();
|
|
||||||
+ final Commands commands = vanillaServer.getCommands();
|
|
||||||
+
|
|
||||||
+ if (ScissorsConfig.commandSignsBypassPermissions)
|
|
||||||
+ {
|
|
||||||
+ commands.performPrefixedCommand(this.createCommandSourceStack(((org.bukkit.craftbukkit.entity.CraftPlayer) event.getPlayer()).getHandle(), world, pos), event.getMessage());
|
|
||||||
+ }
|
|
||||||
+ else
|
|
||||||
+ {
|
|
||||||
+ craftServer.dispatchCommand(craftPlayer, command.substring(1));
|
|
||||||
+ }
|
|
||||||
+ // Scissors end
|
|
||||||
flag1 = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
||||||
index 717bd02837ac33180ceca92e2f45a8c2e6ad4694..1d904254eaa1be68ca51a2f43c5058ad48a6c05c 100644
|
|
||||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
||||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
||||||
@@ -978,6 +978,7 @@ public final class CraftServer implements Server {
|
|
||||||
}
|
|
||||||
|
|
||||||
org.spigotmc.SpigotConfig.init((File) console.options.valueOf("spigot-settings")); // Spigot
|
|
||||||
+ me.totalfreedom.scissors.ScissorsConfig.init(((File) console.options.valueOf("scissors-settings"))); // Scissors
|
|
||||||
this.console.paperConfigurations.reloadConfigs(this.console);
|
|
||||||
for (ServerLevel world : this.console.getAllLevels()) {
|
|
||||||
// world.serverLevelData.setDifficulty(config.difficulty); // Paper - per level difficulty
|
|
||||||
@@ -1009,6 +1010,7 @@ public final class CraftServer implements Server {
|
|
||||||
this.reloadData();
|
|
||||||
org.spigotmc.SpigotConfig.registerCommands(); // Spigot
|
|
||||||
io.papermc.paper.command.PaperCommands.registerCommands(this.console); // Paper
|
|
||||||
+ me.totalfreedom.scissors.ScissorsConfig.registerCommands(); // Scissors
|
|
||||||
this.overrideAllCommandBlockCommands = this.commandsConfiguration.getStringList("command-block-overrides").contains("*");
|
|
||||||
this.ignoreVanillaPermissions = this.commandsConfiguration.getBoolean("ignore-vanilla-permissions");
|
|
||||||
|
|
||||||
@@ -2759,6 +2761,12 @@ public final class CraftServer implements Server {
|
|
||||||
return CraftServer.this.console.paperConfigurations.createLegacyObject(CraftServer.this.console);
|
|
||||||
}
|
|
||||||
|
|
||||||
+ @Override
|
|
||||||
+ public YamlConfiguration getScissorsConfig()
|
|
||||||
+ {
|
|
||||||
+ return me.totalfreedom.scissors.ScissorsConfig.config;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
@Override
|
|
||||||
public void restart() {
|
|
||||||
org.spigotmc.RestartCommand.restart();
|
|
||||||
diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java
|
|
||||||
index 0fb3a648ee6bd6cb88515770bcfc70e368313527..5bbfcfe68dace755fe6ec4bc94965d216d998382 100644
|
|
||||||
--- a/src/main/java/org/bukkit/craftbukkit/Main.java
|
|
||||||
+++ b/src/main/java/org/bukkit/craftbukkit/Main.java
|
|
||||||
@@ -180,9 +180,27 @@ public class Main {
|
|
||||||
.defaultsTo("Unknown Server")
|
|
||||||
.describedAs("Name");
|
|
||||||
// Paper end
|
|
||||||
+
|
|
||||||
+ // Scissors start
|
|
||||||
+ acceptsAll(asList("scissors-dir", "scissors-settings-directory"), "Directory for Scissors settings")
|
|
||||||
+ .withRequiredArg()
|
|
||||||
+ .ofType(File.class)
|
|
||||||
+ .defaultsTo(new File(io.papermc.paper.configuration.PaperConfigurations.CONFIG_DIR))
|
|
||||||
+ .describedAs("Config directory");
|
|
||||||
+ // Scissors end
|
|
||||||
+
|
|
||||||
+ // Scissors start
|
|
||||||
+ acceptsAll(asList("scissors", "scissors-settings"), "File for Scissors settings")
|
|
||||||
+ .withRequiredArg()
|
|
||||||
+ .ofType(File.class)
|
|
||||||
+ .defaultsTo(new File("scissors.yml"))
|
|
||||||
+ .describedAs("YAML file");
|
|
||||||
+ // Scissors end
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
+
|
|
||||||
+
|
|
||||||
OptionSet options = null;
|
|
||||||
|
|
||||||
// Paper start - preload logger classes to avoid plugins mixing versions
|
|
@@ -0,0 +1,86 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Allink <arclicious@vivaldi.net>
|
||||||
|
Date: Sun, 10 Jul 2022 10:06:58 +0100
|
||||||
|
Subject: [PATCH] Disable running commands in books by default
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/item/WrittenBookItem.java b/src/main/java/net/minecraft/world/item/WrittenBookItem.java
|
||||||
|
index 26a9a15cc630113cd8d2c8287c6b0f1067ce53f0..15419727d37fc75bc18177cf3ea2daa54f97ec47 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/item/WrittenBookItem.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/item/WrittenBookItem.java
|
||||||
|
@@ -1,7 +1,10 @@
|
||||||
|
package net.minecraft.world.item;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
+import java.util.stream.Collectors;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
+
|
||||||
|
+import com.github.atlasmediagroup.scissors.ScissorsConfig;
|
||||||
|
import net.minecraft.ChatFormatting;
|
||||||
|
import net.minecraft.commands.CommandSourceStack;
|
||||||
|
import net.minecraft.core.BlockPos;
|
||||||
|
@@ -9,10 +12,7 @@ import net.minecraft.nbt.CompoundTag;
|
||||||
|
import net.minecraft.nbt.ListTag;
|
||||||
|
import net.minecraft.nbt.StringTag;
|
||||||
|
import net.minecraft.nbt.Tag;
|
||||||
|
-import net.minecraft.network.chat.Component;
|
||||||
|
-import net.minecraft.network.chat.ComponentUtils;
|
||||||
|
-import net.minecraft.network.chat.TextComponent;
|
||||||
|
-import net.minecraft.network.chat.TranslatableComponent;
|
||||||
|
+import net.minecraft.network.chat.*;
|
||||||
|
import net.minecraft.stats.Stats;
|
||||||
|
import net.minecraft.util.StringUtil;
|
||||||
|
import net.minecraft.world.InteractionHand;
|
||||||
|
@@ -113,8 +113,7 @@ public class WrittenBookItem extends Item {
|
||||||
|
|
||||||
|
public static boolean resolveBookComponents(ItemStack book, @Nullable CommandSourceStack commandSource, @Nullable Player player) {
|
||||||
|
CompoundTag compoundTag = book.getTag();
|
||||||
|
- if (com.destroystokyo.paper.PaperConfig.resolveSelectorsInBooks && compoundTag != null && !compoundTag.getBoolean("resolved")) { // Paper
|
||||||
|
- compoundTag.putBoolean("resolved", true);
|
||||||
|
+ if (compoundTag != null) { // Paper
|
||||||
|
if (!makeSureTagIsValid(compoundTag)) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
@@ -165,8 +164,41 @@ public class WrittenBookItem extends Item {
|
||||||
|
component2 = new TextComponent(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
- return Component.Serializer.toJson(component2);
|
||||||
|
+ return Component.Serializer.toJson(!ScissorsConfig.runCommandsInBooks ? sanitize(component2, 0) : component2); // Scissors - Allow server owners to disable run command in books
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ // Scissors start - Allow server owners to disable run command in books
|
||||||
|
+ public static Component sanitize(Component component, int depth) {
|
||||||
|
+ if (depth > 128) {
|
||||||
|
+ return Component.nullToEmpty("Sanitization function depth limit exceeded");
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ MutableComponent component2 = component.copy();
|
||||||
|
+
|
||||||
|
+ final Style style = component2.getStyle();
|
||||||
|
+ final ClickEvent clickEvent = style.getClickEvent();
|
||||||
|
+
|
||||||
|
+ if(clickEvent != null && clickEvent.getAction().equals(ClickEvent.Action.RUN_COMMAND))
|
||||||
|
+ {
|
||||||
|
+ final String clickEventValue = clickEvent.getValue();
|
||||||
|
+
|
||||||
|
+ component2 = component2.copy().setStyle(style
|
||||||
|
+ .withClickEvent(null)
|
||||||
|
+ .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.nullToEmpty("Would've " + (clickEventValue.startsWith("/") ? "ran": "said") + ": " + clickEvent.getValue())))
|
||||||
|
+ );
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ final List<Component> processedExtra = component2.getSiblings()
|
||||||
|
+ .stream()
|
||||||
|
+ .map(comp -> sanitize(comp, depth + 1))
|
||||||
|
+ .toList();
|
||||||
|
+
|
||||||
|
+ component2.getSiblings().clear();
|
||||||
|
+ component2.getSiblings().addAll(processedExtra);
|
||||||
|
+
|
||||||
|
+ return component2;
|
||||||
|
}
|
||||||
|
+ // Scissors end
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isFoil(ItemStack stack) {
|
@@ -1,32 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Allink <arclicious@vivaldi.net>
|
|
||||||
Date: Mon, 20 Mar 2023 07:04:50 +0000
|
|
||||||
Subject: [PATCH] Patch invalid entity rotation log spam
|
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
|
||||||
index 38c027c0fbddf58136b7d67eb7156403a79de4d1..ff3940a0d552140cae820fbed16bfb5e69507822 100644
|
|
||||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
|
||||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
|
||||||
@@ -4615,7 +4615,9 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
|
||||||
|
|
||||||
public void setYRot(float yaw) {
|
|
||||||
if (!Float.isFinite(yaw)) {
|
|
||||||
- Util.logAndPauseIfInIde("Invalid entity rotation: " + yaw + ", discarding.");
|
|
||||||
+ // Scissors start - Patch invalid entity rotation log spam
|
|
||||||
+ //Util.logAndPauseIfInIde("Invalid entity rotation: " + yaw + ", discarding.");
|
|
||||||
+ // Scissors end
|
|
||||||
} else {
|
|
||||||
this.yRot = yaw;
|
|
||||||
}
|
|
||||||
@@ -4627,7 +4629,9 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
|
||||||
|
|
||||||
public void setXRot(float pitch) {
|
|
||||||
if (!Float.isFinite(pitch)) {
|
|
||||||
- Util.logAndPauseIfInIde("Invalid entity rotation: " + pitch + ", discarding.");
|
|
||||||
+ // Scissors start - Patch invalid entity rotation log spam
|
|
||||||
+ //Util.logAndPauseIfInIde("Invalid entity rotation: " + pitch + ", discarding.");
|
|
||||||
+ // Scissors end
|
|
||||||
} else {
|
|
||||||
this.xRot = pitch;
|
|
||||||
}
|
|
@@ -1,19 +1,19 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
From: Luna <lunahatesgogle@gmail.com>
|
From: Luna <lunahatesgogle@gmail.com>
|
||||||
Date: Mon, 11 Jul 2022 17:29:12 -0300
|
Date: Mon, 11 Jul 2022 17:21:37 -0300
|
||||||
Subject: [PATCH] Validate block entity tag query positions
|
Subject: [PATCH] Validate block entity tag query positions
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||||
index 37fcbdcddaa6cbfd6ae37d70cffab957c90f4e07..01f88bf2f4872884a9c4c2d1d5f1369c61fb0ebf 100644
|
index 65e9791d7e613d039f93184cde717bff8e97000c..2e6e1af5244202e0bc77b443f089b4f3016be8ac 100644
|
||||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||||
@@ -1375,7 +1375,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
@@ -1273,7 +1273,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
||||||
@Override
|
@Override
|
||||||
public void handleBlockEntityTagQuery(ServerboundBlockEntityTagQuery packet) {
|
public void handleBlockEntityTagQuery(ServerboundBlockEntityTagQuery packet) {
|
||||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
|
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel());
|
||||||
- if (this.player.hasPermissions(2)) {
|
- if (this.player.hasPermissions(2)) {
|
||||||
+ if (this.player.hasPermissions(2) && Level.isInSpawnableBounds(packet.getPos())) { // Scissors - Validate block entity tag query positions
|
+ if (this.player.hasPermissions(2) && Level.isInSpawnableBounds(packet.getPos())) { // Scissors - Validate block entity tag query positions
|
||||||
BlockEntity tileentity = this.player.level().getBlockEntity(packet.getPos());
|
BlockEntity tileentity = this.player.getLevel().getBlockEntity(packet.getPos());
|
||||||
CompoundTag nbttagcompound = tileentity != null ? tileentity.saveWithoutMetadata() : null;
|
CompoundTag nbttagcompound = tileentity != null ? tileentity.saveWithoutMetadata() : null;
|
||||||
|
|
@@ -0,0 +1,93 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Allink <arclicious@vivaldi.net>
|
||||||
|
Date: Wed, 13 Jul 2022 11:31:04 +0100
|
||||||
|
Subject: [PATCH] Fix ClickEvents on Signs bypassing permissions
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/com/github/atlasmediagroup/scissors/ScissorsConfig.java b/src/main/java/com/github/atlasmediagroup/scissors/ScissorsConfig.java
|
||||||
|
index 9612d02814d6ae45d7087c34e0c8549e6c9aecf9..ad222b622979716efdb0ea14cbf2cbcb4acf2e74 100644
|
||||||
|
--- a/src/main/java/com/github/atlasmediagroup/scissors/ScissorsConfig.java
|
||||||
|
+++ b/src/main/java/com/github/atlasmediagroup/scissors/ScissorsConfig.java
|
||||||
|
@@ -64,8 +64,8 @@ public class ScissorsConfig
|
||||||
|
config.options().header(HEADER);
|
||||||
|
config.options().copyDefaults(true);
|
||||||
|
|
||||||
|
- version = getInt("config-version", 1);
|
||||||
|
- set("config-version", 1);
|
||||||
|
+ version = getInt("config-version", 2);
|
||||||
|
+ set("config-version", 2);
|
||||||
|
readConfig(ScissorsConfig.class, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -132,6 +132,13 @@ public class ScissorsConfig
|
||||||
|
runCommandsInBooks = getBoolean("runCommandsInBooks", false);
|
||||||
|
}
|
||||||
|
|
||||||
|
+ // people still may want them to bypass permissions for warps
|
||||||
|
+ public static boolean commandSignsBypassPermissions = false;
|
||||||
|
+ public static void commandSignsBypassPermissions()
|
||||||
|
+ {
|
||||||
|
+ commandSignsBypassPermissions = getBoolean("commandSignsBypassPermissions", false);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
private static void set(String path, Object val)
|
||||||
|
{
|
||||||
|
config.set(path, val);
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java
|
||||||
|
index d5bcc81a809e3c733c6fc11309bcf0913860edf6..19e04b0b47c0e185b5e02e8a7c00bab551a0d45e 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java
|
||||||
|
@@ -1,11 +1,13 @@
|
||||||
|
package net.minecraft.world.level.block.entity;
|
||||||
|
|
||||||
|
+import com.github.atlasmediagroup.scissors.ScissorsConfig;
|
||||||
|
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
import net.minecraft.commands.CommandSource;
|
||||||
|
import net.minecraft.commands.CommandSourceStack;
|
||||||
|
+import net.minecraft.commands.Commands;
|
||||||
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.nbt.CompoundTag;
|
||||||
|
import net.minecraft.network.chat.ClickEvent;
|
||||||
|
@@ -15,6 +17,7 @@ import net.minecraft.network.chat.MutableComponent;
|
||||||
|
import net.minecraft.network.chat.Style;
|
||||||
|
import net.minecraft.network.chat.TextComponent;
|
||||||
|
import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket;
|
||||||
|
+import net.minecraft.server.MinecraftServer;
|
||||||
|
import net.minecraft.server.level.ServerLevel;
|
||||||
|
import net.minecraft.server.level.ServerPlayer;
|
||||||
|
import net.minecraft.util.FormattedCharSequence;
|
||||||
|
@@ -23,6 +26,8 @@ import net.minecraft.world.item.DyeColor;
|
||||||
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
import net.minecraft.world.phys.Vec2;
|
||||||
|
import net.minecraft.world.phys.Vec3;
|
||||||
|
+import org.bukkit.craftbukkit.CraftServer;
|
||||||
|
+import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||||
|
|
||||||
|
public class SignBlockEntity extends BlockEntity implements CommandSource { // CraftBukkit - implements
|
||||||
|
private static final boolean CONVERT_LEGACY_SIGNS = Boolean.getBoolean("convertLegacySigns"); // Paper
|
||||||
|
@@ -236,7 +241,21 @@ public class SignBlockEntity extends BlockEntity implements CommandSource { // C
|
||||||
|
if (!event.callEvent()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
- player.getServer().getCommands().performCommand(this.createCommandSourceStack(((org.bukkit.craftbukkit.entity.CraftPlayer) event.getPlayer()).getHandle()), event.getMessage());
|
||||||
|
+
|
||||||
|
+ // Scissors start - Add optional permissions to command signs
|
||||||
|
+ final MinecraftServer vanillaServer = player.getServer();
|
||||||
|
+ final CraftServer craftServer = vanillaServer.server;
|
||||||
|
+ final CraftPlayer craftPlayer = player.getBukkitEntity();
|
||||||
|
+ final Commands commands = vanillaServer.getCommands();
|
||||||
|
+
|
||||||
|
+ if (ScissorsConfig.commandSignsBypassPermissions)
|
||||||
|
+ {
|
||||||
|
+ commands.performCommand(this.createCommandSourceStack(((org.bukkit.craftbukkit.entity.CraftPlayer) event.getPlayer()).getHandle()), event.getMessage());
|
||||||
|
+ } else
|
||||||
|
+ {
|
||||||
|
+ craftServer.dispatchCommand(craftPlayer, command.substring(1));
|
||||||
|
+ }
|
||||||
|
+ // Scissors end
|
||||||
|
// Paper end
|
||||||
|
}
|
||||||
|
}
|
@@ -1,61 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Luna <lunahatesgogle@gmail.com>
|
|
||||||
Date: Sun, 2 Apr 2023 16:29:51 -0300
|
|
||||||
Subject: [PATCH] Patch large selector distance crash
|
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/advancements/critereon/MinMaxBounds.java b/src/main/java/net/minecraft/advancements/critereon/MinMaxBounds.java
|
|
||||||
index 60d32afe2eecdfebdc91531ca3672f8f130ac30e..73b0f516f80ef810379860ea74697a3429c646e5 100644
|
|
||||||
--- a/src/main/java/net/minecraft/advancements/critereon/MinMaxBounds.java
|
|
||||||
+++ b/src/main/java/net/minecraft/advancements/critereon/MinMaxBounds.java
|
|
||||||
@@ -177,7 +177,7 @@ public abstract class MinMaxBounds<T extends Number> {
|
|
||||||
return value == null ? null : value * value;
|
|
||||||
}
|
|
||||||
|
|
||||||
- private Doubles(@Nullable Double min, @Nullable Double max) {
|
|
||||||
+ public Doubles(@Nullable Double min, @Nullable Double max) { // Scissors - private -> public
|
|
||||||
super(min, max);
|
|
||||||
this.minSq = squareOpt(min);
|
|
||||||
this.maxSq = squareOpt(max);
|
|
||||||
diff --git a/src/main/java/net/minecraft/commands/arguments/selector/EntitySelector.java b/src/main/java/net/minecraft/commands/arguments/selector/EntitySelector.java
|
|
||||||
index f25b9330e068c7d9e12cb57a7761cfef9ebaf7bc..ba549e6e5da75413ae3b4083f8b7a5527672de4e 100644
|
|
||||||
--- a/src/main/java/net/minecraft/commands/arguments/selector/EntitySelector.java
|
|
||||||
+++ b/src/main/java/net/minecraft/commands/arguments/selector/EntitySelector.java
|
|
||||||
@@ -10,6 +10,7 @@ import java.util.function.BiConsumer;
|
|
||||||
import java.util.function.Function;
|
|
||||||
import java.util.function.Predicate;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
+import me.totalfreedom.scissors.MathUtility;
|
|
||||||
import net.minecraft.advancements.critereon.MinMaxBounds;
|
|
||||||
import net.minecraft.commands.CommandSourceStack;
|
|
||||||
import net.minecraft.commands.arguments.EntityArgument;
|
|
||||||
@@ -60,9 +61,27 @@ public class EntitySelector {
|
|
||||||
this.includesEntities = includesNonPlayers;
|
|
||||||
this.worldLimited = localWorldOnly;
|
|
||||||
this.predicate = basePredicate;
|
|
||||||
- this.range = distance;
|
|
||||||
+
|
|
||||||
+ // Scissors start - Patch large selector distance crash
|
|
||||||
+ this.range = new MinMaxBounds.Doubles(
|
|
||||||
+ distance.getMin() != null ? Math.min(distance.getMin(), 1024) : null,
|
|
||||||
+ distance.getMax() != null ? Math.min(distance.getMax(), 1024) : null
|
|
||||||
+ );
|
|
||||||
this.position = positionOffset;
|
|
||||||
- this.aabb = box;
|
|
||||||
+ if (box != null) {
|
|
||||||
+ this.aabb = new AABB(
|
|
||||||
+ MathUtility.clampDouble(box.minX, -1024, 1025),
|
|
||||||
+ MathUtility.clampDouble(box.minY, -1024, 1025),
|
|
||||||
+ MathUtility.clampDouble(box.minZ, -1024, 1025),
|
|
||||||
+ MathUtility.clampDouble(box.maxX, -1024, 1025),
|
|
||||||
+ MathUtility.clampDouble(box.maxY, -1024, 1025),
|
|
||||||
+ MathUtility.clampDouble(box.maxZ, -1024, 1025),
|
|
||||||
+ false
|
|
||||||
+ );
|
|
||||||
+ } else {
|
|
||||||
+ this.aabb = null;
|
|
||||||
+ }
|
|
||||||
+ // Scissors end
|
|
||||||
this.order = sorter;
|
|
||||||
this.currentEntity = senderOnly;
|
|
||||||
this.playerName = playerName;
|
|
@@ -1,24 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Luna <lunahatesgogle@gmail.com>
|
|
||||||
Date: Mon, 10 Apr 2023 13:56:18 -0300
|
|
||||||
Subject: [PATCH] Limit sculk catalyst cursor positions
|
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/level/block/SculkSpreader.java b/src/main/java/net/minecraft/world/level/block/SculkSpreader.java
|
|
||||||
index ab732f0e52ef3c3d3be6ddc827d693fe294e4167..761c8cfb98e05a3c500599520e26e4323725fc85 100644
|
|
||||||
--- a/src/main/java/net/minecraft/world/level/block/SculkSpreader.java
|
|
||||||
+++ b/src/main/java/net/minecraft/world/level/block/SculkSpreader.java
|
|
||||||
@@ -141,6 +141,13 @@ public class SculkSpreader {
|
|
||||||
Object2IntMap<BlockPos> object2IntMap = new Object2IntOpenHashMap<>();
|
|
||||||
|
|
||||||
for(SculkSpreader.ChargeCursor chargeCursor : this.cursors) {
|
|
||||||
+ // Scissors start
|
|
||||||
+ if (!world.getMinecraftWorld().isLoadedAndInBounds(chargeCursor.getPos()))
|
|
||||||
+ {
|
|
||||||
+ continue;
|
|
||||||
+ }
|
|
||||||
+ // Scissors end
|
|
||||||
+
|
|
||||||
chargeCursor.update(world, pos, random, this, shouldConvertToBlock);
|
|
||||||
if (chargeCursor.charge <= 0) {
|
|
||||||
world.levelEvent(3006, chargeCursor.getPos(), 0);
|
|
@@ -1,35 +1,20 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
From: Allink <arclicious@vivaldi.net>
|
From: Allink <arclicious@vivaldi.net>
|
||||||
Date: Tue, 16 Aug 2022 17:13:02 +0100
|
Date: Tue, 16 Aug 2022 17:25:37 +0100
|
||||||
Subject: [PATCH] Refuse to convert legacy messages over 1k characters
|
Subject: [PATCH] Refuse to convert legacy messages over 1k characters
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java b/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java
|
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java b/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java
|
||||||
index 0f70be614f8f5350ad558d0ae645cdf0027e1e76..6f036df37609daf33db3884174406e1ccd339735 100644
|
index 26d43c229caf9f8504af7071c3a61ec6da7e27ec..ecceb3fc7f822d826b4a789fe72a8cd08e90d60e 100644
|
||||||
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java
|
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java
|
||||||
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java
|
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java
|
||||||
@@ -3,12 +3,14 @@ package org.bukkit.craftbukkit.util;
|
@@ -198,6 +198,11 @@ public final class CraftChatMessage {
|
||||||
import com.google.common.collect.ImmutableMap;
|
|
||||||
import com.google.common.collect.ImmutableMap.Builder;
|
|
||||||
import com.google.gson.JsonParseException;
|
|
||||||
+
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
+
|
|
||||||
import net.minecraft.ChatFormatting;
|
|
||||||
import net.minecraft.network.chat.ClickEvent;
|
|
||||||
import net.minecraft.network.chat.ClickEvent.Action;
|
|
||||||
@@ -199,6 +201,11 @@ public final class CraftChatMessage {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Component[] fromString(String message, boolean keepNewlines, boolean plain) {
|
public static Component[] fromString(String message, boolean keepNewlines, boolean plain) {
|
||||||
+ // Scissors start - Refuse to convert legacy messages over 1k characters
|
+ // Scissors start - Refuse to convert legacy messages over 1k characters
|
||||||
+ if (message.length() > 1_000) {
|
+ if (message.length() > 1_000) {
|
||||||
+ return new Component[]{Component.empty()};
|
+ return new Component[]{TextComponent.EMPTY};
|
||||||
+ }
|
+ }
|
||||||
+ // Scissors end
|
+ // Scissors end
|
||||||
return new StringMessage(message, keepNewlines, plain).getOutput();
|
return new StringMessage(message, keepNewlines, plain).getOutput();
|
@@ -0,0 +1,38 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Allink <arclicious@vivaldi.net>
|
||||||
|
Date: Sat, 20 Aug 2022 03:01:56 +0100
|
||||||
|
Subject: [PATCH] Fix exploit where paintings are able to spawn out of bounds
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/com/github/atlasmediagroup/scissors/ScissorsConfig.java b/src/main/java/com/github/atlasmediagroup/scissors/ScissorsConfig.java
|
||||||
|
index ad222b622979716efdb0ea14cbf2cbcb4acf2e74..33b97f0738fbc4a54a174e9419275770e4513ca0 100644
|
||||||
|
--- a/src/main/java/com/github/atlasmediagroup/scissors/ScissorsConfig.java
|
||||||
|
+++ b/src/main/java/com/github/atlasmediagroup/scissors/ScissorsConfig.java
|
||||||
|
@@ -30,7 +30,7 @@ public class ScissorsConfig
|
||||||
|
|
||||||
|
Discord: https://discord.com/invite/mtVQcHn58h
|
||||||
|
Website: https://scissors.gg/\s
|
||||||
|
- Docs: https://scissors.gg/javadoc/1.18.2/\s
|
||||||
|
+ Docs: https://javadoc.scissors.gg/1.18.2/\s
|
||||||
|
""";
|
||||||
|
private static final Pattern SPACE = Pattern.compile(" ");
|
||||||
|
private static final Pattern NOT_NUMERIC = Pattern.compile("[^-\\d.]");
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/entity/decoration/HangingEntity.java b/src/main/java/net/minecraft/world/entity/decoration/HangingEntity.java
|
||||||
|
index 2805ebfe4ffe769bcde778a1225b3101c91538d8..3c4bfad55e438c5e723ef58c9cc24908af9e0846 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/entity/decoration/HangingEntity.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/entity/decoration/HangingEntity.java
|
||||||
|
@@ -265,7 +265,13 @@ public abstract class HangingEntity extends Entity {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void readAdditionalSaveData(CompoundTag nbt) {
|
||||||
|
- this.pos = new BlockPos(nbt.getInt("TileX"), nbt.getInt("TileY"), nbt.getInt("TileZ"));
|
||||||
|
+ // Scissors start - Fix exploit where paintings are able to spawn out of bounds
|
||||||
|
+ final BlockPos pos = new BlockPos(nbt.getInt("TileX"), nbt.getInt("TileY"), nbt.getInt("TileZ"));
|
||||||
|
+ if (this.level.isLoadedAndInBounds(pos))
|
||||||
|
+ {
|
||||||
|
+ this.pos = pos;
|
||||||
|
+ }
|
||||||
|
+ // Scissors end
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract int getWidth();
|
@@ -1,31 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Luna <lunahatesgogle@gmail.com>
|
|
||||||
Date: Fri, 28 Apr 2023 16:29:23 -0300
|
|
||||||
Subject: [PATCH] Limit map decoration text length
|
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/level/saveddata/maps/MapDecoration.java b/src/main/java/net/minecraft/world/level/saveddata/maps/MapDecoration.java
|
|
||||||
index 347d2914f9560a3ee8cea59444bc0dfbb7cf3456..b225f770869832775c9a8a79ffaf89e98245cc2e 100644
|
|
||||||
--- a/src/main/java/net/minecraft/world/level/saveddata/maps/MapDecoration.java
|
|
||||||
+++ b/src/main/java/net/minecraft/world/level/saveddata/maps/MapDecoration.java
|
|
||||||
@@ -2,6 +2,7 @@ package net.minecraft.world.level.saveddata.maps;
|
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
+import net.minecraft.ChatFormatting;
|
|
||||||
import net.minecraft.network.chat.Component;
|
|
||||||
import net.minecraft.util.Mth;
|
|
||||||
|
|
||||||
@@ -14,6 +15,12 @@ public class MapDecoration {
|
|
||||||
private final Component name;
|
|
||||||
|
|
||||||
public MapDecoration(MapDecoration.Type type, byte x, byte z, byte rotation, @Nullable Component text) {
|
|
||||||
+ // Scissors start - Limit decoration text length
|
|
||||||
+ if (text != null && text.getString().length() > 32) {
|
|
||||||
+ text = null;
|
|
||||||
+ }
|
|
||||||
+ // Scissors end
|
|
||||||
+
|
|
||||||
this.type = type;
|
|
||||||
this.x = x;
|
|
||||||
this.y = z;
|
|
@@ -1,23 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Luna <lunahatesgogle@gmail.com>
|
|
||||||
Date: Fri, 28 Apr 2023 16:34:15 -0300
|
|
||||||
Subject: [PATCH] Limit map decoration count
|
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java b/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java
|
|
||||||
index 3b12030b49b1c539684d75ca3896eb498400ef99..a1f042e5329343489cf30e436a8f553d39e5a6e4 100644
|
|
||||||
--- a/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java
|
|
||||||
+++ b/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java
|
|
||||||
@@ -354,6 +354,12 @@ public class MapItemSavedData extends SavedData {
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addDecoration(MapDecoration.Type type, @Nullable LevelAccessor world, String key, double x, double z, double rotation, @Nullable Component text) {
|
|
||||||
+ // Scissors start - Limit decoration count
|
|
||||||
+ if (this.decorations.size() > 32) {
|
|
||||||
+ return;
|
|
||||||
+ }
|
|
||||||
+ // Scissors end
|
|
||||||
+
|
|
||||||
int i = 1 << this.scale;
|
|
||||||
float f = (float) (x - (double) this.centerX) / (float) i;
|
|
||||||
float f1 = (float) (z - (double) this.centerZ) / (float) i;
|
|
@@ -1,21 +1,14 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
From: Allink <arclicious@vivaldi.net>
|
From: Allink <arclicious@vivaldi.net>
|
||||||
Date: Sun, 27 Nov 2022 05:14:18 +0000
|
Date: Sun, 27 Nov 2022 04:56:24 +0000
|
||||||
Subject: [PATCH] Prevent velocity freeze
|
Subject: [PATCH] Prevent velocity freeze
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java b/src/main/java/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java
|
diff --git a/src/main/java/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java b/src/main/java/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java
|
||||||
index 2096e8a0bdbcfc865f175f3a01ab688542481531..15d375221c253dc4ca1b598eb80b4638eba6f8d0 100644
|
index fa4e930388baa2ee0a752873b2ec1a67cc020de6..8ba2433de1e079e2227b97a5a7b5f06a6f34984f 100644
|
||||||
--- a/src/main/java/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java
|
--- a/src/main/java/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java
|
||||||
+++ b/src/main/java/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java
|
+++ b/src/main/java/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java
|
||||||
@@ -1,5 +1,6 @@
|
@@ -41,9 +41,13 @@ public abstract class AbstractHurtingProjectile extends Projectile {
|
||||||
package net.minecraft.world.entity.projectile;
|
|
||||||
|
|
||||||
+import me.totalfreedom.scissors.MathUtility;
|
|
||||||
import net.minecraft.core.particles.ParticleOptions;
|
|
||||||
import net.minecraft.core.particles.ParticleTypes;
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
|
||||||
@@ -41,9 +42,13 @@ public abstract class AbstractHurtingProjectile extends Projectile {
|
|
||||||
double d6 = Math.sqrt(d3 * d3 + d4 * d4 + d5 * d5);
|
double d6 = Math.sqrt(d3 * d3 + d4 * d4 + d5 * d5);
|
||||||
|
|
||||||
if (d6 != 0.0D) {
|
if (d6 != 0.0D) {
|
||||||
@@ -32,7 +25,7 @@ index 2096e8a0bdbcfc865f175f3a01ab688542481531..15d375221c253dc4ca1b598eb80b4638
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -141,6 +146,25 @@ public abstract class AbstractHurtingProjectile extends Projectile {
|
@@ -150,6 +154,25 @@ public abstract class AbstractHurtingProjectile extends Projectile {
|
||||||
nbt.put("power", this.newDoubleList(new double[]{this.xPower, this.yPower, this.zPower}));
|
nbt.put("power", this.newDoubleList(new double[]{this.xPower, this.yPower, this.zPower}));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,16 +42,16 @@ index 2096e8a0bdbcfc865f175f3a01ab688542481531..15d375221c253dc4ca1b598eb80b4638
|
|||||||
+ return;
|
+ return;
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ this.xPower = MathUtility.clampDouble(xPower, -1024, 1024);
|
+ this.xPower = xPower;
|
||||||
+ this.yPower = MathUtility.clampDouble(yPower, -1024, 1024);
|
+ this.yPower = yPower;
|
||||||
+ this.zPower = MathUtility.clampDouble(zPower, -1024, 1024);
|
+ this.zPower = zPower;
|
||||||
+ }
|
+ }
|
||||||
+ // Scissors end
|
+ // Scissors end
|
||||||
+
|
+
|
||||||
@Override
|
@Override
|
||||||
public void readAdditionalSaveData(CompoundTag nbt) {
|
public void readAdditionalSaveData(CompoundTag nbt) {
|
||||||
super.readAdditionalSaveData(nbt);
|
super.readAdditionalSaveData(nbt);
|
||||||
@@ -148,9 +172,13 @@ public abstract class AbstractHurtingProjectile extends Projectile {
|
@@ -157,9 +180,13 @@ public abstract class AbstractHurtingProjectile extends Projectile {
|
||||||
ListTag nbttaglist = nbt.getList("power", 6);
|
ListTag nbttaglist = nbt.getList("power", 6);
|
||||||
|
|
||||||
if (nbttaglist.size() == 3) {
|
if (nbttaglist.size() == 3) {
|
||||||
@@ -75,7 +68,7 @@ index 2096e8a0bdbcfc865f175f3a01ab688542481531..15d375221c253dc4ca1b598eb80b4638
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -184,9 +212,12 @@ public abstract class AbstractHurtingProjectile extends Projectile {
|
@@ -193,9 +220,12 @@ public abstract class AbstractHurtingProjectile extends Projectile {
|
||||||
Vec3 vec3d = entity.getLookAngle();
|
Vec3 vec3d = entity.getLookAngle();
|
||||||
|
|
||||||
this.setDeltaMovement(vec3d);
|
this.setDeltaMovement(vec3d);
|
@@ -1,45 +1,36 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
From: Allink <arclicious@vivaldi.net>
|
From: Telesphoreo <me@telesphoreo.me>
|
||||||
Date: Fri, 2 Jun 2023 20:55:18 +0100
|
Date: Sun, 11 Jun 2023 00:00:20 -0500
|
||||||
Subject: [PATCH] Implement command block events
|
Subject: [PATCH] Implement command block events
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||||
index a2b96f7b1e98586017dbbf28a73446196738ee99..0227e2c7197c3684677f76ff7f0fe0acc21b6c14 100644
|
index 2e6e1af5244202e0bc77b443f089b4f3016be8ac..f1f17e33cddf23fffae96d60bfd92934b6ab3c5a 100644
|
||||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||||
@@ -1,6 +1,8 @@
|
@@ -25,6 +25,8 @@ import java.util.stream.Collectors;
|
||||||
package net.minecraft.server.network;
|
import java.util.stream.Stream;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import me.totalfreedom.scissors.ScissorsConfig;
|
|
||||||
+import me.totalfreedom.scissors.event.block.CommandBlockPlayerEditEvent;
|
+import me.totalfreedom.scissors.event.block.CommandBlockPlayerEditEvent;
|
||||||
+import me.totalfreedom.scissors.event.block.CommandMinecartPlayerEditEvent;
|
+import me.totalfreedom.scissors.event.block.CommandMinecartPlayerEditEvent;
|
||||||
import me.totalfreedom.scissors.event.player.SpectatorTeleportEvent;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import com.google.common.collect.Lists;
|
import net.minecraft.ChatFormatting;
|
||||||
import com.google.common.primitives.Floats;
|
import net.minecraft.CrashReport;
|
||||||
@@ -160,6 +162,7 @@ import net.minecraft.world.entity.player.Inventory;
|
@@ -156,6 +158,7 @@ import net.minecraft.world.phys.shapes.BooleanOp;
|
||||||
import net.minecraft.world.entity.player.ProfilePublicKey;
|
|
||||||
import net.minecraft.world.entity.projectile.AbstractArrow;
|
|
||||||
import net.minecraft.world.entity.vehicle.Boat;
|
|
||||||
+import net.minecraft.world.entity.vehicle.MinecartCommandBlock;
|
|
||||||
import net.minecraft.world.item.BlockItem;
|
|
||||||
import net.minecraft.world.item.BucketItem;
|
|
||||||
import net.minecraft.world.item.Item;
|
|
||||||
@@ -188,6 +191,7 @@ import net.minecraft.world.phys.Vec3;
|
|
||||||
import net.minecraft.world.phys.shapes.BooleanOp;
|
|
||||||
import net.minecraft.world.phys.shapes.Shapes;
|
import net.minecraft.world.phys.shapes.Shapes;
|
||||||
import net.minecraft.world.phys.shapes.VoxelShape;
|
import net.minecraft.world.phys.shapes.VoxelShape;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
+import org.bukkit.entity.minecart.CommandMinecart;
|
+import org.bukkit.entity.minecart.CommandMinecart;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
// CraftBukkit start
|
// CraftBukkit start
|
||||||
@@ -1001,6 +1005,21 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
@@ -916,6 +919,19 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
||||||
this.player.level().getChunkAt(blockposition).setBlockEntity(tileentity);
|
this.player.level.getChunkAt(blockposition).setBlockEntity(tileentity);
|
||||||
}
|
}
|
||||||
|
|
||||||
+ // Scissors start - Implement command block events
|
+ // Scissors start - Implement command block events
|
||||||
+ if (commandblocklistenerabstract instanceof org.bukkit.block.CommandBlock commandBlock)
|
+ if (commandblocklistenerabstract instanceof org.bukkit.block.CommandBlock commandBlock) {
|
||||||
+ {
|
|
||||||
+ CommandBlockPlayerEditEvent event = new CommandBlockPlayerEditEvent(this.getCraftPlayer(), Objects.requireNonNullElse(commandblocklistenerabstract.getCommand(), ""), s, commandBlock);
|
+ CommandBlockPlayerEditEvent event = new CommandBlockPlayerEditEvent(this.getCraftPlayer(), Objects.requireNonNullElse(commandblocklistenerabstract.getCommand(), ""), s, commandBlock);
|
||||||
+ event.callEvent();
|
+ event.callEvent();
|
||||||
+
|
+
|
||||||
@@ -49,22 +40,20 @@ index a2b96f7b1e98586017dbbf28a73446196738ee99..0227e2c7197c3684677f76ff7f0fe0ac
|
|||||||
+
|
+
|
||||||
+ s = event.getNewCommand();
|
+ s = event.getNewCommand();
|
||||||
+ }
|
+ }
|
||||||
+
|
|
||||||
+ // Scissors end
|
+ // Scissors end
|
||||||
+
|
+
|
||||||
commandblocklistenerabstract.setCommand(s);
|
commandblocklistenerabstract.setCommand(s);
|
||||||
commandblocklistenerabstract.setTrackOutput(flag);
|
commandblocklistenerabstract.setTrackOutput(flag);
|
||||||
if (!flag) {
|
if (!flag) {
|
||||||
@@ -1032,7 +1051,27 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
@@ -947,7 +963,25 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
||||||
BaseCommandBlock commandblocklistenerabstract = packet.getCommandBlock(this.player.level());
|
BaseCommandBlock commandblocklistenerabstract = packet.getCommandBlock(this.player.level);
|
||||||
|
|
||||||
if (commandblocklistenerabstract != null) {
|
if (commandblocklistenerabstract != null) {
|
||||||
- commandblocklistenerabstract.setCommand(packet.getCommand());
|
- commandblocklistenerabstract.setCommand(packet.getCommand());
|
||||||
+ // Scissors start - Implement command block events
|
+ // Scissors start - Implement command block events
|
||||||
+ String command = packet.getCommand();
|
+ String command = packet.getCommand();
|
||||||
+
|
+
|
||||||
+ if (commandblocklistenerabstract instanceof CommandMinecart commandMinecart)
|
+ if (commandblocklistenerabstract instanceof CommandMinecart commandMinecart) {
|
||||||
+ {
|
|
||||||
+ CommandMinecartPlayerEditEvent event = new CommandMinecartPlayerEditEvent(this.getCraftPlayer(), Objects.requireNonNullElse(commandblocklistenerabstract.getCommand(), ""), command, commandMinecart);
|
+ CommandMinecartPlayerEditEvent event = new CommandMinecartPlayerEditEvent(this.getCraftPlayer(), Objects.requireNonNullElse(commandblocklistenerabstract.getCommand(), ""), command, commandMinecart);
|
||||||
+ event.callEvent();
|
+ event.callEvent();
|
||||||
+
|
+
|
||||||
@@ -80,7 +69,6 @@ index a2b96f7b1e98586017dbbf28a73446196738ee99..0227e2c7197c3684677f76ff7f0fe0ac
|
|||||||
+ // commandblocklistenerabstract.setCommand(packet.getCommand());
|
+ // commandblocklistenerabstract.setCommand(packet.getCommand());
|
||||||
+
|
+
|
||||||
+ // Scissors end
|
+ // Scissors end
|
||||||
+
|
|
||||||
commandblocklistenerabstract.setTrackOutput(packet.isTrackOutput());
|
commandblocklistenerabstract.setTrackOutput(packet.isTrackOutput());
|
||||||
if (!packet.isTrackOutput()) {
|
if (!packet.isTrackOutput()) {
|
||||||
commandblocklistenerabstract.setLastOutput((Component) null);
|
commandblocklistenerabstract.setLastOutput((Component) null);
|
@@ -1,26 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Luna <lunahatesgogle@gmail.com>
|
|
||||||
Date: Fri, 28 Apr 2023 16:44:50 -0300
|
|
||||||
Subject: [PATCH] Prevent player banning using duplicate UUIDs
|
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
||||||
index 2ac23779222369ace69f1e3f7fb12184865b7a43..05c8e4e30b2dce565e84f4c09b3f27244f8c0451 100644
|
|
||||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
||||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
||||||
@@ -1610,7 +1610,14 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
|
||||||
if (entity != null) {
|
|
||||||
ServerLevel.LOGGER.warn("Force-added player with duplicate UUID {}", player.getUUID().toString());
|
|
||||||
entity.unRide();
|
|
||||||
- this.removePlayerImmediately((ServerPlayer) entity, Entity.RemovalReason.DISCARDED);
|
|
||||||
+
|
|
||||||
+ // Scissors start - Prevent player banning using duplicate UUIDs
|
|
||||||
+ if (entity instanceof ServerPlayer serverPlayer) {
|
|
||||||
+ this.removePlayerImmediately(serverPlayer, Entity.RemovalReason.DISCARDED);
|
|
||||||
+ } else {
|
|
||||||
+ entity.discard();
|
|
||||||
+ }
|
|
||||||
+ // Scissors end
|
|
||||||
}
|
|
||||||
|
|
||||||
this.entityLookup.addNewEntity(player); // Paper - rewite chunk system
|
|
@@ -1,19 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Luna <lunahatesgogle@gmail.com>
|
|
||||||
Date: Fri, 28 Apr 2023 16:46:00 -0300
|
|
||||||
Subject: [PATCH] Don't warn on duplicate entity UUIDs
|
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/io/papermc/paper/chunk/system/entity/EntityLookup.java b/src/main/java/io/papermc/paper/chunk/system/entity/EntityLookup.java
|
|
||||||
index 82ccaf612548a7dbab7e5aeffb6eb8db84367477..5147c5860f0b485ecb82fa06336939d5bb54057d 100644
|
|
||||||
--- a/src/main/java/io/papermc/paper/chunk/system/entity/EntityLookup.java
|
|
||||||
+++ b/src/main/java/io/papermc/paper/chunk/system/entity/EntityLookup.java
|
|
||||||
@@ -367,7 +367,7 @@ public final class EntityLookup implements LevelEntityGetter<Entity> {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (this.entityByUUID.containsKey(entity.getUUID())) {
|
|
||||||
- LOGGER.warn("Entity uuid already exists: " + entity.getUUID() + ", mapped to " + this.entityByUUID.get(entity.getUUID()) + ", can't add " + entity);
|
|
||||||
+ // Scissors - Don't warn on duplicate entity UUIDs
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
this.entityById.put(entity.getId(), entity);
|
|
@@ -1,58 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Chipmunk <65827213+ChipmunkMC@users.noreply.github.com>
|
|
||||||
Date: Mon, 1 May 2023 09:13:50 -0400
|
|
||||||
Subject: [PATCH] Make excluding players from nbt components configurable
|
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/me/totalfreedom/scissors/ScissorsConfig.java b/src/main/java/me/totalfreedom/scissors/ScissorsConfig.java
|
|
||||||
index 9f2a51fddb692f5152c32dcbe1f5a6ba150634e4..39b56ca496ed7369ead21805d476c2b813fcdd1d 100644
|
|
||||||
--- a/src/main/java/me/totalfreedom/scissors/ScissorsConfig.java
|
|
||||||
+++ b/src/main/java/me/totalfreedom/scissors/ScissorsConfig.java
|
|
||||||
@@ -87,8 +87,8 @@ public class ScissorsConfig
|
|
||||||
config.options().header(HEADER);
|
|
||||||
config.options().copyDefaults(true);
|
|
||||||
|
|
||||||
- version = getInt("config-version", 3);
|
|
||||||
- set("config-version", 3);
|
|
||||||
+ version = getInt("config-version", 4);
|
|
||||||
+ set("config-version", 4);
|
|
||||||
readConfig(ScissorsConfig.class, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -169,6 +169,12 @@ public class ScissorsConfig
|
|
||||||
chatSignaturesEnabled = getBoolean("chatSignaturesEnabled", true);
|
|
||||||
}
|
|
||||||
|
|
||||||
+ public static boolean excludePlayersFromNbtComponents = false;
|
|
||||||
+ private static void excludePlayersFromNbtComponents()
|
|
||||||
+ {
|
|
||||||
+ excludePlayersFromNbtComponents = getBoolean("excludePlayersFromNbtComponents", false);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
private static void set(String path, Object val)
|
|
||||||
{
|
|
||||||
config.set(path, val);
|
|
||||||
diff --git a/src/main/java/net/minecraft/network/chat/contents/EntityDataSource.java b/src/main/java/net/minecraft/network/chat/contents/EntityDataSource.java
|
|
||||||
index e5a2bb129100f0f935c8f10682204e7cb6277142..1ebc6107bbbf18dd9ede1196769e43ee7cb9d448 100644
|
|
||||||
--- a/src/main/java/net/minecraft/network/chat/contents/EntityDataSource.java
|
|
||||||
+++ b/src/main/java/net/minecraft/network/chat/contents/EntityDataSource.java
|
|
||||||
@@ -1,5 +1,6 @@
|
|
||||||
package net.minecraft.network.chat.contents;
|
|
||||||
|
|
||||||
+import me.totalfreedom.scissors.ScissorsConfig;
|
|
||||||
import com.mojang.brigadier.StringReader;
|
|
||||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
|
||||||
import java.util.List;
|
|
||||||
@@ -32,7 +33,11 @@ public record EntityDataSource(String selectorPattern, @Nullable EntitySelector
|
|
||||||
public Stream<CompoundTag> getData(CommandSourceStack source) throws CommandSyntaxException {
|
|
||||||
if (this.compiledSelector != null) {
|
|
||||||
List<? extends Entity> list = this.compiledSelector.findEntities(source);
|
|
||||||
- return list.stream().filter((entity) -> !(entity instanceof Player)).map(NbtPredicate::getEntityTagToCompare); // Scissors - Don't query NBT from players
|
|
||||||
+ // Scissors start
|
|
||||||
+ Stream<? extends Entity> stream = list.stream();
|
|
||||||
+ if (ScissorsConfig.excludePlayersFromNbtComponents) stream = stream.filter((entity) -> !(entity instanceof Player));
|
|
||||||
+ return stream.map(NbtPredicate::getEntityTagToCompare);
|
|
||||||
+ // Scissors end
|
|
||||||
} else {
|
|
||||||
return Stream.empty();
|
|
||||||
}
|
|
@@ -1,22 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Luna <lunahatesgogle@gmail.com>
|
|
||||||
Date: Mon, 29 May 2023 19:34:50 -0300
|
|
||||||
Subject: [PATCH] Fix component extra empty array exploit
|
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/network/chat/Component.java b/src/main/java/net/minecraft/network/chat/Component.java
|
|
||||||
index 3c0ee4e1f42f6056ca86a6f9f129d467e29a2fbc..9c2c22ee548ad77f0912698f33de5f467f32fb7f 100644
|
|
||||||
--- a/src/main/java/net/minecraft/network/chat/Component.java
|
|
||||||
+++ b/src/main/java/net/minecraft/network/chat/Component.java
|
|
||||||
@@ -266,6 +266,11 @@ public interface Component extends Message, FormattedText, Iterable<Component> {
|
|
||||||
if (!jsonelement.isJsonObject()) {
|
|
||||||
if (jsonelement.isJsonArray()) {
|
|
||||||
JsonArray jsonarray = jsonelement.getAsJsonArray();
|
|
||||||
+ // Scissors start
|
|
||||||
+ if (jsonarray.size() <= 0) {
|
|
||||||
+ throw new JsonParseException("Unexpected empty array of components");
|
|
||||||
+ }
|
|
||||||
+ // Scissors end
|
|
||||||
|
|
||||||
ichatmutablecomponent = null;
|
|
||||||
Iterator iterator = jsonarray.iterator();
|
|
@@ -1,163 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Luna <lunahatesgogle@gmail.com>
|
|
||||||
Date: Wed, 31 May 2023 18:14:00 -0300
|
|
||||||
Subject: [PATCH] Add depth limit to Component deserializer
|
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/me/totalfreedom/scissors/ScissorsConfig.java b/src/main/java/me/totalfreedom/scissors/ScissorsConfig.java
|
|
||||||
index 39b56ca496ed7369ead21805d476c2b813fcdd1d..9659cff6412584190ff0c32e01f602de4ff7d3b3 100644
|
|
||||||
--- a/src/main/java/me/totalfreedom/scissors/ScissorsConfig.java
|
|
||||||
+++ b/src/main/java/me/totalfreedom/scissors/ScissorsConfig.java
|
|
||||||
@@ -87,8 +87,8 @@ public class ScissorsConfig
|
|
||||||
config.options().header(HEADER);
|
|
||||||
config.options().copyDefaults(true);
|
|
||||||
|
|
||||||
- version = getInt("config-version", 4);
|
|
||||||
- set("config-version", 4);
|
|
||||||
+ version = getInt("config-version", 5);
|
|
||||||
+ set("config-version", 5);
|
|
||||||
readConfig(ScissorsConfig.class, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -175,6 +175,12 @@ public class ScissorsConfig
|
|
||||||
excludePlayersFromNbtComponents = getBoolean("excludePlayersFromNbtComponents", false);
|
|
||||||
}
|
|
||||||
|
|
||||||
+ public static int componentDepthLimit = 128;
|
|
||||||
+ private static void componentDepthLimit()
|
|
||||||
+ {
|
|
||||||
+ componentDepthLimit = getInt("componentDepthLimit", 128);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
private static void set(String path, Object val)
|
|
||||||
{
|
|
||||||
config.set(path, val);
|
|
||||||
diff --git a/src/main/java/net/minecraft/network/chat/Component.java b/src/main/java/net/minecraft/network/chat/Component.java
|
|
||||||
index 9c2c22ee548ad77f0912698f33de5f467f32fb7f..ba2879b25e59290ab81501458414a417c121ed03 100644
|
|
||||||
--- a/src/main/java/net/minecraft/network/chat/Component.java
|
|
||||||
+++ b/src/main/java/net/minecraft/network/chat/Component.java
|
|
||||||
@@ -26,6 +26,7 @@ import java.util.List;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.Optional;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
+import me.totalfreedom.scissors.ScissorsConfig; // Scissors
|
|
||||||
import net.minecraft.ChatFormatting;
|
|
||||||
import net.minecraft.Util;
|
|
||||||
import net.minecraft.network.chat.contents.BlockDataSource;
|
|
||||||
@@ -44,6 +45,7 @@ import net.minecraft.util.GsonHelper;
|
|
||||||
import net.minecraft.util.LowerCaseEnumTypeAdapterFactory;
|
|
||||||
// CraftBukkit start
|
|
||||||
import com.google.common.collect.Streams;
|
|
||||||
+import java.util.regex.Pattern; // Scissors
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
// CraftBukkit end
|
|
||||||
|
|
||||||
@@ -254,10 +256,16 @@ public interface Component extends Message, FormattedText, Iterable<Component> {
|
|
||||||
throw new IllegalStateException("Couldn't get field 'lineStart' for JsonReader", nosuchfieldexception);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
+ private static final Pattern PLACEHOLDER_PATTERN = Pattern.compile("%[0-9]+\\$s"); // Scissors
|
|
||||||
|
|
||||||
public Serializer() {}
|
|
||||||
|
|
||||||
- public MutableComponent deserialize(JsonElement jsonelement, Type type, JsonDeserializationContext jsondeserializationcontext) throws JsonParseException {
|
|
||||||
+ // Scissors start
|
|
||||||
+ private MutableComponent deserialize(JsonElement jsonelement, JsonDeserializationContext jsondeserializationcontext, int depth) throws JsonParseException {
|
|
||||||
+ if (depth > ScissorsConfig.componentDepthLimit) {
|
|
||||||
+ throw new JsonParseException("Depth limit exceeded");
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
if (jsonelement.isJsonPrimitive()) {
|
|
||||||
return Component.literal(jsonelement.getAsString());
|
|
||||||
} else {
|
|
||||||
@@ -266,18 +274,16 @@ public interface Component extends Message, FormattedText, Iterable<Component> {
|
|
||||||
if (!jsonelement.isJsonObject()) {
|
|
||||||
if (jsonelement.isJsonArray()) {
|
|
||||||
JsonArray jsonarray = jsonelement.getAsJsonArray();
|
|
||||||
- // Scissors start
|
|
||||||
if (jsonarray.size() <= 0) {
|
|
||||||
throw new JsonParseException("Unexpected empty array of components");
|
|
||||||
}
|
|
||||||
- // Scissors end
|
|
||||||
|
|
||||||
ichatmutablecomponent = null;
|
|
||||||
Iterator iterator = jsonarray.iterator();
|
|
||||||
|
|
||||||
while (iterator.hasNext()) {
|
|
||||||
JsonElement jsonelement1 = (JsonElement) iterator.next();
|
|
||||||
- MutableComponent ichatmutablecomponent1 = this.deserialize(jsonelement1, jsonelement1.getClass(), jsondeserializationcontext);
|
|
||||||
+ MutableComponent ichatmutablecomponent1 = this.deserialize(jsonelement1, jsondeserializationcontext, depth + 1);
|
|
||||||
|
|
||||||
if (ichatmutablecomponent == null) {
|
|
||||||
ichatmutablecomponent = ichatmutablecomponent1;
|
|
||||||
@@ -301,12 +307,17 @@ public interface Component extends Message, FormattedText, Iterable<Component> {
|
|
||||||
s = GsonHelper.getAsString(jsonobject, "translate");
|
|
||||||
String s1 = GsonHelper.getAsString(jsonobject, "fallback", (String) null);
|
|
||||||
|
|
||||||
+ // Penalize depth for placeholders in translate & fallback
|
|
||||||
+ long translate_placeholders = PLACEHOLDER_PATTERN.matcher(s).results().count();
|
|
||||||
+ long fallback_placeholders = s1 != null ? PLACEHOLDER_PATTERN.matcher(s1).results().count() : 0;
|
|
||||||
+ int penalty = (int)Math.max(translate_placeholders, fallback_placeholders) * 12;
|
|
||||||
+
|
|
||||||
if (jsonobject.has("with")) {
|
|
||||||
JsonArray jsonarray1 = GsonHelper.getAsJsonArray(jsonobject, "with");
|
|
||||||
Object[] aobject = new Object[jsonarray1.size()];
|
|
||||||
|
|
||||||
for (int i = 0; i < aobject.length; ++i) {
|
|
||||||
- aobject[i] = Serializer.unwrapTextArgument(this.deserialize(jsonarray1.get(i), type, jsondeserializationcontext));
|
|
||||||
+ aobject[i] = Serializer.unwrapTextArgument(this.deserialize(jsonarray1.get(i), jsondeserializationcontext, depth + 1 + penalty));
|
|
||||||
}
|
|
||||||
|
|
||||||
ichatmutablecomponent = Component.translatableWithFallback(s, s1, aobject);
|
|
||||||
@@ -322,7 +333,7 @@ public interface Component extends Message, FormattedText, Iterable<Component> {
|
|
||||||
|
|
||||||
ichatmutablecomponent = Component.score(GsonHelper.getAsString(jsonobject1, "name"), GsonHelper.getAsString(jsonobject1, "objective"));
|
|
||||||
} else if (jsonobject.has("selector")) {
|
|
||||||
- Optional<Component> optional = this.parseSeparator(type, jsondeserializationcontext, jsonobject);
|
|
||||||
+ Optional<Component> optional = this.parseSeparator(jsondeserializationcontext, jsonobject, depth + 1);
|
|
||||||
|
|
||||||
ichatmutablecomponent = Component.selector(GsonHelper.getAsString(jsonobject, "selector"), optional);
|
|
||||||
} else if (jsonobject.has("keybind")) {
|
|
||||||
@@ -333,7 +344,7 @@ public interface Component extends Message, FormattedText, Iterable<Component> {
|
|
||||||
}
|
|
||||||
|
|
||||||
s = GsonHelper.getAsString(jsonobject, "nbt");
|
|
||||||
- Optional<Component> optional1 = this.parseSeparator(type, jsondeserializationcontext, jsonobject);
|
|
||||||
+ Optional<Component> optional1 = this.parseSeparator(jsondeserializationcontext, jsonobject, depth + 1);
|
|
||||||
boolean flag = GsonHelper.getAsBoolean(jsonobject, "interpret", false);
|
|
||||||
Object object;
|
|
||||||
|
|
||||||
@@ -360,7 +371,7 @@ public interface Component extends Message, FormattedText, Iterable<Component> {
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int j = 0; j < jsonarray2.size(); ++j) {
|
|
||||||
- ichatmutablecomponent.append((Component) this.deserialize(jsonarray2.get(j), type, jsondeserializationcontext));
|
|
||||||
+ ichatmutablecomponent.append((Component) this.deserialize(jsonarray2.get(j), jsondeserializationcontext, depth + 1));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -370,6 +381,11 @@ public interface Component extends Message, FormattedText, Iterable<Component> {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
+ public MutableComponent deserialize(JsonElement jsonelement, Type type, JsonDeserializationContext jsondeserializationcontext) throws JsonParseException {
|
|
||||||
+ return this.deserialize(jsonelement, jsondeserializationcontext, 1);
|
|
||||||
+ }
|
|
||||||
+ // Scissors end
|
|
||||||
+
|
|
||||||
private static Object unwrapTextArgument(Object text) {
|
|
||||||
if (text instanceof Component) {
|
|
||||||
Component ichatbasecomponent = (Component) text;
|
|
||||||
@@ -388,8 +404,10 @@ public interface Component extends Message, FormattedText, Iterable<Component> {
|
|
||||||
return text;
|
|
||||||
}
|
|
||||||
|
|
||||||
- private Optional<Component> parseSeparator(Type type, JsonDeserializationContext context, JsonObject json) {
|
|
||||||
- return json.has("separator") ? Optional.of(this.deserialize(json.get("separator"), type, context)) : Optional.empty();
|
|
||||||
+ // Scissors start
|
|
||||||
+ private Optional<Component> parseSeparator(JsonDeserializationContext context, JsonObject json, int depth) {
|
|
||||||
+ return json.has("separator") ? Optional.of(this.deserialize(json.get("separator"), context, depth + 1)) : Optional.empty();
|
|
||||||
+ // Scissors end
|
|
||||||
}
|
|
||||||
|
|
||||||
private void serializeStyle(Style style, JsonObject json, JsonSerializationContext context) {
|
|
@@ -1,116 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Allink <arclicious@vivaldi.net>
|
|
||||||
Date: Fri, 2 Jun 2023 22:13:54 +0100
|
|
||||||
Subject: [PATCH] Add depth limit to SNBT
|
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/nbt/TagParser.java b/src/main/java/net/minecraft/nbt/TagParser.java
|
|
||||||
index fbfe810e8be6cb159742f7fd85e7491b9cefa4dc..82b1d851e310504e7373a967dfb5b0b096d36693 100644
|
|
||||||
--- a/src/main/java/net/minecraft/nbt/TagParser.java
|
|
||||||
+++ b/src/main/java/net/minecraft/nbt/TagParser.java
|
|
||||||
@@ -169,8 +169,58 @@ public class TagParser {
|
|
||||||
}
|
|
||||||
|
|
||||||
this.expect('}');
|
|
||||||
- return compoundTag;
|
|
||||||
+
|
|
||||||
+ // Scissors start - Add depth limit to SNBT
|
|
||||||
+ return exceedsDepthLimit(compoundTag) ? new CompoundTag() : compoundTag;
|
|
||||||
+ // Scissors end
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ // Scissors start - Add depth limit to SNBT
|
|
||||||
+ private boolean exceedsDepthLimit(Tag tag) {
|
|
||||||
+ return this.exceedsDepthLimit(0, tag);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ private boolean exceedsDepthLimit(long depth, Tag tag)
|
|
||||||
+ {
|
|
||||||
+ if (depth > 256)
|
|
||||||
+ {
|
|
||||||
+ return true;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ if (tag instanceof ListTag listTag)
|
|
||||||
+ {
|
|
||||||
+ for (Tag childTag : listTag)
|
|
||||||
+ {
|
|
||||||
+ boolean returnValue = this.exceedsDepthLimit(depth + 1, childTag);
|
|
||||||
+
|
|
||||||
+ if (returnValue)
|
|
||||||
+ {
|
|
||||||
+ return true;
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+ } else if (tag instanceof CompoundTag compoundTag)
|
|
||||||
+ {
|
|
||||||
+ for (String key: compoundTag.getAllKeys())
|
|
||||||
+ {
|
|
||||||
+ Tag childTag = compoundTag.get(key);
|
|
||||||
+
|
|
||||||
+ if (childTag == null)
|
|
||||||
+ {
|
|
||||||
+ continue;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ boolean returnValue = this.exceedsDepthLimit(depth + 1, childTag);
|
|
||||||
+
|
|
||||||
+ if (returnValue)
|
|
||||||
+ {
|
|
||||||
+ return true;
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ return false;
|
|
||||||
}
|
|
||||||
+ // Scissors end
|
|
||||||
|
|
||||||
private Tag readListTag() throws CommandSyntaxException {
|
|
||||||
this.expect('[');
|
|
||||||
@@ -203,7 +253,11 @@ public class TagParser {
|
|
||||||
}
|
|
||||||
|
|
||||||
this.expect(']');
|
|
||||||
- return listTag;
|
|
||||||
+
|
|
||||||
+ // Scissors start - Add depth limit to SNBT
|
|
||||||
+ return exceedsDepthLimit(listTag) ? new ListTag() : listTag;
|
|
||||||
+ // return listTag;
|
|
||||||
+ // Scissors end
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -228,7 +282,7 @@ public class TagParser {
|
|
||||||
}
|
|
||||||
|
|
||||||
private <T extends Number> List<T> readArray(TagType<?> arrayTypeReader, TagType<?> typeReader) throws CommandSyntaxException {
|
|
||||||
- List<T> list = Lists.newArrayList();
|
|
||||||
+ List<Number> list = Lists.newArrayList(); // Scissors - List<T> -> List<Number>
|
|
||||||
|
|
||||||
while(true) {
|
|
||||||
if (this.reader.peek() != ']') {
|
|
||||||
@@ -241,11 +295,11 @@ public class TagParser {
|
|
||||||
}
|
|
||||||
|
|
||||||
if (typeReader == ByteTag.TYPE) {
|
|
||||||
- list.add((T)((NumericTag)tag).getAsByte());
|
|
||||||
+ list.add(((NumericTag)tag).getAsByte()); // Scissors - Remove (T) cast
|
|
||||||
} else if (typeReader == LongTag.TYPE) {
|
|
||||||
- list.add((T)((NumericTag)tag).getAsLong());
|
|
||||||
+ list.add(((NumericTag)tag).getAsLong()); // Scissors - Remove (T) cast
|
|
||||||
} else {
|
|
||||||
- list.add((T)((NumericTag)tag).getAsInt());
|
|
||||||
+ list.add(((NumericTag)tag).getAsInt()); // Scissors - Remove (T) cast
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.hasElementSeparator()) {
|
|
||||||
@@ -257,7 +311,7 @@ public class TagParser {
|
|
||||||
}
|
|
||||||
|
|
||||||
this.expect(']');
|
|
||||||
- return list;
|
|
||||||
+ return (List<T>) list; // Scissors - Cast to List<T>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@@ -1,27 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Luna <lunahatesgogle@gmail.com>
|
|
||||||
Date: Wed, 7 Jun 2023 16:50:35 -0300
|
|
||||||
Subject: [PATCH] Limit beacon effectRange
|
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/BeaconBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BeaconBlockEntity.java
|
|
||||||
index f2325c0c475bb465f5275f78c71949648a860d0c..4ec228ce026ee39eebd17d180fb5caea1b74e6e2 100644
|
|
||||||
--- a/src/main/java/net/minecraft/world/level/block/entity/BeaconBlockEntity.java
|
|
||||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/BeaconBlockEntity.java
|
|
||||||
@@ -83,7 +83,7 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider, Name
|
|
||||||
private double effectRange = -1;
|
|
||||||
|
|
||||||
public double getEffectRange() {
|
|
||||||
- if (this.effectRange < 0) {
|
|
||||||
+ if (this.effectRange < 0 || this.effectRange > 256) { // Scissors
|
|
||||||
return this.levels * 10 + 10;
|
|
||||||
} else {
|
|
||||||
return effectRange;
|
|
||||||
@@ -415,6 +415,7 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider, Name
|
|
||||||
|
|
||||||
this.lockKey = LockCode.fromTag(nbt);
|
|
||||||
this.effectRange = nbt.contains(PAPER_RANGE_TAG, 6) ? nbt.getDouble(PAPER_RANGE_TAG) : -1; // Paper
|
|
||||||
+ if (this.effectRange > 256) this.effectRange = 256; // Scissors
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
@@ -1,19 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Luna <lunahatesgogle@gmail.com>
|
|
||||||
Date: Mon, 12 Jun 2023 17:32:04 -0300
|
|
||||||
Subject: [PATCH] Fix invalid armor trim exploit
|
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaArmor.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaArmor.java
|
|
||||||
index c92981aedebe934cefa1c96a0328fb91fe17acbc..a1e1a94f0eb46b7eb3fe19e416e21e29b33f3e9f 100644
|
|
||||||
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaArmor.java
|
|
||||||
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaArmor.java
|
|
||||||
@@ -71,7 +71,7 @@ public class CraftMetaArmor extends CraftMetaItem implements ArmorMeta {
|
|
||||||
TrimMaterial trimMaterial = Registry.TRIM_MATERIAL.get(NamespacedKey.fromString(trimCompound.getString(TRIM_MATERIAL.NBT)));
|
|
||||||
TrimPattern trimPattern = Registry.TRIM_PATTERN.get(NamespacedKey.fromString(trimCompound.getString(TRIM_PATTERN.NBT)));
|
|
||||||
|
|
||||||
- this.trim = new ArmorTrim(trimMaterial, trimPattern);
|
|
||||||
+ if (trimMaterial != null && trimPattern != null) this.trim = new ArmorTrim(trimMaterial, trimPattern); // Scissors
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,7 +1,7 @@
|
|||||||
pluginManagement {
|
pluginManagement {
|
||||||
repositories {
|
repositories {
|
||||||
gradlePluginPortal()
|
gradlePluginPortal()
|
||||||
maven("https://repo.papermc.io/repository/maven-public/")
|
maven("https://papermc.io/repo/repository/maven-public/")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user