Compare commits
3 Commits
a33204b7b8
...
deb42dbe25
Author | SHA1 | Date | |
---|---|---|---|
deb42dbe25 | |||
f890521e7a | |||
44ba3cd7ab |
9
.drone.yml
Normal file
9
.drone.yml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
kind: pipeline
|
||||||
|
name: default
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: build
|
||||||
|
image: maven:3-eclipse-temurin-17
|
||||||
|
commands:
|
||||||
|
- mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V
|
||||||
|
- mvn test -B
|
@ -4,13 +4,24 @@ import org.bukkit.event.EventHandler;
|
|||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class CommandCanceller implements Listener
|
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
|
@EventHandler
|
||||||
public void onCommand(PlayerCommandPreprocessEvent event)
|
public void onCommand(PlayerCommandPreprocessEvent event)
|
||||||
{
|
{
|
||||||
// block literally all commands (except from proxy ones)
|
if(!event.getMessage().matches(allowedCmdsRegex))
|
||||||
|
// block all commands (except from proxy and allowed ones)
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user