Vanish doesn't work after a player reconnects

Discussion in 'Plugin Development' started by max12345, Dec 28, 2017.

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


    Hi there,

    I'm trying to build a /vanish Command:

    I used a Array List in which the vanished Player is "stored" and all players who reconnect should not see the vanished Player but they all can see him...

    Last edited: Jan 2, 2018
  2. Offline


    You aren't registering the event listeners in the main class.
  3. Offline


    I think I'm doing this:
    Main class:
    public void registerEvents() {
    PluginManager pm = getServer().getPluginManager();
    pm.registerEvents(new JoinListener(), this);
    pm.registerEvents(new LeaveListener(), this);
    pm.registerEvents(new BuildListener(), this);
    pm.registerEvents(new InteractEvent(), this);
    pm.registerEvents(new JoinListener_vanish(), this);
    pm.registerEvents(new QuitListener_vanish(), this);
  4. Offline


    Ok, two more ideas:

    1) Do you mean to negate this if statement?
    At the moment, only players who have that permission will be unable to see people (in the join listener). Also it does't really make sense to do the if statement inside the loop, you should do the if statement before you loop through the players with the current design.

    2) Are you calling the registerEvents() method in your onEnable() method?
  5. Offline


    Thanks that simple thing solved the problem ;).

    Another question to the Vanish:
    a player who joins the server gets a message, "Welcome, there are xx Players online", the vanished people are counted there too.

    How can i remove them? Maybe when a player gets vanished add +1 to an int v and when he isn't vanished anymore remove 1? and then an int a with bukkit.getOnlinePlayers - v?

    EDIT: I thought i can solve it like this:
    int x = Bukkit.getOnlinePlayers().size();
    public int v;
    public int a = x - v;

    But when i want to use a in a other class it says that the variable has to be static, but thats in this case not possible...

    How can i solve this?
    Last edited: Dec 30, 2017
  6. Offline


    I'd do something like this:
    int online = 0;
    for (Player p : Bukkit.getOnlinePlayers())
        if (!vanished.contains(p))
    So then you're only counting the players not in the vanished list.
  7. Offline


    It's strange, Java wants a { BEFORE the for like this:

    int online = 0; {
    for (Player p : Bukkit.getOnlinePlayers())
    if (!vanished.contains(p))

    And how can i use this int in another class because it's not static?

    Last edited: Dec 31, 2017
  8. Offline


    So, i've put the for loop into the join listener, but i have to remove the player when he leaves from the online int, but theres the same problem, i can't use a static int but have to access it.

    How can i slove this?
    Really hope you can help me ;)
  9. Offline


Thread Status:
Not open for further replies.

Share This Page