mirror of
https://github.com/AtlasMediaGroup/Scissors.git
synced 2025-07-15 15:18:35 +00:00
Compare commits
59 Commits
Author | SHA1 | Date | |
---|---|---|---|
fb286351e1 | |||
d487ca64dc | |||
a4ede7dc64 | |||
5af8738efc | |||
ece466de42 | |||
1a5d2bf22a | |||
671bf4bd18 | |||
76155af1ed | |||
f33f6d2de8 | |||
7b8d2ee804 | |||
b72d5ec8fc | |||
7e6bd02e17 | |||
79f013c021 | |||
2073436f76 | |||
43213a0e43 | |||
1b4d65a1e6 | |||
020afc9e99 | |||
92a9dd9634 | |||
661bd58103 | |||
494829e797 | |||
4c31b7f9ac | |||
b75232882c | |||
f21a7fb408 | |||
ae3dc6aa18 | |||
8f07c9e142 | |||
1cd49aebf7 | |||
3a4b3ffd34 | |||
c48a56ac01 | |||
fb17ef58f1 | |||
aba21aaf49 | |||
dcf6dab4ee | |||
cb464a0b3a | |||
71804a2e65 | |||
611e77e503 | |||
3b8ad1a45d | |||
c2b2427622 | |||
a877b648d5 | |||
f66a491861 | |||
bca6da00e8 | |||
c4afa459b5 | |||
55ec369c40 | |||
6b0f19780f | |||
2907ef1436 | |||
b2f423c4ec | |||
7885894176 | |||
4d16aa5d43 | |||
61bcac75e9 | |||
9bfd719cb6 | |||
7f0374c24f | |||
10d6b02984 | |||
638bd93702 | |||
106edf19b7 | |||
236e8a95a3 | |||
9e244f52c9 | |||
61fd911106 | |||
21f493bcf8 | |||
ac37ce16dd | |||
6f32742d79 | |||
dc1a5399f7 |
26
.github/workflows/build.yml
vendored
26
.github/workflows/build.yml
vendored
@ -1,10 +1,5 @@
|
||||
name: Patch and Build
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "**" ]
|
||||
pull_request:
|
||||
|
||||
on: [ push, pull_request ]
|
||||
jobs:
|
||||
build:
|
||||
# Only run on PRs if the source branch is on someone else's repo
|
||||
@ -12,19 +7,26 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout Git Repository
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v2
|
||||
- name: Validate Gradle wrapper
|
||||
uses: gradle/wrapper-validation-action@v1
|
||||
- name: Setup Gradle
|
||||
uses: gradle/gradle-build-action@v2
|
||||
- name: Cache Gradle
|
||||
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
|
||||
uses: actions/setup-java@v3
|
||||
uses: actions/setup-java@v2.3.0
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: '17'
|
||||
- name: Configure Git User Details
|
||||
run: git config --global user.email "actions@github.com" && git config --global user.name "Github Actions"
|
||||
- name: Apply Patches
|
||||
run: ./gradlew applyPatches
|
||||
run: ./gradlew applyPatches --stacktrace
|
||||
- name: Build
|
||||
run: ./gradlew build
|
||||
run: ./gradlew build --stacktrace
|
||||
|
8
Jenkinsfile
vendored
8
Jenkinsfile
vendored
@ -14,12 +14,12 @@ pipeline {
|
||||
stage('paperclipJar') {
|
||||
steps {
|
||||
withGradle {
|
||||
sh './gradlew createReobfPaperclipJar --no-daemon --refresh-dependencies'
|
||||
sh './gradlew paperclipJar --no-daemon --refresh-dependencies'
|
||||
}
|
||||
sh """
|
||||
#!/bin/sh
|
||||
mv \${WORKSPACE}/build/libs/Scissors-paperclip-*.jar \${WORKSPACE}/build/libs/scissors-\${BRANCH_NAME}-\${BUILD_NUMBER}.jar
|
||||
rm \${WORKSPACE}/build/libs/Scissors-bundler-*.jar
|
||||
BRANCH=\$(echo "\${BRANCH_NAME}" | sed 's/\\//_/g')
|
||||
mv \${WORKSPACE}/build/libs/Scissors-*.jar \${WORKSPACE}/build/libs/scissors-\${BRANCH}-\${BUILD_NUMBER}.jar
|
||||
"""
|
||||
}
|
||||
}
|
||||
@ -33,7 +33,7 @@ pipeline {
|
||||
}
|
||||
post {
|
||||
always {
|
||||
archiveArtifacts artifacts: 'build/libs/scissors-*.jar', fingerprint: true
|
||||
archiveArtifacts artifacts: 'build/libs/*.jar', fingerprint: true
|
||||
junit 'Scissors-Server/build/test-results/test/*.xml'
|
||||
junit 'Scissors-API/build/test-results/test/*.xml'
|
||||
cleanWs()
|
||||
|
30
README.md
30
README.md
@ -1,32 +1,8 @@
|
||||
# Scissors [](https://ci.scissors.gg/job/Scissors/job/1.20/)
|
||||
|
||||
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.
|
||||
# Scissors [](https://ci.scissors.gg/job/Scissors/job/1.17.1/)
|
||||
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.
|
||||
|
||||
## Links
|
||||
### [Scissors Download](https://ci.plex.us.org/job/Scissors)
|
||||
### [Scissors Javadoc](https://javadoc.scissors.gg/1.20)
|
||||
### [Scissors Javadoc](https://javadoc.scissors.gg/1.17.1)
|
||||
### [Scissors Announcements](https://totalfreedom.me/forum/board/139)
|
||||
### [Scissors General Discussion](https://totalfreedom.me/forum/board/140)
|
||||
|
||||
## Tasks
|
||||
```
|
||||
Paperweight tasks
|
||||
-----------------
|
||||
applyApiPatches
|
||||
applyPatches
|
||||
applyServerPatches
|
||||
cleanCache - Delete the project setup cache and task outputs.
|
||||
createMojmapBundlerJar - Build a runnable bundler jar
|
||||
createMojmapPaperclipJar - Build a runnable paperclip jar
|
||||
createReobfBundlerJar - Build a runnable bundler jar
|
||||
createReobfPaperclipJar - Build a runnable paperclip jar
|
||||
generateDevelopmentBundle
|
||||
rebuildApiPatches
|
||||
rebuildPatches
|
||||
rebuildServerPatches
|
||||
reobfJar - Re-obfuscate the built jar to obf mappings
|
||||
runDev - Spin up a non-relocated Mojang-mapped test server
|
||||
runReobf - Spin up a test server from the reobfJar output jar
|
||||
runShadow - Spin up a test server from the shadowJar archiveFile
|
||||
```
|
||||
|
@ -8,9 +8,4 @@
|
||||
# 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/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
|
||||
minecraft net/minecraft/nbt/TagParser.java
|
@ -1,23 +1,31 @@
|
||||
import io.papermc.paperweight.util.constants.*
|
||||
|
||||
plugins {
|
||||
java
|
||||
`maven-publish`
|
||||
id("com.github.johnrengelman.shadow") version "8.1.1" apply false
|
||||
id("io.papermc.paperweight.patcher") version "1.5.5"
|
||||
id("com.github.johnrengelman.shadow") version "7.1.2" apply false
|
||||
id("io.papermc.paperweight.patcher") version "1.2.0"
|
||||
}
|
||||
|
||||
val paperMavenPublicUrl = "https://repo.papermc.io/repository/maven-public/"
|
||||
val spigotDecompiler: Configuration by configurations.creating
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven(paperMavenPublicUrl) {
|
||||
content { onlyForConfigurations(configurations.paperclip.name) }
|
||||
maven("https://repo.papermc.io/repository/maven-public/") {
|
||||
content {
|
||||
onlyForConfigurations(
|
||||
configurations.paperclip.name,
|
||||
spigotDecompiler.name,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
remapper("net.fabricmc:tiny-remapper:0.8.6:fat")
|
||||
decompiler("net.minecraftforge:forgeflower:2.0.627.2")
|
||||
paperclip("io.papermc:paperclip:3.0.3")
|
||||
remapper("net.fabricmc:tiny-remapper:0.8.1:fat")
|
||||
decompiler("net.minecraftforge:forgeflower:1.5.498.22")
|
||||
spigotDecompiler("io.papermc:patched-spigot-fernflower:0.1+build.4")
|
||||
paperclip("io.papermc:paperclip:2.0.1")
|
||||
}
|
||||
|
||||
allprojects {
|
||||
@ -42,21 +50,18 @@ subprojects {
|
||||
tasks.withType<ProcessResources> {
|
||||
filteringCharset = Charsets.UTF_8.name()
|
||||
}
|
||||
tasks.withType<Test> {
|
||||
minHeapSize = "2g"
|
||||
maxHeapSize = "4g"
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven(paperMavenPublicUrl)
|
||||
maven("https://repo.papermc.io/repository/maven-public/")
|
||||
}
|
||||
}
|
||||
|
||||
paperweight {
|
||||
serverProject.set(project(":Scissors-Server"))
|
||||
|
||||
remapRepo.set(paperMavenPublicUrl)
|
||||
decompileRepo.set(paperMavenPublicUrl)
|
||||
remapRepo.set("https://maven.fabricmc.net/")
|
||||
decompileRepo.set("https://files.minecraftforge.net/maven/")
|
||||
|
||||
usePaperUpstream(providers.gradleProperty("paperRef")) {
|
||||
withPaperPatcher {
|
||||
@ -75,7 +80,7 @@ tasks.generateDevelopmentBundle {
|
||||
libraryRepositories.set(
|
||||
listOf(
|
||||
"https://repo.maven.apache.org/maven2/",
|
||||
paperMavenPublicUrl,
|
||||
"https://repo.papermc.io/repository/maven-public/",
|
||||
"https://repo.scissors.gg/repository/scissors-snapshot/",
|
||||
)
|
||||
)
|
||||
|
@ -1,8 +1,8 @@
|
||||
group=me.totalfreedom.scissors
|
||||
version=1.20-R0.1-SNAPSHOT
|
||||
version=1.17.1-R0.1-SNAPSHOT
|
||||
|
||||
mcVersion=1.20
|
||||
paperRef=de19eb8c4a490ff4f427e9ad8b8bbe181c368cc1
|
||||
mcVersion=1.17.1
|
||||
paperRef=6625db387ea9fe5296a6c6f984975b387c3089f0
|
||||
|
||||
org.gradle.caching=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
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip
|
||||
networkTimeout=10000
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
18
gradlew
vendored
18
gradlew
vendored
@ -55,7 +55,7 @@
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (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.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
@ -80,11 +80,11 @@ do
|
||||
esac
|
||||
done
|
||||
|
||||
# This is normally unused
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
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.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
@ -143,16 +143,12 @@ fi
|
||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
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 ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
case $MAX_FD in #(
|
||||
'' | 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" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
@ -209,12 +205,6 @@ set -- \
|
||||
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.
|
||||
#
|
||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||
|
11
gradlew.bat
vendored
11
gradlew.bat
vendored
@ -26,7 +26,6 @@ if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
@rem This is normally unused
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@ -41,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
if "%ERRORLEVEL%" == "0" goto execute
|
||||
|
||||
echo.
|
||||
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
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
set EXIT_CODE=%ERRORLEVEL%
|
||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||
exit /b %EXIT_CODE%
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
@ -4,13 +4,13 @@ Date: Mon, 4 Jul 2022 16:44:35 +0100
|
||||
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/com/github/atlasmediagroup/scissors/event/block/MasterBlockFireEvent.java b/src/main/java/com/github/atlasmediagroup/scissors/event/block/MasterBlockFireEvent.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..a24cb52a5af62012c5d5acc29e4c3558e92ae572
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/totalfreedom/scissors/event/block/MasterBlockFireEvent.java
|
||||
+++ b/src/main/java/com/github/atlasmediagroup/scissors/event/block/MasterBlockFireEvent.java
|
||||
@@ -0,0 +1,51 @@
|
||||
+package me.totalfreedom.scissors.event.block;
|
||||
+package com.github.atlasmediagroup.scissors.event.block;
|
||||
+
|
||||
+import org.bukkit.Location;
|
||||
+import org.bukkit.event.Cancellable;
|
||||
|
@ -1,16 +1,16 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Allink <arclicious@vivaldi.net>
|
||||
Date: Tue, 5 Jul 2022 04:10:29 +0100
|
||||
Date: Tue, 5 Jul 2022 03:28:49 +0100
|
||||
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/com/github/atlasmediagroup/scissors/event/player/SpectatorTeleportEvent.java b/src/main/java/com/github/atlasmediagroup/scissors/event/player/SpectatorTeleportEvent.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..d7efa63c316ed99c3eccfeadc1b0873b2ccb5d8a
|
||||
index 0000000000000000000000000000000000000000..504f02ac89ea0ed3569cbc4ff67292041c9f408e
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/totalfreedom/scissors/event/player/SpectatorTeleportEvent.java
|
||||
+++ b/src/main/java/com/github/atlasmediagroup/scissors/event/player/SpectatorTeleportEvent.java
|
||||
@@ -0,0 +1,60 @@
|
||||
+package me.totalfreedom.scissors.event.player;
|
||||
+package com.github.atlasmediagroup.scissors.event.player;
|
||||
+
|
||||
+import org.bukkit.entity.Entity;
|
||||
+import org.bukkit.entity.Player;
|
||||
|
@ -1,14 +1,14 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Allink <arclicious@vivaldi.net>
|
||||
Date: Sun, 10 Jul 2022 10:12:04 +0100
|
||||
Date: Sun, 10 Jul 2022 07:27:37 +0100
|
||||
Subject: [PATCH] Add Scissors configuration file
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
|
||||
index 1d1a1d087dabc9794e0062a064da2cced4062309..1770de3705aa14232b133bce9fac56dfe89faa37 100644
|
||||
index c34cfba8f9ed7e9dbd0b6b8ffef9fba46abff046..416bdfccc6cae51a584f29949a32172fb10f78a6 100644
|
||||
--- a/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
|
||||
@@ -1715,6 +1715,13 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
|
||||
}
|
||||
// Paper end
|
||||
|
||||
|
@ -1,16 +1,16 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Allink <arclicious@vivaldi.net>
|
||||
Date: Fri, 2 Jun 2023 20:42:02 +0100
|
||||
Date: Fri, 2 Jun 2023 23:40:13 +0100
|
||||
Subject: [PATCH] Add command block player edit event
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/totalfreedom/scissors/event/block/CommandBlockPlayerEditEvent.java b/src/main/java/me/totalfreedom/scissors/event/block/CommandBlockPlayerEditEvent.java
|
||||
diff --git a/src/main/java/com/github/atlasmediagroup/scissors/event/block/CommandBlockPlayerEditEvent.java b/src/main/java/com/github/atlasmediagroup/scissors/event/block/CommandBlockPlayerEditEvent.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..722f5839600954998cbbf799e68477d499d104c4
|
||||
index 0000000000000000000000000000000000000000..983dd3b25800d5f1fcc61415051bf7c28d0147bd
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/totalfreedom/scissors/event/block/CommandBlockPlayerEditEvent.java
|
||||
+++ b/src/main/java/com/github/atlasmediagroup/scissors/event/block/CommandBlockPlayerEditEvent.java
|
||||
@@ -0,0 +1,77 @@
|
||||
+package me.totalfreedom.scissors.event.block;
|
||||
+package com.github.atlasmediagroup.scissors.event.block;
|
||||
+
|
||||
+import org.bukkit.block.CommandBlock;
|
||||
+import org.bukkit.entity.Player;
|
||||
@ -87,13 +87,13 @@ index 0000000000000000000000000000000000000000..722f5839600954998cbbf799e68477d4
|
||||
+ return handlers;
|
||||
+ }
|
||||
+}
|
||||
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/com/github/atlasmediagroup/scissors/event/block/CommandMinecartPlayerEditEvent.java b/src/main/java/com/github/atlasmediagroup/scissors/event/block/CommandMinecartPlayerEditEvent.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..4282f24deb87e52ee19a13b172ec80c6a6017e28
|
||||
index 0000000000000000000000000000000000000000..2ecaad3d67d3a028a50e998d791de3a829197117
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/totalfreedom/scissors/event/block/CommandMinecartPlayerEditEvent.java
|
||||
+++ b/src/main/java/com/github/atlasmediagroup/scissors/event/block/CommandMinecartPlayerEditEvent.java
|
||||
@@ -0,0 +1,78 @@
|
||||
+package me.totalfreedom.scissors.event.block;
|
||||
+package com.github.atlasmediagroup.scissors.event.block;
|
||||
+
|
||||
+import org.bukkit.block.CommandBlock;
|
||||
+import org.bukkit.entity.Player;
|
||||
|
@ -1,27 +1,25 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Telesphoreo <me@telesphoreo.me>
|
||||
Date: Wed, 27 Jul 2022 22:09:00 -0500
|
||||
From: Luna <lunahatesgogle@gmail.com>
|
||||
Date: Sat, 12 Mar 2022 22:22:22 -0300
|
||||
Subject: [PATCH] Build changes
|
||||
|
||||
|
||||
diff --git a/build.gradle.kts b/build.gradle.kts
|
||||
index a3a76b9b7efa773117d2ee1ce53ef784b09b277d..fad5e021f1282cd478f6ce484edbc135494b81b3 100644
|
||||
index c236fe5dc388f8bc0a929f1de04af94c63514208..722e2aefa279e02bfef23cda8d98210072b0ed3d 100644
|
||||
--- a/build.gradle.kts
|
||||
+++ b/build.gradle.kts
|
||||
@@ -7,8 +7,10 @@ plugins {
|
||||
@@ -13,8 +13,8 @@ plugins {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
- implementation(project(":paper-api"))
|
||||
- implementation(project(":paper-mojangapi"))
|
||||
+ implementation(project(":Scissors-API"))
|
||||
+ implementation("io.papermc.paper:paper-mojangapi:1.20-R0.1-SNAPSHOT") {
|
||||
+ exclude("io.papermc.paper", "paper-api")
|
||||
+ }
|
||||
- implementation(project(":Paper-API"))
|
||||
- implementation(project(":Paper-MojangAPI"))
|
||||
+ implementation(project(":Scissors-API")) // Scissors
|
||||
+ implementation("io.papermc.paper:paper-mojangapi:1.17.1-R0.1-SNAPSHOT") // Scissors
|
||||
// Paper start
|
||||
implementation("org.jline:jline-terminal-jansi:3.21.0")
|
||||
implementation("net.minecrell:terminalconsoleappender:1.3.0")
|
||||
@@ -58,11 +60,17 @@ tasks.jar {
|
||||
@@ -62,11 +62,17 @@ tasks.jar {
|
||||
val gitHash = git("rev-parse", "--short=7", "HEAD").getText().trim()
|
||||
val implementationVersion = System.getenv("BUILD_NUMBER") ?: "\"$gitHash\""
|
||||
val date = git("show", "-s", "--format=%ci", gitHash).getText().trim() // Paper
|
||||
@ -37,21 +35,21 @@ index a3a76b9b7efa773117d2ee1ce53ef784b09b277d..fad5e021f1282cd478f6ce484edbc135
|
||||
"Main-Class" to "org.bukkit.craftbukkit.Main",
|
||||
"Implementation-Title" to "CraftBukkit",
|
||||
- "Implementation-Version" to "git-Paper-$implementationVersion",
|
||||
+ "Implementation-Version" to "git-Scissors-$implementationVersion",
|
||||
+ "Implementation-Version" to "git-Scissors-$implementationVersion", // Scissors
|
||||
"Implementation-Vendor" to date, // Paper
|
||||
"Specification-Title" to "Bukkit",
|
||||
"Specification-Version" to project.version,
|
||||
@@ -134,7 +142,7 @@ fun TaskContainer.registerRunTask(
|
||||
name: String,
|
||||
block: JavaExec.() -> Unit
|
||||
@@ -193,7 +199,7 @@ tasks.test {
|
||||
fun TaskContainer.registerRunTask(
|
||||
name: String, block: JavaExec.() -> Unit
|
||||
): TaskProvider<JavaExec> = register<JavaExec>(name) {
|
||||
- group = "paper"
|
||||
+ group = "paperweight"
|
||||
mainClass.set("org.bukkit.craftbukkit.Main")
|
||||
standardInput = System.`in`
|
||||
workingDir = rootProject.layout.projectDirectory
|
||||
workingDir = rootProject.layout.projectDirectory.dir(
|
||||
providers.gradleProperty("runWorkDir").forUseAtConfigurationTime().orElse("run")
|
||||
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
|
||||
+++ b/src/main/java/com/destroystokyo/paper/Metrics.java
|
||||
@@ -593,7 +593,7 @@ public class Metrics {
|
||||
@ -63,22 +61,17 @@ index 4b002e8b75d117b726b0de274a76d3596fce015b..5ff11b9bcef76cb767f0b03ffc326d3f
|
||||
|
||||
metrics.addCustomChart(new Metrics.SimplePie("minecraft_version", () -> {
|
||||
String minecraftVersion = Bukkit.getVersion();
|
||||
@@ -607,11 +607,11 @@ public class Metrics {
|
||||
final String implVersion = org.bukkit.craftbukkit.Main.class.getPackage().getImplementationVersion();
|
||||
if (implVersion != null) {
|
||||
final String buildOrHash = implVersion.substring(implVersion.lastIndexOf('-') + 1);
|
||||
- paperVersion = "git-Paper-%s-%s".formatted(Bukkit.getServer().getMinecraftVersion(), buildOrHash);
|
||||
+ paperVersion = "git-Scissors-%s-%s".formatted(Bukkit.getServer().getMinecraftVersion(), buildOrHash);
|
||||
} else {
|
||||
paperVersion = "unknown";
|
||||
}
|
||||
- metrics.addCustomChart(new Metrics.SimplePie("paper_version", () -> paperVersion));
|
||||
+ metrics.addCustomChart(new Metrics.SimplePie("scissors_version", () -> paperVersion));
|
||||
@@ -603,7 +603,7 @@ public class Metrics {
|
||||
|
||||
metrics.addCustomChart(new Metrics.SingleLineChart("players", () -> Bukkit.getOnlinePlayers().size()));
|
||||
metrics.addCustomChart(new Metrics.SimplePie("online_mode", () -> Bukkit.getOnlineMode() ? "online" : "offline"));
|
||||
- metrics.addCustomChart(new Metrics.SimplePie("paper_version", () -> (Metrics.class.getPackage().getImplementationVersion() != null) ? Metrics.class.getPackage().getImplementationVersion() : "unknown"));
|
||||
+ metrics.addCustomChart(new Metrics.SimplePie("scissors_version", () -> (Metrics.class.getPackage().getImplementationVersion() != null) ? Metrics.class.getPackage().getImplementationVersion() : "unknown"));
|
||||
|
||||
metrics.addCustomChart(new Metrics.DrilldownPie("java_version", () -> {
|
||||
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
|
||||
index e0b1f0671d16ddddcb6725acd25a1d1d69e42701..3a3d1d22e105ec2c68a06512434540a81c889685 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 {
|
||||
@ -91,10 +84,10 @@ index c5d5648f4ca603ef2b1df723b58f9caf4dd3c722..2fbb5fc19e6d7f3767c7c6eedcbc6af2
|
||||
.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
|
||||
index fb82bb52f219e7683fe1d3c0fb3acbe2251de8d4..0f9928bf68f8bc5abfe02f41c98c63888987d9b9 100644
|
||||
index 8091a901106a1085da9dfd8627dadcbe50f00872..e6da0f7e755e6b0225afbced2c7a14e9df83b09d 100644
|
||||
--- a/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
|
||||
@@ -1729,7 +1729,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
|
||||
@DontObfuscate
|
||||
public String getServerModName() {
|
||||
@ -104,20 +97,20 @@ index fb82bb52f219e7683fe1d3c0fb3acbe2251de8d4..0f9928bf68f8bc5abfe02f41c98c6388
|
||||
|
||||
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
|
||||
index aefbb6a3f49a74a4c8fd004aa6a4ab1ab907e878..777b727a360683a72cef8c06ab7ab1439d69ac0a 100644
|
||||
index 99a94898316b0601f55b333c15a9926eae24f8a2..cc797b45674163b5913e20031d110796d78b928b 100644
|
||||
--- a/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
|
||||
@@ -251,7 +251,7 @@ import javax.annotation.Nullable; // Paper
|
||||
import javax.annotation.Nonnull; // Paper
|
||||
|
||||
public final class CraftServer implements Server {
|
||||
- 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 bukkitVersion = Versioning.getBukkitVersion();
|
||||
private final Logger logger = Logger.getLogger("Minecraft");
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/util/Versioning.java b/src/main/java/org/bukkit/craftbukkit/util/Versioning.java
|
||||
index 774556a62eb240da42e84db4502e2ed43495be17..5e6cce78e7987b4aa1c0052262ab8c4563905372 100644
|
||||
index 774556a62eb240da42e84db4502e2ed43495be17..becf61c0adde1c27f3e462a1b8248544ab181797 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/util/Versioning.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/util/Versioning.java
|
||||
@@ -11,7 +11,7 @@ public final class Versioning {
|
||||
@ -125,7 +118,7 @@ index 774556a62eb240da42e84db4502e2ed43495be17..5e6cce78e7987b4aa1c0052262ab8c45
|
||||
String result = "Unknown-Version";
|
||||
|
||||
- InputStream stream = Bukkit.class.getClassLoader().getResourceAsStream("META-INF/maven/io.papermc.paper/paper-api/pom.properties");
|
||||
+ InputStream stream = Bukkit.class.getClassLoader().getResourceAsStream("META-INF/maven/me.totalfreedom.scissors/Scissors-API/pom.properties");
|
||||
+ InputStream stream = Bukkit.class.getClassLoader().getResourceAsStream("META-INF/maven/me.totalfreedom.scissors/scissors-api/pom.properties");
|
||||
Properties properties = new Properties();
|
||||
|
||||
if (stream != null) {
|
||||
|
@ -1,17 +1,17 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Telesphoreo <me@telesphoreo.me>
|
||||
Date: Sat, 10 Dec 2022 22:25:38 -0600
|
||||
From: Video <videogamesm12@gmail.com>
|
||||
Date: Sat, 12 Mar 2022 19:34:59 -0700
|
||||
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
|
||||
index 3ad05bbab726c59e7b67d9614af4b208d4520cb3..c0633f9553fb5aa52e8ffc863159521d09cb3bd5 100644
|
||||
index fda8aad4a394cf331f3421ec07ffe0d605c8da4e..c5711b3d120699ec78f81e9b6ee80d0764552e94 100644
|
||||
--- a/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 {
|
||||
@@ -175,7 +175,14 @@ public class HoverEvent {
|
||||
} else {
|
||||
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"));
|
||||
+ // Scissors start
|
||||
+ UUID uUID;
|
||||
@ -24,10 +24,10 @@ index 3ad05bbab726c59e7b67d9614af4b208d4520cb3..c0633f9553fb5aa52e8ffc863159521d
|
||||
Component component = Component.Serializer.fromJson(jsonObject.get("name"));
|
||||
return new HoverEvent.EntityTooltipInfo(entityType, uUID, component);
|
||||
}
|
||||
@@ -186,7 +193,14 @@ public class HoverEvent {
|
||||
@@ -187,7 +194,14 @@ public class HoverEvent {
|
||||
CompoundTag compoundTag = TagParser.parseTag(text.getString());
|
||||
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"));
|
||||
+ // Scissors start
|
||||
+ UUID uUID;
|
||||
@ -38,5 +38,5 @@ index 3ad05bbab726c59e7b67d9614af4b208d4520cb3..c0633f9553fb5aa52e8ffc863159521d
|
||||
+ }
|
||||
+ // Scissors end
|
||||
return new HoverEvent.EntityTooltipInfo(entityType, uUID, component);
|
||||
} catch (Exception var5) {
|
||||
} catch (CommandSyntaxException | JsonSyntaxException var5) {
|
||||
return null;
|
||||
|
@ -1,46 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Video <videogamesm12@gmail.com>
|
||||
Date: Fri, 10 Jun 2022 22:55:01 -0500
|
||||
Subject: [PATCH] Fixes invalid LootTables causing problems when applied to
|
||||
Minecart entities
|
||||
|
||||
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/loottable/PaperContainerEntityLootableInventory.java b/src/main/java/com/destroystokyo/paper/loottable/PaperContainerEntityLootableInventory.java
|
||||
index d4a8c1bbb8fef27ac42bdf27dde495b4c649e6cb..865c61accf211d28be3c82dcf158fec9778b50c1 100644
|
||||
--- a/src/main/java/com/destroystokyo/paper/loottable/PaperContainerEntityLootableInventory.java
|
||||
+++ b/src/main/java/com/destroystokyo/paper/loottable/PaperContainerEntityLootableInventory.java
|
||||
@@ -17,7 +17,7 @@ public class PaperContainerEntityLootableInventory implements PaperLootableEntit
|
||||
|
||||
@Override
|
||||
public org.bukkit.loot.LootTable getLootTable() {
|
||||
- return entity.getLootTable() != null && !entity.getLootTable().getPath().isEmpty() ? Bukkit.getLootTable(CraftNamespacedKey.fromMinecraft(entity.getLootTable())) : 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
|
||||
}
|
||||
|
||||
@Override
|
||||
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
|
||||
--- a/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
|
||||
|
||||
@Override
|
||||
public org.bukkit.loot.LootTable getLootTable() {
|
||||
- return tileEntityLootable.lootTable != null && !tileEntityLootable.lootTable.getPath().isEmpty() ? Bukkit.getLootTable(CraftNamespacedKey.fromMinecraft(tileEntityLootable.lootTable)) : null;
|
||||
+ return tileEntityLootable.lootTable != null && !tileEntityLootable.lootTable.getPath().isEmpty() && tileEntityLootable.lootTable.toString().length() < 256 ? Bukkit.getLootTable(CraftNamespacedKey.fromMinecraft(tileEntityLootable.lootTable)) : null; // Scissors - Validate length of loot tables before even trying
|
||||
}
|
||||
|
||||
@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
|
||||
index b9f0dae1ec96194fe78c086b63d8a18b1d0cfcf7..bdc49a9965fd3add3dfca31fb0517c14597fb076 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java
|
||||
@@ -46,7 +46,7 @@ public abstract class RandomizableContainerBlockEntity extends BaseContainerBloc
|
||||
protected boolean tryLoadLootTable(CompoundTag nbt) {
|
||||
this.lootableData.loadNbt(nbt); // Paper
|
||||
if (nbt.contains("LootTable", 8)) {
|
||||
- this.lootTable = new ResourceLocation(nbt.getString("LootTable"));
|
||||
+ 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");
|
||||
return false; // Paper - always load the items, table may still remain
|
@ -1,24 +1,24 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Video <videogamesm12@gmail.com>
|
||||
Date: Fri, 22 Apr 2022 00:59:00 -0500
|
||||
Date: Sun, 13 Mar 2022 03:01:29 -0600
|
||||
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
|
||||
index deed77a3d44bc55681483d7f47f148b5220135f2..053cb78362006a94ee0d82b9b1f665c5f86a4458 100644
|
||||
index 7cacc61fed0c610845c67894d1cc68e44f5e46fe..4186b9558cbf6799e8491443b9ed5a2c9063ab7c 100644
|
||||
--- a/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;
|
||||
import net.minecraft.nbt.NbtUtils;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.level.block.entity.SkullBlockEntity;
|
||||
@@ -6,6 +6,9 @@ import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import com.destroystokyo.paper.profile.CraftPlayerProfile;
|
||||
import com.destroystokyo.paper.profile.PlayerProfile;
|
||||
+// Scissors start
|
||||
+import org.apache.commons.lang3.StringUtils;
|
||||
+// Scissors end
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
@@ -73,7 +76,9 @@ class CraftMetaSkull extends CraftMetaItem implements SkullMeta {
|
||||
import org.bukkit.OfflinePlayer;
|
||||
@@ -47,7 +50,9 @@ class CraftMetaSkull extends CraftMetaItem implements SkullMeta {
|
||||
|
||||
if (tag.contains(SKULL_OWNER.NBT, CraftMagicNumbers.NBT.TAG_COMPOUND)) {
|
||||
this.setProfile(NbtUtils.readGameProfile(tag.getCompound(SKULL_OWNER.NBT)));
|
||||
@ -28,4 +28,4 @@ index deed77a3d44bc55681483d7f47f148b5220135f2..053cb78362006a94ee0d82b9b1f665c5
|
||||
+ // Scissors end
|
||||
this.setProfile(new GameProfile(null, tag.getString(SKULL_OWNER.NBT)));
|
||||
}
|
||||
|
||||
}
|
@ -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
|
||||
index 41c9f074203915c31c1ae7a160ce509c13383f84..79a7fff759f062b783a540079cb43f2942799715 100644
|
||||
index 8484e80a70129fb0358d56efab6fd54798b54e6e..90fce5d2178672608f3ae97277cafe740a9ebead 100644
|
||||
--- a/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;
|
||||
@ -16,7 +16,7 @@ index 41c9f074203915c31c1ae7a160ce509c13383f84..79a7fff759f062b783a540079cb43f29
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.tags.BlockTags;
|
||||
@@ -370,6 +371,13 @@ public class BeehiveBlockEntity extends BlockEntity {
|
||||
@@ -351,6 +352,13 @@ public class BeehiveBlockEntity extends BlockEntity {
|
||||
|
||||
for (int i = 0; i < nbttaglist.size(); ++i) {
|
||||
CompoundTag nbttagcompound1 = nbttaglist.getCompound(i);
|
||||
|
@ -0,0 +1,46 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Video <videogamesm12@gmail.com>
|
||||
Date: Sun, 13 Mar 2022 07:39:26 -0600
|
||||
Subject: [PATCH] Fixes invalid LootTables causing problems when applied to
|
||||
Minecart entities
|
||||
|
||||
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/loottable/PaperMinecartLootableInventory.java b/src/main/java/com/destroystokyo/paper/loottable/PaperMinecartLootableInventory.java
|
||||
index 83dd3c254fd10e4596e454cc75c8e5e976b73ac0..1b2533bbbc62bcb0d00789312ba72a49f8f49f42 100644
|
||||
--- a/src/main/java/com/destroystokyo/paper/loottable/PaperMinecartLootableInventory.java
|
||||
+++ b/src/main/java/com/destroystokyo/paper/loottable/PaperMinecartLootableInventory.java
|
||||
@@ -16,7 +16,7 @@ public class PaperMinecartLootableInventory implements PaperLootableEntityInvent
|
||||
|
||||
@Override
|
||||
public org.bukkit.loot.LootTable getLootTable() {
|
||||
- return entity.lootTable != null && !entity.lootTable.getPath().isEmpty() ? Bukkit.getLootTable(CraftNamespacedKey.fromMinecraft(entity.lootTable)) : null;
|
||||
+ 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
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/loottable/PaperTileEntityLootableInventory.java b/src/main/java/com/destroystokyo/paper/loottable/PaperTileEntityLootableInventory.java
|
||||
index 94dc68182ec5f6dc1294ad15523427836228086a..07075cea760562c901d4469a7f88271c3ffa30bb 100644
|
||||
--- a/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
|
||||
|
||||
@Override
|
||||
public org.bukkit.loot.LootTable getLootTable() {
|
||||
- return tileEntityLootable.lootTable != null && !tileEntityLootable.lootTable.getPath().isEmpty() ? Bukkit.getLootTable(CraftNamespacedKey.fromMinecraft(tileEntityLootable.lootTable)) : null;
|
||||
+ return tileEntityLootable.lootTable != null && !tileEntityLootable.lootTable.getPath().isEmpty() && tileEntityLootable.lootTable.toString().length() < 256 ? Bukkit.getLootTable(CraftNamespacedKey.fromMinecraft(tileEntityLootable.lootTable)) : null; // Scissors - Validate length of loot tables before even trying
|
||||
}
|
||||
|
||||
@Override
|
||||
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 f57864ce919ef4721cfb5913c636fe8903ce4cc1..d80c7be5b153db4046d0b11c0116c6aa860ea48c 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java
|
||||
@@ -219,7 +219,7 @@ public abstract class AbstractMinecartContainer extends AbstractMinecart impleme
|
||||
this.lootableData.loadNbt(nbt); // Paper
|
||||
this.itemStacks = NonNullList.withSize(this.getContainerSize(), ItemStack.EMPTY);
|
||||
if (nbt.contains("LootTable", 8)) {
|
||||
- this.lootTable = new ResourceLocation(nbt.getString("LootTable"));
|
||||
+ this.lootTable = ResourceLocation.tryParse(nbt.getString("LootTable")); // Scissors - Validate loot tables
|
||||
this.lootTableSeed = nbt.getLong("LootTableSeed");
|
||||
} if (true) { // Paper - always load the items, table may still remain
|
||||
ContainerHelper.loadAllItems(nbt, this.itemStacks);
|
@ -1,14 +1,23 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
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
|
||||
|
||||
|
||||
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 c88ab49f60857d5687facc8523f9edc4d652c81b..2e3220cbbea5f6cb9acb7f8fbaf2ff8f91b09234 100644
|
||||
--- a/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 {
|
||||
@@ -1758,7 +1758,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
||||
try {
|
||||
blockParser = blockParser.parse(false);
|
||||
} catch (com.mojang.brigadier.exceptions.CommandSyntaxException e) {
|
||||
- e.printStackTrace();
|
||||
+ // Scissors - Don't log errors thrown by Brigadier when an error is thrown
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1782,8 +1782,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
||||
resource = CraftNamespacedKey.fromMinecraft(key);
|
||||
}
|
||||
} catch (IllegalArgumentException ex) {
|
||||
|
@ -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,22 +1,22 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Telesphoreo <me@telesphoreo.me>
|
||||
Date: Thu, 8 Jun 2023 19:19:37 -0500
|
||||
From: Video <videogamesm12@gmail.com>
|
||||
Date: Sun, 13 Mar 2022 08:14:44 -0600
|
||||
Subject: [PATCH] Ignore errors thrown when trying to remove minecart entities
|
||||
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
|
||||
index 272095d7a09ab41227d741172735f66fd2798ce1..ea966ea94062be3ed9b6b2c460a316378c016fa7 100644
|
||||
index d80c7be5b153db4046d0b11c0116c6aa860ea48c..dfbae9ca58722c0aeb6cb9888643016d4cb36f63 100644
|
||||
--- a/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
|
||||
public void remove(Entity.RemovalReason reason) {
|
||||
if (!this.level().isClientSide && reason.shouldDestroy()) {
|
||||
- Containers.dropContents(this.level(), (Entity) this, (Container) this);
|
||||
if (!this.level.isClientSide && reason.shouldDestroy()) {
|
||||
- Containers.dropContents(this.level, this, this);
|
||||
+ // Scissors start - Ignore errors thrown when trying to remove minecart entities with content in them
|
||||
+ try {
|
||||
+ Containers.dropContents(this.level(), (Entity) this, (Container) this);
|
||||
+ Containers.dropContents(this.level, this, this);
|
||||
+ } catch (Exception ignored) {
|
||||
+ }
|
||||
+ // 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
|
||||
index 3d41dbe0285f8fec8adae1e93010cf464df9b08c..7ee2c5beaaca9deb61589074f55e4004d1dd76b5 100644
|
||||
index 063f3e4c67e6716c9a03dbe4b72eafd32e4f0d53..03b8cc0ae12f17cf3a1c57958cf10ca23750b92a 100644
|
||||
--- a/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 {
|
||||
@@ -377,11 +377,14 @@ public class ItemEntity extends Entity {
|
||||
|
||||
CompoundTag nbttagcompound1 = nbt.getCompound("Item");
|
||||
|
||||
- this.setItem(ItemStack.of(nbttagcompound1));
|
||||
- if (this.getItem().isEmpty()) {
|
||||
+ // Scissors start
|
||||
+ ItemStack item = ItemStack.of(nbttagcompound1);
|
||||
+ if (item.isEmpty()) {
|
||||
if (this.getItem().isEmpty()) {
|
||||
this.discard();
|
||||
+ return;
|
||||
}
|
||||
|
||||
+ this.setItem(item);
|
||||
+ this.setItem(ItemStack.of(nbttagcompound1));
|
||||
+ // Scissors end
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ Subject: [PATCH] Fixes Knowledge Books causing log spam when invalid data is
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/item/KnowledgeBookItem.java b/src/main/java/net/minecraft/world/item/KnowledgeBookItem.java
|
||||
index b79f4ce38a42e4dba8ebdfc97dadc531b7245c7a..9c49be7c53a1f2a8c203341b8ded9cd222d0c178 100644
|
||||
index bb5319afd112f1013445e29e9fcad137d4c581f9..1cd62752e675b91fdcc21733509c95d5bd97625a 100644
|
||||
--- a/src/main/java/net/minecraft/world/item/KnowledgeBookItem.java
|
||||
+++ b/src/main/java/net/minecraft/world/item/KnowledgeBookItem.java
|
||||
@@ -40,9 +40,9 @@ public class KnowledgeBookItem extends Item {
|
||||
@ -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
|
||||
index 50fdb086ffec84edc5138737c95f08ed4757a6f3..bb0f673a619810850df0d78bb4abd9d7c49ecbe4 100644
|
||||
index e816e505cd292d6c5138dff0aeae0e9592c09de0..0f6438dfe0a6620eb87233b9eefbe2340dfc347b 100644
|
||||
--- a/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++) {
|
||||
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 dca8853944832e8fc5a291aa6b46d84b24181ea7..24f009fa3b84323b4c43e0ed15c224d16a7ede81 100644
|
||||
--- a/src/main/java/net/minecraft/nbt/NbtUtils.java
|
||||
+++ b/src/main/java/net/minecraft/nbt/NbtUtils.java
|
||||
@@ -230,7 +230,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 52e4948fd1657fa1776ac6b0142e8c21e7567976..a811b97021e2eed6efc592bc33602a270feb75a0 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java
|
||||
@@ -536,7 +536,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"));
|
@ -1,54 +1,54 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Telesphoreo <me@telesphoreo.me>
|
||||
Date: Sat, 10 Dec 2022 23:02:48 -0600
|
||||
From: Video <videogamesm12@gmail.com>
|
||||
Date: Mon, 14 Mar 2022 00:49:35 -0600
|
||||
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
|
||||
index db3cddf8b227453c9b08e481b21101c5d2e0472d..77ae3bc5fd6cf34aae7bd3baa563f3e23e57de26 100644
|
||||
index 4733f74ff028c03a60b73280caf9e4d1e2f0ca30..02172fdcf587904258387d309938fb379a300524 100644
|
||||
--- a/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) {
|
||||
- this.setPotion(BuiltInRegistries.POTION.get(new ResourceLocation(string)));
|
||||
+ this.setPotion(BuiltInRegistries.POTION.get(ResourceLocation.tryParse(string))); // Scissors - Validate resource locations
|
||||
public void setType(String string) {
|
||||
- this.setPotion(Registry.POTION.get(new ResourceLocation(string)));
|
||||
+ this.setPotion(Registry.POTION.get(ResourceLocation.tryParse(string))); // Scissors - Validate resource locations
|
||||
}
|
||||
// CraftBukkit end
|
||||
|
||||
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 1c446dba5de89698397041ee38a2e1a00bec8a56..93799eda06c7b699580251f80b641c47643f3615 100644
|
||||
--- a/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
|
||||
@@ -513,7 +513,7 @@ public class EntityType<T extends Entity> implements EntityTypeTest<Entity, T> {
|
||||
}), (entity) -> {
|
||||
entity.load(nbt);
|
||||
}, () -> {
|
||||
- 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
|
||||
@@ -537,7 +537,7 @@ public class EntityType<T extends Entity> implements EntityTypeTest<Entity, T> {
|
||||
}
|
||||
|
||||
public static Optional<EntityType<?>> by(CompoundTag nbt) {
|
||||
- return BuiltInRegistries.ENTITY_TYPE.getOptional(new ResourceLocation(nbt.getString("id")));
|
||||
+ return BuiltInRegistries.ENTITY_TYPE.getOptional(ResourceLocation.tryParse(nbt.getString("id")));
|
||||
- return Registry.ENTITY_TYPE.getOptional(new ResourceLocation(nbt.getString("id")));
|
||||
+ return Registry.ENTITY_TYPE.getOptional(ResourceLocation.tryParse(nbt.getString("id"))); // Scissors - Validate resource locations
|
||||
}
|
||||
|
||||
@Nullable
|
||||
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 8837fc04a67a656d0e780965ac113d3b28e2369f..11427668a0af28cf638df3574357f696f49af13d 100644
|
||||
--- a/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 {
|
||||
@@ -570,7 +570,7 @@ public abstract class Mob extends LivingEntity {
|
||||
|
||||
this.setLeftHanded(nbt.getBoolean("LeftHanded"));
|
||||
if (nbt.contains("DeathLootTable", 8)) {
|
||||
- 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");
|
||||
}
|
||||
|
@ -1,16 +1,16 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Video <videogamesm12@gmail.com>
|
||||
Date: Mon, 9 May 2022 23:40:59 -0500
|
||||
Date: Sun, 20 Mar 2022 03:04:33 -0600
|
||||
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
|
||||
index fa724cd34a7c469ca12068e64295cd00ad215a3c..168b60fda38a7172f4473017ccc42447b36faab2 100644
|
||||
index 02172fdcf587904258387d309938fb379a300524..3c60094119a2b51d5fbab6c559c43293913f6204 100644
|
||||
--- a/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 {
|
||||
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) {
|
||||
- AreaEffectCloud.LOGGER.warn("Couldn't load custom particle {}", nbt.getString("Particle"), commandsyntaxexception);
|
||||
+ // Scissors - Don't log custom particle errors
|
||||
@ -60,22 +60,18 @@ index 0dd0ce9a9b3253e87eda12354249ec2fd2a33cf2..b6920f9432ca1736afbe775186fbbcf1
|
||||
|
||||
@Override
|
||||
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 5a43e420f14fa52d71d41ff3694a179e7a1a5be3..488ccdeb867dcd3aaae4bce77da8b7a11d07eddc 100644
|
||||
--- a/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 {
|
||||
@@ -67,8 +67,14 @@ public abstract class CraftMob extends CraftLivingEntity implements Mob {
|
||||
this.getHandle().lootTable = this.getHandle().getDefaultLootTable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public LootTable getLootTable() {
|
||||
- NamespacedKey key = CraftNamespacedKey.fromMinecraft(this.getHandle().getLootTable());
|
||||
- NamespacedKey key = CraftNamespacedKey.fromMinecraft(this.getHandle().lootTable);
|
||||
- return Bukkit.getLootTable(key);
|
||||
+ if (this.getHandle().lootTable == null) {
|
||||
+ this.getHandle().lootTable = this.getHandle().getDefaultLootTable();
|
||||
+ }
|
||||
+
|
||||
+ // Scissors start - Return a null loot table if the specified loot table is not valid
|
||||
+ try {
|
||||
+ NamespacedKey key = CraftNamespacedKey.fromMinecraft(this.getHandle().getLootTable());
|
||||
+ NamespacedKey key = CraftNamespacedKey.fromMinecraft(this.getHandle().lootTable);
|
||||
+ return Bukkit.getLootTable(key);
|
||||
+ } catch (Exception ex) {
|
||||
+ return null;
|
@ -0,0 +1,28 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Video <videogamesm12@gmail.com>
|
||||
Date: Sun, 20 Mar 2022 04:39:09 -0600
|
||||
Subject: [PATCH] Fixes crash exploit related to out of bounds Axolotl variants
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/animal/axolotl/Axolotl.java b/src/main/java/net/minecraft/world/entity/animal/axolotl/Axolotl.java
|
||||
index 2b8725087fd3bfeca7162bda2783fdacd13a8390..802c9c87df190dce09f9e703cedcb06874c58389 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/animal/axolotl/Axolotl.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/animal/axolotl/Axolotl.java
|
||||
@@ -118,7 +118,7 @@ public class Axolotl extends Animal implements LerpingModel, Bucketable {
|
||||
@Override
|
||||
public void readAdditionalSaveData(CompoundTag nbt) {
|
||||
super.readAdditionalSaveData(nbt);
|
||||
- this.setVariant(Axolotl.Variant.BY_ID[nbt.getInt("Variant")]);
|
||||
+ this.setVariant(Axolotl.Variant.BY_ID[Math.min(Math.abs(nbt.getInt("Variant")), 4)]); // Scissors - Fixes out of bounds Axolotl variant exploit
|
||||
this.setFromBucket(nbt.getBoolean("FromBucket"));
|
||||
}
|
||||
|
||||
@@ -361,7 +361,7 @@ public class Axolotl extends Animal implements LerpingModel, Bucketable {
|
||||
@Override
|
||||
public void loadFromBucketTag(CompoundTag nbt) {
|
||||
Bucketable.loadDefaultDataFromBucketTag(this, nbt);
|
||||
- this.setVariant(Axolotl.Variant.BY_ID[nbt.getInt("Variant")]);
|
||||
+ this.setVariant(Axolotl.Variant.BY_ID[Math.min(Math.abs(nbt.getInt("Variant")), 4)]); // Scissors - Fix out-of-bounds Axolotl variant exploit
|
||||
if (nbt.contains("Age")) {
|
||||
this.setAge(nbt.getInt("Age"));
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Video <videogamesm12@gmail.com>
|
||||
Date: Sun, 20 Mar 2022 07:46:37 -0600
|
||||
Subject: [PATCH] Validate coordinates before attempting to get block entities
|
||||
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
|
||||
index 621ec8e8a197323da6b423fee57c816ac9d7c875..83333ae9c8e8c1edc6e7f02468bd8dc7e44bb66e 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -2933,20 +2933,24 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
||||
if (this.player.gameMode.isCreative()) {
|
||||
boolean flag = packet.getSlotNum() < 0;
|
||||
ItemStack itemstack = packet.getItem();
|
||||
- CompoundTag nbttagcompound = itemstack.getTagElement("BlockEntityTag");
|
||||
|
||||
+ CompoundTag nbttagcompound = itemstack.getTagElement("BlockEntityTag");
|
||||
if (!itemstack.isEmpty() && nbttagcompound != null && nbttagcompound.contains("x") && nbttagcompound.contains("y") && nbttagcompound.contains("z") && this.player.getBukkitEntity().hasPermission("minecraft.nbt.copy")) { // Spigot
|
||||
BlockPos blockposition = new BlockPos(nbttagcompound.getInt("x"), nbttagcompound.getInt("y"), nbttagcompound.getInt("z"));
|
||||
- BlockEntity tileentity = this.player.level.getBlockEntity(blockposition);
|
||||
+ // Scissors start - Validate coordinates and whether or not the player can reach them
|
||||
+ if (Level.isInSpawnableBounds(blockposition) && !isOutsideOfReach(blockposition.getX(), blockposition.getY(), blockposition.getZ())) {
|
||||
+ BlockEntity tileentity = this.player.level.getBlockEntity(blockposition);
|
||||
|
||||
- if (tileentity != null) {
|
||||
- CompoundTag nbttagcompound1 = tileentity.save(new CompoundTag());
|
||||
+ if (tileentity != null) {
|
||||
+ CompoundTag nbttagcompound1 = tileentity.save(new CompoundTag());
|
||||
|
||||
- nbttagcompound1.remove("x");
|
||||
- nbttagcompound1.remove("y");
|
||||
- nbttagcompound1.remove("z");
|
||||
- itemstack.addTagElement("BlockEntityTag", (Tag) nbttagcompound1);
|
||||
+ nbttagcompound1.remove("x");
|
||||
+ nbttagcompound1.remove("y");
|
||||
+ nbttagcompound1.remove("z");
|
||||
+ itemstack.addTagElement("BlockEntityTag", (Tag) nbttagcompound1);
|
||||
+ }
|
||||
}
|
||||
+ // Scissors end
|
||||
}
|
||||
|
||||
boolean flag1 = packet.getSlotNum() >= 1 && packet.getSlotNum() <= 45;
|
@ -5,10 +5,10 @@ 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
|
||||
index c0633f9553fb5aa52e8ffc863159521d09cb3bd5..7449a024265c42f28a6c9a1ed8d8f4b9e3096aac 100644
|
||||
index c5711b3d120699ec78f81e9b6ee80d0764552e94..9c1341803cf892f7f3af11381bd56bc95f31fad0 100644
|
||||
--- a/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 {
|
||||
@@ -315,7 +315,7 @@ public class HoverEvent {
|
||||
CompoundTag compoundTag = TagParser.parseTag(string);
|
||||
return new HoverEvent.ItemStackInfo(item, i, compoundTag);
|
||||
} catch (CommandSyntaxException var6) {
|
||||
@ -17,7 +17,7 @@ index c0633f9553fb5aa52e8ffc863159521d09cb3bd5..7449a024265c42f28a6c9a1ed8d8f4b9
|
||||
}
|
||||
}
|
||||
|
||||
@@ -328,7 +328,7 @@ public class HoverEvent {
|
||||
@@ -329,7 +329,7 @@ public class HoverEvent {
|
||||
CompoundTag compoundTag = TagParser.parseTag(text.getString());
|
||||
return new HoverEvent.ItemStackInfo(ItemStack.of(compoundTag));
|
||||
} catch (CommandSyntaxException var2) {
|
||||
@ -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
|
||||
index 955316687e2e29ad75a0052317a7b0f89034c82a..2537c48d1269d8ea51222412b2eeaac26a7dc4d4 100644
|
||||
index b829efdb40051a41b3bf1cabb8bf7d7c952797b5..a0f20bd54f713afe17c9b5fea9fdee6c59b6e219 100644
|
||||
--- a/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 {
|
||||
@@ -388,7 +388,7 @@ public class ItemFrame extends HangingEntity {
|
||||
ItemStack itemstack = ItemStack.of(nbttagcompound1);
|
||||
|
||||
if (itemstack.isEmpty()) {
|
@ -1,33 +1,28 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
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
|
||||
|
||||
|
||||
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 ece77f5ea4b14bbed7c070131b3251ea86764538..74e5c5194580c6b65f3b4e657237fef7ef005ec2 100644
|
||||
--- a/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.io.Resources;
|
||||
import com.google.gson.*;
|
||||
+import io.papermc.paper.util.JarManifests;
|
||||
+import java.util.Map;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.event.ClickEvent;
|
||||
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;
|
||||
|
||||
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 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 DOWNLOAD_PAGE = "https://ci.scissors.gg/job/Scissors/job/" + GITHUB_BRANCH_NAME;
|
||||
private static @Nullable String mcVer;
|
||||
@ -50,13 +45,13 @@ index 9d687da5bdf398bb3f6c84cdf1249a7213d09f2e..0a8fda6939152d393f07e5d2812409ad
|
||||
|
||||
+ // Scissors start - Allow getting git information
|
||||
+ public static String getCommit() {
|
||||
+ final var manifest = JarManifests.manifest(Bukkit.getServer().getClass());
|
||||
+ return manifest == null ? null : manifest.getMainAttributes().getValue("Git-Commit");
|
||||
+ Map<String, String> attributes = JarManifests.MANIFEST_MAP;
|
||||
+ return attributes.get("Git-Commit");
|
||||
+ }
|
||||
+
|
||||
+ public static String getBranch() {
|
||||
+ final var manifest = JarManifests.manifest(Bukkit.getServer().getClass());
|
||||
+ return manifest == null ? null : manifest.getMainAttributes().getValue("Git-Branch");
|
||||
+ Map<String, String> attributes = JarManifests.MANIFEST_MAP;
|
||||
+ return attributes.get("Git-Branch");
|
||||
+ }
|
||||
+ // Scissors end
|
||||
+
|
||||
@ -77,14 +72,14 @@ index 9d687da5bdf398bb3f6c84cdf1249a7213d09f2e..0a8fda6939152d393f07e5d2812409ad
|
||||
switch (distance) {
|
||||
case -1:
|
||||
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 22e9dd17f62103c5061435099ce96a3d70d54808..d033caf5dabbd2a240286c5623b3d287ae5cbdd9 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/Main.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/Main.java
|
||||
@@ -292,7 +292,7 @@ public class Main {
|
||||
@@ -269,7 +269,7 @@ public class Main {
|
||||
if (buildDate.before(deadline.getTime())) {
|
||||
// Paper start - This is some stupid bullshit
|
||||
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("*** Server will start in 20 seconds ***");
|
||||
//Thread.sleep(TimeUnit.SECONDS.toMillis(20));
|
@ -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();
|
||||
}
|
@ -1,23 +1,24 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Telesphoreo <me@telesphoreo.me>
|
||||
Date: Sat, 10 Dec 2022 23:48:28 -0600
|
||||
From: Video <videogamesm12@gmail.com>
|
||||
Date: Mon, 28 Mar 2022 13:19:43 -0600
|
||||
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
|
||||
index 37fc353c3e59dd5af2fd6c58ac084fb0e6e155d7..3c0ee4e1f42f6056ca86a6f9f129d467e29a2fbc 100644
|
||||
index 5ba1636bbb938373e43c1f3ac561368fc9cffd43..6978d14c6bd90ffb640e39e8666430d95d5ef45c 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;
|
||||
@@ -24,6 +24,8 @@ import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Optional;
|
||||
import javax.annotation.Nullable;
|
||||
+
|
||||
+import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.network.chat.contents.BlockDataSource;
|
||||
import net.minecraft.network.chat.contents.DataSource;
|
||||
@@ -522,6 +523,26 @@ public interface Component extends Message, FormattedText, Iterable<Component> {
|
||||
return GsonHelper.toStableString(Serializer.toJsonTree(text));
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.FormattedCharSequence;
|
||||
@@ -427,6 +429,26 @@ public interface Component extends Message, FormattedText, Iterable<Component> {
|
||||
return Component.Serializer.GSON.toJsonTree(text);
|
||||
}
|
||||
|
||||
+ // Scissors start
|
||||
@ -26,7 +27,7 @@ index 37fc353c3e59dd5af2fd6c58ac084fb0e6e155d7..3c0ee4e1f42f6056ca86a6f9f129d467
|
||||
+ try {
|
||||
+ return fromJson(json);
|
||||
+ } catch (Exception ex) {
|
||||
+ return Component.empty().append("** Invalid JSON Component **").withStyle(ChatFormatting.RED);
|
||||
+ return new TextComponent("** Invalid JSON Component **").withStyle(ChatFormatting.RED);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
@ -35,19 +36,19 @@ index 37fc353c3e59dd5af2fd6c58ac084fb0e6e155d7..3c0ee4e1f42f6056ca86a6f9f129d467
|
||||
+ try {
|
||||
+ return fromJson(json);
|
||||
+ } catch (Exception ex) {
|
||||
+ return Component.empty().append("** Invalid JSON Component **").withStyle(ChatFormatting.RED);
|
||||
+ return new TextComponent("** Invalid JSON Component **").withStyle(ChatFormatting.RED);
|
||||
+ }
|
||||
+ }
|
||||
+ // Scissors end
|
||||
+
|
||||
public static JsonElement toJsonTree(Component text) {
|
||||
return Component.Serializer.GSON.toJsonTree(text);
|
||||
}
|
||||
@Nullable
|
||||
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
|
||||
index 7449a024265c42f28a6c9a1ed8d8f4b9e3096aac..487c68abc3eb5c18dc7fee762b2164001283cab7 100644
|
||||
index 9c1341803cf892f7f3af11381bd56bc95f31fad0..c4394812326bccd70d64b4bd45eb1bb7b53b0905 100644
|
||||
--- a/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 {
|
||||
@@ -80,7 +80,7 @@ public class HoverEvent {
|
||||
if (jsonElement != null) {
|
||||
return action.deserialize(jsonElement);
|
||||
} else {
|
||||
@ -56,7 +57,7 @@ index 7449a024265c42f28a6c9a1ed8d8f4b9e3096aac..487c68abc3eb5c18dc7fee762b216400
|
||||
return component != null ? action.deserializeFromLegacy(component) : null;
|
||||
}
|
||||
}
|
||||
@@ -94,7 +94,7 @@ public class HoverEvent {
|
||||
@@ -95,7 +95,7 @@ public class HoverEvent {
|
||||
}
|
||||
|
||||
public static class Action<T> {
|
||||
@ -65,7 +66,7 @@ index 7449a024265c42f28a6c9a1ed8d8f4b9e3096aac..487c68abc3eb5c18dc7fee762b216400
|
||||
public static final HoverEvent.Action<HoverEvent.ItemStackInfo> SHOW_ITEM = new HoverEvent.Action<>("show_item", true, HoverEvent.ItemStackInfo::create, HoverEvent.ItemStackInfo::serialize, HoverEvent.ItemStackInfo::create);
|
||||
public static final HoverEvent.Action<HoverEvent.EntityTooltipInfo> SHOW_ENTITY = new HoverEvent.Action<>("show_entity", true, HoverEvent.EntityTooltipInfo::create, HoverEvent.EntityTooltipInfo::serialize, HoverEvent.EntityTooltipInfo::create);
|
||||
private static final Map<String, HoverEvent.Action<?>> LOOKUP = Stream.of(SHOW_TEXT, SHOW_ITEM, SHOW_ENTITY).collect(ImmutableMap.toImmutableMap(HoverEvent.Action::getName, (action) -> {
|
||||
@@ -182,7 +182,7 @@ public class HoverEvent {
|
||||
@@ -183,7 +183,7 @@ public class HoverEvent {
|
||||
return null;
|
||||
}
|
||||
// Scissors end
|
||||
@ -74,46 +75,50 @@ index 7449a024265c42f28a6c9a1ed8d8f4b9e3096aac..487c68abc3eb5c18dc7fee762b216400
|
||||
return new HoverEvent.EntityTooltipInfo(entityType, uUID, component);
|
||||
}
|
||||
}
|
||||
@@ -191,7 +191,7 @@ public class HoverEvent {
|
||||
@@ -192,7 +192,7 @@ public class HoverEvent {
|
||||
public static HoverEvent.EntityTooltipInfo create(Component text) {
|
||||
try {
|
||||
CompoundTag compoundTag = TagParser.parseTag(text.getString());
|
||||
- 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
|
||||
EntityType<?> entityType = BuiltInRegistries.ENTITY_TYPE.get(new ResourceLocation(compoundTag.getString("type")));
|
||||
EntityType<?> entityType = Registry.ENTITY_TYPE.get(new ResourceLocation(compoundTag.getString("type")));
|
||||
// Scissors start
|
||||
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
|
||||
index 97a2657bc98d41c3c1e376b266d2c85f685acc88..7b6476455e095eed15c92797ce3a3e1146dbdc3f 100644
|
||||
--- a/src/main/java/net/minecraft/network/chat/contents/NbtContents.java
|
||||
+++ b/src/main/java/net/minecraft/network/chat/contents/NbtContents.java
|
||||
@@ -8,6 +8,7 @@ import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
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 {
|
||||
diff --git a/src/main/java/net/minecraft/network/chat/NbtComponent.java b/src/main/java/net/minecraft/network/chat/NbtComponent.java
|
||||
index ae9fef071388bc6b10d34a0126c9dd1ac77eb9e7..f5f2ec1192303bc55a64dce3e0457e4531a35ba7 100644
|
||||
--- a/src/main/java/net/minecraft/network/chat/NbtComponent.java
|
||||
+++ b/src/main/java/net/minecraft/network/chat/NbtComponent.java
|
||||
@@ -77,13 +77,14 @@ public abstract class NbtComponent extends BaseComponent implements ContextAware
|
||||
if (this.interpreting) {
|
||||
Component component = DataFixUtils.orElse(ComponentUtils.updateForEntity(source, this.separator, sender, depth), ComponentUtils.DEFAULT_NO_STYLE_SEPARATOR);
|
||||
return stream.flatMap((text) -> {
|
||||
+ // Scissors start - Use safer method for getting Components from JSON
|
||||
try {
|
||||
- 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));
|
||||
} catch (Exception var5) {
|
||||
- LOGGER.warn("Failed to parse component: {}", text, var5);
|
||||
+ // Scissors - don't log
|
||||
+ // LOGGER.warn("Failed to parse component: {}", text, var5);
|
||||
return Stream.of();
|
||||
}
|
||||
+ // Scissors end
|
||||
}).reduce((accumulator, current) -> {
|
||||
return accumulator.append(component).append(current);
|
||||
}).orElseGet(() -> {
|
||||
@@ -94,7 +95,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
|
||||
index 92202262eff01ae3bbeff0e6ebdcf26ad613c169..38c027c0fbddf58136b7d67eb7156403a79de4d1 100644
|
||||
index b7c4700fd5db14c77e7ee78311dd77a754d9d41c..07f04c1708b118ace3ed73ae2bf88c29b1c80ad2 100644
|
||||
--- a/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 {
|
||||
@@ -2202,12 +2202,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, n
|
||||
this.setRot(this.getYRot(), this.getXRot());
|
||||
if (nbt.contains("CustomName", 8)) {
|
||||
String s = nbt.getString("CustomName");
|
||||
@ -128,45 +133,45 @@ index 92202262eff01ae3bbeff0e6ebdcf26ad613c169..38c027c0fbddf58136b7d67eb7156403
|
||||
|
||||
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
|
||||
index 59246e24558569f7f50b4d4d508616798091c888..5005a0ad5f703727ea9c618ae4b769a77d5655b5 100644
|
||||
index 3281448bf37da8a1b4b7b44f10f4b2438b4a4f29..8038e3a10b563321df1e8cedd26b256078ce745a 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
|
||||
@@ -410,7 +410,7 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider, Name
|
||||
@@ -405,7 +405,7 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider {
|
||||
this.levels = nbt.getInt("Levels"); // SPIGOT-5053, use where available
|
||||
// CraftBukkit end
|
||||
if (nbt.contains("CustomName", 8)) {
|
||||
- this.name = io.papermc.paper.util.MCUtil.getBaseComponentFromNbt("CustomName", nbt); // Paper - Catch ParseException
|
||||
- this.name = Component.Serializer.fromJson(nbt.getString("CustomName"));
|
||||
+ this.name = Component.Serializer.fromJsonSafe(nbt.getString("CustomName")); // Scissors - Use safer method for getting Components from JSON
|
||||
}
|
||||
|
||||
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
|
||||
index 65e1381bb2d10bd212463feb602c60f8fdb9ade1..3e23451066894ebd88cad7022970cb2c0e9b75db 100644
|
||||
index 40ac65501a0213b43964fd68eb155d4358fb7fd4..9cfc44472e841e1a2cd7de2a1284afdde05a7989 100644
|
||||
--- a/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
|
||||
@@ -44,7 +44,7 @@ public class EnchantmentTableBlockEntity extends BlockEntity implements Nameable
|
||||
public void load(CompoundTag nbt) {
|
||||
super.load(nbt);
|
||||
if (nbt.contains("CustomName", 8)) {
|
||||
- this.name = io.papermc.paper.util.MCUtil.getBaseComponentFromNbt("CustomName", nbt); // Paper - Catch ParseException
|
||||
- this.name = Component.Serializer.fromJson(nbt.getString("CustomName"));
|
||||
+ 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
|
||||
index 2be7a697f08045b974579e6942b38571e744efac..84ec21c38bb44db1e9ff26c01d5c8af1a2417616 100644
|
||||
index 2153e7035535990b5307b85d8bc3dab50c0a3ae8..5f11f9b77684bd91b4cfe77cd415ed42bd9bc21a 100644
|
||||
--- a/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 {
|
||||
CompoundTag compoundTag = nbt.getCompound(i);
|
||||
String string = compoundTag.getString("Name");
|
||||
@@ -39,7 +39,7 @@ public class ScoreboardSaveData extends SavedData {
|
||||
}
|
||||
|
||||
PlayerTeam playerTeam = this.scoreboard.addPlayerTeam(string);
|
||||
- Component component = Component.Serializer.fromJson(compoundTag.getString("DisplayName"));
|
||||
+ Component component = Component.Serializer.fromJsonSafe(compoundTag.getString("DisplayName")); // Scissors - Use safer method for getting Components from JSON
|
||||
if (component != null) {
|
||||
playerTeam.setDisplayName(component);
|
||||
}
|
||||
@@ -53,14 +53,14 @@ public class ScoreboardSaveData extends SavedData {
|
||||
@@ -57,14 +57,14 @@ public class ScoreboardSaveData extends SavedData {
|
||||
}
|
||||
|
||||
if (compoundTag.contains("MemberNamePrefix", 8)) {
|
||||
@ -183,12 +188,12 @@ index 2be7a697f08045b974579e6942b38571e744efac..84ec21c38bb44db1e9ff26c01d5c8af1
|
||||
if (component3 != null) {
|
||||
playerTeam.setPlayerSuffix(component3);
|
||||
}
|
||||
@@ -115,7 +115,7 @@ public class ScoreboardSaveData extends SavedData {
|
||||
CompoundTag compoundTag = nbt.getCompound(i);
|
||||
ObjectiveCriteria.byName(compoundTag.getString("CriteriaName")).ifPresent((criterion) -> {
|
||||
String string = compoundTag.getString("Name");
|
||||
@@ -123,7 +123,7 @@ public class ScoreboardSaveData extends SavedData {
|
||||
string = string.substring(0, 16);
|
||||
}
|
||||
|
||||
- Component component = Component.Serializer.fromJson(compoundTag.getString("DisplayName"));
|
||||
+ Component component = Component.Serializer.fromJsonSafe(compoundTag.getString("DisplayName")); // Scissors - Use safer method for getting Components from JSON
|
||||
ObjectiveCriteria.RenderType renderType = ObjectiveCriteria.RenderType.byId(compoundTag.getString("RenderType"));
|
||||
this.scoreboard.addObjective(string, criterion, component, renderType);
|
||||
this.scoreboard.addObjective(string, objectiveCriteria, component, renderType);
|
||||
});
|
165
patches/server/0019-Block-server-side-chunkbans.patch
Normal file
165
patches/server/0019-Block-server-side-chunkbans.patch
Normal file
@ -0,0 +1,165 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: ayunami2000 <spwilliamsiam@gmail.com>
|
||||
Date: Mon, 28 Mar 2022 17:02:21 -0400
|
||||
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 b039a32b805fc02033fa862a1c40c4a51639e69a..b2227f01bc90351a4a3f73fa835dd89bde15632e 100644
|
||||
--- a/src/main/java/net/minecraft/network/PacketEncoder.java
|
||||
+++ b/src/main/java/net/minecraft/network/PacketEncoder.java
|
||||
@@ -5,8 +5,22 @@ 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.protocol.Packet;
|
||||
import net.minecraft.network.protocol.PacketFlow;
|
||||
+import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket;
|
||||
+import net.minecraft.network.protocol.game.ClientboundChatPacket;
|
||||
+import net.minecraft.network.protocol.game.ClientboundContainerSetContentPacket;
|
||||
+import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket;
|
||||
+import net.minecraft.network.protocol.game.ClientboundLevelChunkPacket;
|
||||
+import net.minecraft.network.protocol.game.ClientboundMapItemDataPacket;
|
||||
+import net.minecraft.network.protocol.game.ClientboundSetEntityDataPacket;
|
||||
+import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket;
|
||||
+import net.minecraft.world.item.ItemStack;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.logging.log4j.Marker;
|
||||
@@ -21,6 +35,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
|
||||
+
|
||||
@Override
|
||||
protected void encode(ChannelHandlerContext channelHandlerContext, Packet<?> packet, ByteBuf byteBuf) throws Exception {
|
||||
ConnectionProtocol connectionProtocol = channelHandlerContext.channel().attr(Connection.ATTRIBUTE_PROTOCOL).get();
|
||||
@@ -36,35 +67,68 @@ public class PacketEncoder extends MessageToByteEncoder<Packet<?>> {
|
||||
throw new IOException("Can't serialize unregistered packet");
|
||||
} else {
|
||||
FriendlyByteBuf friendlyByteBuf = new FriendlyByteBuf(byteBuf);
|
||||
- friendlyByteBuf.writeVarInt(integer);
|
||||
- friendlyByteBuf.adventure$locale = channelHandlerContext.channel().attr(PaperAdventure.LOCALE_ATTRIBUTE).get(); // Paper
|
||||
-
|
||||
+ // Scissors start
|
||||
+ int k;
|
||||
try {
|
||||
- int i = friendlyByteBuf.writerIndex();
|
||||
- packet.write(friendlyByteBuf);
|
||||
- int j = friendlyByteBuf.writerIndex() - i;
|
||||
- if (j > 8388608) {
|
||||
- throw new IllegalArgumentException("Packet too big (is " + j + ", should be less than 8388608): " + packet);
|
||||
- }
|
||||
+ k = tryWrite(packet, friendlyByteBuf, channelHandlerContext, integer);
|
||||
} catch (Throwable var9) {
|
||||
- LOGGER.error("Packet encoding of packet ID {} threw (skippable? {})", integer, packet.isSkippable(), var9); // Paper - WHAT WAS IT? WHO DID THIS TO YOU? WHAT DID YOU SEE?
|
||||
- if (packet.isSkippable()) {
|
||||
- throw new SkipPacketException(var9);
|
||||
- } else {
|
||||
- throw var9;
|
||||
+ packet = capPacket(packet, integer);
|
||||
+ if (packet == null) {
|
||||
+ throw new SkipPacketException(new IllegalArgumentException("Packet too big: " + packet));
|
||||
}
|
||||
+ friendlyByteBuf.clear();
|
||||
+ k = tryWrite(packet, friendlyByteBuf, channelHandlerContext, integer);
|
||||
}
|
||||
-
|
||||
- // Paper start
|
||||
- int packetLength = friendlyByteBuf.readableBytes();
|
||||
- if (packetLength > MAX_PACKET_SIZE) {
|
||||
- throw new PacketTooLargeException(packet, packetLength);
|
||||
- }
|
||||
- // Paper end
|
||||
+ // 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 ClientboundLevelChunkPacket 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 ClientboundChatPacket chatPacket)
|
||||
+ {
|
||||
+ return null;
|
||||
+ }
|
||||
+ 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 = 2097152;
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacket.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacket.java
|
||||
index 60d72e488bc77cd913328be400ca374a873b4561..1af2260e7bab81fca24784172dd31e06e9adb1e1 100644
|
||||
--- a/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacket.java
|
||||
+++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacket.java
|
||||
@@ -50,6 +50,13 @@ public class ClientboundLevelChunkPacket implements Packet<ClientGamePacketListe
|
||||
}
|
||||
// Paper end
|
||||
|
||||
+ // Scissors start
|
||||
+ public void clearNBT() {
|
||||
+ this.blockEntitiesTags.clear();
|
||||
+ this.extraPackets.clear();
|
||||
+ }
|
||||
+ // Scissors end
|
||||
+
|
||||
// Paper start - Anti-Xray - Add chunk packet info
|
||||
@Deprecated public ClientboundLevelChunkPacket(LevelChunk chunk) { this(chunk, true); } // Notice for updates: Please make sure this constructor isn't used anywhere
|
||||
public ClientboundLevelChunkPacket(LevelChunk chunk, boolean modifyBlocks) {
|
@ -1,19 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Telesphoreo <me@telesphoreo.me>
|
||||
Date: Thu, 8 Jun 2023 19:24:05 -0500
|
||||
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
|
||||
index 67627bbf84f5aab2872f636b1dcb6728c8494147..468f64afb7e9b3ef579205d3beea025deb31b460 100644
|
||||
--- a/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 {
|
||||
|
||||
protected void tickDeath() {
|
||||
++this.deathTime;
|
||||
- if (this.deathTime >= 20 && !this.level().isClientSide() && !this.isRemoved()) {
|
||||
+ if ((this.deathTime >= 20 || this.deathTime <= 0) && !this.level().isClientSide() && !this.isRemoved()) {
|
||||
this.level().broadcastEntityEvent(this, (byte) 60);
|
||||
this.remove(Entity.RemovalReason.KILLED);
|
||||
}
|
@ -1,34 +1,36 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Telesphoreo <me@telesphoreo.me>
|
||||
Date: Fri, 25 Nov 2022 22:25:24 -0600
|
||||
From: Video <videogamesm12@gmail.com>
|
||||
Date: Mon, 28 Mar 2022 16:49:17 -0600
|
||||
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
|
||||
index 584a58659fae6ba3d8b53858890bc6ec509ffb0e..0dcee5b53740126e0886058dacc43e447836b8d8 100644
|
||||
index 8f4c83837d0b01a3dbca2607ea718c371db48ef4..fe2717679f84fbef1b8ff1f9a3c3bf0fba8965f1 100644
|
||||
--- a/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 {
|
||||
+ // Scissors start - Reject oversized components
|
||||
+ MutableComponent result;
|
||||
+
|
||||
if (depth > 100) {
|
||||
- return text.copy();
|
||||
+ result = text.copy();
|
||||
} else {
|
||||
// Paper start
|
||||
if (text instanceof io.papermc.paper.adventure.AdventureComponent adventureComponent) {
|
||||
@@ -53,8 +55,11 @@ public class ComponentUtils {
|
||||
MutableComponent mutableComponent = text instanceof ContextAwareComponent ? ((ContextAwareComponent)text).resolve(source, sender, depth + 1) : text.plainCopy();
|
||||
|
||||
@@ -46,8 +49,12 @@ public class ComponentUtils {
|
||||
mutableComponent.append(updateForEntity(source, component, sender, depth + 1));
|
||||
}
|
||||
|
||||
- return 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?
|
||||
+ return Component.Serializer.toJson(result).length() > 65535 ? Component.empty() : result;
|
||||
+ return Component.Serializer.toJson(result).length() > 65535 ? new TextComponent("") : result;
|
||||
+ // Scissors end
|
||||
}
|
||||
|
@ -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);
|
||||
+ }
|
||||
+ }
|
||||
+}
|
@ -6,20 +6,20 @@ 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
|
||||
index b87999106b5068a243c064fa3c30968411996e2b..596baf1bc372875b8b82904d9d5bd53f4bedc0fb 100644
|
||||
index 24f009fa3b84323b4c43e0ed15c224d16a7ede81..1d1876c78f82ce36d45320e4575c79fdc284ce0e 100644
|
||||
--- a/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 {
|
||||
}
|
||||
|
||||
// Paper start - support string UUID's
|
||||
if (nbt.contains("Id", 8)) {
|
||||
- uUID = UUID.fromString(nbt.getString("Id"));
|
||||
if (compound.contains("Id", 8)) {
|
||||
- uUID = UUID.fromString(compound.getString("Id"));
|
||||
+ // Scissors start - Validate String UUIDs in game profiles
|
||||
+ try {
|
||||
+ uUID = UUID.fromString(nbt.getString("Id"));
|
||||
+ uUID = UUID.fromString(compound.getString("Id"));
|
||||
+ } catch (Exception ignored) {
|
||||
+ }
|
||||
+ // Scissors end
|
||||
}
|
||||
// Paper end
|
||||
|
||||
if (compound.hasUUID("Id")) {
|
@ -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
|
||||
index af5a1111a06789e1401f8c60bb4c8838587f2376..bfcdc18f9b06023a5c461e06abbb93eea32bcdba 100644
|
||||
index 2e3220cbbea5f6cb9acb7f8fbaf2ff8f91b09234..3ea83a093f698a055566f45a7927c289ff9a6955 100644
|
||||
--- a/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;
|
||||
@@ -45,6 +45,7 @@ import net.minecraft.nbt.NbtIo;
|
||||
import net.minecraft.nbt.StringTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
+import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
+import net.minecraft.resources.ResourceLocation; // Scissors
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.commons.lang.Validate;
|
||||
@@ -485,7 +486,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
||||
@@ -481,7 +482,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
||||
AttributeModifier attribMod = CraftAttributeInstance.convert(nmsModifier);
|
||||
|
||||
String attributeName = CraftAttributeMap.convertIfNeeded(entry.getString(ATTRIBUTES_IDENTIFIER.NBT)); // Paper
|
@ -1,64 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Video <videogamesm12@gmail.com>
|
||||
Date: Wed, 27 Jul 2022 22:30:39 -0500
|
||||
Subject: [PATCH] Validate coordinates before attempting to get block entities
|
||||
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
|
||||
index 1288f651fa83d5ab99a88858f52a6d3212284df0..61f6b51b9d868ae6bd79185cc066976a094da8ce 100644
|
||||
--- a/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
|
||||
}
|
||||
// Spigot end
|
||||
|
||||
+ // Scissors start - Readd the following Paper code
|
||||
+ // 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
|
||||
BlockPos blockposition = BlockEntity.getPosFromTag(nbttagcompound);
|
||||
|
||||
- if (this.player.level().isLoaded(blockposition)) {
|
||||
- // Paper start
|
||||
- BlockEntity tileentity = null;
|
||||
- if (this.player.distanceToSqr(blockposition.getX(), blockposition.getY(), blockposition.getZ()) < 32 * 32 && this.player.serverLevel().isLoadedAndInBounds(blockposition)) {
|
||||
- tileentity = this.player.level().getBlockEntity(blockposition);
|
||||
- }
|
||||
- // 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;
|
||||
+ if (this.player.distanceToSqr(blockposition.getX(), blockposition.getY(), blockposition.getZ()) < 32 * 32 && this.player.serverLevel().isLoadedAndInBounds(blockposition))
|
||||
+ {
|
||||
+ tileentity = this.player.level().getBlockEntity(blockposition);
|
||||
+ }
|
||||
+ // Paper end
|
||||
|
||||
- if (tileentity != null) {
|
||||
- tileentity.saveToItem(itemstack);
|
||||
+ if (tileentity != null)
|
||||
+ {
|
||||
+ tileentity.saveToItem(itemstack);
|
||||
+ }
|
||||
}
|
||||
+ // Scissors end
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,95 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Business Goose <arclicious@vivaldi.net>
|
||||
Date: Mon, 4 Apr 2022 00:16:54 +0100
|
||||
Subject: [PATCH] Prevent abusable entities from being spawned by spawners
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/BaseSpawner.java b/src/main/java/net/minecraft/world/level/BaseSpawner.java
|
||||
index 569cef8fcb1e3e1e8b66dad4fa9b956b44542bf1..f844e0b1e44f0b45b1febadf02d7b37d3099fbdb 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/BaseSpawner.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/BaseSpawner.java
|
||||
@@ -19,7 +19,9 @@ import net.minecraft.util.StringUtil;
|
||||
import net.minecraft.util.random.WeightedRandomList;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
+import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.Mob;
|
||||
+import net.minecraft.world.entity.MobCategory;
|
||||
import net.minecraft.world.entity.MobSpawnType;
|
||||
import net.minecraft.world.entity.SpawnGroupData;
|
||||
import net.minecraft.world.entity.SpawnPlacements;
|
||||
@@ -31,6 +33,7 @@ public abstract class BaseSpawner {
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
private static final int EVENT_SPAWN = 1;
|
||||
+ public static List<MobCategory> whitelistedCategories = List.of(MobCategory.CREATURE, MobCategory.MONSTER, MobCategory.WATER_CREATURE, MobCategory.UNDERGROUND_WATER_CREATURE, MobCategory.AMBIENT); // Scissors
|
||||
public static WeightedRandomList<SpawnData> EMPTY_POTENTIALS = WeightedRandomList.create(); // Paper - private->public
|
||||
public int spawnDelay = 20;
|
||||
public WeightedRandomList<SpawnData> spawnPotentials;
|
||||
@@ -64,6 +67,13 @@ public abstract class BaseSpawner {
|
||||
public ResourceLocation getEntityId(@Nullable Level world, BlockPos pos) {
|
||||
String s = this.nextSpawnData.getTag().getString("id");
|
||||
|
||||
+ // Scissors start
|
||||
+ Optional<EntityType<?>> entityType = EntityType.byString(s);
|
||||
+ if (entityType.isPresent() && !whitelistedCategories.contains(entityType.get().getCategory())) {
|
||||
+ return null;
|
||||
+ }
|
||||
+ // Scissors end
|
||||
+
|
||||
try {
|
||||
return StringUtil.isNullOrEmpty(s) ? null : new ResourceLocation(s);
|
||||
} catch (ResourceLocationException resourcekeyinvalidexception) {
|
||||
@@ -73,6 +83,12 @@ public abstract class BaseSpawner {
|
||||
}
|
||||
|
||||
public void setEntityId(EntityType<?> type) {
|
||||
+ // Scissors start - Don't allow unnatural entities to be added to spawners
|
||||
+ if (!whitelistedCategories.contains(type.getCategory())) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // Scissors end
|
||||
+
|
||||
this.nextSpawnData.getTag().putString("id", Registry.ENTITY_TYPE.getKey(type).toString());
|
||||
this.spawnPotentials = BaseSpawner.EMPTY_POTENTIALS; // CraftBukkit - SPIGOT-3496, MC-92282
|
||||
}
|
||||
@@ -121,7 +137,7 @@ public abstract class BaseSpawner {
|
||||
CompoundTag nbttagcompound = this.nextSpawnData.getTag();
|
||||
Optional<EntityType<?>> optional = EntityType.by(nbttagcompound);
|
||||
|
||||
- if (!optional.isPresent()) {
|
||||
+ if (!(optional.isPresent() && whitelistedCategories.contains(optional.get().getCategory()))) { // Scissors - Don't try spawning in entites that aren't whitelisted
|
||||
this.delay(world, pos);
|
||||
return;
|
||||
}
|
||||
@@ -254,12 +270,16 @@ public abstract class BaseSpawner {
|
||||
ListTag nbttaglist = nbt.getList("SpawnPotentials", 10);
|
||||
|
||||
for (int i = 0; i < nbttaglist.size(); ++i) {
|
||||
- list.add(new SpawnData(nbttaglist.getCompound(i)));
|
||||
+ // Scissors start - Filter unnatural entity types from being added
|
||||
+ if (isValid(nbttaglist.getCompound(i))) {
|
||||
+ list.add(new SpawnData(nbttaglist.getCompound(i)));
|
||||
+ }
|
||||
+ // Scissors end
|
||||
}
|
||||
}
|
||||
|
||||
this.spawnPotentials = WeightedRandomList.create((List) list);
|
||||
- if (nbt.contains("SpawnData", 10)) {
|
||||
+ if (nbt.contains("SpawnData", 10) && isValid(nbt.getCompound("SpawnData"))) { // Scissors - Filter unnatural entity types from being added
|
||||
this.setNextSpawnData(world, pos, new SpawnData(1, nbt.getCompound("SpawnData")));
|
||||
} else if (!list.isEmpty()) {
|
||||
this.spawnPotentials.getRandom(this.random).ifPresent((mobspawnerdata) -> {
|
||||
@@ -371,4 +391,11 @@ public abstract class BaseSpawner {
|
||||
public double getoSpin() {
|
||||
return this.oSpin;
|
||||
}
|
||||
+
|
||||
+ // Scissors start
|
||||
+ public boolean isValid(CompoundTag tag) {
|
||||
+ Optional<EntityType<?>> type = EntityType.by(tag);
|
||||
+ return type.isPresent() && whitelistedCategories.contains(type.get().getCategory());
|
||||
+ }
|
||||
+ // Scissors end
|
||||
}
|
@ -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()) {
|
@ -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 f5f2ec1192303bc55a64dce3e0457e4531a35ba7..62613d9fccd74fe16512fe1fe703dc6db0166b28 100644
|
||||
--- a/src/main/java/net/minecraft/network/chat/NbtComponent.java
|
||||
+++ b/src/main/java/net/minecraft/network/chat/NbtComponent.java
|
||||
@@ -22,6 +22,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.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
@@ -218,7 +219,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
|
||||
index 749d3e67a877d7d1ed47b5fef511a604ee6589b6..fe7a7fd77c7dd1750144fb57e181c51ccda26329 100644
|
||||
index 88bac72edf19c578902f49d20353989ed4d96f8f..6963f2720fcc9888f62f5a1382dd96d82f598ac8 100644
|
||||
--- a/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> {
|
||||
@@ -34,6 +34,7 @@ public class ListTag extends CollectionTag<Tag> {
|
||||
list.add(tagType.load(dataInput, i + 1, nbtAccounter));
|
||||
}
|
||||
|
24
patches/server/0026-Fix-lectern-quick-move.patch
Normal file
24
patches/server/0026-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);
|
@ -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
|
||||
index 2cc714585fc3790b70a7ad1ab8034543462e2b3b..2d3706d8d0dbed3b3588066eaa6b9ce1b266294f 100644
|
||||
index 79e036d79dec2ec4404baf02c23ba5ccad20cdce..506be74453c6ecc52f05a48b1d95f82175fa6159 100644
|
||||
--- a/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) {
|
||||
@ -17,7 +17,7 @@ index 2cc714585fc3790b70a7ad1ab8034543462e2b3b..2d3706d8d0dbed3b3588066eaa6b9ce1
|
||||
if (this == MobEffects.REGENERATION) {
|
||||
if (entity.getHealth() < entity.getMaxHealth()) {
|
||||
entity.heal(1.0F, RegainReason.MAGIC_REGEN); // CraftBukkit
|
||||
@@ -86,17 +87,31 @@ public class MobEffect {
|
||||
@@ -75,17 +76,31 @@ public class MobEffect {
|
||||
// CraftBukkit end
|
||||
}
|
||||
} else if ((this != MobEffects.HEAL || entity.isInvertedHealAndHarm()) && (this != MobEffects.HARM || !entity.isInvertedHealAndHarm())) {
|
||||
@ -25,7 +25,7 @@ index 2cc714585fc3790b70a7ad1ab8034543462e2b3b..2d3706d8d0dbed3b3588066eaa6b9ce1
|
||||
+ // Scissors start
|
||||
+ amplifier = Math.min(Math.abs(amplifier), 124);
|
||||
+ 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
|
||||
} else {
|
249
patches/server/0028-Reset-large-tags.patch
Normal file
249
patches/server/0028-Reset-large-tags.patch
Normal file
@ -0,0 +1,249 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Business Goose <arclicious@vivaldi.net>
|
||||
Date: Mon, 18 Apr 2022 03:56:09 +0100
|
||||
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 d02339a07e1da56fd5dc171a5e32b00d63fa555c..fe6cb52573ee50a2c02d7add38b5e8411d7177f4 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;
|
||||
@@ -7,23 +8,28 @@ import com.google.gson.JsonParseException;
|
||||
import com.mojang.brigadier.StringReader;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
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;
|
||||
-import java.util.Objects;
|
||||
-import java.util.Optional;
|
||||
-import java.util.Random;
|
||||
-import java.util.function.Consumer;
|
||||
-import java.util.function.Predicate;
|
||||
-import java.util.stream.Collectors;
|
||||
-import javax.annotation.Nullable;
|
||||
+import net.minecraft.ChatFormatting;
|
||||
+import net.minecraft.Util;
|
||||
+import net.minecraft.advancements.CriteriaTriggers;
|
||||
+import net.minecraft.commands.arguments.blocks.BlockPredicateArgument;
|
||||
+import net.minecraft.commands.arguments.blocks.BlockStateParser;
|
||||
+import net.minecraft.core.BlockPos;
|
||||
+import net.minecraft.core.Direction;
|
||||
+import net.minecraft.core.Registry;
|
||||
+import net.minecraft.nbt.CompoundTag;
|
||||
+import net.minecraft.nbt.ListTag;
|
||||
+import net.minecraft.nbt.NbtOps;
|
||||
+import net.minecraft.network.chat.*;
|
||||
+import net.minecraft.network.protocol.game.ClientboundBlockUpdatePacket;
|
||||
+import net.minecraft.resources.ResourceLocation;
|
||||
+import net.minecraft.server.MinecraftServer;
|
||||
+import net.minecraft.server.level.ServerLevel;
|
||||
+import net.minecraft.server.level.ServerPlayer;
|
||||
+import net.minecraft.sounds.SoundEvent;
|
||||
+import net.minecraft.sounds.SoundSource;
|
||||
+import net.minecraft.stats.Stats;
|
||||
import net.minecraft.tags.BlockTags;
|
||||
import net.minecraft.tags.Tag;
|
||||
import net.minecraft.tags.TagContainer;
|
||||
@@ -31,11 +37,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;
|
||||
@@ -51,50 +53,13 @@ import net.minecraft.world.item.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.world.item.enchantment.Enchantments;
|
||||
import net.minecraft.world.level.ItemLike;
|
||||
import net.minecraft.world.level.Level;
|
||||
-import net.minecraft.world.level.block.BaseEntityBlock;
|
||||
-import net.minecraft.world.level.block.Block;
|
||||
-import org.apache.logging.log4j.LogManager;
|
||||
-import org.apache.logging.log4j.Logger;
|
||||
-
|
||||
-// CraftBukkit start
|
||||
-import com.mojang.serialization.Dynamic;
|
||||
-import java.util.List;
|
||||
-import java.util.Map;
|
||||
-import net.minecraft.ChatFormatting;
|
||||
-import net.minecraft.Util;
|
||||
-import net.minecraft.advancements.CriteriaTriggers;
|
||||
-import net.minecraft.commands.arguments.blocks.BlockPredicateArgument;
|
||||
-import net.minecraft.commands.arguments.blocks.BlockStateParser;
|
||||
-import net.minecraft.core.BlockPos;
|
||||
-import net.minecraft.core.Direction;
|
||||
-import net.minecraft.core.Registry;
|
||||
-import net.minecraft.nbt.CompoundTag;
|
||||
-import net.minecraft.nbt.ListTag;
|
||||
-import net.minecraft.nbt.NbtOps;
|
||||
-import net.minecraft.network.chat.Component;
|
||||
-import net.minecraft.network.chat.ComponentUtils;
|
||||
-import net.minecraft.network.chat.HoverEvent;
|
||||
-import net.minecraft.network.chat.MutableComponent;
|
||||
-import net.minecraft.network.chat.Style;
|
||||
-import net.minecraft.network.chat.TextComponent;
|
||||
-import net.minecraft.network.chat.TranslatableComponent;
|
||||
-import net.minecraft.network.protocol.game.ClientboundBlockUpdatePacket;
|
||||
-import net.minecraft.resources.ResourceLocation;
|
||||
-import net.minecraft.server.MinecraftServer;
|
||||
-import net.minecraft.server.level.ServerLevel;
|
||||
-import net.minecraft.server.level.ServerPlayer;
|
||||
-import net.minecraft.sounds.SoundEvent;
|
||||
-import net.minecraft.sounds.SoundSource;
|
||||
-import net.minecraft.stats.Stats;
|
||||
-import net.minecraft.world.level.block.Blocks;
|
||||
-import net.minecraft.world.level.block.JukeboxBlock;
|
||||
-import net.minecraft.world.level.block.SaplingBlock;
|
||||
-import net.minecraft.world.level.block.SoundType;
|
||||
-import net.minecraft.world.level.block.WitherSkullBlock;
|
||||
+import net.minecraft.world.level.block.*;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.SignBlockEntity;
|
||||
import net.minecraft.world.level.block.entity.SkullBlockEntity;
|
||||
import net.minecraft.world.level.block.state.pattern.BlockInWorld;
|
||||
+import org.apache.logging.log4j.LogManager;
|
||||
+import org.apache.logging.log4j.Logger;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.TreeType;
|
||||
import org.bukkit.block.BlockState;
|
||||
@@ -106,6 +71,15 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.block.BlockFertilizeEvent;
|
||||
import org.bukkit.event.player.PlayerItemDamageEvent;
|
||||
import org.bukkit.event.world.StructureGrowEvent;
|
||||
+
|
||||
+import javax.annotation.Nullable;
|
||||
+import java.text.DecimalFormat;
|
||||
+import java.text.DecimalFormatSymbols;
|
||||
+import java.util.*;
|
||||
+import java.util.Map.Entry;
|
||||
+import java.util.function.Consumer;
|
||||
+import java.util.function.Predicate;
|
||||
+import java.util.stream.Collectors;
|
||||
// CraftBukkit end
|
||||
|
||||
public final class ItemStack {
|
||||
@@ -245,6 +219,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)) {
|
||||
@@ -485,7 +466,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;
|
||||
@@ -815,6 +800,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;
|
||||
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 14da2997b5fff4434b1fe8d5a1b3109dde143740..a4385cea2d472611cfc7ef43662367bb1d780333 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 {
|
||||
|
19
patches/server/0029-Fix-negative-death-times.patch
Normal file
19
patches/server/0029-Fix-negative-death-times.patch
Normal file
@ -0,0 +1,19 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Business Goose <arclicious@vivaldi.net>
|
||||
Date: Mon, 18 Apr 2022 16:55:19 +0100
|
||||
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
|
||||
index 99a5074adbe2a254ae6115b3548f1fcd30ba2489..68ae4dfe3f4a77605b19607b5f04a2a6d07d6fc8 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -623,7 +623,7 @@ public abstract class LivingEntity extends Entity {
|
||||
|
||||
protected void tickDeath() {
|
||||
++this.deathTime;
|
||||
- if (this.deathTime >= 20 && !this.isRemoved() && !this.level.isClientSide()) { // CraftBukkit - (this.deathTicks == 20) -> (this.deathTicks >= 20 && !this.dead)
|
||||
+ if ((this.deathTime >= 20 || this.deathTime <= 0) && !this.isRemoved() && !this.level.isClientSide()) { // CraftBukkit - (this.deathTicks == 20) -> (this.deathTicks >= 20 && !this.dead)
|
||||
this.level.broadcastEntityEvent(this, (byte) 60);
|
||||
this.remove(Entity.RemovalReason.KILLED);
|
||||
}
|
@ -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) {
|
@ -1,12 +1,12 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Telesphoreo <me@telesphoreo.me>
|
||||
Date: Sat, 10 Dec 2022 23:44:05 -0600
|
||||
From: Business Goose <arclicious@vivaldi.net>
|
||||
Date: Thu, 21 Apr 2022 13:52:32 +0100
|
||||
Subject: [PATCH] Limit amount of vehicle collision checks to 3 and discard
|
||||
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
|
||||
index 9948a28dae4edba877c13ef0156be5ff58df3fa2..93f359c71659c0b2fdf25b1c76c072bf9209db2a 100644
|
||||
index 309bafd257d4932cfd69c2c212b32306938cd234..17c6aef70089730d9ca3d20d242f6755851b9494 100644
|
||||
--- a/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;
|
||||
@ -17,7 +17,7 @@ index 9948a28dae4edba877c13ef0156be5ff58df3fa2..93f359c71659c0b2fdf25b1c76c072bf
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.BlockUtil;
|
||||
import net.minecraft.Util;
|
||||
@@ -107,6 +108,7 @@ public abstract class AbstractMinecart extends Entity {
|
||||
@@ -109,6 +110,7 @@ public abstract class AbstractMinecart extends Entity {
|
||||
private double flyingX = 0.949999988079071D; // Paper - restore vanilla precision
|
||||
private double flyingY = 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;
|
||||
// CraftBukkit end
|
||||
|
||||
@@ -434,8 +436,10 @@ public abstract class AbstractMinecart extends Entity {
|
||||
@@ -425,8 +427,10 @@ public abstract class AbstractMinecart extends Entity {
|
||||
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(this, this.getBoundingBox().inflate(0.20000000298023224D, 0.0D, 0.20000000298023224D), EntitySelector.pushableBy(this));
|
||||
|
||||
- if (!list.isEmpty()) {
|
||||
- for (int l = 0; l < list.size(); ++l) {
|
||||
@ -38,7 +38,7 @@ index 9948a28dae4edba877c13ef0156be5ff58df3fa2..93f359c71659c0b2fdf25b1c76c072bf
|
||||
Entity entity = (Entity) list.get(l);
|
||||
|
||||
if (!(entity instanceof Player) && !(entity instanceof IronGolem) && !(entity instanceof AbstractMinecart) && !this.isVehicle() && !entity.isPassenger()) {
|
||||
@@ -462,6 +466,16 @@ public abstract class AbstractMinecart extends Entity {
|
||||
@@ -453,6 +457,16 @@ public abstract class AbstractMinecart extends Entity {
|
||||
entity.push(this);
|
||||
}
|
||||
}
|
||||
@ -54,20 +54,20 @@ index 9948a28dae4edba877c13ef0156be5ff58df3fa2..93f359c71659c0b2fdf25b1c76c072bf
|
||||
+ }
|
||||
}
|
||||
} 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
|
||||
index 35aeba4e8430e6419caa9db4a0b931a994228618..11b337298ac824adce04cf0608f8f960e59640c9 100644
|
||||
index 391454a58d18d7373b974e094fd62514ca0d0b6b..52b75015c89be054ef2bfe1f4780a69540b0f032 100644
|
||||
--- a/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.List;
|
||||
import java.util.function.IntFunction;
|
||||
+import java.util.concurrent.TimeUnit;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.BlockUtil;
|
||||
import net.minecraft.core.BlockPos;
|
||||
@@ -109,6 +110,7 @@ public class Boat extends Entity implements VariantHolder<Boat.Type> {
|
||||
@@ -108,6 +109,7 @@ public class Boat extends Entity {
|
||||
public double unoccupiedDeceleration = -1;
|
||||
public boolean landBoats = false;
|
||||
// CraftBukkit end
|
||||
@ -75,22 +75,22 @@ index 35aeba4e8430e6419caa9db4a0b931a994228618..11b337298ac824adce04cf0608f8f960
|
||||
|
||||
public Boat(EntityType<? extends Boat> type, Level world) {
|
||||
super(type, world);
|
||||
@@ -421,10 +423,12 @@ public class Boat extends Entity implements VariantHolder<Boat.Type> {
|
||||
@@ -400,10 +402,12 @@ public class Boat extends Entity {
|
||||
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(this, this.getBoundingBox().inflate(0.20000000298023224D, -0.009999999776482582D, 0.20000000298023224D), EntitySelector.pushableBy(this));
|
||||
|
||||
- if (!list.isEmpty()) {
|
||||
+ // Scissors - Add collision debounce
|
||||
+ 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) {
|
||||
+ // Scissors - Limit amount of vehicle collision checks to 3 maximum
|
||||
+ for (int j = 0; j < Math.min(3, list.size()); ++j) {
|
||||
Entity entity = (Entity) list.get(j);
|
||||
|
||||
if (!entity.hasPassenger((Entity) this)) {
|
||||
@@ -435,6 +439,16 @@ public class Boat extends Entity implements VariantHolder<Boat.Type> {
|
||||
if (!entity.hasPassenger(this)) {
|
||||
@@ -414,6 +418,16 @@ public class Boat extends Entity {
|
||||
}
|
||||
}
|
||||
}
|
@ -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,22 +1,21 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
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
|
||||
|
||||
|
||||
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
|
||||
+++ 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.function.Predicate;
|
||||
+import me.totalfreedom.scissors.NbtUtility;
|
||||
import net.minecraft.core.NonNullList;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
@@ -22,10 +23,13 @@ public class ContainerHelper {
|
||||
@@ -22,10 +23,14 @@ public class ContainerHelper {
|
||||
|
||||
public static CompoundTag saveAllItems(CompoundTag nbt, NonNullList<ItemStack> stacks, boolean setIfEmpty) {
|
||||
ListTag listTag = new ListTag();
|
||||
@ -25,21 +24,22 @@ index 4092c7a8c2b0d9d26e6f4d97386735236300d132..9e0ab51dd7a4f9fed8f9edde962d42d4
|
||||
|
||||
for(int i = 0; i < stacks.size(); ++i) {
|
||||
ItemStack itemStack = stacks.get(i);
|
||||
+
|
||||
if (!itemStack.isEmpty()) {
|
||||
+ total += NbtUtility.getTagSize(itemStack.getTag()); // Scissors
|
||||
+ total += NbtUtility.getTagSize(itemStack.getTag());
|
||||
CompoundTag compoundTag = new CompoundTag();
|
||||
compoundTag.putByte("Slot", (byte)i);
|
||||
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) && !(total > NbtUtility.MAXIMUM_SIZE)) { // Scissors
|
||||
+ if ((!listTag.isEmpty() || setIfEmpty) && !(total > NbtUtility.MAXIMUM_SIZE)) {
|
||||
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) {
|
||||
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
|
||||
index 2a786c9fd29dc2139cf487fa645cd43345d60167..dbdc66620ae4284cfe96f633b1f4db46866b597b 100644
|
||||
index 1bb79768fe3be8a44a00e1f8686f95eed0dc2cf2..73e95e631ac622de897775399d205de66c4d8ff8 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
|
||||
@@ -9,6 +9,7 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.annotation.Nullable;
|
||||
+import me.totalfreedom.scissors.NbtUtility;
|
||||
import net.minecraft.SharedConstants;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.core.BlockPos;
|
||||
@@ -212,6 +213,16 @@ public abstract class AbstractFurnaceBlockEntity extends BaseContainerBlockEntit
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.minecraft.world.level.block.entity;
|
||||
|
||||
+import com.github.atlasmediagroup.scissors.NbtUtility;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntMap.Entry;
|
||||
@@ -209,6 +210,17 @@ public abstract class AbstractFurnaceBlockEntity extends BaseContainerBlockEntit
|
||||
public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
|
||||
|
||||
public List<ItemStack> getContents() {
|
||||
@ -84,21 +83,22 @@ index 2a786c9fd29dc2139cf487fa645cd43345d60167..dbdc66620ae4284cfe96f633b1f4db46
|
||||
+ if (total > NbtUtility.MAXIMUM_SIZE) {
|
||||
+ this.items.clear();
|
||||
+ }
|
||||
+
|
||||
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
|
||||
index 416aa989ebb18a8741cc9d605a1180ab830f6643..893cf89dd2b022e2b785318e7e86eb5d75be8ed8 100644
|
||||
index f494063ead9c6303fb3ca880aba2a877ae8d83ab..7ec2f7f9ea8e75d5a04c700fce783a21a9b560f8 100644
|
||||
--- a/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 @@
|
||||
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.Direction;
|
||||
import net.minecraft.core.NonNullList;
|
||||
@@ -34,6 +35,16 @@ public class BarrelBlockEntity extends RandomizableContainerBlockEntity {
|
||||
@@ -35,6 +36,17 @@ public class BarrelBlockEntity extends RandomizableContainerBlockEntity {
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getContents() {
|
||||
@ -112,22 +112,22 @@ index 416aa989ebb18a8741cc9d605a1180ab830f6643..893cf89dd2b022e2b785318e7e86eb5d
|
||||
+ if (total > NbtUtility.MAXIMUM_SIZE) {
|
||||
+ this.items.clear();
|
||||
+ }
|
||||
+
|
||||
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
|
||||
index c57efcb9a79337ec791e4e8f6671612f0a82b441..2963b72061a9ede734842d6fb46a67a1c41d4740 100644
|
||||
index 3e71a16ae77601f589f4283a72ef8b68aae60db3..27fb605dbaefbb3a8eed25a519af4062e67aee26 100644
|
||||
--- a/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.Iterator;
|
||||
import javax.annotation.Nullable;
|
||||
+import me.totalfreedom.scissors.NbtUtility;
|
||||
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
|
||||
@@ -72,6 +73,17 @@ public class BrewingStandBlockEntity extends BaseContainerBlockEntity implements
|
||||
}
|
||||
|
||||
public List<ItemStack> getContents() {
|
||||
@ -141,21 +141,22 @@ index c57efcb9a79337ec791e4e8f6671612f0a82b441..2963b72061a9ede734842d6fb46a67a1
|
||||
+ if (total > NbtUtility.MAXIMUM_SIZE) {
|
||||
+ this.items.clear();
|
||||
+ }
|
||||
+
|
||||
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
|
||||
index a71414397bd45ee7bcacfeef0041d80dfa25f114..1b6f91055eb01627761e83e5e99e1731029b32ab 100644
|
||||
index 52de9852f87d346714a950b60a0004d386ac10f0..14854956a81c5f6da4d3f3ff2e910f37f32c21f7 100644
|
||||
--- a/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 @@
|
||||
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.Direction;
|
||||
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;
|
||||
|
||||
public List<ItemStack> getContents() {
|
||||
@ -169,21 +170,22 @@ index a71414397bd45ee7bcacfeef0041d80dfa25f114..1b6f91055eb01627761e83e5e99e1731
|
||||
+ if (total > NbtUtility.MAXIMUM_SIZE) {
|
||||
+ this.items.clear();
|
||||
+ }
|
||||
+
|
||||
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
|
||||
index 881379681c39230a00b3a1f11cd87498984396c7..1be5d600573f7632e6630224530dd76522e1b191 100644
|
||||
index cfec89db4300bdb96a220540ee87892d22215e9d..ea14263bc11a80657b099342c1d6bb239ea1c80e 100644
|
||||
--- a/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 @@
|
||||
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.NonNullList;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
@@ -28,6 +29,16 @@ public class DispenserBlockEntity extends RandomizableContainerBlockEntity {
|
||||
@@ -31,6 +32,17 @@ public class DispenserBlockEntity extends RandomizableContainerBlockEntity {
|
||||
private int maxStack = MAX_STACK;
|
||||
|
||||
public List<ItemStack> getContents() {
|
||||
@ -197,22 +199,22 @@ index 881379681c39230a00b3a1f11cd87498984396c7..1be5d600573f7632e6630224530dd765
|
||||
+ if (total > NbtUtility.MAXIMUM_SIZE) {
|
||||
+ this.items.clear();
|
||||
+ }
|
||||
+
|
||||
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
|
||||
index 789e5458f4a137694563a22612455506807de51b..84c721da46b7786857677b56f439c2b9448ba4b8 100644
|
||||
index 06ffdf7301c8c9a02b4aa3693c69984064c8e085..ed28d8a30f9238a94ff6aff00740b77d12bfb8d6 100644
|
||||
--- a/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;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
import javax.annotation.Nullable;
|
||||
+import me.totalfreedom.scissors.NbtUtility;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.NonNullList;
|
||||
@@ -56,6 +57,16 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.minecraft.world.level.block.entity;
|
||||
|
||||
+import com.github.atlasmediagroup.scissors.NbtUtility;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.function.BooleanSupplier;
|
||||
@@ -53,7 +54,19 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
|
||||
private int maxStack = MAX_STACK;
|
||||
|
||||
public List<ItemStack> getContents() {
|
||||
@ -226,25 +228,27 @@ index 789e5458f4a137694563a22612455506807de51b..84c721da46b7786857677b56f439c2b9
|
||||
+ if (total > NbtUtility.MAXIMUM_SIZE) {
|
||||
+ this.items.clear();
|
||||
+ }
|
||||
+
|
||||
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
|
||||
index b7686fd63b7c5d88c3a12ec4ee9bc01a17f997e0..c2904048625bb4439c7f0ba8a2605d3194b66070 100644
|
||||
index 01d77f800a1497418f08b8d52b0b7995bfbb5f4e..281d5f875de4bfaca1efc281e595cfa0dc492ede 100644
|
||||
--- a/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.stream.IntStream;
|
||||
import javax.annotation.Nullable;
|
||||
+import me.totalfreedom.scissors.NbtUtility;
|
||||
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;
|
||||
@@ -257,7 +258,19 @@ public class ShulkerBoxBlockEntity extends RandomizableContainerBlockEntity impl
|
||||
|
||||
public List<ItemStack> getContents() {
|
||||
@Override
|
||||
protected NonNullList<ItemStack> getItems() {
|
||||
+ // Scissors - Account for items inside containers
|
||||
+ long total = 0;
|
||||
+
|
||||
@ -255,6 +259,9 @@ index b7686fd63b7c5d88c3a12ec4ee9bc01a17f997e0..c2904048625bb4439c7f0ba8a2605d31
|
||||
+ if (total > NbtUtility.MAXIMUM_SIZE) {
|
||||
+ this.itemStacks.clear();
|
||||
+ }
|
||||
+
|
||||
return this.itemStacks;
|
||||
+
|
||||
}
|
||||
|
||||
@Override
|
@ -1,46 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Allink <arclicious@vivaldi.net>
|
||||
Date: Sun, 10 Jul 2022 02:55:01 +0100
|
||||
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
|
||||
index 2807dbb730974ca4d3a7c7fd1358e2438628bc50..37fcbdcddaa6cbfd6ae37d70cffab957c90f4e07 100644
|
||||
--- a/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;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
import javax.annotation.Nullable;
|
||||
+
|
||||
+import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.CrashReport;
|
||||
import net.minecraft.CrashReportCategory;
|
||||
@@ -2985,6 +2987,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
public void handleContainerClick(ServerboundContainerClickPacket packet) {
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
|
||||
if (this.player.isImmobile()) return; // CraftBukkit
|
||||
+
|
||||
this.player.resetLastActionTime();
|
||||
if (this.player.containerMenu.containerId == packet.getContainerId() && this.player.containerMenu.stillValid(this.player)) { // CraftBukkit
|
||||
boolean cancelled = this.player.isSpectator(); // CraftBukkit - see below if
|
||||
@@ -3006,6 +3009,18 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
return;
|
||||
}
|
||||
|
||||
+ // Scissors start - Do not call events when the slot/button number is invalid
|
||||
+ final int sentSlotNum = packet.getSlotNum();
|
||||
+ if((Mth.clamp(sentSlotNum, -1, this.player.containerMenu.slots.size() - 1) != sentSlotNum) && sentSlotNum != -999)
|
||||
+ {
|
||||
+ this.getCraftPlayer().kick(
|
||||
+ net.kyori.adventure.text.Component.text("Invalid container click slot (Hacking?)")
|
||||
+ .color(NamedTextColor.RED)
|
||||
+ );
|
||||
+ return;
|
||||
+ }
|
||||
+ // Scissors end
|
||||
+
|
||||
InventoryView inventory = this.player.containerMenu.getBukkitView();
|
||||
SlotType type = inventory.getSlotType(packet.getSlotNum());
|
||||
|
@ -1,15 +1,15 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Telesphoreo <me@telesphoreo.me>
|
||||
Date: Thu, 8 Jun 2023 19:32:11 -0500
|
||||
From: Allink <arclicious@vivaldi.net>
|
||||
Date: Tue, 17 May 2022 05:57:52 +0100
|
||||
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
|
||||
index 468f64afb7e9b3ef579205d3beea025deb31b460..71a32f8dfdf043f55f092225a13884ae8935e67c 100644
|
||||
index 68ae4dfe3f4a77605b19607b5f04a2a6d07d6fc8..b7efb87767570992e9bb14510e510f2b37ec2226 100644
|
||||
--- a/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 {
|
||||
boolean flag = scoreboardteam != null && this.level().getScoreboard().addPlayerToTeam(this.getStringUUID(), scoreboardteam);
|
||||
@@ -816,7 +816,9 @@ public abstract class LivingEntity extends Entity {
|
||||
boolean flag = scoreboardteam != null && this.level.getScoreboard().addPlayerToTeam(this.getStringUUID(), scoreboardteam);
|
||||
|
||||
if (!flag) {
|
||||
- LivingEntity.LOGGER.warn("Unable to add mob to team \"{}\" (that team probably doesn't exist)", s);
|
@ -1,19 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Luna <lunahatesgogle@gmail.com>
|
||||
Date: Mon, 11 Jul 2022 17:29:12 -0300
|
||||
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
|
||||
index 37fcbdcddaa6cbfd6ae37d70cffab957c90f4e07..01f88bf2f4872884a9c4c2d1d5f1369c61fb0ebf 100644
|
||||
--- a/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
|
||||
@Override
|
||||
public void handleBlockEntityTagQuery(ServerboundBlockEntityTagQuery packet) {
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
|
||||
- if (this.player.hasPermissions(2)) {
|
||||
+ if (this.player.hasPermissions(2) && Level.isInSpawnableBounds(packet.getPos())) { // Scissors - Validate block entity tag query positions
|
||||
BlockEntity tileentity = this.player.level().getBlockEntity(packet.getPos());
|
||||
CompoundTag nbttagcompound = tileentity != null ? tileentity.saveWithoutMetadata() : null;
|
||||
|
@ -0,0 +1,23 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Video <videogamesm12@gmail.com>
|
||||
Date: Fri, 19 Aug 2022 00:49:38 -0600
|
||||
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 ca9decf85dd1af0baf0d34a48aa67cbb9f4eb586..50cbd324b87300d6b872581571fa97ad9fa54396 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,11 @@ 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 - Fixes exploit where bad TileX, TileY, and TileZ coordinates can crash servers
|
||||
+ BlockPos pos = new BlockPos(nbt.getInt("TileX"), nbt.getInt("TileY"), nbt.getInt("TileZ"));
|
||||
+ if (level.isLoadedAndInBounds(pos))
|
||||
+ this.pos = pos;
|
||||
+ // Scissors end
|
||||
}
|
||||
|
||||
public abstract int getWidth();
|
@ -1,34 +1,34 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Allink <arclicious@vivaldi.net>
|
||||
Date: Mon, 4 Jul 2022 22:12:19 +0100
|
||||
Date: Mon, 4 Jul 2022 17:02:52 +0100
|
||||
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
|
||||
index 2e7c03b00bc941b86df6a7f1b2b188c9f0aede22..333f9bcccbe9ecd88c1fd13e2956f69414d6e295 100644
|
||||
index fd73e9100feac8c7bf9a5fee21a0ab2d502dc3e0..4912d24683f5094b0b93798c3ad378516eed4746 100644
|
||||
--- a/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,6 +1,6 @@
|
||||
package net.minecraft.world.level.block;
|
||||
|
||||
+import me.totalfreedom.scissors.event.block.MasterBlockFireEvent;
|
||||
import com.mojang.logging.LogUtils;
|
||||
-import java.util.Random;
|
||||
+import com.github.atlasmediagroup.scissors.event.block.MasterBlockFireEvent;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
@@ -25,10 +26,10 @@ 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.DirectionProperty;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
@@ -25,8 +25,10 @@ import net.minecraft.world.level.block.state.properties.DirectionProperty;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
+import org.bukkit.event.block.BlockRedstoneEvent;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
+import org.bukkit.Location;
|
||||
import org.slf4j.Logger;
|
||||
+import org.bukkit.event.block.BlockRedstoneEvent;
|
||||
|
||||
-import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit
|
||||
-
|
||||
+import java.util.Random;
|
||||
|
||||
public class CommandBlock extends BaseEntityBlock implements GameMasterBlock {
|
||||
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
@@ -117,6 +118,15 @@ public class CommandBlock extends BaseEntityBlock implements GameMasterBlock {
|
||||
@@ -116,6 +118,15 @@ public class CommandBlock extends BaseEntityBlock implements GameMasterBlock {
|
||||
}
|
||||
|
||||
private void execute(BlockState state, Level world, BlockPos pos, BaseCommandBlock executor, boolean hasCommand) {
|
||||
@ -45,45 +45,44 @@ index 2e7c03b00bc941b86df6a7f1b2b188c9f0aede22..333f9bcccbe9ecd88c1fd13e2956f694
|
||||
executor.performCommand(world);
|
||||
} 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
|
||||
index 4142687c6bb08ac8a156fcaee39ce26308924615..fd9b338117f5cb4575b60bb5bc5664c548132265 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 @@
|
||||
@@ -1,6 +1,8 @@
|
||||
package net.minecraft.world.level.block;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
+
|
||||
+import com.github.atlasmediagroup.scissors.event.block.MasterBlockFireEvent;
|
||||
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
|
||||
index 182e16c1d968707a11329150d71b7d01df6c6e52..fa5cade3f5f2fecc37cc065b96403d0a1c1a2553 100644
|
||||
index c391db3b6cbe3140a92aec44fb52e90455209217..c93d21142c5f7b2799eeac7a8314ffdb7360162e 100644
|
||||
--- a/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 com.github.atlasmediagroup.scissors.event.block.MasterBlockFireEvent;
|
||||
import com.google.common.collect.Lists;
|
||||
import java.util.Arrays;
|
||||
import java.util.Optional;
|
||||
+
|
||||
+import me.totalfreedom.scissors.event.block.MasterBlockFireEvent;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.Registry;
|
||||
@@ -17,6 +19,7 @@ import net.minecraft.world.level.block.JigsawBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.levelgen.structure.pools.JigsawPlacement;
|
||||
import net.minecraft.world.level.levelgen.structure.pools.StructureTemplatePool;
|
||||
import java.util.List;
|
||||
@@ -28,6 +29,7 @@ import net.minecraft.world.level.levelgen.structure.BoundingBox;
|
||||
import net.minecraft.world.level.levelgen.structure.PoolElementStructurePiece;
|
||||
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureManager;
|
||||
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate;
|
||||
+import org.bukkit.Location;
|
||||
|
||||
public class JigsawBlockEntity extends BlockEntity {
|
||||
public static final String TARGET = "target";
|
||||
@@ -107,6 +110,16 @@ public class JigsawBlockEntity extends BlockEntity {
|
||||
@@ -120,11 +122,21 @@ public class JigsawBlockEntity extends BlockEntity {
|
||||
}
|
||||
|
||||
public void generate(ServerLevel world, int maxDepth, boolean keepJigsaws) {
|
||||
+ // Scissors - Add master block fire event
|
||||
+ final BlockPos pos = this.getBlockPos();
|
||||
+ final MasterBlockFireEvent event = new MasterBlockFireEvent(new Location(this.getLevel().getWorld(), pos.getX(), pos.getY(), pos.getZ()));
|
||||
+ final BlockPos blockPos = this.getBlockPos();
|
||||
+ final MasterBlockFireEvent event = new MasterBlockFireEvent(new Location(this.getLevel().getWorld(), blockPos.getX(), blockPos.getY(), blockPos.getZ()));
|
||||
+
|
||||
+ if (!event.callEvent())
|
||||
+ {
|
||||
@ -91,31 +90,37 @@ index 182e16c1d968707a11329150d71b7d01df6c6e52..fa5cade3f5f2fecc37cc065b96403d0a
|
||||
+ }
|
||||
+ // Scissors end
|
||||
+
|
||||
BlockPos blockPos = this.getBlockPos().relative(this.getBlockState().getValue(JigsawBlock.ORIENTATION).front());
|
||||
Registry<StructureTemplatePool> registry = world.registryAccess().registryOrThrow(Registries.TEMPLATE_POOL);
|
||||
// Paper start - Replace getHolderOrThrow with a null check
|
||||
ChunkGenerator chunkGenerator = world.getChunkSource().getGenerator();
|
||||
StructureManager structureManager = world.getStructureManager();
|
||||
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
|
||||
index 9792bf3ee083f571f1f4089d30beb586839f5f6b..e9d584b0ca984f9b7c70f99e1665cdedecb710e1 100644
|
||||
index a9b186e5a60838443d2ad2ee82ed3f4803a4899a..9134c8fc0b9363eadf6da288029b7a33c6d5d405 100644
|
||||
--- a/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;
|
||||
import java.util.Optional;
|
||||
@@ -6,6 +6,8 @@ import java.util.Optional;
|
||||
import java.util.Random;
|
||||
import java.util.stream.Stream;
|
||||
import javax.annotation.Nullable;
|
||||
+
|
||||
+import me.totalfreedom.scissors.event.block.MasterBlockFireEvent;
|
||||
+import com.github.atlasmediagroup.scissors.event.block.MasterBlockFireEvent;
|
||||
import net.minecraft.ResourceLocationException;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.core.BlockPos;
|
||||
@@ -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.StructureTemplate;
|
||||
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplateManager;
|
||||
+import org.bukkit.Location;
|
||||
|
||||
public class StructureBlockEntity extends BlockEntity {
|
||||
private static final int SCAN_CORNER_BLOCKS_RANGE = 5;
|
||||
@@ -264,7 +267,6 @@ public class StructureBlockEntity extends BlockEntity {
|
||||
@@ -266,7 +269,6 @@ public class StructureBlockEntity extends BlockEntity {
|
||||
return false;
|
||||
} else {
|
||||
BlockPos blockPos = this.getBlockPos();
|
||||
@ -123,7 +128,7 @@ index 9792bf3ee083f571f1f4089d30beb586839f5f6b..e9d584b0ca984f9b7c70f99e1665cded
|
||||
BlockPos blockPos2 = new BlockPos(blockPos.getX() - 80, this.level.getMinBuildHeight(), blockPos.getZ() - 80);
|
||||
BlockPos blockPos3 = new BlockPos(blockPos.getX() + 80, this.level.getMaxBuildHeight() - 1, blockPos.getZ() + 80);
|
||||
Stream<BlockPos> stream = this.getRelatedCorners(blockPos2, blockPos3);
|
||||
@@ -321,6 +323,16 @@ public class StructureBlockEntity extends BlockEntity {
|
||||
@@ -323,6 +325,16 @@ public class StructureBlockEntity extends BlockEntity {
|
||||
|
||||
public boolean saveStructure(boolean bl) {
|
||||
if (this.mode == StructureMode.SAVE && !this.level.isClientSide && this.structureName != null) {
|
||||
@ -139,8 +144,8 @@ index 9792bf3ee083f571f1f4089d30beb586839f5f6b..e9d584b0ca984f9b7c70f99e1665cded
|
||||
+
|
||||
BlockPos blockPos = this.getBlockPos().offset(this.structurePos);
|
||||
ServerLevel serverLevel = (ServerLevel)this.level;
|
||||
StructureTemplateManager structureTemplateManager = serverLevel.getStructureManager();
|
||||
@@ -358,6 +370,16 @@ public class StructureBlockEntity extends BlockEntity {
|
||||
StructureManager structureManager = serverLevel.getStructureManager();
|
||||
@@ -360,6 +372,16 @@ public class StructureBlockEntity extends BlockEntity {
|
||||
|
||||
public boolean loadStructure(ServerLevel world, boolean bl) {
|
||||
if (this.mode == StructureMode.LOAD && this.structureName != null) {
|
||||
@ -154,10 +159,28 @@ index 9792bf3ee083f571f1f4089d30beb586839f5f6b..e9d584b0ca984f9b7c70f99e1665cded
|
||||
+ }
|
||||
+ // Scissors end
|
||||
+
|
||||
StructureTemplateManager structureTemplateManager = world.getStructureManager();
|
||||
StructureManager structureManager = world.getStructureManager();
|
||||
|
||||
Optional<StructureTemplate> optional;
|
||||
@@ -403,6 +425,16 @@ public class StructureBlockEntity extends BlockEntity {
|
||||
@@ -376,7 +398,16 @@ public class StructureBlockEntity extends BlockEntity {
|
||||
}
|
||||
|
||||
public boolean loadStructure(ServerLevel world, boolean bl, StructureTemplate structureTemplate) {
|
||||
- BlockPos blockPos = this.getBlockPos();
|
||||
+ // Scissors - Add master block fire event
|
||||
+ final BlockPos blockPos = this.getBlockPos();
|
||||
+ final MasterBlockFireEvent event = new MasterBlockFireEvent(new Location(this.getLevel().getWorld(), blockPos.getX(), blockPos.getY(), blockPos.getZ()));
|
||||
+
|
||||
+ if (!event.callEvent())
|
||||
+ {
|
||||
+ return false;
|
||||
+ }
|
||||
+ // Scissors end
|
||||
+
|
||||
if (!StringUtil.isNullOrEmpty(structureTemplate.getAuthor())) {
|
||||
this.author = structureTemplate.getAuthor();
|
||||
}
|
||||
@@ -405,6 +436,16 @@ public class StructureBlockEntity extends BlockEntity {
|
||||
}
|
||||
|
||||
public void unloadStructure() {
|
||||
@ -173,4 +196,4 @@ index 9792bf3ee083f571f1f4089d30beb586839f5f6b..e9d584b0ca984f9b7c70f99e1665cded
|
||||
+
|
||||
if (this.structureName != null) {
|
||||
ServerLevel serverLevel = (ServerLevel)this.level;
|
||||
StructureTemplateManager structureTemplateManager = serverLevel.getStructureManager();
|
||||
StructureManager structureManager = serverLevel.getStructureManager();
|
@ -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 {
|
@ -1,21 +1,21 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Allink <arclicious@vivaldi.net>
|
||||
Date: Tue, 5 Jul 2022 04:12:31 +0100
|
||||
Date: Tue, 5 Jul 2022 03:34:36 +0100
|
||||
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
|
||||
index 61f6b51b9d868ae6bd79185cc066976a094da8ce..2807dbb730974ca4d3a7c7fd1358e2438628bc50 100644
|
||||
index 83333ae9c8e8c1edc6e7f02468bd8dc7e44bb66e..ca595abe940463a62da033c7082c868c4c4b28d8 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.event.player.SpectatorTeleportEvent;
|
||||
+import com.github.atlasmediagroup.scissors.event.player.SpectatorTeleportEvent;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.primitives.Floats;
|
||||
import com.mojang.brigadier.ParseResults;
|
||||
@@ -2066,6 +2067,14 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
@@ -1905,6 +1906,14 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
||||
Entity entity = packet.getEntity(worldserver);
|
||||
|
||||
if (entity != null) {
|
@ -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
|
52
patches/server/0037-Prevent-invalid-container-events.patch
Normal file
52
patches/server/0037-Prevent-invalid-container-events.patch
Normal file
@ -0,0 +1,52 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Allink <arclicious@vivaldi.net>
|
||||
Date: Sun, 10 Jul 2022 02:20:16 +0100
|
||||
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
|
||||
index ca595abe940463a62da033c7082c868c4c4b28d8..a102586b42ac408a3f655f7c0d069ab0990ec7fc 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -24,6 +24,8 @@ import java.util.function.UnaryOperator;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
import javax.annotation.Nullable;
|
||||
+
|
||||
+import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.CrashReport;
|
||||
import net.minecraft.CrashReportCategory;
|
||||
@@ -2593,6 +2595,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
||||
public void handleContainerClick(ServerboundContainerClickPacket packet) {
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel());
|
||||
if (this.player.isImmobile()) return; // CraftBukkit
|
||||
+
|
||||
this.player.resetLastActionTime();
|
||||
if (this.player.containerMenu.containerId == packet.getContainerId() && this.player.containerMenu.stillValid(this.player)) { // CraftBukkit
|
||||
boolean cancelled = this.player.isSpectator(); // CraftBukkit - see below if
|
||||
@@ -2602,11 +2605,24 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
||||
boolean flag = packet.getStateId() != this.player.containerMenu.getStateId();
|
||||
|
||||
this.player.containerMenu.suppressRemoteUpdates();
|
||||
+
|
||||
// CraftBukkit start - Call InventoryClickEvent
|
||||
if (packet.getSlotNum() < -1 && packet.getSlotNum() != -999) {
|
||||
return;
|
||||
}
|
||||
|
||||
+ // Scissors start - Do not call events when the slot/button number is invalid
|
||||
+ final int sentSlotNum = packet.getSlotNum();
|
||||
+ if((Mth.clamp(sentSlotNum, -1, this.player.containerMenu.slots.size() - 1) != sentSlotNum) && sentSlotNum != -999)
|
||||
+ {
|
||||
+ this.getCraftPlayer().kick(
|
||||
+ net.kyori.adventure.text.Component.text("Invalid container click slot (Hacking?)")
|
||||
+ .color(NamedTextColor.RED)
|
||||
+ );
|
||||
+ return;
|
||||
+ }
|
||||
+ // Scissors end
|
||||
+
|
||||
InventoryView inventory = this.player.containerMenu.getBukkitView();
|
||||
SlotType type = inventory.getSlotType(packet.getSlotNum());
|
||||
|
@ -0,0 +1,24 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Allink <arclicious@vivaldi.net>
|
||||
Date: Sun, 10 Jul 2022 02:25:28 +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 73e95e631ac622de897775399d205de66c4d8ff8..c3fd536cebb2f8664f9bf86d322f88094677d2b5 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
|
||||
@@ -629,6 +629,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,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;
|
||||
}
|
445
patches/server/0039-Add-Scissors-config-command.patch
Normal file
445
patches/server/0039-Add-Scissors-config-command.patch
Normal file
@ -0,0 +1,445 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Allink <arclicious@vivaldi.net>
|
||||
Date: Sun, 10 Jul 2022 07:53:59 +0100
|
||||
Subject: [PATCH] Add Scissors config & command
|
||||
|
||||
|
||||
diff --git a/src/main/java/co/aikar/timings/TimingsExport.java b/src/main/java/co/aikar/timings/TimingsExport.java
|
||||
index e29b0a90019b12bd6586ad0f7b5314f307e527ba..c6f19e178f8c5a03f9fb8b011f329ef81e4e35d8 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 net.minecraft.server.MinecraftServer;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
@@ -228,7 +229,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..f5202deac5b3a715a22d0d482f1302b6074b26ac
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/com/github/atlasmediagroup/scissors/ScissorsCommand.java
|
||||
@@ -0,0 +1,150 @@
|
||||
+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 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/com/github/atlasmediagroup/scissors/ScissorsConfig.java b/src/main/java/com/github/atlasmediagroup/scissors/ScissorsConfig.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..076379a0e61d74ecaf651b341821e1e30999b3b8
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/com/github/atlasmediagroup/scissors/ScissorsConfig.java
|
||||
@@ -0,0 +1,170 @@
|
||||
+package com.github.atlasmediagroup.scissors;
|
||||
+
|
||||
+import com.google.common.base.Throwables;
|
||||
+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;
|
||||
+
|
||||
+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;
|
||||
+
|
||||
+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.17.1/\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);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ 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 6a00ee7f69bf44c5a9a329df26ac5640b368283b..3fed82a0b271234065767ec37c9ddd0a9f39da27 100644
|
||||
--- a/src/main/java/net/minecraft/server/Main.java
|
||||
+++ b/src/main/java/net/minecraft/server/Main.java
|
||||
@@ -106,6 +106,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 b6ee0e709b0f0529b99567bc9b8fb6bfd99bcd8e..4cd18a681dedea26b98002902a3c3b1f47966887 100644
|
||||
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
@@ -234,7 +234,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 cc797b45674163b5913e20031d110796d78b928b..bb5d6e5405c1781404bfd3d2af9c93026f9c86f0 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
@@ -924,6 +924,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))
|
||||
@@ -979,6 +980,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");
|
||||
|
||||
@@ -2566,6 +2568,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 d033caf5dabbd2a240286c5623b3d287ae5cbdd9..facfcc3f478a21240fa2938c94de7dc599eeafd3 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(new File[] {})
|
||||
.describedAs("Jar file");
|
||||
// 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
|
||||
}
|
||||
};
|
||||
|
@ -0,0 +1,103 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Allink <arclicious@vivaldi.net>
|
||||
Date: Sun, 10 Jul 2022 09:46:20 +0100
|
||||
Subject: [PATCH] Disable running commands in books by default
|
||||
|
||||
|
||||
diff --git a/src/main/java/com/github/atlasmediagroup/scissors/ScissorsConfig.java b/src/main/java/com/github/atlasmediagroup/scissors/ScissorsConfig.java
|
||||
index d0e2bcf4671d723d5893e0a9bc8c6e30a9b83be6..6fcbd02c02d70617e4533b450747c918ec3339d5 100644
|
||||
--- a/src/main/java/com/github/atlasmediagroup/scissors/ScissorsConfig.java
|
||||
+++ b/src/main/java/com/github/atlasmediagroup/scissors/ScissorsConfig.java
|
||||
@@ -127,6 +127,12 @@ public class ScissorsConfig
|
||||
}
|
||||
}
|
||||
|
||||
+ 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);
|
||||
diff --git a/src/main/java/net/minecraft/world/item/WrittenBookItem.java b/src/main/java/net/minecraft/world/item/WrittenBookItem.java
|
||||
index de11f8b4a783e7aa6029693f6812c950649fe88c..526206f11bdfc2aa7cb88649c47d707678753007 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 (compoundTag != null && !compoundTag.getBoolean("resolved")) {
|
||||
- compoundTag.putBoolean("resolved", true);
|
||||
+ if (compoundTag != null) {
|
||||
if (!makeSureTagIsValid(compoundTag)) {
|
||||
return false;
|
||||
} else {
|
||||
@@ -148,8 +147,41 @@ public class WrittenBookItem extends Item {
|
||||
component2 = new TextComponent(string);
|
||||
}
|
||||
|
||||
- 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,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);
|
@ -0,0 +1,93 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Allink <arclicious@vivaldi.net>
|
||||
Date: Wed, 13 Jul 2022 10:16:57 +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 6fcbd02c02d70617e4533b450747c918ec3339d5..52b0161711634f9ad8cecf58668737a726278f72 100644
|
||||
--- a/src/main/java/com/github/atlasmediagroup/scissors/ScissorsConfig.java
|
||||
+++ b/src/main/java/com/github/atlasmediagroup/scissors/ScissorsConfig.java
|
||||
@@ -65,8 +65,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);
|
||||
}
|
||||
|
||||
@@ -133,6 +133,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 344d3a8c1162f1a4ab5fc2b7676680ddace46649..5e526ba120b9e4ba77fa4474730aa180dba5eb56 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.core.Vec3i;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
@@ -16,6 +18,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;
|
||||
@@ -24,6 +27,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
|
||||
@@ -237,7 +242,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
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Luna <lunahatesgogle@gmail.com>
|
||||
Date: Mon, 11 Jul 2022 17:10:17 -0300
|
||||
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
|
||||
index a102586b42ac408a3f655f7c0d069ab0990ec7fc..1c56ca1f7ed3064bfd3352cf46741fc64bbee4eb 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -1240,7 +1240,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
||||
if (this.player.hasPermissions(2)) {
|
||||
Entity entity = this.player.getLevel().getEntity(packet.getEntityId());
|
||||
|
||||
- if (entity != null) {
|
||||
+ if (entity != null && !isOutsideOfReach(entity.position().x, entity.position().y, entity.position().z)) { // Scissors - Prevent querying of entities out of reach
|
||||
CompoundTag nbttagcompound = entity.saveWithoutId(new CompoundTag());
|
||||
|
||||
this.player.connection.send(new ClientboundTagQueryPacket(packet.getTransactionId(), nbttagcompound));
|
||||
@@ -1252,8 +1252,11 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
||||
@Override
|
||||
public void handleBlockEntityTagQuery(ServerboundBlockEntityTagQuery packet) {
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel());
|
||||
- if (this.player.hasPermissions(2)) {
|
||||
- BlockEntity tileentity = this.player.getLevel().getBlockEntity(packet.getPos());
|
||||
+ // Scissors start - Validate block entity tag query positions, prevent querying block entities out of reach
|
||||
+ final BlockPos pos = packet.getPos();
|
||||
+ if (this.player.hasPermissions(2) && Level.isInSpawnableBounds(pos) && !isOutsideOfReach(pos.getX(), pos.getY(), pos.getZ())) {
|
||||
+ BlockEntity tileentity = this.player.getLevel().isLoaded(pos) ? this.player.getLevel().getBlockEntity(pos) : null;
|
||||
+ // Scissors end
|
||||
CompoundTag nbttagcompound = tileentity != null ? tileentity.save(new CompoundTag()) : null;
|
||||
|
||||
this.player.connection.send(new ClientboundTagQueryPacket(packet.getTransactionId(), nbttagcompound));
|
@ -0,0 +1,22 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Allink <arclicious@vivaldi.net>
|
||||
Date: Mon, 25 Jul 2022 09:43:20 +0100
|
||||
Subject: [PATCH] Fix out of bound chunks crashing server
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/WorldGenRegion.java b/src/main/java/net/minecraft/server/level/WorldGenRegion.java
|
||||
index cf1cb0996bb06ae7cf56e0ecf0c01f03da7fdd83..57154a7dd88f00ac7cd78f51ead718853e0d2101 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/WorldGenRegion.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/WorldGenRegion.java
|
||||
@@ -157,7 +157,10 @@ public class WorldGenRegion implements WorldGenLevel {
|
||||
if (ichunkaccess != null) {
|
||||
throw (RuntimeException) Util.pauseInIde((Throwable) (new RuntimeException(String.format("Chunk is not of correct status. Expecting %s, got %s | %s %s", leastStatus, ichunkaccess.getStatus(), chunkX, chunkZ))));
|
||||
} else {
|
||||
- throw (RuntimeException) Util.pauseInIde((Throwable) (new RuntimeException(String.format("We are asking a region for a chunk out of bound | %s %s", chunkX, chunkZ))));
|
||||
+ // Scissors start - Fix out of bound chunks crashing server
|
||||
+ // throw (RuntimeException) Util.pauseInIde((Throwable) (new RuntimeException(String.format("We are asking a region for a chunk out of bound | %s %s", chunkX, chunkZ))));
|
||||
+ return null;
|
||||
+ // Scissors end
|
||||
}
|
||||
}
|
||||
}
|
@ -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,35 +1,20 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Allink <arclicious@vivaldi.net>
|
||||
Date: Tue, 16 Aug 2022 17:13:02 +0100
|
||||
Date: Tue, 16 Aug 2022 18:14:16 +0100
|
||||
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
|
||||
index 0f70be614f8f5350ad558d0ae645cdf0027e1e76..6f036df37609daf33db3884174406e1ccd339735 100644
|
||||
index 26d43c229caf9f8504af7071c3a61ec6da7e27ec..ecceb3fc7f822d826b4a789fe72a8cd08e90d60e 100644
|
||||
--- a/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;
|
||||
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 {
|
||||
@@ -198,6 +198,11 @@ public final class CraftChatMessage {
|
||||
}
|
||||
|
||||
public static Component[] fromString(String message, boolean keepNewlines, boolean plain) {
|
||||
+ // Scissors start - Refuse to convert legacy messages over 1k characters
|
||||
+ if (message.length() > 1_000) {
|
||||
+ return new Component[]{Component.empty()};
|
||||
+ return new Component[]{TextComponent.EMPTY};
|
||||
+ }
|
||||
+ // Scissors end
|
||||
return new StringMessage(message, keepNewlines, plain).getOutput();
|
@ -0,0 +1,227 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: VideoGameSmash12 <videogamesm12@gmail.com>
|
||||
Date: Sun, 2 Oct 2022 19:43:40 -0600
|
||||
Subject: [PATCH] Adds configuration option to outright disable Game Master
|
||||
Blocks and fixes some configuration bugs
|
||||
|
||||
|
||||
diff --git a/src/main/java/com/github/atlasmediagroup/scissors/ScissorsConfig.java b/src/main/java/com/github/atlasmediagroup/scissors/ScissorsConfig.java
|
||||
index 52b0161711634f9ad8cecf58668737a726278f72..bb58d90e9d676761a43a12cbc1c3b687d00654b1 100644
|
||||
--- a/src/main/java/com/github/atlasmediagroup/scissors/ScissorsConfig.java
|
||||
+++ b/src/main/java/com/github/atlasmediagroup/scissors/ScissorsConfig.java
|
||||
@@ -65,8 +65,8 @@ public class ScissorsConfig
|
||||
config.options().header(HEADER);
|
||||
config.options().copyDefaults(true);
|
||||
|
||||
- version = getInt("config-version", 2);
|
||||
- set("config-version", 2);
|
||||
+ version = getInt("config-version", 3);
|
||||
+ set("config-version", 3);
|
||||
readConfig(ScissorsConfig.class, null);
|
||||
}
|
||||
|
||||
@@ -135,11 +135,17 @@ public class ScissorsConfig
|
||||
|
||||
// people still may want them to bypass permissions for warps
|
||||
public static boolean commandSignsBypassPermissions = false;
|
||||
- public static void commandSignsBypassPermissions()
|
||||
+ private static void commandSignsBypassPermissions()
|
||||
{
|
||||
commandSignsBypassPermissions = getBoolean("commandSignsBypassPermissions", false);
|
||||
}
|
||||
|
||||
+ public static boolean disableGameMasterBlocks = false;
|
||||
+ private static void disableGameMasterBlocks()
|
||||
+ {
|
||||
+ disableGameMasterBlocks = getBoolean("disableGameMasterBlocks", false);
|
||||
+ }
|
||||
+
|
||||
private static void set(String path, Object val)
|
||||
{
|
||||
config.set(path, val);
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
index dbf982c85ff361184a34b462bec331ac5b1a472c..8ec188a09dd1d5150a25fdf18f49deac1593fb4d 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 com.github.atlasmediagroup.scissors.ScissorsConfig;
|
||||
import com.github.atlasmediagroup.scissors.event.player.SpectatorTeleportEvent;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.primitives.Floats;
|
||||
@@ -987,7 +988,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
||||
@Override
|
||||
public void handleSetStructureBlock(ServerboundSetStructureBlockPacket packet) {
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel());
|
||||
- if (this.player.canUseGameMasterBlocks()) {
|
||||
+ if (!ScissorsConfig.disableGameMasterBlocks && this.player.canUseGameMasterBlocks()) { // Scissors - Add configuration option to completely disable game master blocks
|
||||
BlockPos blockposition = packet.getPos();
|
||||
BlockState iblockdata = this.player.level.getBlockState(blockposition);
|
||||
BlockEntity tileentity = this.player.level.getBlockEntity(blockposition);
|
||||
@@ -1045,7 +1046,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
||||
@Override
|
||||
public void handleSetJigsawBlock(ServerboundSetJigsawBlockPacket packet) {
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel());
|
||||
- if (this.player.canUseGameMasterBlocks()) {
|
||||
+ if (!ScissorsConfig.disableGameMasterBlocks && this.player.canUseGameMasterBlocks()) { // Scissors - Add configuration option to completely disable game master blocks
|
||||
BlockPos blockposition = packet.getPos();
|
||||
BlockState iblockdata = this.player.level.getBlockState(blockposition);
|
||||
BlockEntity tileentity = this.player.level.getBlockEntity(blockposition);
|
||||
@@ -1068,7 +1069,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
||||
@Override
|
||||
public void handleJigsawGenerate(ServerboundJigsawGeneratePacket packet) {
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel());
|
||||
- if (this.player.canUseGameMasterBlocks()) {
|
||||
+ if (!ScissorsConfig.disableGameMasterBlocks && this.player.canUseGameMasterBlocks()) { // Scissors - Add configuration option to completely disable game master blocks
|
||||
BlockPos blockposition = packet.getPos();
|
||||
BlockEntity tileentity = this.player.level.getBlockEntity(blockposition);
|
||||
|
||||
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 c93d21142c5f7b2799eeac7a8314ffdb7360162e..2279b7958c837a9616e8de2c2de53950d2f19a59 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/entity/JigsawBlockEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/JigsawBlockEntity.java
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.minecraft.world.level.block.entity;
|
||||
|
||||
+import com.github.atlasmediagroup.scissors.ScissorsConfig; // Scissors
|
||||
import com.github.atlasmediagroup.scissors.event.block.MasterBlockFireEvent;
|
||||
import com.google.common.collect.Lists;
|
||||
import java.util.Arrays;
|
||||
@@ -122,6 +123,12 @@ public class JigsawBlockEntity extends BlockEntity {
|
||||
}
|
||||
|
||||
public void generate(ServerLevel world, int maxDepth, boolean keepJigsaws) {
|
||||
+ // Scissors start - Add configuration option to completely disable jigsaw and structure blocks
|
||||
+ if (ScissorsConfig.disableGameMasterBlocks) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // Scissors end
|
||||
+
|
||||
// Scissors - Add master block fire event
|
||||
final BlockPos blockPos = this.getBlockPos();
|
||||
final MasterBlockFireEvent event = new MasterBlockFireEvent(new Location(this.getLevel().getWorld(), blockPos.getX(), blockPos.getY(), blockPos.getZ()));
|
||||
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 ed297126ebc05c1eb81e32b7644552d5627b3697..896afd5ce022a4f4d83f2985112bcf0e3fc5f37d 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/entity/StructureBlockEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/StructureBlockEntity.java
|
||||
@@ -7,6 +7,7 @@ import java.util.Random;
|
||||
import java.util.stream.Stream;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
+import com.github.atlasmediagroup.scissors.ScissorsConfig;
|
||||
import com.github.atlasmediagroup.scissors.event.block.MasterBlockFireEvent;
|
||||
import net.minecraft.ResourceLocationException;
|
||||
import net.minecraft.Util;
|
||||
@@ -130,6 +131,12 @@ public class StructureBlockEntity extends BlockEntity {
|
||||
}
|
||||
|
||||
private void updateBlockState() {
|
||||
+ // Scissors start - Add configuration option to completely disable jigsaw and structure blocks
|
||||
+ if (ScissorsConfig.disableGameMasterBlocks) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // Scissors end
|
||||
+
|
||||
if (this.level != null) {
|
||||
BlockPos blockPos = this.getBlockPos();
|
||||
BlockState blockState = this.level.getBlockState(blockPos);
|
||||
@@ -152,6 +159,12 @@ public class StructureBlockEntity extends BlockEntity {
|
||||
}
|
||||
|
||||
public boolean usedBy(Player player) {
|
||||
+ // Scissors start - Add configuration option to completely disable jigsaw and structure blocks
|
||||
+ if (ScissorsConfig.disableGameMasterBlocks) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ // Scissors end
|
||||
+
|
||||
if (!player.canUseGameMasterBlocks()) {
|
||||
return false;
|
||||
} else {
|
||||
@@ -265,6 +278,12 @@ public class StructureBlockEntity extends BlockEntity {
|
||||
}
|
||||
|
||||
public boolean detectSize() {
|
||||
+ // Scissors start - Add configuration option to completely disable jigsaw and structure blocks
|
||||
+ if (ScissorsConfig.disableGameMasterBlocks) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ // Scissors end
|
||||
+
|
||||
if (this.mode != StructureMode.SAVE) {
|
||||
return false;
|
||||
} else {
|
||||
@@ -324,13 +343,18 @@ public class StructureBlockEntity extends BlockEntity {
|
||||
}
|
||||
|
||||
public boolean saveStructure(boolean bl) {
|
||||
+ // Scissors - Add option to completely disable structure and jigsaw blocks
|
||||
+ if (ScissorsConfig.disableGameMasterBlocks) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ // Scissors end
|
||||
+
|
||||
if (this.mode == StructureMode.SAVE && !this.level.isClientSide && this.structureName != null) {
|
||||
// Scissors - Add master block fire event
|
||||
final BlockPos pos = this.getBlockPos();
|
||||
final MasterBlockFireEvent event = new MasterBlockFireEvent(new Location(this.getLevel().getWorld(), pos.getX(), pos.getY(), pos.getZ()));
|
||||
|
||||
- if (!event.callEvent())
|
||||
- {
|
||||
+ if (!event.callEvent()) {
|
||||
return false;
|
||||
}
|
||||
// Scissors end
|
||||
@@ -371,6 +395,12 @@ public class StructureBlockEntity extends BlockEntity {
|
||||
}
|
||||
|
||||
public boolean loadStructure(ServerLevel world, boolean bl) {
|
||||
+ // Scissors start - Add configuration option to completely disable jigsaw and structure blocks
|
||||
+ if (ScissorsConfig.disableGameMasterBlocks) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ // Scissors end
|
||||
+
|
||||
if (this.mode == StructureMode.LOAD && this.structureName != null) {
|
||||
// Scissors - Add master block fire event
|
||||
final BlockPos blockPos = this.getBlockPos();
|
||||
@@ -398,6 +428,12 @@ public class StructureBlockEntity extends BlockEntity {
|
||||
}
|
||||
|
||||
public boolean loadStructure(ServerLevel world, boolean bl, StructureTemplate structureTemplate) {
|
||||
+ // Scissors start - Add configuration option to completely disable jigsaw and structure blocks
|
||||
+ if (ScissorsConfig.disableGameMasterBlocks) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ // Scissors end
|
||||
+
|
||||
// Scissors - Add master block fire event
|
||||
final BlockPos blockPos = this.getBlockPos();
|
||||
final MasterBlockFireEvent event = new MasterBlockFireEvent(new Location(this.getLevel().getWorld(), blockPos.getX(), blockPos.getY(), blockPos.getZ()));
|
||||
@@ -436,6 +472,12 @@ public class StructureBlockEntity extends BlockEntity {
|
||||
}
|
||||
|
||||
public void unloadStructure() {
|
||||
+ // Scissors start - Add configuration option to completely disable jigsaw and structure blocks
|
||||
+ if (ScissorsConfig.disableGameMasterBlocks) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // Scissors end
|
||||
+
|
||||
// Scissors - Add master block fire event
|
||||
final BlockPos blockPos = this.getBlockPos();
|
||||
final MasterBlockFireEvent event = new MasterBlockFireEvent(new Location(this.getLevel().getWorld(), blockPos.getX(), blockPos.getY(), blockPos.getZ()));
|
||||
@@ -454,6 +496,12 @@ public class StructureBlockEntity extends BlockEntity {
|
||||
}
|
||||
|
||||
public boolean isStructureLoadable() {
|
||||
+ // Scissors start - Add configuration option to completely disable jigsaw and structure blocks
|
||||
+ if (ScissorsConfig.disableGameMasterBlocks) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ // Scissors end
|
||||
+
|
||||
if (this.mode == StructureMode.LOAD && !this.level.isClientSide && this.structureName != null) {
|
||||
ServerLevel serverLevel = (ServerLevel)this.level;
|
||||
StructureManager structureManager = serverLevel.getStructureManager();
|
@ -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,21 +1,14 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Allink <arclicious@vivaldi.net>
|
||||
Date: Sun, 27 Nov 2022 05:14:18 +0000
|
||||
Date: Sun, 27 Nov 2022 04:04:14 +0000
|
||||
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
|
||||
index 2096e8a0bdbcfc865f175f3a01ab688542481531..15d375221c253dc4ca1b598eb80b4638eba6f8d0 100644
|
||||
index 3a088afd8269606543ebc9fb2074eb70431fcd39..561e68806b50c417f08a20bcf87c44d117b9f41c 100644
|
||||
--- a/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 @@
|
||||
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 {
|
||||
@@ -41,9 +41,13 @@ public abstract class AbstractHurtingProjectile extends Projectile {
|
||||
double d6 = Math.sqrt(d3 * d3 + d4 * d4 + d5 * d5);
|
||||
|
||||
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}));
|
||||
}
|
||||
|
||||
@ -49,16 +42,16 @@ index 2096e8a0bdbcfc865f175f3a01ab688542481531..15d375221c253dc4ca1b598eb80b4638
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ this.xPower = MathUtility.clampDouble(xPower, -1024, 1024);
|
||||
+ this.yPower = MathUtility.clampDouble(yPower, -1024, 1024);
|
||||
+ this.zPower = MathUtility.clampDouble(zPower, -1024, 1024);
|
||||
+ this.xPower = Math.min(Math.max(xPower, -1024), 1024);
|
||||
+ this.yPower = Math.min(Math.max(yPower, -1024), 1024);
|
||||
+ this.zPower = Math.min(Math.max(zPower, -1024), 1024);
|
||||
+ }
|
||||
+ // Scissors end
|
||||
+
|
||||
@Override
|
||||
public void readAdditionalSaveData(CompoundTag 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);
|
||||
|
||||
if (nbttaglist.size() == 3) {
|
||||
@ -75,7 +68,7 @@ index 2096e8a0bdbcfc865f175f3a01ab688542481531..15d375221c253dc4ca1b598eb80b4638
|
||||
}
|
||||
}
|
||||
|
||||
@@ -184,9 +212,12 @@ public abstract class AbstractHurtingProjectile extends Projectile {
|
||||
@@ -192,9 +219,13 @@ public abstract class AbstractHurtingProjectile extends Projectile {
|
||||
Vec3 vec3d = entity.getLookAngle();
|
||||
|
||||
this.setDeltaMovement(vec3d);
|
||||
@ -86,8 +79,9 @@ index 2096e8a0bdbcfc865f175f3a01ab688542481531..15d375221c253dc4ca1b598eb80b4638
|
||||
+ //this.xPower = vec3d.x * 0.1D;
|
||||
+ //this.yPower = vec3d.y * 0.1D;
|
||||
+ //this.zPower = vec3d.z * 0.1D;
|
||||
+
|
||||
+ setPower(vec3d.x * 0.1D, vec3d.y * 0.1D, vec3d.z * 0.1D);
|
||||
+ // Scissors end
|
||||
this.setOwner(entity);
|
||||
}
|
||||
|
||||
return true;
|
||||
} else {
|
@ -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) {
|
@ -5,11 +5,11 @@ 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
|
||||
index a890f52e2214242f6e31353bb912813d00e41045..bc0e1938d6e1faca64bb041442bad9e501708fe4 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;
|
||||
@@ -173,7 +173,7 @@ public abstract class MinMaxBounds<T extends Number> {
|
||||
return double_ == null ? null : double_ * double_;
|
||||
}
|
||||
|
||||
- private Doubles(@Nullable Double min, @Nullable Double max) {
|
||||
@ -18,18 +18,10 @@ index 60d32afe2eecdfebdc91531ca3672f8f130ac30e..73b0f516f80ef810379860ea74697a34
|
||||
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
|
||||
index 0fb8f32427843f4bfd90ab88ecb3ab3e4a4fda31..c9b5f7715d4a866d477c65adb39f11cc46e5623a 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 {
|
||||
@@ -58,9 +58,27 @@ public class EntitySelector {
|
||||
this.includesEntities = includesNonPlayers;
|
||||
this.worldLimited = localWorldOnly;
|
||||
this.predicate = basePredicate;
|
||||
@ -44,12 +36,12 @@ index f25b9330e068c7d9e12cb57a7761cfef9ebaf7bc..ba549e6e5da75413ae3b4083f8b7a552
|
||||
- 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),
|
||||
+ Math.min(Math.max(box.minX, -1024), 1025),
|
||||
+ Math.min(Math.max(box.minY, -1024), 1025),
|
||||
+ Math.min(Math.max(box.minZ, -1024), 1025),
|
||||
+ Math.min(Math.max(box.maxX, -1024), 1025),
|
||||
+ Math.min(Math.max(box.maxY, -1024), 1025),
|
||||
+ Math.min(Math.max(box.maxZ, -1024), 1025),
|
||||
+ false
|
||||
+ );
|
||||
+ } else {
|
@ -1,22 +1,14 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Luna <lunahatesgogle@gmail.com>
|
||||
Date: Fri, 28 Apr 2023 16:29:23 -0300
|
||||
Date: Fri, 28 Apr 2023 18:24:09 -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
|
||||
index 3d9c3e3ec56bc1bf5719e31d169015eaf598bde3..1233c8904f6a4f91931b42a08c514d783267a4c8 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 {
|
||||
@@ -14,6 +14,12 @@ public class MapDecoration {
|
||||
private final Component name;
|
||||
|
||||
public MapDecoration(MapDecoration.Type type, byte x, byte z, byte rotation, @Nullable Component text) {
|
@ -1,14 +1,14 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Luna <lunahatesgogle@gmail.com>
|
||||
Date: Fri, 28 Apr 2023 16:34:15 -0300
|
||||
Date: Fri, 28 Apr 2023 18:24:55 -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
|
||||
index 6f64d1ce0f5b20e1579f8af64c08ef8fc4e4444b..d78036b62bb36539d3d3e1a8299af2fa60ebd379 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 {
|
||||
@@ -357,6 +357,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) {
|
||||
@ -19,5 +19,5 @@ index 3b12030b49b1c539684d75ca3896eb498400ef99..a1f042e5329343489cf30e436a8f553d
|
||||
+ // 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;
|
||||
float f = (float) (x - (double) this.x) / (float) i;
|
||||
float f1 = (float) (z - (double) this.z) / (float) i;
|
@ -1,14 +1,14 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Luna <lunahatesgogle@gmail.com>
|
||||
Date: Fri, 28 Apr 2023 16:44:50 -0300
|
||||
Date: Fri, 28 Apr 2023 18:25:56 -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
|
||||
index a002713686e66faf0d18662586a7a236c27ca7d2..795d72084ff196c5f4a0ff4bafd3ac88257fc379 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 {
|
||||
@@ -1354,7 +1354,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();
|
||||
@ -23,4 +23,4 @@ index 2ac23779222369ace69f1e3f7fb12184865b7a43..05c8e4e30b2dce565e84f4c09b3f2724
|
||||
+ // Scissors end
|
||||
}
|
||||
|
||||
this.entityLookup.addNewEntity(player); // Paper - rewite chunk system
|
||||
this.entityManager.addNewEntity(player); // CraftBukkit - decompile error
|
@ -0,0 +1,19 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Luna <lunahatesgogle@gmail.com>
|
||||
Date: Fri, 28 Apr 2023 18:32:03 -0300
|
||||
Subject: [PATCH] Don't warn on duplicate entity UUIDs
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/entity/PersistentEntitySectionManager.java b/src/main/java/net/minecraft/world/level/entity/PersistentEntitySectionManager.java
|
||||
index 8cb246863e06c5b95ba1442e2ec47095026c4f39..48990a8192465e11b27c072fc7d4351a6c5fb7a0 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/entity/PersistentEntitySectionManager.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/entity/PersistentEntitySectionManager.java
|
||||
@@ -147,7 +147,7 @@ public class PersistentEntitySectionManager<T extends EntityAccess> implements A
|
||||
return true;
|
||||
}
|
||||
// Paper end
|
||||
- PersistentEntitySectionManager.LOGGER.warn("UUID of added entity already exists: {}", entity);
|
||||
+ // Scissors - Don't warn on duplicate entity UUIDs
|
||||
// Paper start
|
||||
if (net.minecraft.world.level.Level.DEBUG_ENTITIES && ((Entity) entity).level.paperConfig.duplicateUUIDMode != com.destroystokyo.paper.PaperWorldConfig.DuplicateUUIDMode.NOTHING) {
|
||||
if (((Entity) entity).addedToWorldStack != null) {
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Luna <lunahatesgogle@gmail.com>
|
||||
Date: Mon, 29 May 2023 19:47:48 -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 6978d14c6bd90ffb640e39e8666430d95d5ef45c..474ed00c09d58a7796cd543c9bcf8752e2f9f742 100644
|
||||
--- a/src/main/java/net/minecraft/network/chat/Component.java
|
||||
+++ b/src/main/java/net/minecraft/network/chat/Component.java
|
||||
@@ -201,6 +201,12 @@ public interface Component extends Message, FormattedText, Iterable<Component> {
|
||||
} else 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
|
||||
+
|
||||
MutableComponent ichatmutablecomponent = null;
|
||||
Iterator iterator = jsonarray.iterator();
|
||||
|
@ -0,0 +1,151 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Luna <lunahatesgogle@gmail.com>
|
||||
Date: Wed, 31 May 2023 20:44:20 -0300
|
||||
Subject: [PATCH] Add depth limit to Component deserializer
|
||||
|
||||
|
||||
diff --git a/src/main/java/com/github/atlasmediagroup/scissors/ScissorsConfig.java b/src/main/java/com/github/atlasmediagroup/scissors/ScissorsConfig.java
|
||||
index bb58d90e9d676761a43a12cbc1c3b687d00654b1..74f33cba7d713eddca5a58a2b33cad357792145e 100644
|
||||
--- a/src/main/java/com/github/atlasmediagroup/scissors/ScissorsConfig.java
|
||||
+++ b/src/main/java/com/github/atlasmediagroup/scissors/ScissorsConfig.java
|
||||
@@ -65,8 +65,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);
|
||||
}
|
||||
|
||||
@@ -146,6 +146,12 @@ public class ScissorsConfig
|
||||
disableGameMasterBlocks = getBoolean("disableGameMasterBlocks", 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 474ed00c09d58a7796cd543c9bcf8752e2f9f742..68e99223b0b084bdfdb9990780150bbc7d8ad8ea 100644
|
||||
--- a/src/main/java/net/minecraft/network/chat/Component.java
|
||||
+++ b/src/main/java/net/minecraft/network/chat/Component.java
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.minecraft.network.chat;
|
||||
|
||||
+import com.github.atlasmediagroup.scissors.ScissorsConfig; // Scissors
|
||||
import com.google.common.collect.Lists;
|
||||
import io.papermc.paper.adventure.AdventureComponent; // Paper
|
||||
import com.google.gson.Gson;
|
||||
@@ -33,6 +34,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
|
||||
|
||||
@@ -192,27 +194,31 @@ 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 new TextComponent(jsonelement.getAsString());
|
||||
} else 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
|
||||
|
||||
MutableComponent 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;
|
||||
@@ -236,12 +242,17 @@ public interface Component extends Message, FormattedText, Iterable<Component> {
|
||||
|
||||
if (jsonobject.has("translate")) {
|
||||
s = GsonHelper.getAsString(jsonobject, "translate");
|
||||
+
|
||||
+ // Penalize depth for placeholders in translate & fallback
|
||||
+ long translate_placeholders = PLACEHOLDER_PATTERN.matcher(s).results().count();
|
||||
+ int penalty = (int)translate_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] = this.deserialize(jsonarray1.get(i), type, jsondeserializationcontext);
|
||||
+ aobject[i] = this.deserialize(jsonarray1.get(i), jsondeserializationcontext, depth + 1 + penalty);
|
||||
if (aobject[i] instanceof TextComponent) {
|
||||
TextComponent chatcomponenttext = (TextComponent) aobject[i];
|
||||
|
||||
@@ -264,7 +275,7 @@ public interface Component extends Message, FormattedText, Iterable<Component> {
|
||||
|
||||
object = new ScoreComponent(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);
|
||||
|
||||
object = new SelectorComponent(GsonHelper.getAsString(jsonobject, "selector"), optional);
|
||||
} else if (jsonobject.has("keybind")) {
|
||||
@@ -275,7 +286,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);
|
||||
|
||||
if (jsonobject.has("block")) {
|
||||
@@ -300,7 +311,7 @@ public interface Component extends Message, FormattedText, Iterable<Component> {
|
||||
}
|
||||
|
||||
for (int j = 0; j < jsonarray2.size(); ++j) {
|
||||
- ((MutableComponent) object).append(this.deserialize(jsonarray2.get(j), type, jsondeserializationcontext));
|
||||
+ ((MutableComponent) object).append(this.deserialize(jsonarray2.get(j), jsondeserializationcontext, depth + 1));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -309,8 +320,13 @@ public interface Component extends Message, FormattedText, Iterable<Component> {
|
||||
}
|
||||
}
|
||||
|
||||
- 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();
|
||||
+ public MutableComponent deserialize(JsonElement jsonelement, Type type, JsonDeserializationContext jsondeserializationcontext) throws JsonParseException {
|
||||
+ return this.deserialize(jsonelement, jsondeserializationcontext, 1);
|
||||
+ }
|
||||
+
|
||||
+ 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,11 +1,11 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Allink <arclicious@vivaldi.net>
|
||||
Date: Fri, 2 Jun 2023 22:13:54 +0100
|
||||
Date: Fri, 2 Jun 2023 23:30:40 +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
|
||||
index 28a13331ac7713cde725bf7c7ce6be959227d506..4f5573d1cc5630519122010d44f0a82e2948e767 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 {
|
@ -1,40 +1,40 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Allink <arclicious@vivaldi.net>
|
||||
Date: Fri, 2 Jun 2023 20:55:18 +0100
|
||||
Date: Fri, 2 Jun 2023 23:42:46 +0100
|
||||
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
|
||||
index a2b96f7b1e98586017dbbf28a73446196738ee99..0227e2c7197c3684677f76ff7f0fe0acc21b6c14 100644
|
||||
index 8ec188a09dd1d5150a25fdf18f49deac1593fb4d..0eb54b2b36df7870724e33d75d1d3f6d5492ffab 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -1,6 +1,8 @@
|
||||
package net.minecraft.server.network;
|
||||
|
||||
import me.totalfreedom.scissors.ScissorsConfig;
|
||||
+import me.totalfreedom.scissors.event.block.CommandBlockPlayerEditEvent;
|
||||
+import me.totalfreedom.scissors.event.block.CommandMinecartPlayerEditEvent;
|
||||
import me.totalfreedom.scissors.event.player.SpectatorTeleportEvent;
|
||||
import com.github.atlasmediagroup.scissors.ScissorsConfig;
|
||||
+import com.github.atlasmediagroup.scissors.event.block.CommandBlockPlayerEditEvent;
|
||||
+import com.github.atlasmediagroup.scissors.event.block.CommandMinecartPlayerEditEvent;
|
||||
import com.github.atlasmediagroup.scissors.event.player.SpectatorTeleportEvent;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.primitives.Floats;
|
||||
@@ -160,6 +162,7 @@ import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.entity.player.ProfilePublicKey;
|
||||
@@ -134,6 +136,7 @@ import net.minecraft.world.entity.player.ChatVisiblity;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
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.VoxelShape;
|
||||
@@ -186,6 +189,7 @@ import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
||||
import org.bukkit.craftbukkit.util.LazyPlayerSet;
|
||||
import org.bukkit.craftbukkit.util.Waitable;
|
||||
import org.bukkit.entity.Player;
|
||||
+import org.bukkit.entity.minecart.CommandMinecart;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
// CraftBukkit start
|
||||
@@ -1001,6 +1005,21 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
this.player.level().getChunkAt(blockposition).setBlockEntity(tileentity);
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.block.SignChangeEvent;
|
||||
@@ -902,6 +906,21 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
||||
this.player.level.getChunkAt(blockposition).setBlockEntity(tileentity);
|
||||
}
|
||||
|
||||
+ // Scissors start - Implement command block events
|
||||
@ -55,8 +55,8 @@ index a2b96f7b1e98586017dbbf28a73446196738ee99..0227e2c7197c3684677f76ff7f0fe0ac
|
||||
commandblocklistenerabstract.setCommand(s);
|
||||
commandblocklistenerabstract.setTrackOutput(flag);
|
||||
if (!flag) {
|
||||
@@ -1032,7 +1051,27 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
BaseCommandBlock commandblocklistenerabstract = packet.getCommandBlock(this.player.level());
|
||||
@@ -933,7 +952,27 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
||||
BaseCommandBlock commandblocklistenerabstract = packet.getCommandBlock(this.player.level);
|
||||
|
||||
if (commandblocklistenerabstract != null) {
|
||||
- commandblocklistenerabstract.setCommand(packet.getCommand());
|
@ -1,14 +1,14 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Luna <lunahatesgogle@gmail.com>
|
||||
Date: Wed, 7 Jun 2023 16:50:35 -0300
|
||||
Date: Wed, 7 Jun 2023 17:02:00 -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
|
||||
index 8038e3a10b563321df1e8cedd26b256078ce745a..7fb177779fa2bf30e4d190a277691eeab375120e 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
|
||||
@@ -84,7 +84,7 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider {
|
||||
private double effectRange = -1;
|
||||
|
||||
public double getEffectRange() {
|
||||
@ -17,7 +17,7 @@ index f2325c0c475bb465f5275f78c71949648a860d0c..4ec228ce026ee39eebd17d180fb5caea
|
||||
return this.levels * 10 + 10;
|
||||
} else {
|
||||
return effectRange;
|
||||
@@ -415,6 +415,7 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider, Name
|
||||
@@ -410,6 +410,7 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider {
|
||||
|
||||
this.lockKey = LockCode.fromTag(nbt);
|
||||
this.effectRange = nbt.contains(PAPER_RANGE_TAG, 6) ? nbt.getDouble(PAPER_RANGE_TAG) : -1; // Paper
|
46
patches/server/0057-Fix-packet-related-lag-exploits.patch
Normal file
46
patches/server/0057-Fix-packet-related-lag-exploits.patch
Normal file
@ -0,0 +1,46 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Luna <lunahatesgogle@gmail.com>
|
||||
Date: Tue, 4 Jul 2023 18:49:34 -0300
|
||||
Subject: [PATCH] Fix packet-related lag exploits
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
index d3fd35a33da5ce40667781f7ee35e89531b4ea96..f92385c4f72fce6ceec40e21ea081eeb1bd8fc25 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -866,7 +866,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
||||
this.player.sendMessage(new TranslatableComponent("advMode.notEnabled"), Util.NIL_UUID);
|
||||
} else if (!this.player.canUseGameMasterBlocks() && (!this.player.isCreative() || !this.player.getBukkitEntity().hasPermission("minecraft.commandblock"))) { // Paper - command block permission
|
||||
this.player.sendMessage(new TranslatableComponent("advMode.notAllowed"), Util.NIL_UUID);
|
||||
- } else {
|
||||
+ } else if (this.player.level.isLoadedAndInBounds(packet.getPos())) { // Scissors
|
||||
BaseCommandBlock commandblocklistenerabstract = null;
|
||||
CommandBlockEntity tileentitycommand = null;
|
||||
BlockPos blockposition = packet.getPos();
|
||||
@@ -1027,7 +1027,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
||||
@Override
|
||||
public void handleSetStructureBlock(ServerboundSetStructureBlockPacket packet) {
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel());
|
||||
- if (!ScissorsConfig.disableGameMasterBlocks && this.player.canUseGameMasterBlocks()) { // Scissors - Add configuration option to completely disable game master blocks
|
||||
+ if (!ScissorsConfig.disableGameMasterBlocks && this.player.canUseGameMasterBlocks() && this.player.level.isLoadedAndInBounds(packet.getPos())) { // Scissors
|
||||
BlockPos blockposition = packet.getPos();
|
||||
BlockState iblockdata = this.player.level.getBlockState(blockposition);
|
||||
BlockEntity tileentity = this.player.level.getBlockEntity(blockposition);
|
||||
@@ -1085,7 +1085,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
||||
@Override
|
||||
public void handleSetJigsawBlock(ServerboundSetJigsawBlockPacket packet) {
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel());
|
||||
- if (!ScissorsConfig.disableGameMasterBlocks && this.player.canUseGameMasterBlocks()) { // Scissors - Add configuration option to completely disable game master blocks
|
||||
+ if (!ScissorsConfig.disableGameMasterBlocks && this.player.canUseGameMasterBlocks() && this.player.level.isLoadedAndInBounds(packet.getPos())) { // Scissors
|
||||
BlockPos blockposition = packet.getPos();
|
||||
BlockState iblockdata = this.player.level.getBlockState(blockposition);
|
||||
BlockEntity tileentity = this.player.level.getBlockEntity(blockposition);
|
||||
@@ -1108,7 +1108,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
|
||||
@Override
|
||||
public void handleJigsawGenerate(ServerboundJigsawGeneratePacket packet) {
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel());
|
||||
- if (!ScissorsConfig.disableGameMasterBlocks && this.player.canUseGameMasterBlocks()) { // Scissors - Add configuration option to completely disable game master blocks
|
||||
+ if (!ScissorsConfig.disableGameMasterBlocks && this.player.canUseGameMasterBlocks() && this.player.level.isLoadedAndInBounds(packet.getPos())) { // Scissors
|
||||
BlockPos blockposition = packet.getPos();
|
||||
BlockEntity tileentity = this.player.level.getBlockEntity(blockposition);
|
||||
|
44
patches/server/0058-Limit-save-data-for-Bees-and-Vexes.patch
Normal file
44
patches/server/0058-Limit-save-data-for-Bees-and-Vexes.patch
Normal file
@ -0,0 +1,44 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Allink <arclicious@vivaldi.net>
|
||||
Date: Wed, 5 Jul 2023 22:58:24 +0100
|
||||
Subject: [PATCH] Limit save data for Bees and Vexes
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/animal/Bee.java b/src/main/java/net/minecraft/world/entity/animal/Bee.java
|
||||
index 083640b7e4aee75db9b884aebd640c9410e669ca..76a2d683c7a32a8af2683cb2d7a3e33111064b27 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/animal/Bee.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/animal/Bee.java
|
||||
@@ -223,8 +223,12 @@ public class Bee extends Animal implements NeutralMob, FlyingAnimal {
|
||||
@Override
|
||||
public void readAdditionalSaveData(CompoundTag nbt) {
|
||||
this.hivePos = null;
|
||||
- if (nbt.contains("HivePos")) {
|
||||
- this.hivePos = NbtUtils.readBlockPos(nbt.getCompound("HivePos"));
|
||||
+ if (nbt.contains("HivePos"))
|
||||
+ {
|
||||
+ // Scissors start - Limit HivePos
|
||||
+ final BlockPos savedHivePos = NbtUtils.readBlockPos(nbt.getCompound("HivePos"));
|
||||
+ this.hivePos = this.level.isLoadedAndInBounds(savedHivePos) ? savedHivePos : null;
|
||||
+ // Scissors end - Limit HivePos
|
||||
}
|
||||
|
||||
this.savedFlowerPos = null;
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/monster/Vex.java b/src/main/java/net/minecraft/world/entity/monster/Vex.java
|
||||
index f78f3f2d740f7b4800e17d9bc64b7b4fedda49b9..a4c4c7cd5a4325916836728f11d2164ad211143b 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/monster/Vex.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/monster/Vex.java
|
||||
@@ -107,8 +107,12 @@ public class Vex extends Monster {
|
||||
@Override
|
||||
public void readAdditionalSaveData(CompoundTag nbt) {
|
||||
super.readAdditionalSaveData(nbt);
|
||||
- if (nbt.contains("BoundX")) {
|
||||
- this.boundOrigin = new BlockPos(nbt.getInt("BoundX"), nbt.getInt("BoundY"), nbt.getInt("BoundZ"));
|
||||
+ if (nbt.contains("BoundX"))
|
||||
+ {
|
||||
+ // Scissors start - Limit Vex bound origin
|
||||
+ final BlockPos savedBoundOrigin = new BlockPos(nbt.getInt("BoundX"), nbt.getInt("BoundY"), nbt.getInt("BoundZ"));
|
||||
+ this.boundOrigin = this.level.isLoadedAndInBounds(savedBoundOrigin) ? savedBoundOrigin : null;
|
||||
+ // Scissors end - Limit Vex bound origin
|
||||
}
|
||||
|
||||
if (nbt.contains("LifeTicks")) {
|
32
patches/server/0059-Mute-invalid-attributes.patch
Normal file
32
patches/server/0059-Mute-invalid-attributes.patch
Normal file
@ -0,0 +1,32 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Allink <arclicious@vivaldi.net>
|
||||
Date: Thu, 6 Jul 2023 23:01:12 +0100
|
||||
Subject: [PATCH] Mute invalid attributes
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java b/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java
|
||||
index 9cbfda029782385d1a7987f5be46d450bd8a758e..2421573bbc738ce5c2ac0e5a3013a4813d807dc5 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java
|
||||
@@ -127,7 +127,7 @@ public class AttributeMap {
|
||||
}
|
||||
|
||||
}, () -> {
|
||||
- LOGGER.warn("Ignoring unknown attribute '{}'", (Object)string);
|
||||
+ // LOGGER.warn("Ignoring unknown attribute '{}'", (Object)string); // Scissors - Mute invalid attributes
|
||||
});
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeModifier.java b/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeModifier.java
|
||||
index 5f94be8e8793f0b5b99e630882f53199d688eadf..7da1c212ff15940c849ac27061d47c5d9ffb1a30 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeModifier.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeModifier.java
|
||||
@@ -90,7 +90,7 @@ public class AttributeModifier {
|
||||
AttributeModifier.Operation operation = AttributeModifier.Operation.fromValue(nbt.getInt("Operation"));
|
||||
return new AttributeModifier(uUID, nbt.getString("Name"), nbt.getDouble("Amount"), operation);
|
||||
} catch (Exception var3) {
|
||||
- LOGGER.warn("Unable to create attribute: {}", (Object)var3.getMessage());
|
||||
+ // LOGGER.warn("Unable to create attribute: {}", (Object)var3.getMessage()); // Scissors - Mute invalid attributes
|
||||
return null;
|
||||
}
|
||||
}
|
32
patches/server/0060-Mute-invalid-Enderdragon-phases.patch
Normal file
32
patches/server/0060-Mute-invalid-Enderdragon-phases.patch
Normal file
@ -0,0 +1,32 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Allink <arclicious@vivaldi.net>
|
||||
Date: Thu, 6 Jul 2023 23:34:46 +0100
|
||||
Subject: [PATCH] Mute invalid Enderdragon phases
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/boss/enderdragon/phases/DragonChargePlayerPhase.java b/src/main/java/net/minecraft/world/entity/boss/enderdragon/phases/DragonChargePlayerPhase.java
|
||||
index 235b1548ccd1ff6a7ff05fc6a903d8b053aea5ce..92b4bd06c53e1f2c5c4c05ec7dd10e15889f4ebb 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/boss/enderdragon/phases/DragonChargePlayerPhase.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/boss/enderdragon/phases/DragonChargePlayerPhase.java
|
||||
@@ -19,7 +19,7 @@ public class DragonChargePlayerPhase extends AbstractDragonPhaseInstance {
|
||||
@Override
|
||||
public void doServerTick() {
|
||||
if (this.targetLocation == null) {
|
||||
- LOGGER.warn("Aborting charge player as no target was set.");
|
||||
+ // LOGGER.warn("Aborting charge player as no target was set."); // Scissors - Mute invalid Enderdragon phases
|
||||
this.dragon.getPhaseManager().setPhase(EnderDragonPhase.HOLDING_PATTERN);
|
||||
} else if (this.timeSinceCharge > 0 && this.timeSinceCharge++ >= 10) {
|
||||
this.dragon.getPhaseManager().setPhase(EnderDragonPhase.HOLDING_PATTERN);
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/boss/enderdragon/phases/DragonStrafePlayerPhase.java b/src/main/java/net/minecraft/world/entity/boss/enderdragon/phases/DragonStrafePlayerPhase.java
|
||||
index 318a288a9170254b682955d96a150e99ca89b345..bcdd44cc2927791eae8492d316f26b52b58a2a06 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/boss/enderdragon/phases/DragonStrafePlayerPhase.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/boss/enderdragon/phases/DragonStrafePlayerPhase.java
|
||||
@@ -29,7 +29,7 @@ public class DragonStrafePlayerPhase extends AbstractDragonPhaseInstance {
|
||||
@Override
|
||||
public void doServerTick() {
|
||||
if (this.attackTarget == null) {
|
||||
- LOGGER.warn("Skipping player strafe phase because no player was found");
|
||||
+ // LOGGER.warn("Skipping player strafe phase because no player was found"); // Scissors - Mute invalid Enderdragon phases
|
||||
this.dragon.getPhaseManager().setPhase(EnderDragonPhase.HOLDING_PATTERN);
|
||||
} else {
|
||||
if (this.currentPath != null && this.currentPath.isDone()) {
|
@ -1,7 +1,7 @@
|
||||
pluginManagement {
|
||||
repositories {
|
||||
gradlePluginPortal()
|
||||
maven("https://repo.papermc.io/repository/maven-public/")
|
||||
maven("https://papermc.io/repo/repository/maven-public/")
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user