Beatrice DellacĂ
09396fa09a
All checks were successful
continuous-integration/drone/push Build is passing
25 lines
813 B
Java
25 lines
813 B
Java
package wtf.beatrice.limbomanager.listeners;
|
|
|
|
import org.bukkit.event.EventHandler;
|
|
import org.bukkit.event.Listener;
|
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
|
|
|
public class CommandCanceller implements Listener
|
|
{
|
|
|
|
private final static String allowedCmdsRegex = "\\/(login|register|changepassword|premium|cracked|spawn)\\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)
|
|
{
|
|
if(!event.getMessage().matches(allowedCmdsRegex))
|
|
// block all commands (except from proxy and allowed ones)
|
|
event.setCancelled(true);
|
|
}
|
|
}
|