Hiding commands from /[Tab] 1.13.1

Discussion in 'Plugin Development' started by awesomebutter234, Nov 24, 2018.

Thread Status:
Not open for further replies.
  1. In 1.12.2 PacketPlayOutTabComplete fired when this was done, but now it only fires when I'm putting in the arguments for the command.
    How would I go about stopping the command list from popping up?



    Edit:
    I managed to find out what holds the commands, and found out that commands like /trigger have their permission set to null, which meant anyone could use it. I was able to modify via reflection to get the commands to not show up, problem is that now my own plugin's commands don't work.

    Code:
    CraftServer server = (CraftServer)Bukkit.getServer();
    
                    HashMap<String,Command> hope =new HashMap<String,Command>();
                    for(Command co : server.getCommandMap().getCommands())
                    {
                        //co.testPermissionSilent(null);
                            if(co.getPermission() == null || co.getPermission().equals("null"))
                            {
                                co.setPermission("nada");
                            }
      
                            if(Arrays.asList(new String[] {"plugins","?","ver","version","help","me","trigger"}).contains(co.getName()))
                            {
                                co.setPermission("nada");
                            }
                            if(Arrays.asList(new String[] {"bukkit.command.help","minecraft.command.msg"}).contains(co.getPermission()))
                            {
                                co.setPermission("nada");
                            }
                      
                        hope.put(co.getName(), co);
                        Bukkit.getLogger().info("CMD: "+ co.getName() +"  " +co.getPermission() );
                    }
                  
                    Field f = null;
                    try {
                        f = SimpleCommandMap.class.getDeclaredField("knownCommands");
                    } catch (NoSuchFieldException | SecurityException e1) {
                        // TODO Auto-generated catch block
                        e1.printStackTrace();
                    }
                    if(f != null)
                    {
                        f.setAccessible(true);
                        try {
                          
                            f.set(server.getCommandMap(),hope);
                            Bukkit.getLogger().info("Success!");
                          
                        } catch (IllegalArgumentException e1) {
                            // TODO Auto-generated catch block
                            e1.printStackTrace();
                        } catch (IllegalAccessException e1) {
                            // TODO Auto-generated catch block
                            e1.printStackTrace();
                        }
                    }
     
    Last edited: Nov 24, 2018
  2. Offline

    Zombie_Striker

Thread Status:
Not open for further replies.

Share This Page