BlueTree242 / AdvancedPlHide

A plugin that allows you to remove parts of tab completion and hide plugins from the tabcompleter!
GNU General Public License v3.0
9 stars 4 forks source link

Hide player name tab complete #6

Open vaporvee opened 2 years ago

vaporvee commented 2 years ago

Is it possible to hide the suggestion for player names? Would be cool because the plugin is mainly about disabling tab complete and commands

BlueTree242 commented 2 years ago

yes, spectific players, or hide all except

vaporvee commented 2 years ago

for me its enough when i can just hide all players

BlueTree242 commented 2 years ago

actually note that you can only do that for spectific commands

vaporvee commented 2 years ago

which specific commands? you mean normal in player chat theres still auto complete?

BlueTree242 commented 2 years ago

yes, also i see a good feature request in your message

masmc05 commented 2 years ago

won't it work on every command even if you hook into com.destroystokyo.paper.event.brigadier.AsyncPlayerSendSuggestionsEvent ? in the server code it is called right before sending the suggestions, with the final sugestions from the event

masmc05 commented 2 years ago

didn't worked with the brigadier so it's a bit confusing why we can't control it XD

masmc05 commented 2 years ago

from my testing, even vanilla commands don't use this request on basic arguments (like for /gamemode [client completes this by himselve] ), but request players, (like for /gamemode survival [will request completions from server] ), so you could filter a player from it

BlueTree242 commented 2 years ago

The plugin uses packets, not paper's event as it isnt complete. That's the plugin implementation i can easily get it to work on every command

BlueTree242 commented 2 years ago

Please wait for me i got a few features to be added soon

BlueTree242 commented 2 years ago

Yea! Vanilla commands dont use tab complete, it is only modified from packets or just that commands event

masmc05 commented 2 years ago

then how

@EventHandler
    public void onComplete(AsyncPlayerSendSuggestionsEvent event) {
        event.getSuggestions().getList().forEach(suggestion -> event.getPlayer().sendMessage(suggestion.getText()));
    }

was working with vanilla commands? if paper was able to implement the event, then it somehow should work behind the scenes, i'm using 1.18.1 btw

BlueTree242 commented 2 years ago

try it with non vanilla commands

masmc05 commented 2 years ago

works too

BlueTree242 commented 2 years ago

what command did you try

masmc05 commented 2 years ago

from advancedban

BlueTree242 commented 2 years ago

try calling getSuggestions

masmc05 commented 2 years ago
@EventHandler
    public void onComplete(AsyncPlayerSendSuggestionsEvent event) {
        event.getSuggestions().getList().clear();
    }

succesfully removed all existing suggestions from all the plugin's commands

masmc05 commented 2 years ago

try calling getSuggestions

what do you mean?

BlueTree242 commented 2 years ago

nvm

BlueTree242 commented 2 years ago

i would take a closer look then

masmc05 commented 2 years ago
@EventHandler
    public void onComplete(AsyncPlayerSendSuggestionsEvent event) {
        event.getSuggestions().getList().clear();
    }

succesfully removed all existing suggestions from all the plugin's commands

it didn't removed static suggestions like survival... from gamemode, but removed suggestions that may be different sometimes (like players on /gamemode survival)

BlueTree242 commented 2 years ago

that's what im trying to say

masmc05 commented 2 years ago

well, to filter players it is good, because he asks for players every time

masmc05 commented 2 years ago

and the event gives the opportunity to removes all the players from the suggestions even from vanilla commands

BlueTree242 commented 2 years ago

i don't see the purpose, remember this is a paper event, im trying to make it work on spigot too so i use packets

masmc05 commented 2 years ago

Yea! Vanilla commands dont use tab complete, it is only modified from packets or just that commands event

to say that he use tab completions when completing players, if the event is fired, then it means that he worked on these suggestions

BlueTree242 commented 2 years ago

i have a question, what do you mean by "he" it confuses me, do you mean player client?

masmc05 commented 2 years ago

yes

masmc05 commented 2 years ago

and vanilla also

BlueTree242 commented 2 years ago

ye not surprised, not tab completion event, its brigadier, its even in the package

masmc05 commented 2 years ago

well yes, vanilla uses brigardier from 1.13

BlueTree242 commented 2 years ago

lol dinnerbone added this in 1.13 so yes

masmc05 commented 2 years ago

brigardier is even open source, but as i know it don't have events, that's why paper-brigardier exists

BlueTree242 commented 2 years ago

Ye this plugin modifies it before being sent to client, no paper used

BlueTree242 commented 2 years ago

Currently didn't implement modifications on most parts of brigardier

BlueTree242 commented 2 years ago

This is also because of something i read before but not sure, that there is a argument type for players that the client automatically knows this is for players, probably asks server for player list so this is probably why there is no event on simply stuff like /gamemode creative because for the client its fixed values

masmc05 commented 2 years ago

image maybe it will help you, this is the packet with completions that is going to be sent to player when pressed tab with "/gamemode survival" in chat, idk how to use protocol lib so wish luck with blocking the players even in vanilla commands

BlueTree242 commented 2 years ago

What intellij plugin is that

BlueTree242 commented 2 years ago

Also i use that packet lol, but i dont think it can remove players but other stuff it can

masmc05 commented 2 years ago

that is it's debug menu, i don't use any plugins related to plugin development

masmc05 commented 2 years ago

image like no changes to it

BlueTree242 commented 2 years ago

Oh ye ur in the packet class lol

masmc05 commented 2 years ago

Also i use that packet lol, but i dont think it can remove players but other stuff it can

idk, in code it's arraylist, on protocol lib it's 1 value (or i'm just sleepy), but if you can't remove it, hide it (with "" at least), or create and send a new packet

BlueTree242 commented 2 years ago

Only way is doing modifications that may break sometimes

BlueTree242 commented 2 years ago

I guess the event should be modified

masmc05 commented 2 years ago

image image

ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(this, ListenerPriority.LOW, PacketType.Play.Server.TAB_COMPLETE) {
            @Override
            public void onPacketSending(PacketEvent event) {
                var suggestions  = event.getPacket().getSpecificModifier(Suggestions.class);
                suggestions.getValues().get(0).getList().add(new Suggestion(suggestions.getValues().get(0).getRange(),"This is the biggest test ever"));
                suggestions.getValues().get(0).getList().add(new Suggestion(suggestions.getValues().get(0).getRange(),"No jokes"));
                suggestions.getValues().forEach(suggestions1 -> {
                    var temp = new ArrayList<>(suggestions1.getList());
                    temp.forEach(suggestion -> {
                        if (suggestion.getText().equals("mastermc05")){
                            suggestions1.getList().remove(suggestion);
                        }
                    });
                });
            }
        });

managed to remove my name from every suggestion and add "this is the bigest test ever" to them, without touching other suggestions

masmc05 commented 2 years ago

the suggestions class is from brigardier (https://github.com/Mojang/brigadier) that is from vanilla

BlueTree242 commented 2 years ago

the suggestions class is from brigardier (https://github.com/Mojang/brigadier) that is from vanilla

Yeah we use that

BlueTree242 commented 2 years ago

image image

ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(this, ListenerPriority.LOW, PacketType.Play.Server.TAB_COMPLETE) {
            @Override
            public void onPacketSending(PacketEvent event) {
                var suggestions  = event.getPacket().getSpecificModifier(Suggestions.class);
                suggestions.getValues().get(0).getList().add(new Suggestion(suggestions.getValues().get(0).getRange(),"This is the biggest test ever"));
                suggestions.getValues().get(0).getList().add(new Suggestion(suggestions.getValues().get(0).getRange(),"No jokes"));
                suggestions.getValues().forEach(suggestions1 -> {
                    var temp = new ArrayList<>(suggestions1.getList());
                    temp.forEach(suggestion -> {
                        if (suggestion.getText().equals("mastermc05")){
                            suggestions1.getList().remove(suggestion);
                        }
                    });
                });
            }
        });

managed to remove my name from every suggestion and add "this is the bigest test ever" to them, without touching other suggestions

This one is also being listened to, but cant add new values, but can remove