Solved Filtering out console commands.

Discussion in 'Plugin Development' started by BlueMustache, Jul 7, 2014.

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

    BlueMustache

    EDIT: New idea, how might I filter out a command.
    Say I run /tp, how might I filter out any output from the global chat, and the console.

    Greetings Community,
    I was wondering if there was an easy way to do this?
    On my friends server, I am making a custom plugin.
    The way that we play the game, we can teleport to people on our team, and no one else. (This does include coordinates.)
    The problem is, when someone teleports, it tells the whole world "BlueMustache teleported to 0.5, 0.5, 0.5", or something to that order. I am trying to get rid of that.
    I have tried being a proxy to the tp command, but that doesn't work.
    My best attempt was this.

    Code:java
    1. @EventHandler
    2. public void onTeleportCommand(PlayerTeleportEvent e){
    3. if (e.getCause().equals(TeleportCause.COMMAND)) {
    4. Player target = e.getPlayer();
    5. Location to = e.getTo();
    6. e.setCancelled(true);
    7. target.teleport(to, TeleportCause.PLUGIN);
    8. } else {
    9. return;
    10. }
    11. }


    This did work, but it was basically pointless.
    Thesis:
    Is there a way to edit the teleport command to not say anything in the console or to everyone else?
    Please help!
    Response needed asap.
    Thanks.
    -Blue
     
  2. Offline

    Wizehh

    Couldn't you just make your own teleportation command? That, or modify Craftbukkit's source code.
     
  3. Offline

    BlueMustache

    Wizehh
    Yes, that is aw way to do it.
    I tried it.
    I would like a simpler way.
    More like a patch.
     
  4. Offline

    macboinc

    Try typing this command to the server: /gamerule commandBlockOutput false
     
  5. Offline

    BlueMustache

    macboinc
    I had already typed that, that had no affect.
    I just want to nullify the message that is broadcast to the console, and the players, about me teleporting.
    Any ideas?
     
  6. Offline

    HungerCraftNL

    Make an own command like this
    PHP:
    public boolean onCommand(CommandSender senderCommand cmdString labelString[] args){
      if(!(
    sender instanceof Player)){
        
    sender.sendMessage("You can't run this command!");
        return 
    true;
      }
      
    Player p = (Playersender;
      if(
    cmd.getName().equalsIgnoreCase("tp")){
        if(
    args.length == 1){
          
    Player t Bukkit.getPlayer(args[1]);
          
    p.teleport(t);
          
    p.sendMessage("You have teleported to " t.getName());
        }
      }
      return 
    false;
    }
     
  7. Offline

    BlueMustache

    HungerCraftNL
    Thanks for that.
    Problem is.
    That is good, but I am trying not to re write the command.
    Even if I have to, It takes a long time to rewrite that for all factory features.

    EDIT: Also, I am use PlayerCommandPreprocessEvent, instead, so the args are confusing.

    Bump

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
  8. Offline

    xTigerRebornx

    BlueMustache I believe the gamerule to do this is being added in 1.8 (logAdminCommands).
    Creating your own command is a valid solution for now, and who says you have to rewrite it? Simply remove the logging of the teleport in your command?
     
  9. Offline

    BlueMustache

    xTigerRebornx
    You are a genius!
    Thanks!
    This is a 1.4.7 War server, but rewriting the command will work now that you found that.
    -Blue

    EDIT: I guess I'm not one, I spelled genius wrong. :p
     
Thread Status:
Not open for further replies.

Share This Page