Solved teams problem

Discussion in 'Plugin Development' started by nightwolf111, Jul 21, 2016.

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

    nightwolf111

    hey guys i was making a plugin but i was stuck in the registerteams class i made everyything right but when i start the server it gives me this error :
    this is my main class :
    and this is my register team class :
    and this is my inventoryclickevent class :
    need help plzz :(
     
  2. Offline

    N00BHUN73R

    @nightwolf111
    Inventory click: this.main = new main();
    You can't re-init your plugin, call it in a class constructor.
    Also please use proper-naming conventions. Don't use main as a class name, name it the name of your plugin. also for packages, me.<name>.<pluginname> !
     
  3. Offline

    CruzAPI

    @nightwolf111

    I found some errors in this code that can bring problems to you:

    - You are checking an ItemStack in this line:
    Code:
    if(itemclicked == new ItemStack(Material.EMERALD_BLOCK,1)
    it is wrong because ItemStack is an object and you need to use method .equals(anotherObject) instead of "==".

    - You need to show where is the line of the errors to me find where is wrong and help you.

    - You are not in accordance with the name conventions, it difficults to understand your code.
     
  4. Offline

    nightwolf111

    i changed the name of main to Game and i made a new class called Scoreboards :

    this is the new Game Class :
    and this is the new InventoryClick class :
    and if needed that's the register teams class :
    i tried what you said but it gives me errors too :
    help me plzzz :( :( :(
     
  5. Offline

    Zombie_Striker

    Please read the following link:
    https://bukkit.org/threads/how-to-r...ubleshoot-your-own-plugins-by-yourself.32457/

    The reason you are getting this error is because something is null on line 24 of the RegisterTeams class. Figure out what is null, and set that variable equal to something.
     
  6. Offline

    nightwolf111

    well, if iknow how to fix it i wouldn't post this thread i am a beginner in java coding i need some help the line 24 is : scoreboard.registerNewTeam(name); i don't know what's the problem can you help me pls ?
     
  7. Offline

    Zombie_Striker

    @nightwolf111
    If you are a beginner of Java, then you should not be working on Bukkit plugins just yet. Although you may want to do bukkit first or may even want to learn Java while making plugins, you need to know Java before working on Bukkit plugins. The reason why is so you don't have to make simple mistakes like this one. Knowing the language you are writing in will help you both understand what you are doing (and make your programs more efficient) and will prevent you from making mistakes that should be avoided (making the time to create a plugin much shorter). Please, if you have not learned Java just yet, pick a tutorial from the following link and learn Java before returning to Bukkit.
    https://bukkit.org/threads/plugin-dev-sticky-learning-java-where-to-learn.395662/

    The issue is that you're getting an NPE, which means a value on that line is not set to anything (null) and you are trying to make it do something . There are only two variables on that line: scoreboard and name. One of those to variables has to be null. What you need to do is check which variable is null and figure out why it is null. Once you do that, you need to make sure it is not null.
     
    CodePlaysMinecraft likes this.
  8. Offline

    FrostedSnowman

    Why do that when you can just do

    Code:
    if (itemClicked.getType() == Material.EMERALD_BLOCK);
    
     
  9. Offline

    nightwolf111


    i am not totally begginer i learned the basics of java and i learned some buckets but i wanted to create a plugin to learn more, i know i always make mistakes like those x) i'll try to find out what is the problem. thanx anyways for helping me :) .

    i can not use that it says it must be an ItemStack
     
  10. @nightwolf111
    Notice how it says
    Code:
    itemClicked.getType()
    and not just
    Code:
    itemClicked
     
  11. Offline

    nightwolf111

    aah x) ok i did it


    i solved the problem, i added a method in my main class wich is the game class to add new teams, and i called onEnable method :) thanx guys for your supports :D
     
  12. @nightwolf111
    If your problem has been solved, please mark the thread as such :)
     
  13. Offline

    nightwolf111

    i solved it now i have no errors but when i rightclick with a netherstar in hand nothing happens and it must opens an inventory it was working perfectly before but now it stopped i don't know why and i have no errors :(
     
  14. Offline

    N00BHUN73R

    @nightwolf111
    Please create another thread with your current source code and we'd be happy to help there :)
     
  15. Offline

    nightwolf111

    okay sry :) i think i have to solve my problems by myself to learn faster thanx all for your supports :)
     
  16. @nightwolf111 Please mark this thread as solved.

    Thread Tools > Edit Thread > Prefix > Solved
     
Thread Status:
Not open for further replies.

Share This Page