Compare commits

...

3 Commits

Author SHA1 Message Date
deb42dbe25 Fix DroneCI support
All checks were successful
continuous-integration/drone/push Build is passing
2022-11-11 18:37:25 +01:00
f890521e7a Add DroneCI support 2022-11-11 18:36:57 +01:00
44ba3cd7ab Allow exceptions to commands 2022-11-11 18:31:46 +01:00
2 changed files with 22 additions and 2 deletions

9
.drone.yml Normal file
View 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

View File

@ -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))
event.setCancelled(true); // block all commands (except from proxy and allowed ones)
event.setCancelled(true);
} }
} }