1.13.2 Executing commands silently in console

Discussion in 'Spigot Plugin Development' started by Atomix, Jan 29, 2020.

  1. Basically i needed to find a way to execute a command without leaving its output in the console and from what i found this is the only way? I saw creating a new ConsoleCommandSender will do. It really did the job but the commands arent executed at all now so i was wondering if im missing something or if there is another way to do the whole thing?
     
  2. Why do you need to hide the output from console? This seems pretty malicious.

    Regardless, are you able to post any code, other than just saying the commands aren't getting executed?
     
  3. Its because of my plugin system. Basically there are events at which Id like to let the user execute whatever commands they want and since some of the events are with while statement (like repeating for a while) the console gets way too spammed so id like to prevent that.
    As for the code its only creating the new ConsoleCommandSender...here for simple example:
    Code (Java):
        static ConsoleCommandSender silentConsole() {
            return new ConsoleCommandSender() {

                @Override
                public void sendRawMessage(String paramString) {}

                @Override
                public boolean isConversing() {
                    return false;
                }

                @Override
                public boolean beginConversation(Conversation paramConversation) {
                    return false;
                }

                @Override
                public void acceptConversationInput(String paramString) {}

                @Override
                public void abandonConversation(Conversation paramConversation,
                        ConversationAbandonedEvent paramConversationAbandonedEvent) {}

                @Override
                public void abandonConversation(Conversation paramConversation) {}

                @Override
                public void setOp(boolean paramBoolean) {}

                @Override
                public boolean isOp() {
                    return false;
                }

                @Override
                public void removeAttachment(PermissionAttachment paramPermissionAttachment) {}

                @Override
                public void recalculatePermissions() {}

                @Override
                public boolean isPermissionSet(Permission paramPermission) {
                    return false;
                }

                @Override
                public boolean isPermissionSet(String paramString) {
                    return false;
                }

                @Override
                public boolean hasPermission(Permission paramPermission) {
                    return false;
                }

                @Override
                public boolean hasPermission(String paramString) {
                    return false;
                }

                @Override
                public Set<PermissionAttachmentInfo> getEffectivePermissions() {
                    return null;
                }

                @Override
                public PermissionAttachment addAttachment(Plugin paramPlugin, String paramString,
                        boolean paramBoolean, int paramInt) {
                    return null;
                }

                @Override
                public PermissionAttachment addAttachment(Plugin paramPlugin, String paramString,
                        boolean paramBoolean) {
                    return null;
                }

                @Override
                public PermissionAttachment addAttachment(Plugin paramPlugin, int paramInt) {
                    return null;
                }

                @Override
                public PermissionAttachment addAttachment(Plugin paramPlugin) {
                    return null;
                }

                @Override
                public Spigot spigot() {
                    return null;
                }

                @Override
                public void sendMessage(String[] paramArrayOfString) {}

                @Override
                public void sendMessage(String paramString) {

                }

                @Override
                public Server getServer() {
                    return null;
                }

                @Override
                public String getName() {
                    return null;
                }
            };
        }

        static void RepeatingScheduler(String cmd) {
            ...
            Bukkit.dispatchCommand(silentConsole(), cmd);
            ...
        }
     
  4. Looks to me that you already figured it out.
     
  5. Yeah i silenced the commands but they wont execute now...so im just guessing but maybe i should fill some of the overriding methods with something and i have no clue which and with what

    EDIT: I might have figured something out. Im currently using the bukkit server console command sender and i got the commands to work. Now to see which will silence the output ill try commenting the code inside overriding methods and see what happens

    EDIT2: It appears that the server is an essential part and with it, it executes the commands with output and without it, it doesnt execute the commands at all and gives warns about it being null...so i guess there is no really way?
     
    #5 Atomix, Jan 29, 2020
    Last edited: Jan 29, 2020