mirror of
https://github.com/AtlasMediaGroup/Scissors.git
synced 2025-06-28 16:26:41 +00:00
more patches
This commit is contained in:
30
patches/server/0027-Add-spectator-teleport-event.patch
Normal file
30
patches/server/0027-Add-spectator-teleport-event.patch
Normal file
@ -0,0 +1,30 @@
|
||||
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 30ccbab1586a656e0ae41d7406525fb02d9e025b..987001ab3a7cdd1c8c37e528077e5d33060ab505 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;
|
||||
@@ -2033,6 +2034,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;
|
||||
}
|
37
patches/server/0028-Prevent-invalid-container-events.patch
Normal file
37
patches/server/0028-Prevent-invalid-container-events.patch
Normal file
@ -0,0 +1,37 @@
|
||||
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 987001ab3a7cdd1c8c37e528077e5d33060ab505..87d5f576ef8be68256191df7c3bf4f081c2e7370 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -29,6 +29,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;
|
||||
@@ -2902,6 +2903,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());
|
||||
|
@ -0,0 +1,73 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Allink <arclicious@vivaldi.net>
|
||||
Date: Sun, 10 Jul 2022 10:29:03 +0100
|
||||
Subject: [PATCH] Disable running commands in books by default
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/item/WrittenBookItem.java b/src/main/java/net/minecraft/world/item/WrittenBookItem.java
|
||||
index 31911c09fe15753ae32fa39417bdc9e9de552a88..b810a5afcb2343174e37efb7dd8a36b968b07c3a 100644
|
||||
--- a/src/main/java/net/minecraft/world/item/WrittenBookItem.java
|
||||
+++ b/src/main/java/net/minecraft/world/item/WrittenBookItem.java
|
||||
@@ -2,6 +2,7 @@ package net.minecraft.world.item;
|
||||
|
||||
import java.util.List;
|
||||
import javax.annotation.Nullable;
|
||||
+import me.totalfreedom.scissors.ScissorsConfig; // Scissors
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.core.BlockPos;
|
||||
@@ -9,8 +10,7 @@ import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.nbt.StringTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
-import net.minecraft.network.chat.Component;
|
||||
-import net.minecraft.network.chat.ComponentUtils;
|
||||
+import net.minecraft.network.chat.*; // Scissors
|
||||
import net.minecraft.stats.Stats;
|
||||
import net.minecraft.util.StringUtil;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
@@ -161,9 +161,43 @@ public class WrittenBookItem extends Item {
|
||||
component2 = Component.literal(text);
|
||||
}
|
||||
|
||||
- return Component.Serializer.toJson(component2);
|
||||
+ return Component.Serializer.toJson(!ScissorsConfig.runCommandsInBooks ? sanitize(component2, 0) : component2); // Scissors - Allow server owners to disable run command in books
|
||||
}
|
||||
|
||||
+ // Scissors start - Allow server owners to disable run command in books
|
||||
+ public static Component sanitize(Component component, int depth)
|
||||
+ {
|
||||
+ if (depth > 128)
|
||||
+ {
|
||||
+ return Component.nullToEmpty("Sanitization function depth limit exceeded");
|
||||
+ }
|
||||
+
|
||||
+ MutableComponent component2 = component.copy();
|
||||
+
|
||||
+ final Style style = component2.getStyle();
|
||||
+ final ClickEvent clickEvent = style.getClickEvent();
|
||||
+
|
||||
+ if (clickEvent != null && clickEvent.getAction().equals(ClickEvent.Action.RUN_COMMAND))
|
||||
+ {
|
||||
+ final String clickEventValue = clickEvent.getValue();
|
||||
+
|
||||
+ component2 = component2.copy().setStyle(style
|
||||
+ .withClickEvent(null)
|
||||
+ .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.nullToEmpty("Would've " + (clickEventValue.startsWith("/") ? "ran" : "said") + ": " + clickEvent.getValue())))
|
||||
+ );
|
||||
+ }
|
||||
+
|
||||
+ final List<Component> processedExtra = component2.getSiblings()
|
||||
+ .stream()
|
||||
+ .map(comp -> sanitize(comp, depth + 1))
|
||||
+ .toList();
|
||||
+ component2.getSiblings().clear();
|
||||
+ component2.getSiblings().addAll(processedExtra);
|
||||
+
|
||||
+ return component2;
|
||||
+ }
|
||||
+ // Scissors end
|
||||
+
|
||||
@Override
|
||||
public boolean isFoil(ItemStack stack) {
|
||||
return true;
|
@ -0,0 +1,31 @@
|
||||
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 87d5f576ef8be68256191df7c3bf4f081c2e7370..acb4a7ad68a1d6c1ba43eafdd85ab5f824621507 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -1267,7 +1267,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));
|
||||
@@ -1299,7 +1299,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;
|
||||
|
@ -0,0 +1,67 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Allink <arclicious@vivaldi.net>
|
||||
Date: Wed, 13 Jul 2022 12:13:22 +0100
|
||||
Subject: [PATCH] Fix ClickEvents on Signs bypassing permissions
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java
|
||||
index bc01970c5ef9cde4a75394d6977837e924a38463..12ae1d0b819c2968fed903c14f9523b492a506ff 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;
|
||||
@@ -32,6 +35,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;
|
||||
@@ -39,6 +43,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
|
||||
|
||||
@@ -289,6 +294,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;
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Allink <arclicious@vivaldi.net>
|
||||
Date: Tue, 16 Aug 2022 17:13:02 +0100
|
||||
Subject: [PATCH] Refuse to convert legacy messages over 1k characters
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java b/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java
|
||||
index 730d8e3cf2d9ca05b2d6219cf1856b8721871a37..63e71c5cb4ac4d17d2cfa5324fd842a0d3c61eb5 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java
|
||||
@@ -198,6 +198,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();
|
||||
}
|
||||
|
100
patches/server/0033-Prevent-velocity-freeze.patch
Normal file
100
patches/server/0033-Prevent-velocity-freeze.patch
Normal file
@ -0,0 +1,100 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Telesphoreo <me@telesphoreo.me>
|
||||
Date: Sun, 10 Dec 2023 18:41:18 -0600
|
||||
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 c4ecc5faa4f61e7974e8c475762924a89615b377..1c14b87f84b678b36adede9d2aa9a18453ce4278 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java
|
||||
@@ -1,6 +1,8 @@
|
||||
package net.minecraft.world.entity.projectile;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
+
|
||||
+import me.totalfreedom.scissors.MathUtility;
|
||||
import net.minecraft.core.particles.ParticleOptions;
|
||||
import net.minecraft.core.particles.ParticleTypes;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
@@ -47,12 +49,15 @@ public abstract class AbstractHurtingProjectile extends Projectile {
|
||||
// CraftBukkit end
|
||||
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;
|
||||
+ if (d6 != 0.0D)
|
||||
+ {
|
||||
+ // 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
|
||||
}
|
||||
|
||||
public AbstractHurtingProjectile(EntityType<? extends AbstractHurtingProjectile> type, LivingEntity owner, double directionX, double directionY, double directionZ, Level world) {
|
||||
@@ -164,6 +169,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);
|
||||
@@ -171,9 +195,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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -207,9 +235,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);
|
||||
}
|
||||
|
@ -0,0 +1,107 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Telesphoreo <me@telesphoreo.me>
|
||||
Date: Sun, 10 Dec 2023 18:48:55 -0600
|
||||
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..939f4a0639c847b94cfc9acf1409a7a3fc5ae58f 100644
|
||||
--- a/src/main/java/net/minecraft/network/chat/OutgoingChatMessage.java
|
||||
+++ b/src/main/java/net/minecraft/network/chat/OutgoingChatMessage.java
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.minecraft.network.chat;
|
||||
|
||||
+import me.totalfreedom.scissors.ScissorsConfig;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
|
||||
public interface OutgoingChatMessage {
|
||||
@@ -44,10 +45,22 @@ public interface OutgoingChatMessage {
|
||||
// Paper end
|
||||
PlayerChatMessage playerChatMessage = this.message.filter(filterMaskEnabled);
|
||||
playerChatMessage = unsigned != null ? playerChatMessage.withUnsignedContent(unsigned) : playerChatMessage; // Paper
|
||||
- if (!playerChatMessage.isFullyFiltered()) {
|
||||
+ // Sccissors 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 85a8a687b1568a56e3e646b37ef78b562c1b8a82..68e2edd39dcbcc9199aeaecff9b3280914ba9270 100644
|
||||
--- a/src/main/java/net/minecraft/network/chat/SignedMessageChain.java
|
||||
+++ b/src/main/java/net/minecraft/network/chat/SignedMessageChain.java
|
||||
@@ -5,6 +5,8 @@ import java.time.Instant;
|
||||
import java.util.UUID;
|
||||
import java.util.function.BooleanSupplier;
|
||||
import javax.annotation.Nullable;
|
||||
+
|
||||
+import me.totalfreedom.scissors.ScissorsConfig;
|
||||
import net.minecraft.util.SignatureUpdater;
|
||||
import net.minecraft.util.SignatureValidator;
|
||||
import net.minecraft.util.Signer;
|
||||
@@ -46,7 +48,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 acb4a7ad68a1d6c1ba43eafdd85ab5f824621507..e2f434d509be8b523de916d15eb625fe85a58749 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; // Scissors
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.primitives.Floats;
|
||||
@@ -2243,7 +2244,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
||||
|
||||
private void handleMessageDecodeFailure(SignedMessageChain.DecodeException exception) {
|
||||
ServerGamePacketListenerImpl.LOGGER.warn("Failed to update secure chat state for {}: '{}'", this.player.getGameProfile().getName(), exception.getComponent().getString());
|
||||
- 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));
|
||||
@@ -2291,6 +2292,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
|
||||
}
|
||||
@@ -2486,6 +2488,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
|
||||
}
|
||||
@@ -3464,6 +3467,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();
|
@ -0,0 +1,76 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Telesphoreo <me@telesphoreo.me>
|
||||
Date: Sun, 10 Dec 2023 18:57:50 -0600
|
||||
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 d87ffb5ed4550757016c2fabaa2845a6aaac74d7..7e8cf65ac53f595292d161da0735bf97081e832a 100644
|
||||
--- a/src/main/java/net/minecraft/advancements/critereon/MinMaxBounds.java
|
||||
+++ b/src/main/java/net/minecraft/advancements/critereon/MinMaxBounds.java
|
||||
@@ -123,11 +123,11 @@ 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> min, Optional<Double> max) {
|
||||
+ public Doubles(Optional<Double> min, Optional<Double> max) {
|
||||
this(min, max, squareOpt(min), squareOpt(max));
|
||||
- }
|
||||
+ } // Scissors - private -> public
|
||||
|
||||
private static MinMaxBounds.Doubles create(StringReader reader, Optional<Double> min, Optional<Double> max) throws CommandSyntaxException {
|
||||
if (min.isPresent() && max.isPresent() && min.get() > max.get()) {
|
||||
@@ -188,7 +188,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> min, Optional<Integer> max) {
|
||||
this(min, max, min.map((i) -> {
|
||||
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..f0a84efe86407ab3d7a9f064140c12df43265adc 100644
|
||||
--- a/src/main/java/net/minecraft/commands/arguments/selector/EntitySelector.java
|
||||
+++ b/src/main/java/net/minecraft/commands/arguments/selector/EntitySelector.java
|
||||
@@ -10,6 +10,8 @@ import java.util.function.BiConsumer;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Predicate;
|
||||
import javax.annotation.Nullable;
|
||||
+
|
||||
+import me.totalfreedom.scissors.MathUtility;
|
||||
import net.minecraft.advancements.critereon.MinMaxBounds;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.arguments.EntityArgument;
|
||||
@@ -60,9 +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;
|
@ -0,0 +1,19 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Allink <arclicious@vivaldi.net>
|
||||
Date: Mon, 20 Mar 2023 07:04:50 +0000
|
||||
Subject: [PATCH] Patch invalid entity rotation log spam
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index 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;
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
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);
|
36
patches/server/0038-Limit-map-decorations.patch
Normal file
36
patches/server/0038-Limit-map-decorations.patch
Normal file
@ -0,0 +1,36 @@
|
||||
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;
|
@ -0,0 +1,25 @@
|
||||
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
|
@ -0,0 +1,19 @@
|
||||
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);
|
Reference in New Issue
Block a user