1.8.8 Block break event error

Discussion in 'Spigot Plugin Development' started by Ninjablader101, Mar 6, 2020.

  1. SteelPhoenix

    Moderator

    'PlayerLevelManager playerLevelManager = null;' what do you expect..?
     
  2. Code (Text):
    PlayerLevelManager playetLevelManager = null;
    playerLevelManager.getXp();
    Edit: too late
     
  3. Your trying to get xp from nothing

    PlayerLevelManager playerLevelManager = null;
    int xp = playerLevelManager.getXp();

    If you want to get that players exp you can do it in the event. Plus I don't know what that class even does.
     
    • Agree Agree x 1
  4. PlayerLevelManager is a custom level system. https://sourceb.in/c1bcffea9d <- that's the playerlevelmanager class
     
  5. If the playerLevelManager is null, there will be ofc. an error because its null
     
  6. What should it be
     
  7. I don't think you understand how to use that class, you need to store instances of it, most likely in a map with some kind of player reference
     
  8. Can you send the playerlevelmanager class?
     
  9. PlayerLevelManager is a custom level system. https://sourceb.in/c1bcffea9d <- that's the playerlevelmanager class
     
  10. Code (Java):
        private int level;
        private int xp;
        private Player player;

        public PlayerLevelManager(Player player, int level, int xp) {
            this.player = player;
            this.level = level;
            this.xp = xp;
        }
    and call it in other classes with

    Code (Java):
    PlayerLevelManager YourObjectName = new PlayerLevelManager(PutHereThePlayer, PutHereTheLevel, PutHereTheExp);
     
  11. You know that this is a custom level system right?
     
  12. You know you've mentioned that multiple times now right? You don't seem to understand basic Java.
     
  13. well is the a tutorial i can get to learn it.
     
  14. I know, and because of that i've changed your code (look at the first code field) and showed you how to use it in other classes (look at the second code field)..