Player_Variables

Discussion in 'Plugin Development' started by MrDanielExpo, Dec 13, 2017.

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

    MrDanielExpo

    Hey there,

    I have been making a plugin for my own server that I am setting up soon. I am trying to make this point system, so, if you play games and stay online you get points. When you get enough points you will rank up and unlock cool perks on the server. I had been trying lots of time to create a player stored variable, the {points} variable. I was looking at all the posts on the web and I found this one with hashmaps and they don't even talk about what it does or what to replace with what. I went on a documentation and couldn't find any help, 70% of what they put on there is like object.java.structure which I don't even care/know about.

    For now, I had been using the classic Minecraft Exp System

    What I have done already is I had created a points system with arrays so they are stored somewhere and with the names of the ranks so if you rank the function can just refer to the array:
    Code:
    String[] levels = new String[]{"user","player","gamer", "professional"};
    int[] toLevelUp = new int[]{50, 70, 100, 130, 160, 200, 250, 320, 400, 480, 520, 600};
    
    I also have an online counter so you get points when you stay online:
    Code:
    @EventHandler
    public void onPlayerJoin(PlayerJoinEvent e) throws InterruptedException {
    
    Player player = e.getPlayer(); // Gets the player
    
      float count = 0;
    
      booleanbol1 = false; // 1st hour claim
    
      booleanbol2 = false;
    
    
      while (player.isOnline()) { // Checks if player is online
    
        count = count + 1; // Adds 1 count point for each second the player is online
    
        TimeUnit.SECONDS.sleep(1); // Waits 1 sec
    
    
        if (count > 3600 && bol1 == false) { // Checks if player is online for 1h
    
          player.giveExp(2); // Gives 2 exp
    
          bol1 = true;
    
        }
    
        if (count > 7200 && bol2 == false) { // Checks if player is online for 2h
    
          player.giveExp(3);
    
          bol2 = true; // Gives 3 exp
    
      }
    }
    
    But now I have this problem that I actually can't use the classical Minecraft Exp system and I have to use my own. The problem is that now I need to store it somewhere and everytime a new player joins I have to create a new place to store it so I can't create just one. Someone help. I had searched everywhere and nothing helped. HELP

    Thanks in advance, :D
     
  2. Offline

    leduyquang753

    The config files is your friend.
    When the player leaves your server or the server shuts down store the variables into a config. Then when that player comes back you just get the data back.
     
    Last edited: Dec 14, 2017
Thread Status:
Not open for further replies.

Share This Page