mirror of
https://github.com/AtlasMediaGroup/Scissors.git
synced 2025-06-28 16:26:41 +00:00
more patches
This commit is contained in:
@ -1,30 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Allink <arclicious@vivaldi.net>
|
||||
Date: Tue, 5 Jul 2022 04:12:31 +0100
|
||||
Subject: [PATCH] Add spectator teleport event
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
index 65bb221993147a558995b36fb835f7b82e0eb4bd..4ea2c551d924f976a8de9e2ae521544f323fbec4 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; // Scissors
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.primitives.Floats;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
@@ -2006,6 +2007,12 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
||||
Entity entity = packet.getEntity(worldserver);
|
||||
|
||||
if (entity != null) {
|
||||
+ // Scissors start - Add spectator teleport event
|
||||
+ final SpectatorTeleportEvent event = new SpectatorTeleportEvent(this.player.getBukkitEntity(), entity.getBukkitEntity());
|
||||
+ if (!event.callEvent()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // Scissors end
|
||||
this.player.teleportTo(worldserver, entity.getX(), entity.getY(), entity.getZ(), entity.getYRot(), entity.getXRot(), org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.SPECTATE); // CraftBukkit
|
||||
return;
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Allink <arclicious@vivaldi.net>
|
||||
Date: Sun, 10 Jul 2022 02:55:01 +0100
|
||||
Subject: [PATCH] Prevent invalid container events
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
index 4ea2c551d924f976a8de9e2ae521544f323fbec4..83ae366b4f52261e2e2b65a4183d7ca823edd315 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -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; // Scissors
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.SharedConstants;
|
||||
import net.minecraft.Util;
|
||||
@@ -2900,6 +2901,18 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
||||
return;
|
||||
}
|
||||
|
||||
+ // Scissors start - Do not call events when the slot/button number is invalid
|
||||
+ final int sentSlotNum = packet.getSlotNum();
|
||||
+ if((Mth.clamp(sentSlotNum, -1, this.player.containerMenu.slots.size() - 1) != sentSlotNum) && sentSlotNum != -999)
|
||||
+ {
|
||||
+ this.getCraftPlayer().kick(
|
||||
+ net.kyori.adventure.text.Component.text("Invalid container click slot (Hacking?)")
|
||||
+ .color(NamedTextColor.RED)
|
||||
+ );
|
||||
+ return;
|
||||
+ }
|
||||
+ // Scissors end
|
||||
+
|
||||
InventoryView inventory = this.player.containerMenu.getBukkitView();
|
||||
SlotType type = inventory.getSlotType(packet.getSlotNum());
|
||||
|
@ -1,73 +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/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;
|
@ -1,31 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Luna <lunahatesgogle@gmail.com>
|
||||
Date: Mon, 11 Jul 2022 17:29:12 -0300
|
||||
Subject: [PATCH] Validate block entity/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 83ae366b4f52261e2e2b65a4183d7ca823edd315..67b5447ffcf54c54b2087df456690a9bed98fbd3 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -1262,7 +1262,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
||||
if (this.player.hasPermissions(2)) {
|
||||
Entity entity = this.player.level().getEntity(packet.getEntityId());
|
||||
|
||||
- if (entity != null) {
|
||||
+ if (entity != null && this.player.distanceToSqr(entity.position().x, entity.position().y, entity.position().z) < 32 * 32) { // Scissors - Validate entity tag query positions
|
||||
CompoundTag nbttagcompound = entity.saveWithoutId(new CompoundTag());
|
||||
|
||||
this.player.connection.send(new ClientboundTagQueryPacket(packet.getTransactionId(), nbttagcompound));
|
||||
@@ -1274,7 +1274,10 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
||||
@Override
|
||||
public void handleBlockEntityTagQuery(ServerboundBlockEntityTagQuery packet) {
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
|
||||
- if (this.player.hasPermissions(2)) {
|
||||
+ // Scissors start - Validate block entity tag query positions
|
||||
+ if (this.player.hasPermissions(2) && this.player.level().isLoadedAndInBounds(packet.getPos())
|
||||
+ && this.player.distanceToSqr(packet.getPos().getX(), packet.getPos().getY(), packet.getPos().getZ()) < 32 * 32) {
|
||||
+ // Scissors end
|
||||
BlockEntity tileentity = this.player.level().getBlockEntity(packet.getPos());
|
||||
CompoundTag nbttagcompound = tileentity != null ? tileentity.saveWithoutMetadata() : null;
|
||||
|
@ -1,67 +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/net/minecraft/world/level/block/entity/SignBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java
|
||||
index 38cde466714e5663cd416b6afd5d2558e139ec09..ed48eaae75e709361a260421934b6b925ae9b427 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
|
||||
|
||||
@@ -291,6 +296,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;
|
||||
}
|
||||
}
|
@ -1,18 +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..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();
|
||||
}
|
||||
|
@ -1,94 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Allink <arclicious@vivaldi.net>
|
||||
Date: Sun, 27 Nov 2022 05:14:18 +0000
|
||||
Subject: [PATCH] Prevent velocity freeze
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java b/src/main/java/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java
|
||||
index 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; // Scissors
|
||||
import net.minecraft.core.particles.ParticleOptions;
|
||||
import net.minecraft.core.particles.ParticleTypes;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
@@ -41,9 +42,13 @@ public abstract class AbstractHurtingProjectile extends Projectile {
|
||||
double d6 = Math.sqrt(d3 * d3 + d4 * d4 + d5 * d5);
|
||||
|
||||
if (d6 != 0.0D) {
|
||||
- this.xPower = d3 / d6 * 0.1D;
|
||||
- this.yPower = d4 / d6 * 0.1D;
|
||||
- this.zPower = d5 / d6 * 0.1D;
|
||||
+ // Scissors start - Prevent projectile velocity freeze
|
||||
+ //this.xPower = d3 / d6 * 0.1D;
|
||||
+ //this.yPower = d4 / d6 * 0.1D;
|
||||
+ //this.zPower = d5 / d6 * 0.1D;
|
||||
+
|
||||
+ setPower(d3 / d6 * .1d, d4 / d6 * .1d, d5 / d6 * .1d);
|
||||
+ // Scissors end
|
||||
}
|
||||
|
||||
}
|
||||
@@ -141,6 +146,25 @@ public abstract class AbstractHurtingProjectile extends Projectile {
|
||||
nbt.put("power", this.newDoubleList(new double[]{this.xPower, this.yPower, this.zPower}));
|
||||
}
|
||||
|
||||
+ // Scissors start - Prevent projectile velocity freeze
|
||||
+ public void setPower(double xPower, double yPower, double zPower)
|
||||
+ {
|
||||
+ if (Double.isInfinite(xPower) || Double.isInfinite(yPower) || Double.isInfinite(zPower))
|
||||
+ {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ if (Double.isNaN(xPower) || Double.isNaN(yPower) || Double.isNaN(zPower))
|
||||
+ {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ this.xPower = MathUtility.clampDouble(xPower, -1024, 1024);
|
||||
+ this.yPower = MathUtility.clampDouble(yPower, -1024, 1024);
|
||||
+ this.zPower = MathUtility.clampDouble(zPower, -1024, 1024);
|
||||
+ }
|
||||
+ // Scissors end
|
||||
+
|
||||
@Override
|
||||
public void readAdditionalSaveData(CompoundTag nbt) {
|
||||
super.readAdditionalSaveData(nbt);
|
||||
@@ -148,9 +172,13 @@ public abstract class AbstractHurtingProjectile extends Projectile {
|
||||
ListTag nbttaglist = nbt.getList("power", 6);
|
||||
|
||||
if (nbttaglist.size() == 3) {
|
||||
- this.xPower = nbttaglist.getDouble(0);
|
||||
- this.yPower = nbttaglist.getDouble(1);
|
||||
- this.zPower = nbttaglist.getDouble(2);
|
||||
+ // Scissors start - Prevent projectile velocity freeze
|
||||
+ //this.xPower = nbttaglist.getDouble(0);
|
||||
+ //this.yPower = nbttaglist.getDouble(1);
|
||||
+ //this.zPower = nbttaglist.getDouble(2);
|
||||
+
|
||||
+ setPower(nbttaglist.getDouble(0), nbttaglist.getDouble(1), nbttaglist.getDouble(2));
|
||||
+ // Scissors end
|
||||
}
|
||||
}
|
||||
|
||||
@@ -184,9 +212,13 @@ public abstract class AbstractHurtingProjectile extends Projectile {
|
||||
Vec3 vec3d = entity.getLookAngle();
|
||||
|
||||
this.setDeltaMovement(vec3d);
|
||||
- this.xPower = vec3d.x * 0.1D;
|
||||
- this.yPower = vec3d.y * 0.1D;
|
||||
- this.zPower = vec3d.z * 0.1D;
|
||||
+ // Scissors start - Prevent projectile velocity freeze
|
||||
+ //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);
|
||||
}
|
||||
|
@ -1,105 +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/net/minecraft/network/chat/OutgoingChatMessage.java b/src/main/java/net/minecraft/network/chat/OutgoingChatMessage.java
|
||||
index 74cf1c043beef03cfd5adf481414a5ee78bef2a6..516c61cbb8299828b2f28d4564d08ae1829649b5 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,21 @@ 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;
|
||||
}
|
||||
|
||||
+ 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 67b5447ffcf54c54b2087df456690a9bed98fbd3..94cc122aad0e48687ea9f25cd810f07dc893acc6 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;
|
||||
@@ -2220,7 +2221,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
||||
}
|
||||
|
||||
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));
|
||||
@@ -2276,6 +2277,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
||||
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
|
||||
}
|
||||
@@ -2484,6 +2486,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
||||
|
||||
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
|
||||
}
|
||||
@@ -3462,6 +3465,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
||||
@Override
|
||||
public void handleChatSessionUpdate(ServerboundChatSessionUpdatePacket packet) {
|
||||
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel());
|
||||
+ if (!ScissorsConfig.chatSignaturesEnabled) return; // Scissors
|
||||
RemoteChatSession.Data remotechatsession_a = packet.chatSession();
|
||||
ProfilePublicKey.Data profilepublickey_a = this.chatSession != null ? this.chatSession.profilePublicKey().data() : null;
|
||||
ProfilePublicKey.Data profilepublickey_a1 = remotechatsession_a.profilePublicKey();
|
@ -1,78 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Luna <lunahatesgogle@gmail.com>
|
||||
Date: Sun, 2 Apr 2023 16:29:51 -0300
|
||||
Subject: [PATCH] Patch large selector distance crash
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/advancements/critereon/MinMaxBounds.java b/src/main/java/net/minecraft/advancements/critereon/MinMaxBounds.java
|
||||
index 8897496323378080135127f53db004d576476c21..5f957d3241c1931f8166bc9e4960cef15679e932 100644
|
||||
--- a/src/main/java/net/minecraft/advancements/critereon/MinMaxBounds.java
|
||||
+++ b/src/main/java/net/minecraft/advancements/critereon/MinMaxBounds.java
|
||||
@@ -129,9 +129,9 @@ public interface MinMaxBounds<T extends Number> {
|
||||
|
||||
public static record Doubles(Optional<Double> min, Optional<Double> max, Optional<Double> minSq, Optional<Double> maxSq) implements MinMaxBounds<Double> {
|
||||
public static final MinMaxBounds.Doubles ANY = new MinMaxBounds.Doubles(Optional.empty(), Optional.empty());
|
||||
- public static final Codec<MinMaxBounds.Doubles> CODEC = MinMaxBounds.createCodec(Codec.DOUBLE, MinMaxBounds.Doubles::new);
|
||||
+ public static final Codec<MinMaxBounds.Doubles> CODEC = MinMaxBounds.<Double, MinMaxBounds.Doubles>createCodec(Codec.DOUBLE, MinMaxBounds.Doubles::new); // Scissors - compile fixes
|
||||
|
||||
- private Doubles(Optional<Double> optional, Optional<Double> optional2) {
|
||||
+ public Doubles(Optional<Double> optional, Optional<Double> optional2) { // Scissors - private -> public
|
||||
this(optional, optional2, squareOpt(optional), squareOpt(optional2));
|
||||
}
|
||||
|
||||
@@ -202,7 +202,7 @@ public interface MinMaxBounds<T extends Number> {
|
||||
|
||||
public static record Ints(Optional<Integer> min, Optional<Integer> max, Optional<Long> minSq, Optional<Long> maxSq) implements MinMaxBounds<Integer> {
|
||||
public static final MinMaxBounds.Ints ANY = new MinMaxBounds.Ints(Optional.empty(), Optional.empty());
|
||||
- public static final Codec<MinMaxBounds.Ints> CODEC = MinMaxBounds.createCodec(Codec.INT, MinMaxBounds.Ints::new);
|
||||
+ public static final Codec<MinMaxBounds.Ints> CODEC = MinMaxBounds.<Integer, MinMaxBounds.Ints>createCodec(Codec.INT, MinMaxBounds.Ints::new); // Scissors - compile fixes
|
||||
|
||||
private Ints(Optional<Integer> optional, Optional<Integer> optional2) {
|
||||
this(optional, optional2, optional.map((integer) -> {
|
||||
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 73c15a0c56a103ba4e62f0a51af8d42566b07245..6cb3e86f2d661a55536b782729f768ef72163223 100644
|
||||
--- a/src/main/java/net/minecraft/commands/arguments/selector/EntitySelector.java
|
||||
+++ b/src/main/java/net/minecraft/commands/arguments/selector/EntitySelector.java
|
||||
@@ -5,11 +5,13 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
+import java.util.Optional; // Scissors
|
||||
import java.util.UUID;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Predicate;
|
||||
import javax.annotation.Nullable;
|
||||
+import me.totalfreedom.scissors.MathUtility; // Scissors
|
||||
import net.minecraft.advancements.critereon.MinMaxBounds;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.arguments.EntityArgument;
|
||||
@@ -60,9 +62,26 @@ public class EntitySelector {
|
||||
this.includesEntities = includesNonPlayers;
|
||||
this.worldLimited = localWorldOnly;
|
||||
this.predicate = basePredicate;
|
||||
- this.range = distance;
|
||||
+ // Scissors start - Patch large selector distance crash
|
||||
+ this.range = new MinMaxBounds.Doubles(
|
||||
+ distance.min().map(min -> Math.min(min, 1024)),
|
||||
+ distance.max().map(max -> Math.min(max, 1024))
|
||||
+ );
|
||||
this.position = positionOffset;
|
||||
- this.aabb = box;
|
||||
+ if (box != null) {
|
||||
+ this.aabb = new AABB(
|
||||
+ MathUtility.clampDouble(box.minX, -1024, 1025),
|
||||
+ MathUtility.clampDouble(box.minY, -1024, 1025),
|
||||
+ MathUtility.clampDouble(box.minZ, -1024, 1025),
|
||||
+ MathUtility.clampDouble(box.maxX, -1024, 1025),
|
||||
+ MathUtility.clampDouble(box.maxY, -1024, 1025),
|
||||
+ MathUtility.clampDouble(box.maxZ, -1024, 1025),
|
||||
+ false
|
||||
+ );
|
||||
+ } else {
|
||||
+ this.aabb = null;
|
||||
+ }
|
||||
+ // Scissors end
|
||||
this.order = sorter;
|
||||
this.currentEntity = senderOnly;
|
||||
this.playerName = playerName;
|
@ -1,19 +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 e8845d6ec1bcba6df2eb8e1af0d658b10299831a..015d5e9b6de5f1fb466e1801bdf5fb430ba91f35 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -4696,7 +4696,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;
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Luna <lunahatesgogle@gmail.com>
|
||||
Date: Mon, 10 Apr 2023 13:56:18 -0300
|
||||
Subject: [PATCH] Limit sculk catalyst cursor positions
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/SculkSpreader.java b/src/main/java/net/minecraft/world/level/block/SculkSpreader.java
|
||||
index de90a216321f7d82310a0d1c915fefe64360534c..7e52f6c26234cf6fa092151d51c0c6b70dc22ca8 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/SculkSpreader.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/SculkSpreader.java
|
||||
@@ -181,7 +181,7 @@ public class SculkSpreader {
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
SculkSpreader.ChargeCursor sculkspreader_a = (SculkSpreader.ChargeCursor) iterator.next();
|
||||
-
|
||||
+ if (!world.getMinecraftWorld().isLoadedAndInBounds(sculkspreader_a.getPos())) continue; // Scissors
|
||||
sculkspreader_a.update(world, pos, random, this, shouldConvertToBlock);
|
||||
if (sculkspreader_a.charge <= 0) {
|
||||
world.levelEvent(3006, sculkspreader_a.getPos(), 0);
|
@ -1,36 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Luna <lunahatesgogle@gmail.com>
|
||||
Date: Fri, 28 Apr 2023 16:29:23 -0300
|
||||
Subject: [PATCH] Limit map decorations
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundMapItemDataPacket.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundMapItemDataPacket.java
|
||||
index 81f3e64d94fa17e45411e5c1641d9c5a2fe3d2e2..bcf6e2ce9f00d1688a5fa00ec055a57389346922 100644
|
||||
--- a/src/main/java/net/minecraft/network/protocol/game/ClientboundMapItemDataPacket.java
|
||||
+++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundMapItemDataPacket.java
|
||||
@@ -65,7 +65,8 @@ public class ClientboundMapItemDataPacket implements Packet<ClientGamePacketList
|
||||
b.writeByte(icon.x());
|
||||
b.writeByte(icon.y());
|
||||
b.writeByte(icon.rot() & 15);
|
||||
- b.writeNullable(icon.name(), FriendlyByteBuf::writeComponent);
|
||||
+ final boolean passedNameCap = icon.name() == null || icon.name().getString().length() <= 32; // Scissors
|
||||
+ b.writeNullable(passedNameCap ? icon.name() : null, FriendlyByteBuf::writeComponent); // Scissors
|
||||
});
|
||||
});
|
||||
if (this.colorPatch != null) {
|
||||
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 e4c4948e076cd64686dfd16ae0568fafc1437140..eff53c21b18574750b691b784fb1688885d4ace7 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
|
||||
@@ -361,6 +361,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) {
|
||||
+ // Scissors start - Limit decoration count
|
||||
+ if (this.decorations.size() > 32) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // Scissors end
|
||||
int i = 1 << this.scale;
|
||||
float f = (float) (x - (double) this.centerX) / (float) i;
|
||||
float f1 = (float) (z - (double) this.centerZ) / (float) i;
|
@ -1,25 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Luna <lunahatesgogle@gmail.com>
|
||||
Date: Fri, 28 Apr 2023 16:44:50 -0300
|
||||
Subject: [PATCH] Prevent player banning using duplicate UUIDs
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
index 17610196db7a1c6feb2cf74a02479a8691aa323f..70c52e2293d64d32fdcebbcd0678e0c80d35fbb8 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -1644,7 +1644,13 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||
if (entity != null) {
|
||||
ServerLevel.LOGGER.warn("Force-added player with duplicate UUID {}", player.getUUID());
|
||||
entity.unRide();
|
||||
- this.removePlayerImmediately((ServerPlayer) entity, Entity.RemovalReason.DISCARDED);
|
||||
+ // Scissors start - Prevent player banning using duplicate UUIDs
|
||||
+ if (entity instanceof ServerPlayer serverPlayer) {
|
||||
+ this.removePlayerImmediately(serverPlayer, Entity.RemovalReason.DISCARDED);
|
||||
+ } else {
|
||||
+ entity.discard();
|
||||
+ }
|
||||
+ // Scissors end
|
||||
}
|
||||
|
||||
this.entityLookup.addNewEntity(player); // Paper - rewite chunk system
|
@ -1,19 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Luna <lunahatesgogle@gmail.com>
|
||||
Date: Fri, 28 Apr 2023 16:46:00 -0300
|
||||
Subject: [PATCH] Don't warn on duplicate entity UUIDs
|
||||
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/chunk/system/entity/EntityLookup.java b/src/main/java/io/papermc/paper/chunk/system/entity/EntityLookup.java
|
||||
index 15ee41452992714108efe53b708b5a4e1da7c1ff..5054dce35127cb0132431021578c345fcbb1f92a 100644
|
||||
--- a/src/main/java/io/papermc/paper/chunk/system/entity/EntityLookup.java
|
||||
+++ b/src/main/java/io/papermc/paper/chunk/system/entity/EntityLookup.java
|
||||
@@ -415,7 +415,7 @@ public final class EntityLookup implements LevelEntityGetter<Entity> {
|
||||
return false;
|
||||
}
|
||||
if (this.entityByUUID.containsKey(entity.getUUID())) {
|
||||
- LOGGER.warn("Entity uuid already exists: " + entity.getUUID() + ", mapped to " + this.entityByUUID.get(entity.getUUID()) + ", can't add " + entity);
|
||||
+ // Scissors - Don't warn on duplicate entity UUIDs
|
||||
return false;
|
||||
}
|
||||
this.entityById.put(entity.getId(), entity);
|
@ -1,18 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Luna <lunahatesgogle@gmail.com>
|
||||
Date: Mon, 29 May 2023 19:34:50 -0300
|
||||
Subject: [PATCH] Fix component extra empty array exploit
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/network/chat/Component.java b/src/main/java/net/minecraft/network/chat/Component.java
|
||||
index 9cb6fa8e35c89f73e7c95dbe219a4bf6d00b60a9..fa6151a2361684426bdd3bf3b433fe4dbd0cf47b 100644
|
||||
--- a/src/main/java/net/minecraft/network/chat/Component.java
|
||||
+++ b/src/main/java/net/minecraft/network/chat/Component.java
|
||||
@@ -266,6 +266,7 @@ public interface Component extends Message, FormattedText, Iterable<Component> {
|
||||
if (!jsonelement.isJsonObject()) {
|
||||
if (jsonelement.isJsonArray()) {
|
||||
JsonArray jsonarray = jsonelement.getAsJsonArray();
|
||||
+ if (jsonarray.size() <= 0) throw new JsonParseException("Unexpected empty array of components"); // Scissors
|
||||
|
||||
ichatmutablecomponent = null;
|
||||
Iterator iterator = jsonarray.iterator();
|
@ -1,125 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Luna <lunahatesgogle@gmail.com>
|
||||
Date: Wed, 31 May 2023 18:14:00 -0300
|
||||
Subject: [PATCH] Add depth limit to Component deserializer
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/network/chat/Component.java b/src/main/java/net/minecraft/network/chat/Component.java
|
||||
index fa6151a2361684426bdd3bf3b433fe4dbd0cf47b..4dd93e02f2b18e5c75be14ff8f052220ca69f427 100644
|
||||
--- a/src/main/java/net/minecraft/network/chat/Component.java
|
||||
+++ b/src/main/java/net/minecraft/network/chat/Component.java
|
||||
@@ -26,6 +26,7 @@ import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Optional;
|
||||
import javax.annotation.Nullable;
|
||||
+import me.totalfreedom.scissors.ScissorsConfig; // Scissors
|
||||
import net.minecraft.ChatFormatting; // Scissors
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.network.chat.contents.BlockDataSource;
|
||||
@@ -44,6 +45,7 @@ import net.minecraft.util.GsonHelper;
|
||||
import net.minecraft.util.LowerCaseEnumTypeAdapterFactory;
|
||||
// CraftBukkit start
|
||||
import com.google.common.collect.Streams;
|
||||
+import java.util.regex.Pattern; // Scissors
|
||||
import java.util.stream.Stream;
|
||||
// CraftBukkit end
|
||||
|
||||
@@ -254,10 +256,16 @@ public interface Component extends Message, FormattedText, Iterable<Component> {
|
||||
throw new IllegalStateException("Couldn't get field 'lineStart' for JsonReader", nosuchfieldexception);
|
||||
}
|
||||
});
|
||||
+ private static final Pattern PLACEHOLDER_PATTERN = Pattern.compile("%[0-9]+\\$s"); // Scissors
|
||||
|
||||
public Serializer() {}
|
||||
|
||||
- public MutableComponent deserialize(JsonElement jsonelement, Type type, JsonDeserializationContext jsondeserializationcontext) throws JsonParseException {
|
||||
+ // Scissors start
|
||||
+ private MutableComponent deserialize(JsonElement jsonelement, JsonDeserializationContext jsondeserializationcontext, int depth) throws JsonParseException {
|
||||
+ if (depth > ScissorsConfig.componentDepthLimit) {
|
||||
+ throw new JsonParseException("Depth limit exceeded");
|
||||
+ }
|
||||
+ // Scissors end
|
||||
if (jsonelement.isJsonPrimitive()) {
|
||||
return Component.literal(jsonelement.getAsString());
|
||||
} else {
|
||||
@@ -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); // Scissors
|
||||
|
||||
if (ichatmutablecomponent == null) {
|
||||
ichatmutablecomponent = ichatmutablecomponent1;
|
||||
@@ -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);
|
||||
|
||||
+ // 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)); // Scissors
|
||||
}
|
||||
|
||||
ichatmutablecomponent = Component.translatableWithFallback(s, s1, aobject);
|
||||
@@ -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); // Scissors
|
||||
|
||||
ichatmutablecomponent = Component.selector(GsonHelper.getAsString(jsonobject, "selector"), optional);
|
||||
} else if (jsonobject.has("keybind")) {
|
||||
@@ -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); // Scissors
|
||||
boolean flag = GsonHelper.getAsBoolean(jsonobject, "interpret", false);
|
||||
Object object;
|
||||
|
||||
@@ -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)); // Scissors
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
+ }
|
||||
+ // Scissors end
|
||||
+
|
||||
private static Object unwrapTextArgument(Object text) {
|
||||
if (text instanceof Component) {
|
||||
Component ichatbasecomponent = (Component) text;
|
||||
@@ -384,8 +403,10 @@ public interface Component extends Message, FormattedText, Iterable<Component> {
|
||||
return text;
|
||||
}
|
||||
|
||||
- private Optional<Component> parseSeparator(Type type, JsonDeserializationContext context, JsonObject json) {
|
||||
- return json.has("separator") ? Optional.of(this.deserialize(json.get("separator"), type, context)) : Optional.empty();
|
||||
+ // Scissors start
|
||||
+ private Optional<Component> parseSeparator(JsonDeserializationContext context, JsonObject json, int depth) {
|
||||
+ return json.has("separator") ? Optional.of(this.deserialize(json.get("separator"), context, depth + 1)) : Optional.empty();
|
||||
+ // Scissors end
|
||||
}
|
||||
|
||||
private void serializeStyle(Style style, JsonObject json, JsonSerializationContext context) {
|
Reference in New Issue
Block a user