Config Problem - Check IntList if contains a value

Discussion in 'Plugin Development' started by FameForAim, Dec 12, 2014.

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

    FameForAim

    Hi, i wondered why my class do not work

    i have this code to check the different paths( wich where all arraylists of the type integer) weather the contain the given Xb, Yb and Zb Value:
    !!Its online a part of the whole class!!
    Code:
                    } else
                        if(plugin.getConfig().getIntegerList("X").contains(Xb)){
                            if(plugin.getConfig().getIntegerList("Y").contains(Yb)) {
                                if(plugin.getConfig().getIntegerList("Z").contains(Zb)) {
                                    pe.setCancelled(true);
    This is my config.yml:
    !!! Igrone the first points!!
    Code:
    Player:
      CraftPlayer{name=test}:
        Anzahl: 1
        Location:
          X: 200
          Y: 71
          Z: 216
      CraftPlayer{name=FameForAim}:
        Anzahl: 0
        Location:
          X: {}
          Y: {}
          Z: {}
    X:
    - 200
    - 195
    Y:
    - 71
    - 71
    Z:
    - 216
    - 217
    
    So why this do not work ingame?
    i think something with the contain command is wrong, because i have the values i want to check the config.yml (as you can see) but it respond to me that they arent there and it do not cancle the event.

    Help pls!

    Idea: Does the contain command give out a boolean? and must i check this boolean weather it is true to make the code work?
     
    Last edited: Dec 12, 2014
  2. Offline

    Rocoty

    Yes, the contains METHOD returns a boolean value. And your code is already checking whether it is true.

    You should do some debugging. Print out the values of Xb, Yb and Zb and see if they are what you think they are. Also add print statements in if-blocks to determine whether they evaluate to true or not.

    EDIT: It may also help to print out the contents of the lists.
     
  3. Offline

    FameForAim

    Yeah thanks for this:) I managed it i just had a bracket where should not be one:)
     
Thread Status:
Not open for further replies.

Share This Page