mirror of
https://github.com/AtlasMediaGroup/Scissors.git
synced 2024-11-01 12:37:10 +00:00
38 lines
1.9 KiB
Diff
38 lines
1.9 KiB
Diff
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 d0a7490c153e7968c657a525908de58f60f26c20..807117124668040121c5252a10c33ad100c0b0da 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;
|
|
@@ -2898,6 +2899,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());
|
|
|