Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VanishStatusChangeEvent is passed invalid parameters #2604

Open
ghost opened this issue Jun 16, 2019 · 2 comments
Open

VanishStatusChangeEvent is passed invalid parameters #2604

ghost opened this issue Jun 16, 2019 · 2 comments
Labels
bug: confirmed Confirmed bugs in EssentialsX.
Milestone

Comments

@ghost
Copy link

ghost commented Jun 16, 2019

Information

Full output of /ess version:

[14:31:50] [Server thread/INFO]: Server version: 1.14.2-R0.1-SNAPSHOT git-Spigot-df0eb25-f2757f9 (MC: 1.14.2)
[14:31:50] [Server thread/INFO]: EssentialsX version: 2.16.1.125
[14:31:50] [Server thread/INFO]: PermissionsEx version: 1.23.4
[14:31:50] [Server thread/INFO]: Vault version: 1.7.1-b91
[14:31:50] [Server thread/INFO]: You are running unsupported plugins!
[14:31:50] [Server thread/INFO]: You are running an unsupported server version!

Details

Description
I've made custom vanishing command (which just sends 'player left' message on vanish), and I've encountered the following problem: when issuing /v <player> in console, VanishStatusChangeEvent#getAffected is null, while VanishStatusChangeEvent#getController is the <player>.

Steps to reproduce
Here's the code I use in my command which is using EssentialsX API:

@EventHandler
    public void onPlayerVanishStatusChange(VanishStatusChangeEvent event) {
        boolean vanished = event.getValue();
        Player player = event.getAffected().getBase();

        PlayerFakeLogonEvent playerFakeLogonEvent;
        if (vanished) {
            playerFakeLogonEvent = new PlayerFakeLeaveEvent(player);
        } else {
            playerFakeLogonEvent = new PlayerFakeJoinEvent(player);
        }

        // PlayerFakeLogonEvent is my custom event for showing join/quit messages upon vanish/unvanish
        Bukkit.getPluginManager().callEvent(playerFakeLogonEvent);
    }

Expected behavior
/v <player> triggered in the game (not in console) makes VanishStatusChangeEvent#getAffected return target player, and makes VanishStatusChangeEvent#getController return command issuer.

@triagonal triagonal added the bug: confirmed Confirmed bugs in EssentialsX. label Jun 16, 2019
@triagonal
Copy link
Member

triagonal commented Jun 16, 2019

Confirmed - arguments are passed in the wrong order here:

VanishStatusChangeEvent vanishEvent = new VanishStatusChangeEvent(controller, user, enabled);

When the correct order is:

public VanishStatusChangeEvent(IUser affected, IUser controller, boolean value) {

Feel free to submit a PR if you'd like.

This will be fixed during a major update, as it would break existing implementations that listen for this event.

@mdcfe mdcfe added this to the 3.0 milestone Aug 24, 2019
@pop4959
Copy link
Member

pop4959 commented Oct 27, 2019

In my opinion it would still be good to add an event with the correct signature, and deprecate the old one. That way it can slowly be phased out, and by the time a big milestone is reached most plugins are hopefully using/updated to use the updated event.

@JRoy JRoy changed the title Unexpected behaviour on issuing /vanish in console VanishStatusChangeEvent is passed invalid parameters Jan 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug: confirmed Confirmed bugs in EssentialsX.
Projects
None yet
Development

No branches or pull requests

3 participants