|
|
|
@ -4,13 +4,24 @@ import org.bukkit.event.EventHandler;
|
|
|
|
|
import org.bukkit.event.Listener;
|
|
|
|
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
public class CommandCanceller implements Listener
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
private final static String allowedCmdsRegex = "\\/(login|register|changepassword)\\b";
|
|
|
|
|
/*
|
|
|
|
|
first "/" is the command prefix
|
|
|
|
|
(login|register|...) means either one or the other
|
|
|
|
|
\b means end of word (end of string, whitespace, ...) so NO other characters (like /loginabc)
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
@EventHandler
|
|
|
|
|
public void onCommand(PlayerCommandPreprocessEvent event)
|
|
|
|
|
{
|
|
|
|
|
// block literally all commands (except from proxy ones)
|
|
|
|
|
event.setCancelled(true);
|
|
|
|
|
if(!event.getMessage().matches(allowedCmdsRegex))
|
|
|
|
|
// block all commands (except from proxy and allowed ones)
|
|
|
|
|
event.setCancelled(true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|