DotCommand 1.0

./command now shows up as /command in chat

  1. Miles
    Tested Minecraft Versions:
    • 1.7
    • 1.8
    • 1.9
    This is a very simple and lightweight plugin. (So lightweight that its source is only 20 lines).

    What DotCommand does is remove the leading '.' when commands are typed in chat.

    When we're trying to show players how to run commands, we often prefix the command with a '.' in order for it to show up in chat. This is all fine and good, however this can sometimes confuse the more... beginner... players.

    To solve this, DotCommand changes the messages of those with the dotcommand.modify permission so that their ./command messages only show up as /command.

    For example, if I said "./command they should run", it would be turned into "/command they should run"

    Permissions:

    dotcommand.modify: players with this permission will have their ./command messages modified

    20-line source:
    Code (Text):
    package com.mdc.dotcommand;
    import org.bukkit.Bukkit;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.AsyncPlayerChatEvent;
    import org.bukkit.plugin.java.JavaPlugin;
    public class DotCommand extends JavaPlugin implements Listener {
        @Override
        public void onEnable(){
            Bukkit.getPluginManager().registerEvents(this, this);
        }
        @EventHandler
        public void onChat(AsyncPlayerChatEvent event){
            if(event.getPlayer().hasPermission("dotcommand.modify")){
                if(event.getMessage().startsWith("./")){
                    event.setMessage(event.getMessage().substring(1));
                }
            }
        }
    }