Plugin doesn't Seem to Work on Mac, but works on Windows

Discussion in 'Plugin Development' started by JamesShadowman, Jan 18, 2012.

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

    JamesShadowman

    I'm coding a security plugin for servers.... And it doesn't seem to be working properly. It works on Windows, but it doesn't seem to react correctly on the Mac. Here is the code:

    Code:
    package me.CreatorJames.crackedpremiumauth;
     
    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.net.MalformedURLException;
    import java.net.URL;
    import java.net.URLConnection;
     
    import org.bukkit.entity.Player;
    import org.bukkit.event.player.PlayerJoinEvent;
    import org.bukkit.event.player.PlayerListener;
     
     
     
    public class Ck extends PlayerListener {
       
        private final Main Check = new Main();
        public void onPlayerJoin(PlayerJoinEvent event)
        {
       
            String noob = Check.ServerID();
            String noob1 = Check.Unblocked();
            String[] nameArray = noob1.split(",");
            Player p = event.getPlayer();
            String playername = p.getName();
            String Mom = Connect("http://session.minecraft.net/game/checkserver.jsp?user=" + playername + "&serverId=" + noob);
     
     
                        String[] Bob = Mom.split(" ");
                        if (Bob[0].length() != 3)
                          {
                            boolean foundName = false;
                            for (int i = 0; i < nameArray.length; i++)
                            {
                                if (nameArray[i].equals(playername))
                                {
                                    foundName = true;
                                    break;
                                }
                            }
                            if (!foundName)
                            {
                                p.kickPlayer("Login Using Downloads Here: http://ow.ly/8ekzL to access the server.");
                            }
                          }
                       
                    }
                       
     
                   
                   
                   
             
        private String Connect(String URLa)
        {
            try {
            URL yahoo2 = new URL(URLa);
            URLConnection yc2 = yahoo2.openConnection();
            BufferedReader in2 = new BufferedReader(
                                    new InputStreamReader(
                                    yc2.getInputStream()));
            String inputLine2;
            while ((inputLine2 = in2.readLine()) != null)
            {
                return inputLine2;
            }
            in2.close();
            }  catch (MalformedURLException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            return null;
           
        }
     
     
           
       
             
                 
           
     
        }
       
       
     
       
     
     
    

    And the Exception

    Code:
    15:42:34 [SEVERE] Could not pass event PLAYER_JOIN to CrackedPremiumAuth
    java.lang.NullPointerException
            at me.CreatorJames.crackedpremiumauth.Ck.onPlayerJoin(Ck.java:29)
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader
    va:268)
            at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.
    a:62)
            at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManage
    ava:340)
            at net.minecraft.server.ServerConfigurationManager.c(ServerConfigurat
    Manager.java:129)
            at net.minecraft.server.NetLoginHandler.b(NetLoginHandler.java:113)
            at net.minecraft.server.NetLoginHandler.a(NetLoginHandler.java:80)
            at net.minecraft.server.Packet1Login.a(SourceFile:72)
            at net.minecraft.server.NetworkManager.b(NetworkManager.java:226)
            at net.minecraft.server.NetLoginHandler.a(NetLoginHandler.java:46)
            at net.minecraft.server.NetworkListenThread.a(SourceFile:94)
            at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:534)
            at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:432)
            at net.minecraft.server.ThreadServerApplication.run(SourceFile:465)
    
     
  2. Offline

    tkausl

    I Think the Connect() returns null and you get your NPE at
    Code:
    Mom.split(" ");
     
  3. Offline

    Waffletastic

    Throw some @Overrides in there.
     
  4. Offline

    JamesShadowman

    Sorry, But Where do I throw them in?

    I'm new to Java, but very experienced in C#.
     
  5. Offline

    Waffletastic

    Above onPlayerJoin
     
  6. Offline

    I_am_not_funny

    compiling with an older version of java does the trick in many cases
     
  7. Offline

    CXdur

    Might wanna use the newest event-system, then you dont have to override. And it has to be updated when the newest bukkit is out anyways.
     
Thread Status:
Not open for further replies.

Share This Page