mirror of
https://github.com/AtlasMediaGroup/Scissors.git
synced 2024-11-27 07:05:39 +00:00
38 lines
1.9 KiB
Diff
38 lines
1.9 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Telesphoreo <me@telesphoreo.me>
|
|
Date: Sat, 11 May 2024 13:04:21 -0500
|
|
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 2b93d90da92559da021bac81bb3bc0a4e556ffb6..f8c6d5e2e384e3cf549c68b71c77b0f376cf32f0 100644
|
|
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
@@ -31,6 +31,7 @@ import java.util.stream.Stream;
|
|
import javax.annotation.Nullable;
|
|
|
|
import me.totalfreedom.scissors.event.player.SpectatorTeleportEvent;
|
|
+import net.kyori.adventure.text.format.NamedTextColor;
|
|
import net.minecraft.ChatFormatting;
|
|
import net.minecraft.Util;
|
|
import net.minecraft.advancements.AdvancementHolder;
|
|
@@ -2964,6 +2965,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());
|
|
|