Solved Solved onInteract for Players

Discussion in 'Spigot Plugin Development' started by Uzi, May 31, 2017.

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

    Uzi

    Issue Solved thanks everyone <3

    The main problems are
    Code (Text):
            localItemStack3 = (arrayOfItemStack1 = p.getInventory().getContents()).length;
            Material hand;
            for (ItemStack localItemStack1 = 0; localItemStack1 < localItemStack3; localItemStack1++)
            {
              ItemStack i = arrayOfItemStack1[localItemStack1];
              if (i != null)
              {
    Other problem
    Code (Text):
            int j = (hand = InfusionI.getContents()).length;
            for (localItemStack3 = 0; localItemStack3 < j; localItemStack3++)
            {
              item = hand[localItemStack3];
              if (item != null) {
                isEmpty = false;
              }
            }

    3rd problem going down btw
    Code (Text):
            localItemStack3 = (arrayOfItemStack2 = p.getInventory().getContents()).length;
            Material hand;
            for (ItemStack localItemStack2 = 0; localItemStack2 < localItemStack3; localItemStack2++)
            {
              ItemStack i = arrayOfItemStack2[localItemStack2];
    4th problem
    Code (Text):
            int k = (hand = InfusionII.getContents()).length;
            for (int i = 0; i < k; i++)
            {
              ItemStack item = hand[i];
    Thanks if someone can help me out on this it would mean lots <3

    This is the only problem I am having that is making my plugin not wanting to work...

    Thanks again everyone and have a amazing day! <3
     
    #1 Uzi, May 31, 2017
    Last edited: May 31, 2017
  2. Choco

    Moderator

    Well, "Problem x" doesn't really help us at all. What exactly is the problem. Also, as a side note, is there any reason as to why you're decompiling plugins?
     
  3. Uzi

    Uzi

    1st off this is a open to public source
    2nd off everytime I hover it it show supress warnings or something else out, I asked members on bukkit they said I had to add
    Code (Text):
    ItemStack[] contents = player.getInventory().getContents();

    for (int i = 0; i < contents.length() ; i++)
    {
      Itemstack item = contents[i];
      //your code
    }
    But when I did it popped up with the same message saying supress warnings everywhere can I not just copy and paste codes in eclipse I know how to code but something like this was hard for me to have my plugin interact with opening a command while only having a pickaxe in your hand like I said this is the only error I have in my invent class all my other commands are working just fine

    [​IMG]
     
  4. Choco

    Moderator

    Yea, no it's not. This is decompiled code. If this is public on GitHub, I would very much like to see a link because I have no doubt in my mind that it is decompiled. I work with decompiled code rather frequently to review resources and manage resource reports. Most people on this forum can spot decompiled code from a mile away. Looks like JD-GUI

    SuppressWarnings isn't a tool to fix your errors. It's to suppress any warnings in your IDE that should not be of bother to you (i.e. deprecated methods with no alternative, which is common in Bukkit's API). A lot of your loops can be simplified because again, decompilers struggle to put code back together the way it was in its original form
    Code (Java):
    for (Type variableName : yourListOfTypes) {
        variableName.doSomething();
    }
     
  5. Uzi

    Uzi

    Are you not understanding what I am trying to say!?!??!

    Everytime I added

    Code (Text):
    ItemStack[] contents = player.getInventory().getContents();

    for (int i = 0; i < contents.length() ; i++)
    {
      Itemstack item = contents[i];
      //your code
    }

    I hover over the ItemStack errors and it adds the supress warnings ?!?!?!?!??!
     
  6. Uzi

    Uzi

    https://bukkit.org/threads/oninteract-and-itemstack-errors.453533/#post-3516023

    Never mind XexCruz helped me sorry for making it confusing <<<
     
Thread Status:
Not open for further replies.