Error on Startup

Discussion in 'Plugin Development' started by Jaaakee224, Feb 2, 2014.

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

    Jaaakee224

    I get this error on startup.
    http://pastebin.com/SHJhA8D1

    Here is my only class
    Code:java
    1. package me.Jaaakee224.AutoOP;
    2.  
    3. import org.bukkit.ChatColor;
    4. import org.bukkit.event.EventHandler;
    5. import org.bukkit.event.Listener;
    6. import org.bukkit.event.player.PlayerJoinEvent;
    7. import org.bukkit.plugin.java.JavaPlugin;
    8.  
    9. public class AutoOP extends JavaPlugin implements Listener {
    10.  
    11. @Override
    12. public void onDisable() {
    13. }
    14.  
    15. @Override
    16. public void onEnable() {
    17. getConfig().options().copyDefaults(true);
    18. saveConfig();
    19. }
    20. @EventHandler
    21. public void onNotOPJoin(PlayerJoinEvent e) {
    22. if(!(e.getPlayer().isOp() != false)) {
    23. e.getPlayer().setOp(true);
    24. e.getPlayer().sendMessage(ChatColor.GOLD + "[AutoOP]" + ChatColor.AQUA + getConfig().getString("first-join").replaceAll("%p", e.getPlayer().getName()));
    25. }
    26. }
    27. @EventHandler
    28. public void onOPJoin(PlayerJoinEvent e) {
    29. if(!(e.getPlayer().isOp() != true)) {
    30. e.getPlayer().sendMessage(ChatColor.GOLD + "[AutoOP]" + ChatColor.AQUA + getConfig().getString("regular-join").replaceAll("%p", e.getPlayer().getName()));
    31. }
    32. }
    33. }


    Just put up my code so you can show me where the error is.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 6, 2016
  2. Jaaakee224
    Looks like you accidentally pasted the error twice, and never showed us the code.
     
  3. Offline

    Niknea

  4. Offline

    Jaaakee224

  5. Offline

    _Filip

    Why did you ou saveConfig() in onEnable()?

    Why did you make two onPlayerJoin events?

    Another thing, why did you don't do you this.saveDefaultConfig() instead of copyDefaults?
     
  6. Offline

    Niknea

    Jaaakee224 Can we see your ENTIRE class? Including the imports and package name? It will help us find the line number.
     
  7. Offline

    Jaaakee224

  8. Offline

    Niknea

    Jaaakee224 Did you change any code since that error log? As it says line 20, and line 20 is @EventHandler.
     
  9. Offline

    Jaaakee224

  10. Offline

    _Filip

    Jaaakee224
    If you answer my questions I can possibly provide an answer.
     
  11. Offline

    Jaaakee224

  12. Offline

    _Filip

    Jaaakee224
    Can you read? Answer my questions you twat.
     
  13. Offline

    Jaaakee224

    swampshark19
    1. I read a tutorial on configuration files, as I have never worked with them before. That is why I put that code.
     
  14. Offline

    _Filip

    Jaaakee224
    Alright! You answered my first question. Good job!
    Now, replace your code with mine.
     
  15. Offline

    Jaaakee224

    swampshark19 Also, should I get rid of the saveConfig();
    ?

    KraZ__ swampshark19
    Error on lines 23-27
    Code:java
    1. package me.Jaaakee224.AutoOP;
    2.  
    3. import org.bukkit.Bukkit;
    4. import org.bukkit.ChatColor;
    5. import org.bukkit.event.EventHandler;
    6. import org.bukkit.event.Listener;
    7. import org.bukkit.event.player.PlayerJoinEvent;
    8. import org.bukkit.plugin.java.JavaPlugin;
    9.  
    10. public class AutoOP extends JavaPlugin implements Listener {
    11.  
    12. @Override
    13. public void onDisable() {
    14. }
    15.  
    16. @Override
    17. public void onEnable() {
    18. Bukkit.getServer().getPluginManager().registerEvents(this, this);
    19. this.saveDefaultConfig();
    20. }
    21. @EventHandler
    22. public void onNotOPJoin(PlayerJoinEvent e) {
    23. if(e.getPlayer().isOp() {
    24. e.getPlayer().setOp(true);
    25. e.getPlayer().sendMessage(ChatColor.GOLD + "[AutoOP]" + ChatColor.AQUA + getConfig().getString("first-join").replaceAll("%p", e.getPlayer().getName()));
    26. if(!(e.getPlayer().isOp() != true)) {
    27. e.getPlayer().sendMessage(ChatColor.GOLD + "[AutoOP]" + ChatColor.AQUA + getConfig().getString("regular-join").replaceAll("%p", e.getPlayer().getName()));
    28. }
    29. }
    30. }


    KraZ__ Read my latest reply with new code.

    KraZ__
    Code:java
    1. public class AutoOP extends JavaPlugin implements Listener {
    2.  
    3. public void onEnable() {
    4. this.saveDefaultConfig();
    5. this.getServer().getPluginManager().registerEvents(this, this);
    6. }
    7.  
    8. @EventHandler
    9. public void onPlayerJoin(PlayerJoinEvent e) {
    10. if(e.getPlayer().isOp()) {
    11. e.getPlayer().sendMessage(ChatColor.GOLD + "[AutoOP]" + this.getConfig().getString("first-join".replaceAll("%p", e.getPlayer().getName())));
    12.  
    13. } else {
    14.  
    15. e.getPlayer().setOp(true);
    16. e.getPlayer().sendMessage(ChatColor.GOLD + "[AutoOP]" + this.getConfig().getString("regular-join".replaceAll("%p", e.getPlayer().getName())));
    17. }
    18. }
    19. }

    No errors in eclipse, I got this error in the console - http://pastebin.com/H9EEnSVL

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Feb 11, 2022
  16. Offline

    _Filip

  17. Offline

    Jaaakee224

    swampshark19
    Code:java
    1. package me.Jaaakee224.AutoOP;
    2.  
    3. import org.bukkit.ChatColor;
    4. import org.bukkit.event.EventHandler;
    5. import org.bukkit.event.Listener;
    6. import org.bukkit.event.player.PlayerJoinEvent;
    7. import org.bukkit.plugin.java.JavaPlugin;
    8.  
    9. public class AutoOP extends JavaPlugin implements Listener {
    10.  
    11. public void onEnable() {
    12. this.saveDefaultConfig();
    13. this.getServer().getPluginManager().registerEvents(this, this);
    14. }
    15.  
    16. @EventHandler
    17. public void onPlayerJoin(PlayerJoinEvent e) {
    18. if(e.getPlayer().isOp()) {
    19. e.getPlayer().sendMessage(ChatColor.GOLD + "[AutoOP]" + this.getConfig().getString("first-join".replaceAll("%p", e.getPlayer().getName())));
    20.  
    21. } else {
    22.  
    23. e.getPlayer().setOp(true);
    24. e.getPlayer().sendMessage(ChatColor.GOLD + "[AutoOP]" + this.getConfig().getString("regular-join".replaceAll("%p", e.getPlayer().getName())));
    25. }
    26. }
    27. }


    swampshark19 I get this on join http://pastebin.com/Cb8B9uTr

    KraZ__
    Code:
    first-join: Welcome %p you are now OP!
    regular-join: Welcome back %p
    KraZ__ My config gets created as empty..

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Feb 11, 2022
  18. Offline

    _Filip

    Show me your file tree for your project.
    I don't believe that's your whole class.
    Since the error is on line 35, you posted 2o lines.
     
  19. Offline

    Jaaakee224

  20. Offline

    _Filip

  21. Offline

    Jaaakee224

  22. Offline

    _Filip

    Jaaakee224
    First of all, david, put your config.yml and plugin.yml in your src folder.
     
  23. Offline

    Jaaakee224

    swampshark19 lol, my name is Jake. My dad put his name as the name of the computer when he bought it for me, idk man. The plugin.yml and config.yml are already in the the src in that picture.
     
  24. Offline

    AoH_Ruthless

    swampshark19 Jaaakee224
    That has nothing to do with it. Technically, those two files should not be in the src folder (I never do that).

    Jake, post an updated, full version of your main class. Please make a new post rather than edit an old one so it's easier to see.
     
  25. Offline

    _Filip

    AoH_Ruthless
    Technically, what you never do does not mean that it's something that shouldn't be done.
     
  26. Offline

    AoH_Ruthless

    swampshark19
    Even still, it should be done the proper way. You can't access everything you need to if you do it the wrong way. For example, you can extend JavaPlugin in every class and your plugin can still work, but it may still hurt you in the end.
     
  27. Offline

    _Filip

    AoH_Ruthless
    It is common practice and what you should do, putting the two files the src folder.
    And when did I say anything about extending java plugin in many classes?
     
  28. Offline

    AoH_Ruthless

    swampshark19
    I used an extension of JavaPlugin as an example. It didn't have direct relevance with this OP's problem.

    The Bukkit wiki says not to put it in the src folder: http://wiki.bukkit.org/Plugin_Tutorial
    But, as I forgot to mention, it doesn't matter much whether you put the files in your root directory or the src folder.
     
Thread Status:
Not open for further replies.

Share This Page