event.getFrom() giving different values in different classes

Discussion in 'Plugin Development' started by CookieTom, Feb 3, 2021.

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

    CookieTom

    I've created two identical classes, both printing event.getFrom(). However, for one class the returned value is correct, showing my XYZ coordinates to be correct, but in the other, all the printed XYZ values are 0.0

    Both classes are just running:

    Code:
    Bukkit.broadcastMessage("getFrom: " + e.getFrom())
    https://imgur.com/a/ibZhbfw
    [​IMG]
     
  2. Offline

    Kars

    Show both classes then.
     
    CookieTom likes this.
  3. Offline

    CookieTom

    @Kars Here is the first class
    Code:
    public class Step implements Listener {
    
      @EventHandler
      public void onMove(PlayerMoveEvent e) {
      Bukkit.broadcastMessage("getFrom2: " + e.getFrom());
      }
    } 
    Here is the second class
    Code:
    
    public class Speed implements Listener {
    
    @SuppressWarnings("deprecation")
      @EventHandler
      public void onMove(PlayerMoveEvent e) {
        if (e.getPlayer().getGameMode() == GameMode.SURVIVAL) {
        Bukkit.broadcastMessage("getFrom1: " + e.getFrom());
        }
      }
    } 
     
  4. Offline

    Kars

    CookieTom likes this.
  5. Offline

    timtower Administrator Administrator Moderator

    @CookieTom Why not have 1 eventHandler and pass them along using the same method? Some other plugin might be in between here and changing things.
     
    CookieTom likes this.
  6. Offline

    CookieTom

    I could try just using one EventHandler, but I also removed all the only other plugin on my server and it's still giving 0,0,0 as getFrom. Just seems like a weird issue to me which I can't see how I could be causing
     
  7. Offline

    Newdel

    I copy pasted your code and was not able to recreate this bug. Can you share your whole project?
     
Thread Status:
Not open for further replies.

Share This Page