Paper/Spigot-Server-Patches/0153-Add-UnknownCommandEvent.patch

42 lines
1.9 KiB
Diff
Raw Normal View History

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2017-06-18 02:53:31 +02:00
From: Sweepyoface <github@sweepy.pw>
Date: Sat, 17 Jun 2017 18:48:21 -0400
Subject: [PATCH] Add UnknownCommandEvent
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 681a84e5b3e7594a43fac0d47f1df2eef310bf81..f01bd38d0b600a69224f610fd77a542ec6d1c322 100644
2017-06-18 02:53:31 +02:00
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -80,6 +80,7 @@ import net.minecraft.server.WorldServer;
2019-05-06 05:53:47 +02:00
import net.minecraft.server.WorldSettings;
import net.minecraft.server.WorldType;
import org.apache.commons.lang.Validate;
+import org.apache.commons.lang3.StringUtils;
import org.bukkit.BanList;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
@@ -151,6 +152,7 @@ import org.bukkit.craftbukkit.util.Versioning;
2017-06-18 02:53:31 +02:00
import org.bukkit.craftbukkit.util.permissions.CraftDefaultPermissions;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
2017-07-28 15:45:16 +02:00
+import org.bukkit.event.command.UnknownCommandEvent; // Paper
2017-06-18 02:53:31 +02:00
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.event.player.PlayerChatTabCompleteEvent;
2017-07-28 15:45:16 +02:00
import org.bukkit.event.server.BroadcastMessageEvent;
@@ -751,7 +753,13 @@ public final class CraftServer implements Server {
2017-06-18 02:53:31 +02:00
// Spigot start
if (!org.spigotmc.SpigotConfig.unknownCommandMessage.isEmpty()) {
2017-06-18 02:53:31 +02:00
- sender.sendMessage(org.spigotmc.SpigotConfig.unknownCommandMessage);
+ // Paper start
+ UnknownCommandEvent event = new UnknownCommandEvent(sender, commandLine, org.spigotmc.SpigotConfig.unknownCommandMessage);
+ Bukkit.getServer().getPluginManager().callEvent(event);
+ if (StringUtils.isNotEmpty(event.getMessage())) {
+ sender.sendMessage(event.getMessage());
+ }
+ // Paper end
}
// Spigot end