Plugin isn't up to date error

Discussion in 'Plugin Development' started by Cystalize, Aug 7, 2012.

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

    Cystalize

    The plugin is working fine in the server, but for some reason I keep getting this message in the console:

    Code:
    16:05:50 [SEVERE] Error occurred while enabling Spamicide v0.1 (Is it up to date?)
    java.lang.NullPointerException
        at me.arsinia.spamicide.Spamicide.onEnable(Spamicide.java:85)
        at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:217)
        at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:365)
        at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:381)
        at org.bukkit.craftbukkit.CraftServer.loadPlugin(CraftServer.java:265)
        at org.bukkit.craftbukkit.CraftServer.enablePlugins(CraftServer.java:247)
        at net.minecraft.server.MinecraftServer.i(MinecraftServer.java:296)
        at net.minecraft.server.MinecraftServer.d(MinecraftServer.java:275)
        at net.minecraft.server.MinecraftServer.a(MinecraftServer.java:225)
        at net.minecraft.server.DedicatedServer.init(DedicatedServer.java:140)
        at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:380)
        at net.minecraft.server.ThreadServerApplication.run(SourceFile:539)
    


    Here is my main plugin class:

    Code:
    package me.arsinia.spamicide;
     
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileNotFoundException;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.util.ArrayList;
    import java.util.Properties;
    import java.util.logging.Logger;
    import org.bukkit.ChatColor;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.command.ConsoleCommandSender;
    import org.bukkit.configuration.file.FileConfiguration;
    import org.bukkit.entity.Player;
    import org.bukkit.plugin.java.JavaPlugin;
     
    public class Spamicide extends JavaPlugin
    // ----------CAPS SECTION-------- \\
    {
      static String dir = "plugins/Spamicide";
      static File SpamFile = new File(dir + File.separator + "BlockedWords.txt");
      static Properties prop = new Properties();
      ArrayList<String> ignored = new ArrayList<String>();
      ArrayList<String> Blocked = new ArrayList<String>();
      final String defaultBlocked = "Crap,Shit";
      private static final Logger log = Logger.getLogger("Minecraft");
     
      public void onEnable() { new SpamPlayerListener(this);
        FileConfiguration config = getConfig();
        config.options().header("DEFAULT SPAMICIDE CONFIGURATION");
        config.addDefault("Spamicide.Percentage", Integer.valueOf(60));
        config.addDefault("Spamicide.DetectIfGreaterThan", Integer.valueOf(5));
        config.addDefault("Spamicide.CapsMessage", "TURN OFF YOUR CAPS!");
        config.addDefault("Spamicide.ProfanityMessage", "You cannot say that!");
        config.addDefault("Spamicide.LowerCase", Boolean.valueOf(true));
        config.options().copyDefaults(true);
        saveConfig();
        load();
        log.info("Spamicide:  Enabled");
       
       
       
        try
        {
          reloadConfig();
          if (!getConfig().isSet("Spamicide.MaxConnections")) {
            getConfig().set("MaxConnections", Integer.valueOf(5));
          }
          if (!getConfig().isSet("Spamicide.LockdownOnStart")) {
            getConfig().set("Spamicide.LockdownOnStart", "false");
          }
          if (!getConfig().isSet("Spamicide.Throttle")) {
            getConfig().set("Throttle", Integer.valueOf(500));
          }
          if (!getConfig().isSet("Spamcide.Bandwidth")) {
            getConfig().set("Bandwitdh", Integer.valueOf(10240));
          }
          if (!getConfig().isSet("Spamicide.Afk-Timeout")) {
            getConfig().set("Afk-Timeout", Integer.valueOf(20000));
          }
          if (!getConfig().isSet("port")) {
            getConfig().set("port", Integer.valueOf(25565));
          }
          if (!getConfig().isSet("Block-TOR")) {
            getConfig().set("Block-TOR", "true");
          }
          saveConfig();
          reloadConfig();
        }
        catch (Exception ex)
        {
          saveConfig();
          reloadConfig();
        }
        this.fepExec = new ProxyCommands(this);
        getCommand("spam").setExecutor(this.fepExec);
        int MaxConnections = getConfig().getInt("MaxConnections");
        int Throttle = getConfig().getInt("Throttle");
        int Bandwidth = getConfig().getInt("Bandwitdh");
        int Timeout = getConfig().getInt("Afk-Timeout");
        int Port = getConfig().getInt("port");
        String Tor = getConfig().getString("Block-TOR");
        if (Tor.toLowerCase().equals("true")) {
          this.tor = new TORBanList();
        }
        this.isLocked = false;
        this.events = new ProxyEvents(this);
        this.events.RegisterEvents();
        if (this.listener == null) {
          System.out.println("Spamicide:  Enabling proxy protection...");
          this.listener = new ProxyListener(this, Bandwidth, MaxConnections, Timeout, Throttle, Port);
          this.listener.start();
        }
        this.isLocked = getConfig().get("lockdown").toString().trim().equalsIgnoreCase("true");
        System.out.println("Spamicide:  Enabled proxy protection"); 
      }
     
      public void onDisable() {
        log.info("Spamicide:  Disabled");
       
       
       
        reloadConfig();
        if (this.isLocked)
          getConfig().set("lockdown", "true");
        else {
          getConfig().set("lockdown", "false");
        }
        saveConfig();
      }
     
     
     
      public ArrayList<String> parseArray(String in, char delimiter)
      {
        ArrayList<String> parsed = new ArrayList<String>();
        String build = "";
        int count = 0;
        int len = in.length();
        while (count < len) {
          while ((count < len) && (in.charAt(count) != delimiter)) {
            build = build + in.charAt(count);
            count++;
          }
          parsed.add(build);
          build = "";
          count++;
        }
        return parsed;
      }
      public void load() {
        new File(dir).mkdir();
        if (!SpamFile.exists())
          try
          {
            SpamFile.createNewFile();
            log.info("Spamicide:  Generated BlockedWords file");
            FileOutputStream out = new FileOutputStream(SpamFile);
            prop.put("BlockedWords", "Crap,Shit");
            this.Blocked = parseArray("Crap,Shit", ',');
     
            prop.store(out, "Choose the words that you want blocked from your chat!");
            out.flush();
            out.close();
          } catch (IOException ex) {
            ex.printStackTrace();
          }
        else
          try
          {
            FileInputStream in = new FileInputStream(SpamFile);
            prop.load(in);
            this.Blocked = parseArray(prop.getProperty("BlockedWords"), ',');
            in.close();
            log.info("Spamicide:  Configuration loaded");
          } catch (FileNotFoundException e) {
            log.info("File exists but was not found");
          } catch (IOException e) {
            log.info("IO Exception on load of properties");
            e.printStackTrace();
          }
      }
     
      public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
        boolean op = false;
        if ((sender instanceof Player)) {
          Player player = (Player)sender;
          op = player.isOp();
        }
        if ((label.equalsIgnoreCase("spam")) &&
          ((op) || ((sender instanceof ConsoleCommandSender))) &&
          (args.length == 1) && (args[0].equalsIgnoreCase("reload"))) {
          load();
          reloadConfig();
          log.info("Spamicide:  Configuration reloaded");
          if (op) {
            sender.sendMessage(ChatColor.RED + "Spamicide:  " + ChatColor.GREEN + "Configuration reloaded");
          }
          return true;
        }
     
        return false;
      }
     
     
    // --------PROXY SECTION-------- \\
      public ProxyListener listener;
      private ProxyCommands fepExec;
      private ProxyEvents events;
      private TORBanList tor;
      public boolean isBlockingTOR = false;
      public boolean isLocked = false;
      public boolean isRejectingAll = false;
     
     
      public void ResetSpamCount()
      {
        this.events.ResetSpams();
      }
     
      public void ResetchatSpamCount() {
        this.events.ResetChatSpams();
      }
     
      public int Upstream() {
        return this.listener.LastUpstream;
      }
     
      public void UpdateProxies() {
        if (this.tor != null)
          this.tor.DownloadBans();
      }
     
      public boolean isProxy(String IP)
      {
        return this.tor.isTORProxy(IP);
      }
     
      public int TotalProxies() {
        int result = 0;
        if (this.tor != null) {
          result += this.tor.size();
        }
        return result;
      }
     
      public int Downstream() {
        return this.listener.LastDownstream;
      }
     
      public boolean isListenerRunning() {
        if (this.listener == null) {
          return false;
        }
     
        return this.listener.isRunning();
      }
    }
    I'm not very good at troubleshooting error messages in the console, so I was hoping somebody could help me out. I am using the new recommended build for the external jar, and I've even tried other builds for 1.3.1, but none seem to fix the error. Also, I get absolutely no error messages in Eclipse. PLEASE HELP :3
     
  2. Offline

    Taco

    Take a look at this line:
    at me.arsinia.spamicide.Spamicide.onEnable(Spamicide.java:85)
    This line is saying that your error is ocurring on line 85 of Spamicide.java, and the type of error is a NullPointerException, meaning something is null. So if you're using eclipse, hit ctrl+L and go to line 85 and see what could be your null variable.

    Also, if you haven't read it yet, I recommend taking a peek at this topic: http://forums.bukkit.org/threads/ho...ubleshoot-your-own-plugins-by-yourself.32457/
     
  3. Offline

    Courier

    "Is it up to date?" doesn't mean anything. CraftBukkit always says that when a plugin error in onEnable().
     
  4. Offline

    Cystalize

    ohhmygodd thank you so much for this page! I really need this haha
     
Thread Status:
Not open for further replies.

Share This Page