World/Item from config

Discussion in 'Plugin Development' started by RoboticPlayer, Oct 27, 2015.

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

    RoboticPlayer

    How would I go about getting a world or material from a config.yml? Say I have this config.yml with a stringList of banned blocks
    Code:
    bannedBlocks:
      - TNT
      - Bedrock
    I know I would first do something like this
    Code:
    public [something] getBannedBlocks() {
        for (String item : getConfig().getStringList("bannedBlocks") {
            item.toUpperCase();
            // What now? How do I convert from a string to a Material? Or a string that is a world name to a world object?
        }
        return [list of materials];
    }
     
  2. Offline

    Lordloss

    For the world, you can do: World world = Bukkit.getWorld("Worldname");

    Edit:

    And for the material there is a similar method: Material mat = Material.getMaterial("MaterialName");
     
  3. Offline

    CoolDude53

Thread Status:
Not open for further replies.

Share This Page