EssentialsX

EssentialsX

2M Downloads

VanishStatusChangeEvent is passed invalid parameters

Opened this issue ยท 3 comments

commented

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.

commented

@JRoy When will that be fixed?

commented

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.

commented

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.