Disable Title command successfully executed spamming console

Discussion in 'Spigot Plugin Development' started by SIndybad, Jun 20, 2015.

  1. Every time I do this:
    Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), command);
    which is related to titles, I get spammed with "Title command successfully executed"
    How can I disable this?



    EDIT: U_U
    EDIT2: Plz someone reply
     
    #1 SIndybad, Jun 20, 2015
    Last edited: Jun 23, 2015
  2. full code might be helpful
     
  3. Code (Text):
    //sendCommandFeedback
            HashMap<World, String> worldsFeedBack = new HashMap<World, String>();
            for(World world : Bukkit.getWorlds()){
                worldsFeedBack.put(world, world.getGameRuleValue("sendCommandFeedback"));
                world.setGameRuleValue("sendCommandFeedback", "false");
            }

            //logAdminCommands
            HashMap<World, String> worldsLog = new HashMap<World, String>();
            for(World world : Bukkit.getWorlds()){
                worldsLog.put(world, world.getGameRuleValue("logAdminCommands"));
                world.setGameRuleValue("logAdminCommands", "false");
            }

            //commandBlockOutput
            HashMap<World, String> worldsOutput = new HashMap<World, String>();
            for(World world : Bukkit.getWorlds()){
                worldsOutput.put(world, world.getGameRuleValue("commandBlockOutput"));
                world.setGameRuleValue("commandBlockOutput", "false");
            }

            for(World world : Bukkit.getWorlds()){
                logger.info(world.getGameRuleValue("sendCommandFeedback")+"");
            }
           
           
            Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), command);

           
           
            //sendCommandFeedback
            for(Entry<World, String> entry : worldsFeedBack.entrySet()){
                entry.getKey().setGameRuleValue("sendCommandFeedback", entry.getValue());
            }
           
            //logAdminCommands
            for(Entry<World, String> entry : worldsFeedBack.entrySet()){
                entry.getKey().setGameRuleValue("logAdminCommands", entry.getValue());
            }
           
            //commandBlockOutput
            for(Entry<World, String> entry : worldsFeedBack.entrySet()){
                entry.getKey().setGameRuleValue("commandBlockOutput", entry.getValue());
            }
     
  4. Tux

    Tux

    Are you trying to send titles to players? If so, you may want to try using a Java library for that.

    Otherwise, try implementing your own CommandSender with full permissions and no sendMessage() implementations. This should be simple with an IDE.
     
  5. 1) I don't really get why you not just create all your HashMaps and create just one loop for the worlds, instead of creating one HashMap, doing one complete loop, creating another HashMap, doing another complete loop, and so on.

    2) Most probably this is the problem:
     
  6. Related to 1) of my previous post:
    Code (Text):

            HashMap<World, String> worldsFeedBack = new HashMap<World, String>();
            HashMap<World, String> worldsLog = new HashMap<World, String>();
            HashMap<World, String> worldsOutput = new HashMap<World, String>();

            for(World world : Bukkit.getWorlds()){
                //sendCommandFeedback
                worldsFeedBack.put(world, world.getGameRuleValue("sendCommandFeedback"));
                world.setGameRuleValue("sendCommandFeedback", "false");
                //logAdminCommands
                worldsLog.put(world, world.getGameRuleValue("logAdminCommands"));
                world.setGameRuleValue("logAdminCommands", "false");
                //commandBlockOutput
                worldsOutput.put(world, world.getGameRuleValue("commandBlockOutput"));
                world.setGameRuleValue("commandBlockOutput", "false");
            }    
         
            Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), command);
         
            for(Entry<World, String> entry : worldsFeedBack.entrySet()){
                //sendCommandFeedback
                entry.getKey().setGameRuleValue("sendCommandFeedback", entry.getValue());
                //logAdminCommands
                entry.getKey().setGameRuleValue("logAdminCommands", entry.getValue());
                //commandBlockOutput
                entry.getKey().setGameRuleValue("commandBlockOutput", entry.getValue());
            }
    This would save you 4 complete loops.
     
    • Useful Useful x 1
  7. How do I implement CommandSender?
     
  8. Could it be possible that you are running the piece of code you gave us in a loop or something?

    @Tux Does the default ConsoleCommandSender report back on a command that gets executed by it?
    If "yes" then => Your solution
    If "no" then => It's most probably somewhere in his code still :)
     
  9. I think when you do "Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), command)", it doesn't pay attention to the gamerules... maybe
     
  10. I'm not relying on gamerules in most of my plugins anyways, as these are (speaking for me) most likely made for people inside the game with no access to the Spigot/Bukkit API. Anything you could achieve with a gamerule can also be achieved with a few lines of code most of the time :)
    Speaking of your problem: You might be right, because you are most likely working on a different level than where the gamerules would interfere.

    But still: Can you give a little bit more of sourroundings of the code?
     
  11. Ok, I've made a function that runs titles with commands, and it can be split up into multiple colors. However, the console is constantly getting spammed
     
  12. @Tux How would I implement CommandSender?
     
  13. @Tux How would I implement CommandSender?
    Bump
     
  14. Try executing the command directly, like this:
    Code (Text):

    Bukkit.getServer().getPluginCommand("commandnameWithoutArgs").execute(Bukkit.getConsoleSender(),"commandNameWithoutArgs",new String[]{"arg","arg"});
     
    So, if you wanted to issue the command /title @p 20, 60, 20 then you would do this:

    Code (Text):

    Bukkit.getServer().getPluginCommand("title").execute(Bukkit.getConsoleSender(),"title",new String[]{"@p","times", "20", "60", "20"});
     
    ;)
     
  15. Bukkit.getServer().getPluginCommand("title")
    always returns null... any ideas?
     
  16. depathCommand make the plugin slower pay attention!