Player Variables Type Block Breaked...

Discussion in 'Plugin Development' started by NiavlySDev, Feb 9, 2022.

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

    NiavlySDev

    Hi,
    I have a problem, i'm trying to create a skyblock plugin with missions and i would like to know how i could store some variables type: "Mined Diamond Block": 10; in order to give a reward when a certain level of a certain blocks are mined. I would also like to create a command in my plugin which allows to add permissions to players that allow them to have a "grade" unlocking them benefits such as: "/fly" or "/heal"; and which allows them to recover a kit. And I would like to know how to do this. To summarize, here is a small list of what I would like to find solutions:

    - Storage of Personal Variables (Per player) with a number of blocks mined, the type of block mined, the name of the player etc...

    - Management of permissions in order to add or remove them via an IG command

    Sorry if my english is bad, i'm French and i use my knowledge of English and Google Translate
    Thank you in advance for the time you can spend reading and helping me.

    Have a good evening/day.

    NiavlySDev
     
  2. Offline

    Strahan

    Well, for blocks mined no need to reinvent the wheel. I'd use Statistic. Example:
    Code:
    @Override
    public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
      if (!(sender instanceof Player)) return true;
    
      Material mat = Material.matchMaterial(args[0]);
      if (mat == null) {
        sender.sendMessage("Invalid material!");
        return true;
      }
    
      int result = ((Player)sender).getStatistic(Statistic.MINE_BLOCK, mat);
      sender.sendMessage("Mined " + result + " of " + mat.name());
      return true;
    }
    That is a command method that one can use to see how many blocks have been mined. So you could do /cmd dirt and it'd say 0 if you just started, then after you break some dirt the number will increment. You can set it with Player#setStatistic.

    For the permission part, I'm not really clear on what you want. If you want to dynamically adjust permissions, best would be to hook into your permissions manager. Failing that, create a PermissionAttachment and use that.
     
  3. Offline

    NiavlySDev

    For the permission part, i need to have an IG command who gives a rank with specific permissions. As example, if a cmd named "/giverank [rank]" is executed, plugin give somes permissions (exemples: Rank "Athena" give permission to use "/fly" and "/heal"). Something else, can you explain me permission manager or can you give me an example of code plz?

    For the variable of blocks mined, you give me a soluce and i ty for that, but i need something else. I want to keep player variables as they are even after a server restart. And for my variable of block mined, i want to do a daily mission who reset each day but, i think your solution take global statistics of minecraft in server, but i need a daily mission reseted each day.

    Have a good evening/day.

    NiavlySDev
     
Thread Status:
Not open for further replies.

Share This Page