Compare block type

Discussion in 'Plugin Development' started by Buckle_up, Jun 21, 2016.

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

    Buckle_up

    So the issue i am having is that i need to check if a the block being placed is a certain block type, however this certain block type is specified in the config file, and its a list of items. How would i check every block type specified in the config file? my code so far:
    Code:
    if(event.getBlock().getType() != (any one of list of blocks in config)  )
            return false;
    @timtower so you just want me to run it multiple times individually?
    that seems kinda inneficient... if that is what you are referring too.
     
    Last edited: Jun 22, 2016
  2. Offline

    timtower Moderator Moderator

    @Buckle_up List of materials.
    list.contains(blocktype)
     
  3. Offline

    Buckle_up

    that wont work because the list is a string and contains() requires an object
     
  4. Offline

    timtower Moderator Moderator

    @Buckle_up Then you can do 2 things.
    Change the list to be one for material.
    Use getType().name()
     
  5. Offline

    Buckle_up

    @timtower
    i cant, i am trying to make a factions top plugin, and it will check the factions chunk for this list of items. i am not at that stage yet, right now i am just telling it to return false if it is not one of those blocks so it wont run the event and lag the server more. So whats the second option?
    and youi messaged me and said that posting a reply would be against the terms, should i just edit my original post and tag you to reply?
     
  6. Offline

    timtower Moderator Moderator

    @Buckle_up The suggestions that I made will make that work if you write a little bit of code around it.
    And about that warning: keep that in the PM please.
     
  7. Offline

    CeramicTitan Retired Staff

    LOL. A string is an object?
     
  8. Offline

    Buckle_up

    @timtower the issue im having is, is that i dont know how to get materials from a config file.
    List<Material> Chck = Arrays.asList(new Material[] {plugin.getConfig().get("Factions Blocks")})
    the problem with that is, i cant convert from a string to a material.
     
  9. Offline

    timtower Moderator Moderator

    @Buckle_up That is correct, you ned to do that by hand.
    Or keep it a string list and use type.name()
     
  10. Offline

    Buckle_up

    @timtower do you by any chance have a webpage or tutorial that shows how to convert is by hand? and type().name() returns a banlist
     
    Last edited: Jun 22, 2016
  11. Offline

    timtower Moderator Moderator

    @Buckle_up type().name() should return the Material in uppercase, not a banlist.
     
  12. Offline

    Buckle_up

  13. Offline

    timtower Moderator Moderator

    @Buckle_up Yes, you are copy pasting what I am saying, type is the blocktype. Not an variable.
     
Thread Status:
Not open for further replies.

Share This Page