Solved Pass Orange Wool to WorldEdit BaseBlock

Discussion in 'Plugin Development' started by MeJellyPelly, Nov 19, 2014.

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

    MeJellyPelly

    I have a config setting that defines how an area should be filled:

    Code:
    m1: 2%35:1,32%14,33%15,33%16
    I have split it into an array using the "," as a delimiter. I then split each item using the "%" to get the percentage and block. The problem is ... 35:1 is not an integer (Orange Wool), so I can't pass it to the WorldEdit BaseBlock constructor.

    I followed the post https://forums.bukkit.org/threads/worldedit-totally-lost-need-a-path.232212/ but that uses nice integer values for its blocks.

    How do I get an integer value for Orange Wool?:confused:
     
  2. Offline

    MeJellyPelly

    I can't remember where now, but I found this function which solved the problem (I probably amended it a bit too, for my purposes):

    Code:java
    1. public static BaseBlock getBlock(String id, final LocalWorld world) {
    2. WorldEditPlugin we = (WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit");
    3.  
    4. try {
    5. return we.getWorldEdit().getBlock(new BukkitCommandSender(we, we.getServerInterface(), Bukkit.getConsoleSender()) {
    6.  
    7. @Override
    8. public LocalWorld getWorld() {
    9. return world;
    10. }
    11. }, id, true);
    12. } catch (UnknownItemException e) {
    13. // TODO Auto-generated catch block
    14. e.printStackTrace();
    15. } catch (DisallowedItemException e) {
    16. // TODO Auto-generated catch block
    17. e.printStackTrace();
    18. }
    19.  
    20. return null;
    21. }
    22.  
     
Thread Status:
Not open for further replies.

Share This Page