First pass at patches

This commit is contained in:
Telesphoreo 2023-03-15 22:57:35 -05:00
parent 9c6fa332cc
commit c6da2c38d2
29 changed files with 79 additions and 853 deletions

View File

@ -5,7 +5,7 @@ Subject: [PATCH] Build changes
diff --git a/build.gradle.kts b/build.gradle.kts
index 1919a8e9cb7c995b2a9c876ff4980bdc98977133..244ea8f19b79e7ad55a88c964bb0e9f066f9a7e7 100644
index 9cf389defdaeb887e9cad4f0fed3f3b95667b238..e92a7dd91f4b4771d8087a5fbeed225938da0ef8 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -7,8 +7,10 @@ plugins {
@ -51,10 +51,10 @@ index 1919a8e9cb7c995b2a9c876ff4980bdc98977133..244ea8f19b79e7ad55a88c964bb0e9f0
standardInput = System.`in`
workingDir = rootProject.layout.projectDirectory
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 753a917d34a1e1c1521a8916bc8e44a6acd90a46..b289da2fc7c2053415365505f830aaa045f70ff2 100644
index 081871412e92ce909ad9c51a8d18ede53596c049..f26e4dbdc4cbe7b732d890335759fe3cd5d5aab1 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1654,7 +1654,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -1680,7 +1680,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@DontObfuscate
public String getServerModName() {
@ -64,10 +64,10 @@ index 753a917d34a1e1c1521a8916bc8e44a6acd90a46..b289da2fc7c2053415365505f830aaa0
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 bbb8335dae0a3e2761e6bbb8dc723bcf28cd82ba..3fa8a282e4511e79def2470f1abc34f3bf6527a3 100644
index f9a9d2bb7b6d1bf4a0931438de4d8c7ee0757479..ccc578bf2d7edfe866a5892978ce9e116787c4b4 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
@@ -256,7 +256,7 @@ import javax.annotation.Nullable; // Paper
import javax.annotation.Nonnull; // Paper
public final class CraftServer implements Server {

View File

@ -32,10 +32,10 @@ index 2ee4ee14ab3345486dad6b24fd9a4fcc6c746b99..c5ac6cda91a81d3075f5c763e30dc009
@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 d559f93a9a09bac414dd5d58afccad42c127f09b..8ac4e76bf9acf2f99539c4f874ac5c8605573604 100644
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
@@ -45,7 +45,7 @@ public abstract class RandomizableContainerBlockEntity extends BaseContainerBloc
@@ -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)) {

View File

@ -5,10 +5,10 @@ Subject: [PATCH] ItemEntity - Check if items are air before calling setItem
diff --git a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
index f0ccdfbd7d7be8c6e302609accf8fe9cac8885c4..2dad46159fb1653aff0ecdd907535ac0c59deeed 100644
index d47b3ac633e7936d30abfda6fc46c2c7412d76fe..1b4d21b5960ef09bada7c707fc5ba4e5cc39630c 100644
--- a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
+++ b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
@@ -407,11 +407,15 @@ public class ItemEntity extends Entity {
@@ -416,11 +416,15 @@ public class ItemEntity extends Entity implements TraceableEntity {
CompoundTag nbttagcompound1 = nbt.getCompound("Item");

View File

@ -5,10 +5,10 @@ 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 c33a6d3d5700a7ec1dae2434d00cf0f480a5f0e5..1ccf1d22ac77b669fffd2a1bd7b1331cf0fa281a 100644
index 6dac24354192bea79a4b9eb721543110826790b2..b87999106b5068a243c064fa3c30968411996e2b 100644
--- a/src/main/java/net/minecraft/nbt/NbtUtils.java
+++ b/src/main/java/net/minecraft/nbt/NbtUtils.java
@@ -234,7 +234,7 @@ public final class NbtUtils {
@@ -231,7 +231,7 @@ public final class NbtUtils {
if (!nbt.contains("Name", 8)) {
return Blocks.AIR.defaultBlockState();
} else {
@ -18,7 +18,7 @@ index c33a6d3d5700a7ec1dae2434d00cf0f480a5f0e5..1ccf1d22ac77b669fffd2a1bd7b1331c
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 9788e477ff1446ad2ea3669922cc7dfc09900ce8..809c9b9dfb29c8ce177ade8be980e1d8e94de31e 100644
index 5d6d26cfe8f0ab68a3145214b3fc126ca7a71a66..7e0559cdcabeb33ff383be1a23f4ed04fa091867 100644
--- a/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java
+++ b/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java
@@ -541,7 +541,7 @@ public abstract class AbstractArrow extends Projectile {

View File

@ -5,10 +5,10 @@ Subject: [PATCH] Even more ResourceLocation validation and log spam fixes
diff --git a/src/main/java/net/minecraft/world/entity/AreaEffectCloud.java b/src/main/java/net/minecraft/world/entity/AreaEffectCloud.java
index 11a6f5b9e726453979d4c718c32a44024e1b8a08..c4810371c00eb92dc8574841c74a89203d586c78 100644
index fa724cd34a7c469ca12068e64295cd00ad215a3c..168b60fda38a7172f4473017ccc42447b36faab2 100644
--- a/src/main/java/net/minecraft/world/entity/AreaEffectCloud.java
+++ b/src/main/java/net/minecraft/world/entity/AreaEffectCloud.java
@@ -422,7 +422,7 @@ public class AreaEffectCloud extends Entity {
@@ -425,7 +425,7 @@ public class AreaEffectCloud extends Entity implements TraceableEntity {
try {
this.setParticle(ParticleArgument.readParticle(new StringReader(nbt.getString("Particle")), (HolderLookup) BuiltInRegistries.PARTICLE_TYPE.asLookup()));
} catch (CommandSyntaxException commandsyntaxexception) {

View File

@ -27,10 +27,10 @@ index c0633f9553fb5aa52e8ffc863159521d09cb3bd5..7449a024265c42f28a6c9a1ed8d8f4b9
}
}
diff --git a/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java b/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java
index 428523feaa4f30260e32ba03937e88200246c693..21e6053a62409784c175ea6cf1ada6b5557097a8 100644
index 30aec9dff249ae629b22318e52902361a9fa4099..f87a58097889720cbc6510345696e03722b4f0a8 100644
--- a/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java
+++ b/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java
@@ -428,7 +428,7 @@ public class ItemFrame extends HangingEntity {
@@ -432,7 +432,7 @@ public class ItemFrame extends HangingEntity {
ItemStack itemstack = ItemStack.of(nbttagcompound1);
if (itemstack.isEmpty()) {

View File

@ -5,10 +5,10 @@ Subject: [PATCH] Even more resource location validation
diff --git a/src/main/java/net/minecraft/world/entity/AreaEffectCloud.java b/src/main/java/net/minecraft/world/entity/AreaEffectCloud.java
index c4810371c00eb92dc8574841c74a89203d586c78..929f05c8692223959282f68bf68c4467e4167a80 100644
index 168b60fda38a7172f4473017ccc42447b36faab2..9f01b0f18bf656a7ab62f07cc98aaded96432665 100644
--- a/src/main/java/net/minecraft/world/entity/AreaEffectCloud.java
+++ b/src/main/java/net/minecraft/world/entity/AreaEffectCloud.java
@@ -145,7 +145,7 @@ public class AreaEffectCloud extends Entity {
@@ -145,7 +145,7 @@ public class AreaEffectCloud extends Entity implements TraceableEntity {
}
public void setPotionType(String string) {
@ -18,10 +18,10 @@ index c4810371c00eb92dc8574841c74a89203d586c78..929f05c8692223959282f68bf68c4467
// CraftBukkit end
diff --git a/src/main/java/net/minecraft/world/entity/EntityType.java b/src/main/java/net/minecraft/world/entity/EntityType.java
index 4589f7db68f7a72065c85c0a50216c6d02658f1e..5c23608e20e243eb844c73f713c39bf3e5ab05dd 100644
index ceacc0d383e2ee674783d3c0a7df0a951595faca..32b2558fca4642373f7794449e89bfe275c5cf0d 100644
--- a/src/main/java/net/minecraft/world/entity/EntityType.java
+++ b/src/main/java/net/minecraft/world/entity/EntityType.java
@@ -580,7 +580,7 @@ public class EntityType<T extends Entity> implements FeatureElement, EntityTypeT
@@ -588,7 +588,7 @@ public class EntityType<T extends Entity> implements FeatureElement, EntityTypeT
}), (entity) -> {
entity.load(nbt);
}, () -> {
@ -30,7 +30,7 @@ index 4589f7db68f7a72065c85c0a50216c6d02658f1e..5c23608e20e243eb844c73f713c39bf3
});
}
@@ -599,7 +599,7 @@ public class EntityType<T extends Entity> implements FeatureElement, EntityTypeT
@@ -607,7 +607,7 @@ public class EntityType<T extends Entity> implements FeatureElement, EntityTypeT
}
public static Optional<EntityType<?>> by(CompoundTag nbt) {
@ -40,10 +40,10 @@ index 4589f7db68f7a72065c85c0a50216c6d02658f1e..5c23608e20e243eb844c73f713c39bf3
@Nullable
diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java
index 49b983064ea810382b6112f5dc7f93ba4e5710bd..4dd32f38ebf06d868a37c8e4ae667ac14a774b8d 100644
index 02cb6b8c1d59855ff4a8aad3024fe12007eca0ee..9a64944c6769ced4d82b8edbbc045b870a256cb9 100644
--- a/src/main/java/net/minecraft/world/entity/Mob.java
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
@@ -585,7 +585,7 @@ public abstract class Mob extends LivingEntity {
@@ -615,7 +615,7 @@ public abstract class Mob extends LivingEntity implements Targeting {
this.setLeftHanded(nbt.getBoolean("LeftHanded"));
if (nbt.contains("DeathLootTable", 8)) {

View File

@ -76,10 +76,10 @@ index bf42969859545a8a520923ef1836ffa4a5cc24a0..31d0624fcaf1998383eebde7fbd3a103
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 e072a5475a64d110f25ebcc871aa7703c2fc1e70..21db4153a9eb5e52ff357b4146ae4302029d5cd5 100644
index d51650d3e37eb76a0cf991e95d28a552aa567af9..cd87e192ff09e77538521bbde38416c52daa22b8 100644
--- a/src/main/java/org/bukkit/craftbukkit/Main.java
+++ b/src/main/java/org/bukkit/craftbukkit/Main.java
@@ -278,7 +278,7 @@ public class Main {
@@ -285,7 +285,7 @@ public class Main {
if (buildDate.before(deadline.getTime())) {
// Paper start - This is some stupid bullshit
System.err.println("*** Warning, you've not updated in a while! ***");

View File

@ -6,10 +6,10 @@ Subject: [PATCH] Validate String UUIDs during the CompoundTag -> GameProfile
diff --git a/src/main/java/net/minecraft/nbt/NbtUtils.java b/src/main/java/net/minecraft/nbt/NbtUtils.java
index 1ccf1d22ac77b669fffd2a1bd7b1331cf0fa281a..6b31a32f9dac31b587693ed8001bf190786ceae8 100644
index b87999106b5068a243c064fa3c30968411996e2b..596baf1bc372875b8b82904d9d5bd53f4bedc0fb 100644
--- a/src/main/java/net/minecraft/nbt/NbtUtils.java
+++ b/src/main/java/net/minecraft/nbt/NbtUtils.java
@@ -81,7 +81,12 @@ public final class NbtUtils {
@@ -78,7 +78,12 @@ public final class NbtUtils {
}
// Paper start - support string UUID's
if (nbt.contains("Id", 8)) {

View File

@ -6,10 +6,10 @@ Subject: [PATCH] Fixes creative-killing potion effects and certain potion
diff --git a/src/main/java/net/minecraft/world/effect/MobEffect.java b/src/main/java/net/minecraft/world/effect/MobEffect.java
index e708b2c987fac150c22b3367cec2e3e2bcb9914c..06872ee2d0eb9ea847568d328a95f60db7373be8 100644
index 2cc714585fc3790b70a7ad1ab8034543462e2b3b..2d3706d8d0dbed3b3588066eaa6b9ce1b266294f 100644
--- a/src/main/java/net/minecraft/world/effect/MobEffect.java
+++ b/src/main/java/net/minecraft/world/effect/MobEffect.java
@@ -59,6 +59,7 @@ public class MobEffect {
@@ -58,6 +58,7 @@ public class MobEffect {
}
public void applyEffectTick(LivingEntity entity, int amplifier) {
@ -17,7 +17,7 @@ index e708b2c987fac150c22b3367cec2e3e2bcb9914c..06872ee2d0eb9ea847568d328a95f60d
if (this == MobEffects.REGENERATION) {
if (entity.getHealth() < entity.getMaxHealth()) {
entity.heal(1.0F, RegainReason.MAGIC_REGEN); // CraftBukkit
@@ -87,17 +88,31 @@ public class MobEffect {
@@ -86,17 +87,31 @@ public class MobEffect {
// CraftBukkit end
}
} else if ((this != MobEffects.HEAL || entity.isInvertedHealAndHarm()) && (this != MobEffects.HARM || !entity.isInvertedHealAndHarm())) {
@ -25,7 +25,7 @@ index e708b2c987fac150c22b3367cec2e3e2bcb9914c..06872ee2d0eb9ea847568d328a95f60d
+ // Scissors start
+ amplifier = Math.min(Math.abs(amplifier), 124);
+ if (!god && (this == MobEffects.HARM && !entity.isInvertedHealAndHarm() || this == MobEffects.HEAL && entity.isInvertedHealAndHarm())) {
entity.hurt(DamageSource.MAGIC, (float) (6 << amplifier));
entity.hurt(entity.damageSources().magic(), (float) (6 << amplifier));
}
+ // Scissors end
} else {

View File

@ -5,10 +5,10 @@ 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 9e075de3542bda8ae086c9ca68bcd00b16d565d0..2012c147f60f39ae7dbae74641fd00b3b282a991 100644
index e9d3e34520b706627205e0d5b17b25e09f198e7e..36b1fcc106909aa7305d63bb4710b4330cb9bc6a 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
@@ -622,7 +622,7 @@ public abstract class LivingEntity extends Entity {
@@ -612,7 +612,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
protected void tickDeath() {
++this.deathTime;

View File

@ -6,10 +6,10 @@ Subject: [PATCH] Validate coordinates before attempting to get block entities
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index 9b0b42add71172bd154226e51d62cebd8de3542e..9e093d3001a57b577a7c93d8b721235617656e15 100644
index 2d8488b9aa088b6d5f0c7e557b8ad0b29bc4cd88..68fe0d4142a468ea4cbbb79573b02ab8cd0ae823 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -1922,6 +1922,18 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
@@ -1912,6 +1912,18 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
}
// Spigot end
@ -28,7 +28,7 @@ index 9b0b42add71172bd154226e51d62cebd8de3542e..9e093d3001a57b577a7c93d8b7212356
@Override
public void handleUseItemOn(ServerboundUseItemOnPacket packet) {
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel());
@@ -3314,17 +3326,24 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
@@ -3328,17 +3340,24 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
if (!itemstack.isEmpty() && nbttagcompound != null && nbttagcompound.contains("x") && nbttagcompound.contains("y") && nbttagcompound.contains("z") && this.player.getBukkitEntity().hasPermission("minecraft.nbt.copy")) { // Spigot
BlockPos blockposition = BlockEntity.getPosFromTag(nbttagcompound);

View File

@ -5,7 +5,7 @@ Subject: [PATCH] Reset large tags
diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java
index 6860096cb8c0deecc9c1d87543d1128fb95fd2d4..d7b02676c646db61a5351b72c1c929e8dd80795c 100644
index 75ee1abaadabbe8add0972c48780f5e7b85df069..437f0e2fe381cf0b82c2f7e6fdd13eb91ebab1db 100644
--- a/src/main/java/net/minecraft/world/item/ItemStack.java
+++ b/src/main/java/net/minecraft/world/item/ItemStack.java
@@ -20,6 +20,7 @@ import java.util.function.Predicate;
@ -16,7 +16,7 @@ index 6860096cb8c0deecc9c1d87543d1128fb95fd2d4..d7b02676c646db61a5351b72c1c929e8
import net.minecraft.ChatFormatting;
import net.minecraft.Util;
import net.minecraft.advancements.CriteriaTriggers;
@@ -255,6 +256,12 @@ public final class ItemStack {
@@ -256,6 +257,12 @@ public final class ItemStack {
// CraftBukkit - break into own method
private void load(CompoundTag nbttagcompound) {
@ -29,7 +29,7 @@ index 6860096cb8c0deecc9c1d87543d1128fb95fd2d4..d7b02676c646db61a5351b72c1c929e8
this.item = (Item) BuiltInRegistries.ITEM.get(new ResourceLocation(nbttagcompound.getString("id")));
this.count = nbttagcompound.getByte("Count");
if (nbttagcompound.contains("tag", 10)) {
@@ -516,7 +523,11 @@ public final class ItemStack {
@@ -530,7 +537,11 @@ public final class ItemStack {
nbt.putString("id", minecraftkey == null ? "minecraft:air" : minecraftkey.toString());
nbt.putByte("Count", (byte) this.count);
if (this.tag != null) {
@ -42,7 +42,7 @@ index 6860096cb8c0deecc9c1d87543d1128fb95fd2d4..d7b02676c646db61a5351b72c1c929e8
}
return nbt;
@@ -847,6 +858,9 @@ public final class ItemStack {
@@ -860,6 +871,9 @@ public final class ItemStack {
// Paper end
public void setTag(@Nullable CompoundTag nbt) {

View File

@ -59,7 +59,7 @@ index 4092c7a8c2b0d9d26e6f4d97386735236300d132..9e0ab51dd7a4f9fed8f9edde962d42d4
}
}
diff --git a/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java
index cac2768fe520b591990c7bc943ae7e95f49efb31..f734cba350ed85dbbf52ff527c9bb14b9eb04c86 100644
index 2a786c9fd29dc2139cf487fa645cd43345d60167..dbdc66620ae4284cfe96f633b1f4db46866b597b 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;
@ -70,7 +70,7 @@ index cac2768fe520b591990c7bc943ae7e95f49efb31..f734cba350ed85dbbf52ff527c9bb14b
import net.minecraft.SharedConstants;
import net.minecraft.Util;
import net.minecraft.core.BlockPos;
@@ -211,6 +212,16 @@ public abstract class AbstractFurnaceBlockEntity extends BaseContainerBlockEntit
@@ -212,6 +213,16 @@ public abstract class AbstractFurnaceBlockEntity extends BaseContainerBlockEntit
public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
public List<ItemStack> getContents() {
@ -116,7 +116,7 @@ index 416aa989ebb18a8741cc9d605a1180ab830f6643..893cf89dd2b022e2b785318e7e86eb5d
}
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 0bab2693b91d5bab222c7db8bc6965ccde954003..4a02d8f4d99d2d0e6cac4e40cd0e6350d03c0cd0 100644
index c57efcb9a79337ec791e4e8f6671612f0a82b441..2963b72061a9ede734842d6fb46a67a1c41d4740 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;
@ -127,7 +127,7 @@ index 0bab2693b91d5bab222c7db8bc6965ccde954003..4a02d8f4d99d2d0e6cac4e40cd0e6350
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.NonNullList;
@@ -72,6 +73,16 @@ public class BrewingStandBlockEntity extends BaseContainerBlockEntity implements
@@ -73,6 +74,16 @@ public class BrewingStandBlockEntity extends BaseContainerBlockEntity implements
}
public List<ItemStack> getContents() {
@ -201,7 +201,7 @@ index 881379681c39230a00b3a1f11cd87498984396c7..1be5d600573f7632e6630224530dd765
}
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 d76603c4172aa10889949c6c2acff05fee02a13d..b82fde14db232e63748dddd74d85f5a41359ae41 100644
index 789e5458f4a137694563a22612455506807de51b..84c721da46b7786857677b56f439c2b9448ba4b8 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;
@ -212,7 +212,7 @@ index d76603c4172aa10889949c6c2acff05fee02a13d..b82fde14db232e63748dddd74d85f5a4
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.NonNullList;
@@ -54,6 +55,16 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
@@ -56,6 +57,16 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
private int maxStack = MAX_STACK;
public List<ItemStack> getContents() {

View File

@ -6,7 +6,7 @@ Subject: [PATCH] Limit amount of vehicle collision checks to 3 and discard
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 eec7d7a5b558830111831792c42665724613af23..79f296388a7f86944f33b9a783ab81b3a9e4d4dc 100644
index 9a80cf593bbdd7681bc9395daf4545a98e07636f..9c50f8f917f1d0f795f88493cf0177266942f680 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;
@ -56,7 +56,7 @@ index eec7d7a5b558830111831792c42665724613af23..79f296388a7f86944f33b9a783ab81b3
} 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 85e1892866cd2ee0cec1552b8541c1f800bdf68c..2950f60e068cbeb945cfe38972eaf65b79e3a4f1 100644
index 5095e47b4910167235afdd8f1a7e9c45124ecadb..119888c529aa681cb97d01e80ee0f74644dc0577 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;
@ -75,7 +75,7 @@ index 85e1892866cd2ee0cec1552b8541c1f800bdf68c..2950f60e068cbeb945cfe38972eaf65b
public Boat(EntityType<? extends Boat> type, Level world) {
super(type, world);
@@ -417,10 +419,12 @@ public class Boat extends Entity implements VariantHolder<Boat.Type> {
@@ -420,10 +422,12 @@ 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));
@ -90,7 +90,7 @@ index 85e1892866cd2ee0cec1552b8541c1f800bdf68c..2950f60e068cbeb945cfe38972eaf65b
Entity entity = (Entity) list.get(j);
if (!entity.hasPassenger((Entity) this)) {
@@ -431,6 +435,16 @@ public class Boat extends Entity implements VariantHolder<Boat.Type> {
@@ -434,6 +438,16 @@ public class Boat extends Entity implements VariantHolder<Boat.Type> {
}
}
}

View File

@ -5,10 +5,10 @@ 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 2012c147f60f39ae7dbae74641fd00b3b282a991..d828b838216083192d9a344ca978f6a7360e0363 100644
index 36b1fcc106909aa7305d63bb4710b4330cb9bc6a..795ebbea0c0100cd05661caad74ed2ae1a32e045 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
@@ -850,7 +850,9 @@ public abstract class LivingEntity extends Entity {
@@ -844,7 +844,9 @@ public abstract class LivingEntity extends Entity implements Attackable {
boolean flag = scoreboardteam != null && this.level.getScoreboard().addPlayerToTeam(this.getStringUUID(), scoreboardteam);
if (!flag) {

View File

@ -5,7 +5,7 @@ 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 3ca733528acb40354b308019a84436ea67e05751..76932c683153c7dcbf46de78cccc14772babc5fc 100644
index 37fc353c3e59dd5af2fd6c58ac084fb0e6e155d7..3c0ee4e1f42f6056ca86a6f9f129d467e29a2fbc 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;
@ -16,7 +16,7 @@ index 3ca733528acb40354b308019a84436ea67e05751..76932c683153c7dcbf46de78cccc1477
import net.minecraft.Util;
import net.minecraft.network.chat.contents.BlockDataSource;
import net.minecraft.network.chat.contents.DataSource;
@@ -506,6 +507,26 @@ public interface Component extends Message, FormattedText, Iterable<Component> {
@@ -522,6 +523,26 @@ public interface Component extends Message, FormattedText, Iterable<Component> {
return GsonHelper.toStableString(Serializer.toJsonTree(text));
}
@ -110,10 +110,10 @@ index 97a2657bc98d41c3c1e376b266d2c85f685acc88..7b6476455e095eed15c92797ce3a3e11
}
}).reduce((accumulator, current) -> {
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 7555b04dcf274bb624b89f2eb9ff80da0056de4e..f052ebb7758017dabc7e336898065231a6e4e4fb 100644
index 9a1e8589e6b371869b2199650172d61ae186c907..c0aa5f450b5398c267569066d9aedfbb14f6559a 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -2340,12 +2340,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
@@ -2352,12 +2352,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
this.setRot(this.getYRot(), this.getXRot());
if (nbt.contains("CustomName", 8)) {
String s = nbt.getString("CustomName");
@ -128,7 +128,7 @@ index 7555b04dcf274bb624b89f2eb9ff80da0056de4e..f052ebb7758017dabc7e336898065231
this.setCustomNameVisible(nbt.getBoolean("CustomNameVisible"));
diff --git a/src/main/java/net/minecraft/world/level/block/entity/BeaconBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BeaconBlockEntity.java
index 928625b5ab054ffa412be8a438f58291cc7a3cc0..54e74f39c960daa1f7ebd1d435281b5cc93e59c0 100644
index ef740d1ad6352ca4af299001a081b720bc472d2e..f2325c0c475bb465f5275f78c71949648a860d0c 100644
--- a/src/main/java/net/minecraft/world/level/block/entity/BeaconBlockEntity.java
+++ b/src/main/java/net/minecraft/world/level/block/entity/BeaconBlockEntity.java
@@ -410,7 +410,7 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider, Name

View File

@ -5,7 +5,7 @@ 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 5fce1177e7198d791d4ab1c64b394c5b1c145782..25d483a4792cf159ff691521cd32382d0f7fe931 100644
index ebee957fb048da6ffcd2a5ba2ed989ed1a6634e9..8da0f951b271e332f441852853f4a21d7ab6cf48 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;
@ -29,24 +29,24 @@ index 5fce1177e7198d791d4ab1c64b394c5b1c145782..25d483a4792cf159ff691521cd32382d
public class PacketEncoder extends MessageToByteEncoder<Packet<?>> {
@@ -41,30 +50,101 @@ public class PacketEncoder extends MessageToByteEncoder<Packet<?>> {
packet.write(friendlyByteBuf);
int j = friendlyByteBuf.writerIndex() - i;
if (j > 8388608) {
- throw new IllegalArgumentException("Packet too big (is " + j + ", should be less than 8388608): " + packet);
int k = friendlyByteBuf.writerIndex() - j;
if (k > 8388608) {
- throw new IllegalArgumentException("Packet too big (is " + k + ", should be less than 8388608): " + packet);
+ // Scissors start
+ noKicking(friendlyByteBuf, packet, integer, channelHandlerContext);
+ noKicking(friendlyByteBuf, packet, i, channelHandlerContext);
+ // Scissors end
} else {
int k = channelHandlerContext.channel().attr(Connection.ATTRIBUTE_PROTOCOL).get().getId();
JvmProfiler.INSTANCE.onPacketSent(k, integer, channelHandlerContext.channel().remoteAddress(), j);
int l = channelHandlerContext.channel().attr(Connection.ATTRIBUTE_PROTOCOL).get().getId();
JvmProfiler.INSTANCE.onPacketSent(l, i, channelHandlerContext.channel().remoteAddress(), k);
}
} catch (Throwable var10) {
- LOGGER.error("Packet encoding of packet ID {} threw (skippable? {})", integer, packet.isSkippable(), var10); // Paper - Give proper error message
- LOGGER.error("Packet encoding of packet ID {} threw (skippable? {})", i, packet.isSkippable(), var10); // Paper - Give proper error message
- if (packet.isSkippable()) {
- throw new SkipPacketException(var10);
- } else {
- throw var10;
- }
+ noKicking(friendlyByteBuf, packet, integer, channelHandlerContext);
+ noKicking(friendlyByteBuf, packet, i, channelHandlerContext);
}
// Paper start

View File

@ -5,7 +5,7 @@ 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 da47e84dffd3518b84eeeb80ab4f17073fed9a9c..028d41c22ec5d67434dc42926cd875fe576768ea 100644
index 68fe0d4142a468ea4cbbb79573b02ab8cd0ae823..b4e49a37b0d815a9a3e321ec5c8f7196a5e3a80d 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 @@
@ -15,7 +15,7 @@ index da47e84dffd3518b84eeeb80ab4f17073fed9a9c..028d41c22ec5d67434dc42926cd875fe
import com.google.common.collect.Lists;
import com.google.common.primitives.Floats;
import com.mojang.brigadier.ParseResults;
@@ -2068,6 +2069,14 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
@@ -2058,6 +2059,14 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
Entity entity = packet.getEntity(worldserver);
if (entity != null) {

View File

@ -5,10 +5,10 @@ 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 c8760e58589cd574e9debd29f7e728b482ec1daf..f780dc437741db42da07241c94f1458aa2654cb1 100644
index b4e49a37b0d815a9a3e321ec5c8f7196a5e3a80d..98ad7153e2d8a202938815beae9883f8dc78b471 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -29,6 +29,8 @@ import java.util.function.UnaryOperator;
@@ -30,6 +30,8 @@ import java.util.function.UnaryOperator;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.annotation.Nullable;
@ -17,7 +17,7 @@ index c8760e58589cd574e9debd29f7e728b482ec1daf..f780dc437741db42da07241c94f1458a
import net.minecraft.ChatFormatting;
import net.minecraft.CrashReport;
import net.minecraft.CrashReportCategory;
@@ -2956,6 +2958,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
@@ -2970,6 +2972,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
public void handleContainerClick(ServerboundContainerClickPacket packet) {
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel());
if (this.player.isImmobile()) return; // CraftBukkit
@ -25,7 +25,7 @@ index c8760e58589cd574e9debd29f7e728b482ec1daf..f780dc437741db42da07241c94f1458a
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
@@ -2977,6 +2980,18 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
@@ -2991,6 +2994,18 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
return;
}

View File

@ -5,10 +5,10 @@ Subject: [PATCH] Do not attempt to cast items to recipes
diff --git a/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java
index f734cba350ed85dbbf52ff527c9bb14b9eb04c86..68912cc2bd670944465e6819d82c4aad6b7b324a 100644
index dbdc66620ae4284cfe96f633b1f4db46866b597b..b95c3a74be46a539ccb90774023fa506d0a7e962 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
@@ -642,6 +642,13 @@ public abstract class AbstractFurnaceBlockEntity extends BaseContainerBlockEntit
@@ -643,6 +643,13 @@ public abstract class AbstractFurnaceBlockEntity extends BaseContainerBlockEntit
Entry<ResourceLocation> entry = (Entry) objectiterator.next();
worldserver.getRecipeManager().byKey((ResourceLocation) entry.getKey()).ifPresent((irecipe) -> {

View File

@ -1,483 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Allink <arclicious@vivaldi.net>
Date: Sun, 10 Jul 2022 10:15:20 +0100
Subject: [PATCH] Add Scissors configuration file & command
diff --git a/src/main/java/co/aikar/timings/TimingsExport.java b/src/main/java/co/aikar/timings/TimingsExport.java
index 06bff37e4c1fddd3be6343049a66787c63fb420c..1c1cb20190e8edb7f55a60fc662c28e204690223 100644
--- a/src/main/java/co/aikar/timings/TimingsExport.java
+++ b/src/main/java/co/aikar/timings/TimingsExport.java
@@ -25,6 +25,7 @@ package co.aikar.timings;
import com.google.common.collect.Sets;
import io.papermc.paper.adventure.PaperAdventure;
+import me.totalfreedom.scissors.ScissorsConfig;
import net.kyori.adventure.text.event.ClickEvent;
import net.kyori.adventure.text.format.NamedTextColor;
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
@@ -241,7 +242,8 @@ public class TimingsExport extends Thread {
parent.put("config", createObject(
pair("spigot", mapAsJSON(Bukkit.spigot().getSpigotConfig(), null)),
pair("bukkit", mapAsJSON(Bukkit.spigot().getBukkitConfig(), null)),
- pair("paper", mapAsJSON(Bukkit.spigot().getPaperConfig(), null))
+ pair("paper", mapAsJSON(Bukkit.spigot().getPaperConfig(), null)),
+ pair("scissors", mapAsJSON(ScissorsConfig.config, null)) // Scissors
));
new TimingsExport(listeners, parent, history).start();
diff --git a/src/main/java/me/totalfreedom/scissors/ScissorsCommand.java b/src/main/java/me/totalfreedom/scissors/ScissorsCommand.java
new file mode 100644
index 0000000000000000000000000000000000000000..797677d892d83cf54d9a60af1e277b67ed3d6e95
--- /dev/null
+++ b/src/main/java/me/totalfreedom/scissors/ScissorsCommand.java
@@ -0,0 +1,150 @@
+package me.totalfreedom.scissors;
+
+import com.google.common.base.Functions;
+import com.google.common.base.Joiner;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+import net.minecraft.resources.ResourceLocation;
+import net.minecraft.server.MinecraftServer;
+import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
+import org.bukkit.Location;
+import org.bukkit.command.Command;
+import org.bukkit.command.CommandSender;
+
+import java.io.File;
+import java.util.*;
+import java.util.stream.Collectors;
+
+public class ScissorsCommand extends Command
+{
+
+ private static final String BASE_PERM = "bukkit.command.scissors.";
+ private static final ImmutableSet<String> SUBCOMMANDS = ImmutableSet.<String>builder().add("reload", "version").build();
+
+ public ScissorsCommand(String name)
+ {
+ super(name);
+ this.description = "Scissors related commands";
+ this.usageMessage = "/scissors [" + Joiner.on(" | ").join(SUBCOMMANDS) + "]";
+ this.setPermission("bukkit.command.scissors;" + Joiner.on(';').join(SUBCOMMANDS.stream().map(s -> BASE_PERM + s).collect(Collectors.toSet())));
+ }
+
+ private static boolean testPermission(CommandSender commandSender, String permission)
+ {
+ if (commandSender.hasPermission(BASE_PERM + permission) || commandSender.hasPermission("bukkit.command.scissors"))
+ return true;
+ commandSender.sendMessage(Bukkit.getPermissionMessage()); // Sorry, kashike
+ return false;
+ }
+
+ // Code from Mojang - copyright them
+ public static List<String> getListMatchingLast(CommandSender sender, String[] args, String... matches)
+ {
+ return getListMatchingLast(sender, args, Arrays.asList(matches));
+ }
+
+ public static boolean matches(String s, String s1)
+ {
+ return s1.regionMatches(true, 0, s, 0, s.length());
+ }
+
+ public static List<String> getListMatchingLast(CommandSender sender, String[] strings, Collection<?> collection)
+ {
+ String last = strings[strings.length - 1];
+ ArrayList<String> results = Lists.newArrayList();
+
+ if (!collection.isEmpty())
+ {
+ Iterator iterator = Iterables.transform(collection, Functions.toStringFunction()).iterator();
+
+ while (iterator.hasNext())
+ {
+ String s1 = (String) iterator.next();
+
+ if (matches(last, s1) && (sender.hasPermission(BASE_PERM + s1) || sender.hasPermission("bukkit.command.scissors")))
+ {
+ results.add(s1);
+ }
+ }
+
+ if (results.isEmpty())
+ {
+ iterator = collection.iterator();
+
+ while (iterator.hasNext())
+ {
+ Object object = iterator.next();
+
+ if (object instanceof ResourceLocation && matches(last, ((ResourceLocation) object).getPath()))
+ {
+ results.add(String.valueOf(object));
+ }
+ }
+ }
+ }
+
+ return results;
+ }
+
+ @Override
+ public List<String> tabComplete(CommandSender sender, String alias, String[] args, Location location) throws IllegalArgumentException
+ {
+ if (args.length <= 1)
+ return getListMatchingLast(sender, args, SUBCOMMANDS);
+
+ return Collections.emptyList();
+ }
+ // end copy stuff
+
+ @Override
+ public boolean execute(CommandSender sender, String commandLabel, String[] args)
+ {
+ if (!testPermission(sender)) return true;
+
+ if (args.length == 0)
+ {
+ sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage);
+ return false;
+ }
+ if (SUBCOMMANDS.contains(args[0].toLowerCase(Locale.ENGLISH)))
+ {
+ if (!testPermission(sender, args[0].toLowerCase(Locale.ENGLISH))) return true;
+ }
+ switch (args[0].toLowerCase(Locale.ENGLISH))
+ {
+ case "reload":
+ doReload(sender);
+ break;
+ case "ver":
+ if (!testPermission(sender, "version"))
+ break; // "ver" needs a special check because it's an alias. All other commands are checked up before the switch statement (because they are present in the SUBCOMMANDS set)
+ case "version":
+ Command ver = MinecraftServer.getServer().server.getCommandMap().getCommand("version");
+ if (ver != null)
+ {
+ ver.execute(sender, commandLabel, new String[0]);
+ break;
+ }
+ // else - fall through to default
+ default:
+ sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage);
+ return false;
+ }
+
+ return true;
+ }
+
+ private void doReload(CommandSender sender)
+ {
+ Command.broadcastCommandMessage(sender, ChatColor.RED + "Please note that this command is not supported and may cause issues.");
+ Command.broadcastCommandMessage(sender, ChatColor.RED + "If you encounter any issues please use the /stop command to restart your server.");
+
+ MinecraftServer console = MinecraftServer.getServer();
+ ScissorsConfig.init((File) console.options.valueOf("scissors-settings"));
+ console.server.reloadCount++;
+
+ Command.broadcastCommandMessage(sender, ChatColor.GREEN + "Scissors config reload complete.");
+ }
+}
diff --git a/src/main/java/me/totalfreedom/scissors/ScissorsConfig.java b/src/main/java/me/totalfreedom/scissors/ScissorsConfig.java
new file mode 100644
index 0000000000000000000000000000000000000000..b14ecf820880dca72f55cadfba337f725eaeb464
--- /dev/null
+++ b/src/main/java/me/totalfreedom/scissors/ScissorsConfig.java
@@ -0,0 +1,199 @@
+package me.totalfreedom.scissors;
+
+
+import com.google.common.base.Throwables;
+import net.minecraft.server.MinecraftServer;
+import net.minecraft.server.dedicated.DedicatedServer;
+import org.bukkit.Bukkit;
+import org.bukkit.command.Command;
+import org.bukkit.configuration.InvalidConfigurationException;
+import org.bukkit.configuration.file.YamlConfiguration;
+
+import java.io.File;
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.logging.Level;
+import java.util.regex.Pattern;
+
+// TODO - Migrate to new format
+public class ScissorsConfig
+{
+
+ private static final String HEADER = """
+ This is the main configuration file for Scissors.
+ As you can see, there's tons to configure. Some options may impact gameplay, so use
+ with caution, and make sure you know what each option does before configuring.
+
+ If you need help with the configuration or have any questions related to Scissors,
+ join us in our Discord.
+
+ Discord: https://discord.com/invite/mtVQcHn58h
+ Website: https://scissors.gg/\s
+ Docs: https://scissors.gg/javadoc/1.19.3/\s
+ """;
+ private static final Pattern SPACE = Pattern.compile(" ");
+ private static final Pattern NOT_NUMERIC = Pattern.compile("[^-\\d.]");
+ /*========================================================================*/
+ public static YamlConfiguration config;
+ static int version;
+ /*========================================================================*/
+ static Map<String, Command> commands;
+ private static File CONFIG_FILE;
+
+ public static void init(File configFile)
+ {
+ final File configFolder = (File) DedicatedServer.getServer().options.valueOf("scissors-settings" + "-directory");
+ final Path configFolderPath = configFolder.toPath();
+ final Path oldConfigFilePath = configFile.toPath();
+ final Path newConfigFilePath = configFolderPath.resolve(configFile.toPath());
+
+ if (configFile.exists())
+ {
+ try
+ {
+ Files.move(oldConfigFilePath, newConfigFilePath);
+ }
+ catch (IOException e)
+ {
+ throw new RuntimeException("Error migrating configuration file to new directory!", e);
+ }
+ }
+
+ CONFIG_FILE = newConfigFilePath.toFile();
+ config = new YamlConfiguration();
+ try
+ {
+ config.load(CONFIG_FILE);
+ }
+ catch (IOException ex)
+ {
+ }
+ catch (InvalidConfigurationException ex)
+ {
+ Bukkit.getLogger().log(Level.SEVERE, "Could not load scissors.yml, please correct your syntax errors", ex);
+ throw Throwables.propagate(ex);
+ }
+
+ commands = new HashMap<>();
+ commands.put("scissors", new ScissorsCommand("scissors"));
+
+ config.options().header(HEADER);
+ config.options().copyDefaults(true);
+
+ version = getInt("config-version", 1);
+ set("config-version", 1);
+ readConfig(ScissorsConfig.class, null);
+ }
+
+ protected static void logError(String s)
+ {
+ Bukkit.getLogger().severe(s);
+ }
+
+ protected static void fatal(String s)
+ {
+ throw new RuntimeException("Fatal scissors.yml config error: " + s);
+ }
+
+ public static void registerCommands()
+ {
+ for (Map.Entry<String, Command> entry : commands.entrySet())
+ {
+ MinecraftServer.getServer().server.getCommandMap().register(entry.getKey(), "Scissors", entry.getValue());
+ }
+ }
+
+ static void readConfig(Class<?> clazz, Object instance)
+ {
+ for (Method method : clazz.getDeclaredMethods())
+ {
+ if (Modifier.isPrivate(method.getModifiers()))
+ {
+ if (method.getParameterTypes().length == 0 && method.getReturnType() == Void.TYPE)
+ {
+ try
+ {
+ method.setAccessible(true);
+ method.invoke(instance);
+ }
+ catch (InvocationTargetException ex)
+ {
+ throw Throwables.propagate(ex.getCause());
+ }
+ catch (Exception ex)
+ {
+ Bukkit.getLogger().log(Level.SEVERE, "Error invoking " + method, ex);
+ }
+ }
+ }
+ }
+ saveConfig();
+ }
+
+ static void saveConfig()
+ {
+ try
+ {
+ config.save(CONFIG_FILE);
+ }
+ catch (IOException ex)
+ {
+ Bukkit.getLogger().log(Level.SEVERE, "Could not save " + CONFIG_FILE, ex);
+ }
+ }
+
+ public static boolean runCommandsInBooks = false;
+
+ private static void runCommandsInBooks() {
+ runCommandsInBooks = getBoolean("runCommandsInBooks", false);
+ }
+
+ private static void set(String path, Object val)
+ {
+ config.set(path, val);
+ }
+
+ private static boolean getBoolean(String path, boolean def)
+ {
+ config.addDefault(path, def);
+ return config.getBoolean(path, config.getBoolean(path));
+ }
+
+ private static double getDouble(String path, double def)
+ {
+ config.addDefault(path, def);
+ return config.getDouble(path, config.getDouble(path));
+ }
+
+ private static float getFloat(String path, float def)
+ {
+ // TODO: Figure out why getFloat() always returns the default value.
+ return (float) getDouble(path, def);
+ }
+
+ private static int getInt(String path, int def)
+ {
+ config.addDefault(path, def);
+ return config.getInt(path, config.getInt(path));
+ }
+
+ private static <T> List getList(String path, T def)
+ {
+ config.addDefault(path, def);
+ return config.getList(path, config.getList(path));
+ }
+
+ private static String getString(String path, String def)
+ {
+ config.addDefault(path, def);
+ return config.getString(path, config.getString(path));
+ }
+}
+
diff --git a/src/main/java/net/minecraft/server/Main.java b/src/main/java/net/minecraft/server/Main.java
index 781b72fd88149642c9fceaecfbfe7546273fb749..7eb60d218a55cea6723955c8cad62af7acc10eb1 100644
--- a/src/main/java/net/minecraft/server/Main.java
+++ b/src/main/java/net/minecraft/server/Main.java
@@ -122,6 +122,7 @@ public class Main {
// Paper start - load config files for access below if needed
org.bukkit.configuration.file.YamlConfiguration bukkitConfiguration = io.papermc.paper.configuration.PaperConfigurations.loadLegacyConfigFile((File) optionset.valueOf("bukkit-settings"));
org.bukkit.configuration.file.YamlConfiguration spigotConfiguration = io.papermc.paper.configuration.PaperConfigurations.loadLegacyConfigFile((File) optionset.valueOf("spigot-settings"));
+ org.bukkit.configuration.file.YamlConfiguration scissorsConfiguration = io.papermc.paper.configuration.PaperConfigurations.loadLegacyConfigFile((File) optionset.valueOf("scissors-settings")); // Scissors - TODO Change this
// Paper end
Path path1 = Paths.get("eula.txt");
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
index a7e133f3495e9132a5fdae2c24f225e7b026295a..d4f0d596d30ef20d70c9f86d33288c78bdb5e6a0 100644
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
@@ -221,7 +221,15 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
com.destroystokyo.paper.VersionHistoryManager.INSTANCE.getClass(); // load version history now
io.papermc.paper.brigadier.PaperBrigadierProviderImpl.INSTANCE.getClass(); // init PaperBrigadierProvider
// Paper end
-
+ // Scissors start
+ try {
+ me.totalfreedom.scissors.ScissorsConfig.init((java.io.File) options.valueOf("scissors-settings"));
+ } catch (Exception e) {
+ DedicatedServer.LOGGER.error("Unable to load server configuration", e);
+ return false;
+ }
+ me.totalfreedom.scissors.ScissorsConfig.registerCommands();
+ // Scissors end
this.setPvpAllowed(dedicatedserverproperties.pvp);
this.setFlightAllowed(dedicatedserverproperties.allowFlight);
this.setMotd(dedicatedserverproperties.motd);
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 3fa8a282e4511e79def2470f1abc34f3bf6527a3..1b75855eece59aa6d3a0e3999c66d220daf99ff2 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -960,6 +960,8 @@ public final class CraftServer implements Server {
}
org.spigotmc.SpigotConfig.init((File) console.options.valueOf("spigot-settings")); // Spigot
+ me.totalfreedom.scissors.ScissorsConfig.init(((File) console.options.valueOf("scissors-settings"))); // Scissors
+
this.console.paperConfigurations.reloadConfigs(this.console);
for (ServerLevel world : this.console.getAllLevels()) {
// world.serverLevelData.setDifficulty(config.difficulty); // Paper - per level difficulty
@@ -991,6 +993,7 @@ public final class CraftServer implements Server {
this.reloadData();
org.spigotmc.SpigotConfig.registerCommands(); // Spigot
io.papermc.paper.command.PaperCommands.registerCommands(this.console); // Paper
+ me.totalfreedom.scissors.ScissorsConfig.registerCommands(); // Scissors
this.overrideAllCommandBlockCommands = this.commandsConfiguration.getStringList("command-block-overrides").contains("*");
this.ignoreVanillaPermissions = this.commandsConfiguration.getBoolean("ignore-vanilla-permissions");
@@ -2746,6 +2749,12 @@ public final class CraftServer implements Server {
return CraftServer.this.console.paperConfigurations.createLegacyObject(CraftServer.this.console);
}
+ @Override
+ public YamlConfiguration getScissorsConfig()
+ {
+ return me.totalfreedom.scissors.ScissorsConfig.config;
+ }
+
@Override
public void restart() {
org.spigotmc.RestartCommand.restart();
diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java
index a4bb8e91302e6dfdfa35a7d6a62c9e36a9043bcb..ebf71612ddc17074e7956cf6becbe81ba8c80e30 100644
--- a/src/main/java/org/bukkit/craftbukkit/Main.java
+++ b/src/main/java/org/bukkit/craftbukkit/Main.java
@@ -173,6 +173,22 @@ public class Main {
.defaultsTo("Unknown Server")
.describedAs("Name");
// Paper end
+
+ // Scissors start
+ acceptsAll(asList("scissors-dir", "scissors-settings-directory"), "Directory for Scissors settings")
+ .withRequiredArg()
+ .ofType(File.class)
+ .defaultsTo(new File(io.papermc.paper.configuration.PaperConfigurations.CONFIG_DIR))
+ .describedAs("Config directory");
+ // Scissors end
+
+ // Scissors start
+ acceptsAll(asList("scissors", "scissors-settings"), "File for scissors settings")
+ .withRequiredArg()
+ .ofType(File.class)
+ .defaultsTo(new File("scissors.yml"))
+ .describedAs("Yml file");
+ // Scissors end
}
};

View File

@ -5,10 +5,10 @@ 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 5086fc9f81e9ae894b6fa64819e77267812cae17..ca2b1affa23faf7153fad9e97afbb3b55f1e85d4 100644
index 98ad7153e2d8a202938815beae9883f8dc78b471..c15c5855dca11cd69f316c42783d32b800a93bd7 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -1360,7 +1360,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
@@ -1362,7 +1362,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
@Override
public void handleBlockEntityTagQuery(ServerboundBlockEntityTagQuery packet) {
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel());

View File

@ -1,96 +0,0 @@
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/me/totalfreedom/scissors/ScissorsConfig.java b/src/main/java/me/totalfreedom/scissors/ScissorsConfig.java
index e08f502fc7165f9f466217910210edb5059d39a8..1aa418ef5e400aabdf17dbe81da6cee6a1f63d96 100644
--- a/src/main/java/me/totalfreedom/scissors/ScissorsConfig.java
+++ b/src/main/java/me/totalfreedom/scissors/ScissorsConfig.java
@@ -151,7 +151,8 @@ public class ScissorsConfig
public static boolean runCommandsInBooks = false;
- private static void runCommandsInBooks() {
+ private static void runCommandsInBooks()
+ {
runCommandsInBooks = getBoolean("runCommandsInBooks", false);
}
diff --git a/src/main/java/net/minecraft/world/item/WrittenBookItem.java b/src/main/java/net/minecraft/world/item/WrittenBookItem.java
index 31911c09fe15753ae32fa39417bdc9e9de552a88..8ef33e2e2374c456cb9d4aab8ed6f1742951f402 100644
--- a/src/main/java/net/minecraft/world/item/WrittenBookItem.java
+++ b/src/main/java/net/minecraft/world/item/WrittenBookItem.java
@@ -2,6 +2,8 @@ package net.minecraft.world.item;
import java.util.List;
import javax.annotation.Nullable;
+
+import me.totalfreedom.scissors.ScissorsConfig;
import net.minecraft.ChatFormatting;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.core.BlockPos;
@@ -9,8 +11,7 @@ import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag;
import net.minecraft.nbt.StringTag;
import net.minecraft.nbt.Tag;
-import net.minecraft.network.chat.Component;
-import net.minecraft.network.chat.ComponentUtils;
+import net.minecraft.network.chat.*;
import net.minecraft.stats.Stats;
import net.minecraft.util.StringUtil;
import net.minecraft.world.InteractionHand;
@@ -111,8 +112,7 @@ public class WrittenBookItem extends Item {
public static boolean resolveBookComponents(ItemStack book, @Nullable CommandSourceStack commandSource, @Nullable Player player) {
CompoundTag compoundTag = book.getTag();
- if (io.papermc.paper.configuration.GlobalConfiguration.get().itemValidation.resolveSelectorsInBooks && compoundTag != null && !compoundTag.getBoolean("resolved")) { // Paper
- compoundTag.putBoolean("resolved", true);
+ if (compoundTag != null) { // Paper
if (!makeSureTagIsValid(compoundTag)) {
return false;
} else {
@@ -161,8 +161,41 @@ 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) {

View File

@ -5,10 +5,10 @@ Subject: [PATCH] Fixes out of bounds HangingEntity crash exploit
diff --git a/src/main/java/net/minecraft/world/entity/decoration/HangingEntity.java b/src/main/java/net/minecraft/world/entity/decoration/HangingEntity.java
index 334a47b5e0d205c57dfcbb17168cbd3f21d15606..0227f4ed153d229747722ab709932741e0998dc1 100644
index f7d031e9a5aa533d78a49ed6147dd47dd0f27f01..68bd4f64e85f26071640b219bb91b868f8e8aded 100644
--- a/src/main/java/net/minecraft/world/entity/decoration/HangingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/decoration/HangingEntity.java
@@ -270,6 +270,13 @@ public abstract class HangingEntity extends Entity {
@@ -271,6 +271,13 @@ public abstract class HangingEntity extends Entity {
public void readAdditionalSaveData(CompoundTag nbt) {
BlockPos blockposition = new BlockPos(nbt.getInt("TileX"), nbt.getInt("TileY"), nbt.getInt("TileZ"));

View File

@ -1,93 +0,0 @@
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/me/totalfreedom/scissors/ScissorsConfig.java b/src/main/java/me/totalfreedom/scissors/ScissorsConfig.java
index 1aa418ef5e400aabdf17dbe81da6cee6a1f63d96..9cd5ffca69df27f794f5a72e687fc6b3ae0f1656 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", 1);
- set("config-version", 1);
+ version = getInt("config-version", 2);
+ set("config-version", 2);
readConfig(ScissorsConfig.class, null);
}
@@ -156,6 +156,13 @@ public class ScissorsConfig
runCommandsInBooks = getBoolean("runCommandsInBooks", false);
}
+ // people still may want them to bypass permissions for warps
+ public static boolean commandSignsBypassPermissions = false;
+ private static void commandSignsBypassPermissions()
+ {
+ commandSignsBypassPermissions = getBoolean("commandSignsBypassPermissions", false);
+ }
+
private static void set(String path, Object val)
{
config.set(path, val);
diff --git a/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java
index 4da4edae517a0efec6e03a719ec47b700509dab1..1ec83cbfc2860e1153be301eefb628e209bf9186 100644
--- a/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java
+++ b/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java
@@ -1,11 +1,13 @@
package net.minecraft.world.level.block.entity;
+import me.totalfreedom.scissors.ScissorsConfig;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import java.util.UUID;
import java.util.function.Function;
import javax.annotation.Nullable;
import net.minecraft.commands.CommandSource;
import net.minecraft.commands.CommandSourceStack;
+import net.minecraft.commands.Commands;
import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.ClickEvent;
@@ -15,6 +17,7 @@ import net.minecraft.network.chat.ComponentUtils;
import net.minecraft.network.chat.MutableComponent;
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.util.FormattedCharSequence;
@@ -24,6 +27,8 @@ import net.minecraft.world.item.DyeColor;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.Vec2;
import net.minecraft.world.phys.Vec3;
+import org.bukkit.craftbukkit.CraftServer;
+import org.bukkit.craftbukkit.entity.CraftPlayer;
public class SignBlockEntity extends BlockEntity implements CommandSource { // CraftBukkit - implements
private static final boolean CONVERT_LEGACY_SIGNS = Boolean.getBoolean("convertLegacySigns"); // Paper
@@ -270,7 +275,21 @@ public class SignBlockEntity extends BlockEntity implements CommandSource { // C
if (!event.callEvent()) {
return false;
}
- player.getServer().getCommands().performPrefixedCommand(this.createCommandSourceStack(((org.bukkit.craftbukkit.entity.CraftPlayer) event.getPlayer()).getHandle()), event.getMessage());
+
+ // Scissors start - Add optional permissions to command signs
+ final MinecraftServer vanillaServer = player.getServer();
+ final CraftServer craftServer = vanillaServer.server;
+ final CraftPlayer craftPlayer = player.getBukkitEntity();
+ final Commands commands = vanillaServer.getCommands();
+
+ if (ScissorsConfig.commandSignsBypassPermissions)
+ {
+ commands.performPrefixedCommand(this.createCommandSourceStack(((org.bukkit.craftbukkit.entity.CraftPlayer) event.getPlayer()).getHandle()), event.getMessage());
+ } else
+ {
+ craftServer.dispatchCommand(craftPlayer, command.substring(1));
+ }
+ // Scissors end
// Paper end
}
}

View File

@ -5,7 +5,7 @@ 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 97231f7328f0eebffcacdae5469027be8aeec3ae..cca792cfabedcc72be99a334f1c2a303217484d7 100644
index 2096e8a0bdbcfc865f175f3a01ab688542481531..1c31e2c457c416a970b6ff4913c63195ff19443a 100644
--- a/src/main/java/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java
+++ b/src/main/java/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java
@@ -41,9 +41,13 @@ public abstract class AbstractHurtingProjectile extends Projectile {

View File

@ -1,102 +0,0 @@
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/me/totalfreedom/scissors/ScissorsConfig.java b/src/main/java/me/totalfreedom/scissors/ScissorsConfig.java
index 37b8ce4fe8913fd1097c552609c9eddb2751555e..5f46c6e93048a237e25ad84b8839a2945cc88e81 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", 2);
- set("config-version", 2);
+ version = getInt("config-version", 3);
+ set("config-version", 3);
readConfig(ScissorsConfig.class, null);
}
@@ -163,6 +163,12 @@ public class ScissorsConfig
commandSignsBypassPermissions = getBoolean("commandSignsBypassPermissions", false);
}
+ public static boolean chatSignaturesEnabled = true;
+ private static void chatSignaturesEnabled()
+ {
+ chatSignaturesEnabled = getBoolean("chatSignaturesEnabled", true);
+ }
+
private static void set(String path, Object val)
{
config.set(path, val);
diff --git a/src/main/java/net/minecraft/network/chat/OutgoingChatMessage.java b/src/main/java/net/minecraft/network/chat/OutgoingChatMessage.java
index 74cf1c043beef03cfd5adf481414a5ee78bef2a6..182f68359a7a8c0b331acd103ed3952ea3c33b93 100644
--- a/src/main/java/net/minecraft/network/chat/OutgoingChatMessage.java
+++ b/src/main/java/net/minecraft/network/chat/OutgoingChatMessage.java
@@ -1,5 +1,6 @@
package net.minecraft.network.chat;
+import me.totalfreedom.scissors.ScissorsConfig;
import net.minecraft.server.level.ServerPlayer;
public interface OutgoingChatMessage {
@@ -42,12 +43,16 @@ public interface OutgoingChatMessage {
}
public void sendToPlayer(ServerPlayer sender, boolean filterMaskEnabled, ChatType.Bound params, @javax.annotation.Nullable Component unsigned) {
// Paper end
+ // Scissors start - Add configuration option to disable chat signatures
PlayerChatMessage playerChatMessage = this.message.filter(filterMaskEnabled);
playerChatMessage = unsigned != null ? playerChatMessage.withUnsignedContent(unsigned) : playerChatMessage; // Paper
- if (!playerChatMessage.isFullyFiltered()) {
+ if (!playerChatMessage.isFullyFiltered() && /* Scissors */ ScissorsConfig.chatSignaturesEnabled) {
sender.connection.sendPlayerChatMessage(playerChatMessage, params);
+ return;
}
+ sender.connection.sendDisguisedChatMessage(playerChatMessage.decoratedContent(), params);
+ // Scissors end
}
}
}
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index 7d160cdc01d85c4fdc78342051c92be26e394a7f..b55d78ae48ebc18b857f28084fe86ea41e574cd9 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;
@@ -2366,6 +2367,13 @@ 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
}
@@ -2601,6 +2609,13 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
synchronized (this.lastSeenMessages) {
if (!this.lastSeenMessages.applyOffset(packet.offset())) {
+ // 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
}