Using HashMap with BlocksTo control the destruction of blocks, based on the tool and config

Discussion in 'Plugin Development' started by new-ewrs728, Mar 13, 2019.

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

    new-ewrs728

    Hi again. I have an idea that it was impossible to break a wooden pick, for example, a list of blocks from the config, and with the help of an iron one (also from the config).
    The question is, how do I better control the lists? In minecraft there are a lot of different types of tools, do not you create your own HashMap for everyone?

    Thank you
     
  2. Offline

    timtower Administrator Administrator Moderator

  3. Offline

    new-ewrs728

    Suppose (I forgot how to get from a generic)
    Are there any other options?

    UPD:
    And by the way, I never got an answer. I have something like this in the configuration: DIAMOND_PICKAXE:
    - DIRT ...
    GOLD_PICKAXE:
    - GRASS
    - GLASS
     
    Last edited: Mar 13, 2019
  4. Offline

    timtower Administrator Administrator Moderator

    @new-ewrs728 get from a generic?
    And your question is vague, do you want to make a hashmap for everybody?
     
  5. Offline

    Chr0mosom3

    HashMap<Player, Material> map;

    for every player in the server {
    do some checking {
    map.put(player, material);
    }
    }
     
  6. Offline

    new-ewrs728

    This is the question. What should I do? If I do for each tool, it will be stupid


    Read my question again. I need to do for each tool and its kind. Do not create the same 100 hashmaps diamond Pickaxe, diamond sword, stone sword etc ...
     
  7. Offline

    timtower Administrator Administrator Moderator

    @new-ewrs728 You can use the tools name, all the wooden tools have wood in it.
     
  8. Offline

    new-ewrs728

    do not quite understand
     
  9. Offline

    timtower Administrator Administrator Moderator

    DIAMOND_PICKAXE
    DIAMOND_SHOVEL
    Names all contain DIAMOND, you can use that as key, then you have 5 keys.
    Another option is having a List<CustomClass>
    Where the CustomClass contains the allowed tools in a list and the allowed blocks in a different one.
    for(CustomClass temp : classList){
    if(temp.containsTool(tool) && temp.canBreak(block)){
    // do stuff
    }
    }
     
  10. Offline

    new-ewrs728

    In the first version, you offer me to immediately contact the config, if not null, right?
     
  11. Offline

    timtower Administrator Administrator Moderator

    My suggestion would be to load it into the memory of the plugin in the onEnable and then leave the config alone again.
     
Thread Status:
Not open for further replies.

Share This Page