[SOLVED]How do i replace the default Commands of Bukkit

Discussion in 'Plugin Development' started by philipp12484, Oct 25, 2011.

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

    philipp12484

    Hi,
    I wanted to ask how I change the standard commands of Bukkit.


    (sorry for bad english, im german)
     
  2. Just use a regular command that is called the same as the bukkit command, it will override the standard command.
     
  3. Offline

    philipp12484

    yea, actually i have done this but its says everytime that is the wrong command
    here my code:
    Code:
    public class MtgmcTeleportCommand extends VanillaCommand {
        public MtgmcTeleportCommand() {
            super("tp");
            this.description = "Teleportiert den Spieler zu einem anderen.";
            this.usageMessage = "/tp <ziel>";
            this.setPermission("bukkit.command.teleport");
            plugin = plugin;
        }
    
        public Mtgmc plugin;
    
        @Override
        public boolean execute(CommandSender sender, String currentAlias, String[] args) {
            if(!testPermission(sender)) return true;
            if(args.length != 1) {
                sender.sendMessage(ChatColor.RED + "Verwendung: " + userMessage);
                return false;
            }
    
            Player p = (Player)sender;
            Player ziel = Bukkit.getPlayerExact(args[0]);
    
            if(ziel == null) {
                p.sendMessage("Konnte Benutzer: " + args[0] + "nicht finden.");
            } else {
                Command.broadcastCommandMessage(sender, "Teleportiert " + p.getName() + " zu " + ziel.getName());
                p.teleport(ziel);
            }
            return true;
        }
    
        @Override
        public boolean matches(String input) {
            return input.startsWith("tp ") || input.startsWith("tp");
     
  4. Offline

    philipp12484

    now i have register the commands like in the tutorial:
    PHP:
    commands:
      
    tp:
         
    descriptionDer Befehl Teleportiert spieler.
         
    permissionMtgmc.tp
         usage
    : /<command> [player]
      
    heal:
        
    descriptionDer Befehl heilt Spieler.
        
    permissionMtgmc.heal
        usage
    : /<command>
      
    epl:
        
    descriptionDer Befehl laesst Spieler explodieren
        permission
    Mtgmc.epl
        usage
    : /<command>
      
    gm0:
        
    descriptionDer Befehl switcht den Spieler in den Creative Modus.
        
    permissionMtgmc.gm0
        usage
    : /<command>
      
    gm1:
        
    descriptionDer Befehl switcht den Spieler in den Survival Modus
    but i became an error that says: "Bukkit sad. Bukit want you to access command, but Bukkit cannot let you. Bukkit will leak tears".
     
  5. The description of the linked tutorial is a little outdated according the "permissions" part of the command.
    Since native bukkit permissions were introduced, bukkit will check if you have the here specified permissions before letting you access the command.
    If you don't want to use permissions, just leave that part out, otherwise you have to give yourself the permissions to be able to use the command (using a permissions plugin or defaults, but that's another topic).
     
  6. Offline

    stelar7

    for some reason, when i tried with /pl(/plugins) it didn't work...
     
  7. Offline

    philipp12484

    ok thanks for the support guys, i solved the problem :) .
     
  8. Offline

    BaumwolleHD

Thread Status:
Not open for further replies.

Share This Page