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

37 lines
1.6 KiB
Diff
Raw Normal View History

From 1c86bb208d4b82b050d3982ff3555f2f9735bc55 Mon Sep 17 00:00:00 2001
2017-06-18 08:53:31 +08: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 dd4570078e..a9e9cc6f4e 100644
2017-06-18 08:53:31 +08:00
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -79,6 +79,7 @@ import org.bukkit.craftbukkit.util.Versioning;
2017-06-18 08:53:31 +08:00
import org.bukkit.craftbukkit.util.permissions.CraftDefaultPermissions;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
2017-07-28 21:45:16 +08:00
+import org.bukkit.event.command.UnknownCommandEvent; // Paper
2017-06-18 08:53:31 +08:00
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.event.player.PlayerChatTabCompleteEvent;
2017-07-28 21:45:16 +08:00
import org.bukkit.event.server.BroadcastMessageEvent;
@@ -724,7 +725,13 @@ public final class CraftServer implements Server {
2017-06-18 08:53:31 +08:00
// Spigot start
if (!org.spigotmc.SpigotConfig.unknownCommandMessage.isEmpty()) {
2017-06-18 08:53:31 +08: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
--
2.18.0