Workaround for Unknown command

This commit is contained in:
Norbi Peti 2016-03-08 18:49:08 +01:00
parent 0e55cf89da
commit 91a1cbcbdc
4 changed files with 11 additions and 10 deletions

Binary file not shown.

View file

@ -18,6 +18,7 @@ commands:
mwiki: mwiki:
description: Search the wiki. description: Search the wiki.
usage: "&vUsage: /mwiki [query]&r" usage: "&vUsage: /mwiki [query]&r"
dontrunthiscmd:
author: NorbiPeti author: NorbiPeti
depend: [Essentials, Towny, Minigames, Votifier, Factions] depend: [Essentials, Towny, Minigames, Votifier, Factions]
permissions: permissions:

View file

@ -645,7 +645,7 @@ public class PlayerListener implements Listener {
event.getSender().sendMessage( event.getSender().sendMessage(
"§6You are now talking in: §b" "§6You are now talking in: §b"
+ ConsoleChannel.DisplayName); + ConsoleChannel.DisplayName);
event.setCancelled(true); event.setCommand("dontrunthiscmd");
} else if (cmd.equalsIgnoreCase(Channel.AdminChat.Command)) { } else if (cmd.equalsIgnoreCase(Channel.AdminChat.Command)) {
if (ConsoleChannel.equals(Channel.AdminChat)) if (ConsoleChannel.equals(Channel.AdminChat))
ConsoleChannel = Channel.GlobalChat; ConsoleChannel = Channel.GlobalChat;
@ -654,7 +654,7 @@ public class PlayerListener implements Listener {
event.getSender().sendMessage( event.getSender().sendMessage(
"§6You are now talking in: §b" "§6You are now talking in: §b"
+ ConsoleChannel.DisplayName); + ConsoleChannel.DisplayName);
event.setCancelled(true); event.setCommand("dontrunthiscmd");
} else if (cmd.equalsIgnoreCase(Channel.ModChat.Command)) { } else if (cmd.equalsIgnoreCase(Channel.ModChat.Command)) {
if (ConsoleChannel.equals(Channel.ModChat)) if (ConsoleChannel.equals(Channel.ModChat))
ConsoleChannel = Channel.GlobalChat; ConsoleChannel = Channel.GlobalChat;
@ -663,50 +663,50 @@ public class PlayerListener implements Listener {
event.getSender().sendMessage( event.getSender().sendMessage(
"§6You are now talking in: §b" "§6You are now talking in: §b"
+ ConsoleChannel.DisplayName); + ConsoleChannel.DisplayName);
event.setCancelled(true); event.setCommand("dontrunthiscmd");
} }
} else { } else {
cmd = event.getCommand().substring(0, index); cmd = event.getCommand().substring(0, index);
if (cmd.equalsIgnoreCase(Channel.GlobalChat.Command)) { if (cmd.equalsIgnoreCase(Channel.GlobalChat.Command)) {
event.setCancelled(true);
Channel c = ConsoleChannel; Channel c = ConsoleChannel;
ConsoleChannel = Channel.GlobalChat; ConsoleChannel = Channel.GlobalChat;
ChatProcessing.ProcessChat(Bukkit.getServer() ChatProcessing.ProcessChat(Bukkit.getServer()
.getConsoleSender(), .getConsoleSender(),
event.getCommand().substring(index + 1)); event.getCommand().substring(index + 1));
ConsoleChannel = c; ConsoleChannel = c;
event.setCommand("dontrunthiscmd");
} else if (cmd.equalsIgnoreCase(Channel.TownChat.Command)) { } else if (cmd.equalsIgnoreCase(Channel.TownChat.Command)) {
event.setCancelled(true);
Channel c = ConsoleChannel; Channel c = ConsoleChannel;
ConsoleChannel = Channel.TownChat; ConsoleChannel = Channel.TownChat;
ChatProcessing.ProcessChat(Bukkit.getServer() ChatProcessing.ProcessChat(Bukkit.getServer()
.getConsoleSender(), .getConsoleSender(),
event.getCommand().substring(index + 1)); event.getCommand().substring(index + 1));
ConsoleChannel = c; ConsoleChannel = c;
event.setCommand("dontrunthiscmd");
} else if (cmd.equalsIgnoreCase(Channel.NationChat.Command)) { } else if (cmd.equalsIgnoreCase(Channel.NationChat.Command)) {
event.setCancelled(true);
Channel c = ConsoleChannel; Channel c = ConsoleChannel;
ConsoleChannel = Channel.NationChat; ConsoleChannel = Channel.NationChat;
ChatProcessing.ProcessChat(Bukkit.getServer() ChatProcessing.ProcessChat(Bukkit.getServer()
.getConsoleSender(), .getConsoleSender(),
event.getCommand().substring(index + 1)); event.getCommand().substring(index + 1));
ConsoleChannel = c; ConsoleChannel = c;
event.setCommand("dontrunthiscmd");
} else if (cmd.equalsIgnoreCase(Channel.AdminChat.Command)) { } else if (cmd.equalsIgnoreCase(Channel.AdminChat.Command)) {
event.setCancelled(true);
Channel c = ConsoleChannel; Channel c = ConsoleChannel;
ConsoleChannel = Channel.AdminChat; ConsoleChannel = Channel.AdminChat;
ChatProcessing.ProcessChat(Bukkit.getServer() ChatProcessing.ProcessChat(Bukkit.getServer()
.getConsoleSender(), .getConsoleSender(),
event.getCommand().substring(index + 1)); event.getCommand().substring(index + 1));
ConsoleChannel = c; ConsoleChannel = c;
event.setCommand("dontrunthiscmd");
} else if (cmd.equalsIgnoreCase(Channel.ModChat.Command)) { } else if (cmd.equalsIgnoreCase(Channel.ModChat.Command)) {
event.setCancelled(true);
Channel c = ConsoleChannel; Channel c = ConsoleChannel;
ConsoleChannel = Channel.ModChat; ConsoleChannel = Channel.ModChat;
ChatProcessing.ProcessChat(Bukkit.getServer() ChatProcessing.ProcessChat(Bukkit.getServer()
.getConsoleSender(), .getConsoleSender(),
event.getCommand().substring(index + 1)); event.getCommand().substring(index + 1));
ConsoleChannel = c; ConsoleChannel = c;
event.setCommand("dontrunthiscmd");
} }
} }
if (cmd.toLowerCase().startsWith("un")) { if (cmd.toLowerCase().startsWith("un")) {
@ -722,7 +722,7 @@ public class PlayerListener implements Listener {
if (target == null) { if (target == null) {
event.getSender().sendMessage( event.getSender().sendMessage(
"§cError: Player not found. (/un" + s + " <player>)"); "§cError: Player not found. (/un" + s + " <player>)");
event.setCancelled(true); event.setCommand("dontrunthiscmd");
} }
if (target != null) { if (target != null) {
target.addPotionEffect(new PotionEffect( target.addPotionEffect(new PotionEffect(
@ -735,7 +735,7 @@ public class PlayerListener implements Listener {
.sendMessage( .sendMessage(
event.getSender().getName() + " un" + s + "'d " event.getSender().getName() + " un" + s + "'d "
+ target.getDisplayName()); + target.getDisplayName());
event.setCancelled(true); event.setCommand("dontrunthiscmd");
} }
} }
} }