Coding problems

Discussion in 'Plugin Development' started by Jake110910, Jul 23, 2013.

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


    I am new to java and I don't understand it quite that well so I was just messing around and I can't seem to get something to work right. I wanted to code a bit so that when I used the command "pvp", I would get a certain set of items. I coded this and it didn't work so I just carried on with my experiments and to my surprise whenever I used the command "sand" (the bit of coding I made after my pvp command) I got the items I wanted to get with "pvp". I was wondering if I could get a bit of help to make it so that when I use "pvp" it does what "sand" does but without the sand going in my inventory :) Also, whenever I use the "pvp" command it does nothing :( Another also: Before "sand" worked a error in my console said there was something wrong with a line of code that was after the player.getInventory().setArmorContents(null); the code was player.getInventory().setContents(null); :3
    Thank you for reading this :D
  2. Offline


    tl;dr player.getInventory().clear()?
  3. Offline


    Looks to me like you have an extra } near your PVP Command.

    Your code looks like this, remove that extra bracket at the end.
    2. if (inventory.contains(itemstacksoup) {
    3. // You have some code here
    4. }}
  4. Offline


    Today, we learn vanilla for loops:

    1. for (int i = 0; i < 38; i++) {
    2. inventory.addItem(itemstacksoup);
    3. }

    is the same as:
    1. inventory.addItem(itemstacksoup);
    2. inventory.addItem(itemstacksoup);
    3. inventory.addItem(itemstacksoup);
    4. inventory.addItem(itemstacksoup);
    5. inventory.addItem(itemstacksoup);
    6. inventory.addItem(itemstacksoup);
    7. inventory.addItem(itemstacksoup);
    8. inventory.addItem(itemstacksoup);
    9. inventory.addItem(itemstacksoup);
    10. inventory.addItem(itemstacksoup);
    11. inventory.addItem(itemstacksoup);
    12. inventory.addItem(itemstacksoup);
    13. inventory.addItem(itemstacksoup);
    14. inventory.addItem(itemstacksoup);
    15. inventory.addItem(itemstacksoup);
    16. inventory.addItem(itemstacksoup);
    17. inventory.addItem(itemstacksoup);
    18. inventory.addItem(itemstacksoup);
    19. inventory.addItem(itemstacksoup);
    20. inventory.addItem(itemstacksoup);
    21. inventory.addItem(itemstacksoup);
    22. inventory.addItem(itemstacksoup);
    23. inventory.addItem(itemstacksoup);
    24. inventory.addItem(itemstacksoup);
    25. inventory.addItem(itemstacksoup);
    26. inventory.addItem(itemstacksoup);
    27. inventory.addItem(itemstacksoup);
    28. inventory.addItem(itemstacksoup);
    29. inventory.addItem(itemstacksoup);
    30. inventory.addItem(itemstacksoup);
    31. inventory.addItem(itemstacksoup);
    32. inventory.addItem(itemstacksoup);
    33. inventory.addItem(itemstacksoup);
    34. inventory.addItem(itemstacksoup);
    35. inventory.addItem(itemstacksoup);
    36. inventory.addItem(itemstacksoup);
    37. inventory.addItem(itemstacksoup);
    38. inventory.addItem(itemstacksoup);
    danslayerx likes this.
  5. Offline


    Whenever I remove the the bracket it tells me to insert one at the end of all of my code.
  6. Where did you define the 's' variable that you use by sand
Thread Status:
Not open for further replies.

Share This Page