5c7081fecc
* Updated Upstream (Bukkit/CraftBukkit) Upstream has released updates that appears to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: 45690fe9 SPIGOT-5047: Correct slot types for 1.14 inventories CraftBukkit Changes: 4090d01f SPIGOT-5047: Correct slot types for 1.14 inventories e8c08362 SPIGOT-5046: World#getLoadedChunks returning inaccessible cached chunks. d445af3b SPIGOT-5067: Add item meta for 1.14 spawn eggs * Bring Chunk load checks in-line with spigot As of the last upstream merge spigot now checks ticket level status when returning loaded chunks for a world from api. Now our checks will respect that decision. * Fix spawn ticket levels Vanilla would keep the inner chunks of spawn available for ticking, however my changes made all chunks non-ticking. Resolve by changing ticket levels for spawn chunks inside the border to respect this behavior. * Make World#getChunkIfLoadedImmediately return only entity ticking chunks Mojang appears to be using chunks with level > 33 (non-ticking chunks) as cached chunks and not actually loaded chunks. * Bring all loaded checks in line with spigot Loaded chunks must be at least border chunks, or level <= 33
88 lines
2.6 KiB
Diff
88 lines
2.6 KiB
Diff
From a8f5ece74e38bb84395fa50e72af2d7ecb6fb1c9 Mon Sep 17 00:00:00 2001
|
|
From: Aikar <aikar@aikar.co>
|
|
Date: Sun, 4 Dec 2016 01:19:14 -0500
|
|
Subject: [PATCH] IllegalPacketEvent
|
|
|
|
Fire an event when an illegal packet is received to let plugins handle it
|
|
|
|
Lets plugins change the kick message and if it should kick or not.
|
|
|
|
diff --git a/src/main/java/com/destroystokyo/paper/event/player/IllegalPacketEvent.java b/src/main/java/com/destroystokyo/paper/event/player/IllegalPacketEvent.java
|
|
new file mode 100644
|
|
index 000000000..37a17f0bb
|
|
--- /dev/null
|
|
+++ b/src/main/java/com/destroystokyo/paper/event/player/IllegalPacketEvent.java
|
|
@@ -0,0 +1,70 @@
|
|
+package com.destroystokyo.paper.event.player;
|
|
+
|
|
+import org.bukkit.Bukkit;
|
|
+import org.bukkit.entity.Player;
|
|
+import org.bukkit.event.HandlerList;
|
|
+import org.bukkit.event.player.PlayerEvent;
|
|
+import org.jetbrains.annotations.NotNull;
|
|
+import org.jetbrains.annotations.Nullable;
|
|
+
|
|
+public class IllegalPacketEvent extends PlayerEvent {
|
|
+ @Nullable private final String type;
|
|
+ @Nullable private final String ex;
|
|
+ @Nullable private String kickMessage;
|
|
+ private boolean shouldKick = true;
|
|
+
|
|
+ public IllegalPacketEvent(@NotNull Player player, @Nullable String type, @Nullable String kickMessage, @NotNull Exception e) {
|
|
+ super(player);
|
|
+ this.type = type;
|
|
+ this.kickMessage = kickMessage;
|
|
+ this.ex = e.getMessage();
|
|
+ }
|
|
+
|
|
+ public boolean isShouldKick() {
|
|
+ return shouldKick;
|
|
+ }
|
|
+
|
|
+ public void setShouldKick(boolean shouldKick) {
|
|
+ this.shouldKick = shouldKick;
|
|
+ }
|
|
+
|
|
+ @Nullable
|
|
+ public String getKickMessage() {
|
|
+ return kickMessage;
|
|
+ }
|
|
+
|
|
+ public void setKickMessage(@Nullable String kickMessage) {
|
|
+ this.kickMessage = kickMessage;
|
|
+ }
|
|
+
|
|
+ @Nullable
|
|
+ public String getType() {
|
|
+ return type;
|
|
+ }
|
|
+
|
|
+ @Nullable
|
|
+ public String getExceptionMessage() {
|
|
+ return ex;
|
|
+ }
|
|
+
|
|
+ private static final HandlerList handlers = new HandlerList();
|
|
+
|
|
+ @NotNull
|
|
+ public HandlerList getHandlers() {
|
|
+ return handlers;
|
|
+ }
|
|
+
|
|
+ @NotNull
|
|
+ public static HandlerList getHandlerList() {
|
|
+ return handlers;
|
|
+ }
|
|
+
|
|
+ public static void process(@NotNull Player player, @Nullable String type, @Nullable String kickMessage, @NotNull Exception exception) {
|
|
+ IllegalPacketEvent event = new IllegalPacketEvent(player, type, kickMessage, exception);
|
|
+ event.callEvent();
|
|
+ if (event.shouldKick) {
|
|
+ player.kickPlayer(kickMessage);
|
|
+ }
|
|
+ Bukkit.getLogger().severe(player.getName() + "/" + type + ": " + exception.getMessage());
|
|
+ }
|
|
+}
|
|
--
|
|
2.21.0
|
|
|