Blocking /minecraft:me in plugin

Discussion in 'Plugin Development' started by flash110, Jul 10, 2016.

Thread Status:
Not open for further replies.
  1. Offline

    flash110

    Hello, so today I noticed that blocking commands like /me is easy by creating and overwriting them in your own plugin, but how would I go about overwriting commands with : in them? I do not want to use permissions and negate it.
     
  2. Offline

    CeramicTitan Retired Staff

    if string contains(":"), event.setCancelled(true);
     
  3. Offline

    adagi

    Player» My coords: 143,852
    The event would be cancelled and the message wouldn't be sent. So, you could use #contains("/minecraft:me") etc.

    Gesendet via Tapatalk auf meinem Honor 7. ❤
     
  4. Offline

    cococow123

    Use #startsWith("/minecraft:me ")..

    If a player said a message containing it, it would also cancel it.

    Also put a space after (like the example above) to make sure it is the full command.
     
    adagi likes this.
  5. Offline

    CeramicTitan Retired Staff

    Assuming you use the chat event...
     
  6. Offline

    DarkenCake

    Code:
        @EventHandler
        public void onMinecraftMe(PlayerCommandPreprocessEvent event) {
            Player p = event.getPlayer();
           
            if (event.getMessage().startsWith("/minecraft:")) {
                event.setCancelled(true);
            }
        }
     
  7. Offline

    FisheyLP

    Good starting point but not perfect. Players can still exploit it by writing "/minEcraft:me" for example

    Check if event.getMessage().toLowerCase() starts with "/minecraft:me" and then cancel
     
    cococow123 and ChipDev like this.
  8. Offline

    mine-care

    cococow123 likes this.
Thread Status:
Not open for further replies.

Share This Page