mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-27 13:06:02 +01:00
ffb572ce9a
Spigot has patched this issue inside MapIcon, meaning that we no longer need to maintain this patch; Spigots patch also fixes #668 in that it will verify the length of the array, as well as protect against a negative type value being fetched from the array. Only real change is that Spigots patch returns a MapIcon.Type.PLAYER, instead of the RED_MARKER as originally PR'd by Aikar.
82 lines
2.4 KiB
Diff
82 lines
2.4 KiB
Diff
From 89165c8a70cce041d5daead1b9aadc8f214798a9 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 00000000..e11f74fc
|
|
--- /dev/null
|
|
+++ b/src/main/java/com/destroystokyo/paper/event/player/IllegalPacketEvent.java
|
|
@@ -0,0 +1,63 @@
|
|
+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;
|
|
+
|
|
+public class IllegalPacketEvent extends PlayerEvent {
|
|
+ private final String type;
|
|
+ private final String ex;
|
|
+ private String kickMessage;
|
|
+ private boolean shouldKick = true;
|
|
+
|
|
+ public IllegalPacketEvent(Player player, String type, String kickMessage, 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;
|
|
+ }
|
|
+
|
|
+ public String getKickMessage() {
|
|
+ return kickMessage;
|
|
+ }
|
|
+
|
|
+ public void setKickMessage(String kickMessage) {
|
|
+ this.kickMessage = kickMessage;
|
|
+ }
|
|
+
|
|
+ public String getType() {
|
|
+ return type;
|
|
+ }
|
|
+
|
|
+ public String getExceptionMessage() {
|
|
+ return ex;
|
|
+ }
|
|
+
|
|
+ private static final HandlerList handlers = new HandlerList();
|
|
+
|
|
+ public HandlerList getHandlers() {
|
|
+ return handlers;
|
|
+ }
|
|
+
|
|
+ public static HandlerList getHandlerList() {
|
|
+ return handlers;
|
|
+ }
|
|
+
|
|
+ public static void process(Player player, String type, String kickMessage, 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.12.2
|
|
|