Patch cleanup 2 (#112)

* First pass

* Second pass

* Limit string tag visitors to 1024 elements

* Split configuration patch into multiple patches

* Third and final pass

* Fix build error
This commit is contained in:
Luna 2023-07-01 17:21:13 -03:00 committed by GitHub
parent 76bd4f5ff2
commit 41e0723e0e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
51 changed files with 834 additions and 961 deletions

View File

@ -1,31 +1,34 @@
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 6d3d573ffc118e7f4d76422dc014a7df0384bb49..42b129bd0da13136a98a52c224cc71c27c6af173 100644
index 6d3d573ffc118e7f4d76422dc014a7df0384bb49..0ea1fe86fcd9d9c06648593332be3b4286af81bd 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -7,8 +7,10 @@ plugins {
@@ -7,8 +7,12 @@ plugins {
}
dependencies {
- implementation(project(":paper-api"))
- implementation(project(":paper-mojangapi"))
+ // Scissors start
+ implementation(project(":Scissors-API"))
+ implementation("io.papermc.paper:paper-mojangapi:1.20.1-R0.1-SNAPSHOT") {
+ exclude("io.papermc.paper", "paper-api")
+ }
+ // Scissors end
// Paper start
implementation("org.jline:jline-terminal-jansi:3.21.0")
implementation("net.minecrell:terminalconsoleappender:1.3.0")
@@ -60,11 +62,17 @@ tasks.jar {
@@ -60,11 +64,19 @@ 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
- val gitBranch = git("rev-parse", "--abbrev-ref", "HEAD").getText().trim() // Paper
+ // Scissors start
+ var gitBranch: String;
+ if (System.getenv("JENKINS_URL") == null)
+ {
@ -33,25 +36,26 @@ index 6d3d573ffc118e7f4d76422dc014a7df0384bb49..42b129bd0da13136a98a52c224cc71c2
+ } else {
+ gitBranch = System.getenv("GITHUB_BRANCH")
+ }
+ // Scissors end
attributes(
"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,
@@ -136,7 +144,7 @@ fun TaskContainer.registerRunTask(
@@ -136,7 +148,7 @@ fun TaskContainer.registerRunTask(
name: String,
block: JavaExec.() -> Unit
): TaskProvider<JavaExec> = register<JavaExec>(name) {
- group = "paper"
+ group = "paperweight"
+ group = "paperweight" // Scissors
mainClass.set("org.bukkit.craftbukkit.Main")
standardInput = System.`in`
workingDir = rootProject.layout.projectDirectory
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 4b002e8b75d117b726b0de274a76d3596fce015b..a46d3f40642bbf249c2d24e689f474d07175ca09 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 {
@ -59,7 +63,7 @@ index 4b002e8b75d117b726b0de274a76d3596fce015b..5ff11b9bcef76cb767f0b03ffc326d3f
// Only start Metrics, if it's enabled in the config
if (config.getBoolean("enabled", true)) {
- Metrics metrics = new Metrics("Paper", serverUUID, logFailedRequests, Bukkit.getLogger());
+ Metrics metrics = new Metrics("Scissors", serverUUID, logFailedRequests, Bukkit.getLogger());
+ Metrics metrics = new Metrics("Scissors", serverUUID, logFailedRequests, Bukkit.getLogger()); // Scissors
metrics.addCustomChart(new Metrics.SimplePie("minecraft_version", () -> {
String minecraftVersion = Bukkit.getVersion();
@ -68,17 +72,17 @@ index 4b002e8b75d117b726b0de274a76d3596fce015b..5ff11b9bcef76cb767f0b03ffc326d3f
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);
+ paperVersion = "git-Scissors-%s-%s".formatted(Bukkit.getServer().getMinecraftVersion(), buildOrHash); // Scissors
} else {
paperVersion = "unknown";
}
- metrics.addCustomChart(new Metrics.SimplePie("paper_version", () -> paperVersion));
+ metrics.addCustomChart(new Metrics.SimplePie("scissors_version", () -> paperVersion));
+ metrics.addCustomChart(new Metrics.SimplePie("scissors_version", () -> paperVersion)); // Scissors
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 c5d5648f4ca603ef2b1df723b58f9caf4dd3c722..21ded7c14c56a40feaa7741131be5166947f7169 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 {
@ -86,7 +90,7 @@ index c5d5648f4ca603ef2b1df723b58f9caf4dd3c722..2fbb5fc19e6d7f3767c7c6eedcbc6af2
protected LineReader buildReader(LineReaderBuilder builder) {
builder
- .appName("Paper")
+ .appName("Scissors")
+ .appName("Scissors") // Scissors
.variable(LineReader.HISTORY_FILE, java.nio.file.Paths.get(".console_history"))
.completer(new ConsoleCommandCompleter(this.server))
.option(LineReader.Option.COMPLETE_IN_WORD, true);
@ -104,7 +108,7 @@ index 3238cbcba567b1242c77e41f6b6f19a8d157fb4e..dd4dc6b29e37a4db459779fa8d4adc23
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 0859f11567aecc8cae993a1409cfac7c53ab3dd5..454dcf7006cfbc86d19dde3fe3a6aa0591b2001d 100644
index 0859f11567aecc8cae993a1409cfac7c53ab3dd5..c4717c47aca7d07abeef7625459d13b8c9d6f036 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -261,7 +261,7 @@ import javax.annotation.Nullable; // Paper
@ -112,12 +116,12 @@ index 0859f11567aecc8cae993a1409cfac7c53ab3dd5..454dcf7006cfbc86d19dde3fe3a6aa05
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..741c76c4dfa0bb34cc23bd795c194bdea10418cc 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 +129,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"); // Scissors
Properties properties = new Properties();
if (stream != null) {

View File

@ -1,9 +1,26 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Telesphoreo <me@telesphoreo.me>
Date: Sat, 10 Dec 2022 22:25:38 -0600
Subject: [PATCH] Return null when a show_entity hover event's UUID isn't valid
From: Video <videogamesm12@gmail.com>
Date: Sat, 12 Mar 2022 19:34:59 -0700
Subject: [PATCH] UUID validation
diff --git a/src/main/java/net/minecraft/nbt/NbtUtils.java b/src/main/java/net/minecraft/nbt/NbtUtils.java
index 6dac24354192bea79a4b9eb721543110826790b2..a9c3c55eb622b18c74d8a9bd472e4e871d11b2aa 100644
--- a/src/main/java/net/minecraft/nbt/NbtUtils.java
+++ b/src/main/java/net/minecraft/nbt/NbtUtils.java
@@ -78,7 +78,11 @@ public final class NbtUtils {
}
// Paper start - support string UUID's
if (nbt.contains("Id", 8)) {
- uUID = UUID.fromString(nbt.getString("Id"));
+ // Scissors start - Validate String UUIDs in game profiles
+ try {
+ uUID = UUID.fromString(nbt.getString("Id"));
+ } catch (Exception ignored) {}
+ // Scissors end
}
// Paper end
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
--- a/src/main/java/net/minecraft/network/chat/HoverEvent.java

View File

@ -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

View File

@ -1,9 +1,35 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Video <videogamesm12@gmail.com>
Date: Mon, 9 May 2022 23:40:59 -0500
Subject: [PATCH] Even more resource location validation
Date: Sun, 13 Mar 2022 07:39:26 -0600
Subject: [PATCH] ResourceLocation validation
diff --git a/src/main/java/com/destroystokyo/paper/loottable/PaperContainerEntityLootableInventory.java b/src/main/java/com/destroystokyo/paper/loottable/PaperContainerEntityLootableInventory.java
index 15173e715fa36546820d930a46e0f0c493d07cfc..356cc6f468975faa676db87db8fc0fa2df32f020 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/entity/AreaEffectCloud.java b/src/main/java/net/minecraft/world/entity/AreaEffectCloud.java
index 91e0328f847a2464a1cf65134520244a4cec705f..77ae3bc5fd6cf34aae7bd3baa563f3e23e57de26 100644
--- a/src/main/java/net/minecraft/world/entity/AreaEffectCloud.java
@ -27,7 +53,7 @@ index 91e0328f847a2464a1cf65134520244a4cec705f..77ae3bc5fd6cf34aae7bd3baa563f3e2
}
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 9afc81ccb237c3655d64cdbe8a0db9a4d7791043..7b0aed8ed3a150b7c10fa246bb0b519232424737 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
@ -35,7 +61,7 @@ index 9afc81ccb237c3655d64cdbe8a0db9a4d7791043..ffcb77755b28bcdb3eae981fc735e6dd
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
});
}
@ -44,12 +70,12 @@ index 9afc81ccb237c3655d64cdbe8a0db9a4d7791043..ffcb77755b28bcdb3eae981fc735e6dd
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 BuiltInRegistries.ENTITY_TYPE.getOptional(ResourceLocation.tryParse(nbt.getString("id"))); // Scissors
}
@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 e2a25c29ec74147b3e66aa0b3deb85a8f6ee53a5..0bb87ca2556ca41e0b14503d3ae62e0fc133a209 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 {
@ -57,10 +83,41 @@ index e2a25c29ec74147b3e66aa0b3deb85a8f6ee53a5..b0c953ad8275740679c847e348b311de
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
this.lootTableSeed = nbt.getLong("DeathLootTableSeed");
}
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 448fa4f4f200430d6ce3051763c7ceb697696146..40e59b8db83aec1143e3c394427e916beea7c01f 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
@@ -289,7 +289,12 @@ public abstract class AbstractFurnaceBlockEntity extends BaseContainerBlockEntit
while (iterator.hasNext()) {
String s = (String) iterator.next();
- this.recipesUsed.put(new ResourceLocation(s), nbttagcompound1.getInt(s));
+ // Scissors start
+ final ResourceLocation rl = ResourceLocation.tryParse(s);
+ if (rl != null) {
+ this.recipesUsed.put(rl, nbttagcompound1.getInt(s));
+ }
+ // Scissors end
}
// Paper start - cook speed API
diff --git a/src/main/java/net/minecraft/world/level/block/entity/BrushableBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BrushableBlockEntity.java
index 0425151e688966442340ea1cf892aff34ffe0791..244b04e0020b1bd1e7be34a1b6266a8ac75d29fc 100644
--- a/src/main/java/net/minecraft/world/level/block/entity/BrushableBlockEntity.java
+++ b/src/main/java/net/minecraft/world/level/block/entity/BrushableBlockEntity.java
@@ -199,7 +199,7 @@ public class BrushableBlockEntity extends BlockEntity {
private boolean tryLoadLootTable(CompoundTag nbt) {
if (nbt.contains("LootTable", 8)) {
- this.lootTable = new ResourceLocation(nbt.getString("LootTable"));
+ this.lootTable = ResourceLocation.tryParse(nbt.getString("LootTable")); // Scissors
this.lootTableSeed = nbt.getLong("LootTableSeed");
return true;
} else {
diff --git a/src/main/java/net/minecraft/world/level/block/entity/DecoratedPotBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/DecoratedPotBlockEntity.java
index 6f9286db4e5786464fb0b49dc125e1228ab7ae93..8d91accb0d5e8afa3957d816bd71681b4198ee6e 100644
--- a/src/main/java/net/minecraft/world/level/block/entity/DecoratedPotBlockEntity.java
@ -74,6 +131,19 @@ index 6f9286db4e5786464fb0b49dc125e1228ab7ae93..8d91accb0d5e8afa3957d816bd71681b
}
}
}
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 081691f9710ff1115e4308f79ed49fbc38941193..c29dfd15e147d5c4d9c9584ff7803c2a52009f0d 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
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftLootable.java b/src/main/java/org/bukkit/craftbukkit/block/CraftLootable.java
index e49eece9bff3a53469673d03a7bbf8f9cf8776b8..a49f32e9649155b6af4b1f236e4e8142d730e7e8 100644
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftLootable.java
@ -117,19 +187,15 @@ 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 18b9b0dc70f6872a9d71c120bcd2edca531b0ac4..fa0c023b3a88bd797f563e0e675d70966ff7dbd3 100644
index 18b9b0dc70f6872a9d71c120bcd2edca531b0ac4..4732fff6d1198e5fc4875b4d4523aa2d152817ea 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 {
@@ -80,8 +80,14 @@ public abstract class CraftMob extends CraftLivingEntity implements Mob {
@Override
public LootTable getLootTable() {
- NamespacedKey key = CraftNamespacedKey.fromMinecraft(this.getHandle().getLootTable());
- 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());

View File

@ -1,31 +1,27 @@
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 deed77a3d44bc55681483d7f47f148b5220135f2..f927156d6d7b75ff9a1c437478ae3e200962398c 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;
@@ -11,6 +11,7 @@ import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtUtils;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.block.entity.SkullBlockEntity;
+// Scissors start
+import org.apache.commons.lang3.StringUtils;
+// Scissors end
+import org.apache.commons.lang3.StringUtils; // Scissors
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
@@ -73,7 +76,9 @@ class CraftMetaSkull extends CraftMetaItem implements SkullMeta {
@@ -73,7 +74,7 @@ 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)));
- } else if (tag.contains(SKULL_OWNER.NBT, CraftMagicNumbers.NBT.TAG_STRING) && !tag.getString(SKULL_OWNER.NBT).isEmpty()) {
+ // Scissors start
+ } else if (tag.contains(SKULL_OWNER.NBT, CraftMagicNumbers.NBT.TAG_STRING) && !StringUtils.isBlank(tag.getString(SKULL_OWNER.NBT))) {
+ // Scissors end
+ } else if (tag.contains(SKULL_OWNER.NBT, CraftMagicNumbers.NBT.TAG_STRING) && !StringUtils.isBlank(tag.getString(SKULL_OWNER.NBT))) { // Scissors
this.setProfile(new GameProfile(null, tag.getString(SKULL_OWNER.NBT)));
}

View File

@ -5,14 +5,14 @@ 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 41c9f074203915c31c1ae7a160ce509c13383f84..8b4989593da43fc2fd661ac66bfe5ae1eb5e2780 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;
import net.minecraft.nbt.ListTag;
import net.minecraft.nbt.NbtUtils;
import net.minecraft.network.protocol.game.DebugPackets;
+import net.minecraft.resources.ResourceLocation;
+import net.minecraft.resources.ResourceLocation; // Scissors
import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource;
import net.minecraft.tags.BlockTags;
@ -25,7 +25,7 @@ index 41c9f074203915c31c1ae7a160ce509c13383f84..79a7fff759f062b783a540079cb43f29
+ if (!nbttagcompound1.contains("id") || !ResourceLocation.isValidResourceLocation(nbttagcompound1.getString("id")) || EntityType.byString(nbttagcompound1.getString("id")).isEmpty()) {
+ continue;
+ }
+ // Scissor end
+ // Scissors end
+
BeehiveBlockEntity.BeeData tileentitybeehive_hivebee = new BeehiveBlockEntity.BeeData(nbttagcompound1.getCompound("EntityData"), nbttagcompound1.getInt("TicksInHive"), nbttagcompound1.getInt("MinOccupationTicks"));

View File

@ -1,6 +1,6 @@
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

View File

@ -1,15 +1,15 @@
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 272095d7a09ab41227d741172735f66fd2798ce1..757ae1773ba35c2348483dddbb231060afafc602 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
@@ -139,7 +139,11 @@ public abstract class AbstractMinecartContainer extends AbstractMinecart impleme
@Override
public void remove(Entity.RemovalReason reason) {
if (!this.level().isClientSide && reason.shouldDestroy()) {
@ -17,8 +17,7 @@ index 272095d7a09ab41227d741172735f66fd2798ce1..ea966ea94062be3ed9b6b2c460a31637
+ // Scissors start - Ignore errors thrown when trying to remove minecart entities with content in them
+ try {
+ Containers.dropContents(this.level(), (Entity) this, (Container) this);
+ } catch (Exception ignored) {
+ }
+ } catch (Exception ignored) {}
+ // Scissors end
}

View File

@ -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 50fdb086ffec84edc5138737c95f08ed4757a6f3..da312b4670fc0ac07e4ab798d4793025e362783e 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
@@ -41,7 +41,11 @@ public class CraftMetaKnowledgeBook extends CraftMetaItem implements KnowledgeBo
for (int i = 0; i < pages.size(); i++) {
String recipe = pages.getString(i);
@ -42,8 +42,7 @@ index 50fdb086ffec84edc5138737c95f08ed4757a6f3..bb0f673a619810850df0d78bb4abd9d7
+ // Scissors start - Don't add recipes with invalid namespaces
+ try {
+ this.addRecipe(CraftNamespacedKey.fromString(recipe));
+ } catch (Exception ignored) {
+ }
+ } catch (Exception ignored) {}
+ // Scissors end
}
}

View File

@ -1,14 +1,14 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Telesphoreo <me@telesphoreo.me>
Date: Sat, 10 Dec 2022 22:46:24 -0600
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 6dac24354192bea79a4b9eb721543110826790b2..b87999106b5068a243c064fa3c30968411996e2b 100644
index a9c3c55eb622b18c74d8a9bd472e4e871d11b2aa..a78595e91cbb6a815c9ef6b4596cdb0e560f9e42 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 {
@@ -235,7 +235,7 @@ public final class NbtUtils {
if (!nbt.contains("Name", 8)) {
return Blocks.AIR.defaultBlockState();
} else {
@ -18,7 +18,7 @@ index 6dac24354192bea79a4b9eb721543110826790b2..b87999106b5068a243c064fa3c309684
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
index 7226be19248a1ffb8ff2c89b55882529d33a6c0c..e77605a506edd5fd7380eaa13de0213cbd370f65 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 {

View File

@ -1,12 +1,12 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Video <videogamesm12@gmail.com>
Date: Wed, 27 Jul 2022 22:30:39 -0500
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 2a609e43370e68943c580083f7f7d8c9b0972955..fa5fee810dc8aa7febb46bbf0ad9ab9ce9ffbabd 100644
index 2a609e43370e68943c580083f7f7d8c9b0972955..9d9bcf537ba9ae67cdcfec33f983c0983aaf889e 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -1923,6 +1923,18 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
@ -28,19 +28,16 @@ index 2a609e43370e68943c580083f7f7d8c9b0972955..fa5fee810dc8aa7febb46bbf0ad9ab9c
@Override
public void handleUseItemOn(ServerboundUseItemOnPacket packet) {
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
@@ -3348,17 +3360,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
@@ -3349,16 +3361,21 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
BlockPos blockposition = BlockEntity.getPosFromTag(nbttagcompound);
- if (this.player.level().isLoaded(blockposition)) {
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()))
+ {
@ -53,8 +50,7 @@ index 2a609e43370e68943c580083f7f7d8c9b0972955..fa5fee810dc8aa7febb46bbf0ad9ab9c
- if (tileentity != null) {
- tileentity.saveToItem(itemstack);
+ if (tileentity != null)
+ {
+ if (tileentity != null) {
+ tileentity.saveToItem(itemstack);
+ }
}

View File

@ -1,24 +1,24 @@
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 9d687da5bdf398bb3f6c84cdf1249a7213d09f2e..bc5ed619e05f24f3ad50a6a81306d120869f57a1 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;
import com.google.common.base.Charsets;
import com.google.common.io.Resources;
import com.google.gson.*;
+import io.papermc.paper.util.JarManifests;
+import io.papermc.paper.util.JarManifests; // Scissors
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 org.bukkit.Bukkit; // Scissors
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
@ -28,8 +28,8 @@ index 9d687da5bdf398bb3f6c84cdf1249a7213d09f2e..0a8fda6939152d393f07e5d2812409ad
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 GITHUB_BRANCH_NAME = getBranch();
+ private static final String DOWNLOAD_PAGE = "https://ci.scissors.gg/job/Scissors/job/" + GITHUB_BRANCH_NAME;
+ private static final String GITHUB_BRANCH_NAME = getBranch(); // Scissors
+ private static final String DOWNLOAD_PAGE = "https://ci.scissors.gg/job/Scissors/job/" + GITHUB_BRANCH_NAME; // Scissors
private static @Nullable String mcVer;
@Override
@ -39,8 +39,8 @@ index 9d687da5bdf398bb3f6c84cdf1249a7213d09f2e..0a8fda6939152d393f07e5d2812409ad
public Component getVersionMessage(@Nonnull String serverVersion) {
- String[] parts = serverVersion.substring("git-Paper-".length()).split("[-\\s]");
- final Component updateMessage = getUpdateStatusMessage("PaperMC/Paper", GITHUB_BRANCH_NAME, parts[0]);
+ String[] parts = serverVersion.substring("git-Scissors-".length()).split("[-\\s]");
+ final Component updateMessage = getUpdateStatusMessage("AtlasMediaGroup/Scissors", GITHUB_BRANCH_NAME, parts[0]);
+ String[] parts = serverVersion.substring("git-Scissors-".length()).split("[-\\s]"); // Scissors
+ final Component updateMessage = getUpdateStatusMessage("AtlasMediaGroup/Scissors", GITHUB_BRANCH_NAME, parts[0]); // Scissors
final Component history = getHistory();
return history != null ? TextComponent.ofChildren(updateMessage, Component.newline(), history) : updateMessage;
@ -77,7 +77,7 @@ 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 717e292040ed7779eb4b6c5fa26665d3df9024e7..0fb3a648ee6bd6cb88515770bcfc70e368313527 100644
index d4f6935a1bea77e5118bfd538f9b1358c21591a7..2a834708001ea940d8ab6f6559024df32b1e9520 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 {

View File

@ -1,18 +1,18 @@
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 37fc353c3e59dd5af2fd6c58ac084fb0e6e155d7..2873ed7c443ed8c8c57a8b1d3e444d229f10f07b 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 net.minecraft.ChatFormatting;
+import net.minecraft.ChatFormatting; // Scissors
import net.minecraft.Util;
import net.minecraft.network.chat.contents.BlockDataSource;
import net.minecraft.network.chat.contents.DataSource;
@ -84,7 +84,7 @@ index 7449a024265c42f28a6c9a1ed8d8f4b9e3096aac..487c68abc3eb5c18dc7fee762b216400
// 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
index 97a2657bc98d41c3c1e376b266d2c85f685acc88..a55cae0724cd92c80a4f79a3babb91d0802f0860 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;
@ -95,7 +95,7 @@ index 97a2657bc98d41c3c1e376b266d2c85f685acc88..7b6476455e095eed15c92797ce3a3e11
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 {
@@ -107,10 +108,10 @@ public class NbtContents implements ComponentContents {
Component component = DataFixUtils.orElse(ComponentUtils.updateForEntity(source, this.separator, sender, depth), ComponentUtils.DEFAULT_NO_STYLE_SEPARATOR);
return stream.flatMap((text) -> {
try {
@ -105,7 +105,6 @@ index 97a2657bc98d41c3c1e376b266d2c85f685acc88..7b6476455e095eed15c92797ce3a3e11
} 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();
}
}).reduce((accumulator, current) -> {

View File

@ -1,33 +1,32 @@
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
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 fbfadeb83719b81f42724e79c59e92ed88fdece7..bcb9d99359fb3e03c86d7429d9bcfe63b6c0f5d5 100644
index fbfadeb83719b81f42724e79c59e92ed88fdece7..c9c0652a22760716f9dbb5fc73bc6fce5148b800 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;
@@ -6,9 +6,17 @@ 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 java.util.Collections; // Scissors
+import net.minecraft.ChatFormatting; // Scissors
+import net.minecraft.core.NonNullList; // Scissors
+import net.minecraft.nbt.CompoundTag; // Scissors
+import net.minecraft.network.chat.Component; // Scissors
+import net.minecraft.network.chat.SignedMessageBody; // Scissors
import net.minecraft.network.protocol.Packet;
import net.minecraft.network.protocol.PacketFlow;
+import net.minecraft.network.protocol.game.*;
+import net.minecraft.network.protocol.game.*; // Scissors
import net.minecraft.util.profiling.jfr.JvmProfiler;
+import net.minecraft.world.item.ItemStack;
+import net.minecraft.world.item.ItemStack; // Scissors
import org.slf4j.Logger;
public class PacketEncoder extends MessageToByteEncoder<Packet<?>> {
@@ -19,6 +28,23 @@ public class PacketEncoder extends MessageToByteEncoder<Packet<?>> {
@@ -19,6 +27,23 @@ public class PacketEncoder extends MessageToByteEncoder<Packet<?>> {
this.flow = side;
}
@ -51,7 +50,7 @@ index fbfadeb83719b81f42724e79c59e92ed88fdece7..bcb9d99359fb3e03c86d7429d9bcfe63
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<?>> {
@@ -33,38 +58,66 @@ public class PacketEncoder extends MessageToByteEncoder<Packet<?>> {
throw new IOException("Can't serialize unregistered packet");
} else {
FriendlyByteBuf friendlyByteBuf = new FriendlyByteBuf(byteBuf);

View File

@ -1,25 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Video <videogamesm12@gmail.com>
Date: Wed, 30 Mar 2022 02:01:55 -0600
Subject: [PATCH] Validate String UUIDs during the CompoundTag -> GameProfile
conversion process
diff --git a/src/main/java/net/minecraft/nbt/NbtUtils.java b/src/main/java/net/minecraft/nbt/NbtUtils.java
index b87999106b5068a243c064fa3c30968411996e2b..596baf1bc372875b8b82904d9d5bd53f4bedc0fb 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"));
+ // Scissors start - Validate String UUIDs in game profiles
+ try {
+ uUID = UUID.fromString(nbt.getString("Id"));
+ } catch (Exception ignored) {
+ }
+ // Scissors end
}
// Paper end

View File

@ -1,35 +1,32 @@
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 584a58659fae6ba3d8b53858890bc6ec509ffb0e..54a7dae26854d320d9e53f63eb411a85a2d78159 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 {
@@ -39,8 +39,9 @@ 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;
+ MutableComponent result; // Scissors
if (depth > 100) {
- return text.copy();
+ result = text.copy();
+ result = text.copy(); // Scissors
} else {
// Paper start
if (text instanceof io.papermc.paper.adventure.AdventureComponent adventureComponent) {
@@ -53,8 +55,11 @@ public class ComponentUtils {
@@ -53,8 +54,9 @@ 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));
+ result = mutableComponent.withStyle(resolveStyle(source, text.getStyle(), sender, depth)); // Scissors
}
+ // Would the resulting component exceed 65535 bytes when encoded as a string?
+ return Component.Serializer.toJson(result).length() > 65535 ? Component.empty() : result;
+ // Scissors end
+ return Component.Serializer.toJson(result).length() > 65535 ? Component.empty() : result; // Scissors
}
private static Style resolveStyle(@Nullable CommandSourceStack source, Style style, @Nullable Entity sender, int depth) throws CommandSyntaxException {

View File

@ -1,6 +1,6 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Allink <arclicious@vivaldi.net>
Date: Wed, 15 Mar 2023 23:13:56 -0500
Date: Sun, 10 Jul 2022 10:12:04 +0100
Subject: [PATCH] Add Scissors configuration file & command
@ -26,28 +26,6 @@ index a2f71a6d1a9e98133dff6cd0f625da9435a8af14..f83b2c4298bd1a5f65487f64bd6a11fb
));
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
@ -206,10 +184,10 @@ index 0000000000000000000000000000000000000000..797677d892d83cf54d9a60af1e277b67
+}
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..ec93980fefcab57b7bac78d2fc4a217b376b7eca
index 0000000000000000000000000000000000000000..8cd2848aa6b06c5efbe797ed2d75ff4b025b3c52
--- /dev/null
+++ b/src/main/java/me/totalfreedom/scissors/ScissorsConfig.java
@@ -0,0 +1,213 @@
@@ -0,0 +1,225 @@
+package me.totalfreedom.scissors;
+
+
@ -299,8 +277,8 @@ index 0000000000000000000000000000000000000000..ec93980fefcab57b7bac78d2fc4a217b
+ config.options().header(HEADER);
+ config.options().copyDefaults(true);
+
+ version = getInt("config-version", 3);
+ set("config-version", 3);
+ version = getInt("config-version", 5);
+ set("config-version", 5);
+ readConfig(ScissorsConfig.class, null);
+ }
+
@ -381,6 +359,18 @@ index 0000000000000000000000000000000000000000..ec93980fefcab57b7bac78d2fc4a217b
+ chatSignaturesEnabled = getBoolean("chatSignaturesEnabled", true);
+ }
+
+ public static boolean excludePlayersFromNbtComponents = false;
+ private static void excludePlayersFromNbtComponents()
+ {
+ 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);
@ -423,67 +413,6 @@ index 0000000000000000000000000000000000000000..ec93980fefcab57b7bac78d2fc4a217b
+ }
+}
+
diff --git a/src/main/java/net/minecraft/network/chat/OutgoingChatMessage.java b/src/main/java/net/minecraft/network/chat/OutgoingChatMessage.java
index 74cf1c043beef03cfd5adf481414a5ee78bef2a6..bca80fb82b4bc5318820bcca7d6b4357be94def9 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 {
@@ -44,10 +45,25 @@ public interface OutgoingChatMessage {
// Paper end
PlayerChatMessage playerChatMessage = this.message.filter(filterMaskEnabled);
playerChatMessage = unsigned != null ? playerChatMessage.withUnsignedContent(unsigned) : playerChatMessage; // Paper
- if (!playerChatMessage.isFullyFiltered()) {
+ // Scissors start - Add configuration option to disable chat signatures
+ if (!playerChatMessage.isFullyFiltered() && ScissorsConfig.chatSignaturesEnabled) {
sender.connection.sendPlayerChatMessage(playerChatMessage, params);
+ return;
}
+ if (sender.getServer().server.getOnlineMode()) {
+ sender.connection.sendDisguisedChatMessage(playerChatMessage.decoratedContent(), params);
+ } else {
+ sender.connection.sendPlayerChatMessage(new PlayerChatMessage(
+ SignedMessageLink.unsigned(playerChatMessage.sender()),
+ null,
+ SignedMessageBody.unsigned(playerChatMessage.signedContent()),
+ unsigned,
+ playerChatMessage.filterMask(),
+ playerChatMessage.result()
+ ), params);
+ }
+ // Scissors end
}
}
}
diff --git a/src/main/java/net/minecraft/network/chat/SignedMessageChain.java b/src/main/java/net/minecraft/network/chat/SignedMessageChain.java
index c0a80824a0307ea673805015119cc834b268f0dc..cc67d0e351333731d953d5732215b19d1c36d4bc 100644
--- a/src/main/java/net/minecraft/network/chat/SignedMessageChain.java
+++ b/src/main/java/net/minecraft/network/chat/SignedMessageChain.java
@@ -4,6 +4,8 @@ import com.mojang.logging.LogUtils;
import java.time.Instant;
import java.util.UUID;
import javax.annotation.Nullable;
+
+import me.totalfreedom.scissors.ScissorsConfig;
import net.minecraft.util.SignatureUpdater;
import net.minecraft.util.SignatureValidator;
import net.minecraft.util.Signer;
@@ -41,7 +43,8 @@ public class SignedMessageChain {
if (!playerChatMessage.verify(signatureValidator)) {
throw new SignedMessageChain.DecodeException(Component.translatable("multiplayer.disconnect.unsigned_chat"), true, org.bukkit.event.player.PlayerKickEvent.Cause.UNSIGNED_CHAT); // Paper - kick event causes
} else {
- if (playerChatMessage.hasExpiredServer(Instant.now())) {
+ // Scissors - Do not log this message if chat signatures are disabled
+ if (playerChatMessage.hasExpiredServer(Instant.now()) && ScissorsConfig.chatSignaturesEnabled) {
LOGGER.warn("Received expired chat: '{}'. Is the client/server system time unsynchronized?", (Object)body.content());
}
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
@ -517,191 +446,8 @@ index 9f422cbeaa52b3e6a0a27af4f8ad4ddb7808483f..bbfb536ddec7f44d2a75d35ab495be26
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 cb5f11f60e5abe21ca3dd724c79f29391cd052cc..494e99351d6f70871c88c233a5d7e668ae67d5be 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;
@@ -2325,7 +2326,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
}
private void handleMessageDecodeFailure(SignedMessageChain.DecodeException exception) {
- if (exception.shouldDisconnect()) {
+ if (exception.shouldDisconnect() && ScissorsConfig.chatSignaturesEnabled) { // Scissors - Do not kick when chat signatures are disabled
this.disconnect(exception.getComponent(), exception.kickCause); // Paper - kick event causes
} else {
this.player.sendSystemMessage(exception.getComponent().copy().withStyle(ChatFormatting.RED));
@@ -2381,6 +2382,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
}
@@ -2613,11 +2620,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..1cce74b2fd105d7fe06d390ad77bffa4bdad2a4d 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;
@@ -161,8 +162,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 0521240dddde12d78cc05deda7fac11690f5d155..f19d82fd11633d9f91a70fb14cb5a1bcd91bce73 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
@@ -286,6 +291,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 454dcf7006cfbc86d19dde3fe3a6aa0591b2001d..5293040c7ec5824e40b0779ce507fc4994eb80b6 100644
index c4717c47aca7d07abeef7625459d13b8c9d6f036..16321ec80cb88e7f67ff050e2777f04857903b56 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -1052,6 +1052,7 @@ public final class CraftServer implements Server {
@ -720,24 +466,26 @@ index 454dcf7006cfbc86d19dde3fe3a6aa0591b2001d..5293040c7ec5824e40b0779ce507fc49
this.overrideAllCommandBlockCommands = this.commandsConfiguration.getStringList("command-block-overrides").contains("*");
this.ignoreVanillaPermissions = this.commandsConfiguration.getBoolean("ignore-vanilla-permissions");
@@ -2850,6 +2852,12 @@ public final class CraftServer implements Server {
@@ -2850,6 +2852,14 @@ public final class CraftServer implements Server {
return CraftServer.this.console.paperConfigurations.createLegacyObject(CraftServer.this.console);
}
+ // Scissors start
+ @Override
+ public YamlConfiguration getScissorsConfig()
+ {
+ return me.totalfreedom.scissors.ScissorsConfig.config;
+ }
+ // Scissors end
+
@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 2a834708001ea940d8ab6f6559024df32b1e9520..70268a0bec5172bf723e3f9a8fe3208276f3bfa8 100644
index 2a834708001ea940d8ab6f6559024df32b1e9520..ec69599d8e237440b8dba2a40a58436cc2dbb01a 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 {
@@ -180,6 +180,20 @@ public class Main {
.defaultsTo("Unknown Server")
.describedAs("Name");
// Paper end
@ -748,9 +496,7 @@ index 2a834708001ea940d8ab6f6559024df32b1e9520..70268a0bec5172bf723e3f9a8fe32082
+ .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)
@ -760,8 +506,3 @@ index 2a834708001ea940d8ab6f6559024df32b1e9520..70268a0bec5172bf723e3f9a8fe32082
}
};
+
+
OptionSet options = null;
// Paper start - preload logger classes to avoid plugins mixing versions

View File

@ -1,18 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Luna <lunahatesgogle@gmail.com>
Date: Fri, 8 Apr 2022 23:38:12 -0300
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 b74b77ec2fd45c7a44e4f2696c4f57075c3d4080..c6ac2aff889ff157da47ee26fbfc1f83616d5b8f 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> {
list.add(tagType.load(dataInput, i + 1, nbtAccounter));
}
+ if(j > 1024) return new ListTag(Lists.newArrayListWithCapacity(0), b);
return new ListTag(list, b);
}
}

View File

@ -6,14 +6,14 @@ 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 5da793c0754a943b12ef01cac1072b71afd27b0e..aed46e2ca3191e1c7dccb4eb7d71bd3be97c2993 100644
index db7d7e2ab25f8559247e2496a54807161e24a203..3f8ab313979954c84dd42143fddc84b288a75890 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;
import net.minecraft.nbt.StringTag;
import net.minecraft.nbt.Tag;
import net.minecraft.network.chat.Component;
+import net.minecraft.resources.ResourceLocation;
+import net.minecraft.resources.ResourceLocation; // Scissors
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.level.block.state.BlockState;
import org.apache.commons.lang3.EnumUtils;

View File

@ -5,23 +5,34 @@ 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
index 8a6799b50062c1b7b141ee1568dc523f9ee7ecfd..80e7b0889235288b60d813a569daecb7e08e108e 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;
@@ -1,5 +1,6 @@
package net.minecraft.network.chat.contents;
+import me.totalfreedom.scissors.ScissorsConfig; // Scissors
import com.mojang.brigadier.StringReader;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import java.util.List;
@@ -11,6 +12,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;
+import net.minecraft.world.entity.player.Player; // Scissors
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
@@ -31,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().map(NbtPredicate::getEntityTagToCompare);
+ 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();
}

View File

@ -0,0 +1,142 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Luna <lunahatesgogle@gmail.com>
Date: Fri, 8 Apr 2022 23:38:12 -0300
Subject: [PATCH] Limit string tag visitors to 1024 elements
diff --git a/src/main/java/net/minecraft/nbt/SnbtPrinterTagVisitor.java b/src/main/java/net/minecraft/nbt/SnbtPrinterTagVisitor.java
index e07cc7970955ce240754cfe424d768c2bba0241a..a4f41bb4ec6cb20f782668c714229b61415cfdfb 100644
--- a/src/main/java/net/minecraft/nbt/SnbtPrinterTagVisitor.java
+++ b/src/main/java/net/minecraft/nbt/SnbtPrinterTagVisitor.java
@@ -89,6 +89,7 @@ public class SnbtPrinterTagVisitor implements TagVisitor {
public void visitByteArray(ByteArrayTag element) {
StringBuilder stringBuilder = (new StringBuilder("[")).append("B").append(";");
byte[] bs = element.getAsByteArray();
+ if (bs.length > 1024) { this.result = stringBuilder.append("]").toString(); return; } // Scissors
for(int i = 0; i < bs.length; ++i) {
stringBuilder.append(" ").append((int)bs[i]).append("B");
@@ -105,6 +106,7 @@ public class SnbtPrinterTagVisitor implements TagVisitor {
public void visitIntArray(IntArrayTag element) {
StringBuilder stringBuilder = (new StringBuilder("[")).append("I").append(";");
int[] is = element.getAsIntArray();
+ if (is.length > 1024) { this.result = stringBuilder.append("]").toString(); return; } // Scissors
for(int i = 0; i < is.length; ++i) {
stringBuilder.append(" ").append(is[i]);
@@ -122,6 +124,7 @@ public class SnbtPrinterTagVisitor implements TagVisitor {
String string = "L";
StringBuilder stringBuilder = (new StringBuilder("[")).append("L").append(";");
long[] ls = element.getAsLongArray();
+ if (ls.length > 1024) { this.result = stringBuilder.append("]").toString(); return; } // Scissors
for(int i = 0; i < ls.length; ++i) {
stringBuilder.append(" ").append(ls[i]).append("L");
@@ -136,7 +139,7 @@ public class SnbtPrinterTagVisitor implements TagVisitor {
@Override
public void visitList(ListTag element) {
- if (element.isEmpty()) {
+ if (element.isEmpty() || element.size() > 1024) { // Scissors
this.result = "[]";
} else {
StringBuilder stringBuilder = new StringBuilder("[");
@@ -166,7 +169,7 @@ public class SnbtPrinterTagVisitor implements TagVisitor {
@Override
public void visitCompound(CompoundTag compound) {
- if (compound.isEmpty()) {
+ if (compound.isEmpty() || compound.size() > 1024) { // Scissors
this.result = "{}";
} else {
StringBuilder stringBuilder = new StringBuilder("{");
diff --git a/src/main/java/net/minecraft/nbt/StringTagVisitor.java b/src/main/java/net/minecraft/nbt/StringTagVisitor.java
index a687a0f17df30126d53a1e3a669dc6d157c23ed5..2c50f41dd8034af16fcceca75eeb6c7a9940e327 100644
--- a/src/main/java/net/minecraft/nbt/StringTagVisitor.java
+++ b/src/main/java/net/minecraft/nbt/StringTagVisitor.java
@@ -53,6 +53,7 @@ public class StringTagVisitor implements TagVisitor {
public void visitByteArray(ByteArrayTag element) {
this.builder.append("[B;");
byte[] bs = element.getAsByteArray();
+ if (bs.length > 1024) { this.builder.append(']'); return; } // Scissors
for(int i = 0; i < bs.length; ++i) {
if (i != 0) {
@@ -69,6 +70,7 @@ public class StringTagVisitor implements TagVisitor {
public void visitIntArray(IntArrayTag element) {
this.builder.append("[I;");
int[] is = element.getAsIntArray();
+ if (is.length > 1024) { this.builder.append(']'); return; } // Scissors
for(int i = 0; i < is.length; ++i) {
if (i != 0) {
@@ -85,6 +87,7 @@ public class StringTagVisitor implements TagVisitor {
public void visitLongArray(LongArrayTag element) {
this.builder.append("[L;");
long[] ls = element.getAsLongArray();
+ if (ls.length > 1024) { this.builder.append(']'); return; } // Scissors
for(int i = 0; i < ls.length; ++i) {
if (i != 0) {
@@ -100,6 +103,7 @@ public class StringTagVisitor implements TagVisitor {
@Override
public void visitList(ListTag element) {
this.builder.append('[');
+ if (element.size() > 1024) { this.builder.append(']'); return; } // Scissors
for(int i = 0; i < element.size(); ++i) {
if (i != 0) {
@@ -116,6 +120,7 @@ public class StringTagVisitor implements TagVisitor {
public void visitCompound(CompoundTag compound) {
this.builder.append('{');
List<String> list = Lists.newArrayList(compound.getAllKeys());
+ if (list.size() > 1024) { this.builder.append('}'); return; } // Scissors
Collections.sort(list);
for(String string : list) {
diff --git a/src/main/java/net/minecraft/nbt/TextComponentTagVisitor.java b/src/main/java/net/minecraft/nbt/TextComponentTagVisitor.java
index 149def3da0b92f64e4fc04630965dce44884f938..c9d753f37bd65e35f8a4e2eb5c6fe8f74d5d1606 100644
--- a/src/main/java/net/minecraft/nbt/TextComponentTagVisitor.java
+++ b/src/main/java/net/minecraft/nbt/TextComponentTagVisitor.java
@@ -97,6 +97,7 @@ public class TextComponentTagVisitor implements TagVisitor {
Component component = Component.literal("B").withStyle(SYNTAX_HIGHLIGHTING_NUMBER_TYPE);
MutableComponent mutableComponent = Component.literal("[").append(component).append(";");
byte[] bs = element.getAsByteArray();
+ if (bs.length > 1024) { this.result = mutableComponent.append("]"); return; } // Scissors
for(int i = 0; i < bs.length; ++i) {
MutableComponent mutableComponent2 = Component.literal(String.valueOf((int)bs[i])).withStyle(SYNTAX_HIGHLIGHTING_NUMBER);
@@ -115,6 +116,7 @@ public class TextComponentTagVisitor implements TagVisitor {
Component component = Component.literal("I").withStyle(SYNTAX_HIGHLIGHTING_NUMBER_TYPE);
MutableComponent mutableComponent = Component.literal("[").append(component).append(";");
int[] is = element.getAsIntArray();
+ if (is.length > 1024) { this.result = mutableComponent.append("]"); return; } // Scissors
for(int i = 0; i < is.length; ++i) {
mutableComponent.append(" ").append(Component.literal(String.valueOf(is[i])).withStyle(SYNTAX_HIGHLIGHTING_NUMBER));
@@ -132,6 +134,7 @@ public class TextComponentTagVisitor implements TagVisitor {
Component component = Component.literal("L").withStyle(SYNTAX_HIGHLIGHTING_NUMBER_TYPE);
MutableComponent mutableComponent = Component.literal("[").append(component).append(";");
long[] ls = element.getAsLongArray();
+ if (ls.length > 1024) { this.result = mutableComponent.append("]"); return; } // Scissors
for(int i = 0; i < ls.length; ++i) {
Component component2 = Component.literal(String.valueOf(ls[i])).withStyle(SYNTAX_HIGHLIGHTING_NUMBER);
@@ -147,7 +150,7 @@ public class TextComponentTagVisitor implements TagVisitor {
@Override
public void visitList(ListTag element) {
- if (element.isEmpty()) {
+ if (element.isEmpty() || element.size() > 1024) { // Scissors
this.result = Component.literal("[]");
} else if (INLINE_ELEMENT_TYPES.contains(element.getElementType()) && element.size() <= 8) {
String string = ELEMENT_SEPARATOR + " ";
@@ -190,7 +193,7 @@ public class TextComponentTagVisitor implements TagVisitor {
@Override
public void visitCompound(CompoundTag compound) {
- if (compound.isEmpty()) {
+ if (compound.isEmpty() || compound.size() > 1024) { // Scissors
this.result = Component.literal("{}");
} else {
MutableComponent mutableComponent = Component.literal("{");

View File

@ -6,7 +6,7 @@ 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 bcce17f884b57e619749351b7b2047f0a5f9be71..65e245e02676077e481f8a1fcd9885c389f9666c 100644
index bcce17f884b57e619749351b7b2047f0a5f9be71..84ce9410a9259fd3b8ac8457e6796c7998a1eabc 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 {
@ -25,9 +25,9 @@ index bcce17f884b57e619749351b7b2047f0a5f9be71..65e245e02676077e481f8a1fcd9885c3
+ // Scissors start
+ amplifier = Math.min(Math.abs(amplifier), 124);
+ if (!god && (this == MobEffects.HARM && !entity.isInvertedHealAndHarm() || this == MobEffects.HEAL && entity.isInvertedHealAndHarm())) {
+ // Scissors end
entity.hurt(entity.damageSources().magic(), (float) (6 << amplifier));
}
+ // Scissors end
} else {
- entity.heal((float) Math.max(4 << amplifier, 0), RegainReason.MAGIC); // CraftBukkit
+ // Scissors start

View File

@ -1,11 +1,11 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Telesphoreo <me@telesphoreo.me>
Date: Thu, 8 Jun 2023 19:24:05 -0500
From: Allink <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 a189461330a4d427a7450d504ef13de3605497e3..79430aef1cbcad7d872435ebdec60321e2573bb3 100644
index 064bd3f2615009b3f15f3a5006f0b5f7a7ba6bf5..66d20a86a56cccc39b1de2973e288817ab1bc14e 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 {
@ -13,7 +13,7 @@ index a189461330a4d427a7450d504ef13de3605497e3..79430aef1cbcad7d872435ebdec60321
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()) {
+ if ((this.deathTime >= 20 || this.deathTime <= 0) && !this.level().isClientSide() && !this.isRemoved()) { // Scissors
this.level().broadcastEntityEvent(this, (byte) 60);
this.remove(Entity.RemovalReason.KILLED);
}

View File

@ -1,19 +1,19 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Telesphoreo <me@telesphoreo.me>
Date: Sat, 10 Dec 2022 23:44:05 -0600
From: Allink <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 9948a28dae4edba877c13ef0156be5ff58df3fa2..9e25d4a3384d0157b99f7bd4d5f7edce032ece6b 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;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeUnit; // Scissors
import javax.annotation.Nullable;
import net.minecraft.BlockUtil;
import net.minecraft.Util;
@ -31,39 +31,37 @@ index 9948a28dae4edba877c13ef0156be5ff58df3fa2..93f359c71659c0b2fdf25b1c76c072bf
- if (!list.isEmpty()) {
- for (int l = 0; l < list.size(); ++l) {
+ // Scissors - Add a collision debounce
+ // Scissors start
+ if (!list.isEmpty() && (System.currentTimeMillis() - lastLargeCollision) >= TimeUnit.SECONDS.toMillis(5)) { // Using TimeUnit for better code readability
+ // Scissors - Limit amount of vehicle collision checks to 3 maximum
+ for (int l = 0; l < Math.min(3, list.size()); ++l) {
+ // Scissors end
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 {
@@ -462,6 +466,14 @@ public abstract class AbstractMinecart extends Entity {
entity.push(this);
}
}
+
+ // Scissors - Add a collision debounce
+ if (list.size() > 3) {
+ lastLargeCollision = System.currentTimeMillis();
+ }
+
+ // Scissors - Delete entity if the collision amount is over 15
+ // Scissors start - Add a collision debounce
+ if (list.size() > 15) {
+ this.discard();
+ } else if (list.size() > 3) {
+ lastLargeCollision = System.currentTimeMillis();
+ }
+ // Scissors end
}
} else {
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 35aeba4e8430e6419caa9db4a0b931a994228618..289eb39b15a283b0d9dbc33823f3a73f87202907 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;
import java.util.Iterator;
import java.util.List;
import java.util.function.IntFunction;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeUnit; // Scissors
import javax.annotation.Nullable;
import net.minecraft.BlockUtil;
import net.minecraft.core.BlockPos;
@ -75,35 +73,31 @@ 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> {
@@ -421,10 +423,10 @@ public class Boat extends Entity implements VariantHolder<Boat.Type> {
this.checkInsideBlocks();
List<Entity> list = this.level().getEntities((Entity) 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
+ if (!list.isEmpty() && (System.currentTimeMillis() - lastLargeCollision) >= TimeUnit.SECONDS.toMillis(5)) { // Scissors - add collision debounce, using TimeUnit for better code readability
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) {
+ for (int j = 0; j < Math.min(3, list.size()); ++j) { // Scissors - Limit amount of vehicle collision checks to 3 maximum
Entity entity = (Entity) list.get(j);
if (!entity.hasPassenger((Entity) this)) {
@@ -435,6 +439,16 @@ public class Boat extends Entity implements VariantHolder<Boat.Type> {
@@ -435,6 +437,14 @@ public class Boat extends Entity implements VariantHolder<Boat.Type> {
}
}
}
+
+ // Scissors - Add collision debounce
+ if (list.size() > 3) {
+ lastLargeCollision = System.currentTimeMillis();
+ }
+
+ // Scissors - Delete entity if the collision amount is over 15
+ // Scissors start - Add collision debounce
+ if (list.size() > 15) {
+ this.discard();
+ } else if (list.size() > 3) {
+ lastLargeCollision = System.currentTimeMillis();
+ }
+ // Scissors end
}
}

View File

@ -121,10 +121,10 @@ index 0000000000000000000000000000000000000000..b724baaef8d565e41db1af6393d0890e
+}
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
index 0000000000000000000000000000000000000000..c5dcc833d6f2c0daa1d0c2a7ab81430f25e0b2f3
--- /dev/null
+++ b/src/main/java/me/totalfreedom/scissors/PositionUtility.java
@@ -0,0 +1,83 @@
@@ -0,0 +1,53 @@
+package me.totalfreedom.scissors;
+
+import net.minecraft.core.BlockPos;
@ -135,36 +135,6 @@ index 0000000000000000000000000000000000000000..c54535042a7ac12fe46b3b37db8d7b11
+
+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)
+ {

View File

@ -1,27 +1,26 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Telesphoreo <me@telesphoreo.me>
Date: Sat, 10 Dec 2022 23:38:53 -0600
From: Allink <arclicious@vivaldi.net>
Date: Mon, 18 Apr 2022 03:56:09 +0100
Subject: [PATCH] Reset large tags
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..04c47cf1a920ae6c356449df801227ee14f6dfb7 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;
import java.util.List;
import java.util.function.Predicate;
+import me.totalfreedom.scissors.NbtUtility;
+import me.totalfreedom.scissors.NbtUtility; // Scissors
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,12 @@ public class ContainerHelper {
public static CompoundTag saveAllItems(CompoundTag nbt, NonNullList<ItemStack> stacks, boolean setIfEmpty) {
ListTag listTag = new ListTag();
+ // Scissors - Account for items inside containers
+ long total = 0;
+ long total = 0; // Scissors
for(int i = 0; i < stacks.size(); ++i) {
ItemStack itemStack = stacks.get(i);
@ -30,7 +29,7 @@ index 4092c7a8c2b0d9d26e6f4d97386735236300d132..9e0ab51dd7a4f9fed8f9edde962d42d4
CompoundTag compoundTag = new CompoundTag();
compoundTag.putByte("Slot", (byte)i);
itemStack.save(compoundTag);
@@ -33,7 +37,7 @@ public class ContainerHelper {
@@ -33,7 +36,7 @@ public class ContainerHelper {
}
}
@ -39,34 +38,35 @@ index 4092c7a8c2b0d9d26e6f4d97386735236300d132..9e0ab51dd7a4f9fed8f9edde962d42d4
nbt.put("Items", listTag);
}
@@ -42,11 +46,18 @@ public class ContainerHelper {
@@ -42,11 +45,19 @@ public class ContainerHelper {
public static void loadAllItems(CompoundTag nbt, NonNullList<ItemStack> stacks) {
ListTag listTag = nbt.getList("Items", 10);
+ // Scissors - Account for items inside containers
+ long total = 0;
+ long total = 0; // Scissors - Account for items inside containers
for(int i = 0; i < listTag.size(); ++i) {
CompoundTag compoundTag = listTag.getCompound(i);
int j = compoundTag.getByte("Slot") & 255;
if (j >= 0 && j < stacks.size()) {
+ // Scissors start
+ total += NbtUtility.getTagSize(compoundTag);
+ if (total >= NbtUtility.MAXIMUM_SIZE) {
+ stacks.clear();
+ break;
+ }
+ // Scissors end
stacks.set(j, ItemStack.of(compoundTag));
}
}
diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java
index adb7220be617d6d9f2cdd7fbe4fa2dd24cc7d142..aabde31cd4c6a4f58855156272bc451b042cc315 100644
index adb7220be617d6d9f2cdd7fbe4fa2dd24cc7d142..4a7658deb89e7673bbac8b7e5a91d2861b32e015 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 me.totalfreedom.scissors.NbtUtility; // Scissors
import net.minecraft.ChatFormatting;
import net.minecraft.Util;
import net.minecraft.advancements.CriteriaTriggers;
@ -96,33 +96,31 @@ index adb7220be617d6d9f2cdd7fbe4fa2dd24cc7d142..aabde31cd4c6a4f58855156272bc451b
}
return nbt;
@@ -880,6 +891,9 @@ public final class ItemStack {
@@ -880,6 +891,7 @@ public final class ItemStack {
// Paper end
public void setTag(@Nullable CompoundTag nbt) {
+ // Scissors start - Ignore large tags
+ if (NbtUtility.isTooLarge(nbt)) return;
+ // Scissors end
+ if (NbtUtility.isTooLarge(nbt)) return; // Scissors - Ignore large tags
this.tag = nbt;
this.processEnchantOrder(this.tag); // Paper
if (this.getItem().canBeDepleted()) {
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 448fa4f4f200430d6ce3051763c7ceb697696146..430810b9cc554dfb3bb0972c103c8a36e8db67ef 100644
index 40e59b8db83aec1143e3c394427e916beea7c01f..f292aa0016e6f741b36ddc1417f6f63d248f987f 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 me.totalfreedom.scissors.NbtUtility; // Scissors
import net.minecraft.SharedConstants;
import net.minecraft.Util;
import net.minecraft.core.BlockPos;
@@ -212,6 +213,16 @@ public abstract class AbstractFurnaceBlockEntity extends BaseContainerBlockEntit
@@ -212,6 +213,17 @@ public abstract class AbstractFurnaceBlockEntity extends BaseContainerBlockEntit
public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
public List<ItemStack> getContents() {
+ // Scissors - Account for items inside containers
+ // Scissors start - Account for items inside containers
+ long total = 0;
+
+ for (ItemStack item : this.items) {
@ -132,25 +130,26 @@ index 448fa4f4f200430d6ce3051763c7ceb697696146..430810b9cc554dfb3bb0972c103c8a36
+ if (total > NbtUtility.MAXIMUM_SIZE) {
+ this.items.clear();
+ }
+ // Scissors end
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 416aa989ebb18a8741cc9d605a1180ab830f6643..a9a8c9e68e5b767dec2c26495685da88e0caa627 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 me.totalfreedom.scissors.NbtUtility; // Scissors
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.NonNullList;
@@ -34,6 +35,16 @@ public class BarrelBlockEntity extends RandomizableContainerBlockEntity {
@@ -34,6 +35,17 @@ public class BarrelBlockEntity extends RandomizableContainerBlockEntity {
@Override
public List<ItemStack> getContents() {
+ // Scissors - Account for items inside containers
+ // Scissors start - Account for items inside containers
+ long total = 0;
+
+ for (ItemStack item : this.items) {
@ -160,26 +159,27 @@ index 416aa989ebb18a8741cc9d605a1180ab830f6643..893cf89dd2b022e2b785318e7e86eb5d
+ if (total > NbtUtility.MAXIMUM_SIZE) {
+ this.items.clear();
+ }
+ // Scissors end
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 c57efcb9a79337ec791e4e8f6671612f0a82b441..2cbb8170953cb555411db8c171a3d1d91eb799bb 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;
import java.util.Arrays;
import java.util.Iterator;
import javax.annotation.Nullable;
+import me.totalfreedom.scissors.NbtUtility;
+import me.totalfreedom.scissors.NbtUtility; // Scissors
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
@@ -73,6 +74,17 @@ public class BrewingStandBlockEntity extends BaseContainerBlockEntity implements
}
public List<ItemStack> getContents() {
+ // Scissors - Account for items inside containers
+ // Scissors start - Account for items inside containers
+ long total = 0;
+
+ for (ItemStack item : this.items) {
@ -189,25 +189,26 @@ index c57efcb9a79337ec791e4e8f6671612f0a82b441..2963b72061a9ede734842d6fb46a67a1
+ if (total > NbtUtility.MAXIMUM_SIZE) {
+ this.items.clear();
+ }
+ // Scissors end
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 a71414397bd45ee7bcacfeef0041d80dfa25f114..f51abf1722e98d7ce9e616d84472d847e597eafb 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 me.totalfreedom.scissors.NbtUtility; // Scissors
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
@@ -40,6 +41,17 @@ public class ChestBlockEntity extends RandomizableContainerBlockEntity implement
private int maxStack = MAX_STACK;
public List<ItemStack> getContents() {
+ // Scissors - Account for items inside containers
+ // Scissors start - Account for items inside containers
+ long total = 0;
+
+ for (ItemStack item : this.items) {
@ -217,25 +218,26 @@ index a71414397bd45ee7bcacfeef0041d80dfa25f114..1b6f91055eb01627761e83e5e99e1731
+ if (total > NbtUtility.MAXIMUM_SIZE) {
+ this.items.clear();
+ }
+ // Scissors end
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 881379681c39230a00b3a1f11cd87498984396c7..d0513b72cdaec3b67b9341d251367b193bafa40c 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 me.totalfreedom.scissors.NbtUtility; // Scissors
import net.minecraft.core.BlockPos;
import net.minecraft.core.NonNullList;
import net.minecraft.nbt.CompoundTag;
@@ -28,6 +29,16 @@ public class DispenserBlockEntity extends RandomizableContainerBlockEntity {
@@ -28,6 +29,17 @@ public class DispenserBlockEntity extends RandomizableContainerBlockEntity {
private int maxStack = MAX_STACK;
public List<ItemStack> getContents() {
+ // Scissors - Account for items inside containers
+ // Scissors start - Account for items inside containers
+ long total = 0;
+
+ for (ItemStack item : this.items) {
@ -245,26 +247,27 @@ index 881379681c39230a00b3a1f11cd87498984396c7..1be5d600573f7632e6630224530dd765
+ if (total > NbtUtility.MAXIMUM_SIZE) {
+ this.items.clear();
+ }
+ // Scissors end
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 a8a26a0a37a08b6bbeb5a1fde417d6f448d3c79f..2502c38640fa39552efc02b59733bd0d7330e13a 100644
index a8a26a0a37a08b6bbeb5a1fde417d6f448d3c79f..45e92e5cb10300de9072997cca06968e2c059083 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 me.totalfreedom.scissors.NbtUtility; // Scissors
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
@@ -56,6 +57,17 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
private int maxStack = MAX_STACK;
public List<ItemStack> getContents() {
+ // Scissors - Account for items inside containers
+ // Scissors start - Account for items inside containers
+ long total = 0;
+
+ for (ItemStack item : this.items) {
@ -274,26 +277,27 @@ index a8a26a0a37a08b6bbeb5a1fde417d6f448d3c79f..2502c38640fa39552efc02b59733bd0d
+ if (total > NbtUtility.MAXIMUM_SIZE) {
+ this.items.clear();
+ }
+ // Scissors end
return this.items;
}
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 b7686fd63b7c5d88c3a12ec4ee9bc01a17f997e0..db3a4a8cd19da9775bb0884c33494f1e8591b1fa 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;
import java.util.List;
import java.util.stream.IntStream;
import javax.annotation.Nullable;
+import me.totalfreedom.scissors.NbtUtility;
+import me.totalfreedom.scissors.NbtUtility; // Scissors
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
@@ -60,6 +61,17 @@ public class ShulkerBoxBlockEntity extends RandomizableContainerBlockEntity impl
public boolean opened;
public List<ItemStack> getContents() {
+ // Scissors - Account for items inside containers
+ // Scissors start - Account for items inside containers
+ long total = 0;
+
+ for (ItemStack item : this.itemStacks) {
@ -303,6 +307,7 @@ index b7686fd63b7c5d88c3a12ec4ee9bc01a17f997e0..c2904048625bb4439c7f0ba8a2605d31
+ if (total > NbtUtility.MAXIMUM_SIZE) {
+ this.itemStacks.clear();
+ }
+ // Scissors end
return this.itemStacks;
}

View File

@ -1,21 +1,19 @@
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 79430aef1cbcad7d872435ebdec60321e2573bb3..ee1744ca00fe14b052b9d164d2bbe9dc93201bde 100644
index 66d20a86a56cccc39b1de2973e288817ab1bc14e..8ad6fae4fddc9a5d656c097eda5020672b242e2b 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 {
@@ -862,7 +862,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
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);
+ // Scissors start - Prevent log spam possible with this error message, easily provokable by players in creative.
+ // LivingEntity.LOGGER.warn("Unable to add mob to team \"{}\" (that team probably doesn't exist)", s);
+ // Scissors end
+ // Scissors - Prevent log spam possible with this error message, easily provokable by players in creative.
}
}

View File

@ -1,6 +1,6 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Telesphoreo <me@telesphoreo.me>
Date: Mon, 22 Aug 2022 21:33:37 -0500
From: Video <videogamesm12@gmail.com>
Date: Fri, 19 Aug 2022 00:49:38 -0600
Subject: [PATCH] Fixes out of bounds HangingEntity crash exploit

View File

@ -5,34 +5,29 @@ 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 2e7c03b00bc941b86df6a7f1b2b188c9f0aede22..6d4defceae65290a60a84561293d5b4095c4dcaa 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 @@
package net.minecraft.world.level.block;
+import me.totalfreedom.scissors.event.block.MasterBlockFireEvent;
+import me.totalfreedom.scissors.event.block.MasterBlockFireEvent; // Scissors
import com.mojang.logging.LogUtils;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
@@ -25,10 +26,10 @@ import net.minecraft.world.level.block.state.properties.BlockStateProperties;
@@ -25,6 +26,7 @@ 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.world.phys.BlockHitResult;
+import org.bukkit.event.block.BlockRedstoneEvent;
+import org.bukkit.Location;
+import org.bukkit.Location; // Scissors
import org.slf4j.Logger;
-import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit
-
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 {
import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit
@@ -117,6 +119,15 @@ public class CommandBlock extends BaseEntityBlock implements GameMasterBlock {
}
private void execute(BlockState state, Level world, BlockPos pos, BaseCommandBlock executor, boolean hasCommand) {
+ // Scissors - Add master block fire event
+ // Scissors start - Add master block fire event
+ final MasterBlockFireEvent event = new MasterBlockFireEvent(new Location(world.getWorld(), pos.getX(), pos.getY(), pos.getZ()));
+
+ if (!event.callEvent())
@ -44,44 +39,31 @@ index 2e7c03b00bc941b86df6a7f1b2b188c9f0aede22..333f9bcccbe9ecd88c1fd13e2956f694
if (hasCommand) {
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
--- a/src/main/java/net/minecraft/world/level/block/StructureBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/StructureBlock.java
@@ -1,6 +1,7 @@
package net.minecraft.world.level.block;
import javax.annotation.Nullable;
+
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.InteractionHand;
diff --git a/src/main/java/net/minecraft/world/level/block/entity/JigsawBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/JigsawBlockEntity.java
index 182e16c1d968707a11329150d71b7d01df6c6e52..fa5cade3f5f2fecc37cc065b96403d0a1c1a2553 100644
index 182e16c1d968707a11329150d71b7d01df6c6e52..8582a9369cffe0eebeb82a81fc413d0bf4ad28ed 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;
@@ -2,6 +2,7 @@ package net.minecraft.world.level.block.entity;
import java.util.Arrays;
import java.util.Optional;
+
+import me.totalfreedom.scissors.event.block.MasterBlockFireEvent;
+import me.totalfreedom.scissors.event.block.MasterBlockFireEvent; // Scissors
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;
@@ -17,6 +18,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 org.bukkit.Location;
+import org.bukkit.Location; // Scissors
public class JigsawBlockEntity extends BlockEntity {
public static final String TARGET = "target";
@@ -107,6 +110,16 @@ public class JigsawBlockEntity extends BlockEntity {
@@ -107,6 +109,16 @@ public class JigsawBlockEntity extends BlockEntity {
}
public void generate(ServerLevel world, int maxDepth, boolean keepJigsaws) {
+ // Scissors - Add master block fire event
+ // Scissors start - 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()));
+
@ -95,31 +77,31 @@ index 182e16c1d968707a11329150d71b7d01df6c6e52..fa5cade3f5f2fecc37cc065b96403d0a
Registry<StructureTemplatePool> registry = world.registryAccess().registryOrThrow(Registries.TEMPLATE_POOL);
// Paper start - Replace getHolderOrThrow with a null check
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 9792bf3ee083f571f1f4089d30beb586839f5f6b..fa6592cdc916d3578fccc6c0075eb616fd3f73eb 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;
@@ -5,6 +5,7 @@ import java.util.Objects;
import java.util.Optional;
import java.util.stream.Stream;
import javax.annotation.Nullable;
+
+import me.totalfreedom.scissors.event.block.MasterBlockFireEvent;
+import me.totalfreedom.scissors.event.block.MasterBlockFireEvent; // Scissors
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
@@ -29,6 +30,7 @@ import net.minecraft.world.level.levelgen.structure.templatesystem.BlockRotProce
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;
+import org.bukkit.Location; // Scissors
public class StructureBlockEntity extends BlockEntity {
private static final int SCAN_CORNER_BLOCKS_RANGE = 5;
@@ -264,7 +267,6 @@ public class StructureBlockEntity extends BlockEntity {
@@ -264,7 +266,7 @@ public class StructureBlockEntity extends BlockEntity {
return false;
} else {
BlockPos blockPos = this.getBlockPos();
- int i = 80;
+ // Scissors - Obfuscation fixes
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);
@ -127,7 +109,7 @@ index 9792bf3ee083f571f1f4089d30beb586839f5f6b..e9d584b0ca984f9b7c70f99e1665cded
public boolean saveStructure(boolean bl) {
if (this.mode == StructureMode.SAVE && !this.level.isClientSide && this.structureName != null) {
+ // Scissors - Add master block fire event
+ // Scissors start - 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()));
+
@ -144,7 +126,7 @@ index 9792bf3ee083f571f1f4089d30beb586839f5f6b..e9d584b0ca984f9b7c70f99e1665cded
public boolean loadStructure(ServerLevel world, boolean bl) {
if (this.mode == StructureMode.LOAD && this.structureName != null) {
+ // Scissors - Add master block fire event
+ // Scissors start - 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()));
+
@ -161,7 +143,7 @@ index 9792bf3ee083f571f1f4089d30beb586839f5f6b..e9d584b0ca984f9b7c70f99e1665cded
}
public void unloadStructure() {
+ // Scissors - Add master block fire event
+ // Scissors start - 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()));
+

View File

@ -5,13 +5,13 @@ 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 fa5fee810dc8aa7febb46bbf0ad9ab9ce9ffbabd..77bf4cebd9cb92d6dfd03b6734b50d4457243bc9 100644
index a38c677b01dc4a18ac63d2e5f63cd40d07cc02d9..871f060682a7ff9772d09c0a6afbd55c8360e296 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 me.totalfreedom.scissors.event.player.SpectatorTeleportEvent; // Scissors
import com.google.common.collect.Lists;
import com.google.common.primitives.Floats;
import com.mojang.brigadier.ParseResults;

View File

@ -5,27 +5,18 @@ 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 77bf4cebd9cb92d6dfd03b6734b50d4457243bc9..f6f5efbf757f1508b628db90c9f63da382ebf4d5 100644
index 871f060682a7ff9772d09c0a6afbd55c8360e296..aaaa55f8574694e4b83824773a99461b2f36542a 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;
@@ -30,6 +30,7 @@ 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.kyori.adventure.text.format.NamedTextColor; // Scissors
import net.minecraft.ChatFormatting;
import net.minecraft.CrashReport;
import net.minecraft.CrashReportCategory;
@@ -2989,6 +2991,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
@@ -3010,6 +3013,18 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
@@ -3010,6 +3011,18 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
return;
}

View File

@ -0,0 +1,73 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Allink <arclicious@vivaldi.net>
Date: Sun, 10 Jul 2022 10:29:03 +0100
Subject: [PATCH] Disable running commands in books by default
diff --git a/src/main/java/net/minecraft/world/item/WrittenBookItem.java b/src/main/java/net/minecraft/world/item/WrittenBookItem.java
index 31911c09fe15753ae32fa39417bdc9e9de552a88..b810a5afcb2343174e37efb7dd8a36b968b07c3a 100644
--- a/src/main/java/net/minecraft/world/item/WrittenBookItem.java
+++ b/src/main/java/net/minecraft/world/item/WrittenBookItem.java
@@ -2,6 +2,7 @@ package net.minecraft.world.item;
import java.util.List;
import javax.annotation.Nullable;
+import me.totalfreedom.scissors.ScissorsConfig; // Scissors
import net.minecraft.ChatFormatting;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.core.BlockPos;
@@ -9,8 +10,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.*; // Scissors
import net.minecraft.stats.Stats;
import net.minecraft.util.StringUtil;
import net.minecraft.world.InteractionHand;
@@ -161,9 +161,43 @@ 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) {
return true;

View File

@ -1,37 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Allink <arclicious@vivaldi.net>
Date: Tue, 16 Aug 2022 17:13:02 +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
--- 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 {
}
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()};
+ }
+ // Scissors end
return new StringMessage(message, keepNewlines, plain).getOutput();
}

View File

@ -5,19 +5,15 @@ 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 f6f5efbf757f1508b628db90c9f63da382ebf4d5..cb5f11f60e5abe21ca3dd724c79f29391cd052cc 100644
index 682f3940659b48fd04e5ec65d5557a679eb8b267..08e3e3a2085f23f890890adac5d6b575b9b2364f 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -1375,8 +1375,10 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
@@ -1374,7 +1374,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)) {
- BlockEntity tileentity = this.player.level().getBlockEntity(packet.getPos());
+ // Scissors - Validate block entity tag query positions
+ if (this.player.hasPermissions(2) && Level.isInSpawnableBounds(packet.getPos())) {
+ BlockEntity tileentity = this.player.level().isLoaded(packet.getPos()) ? this.player.level().getBlockEntity(packet.getPos()) : null;
+ // Scissors end
+ if (this.player.hasPermissions(2) && this.player.level().isLoadedAndInBounds(packet.getPos())) { // Scissors - Validate block entity tag query positions
BlockEntity tileentity = this.player.level().getBlockEntity(packet.getPos());
CompoundTag nbttagcompound = tileentity != null ? tileentity.saveWithoutMetadata() : null;
this.player.connection.send(new ClientboundTagQueryPacket(packet.getTransactionId(), nbttagcompound));

View File

@ -0,0 +1,67 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Allink <arclicious@vivaldi.net>
Date: Wed, 13 Jul 2022 12:13:22 +0100
Subject: [PATCH] Fix ClickEvents on Signs bypassing permissions
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 0521240dddde12d78cc05deda7fac11690f5d155..694d99d345025450bebc4c207392151c2f0085e3 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,10 @@ import java.util.Objects;
import java.util.UUID;
import java.util.function.UnaryOperator;
import javax.annotation.Nullable;
+import me.totalfreedom.scissors.ScissorsConfig; // Scissors
import net.minecraft.commands.CommandSource;
import net.minecraft.commands.CommandSourceStack;
+import net.minecraft.commands.Commands; // Scissors
import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtOps;
@@ -19,6 +21,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; // Scissors
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.server.network.FilteredText;
@@ -30,6 +33,7 @@ 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; // Scissors
import org.slf4j.Logger;
import org.bukkit.block.sign.Side;
import org.bukkit.craftbukkit.block.CraftBlock;
@@ -37,6 +41,7 @@ import org.bukkit.craftbukkit.util.CraftChatMessage;
import org.bukkit.entity.Player;
import org.bukkit.event.block.SignChangeEvent;
// CraftBukkit end
+import org.bukkit.craftbukkit.CraftServer; // Scissors
public class SignBlockEntity extends BlockEntity implements CommandSource { // CraftBukkit - implements
@@ -286,6 +291,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;
}
}

View File

@ -0,0 +1,18 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Allink <arclicious@vivaldi.net>
Date: Tue, 16 Aug 2022 17:13:02 +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..c006ac8531cf2c029fd2fac449f96736a4afed0d 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java
@@ -199,6 +199,7 @@ public final class CraftChatMessage {
}
public static Component[] fromString(String message, boolean keepNewlines, boolean plain) {
+ if (message.length() > 1_000) return new Component[]{Component.empty()}; // Scissors - Refuse to convert legacy messages over 1k characters
return new StringMessage(message, keepNewlines, plain).getOutput();
}

View File

@ -5,13 +5,13 @@ 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 6c9a8f062f989db022154155e8a05b334a0510da..68c80eab60680c647094b4465ee1377c9e13d5ff 100644
index 6c9a8f062f989db022154155e8a05b334a0510da..978fad27ad17de03d108ade2c2bfa464b7d83491 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 me.totalfreedom.scissors.MathUtility; // Scissors
import net.minecraft.core.particles.ParticleOptions;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.nbt.CompoundTag;
@ -26,9 +26,9 @@ index 6c9a8f062f989db022154155e8a05b334a0510da..68c80eab60680c647094b4465ee1377c
+ //this.xPower = d3 / d6 * 0.1D;
+ //this.yPower = d4 / d6 * 0.1D;
+ //this.zPower = d5 / d6 * 0.1D;
+ // Scissors end
+
+ setPower(d3 / d6 * .1d, d4 / d6 * .1d, d5 / d6 * .1d);
+ // Scissors end
}
}
@ -69,13 +69,13 @@ index 6c9a8f062f989db022154155e8a05b334a0510da..68c80eab60680c647094b4465ee1377c
+ //this.xPower = nbttaglist.getDouble(0);
+ //this.yPower = nbttaglist.getDouble(1);
+ //this.zPower = nbttaglist.getDouble(2);
+ // Scissors end
+
+ setPower(nbttaglist.getDouble(0), nbttaglist.getDouble(1), nbttaglist.getDouble(2));
+ // Scissors end
}
}
@@ -184,9 +212,12 @@ public abstract class AbstractHurtingProjectile extends Projectile {
@@ -184,9 +212,13 @@ public abstract class AbstractHurtingProjectile extends Projectile {
Vec3 vec3d = entity.getLookAngle();
this.setDeltaMovement(vec3d);
@ -86,6 +86,7 @@ index 6c9a8f062f989db022154155e8a05b334a0510da..68c80eab60680c647094b4465ee1377c
+ //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);

View File

@ -0,0 +1,101 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Allink <arclicious@vivaldi.net>
Date: Tue, 31 Jan 2023 23:16:52 +0000
Subject: [PATCH] Add configuration option to disable chat signatures
diff --git a/src/main/java/net/minecraft/network/chat/OutgoingChatMessage.java b/src/main/java/net/minecraft/network/chat/OutgoingChatMessage.java
index 74cf1c043beef03cfd5adf481414a5ee78bef2a6..1a44bad14ce764d6c09f38065ee8e5f0da4975aa 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; // Scissors
import net.minecraft.server.level.ServerPlayer;
public interface OutgoingChatMessage {
@@ -44,10 +45,25 @@ public interface OutgoingChatMessage {
// Paper end
PlayerChatMessage playerChatMessage = this.message.filter(filterMaskEnabled);
playerChatMessage = unsigned != null ? playerChatMessage.withUnsignedContent(unsigned) : playerChatMessage; // Paper
- if (!playerChatMessage.isFullyFiltered()) {
+ // Scissors start
+ if (!playerChatMessage.isFullyFiltered() && ScissorsConfig.chatSignaturesEnabled) {
sender.connection.sendPlayerChatMessage(playerChatMessage, params);
+ return;
}
+ if (sender.getServer().server.getOnlineMode()) {
+ sender.connection.sendDisguisedChatMessage(playerChatMessage.decoratedContent(), params);
+ } else {
+ sender.connection.sendPlayerChatMessage(new PlayerChatMessage(
+ SignedMessageLink.unsigned(playerChatMessage.sender()),
+ null,
+ SignedMessageBody.unsigned(playerChatMessage.signedContent()),
+ unsigned,
+ playerChatMessage.filterMask(),
+ playerChatMessage.result()
+ ), params);
+ }
+ // Scissors end
}
}
}
diff --git a/src/main/java/net/minecraft/network/chat/SignedMessageChain.java b/src/main/java/net/minecraft/network/chat/SignedMessageChain.java
index c0a80824a0307ea673805015119cc834b268f0dc..9f28f86b1b56ea55ab39f6ac988c1f47c5312c6c 100644
--- a/src/main/java/net/minecraft/network/chat/SignedMessageChain.java
+++ b/src/main/java/net/minecraft/network/chat/SignedMessageChain.java
@@ -4,6 +4,7 @@ import com.mojang.logging.LogUtils;
import java.time.Instant;
import java.util.UUID;
import javax.annotation.Nullable;
+import me.totalfreedom.scissors.ScissorsConfig; // Scissors
import net.minecraft.util.SignatureUpdater;
import net.minecraft.util.SignatureValidator;
import net.minecraft.util.Signer;
@@ -41,7 +42,7 @@ public class SignedMessageChain {
if (!playerChatMessage.verify(signatureValidator)) {
throw new SignedMessageChain.DecodeException(Component.translatable("multiplayer.disconnect.unsigned_chat"), true, org.bukkit.event.player.PlayerKickEvent.Cause.UNSIGNED_CHAT); // Paper - kick event causes
} else {
- if (playerChatMessage.hasExpiredServer(Instant.now())) {
+ if (playerChatMessage.hasExpiredServer(Instant.now()) && ScissorsConfig.chatSignaturesEnabled) { // Scissors
LOGGER.warn("Received expired chat: '{}'. Is the client/server system time unsynchronized?", (Object)body.content());
}
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index 8382d6c4589d2035fcb0ad410f442ead235059e4..f59b2ed4c3f8a4049223985e41537d5fa8bb2f0b 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; // Scissors
import me.totalfreedom.scissors.event.player.SpectatorTeleportEvent; // Scissors
import com.google.common.collect.Lists;
import com.google.common.primitives.Floats;
@@ -2322,7 +2323,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
}
private void handleMessageDecodeFailure(SignedMessageChain.DecodeException exception) {
- if (exception.shouldDisconnect()) {
+ if (exception.shouldDisconnect() && ScissorsConfig.chatSignaturesEnabled) { // Scissors - Do not kick when chat signatures are disabled
this.disconnect(exception.getComponent(), exception.kickCause); // Paper - kick event causes
} else {
this.player.sendSystemMessage(exception.getComponent().copy().withStyle(ChatFormatting.RED));
@@ -2378,6 +2379,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
Optional<LastSeenMessages> optional = this.lastSeenMessages.applyUpdate(acknowledgment);
if (optional.isEmpty()) {
+ if (!ScissorsConfig.chatSignaturesEnabled) return optional; // Scissors
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
}
@@ -2613,6 +2615,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
synchronized (this.lastSeenMessages) {
if (!this.lastSeenMessages.applyOffset(packet.offset())) {
+ if (!ScissorsConfig.chatSignaturesEnabled) return; // Scissors
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
}

View File

@ -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 c19ea0dd30c39b1e7a30ab5bcc32820a5ee3d16a..4705a80cd759dce1fe5313417c7eb0e7be05e706 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -4628,7 +4628,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;
}
@@ -4640,7 +4642,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;
}

View File

@ -0,0 +1,19 @@
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 c19ea0dd30c39b1e7a30ab5bcc32820a5ee3d16a..dd1e22aa7c7195201ee09cc9d3529ca64a1e6509 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -4640,7 +4640,7 @@ 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 - Patch invalid entity rotation log spam
} else {
this.xRot = pitch;
}

View File

@ -18,14 +18,14 @@ 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 f25b9330e068c7d9e12cb57a7761cfef9ebaf7bc..e8cf963f0190438bbf65f827d144775ab0b02b63 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 me.totalfreedom.scissors.MathUtility; // Scissors
import net.minecraft.advancements.critereon.MinMaxBounds;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.arguments.EntityArgument;

View File

@ -5,20 +5,14 @@ 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
index ab732f0e52ef3c3d3be6ddc827d693fe294e4167..9785f2d8c94552b4a1139fa6d936fdaa61e5827c 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 {
@@ -141,6 +141,7 @@ 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
+
+ if (!world.getMinecraftWorld().isLoadedAndInBounds(chargeCursor.getPos())) continue; // Scissors
chargeCursor.update(world, pos, random, this, shouldConvertToBlock);
if (chargeCursor.charge <= 0) {
world.levelEvent(3006, chargeCursor.getPos(), 0);

View File

@ -5,18 +5,18 @@ Subject: [PATCH] Limit map decorations
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 347d2914f9560a3ee8cea59444bc0dfbb7cf3456..b6a38b1458957bd444fea439fa81d2976ffb86e0 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.ChatFormatting; // Scissors
import net.minecraft.network.chat.Component;
import net.minecraft.util.Mth;
@@ -14,6 +15,12 @@ public class MapDecoration {
@@ -14,6 +15,11 @@ public class MapDecoration {
private final Component name;
public MapDecoration(MapDecoration.Type type, byte x, byte z, byte rotation, @Nullable Component text) {
@ -25,15 +25,14 @@ index 347d2914f9560a3ee8cea59444bc0dfbb7cf3456..b225f770869832775c9a8a79ffaf89e9
+ text = null;
+ }
+ // Scissors end
+
this.type = type;
this.x = x;
this.y = z;
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 3b12030b49b1c539684d75ca3896eb498400ef99..0d55d73bd31747ad9579aebbb77f315aa3dc2bc8 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 {
@@ -354,6 +354,11 @@ 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) {
@ -42,7 +41,6 @@ index 3b12030b49b1c539684d75ca3896eb498400ef99..a1f042e5329343489cf30e436a8f553d
+ return;
+ }
+ // Scissors end
+
int i = 1 << this.scale;
float f = (float) (x - (double) this.centerX) / (float) i;
float f1 = (float) (z - (double) this.centerZ) / (float) i;

View File

@ -5,15 +5,14 @@ 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 18aac3da3c88f33b1a71a5920a8daa27e9723913..f5b59d0ab82472e1c992ffb6a8b7fbb687a2b70f 100644
index 18aac3da3c88f33b1a71a5920a8daa27e9723913..b1bfb12f10d6fec9ca905498b4a6768997867311 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 {
@@ -1610,7 +1610,13 @@ public class ServerLevel extends Level implements WorldGenLevel {
if (entity != null) {
ServerLevel.LOGGER.warn("Force-added player with duplicate UUID {}", player.getUUID().toString());
entity.unRide();
- this.removePlayerImmediately((ServerPlayer) entity, Entity.RemovalReason.DISCARDED);
+
+ // Scissors start - Prevent player banning using duplicate UUIDs
+ if (entity instanceof ServerPlayer serverPlayer) {
+ this.removePlayerImmediately(serverPlayer, Entity.RemovalReason.DISCARDED);

View File

@ -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 ec93980fefcab57b7bac78d2fc4a217b376b7eca..44920c46aa75bcdc450e192d8c8ca0bf7ad0b7d5 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();
}

View File

@ -5,18 +5,14 @@ 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
index 2873ed7c443ed8c8c57a8b1d3e444d229f10f07b..a2149452ee461002ea74189c5aa49cddd943d0cf 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> {
@@ -266,6 +266,7 @@ 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
+ if (jsonarray.size() <= 0) throw new JsonParseException("Unexpected empty array of components"); // Scissors
ichatmutablecomponent = null;
Iterator iterator = jsonarray.iterator();

View File

@ -4,36 +4,8 @@ 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 44920c46aa75bcdc450e192d8c8ca0bf7ad0b7d5..56aa12b57d893b0be9ff7a18df87645dae2c8a19 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
index a2149452ee461002ea74189c5aa49cddd943d0cf..f1d1501211a923c0ccab6b5982887c3a9262889b 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;
@ -41,7 +13,7 @@ index 9c2c22ee548ad77f0912698f33de5f467f32fb7f..ba2879b25e59290ab81501458414a417
import java.util.Optional;
import javax.annotation.Nullable;
+import me.totalfreedom.scissors.ScissorsConfig; // Scissors
import net.minecraft.ChatFormatting;
import net.minecraft.ChatFormatting; // Scissors
import net.minecraft.Util;
import net.minecraft.network.chat.contents.BlockDataSource;
@@ -44,6 +45,7 @@ import net.minecraft.util.GsonHelper;
@ -66,80 +38,70 @@ index 9c2c22ee548ad77f0912698f33de5f467f32fb7f..ba2879b25e59290ab81501458414a417
+ if (depth > ScissorsConfig.componentDepthLimit) {
+ throw new JsonParseException("Depth limit exceeded");
+ }
+
+ // Scissors end
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();
@@ -273,7 +281,7 @@ public interface Component extends Message, FormattedText, Iterable<Component> {
while (iterator.hasNext()) {
JsonElement jsonelement1 = (JsonElement) iterator.next();
- MutableComponent ichatmutablecomponent1 = this.deserialize(jsonelement1, jsonelement1.getClass(), jsondeserializationcontext);
+ MutableComponent ichatmutablecomponent1 = this.deserialize(jsonelement1, jsondeserializationcontext, depth + 1);
+ MutableComponent ichatmutablecomponent1 = this.deserialize(jsonelement1, jsondeserializationcontext, depth + 1); // Scissors
if (ichatmutablecomponent == null) {
ichatmutablecomponent = ichatmutablecomponent1;
@@ -301,12 +307,17 @@ public interface Component extends Message, FormattedText, Iterable<Component> {
@@ -297,12 +305,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
+ // Scissors start - 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;
+
+ // Scissors end
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));
+ aobject[i] = Serializer.unwrapTextArgument(this.deserialize(jsonarray1.get(i), jsondeserializationcontext, depth + 1 + penalty)); // Scissors
}
ichatmutablecomponent = Component.translatableWithFallback(s, s1, aobject);
@@ -322,7 +333,7 @@ public interface Component extends Message, FormattedText, Iterable<Component> {
@@ -318,7 +331,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);
+ Optional<Component> optional = this.parseSeparator(jsondeserializationcontext, jsonobject, depth + 1); // Scissors
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> {
@@ -329,7 +342,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);
+ Optional<Component> optional1 = this.parseSeparator(jsondeserializationcontext, jsonobject, depth + 1); // Scissors
boolean flag = GsonHelper.getAsBoolean(jsonobject, "interpret", false);
Object object;
@@ -360,7 +371,7 @@ public interface Component extends Message, FormattedText, Iterable<Component> {
@@ -356,7 +369,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));
+ ichatmutablecomponent.append((Component) this.deserialize(jsonarray2.get(j), jsondeserializationcontext, depth + 1)); // Scissors
}
}
@@ -370,6 +381,11 @@ public interface Component extends Message, FormattedText, Iterable<Component> {
@@ -366,6 +379,12 @@ public interface Component extends Message, FormattedText, Iterable<Component> {
}
}
+ // Scissors start
+ public MutableComponent deserialize(JsonElement jsonelement, Type type, JsonDeserializationContext jsondeserializationcontext) throws JsonParseException {
+ return this.deserialize(jsonelement, jsondeserializationcontext, 1);
+ }
@ -148,7 +110,7 @@ index 9c2c22ee548ad77f0912698f33de5f467f32fb7f..ba2879b25e59290ab81501458414a417
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> {
@@ -384,8 +403,10 @@ public interface Component extends Message, FormattedText, Iterable<Component> {
return text;
}

View File

@ -18,39 +18,40 @@ index c99fc118013cb3d4043638e2001a8297e79ddf9c..cdaa81e1f2167b29ec01cc25e51a8400
private final boolean trackOutput;
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index 26bf05922698c734302fa80076e7a1eadbfe1d8d..dcb8058380bea82bae1b02de4fdcbd0463d3a4f3 100644
index f59b2ed4c3f8a4049223985e41537d5fa8bb2f0b..bc7ada4d20ff006a709d72d7002510b637c5244f 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 me.totalfreedom.scissors.ScissorsConfig; // Scissors
+import me.totalfreedom.scissors.event.block.CommandBlockPlayerEditEvent; // Scissors
+import me.totalfreedom.scissors.event.block.CommandMinecartPlayerEditEvent; // Scissors
import me.totalfreedom.scissors.event.player.SpectatorTeleportEvent; // Scissors
import com.google.common.collect.Lists;
import com.google.common.primitives.Floats;
@@ -160,6 +162,7 @@ import net.minecraft.world.entity.player.Inventory;
@@ -159,6 +161,7 @@ import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.entity.player.ProfilePublicKey;
import net.minecraft.world.entity.projectile.AbstractArrow;
import net.minecraft.world.entity.vehicle.Boat;
+import net.minecraft.world.entity.vehicle.MinecartCommandBlock;
+import net.minecraft.world.entity.vehicle.MinecartCommandBlock; // Scissors
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.BucketItem;
import net.minecraft.world.item.Item;
@@ -188,6 +191,8 @@ import net.minecraft.world.phys.Vec3;
@@ -187,6 +190,8 @@ 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;
+import org.bukkit.craftbukkit.block.CraftCommandBlock;
+import org.bukkit.craftbukkit.entity.CraftMinecartCommand;
+import org.bukkit.craftbukkit.block.CraftCommandBlock; // Scissors
+import org.bukkit.craftbukkit.entity.CraftMinecartCommand; // Scissors
import org.slf4j.Logger;
// CraftBukkit start
@@ -1001,6 +1006,17 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
@@ -1000,6 +1005,16 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
this.player.level().getChunkAt(blockposition).setBlockEntity(tileentity);
}
+ // Scissors start
+ CommandBlockPlayerEditEvent event = new CommandBlockPlayerEditEvent(this.getCraftPlayer(), commandblocklistenerabstract.getCommand(), s, new CraftCommandBlock(this.player.level().getWorld(), tileentitycommand));
+
+ if (!event.callEvent()) {
@ -58,14 +59,12 @@ index 26bf05922698c734302fa80076e7a1eadbfe1d8d..dcb8058380bea82bae1b02de4fdcbd04
+ }
+
+ s = event.getNewCommand();
+
+
+ // Scissors end
+
commandblocklistenerabstract.setCommand(s);
commandblocklistenerabstract.setTrackOutput(flag);
if (!flag) {
@@ -1032,7 +1048,21 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
@@ -1031,7 +1046,18 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
BaseCommandBlock commandblocklistenerabstract = packet.getCommandBlock(this.player.level());
if (commandblocklistenerabstract != null) {
@ -81,10 +80,7 @@ index 26bf05922698c734302fa80076e7a1eadbfe1d8d..dcb8058380bea82bae1b02de4fdcbd04
+ command = event.getNewCommand();
+ commandblocklistenerabstract.setCommand(command);
+
+ // commandblocklistenerabstract.setCommand(packet.getCommand());
+
+ // Scissors end
+
commandblocklistenerabstract.setTrackOutput(packet.isTrackOutput());
if (!packet.isTrackOutput()) {
commandblocklistenerabstract.setLastOutput((Component) null);

View File

@ -5,20 +5,17 @@ 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 fbfe810e8be6cb159742f7fd85e7491b9cefa4dc..b70bafe2766efcbcce00287e6511a588560564a6 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 {
@@ -169,9 +169,56 @@ public class TagParser {
}
this.expect('}');
- return compoundTag;
+
+ // Scissors start - Add depth limit to SNBT
+ return exceedsDepthLimit(compoundTag) ? new CompoundTag() : compoundTag;
+ // Scissors end
+ }
+
+ return exceedsDepthLimit(compoundTag) ? new CompoundTag() : compoundTag; // Scissors - Add depth limit to SNBT
}
+ // Scissors start - Add depth limit to SNBT
+ private boolean exceedsDepthLimit(Tag tag) {
+ return this.exceedsDepthLimit(0, tag);
@ -63,25 +60,22 @@ index fbfe810e8be6cb159742f7fd85e7491b9cefa4dc..82b1d851e310504e7373a967dfb5b0b0
+ }
+
+ return false;
}
+ }
+ // Scissors end
+
private Tag readListTag() throws CommandSyntaxException {
this.expect('[');
@@ -203,7 +253,11 @@ public class TagParser {
this.reader.skipWhitespace();
@@ -203,7 +250,7 @@ public class TagParser {
}
this.expect(']');
- return listTag;
+
+ // Scissors start - Add depth limit to SNBT
+ return exceedsDepthLimit(listTag) ? new ListTag() : listTag;
+ // return listTag;
+ // Scissors end
+ return exceedsDepthLimit(listTag) ? new ListTag() : listTag; // Scissors - Add depth limit to SNBT
}
}
@@ -228,7 +282,7 @@ public class TagParser {
@@ -228,7 +275,7 @@ public class TagParser {
}
private <T extends Number> List<T> readArray(TagType<?> arrayTypeReader, TagType<?> typeReader) throws CommandSyntaxException {
@ -90,7 +84,7 @@ index fbfe810e8be6cb159742f7fd85e7491b9cefa4dc..82b1d851e310504e7373a967dfb5b0b0
while(true) {
if (this.reader.peek() != ']') {
@@ -241,11 +295,11 @@ public class TagParser {
@@ -241,11 +288,11 @@ public class TagParser {
}
if (typeReader == ByteTag.TYPE) {
@ -105,7 +99,7 @@ index fbfe810e8be6cb159742f7fd85e7491b9cefa4dc..82b1d851e310504e7373a967dfb5b0b0
}
if (this.hasElementSeparator()) {
@@ -257,7 +311,7 @@ public class TagParser {
@@ -257,7 +304,7 @@ public class TagParser {
}
this.expect(']');

View File

@ -4,37 +4,6 @@ Date: Tue, 13 Jun 2023 18:29:18 -0300
Subject: [PATCH] Improve validation of ResourceLocations
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 430810b9cc554dfb3bb0972c103c8a36e8db67ef..b2832c75beab2a1fa077b0317392b6aa46134ce6 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
@@ -300,7 +300,12 @@ public abstract class AbstractFurnaceBlockEntity extends BaseContainerBlockEntit
while (iterator.hasNext()) {
String s = (String) iterator.next();
- this.recipesUsed.put(new ResourceLocation(s), nbttagcompound1.getInt(s));
+ // Scissors start
+ final ResourceLocation rl = ResourceLocation.tryParse(s);
+ if (rl != null) {
+ this.recipesUsed.put(rl, nbttagcompound1.getInt(s));
+ }
+ // Scissors end
}
// Paper start - cook speed API
diff --git a/src/main/java/net/minecraft/world/level/block/entity/BrushableBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BrushableBlockEntity.java
index 7a3ac883be4015d41a4c7582341a424b4bd6bbf4..6a6d34831a3c9a1a0fd47dbfd3a497c0b7923ce5 100644
--- a/src/main/java/net/minecraft/world/level/block/entity/BrushableBlockEntity.java
+++ b/src/main/java/net/minecraft/world/level/block/entity/BrushableBlockEntity.java
@@ -199,7 +199,7 @@ public class BrushableBlockEntity extends BlockEntity {
private boolean tryLoadLootTable(CompoundTag nbt) {
if (nbt.contains("LootTable", 8)) {
- this.lootTable = new ResourceLocation(nbt.getString("LootTable"));
+ this.lootTable = ResourceLocation.tryParse(nbt.getString("LootTable")); // Scissors
this.lootTableSeed = nbt.getLong("LootTableSeed");
return true;
} else {
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftNamespacedKey.java b/src/main/java/org/bukkit/craftbukkit/util/CraftNamespacedKey.java
index 5014192edb9616ce725fc1592832034789527b6f..64da1b0afd51720803aba0d9e86d0b1743bdb0da 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftNamespacedKey.java