Development Assistance Weird error when acces a class!

Discussion in 'Plugin Help/Development/Requests' started by jusjus112, Feb 4, 2015.

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

    jusjus112

    hey guys,

    Im getting a error when i acces my class!
    So, in a bukkitrunnable class im getting acces to the class, he imports it and i can get stuff out of it!
    But, when i reload/restart my server, im getting this error, i have never seen it before:
    Code:
    java.lang.NoClassDefFoundError: Could not initialize class PVPGame.Utils.GameManager
    My code is with scoreboards, and this is my class:
    Code:
    public class ScoreBoard extends BukkitRunnable{
      
        public Main plugin;
       
        public ScoreBoard(Main plugin){
        this.plugin = plugin;
        }
    
        @SuppressWarnings("deprecation")
        @Override
        public void run() {
            for(Player all : Bukkit.getOnlinePlayers()){
                if (Bukkit.getOnlinePlayers().length > 0) {
                    GameManager.getManager().updateScoreBoard(all);
                }
            }
        }
    And im getting the .updateScoreboard(); from my gamemanager class:
    Code:
      
        @SuppressWarnings("deprecation")
        public void updateScoreBoard(Player players) {
            if (players.getScoreboard().getObjective("lobby") == null) {
                setScoreboard(players);
                players.setScoreboard(sb);
            }
            if (players.getScoreboard().getObjective("lobby") != null){
                players.setScoreboard(sb);
                sb.getObjective(DisplaySlot.SIDEBAR).getScore(Bukkit.getOfflinePlayer(ChatColor.WHITE + "" +
                        ChatColor.BOLD + "Kills:")).setScore(5);
                sb.getObjective(DisplaySlot.SIDEBAR).getScore(Bukkit.getOfflinePlayer(ChatColor.GOLD + "" + ChatColor.BOLD + StatsManager.getPlayerKills(players.getName()))).setScore(4);
            }
        }
    EDIT: I have removed my scoreboard code, and now i cant acces this whole class!QQ
     
    Last edited: Feb 4, 2015
  2. Offline

    Burnett

  3. Offline

    jusjus112

    @Burnett
    Doenst matter, i have given you the full error, it says that i CANT acces the class.
    Posting the full code, it dont given you any reason.
    But if you think you can help me with the full code:
    Full GameManagerClass: http://pastebin.com/wZHuZARC
     
  4. Offline

    Burnett

    @jusjus112 You posted one line of the error. If you want help then you need to help us help you. Don't use pastebin use the [syntax.] brackets as I am unable to connect to pastebin due to corporate proxy.
     
  5. Offline

    jusjus112

    @Burnett
    omg, oke. I paste FULL code and error:

    GameManager.java:
    Code:
    package PVPGame.Utils;
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.World;
    import org.bukkit.entity.Player;
    import org.bukkit.scoreboard.Scoreboard;
    import org.bukkit.scoreboard.ScoreboardManager;
    import org.bukkit.scoreboard.Team;
    import PVPGame.Main;
    public class GameManager{
          
            private static GameManager gm = new GameManager();
            //Hiermee pak je de constructors met GameManager.getManager()......
            public static GameManager getManager() {
                    return gm;
            }
          
            public ScoreboardManager manager = Bukkit.getScoreboardManager();
            public Scoreboard board;
            //public Scoreboard sb;
            public Team red = board.registerNewTeam("red");
            public Team blue = board.registerNewTeam("blue");
            //public Objective objective;
            //public Score score;
          
            @SuppressWarnings("deprecation")
            public void addPlayer(Player p) {
                    World lobby = Bukkit.getWorld(Main.getWorldLobby());
                    p.teleport(lobby.getSpawnLocation());
                  
                    p.getInventory().clear();
                    p.updateInventory();
                    p.setHealth(20.0);
                    p.setFireTicks(0);
            }
          
            public void removePlayer(Player p) {
                    p.getInventory().clear();
                    p.setFireTicks(0);
            }
          
            /*public void setScoreboard(Player player) {
                     sb = Bukkit.getScoreboardManager().getNewScoreboard();
                    objective = sb.registerNewObjective("lobby", "dummy");
                    objective.setDisplaySlot(DisplaySlot.SIDEBAR);
                    objective.setDisplayName(ChatColor.GOLD + "" + ChatColor.BOLD + "Your Stats");
                    player.setScoreboard(sb);
            }
          
            //@SuppressWarnings("deprecation")
            public void updateScoreBoard(Player players) {
                    if (players.getScoreboard().getObjective("lobby") == null) {
                            setScoreboard(players);
                            players.setScoreboard(sb);
                    }
                    if (players.getScoreboard().getObjective("lobby") != null){
                            players.setScoreboard(sb);
                            score = objective.getScore(ChatColor.GREEN + "Kills:");
                            score.setScore(1);
                            //sb.getObjective(DisplaySlot.SIDEBAR).getScore(Bukkit.getOfflinePlayer(ChatColor.WHITE + "" +
                            //              ChatColor.BOLD + "Kills:")).setScore(5);
                            //sb.getObjective(DisplaySlot.SIDEBAR).getScore(Bukkit.getOfflinePlayer(ChatColor.GOLD + "" + ChatColor.BOLD + StatsManager.getPlayerKills(players.getName()))).setScore(4);
                    }
            }*/
          
            @SuppressWarnings("deprecation")
            public void setTeams() {
                    red.setAllowFriendlyFire(false);
                    red.setCanSeeFriendlyInvisibles(true);
                    red.setPrefix(ChatColor.RED + "[R]");
                    red.setDisplayName(ChatColor.RED + "");
                  
                    blue.setAllowFriendlyFire(false);
                    blue.setCanSeeFriendlyInvisibles(false);
                    blue.setPrefix(ChatColor.BLUE + "[B]");
                    blue.setDisplayName(ChatColor.BLUE + "");
                  
                    for (Player all : Bukkit.getOnlinePlayers()) {
                            all.setScoreboard(board);
                    }
            }
          
            public void endGame() {
                  
            }
          
            public void startGame() {
                  
            }
          
            public String getTeamRedSize() {
                    return Integer.toString(red.getSize());
            }
          
            public String getTeamBlueSize() {
                    return Integer.toString(blue.getSize());
            }
    }
    ERROR:
    Code:
    04.02 04:13:43 [Server] INFO at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:298) ~[spigot1657.jar:git-Spigot-1.7.9-R0.2-207-g03373bb]
    04.02 04:13:43 [Server] INFO at java.lang.reflect.Method.invoke(Method.java:483) ~[?:1.8.0_31]
    04.02 04:13:43 [Server] INFO at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_31]
    04.02 04:13:43 [Server] INFO at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_31]
    04.02 04:13:43 [Server] INFO at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_31]
    04.02 04:13:43 [Server] INFO at PVPGame.Listeners.InteractEvent.onPlayerClick(InteractEvent.java:26) ~[?:?]
    04.02 04:13:43 [Server] INFO Caused by: java.lang.NoClassDefFoundError: Could not initialize class PVPGame.Utils.GameManager
    04.02 04:13:43 [Server] INFO at net.minecraft.server.v1_7_R4.ThreadServerApplication.run(SourceFile:628) [spigot1657.jar:git-Spigot-1.7.9-R0.2-207-g03373bb]
    04.02 04:13:43 [Server] INFO at net.minecraft.server.v1_7_R4.MinecraftServer.run(MinecraftServer.java:490) [spigot1657.jar:git-Spigot-1.7.9-R0.2-207-g03373bb]
    04.02 04:13:43 [Server] INFO at net.minecraft.server.v1_7_R4.MinecraftServer.u(MinecraftServer.java:584) [spigot1657.jar:git-Spigot-1.7.9-R0.2-207-g03373bb]
    04.02 04:13:43 [Server] INFO at net.minecraft.server.v1_7_R4.DedicatedServer.v(DedicatedServer.java:289) [spigot1657.jar:git-Spigot-1.7.9-R0.2-207-g03373bb]
    04.02 04:13:43 [Server] INFO at net.minecraft.server.v1_7_R4.MinecraftServer.v(MinecraftServer.java:734) [spigot1657.jar:git-Spigot-1.7.9-R0.2-207-g03373bb]
    04.02 04:13:43 [Server] INFO at net.minecraft.server.v1_7_R4.ServerConnection.c(ServerConnection.java:81) [spigot1657.jar:git-Spigot-1.7.9-R0.2-207-g03373bb]
    04.02 04:13:43 [Server] INFO at net.minecraft.server.v1_7_R4.NetworkManager.a(NetworkManager.java:186) [spigot1657.jar:git-Spigot-1.7.9-R0.2-207-g03373bb]
    04.02 04:13:43 [Server] INFO at net.minecraft.server.v1_7_R4.PacketPlayInBlockDig.handle(PacketPlayInBlockDig.java:65) [spigot1657.jar:git-Spigot-1.7.9-R0.2-207-g03373bb]
    04.02 04:13:43 [Server] INFO at net.minecraft.server.v1_7_R4.PacketPlayInBlockDig.a(PacketPlayInBlockDig.java:41) [spigot1657.jar:git-Spigot-1.7.9-R0.2-207-g03373bb]
    04.02 04:13:43 [Server] INFO at net.minecraft.server.v1_7_R4.PlayerConnection.a(PlayerConnection.java:552) [spigot1657.jar:git-Spigot-1.7.9-R0.2-207-g03373bb]
    04.02 04:13:43 [Server] INFO at net.minecraft.server.v1_7_R4.PlayerInteractManager.dig(PlayerInteractManager.java:103) [spigot1657.jar:git-Spigot-1.7.9-R0.2-207-g03373bb]
    04.02 04:13:43 [Server] INFO at org.bukkit.craftbukkit.v1_7_R4.event.CraftEventFactory.callPlayerInteractEvent(CraftEventFactory.java:242) [spigot1657.jar:git-Spigot-1.7.9-R0.2-207-g03373bb]
    04.02 04:13:43 [Server] INFO at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:494) [spigot1657.jar:git-Spigot-1.7.9-R0.2-207-g03373bb]
    04.02 04:13:43 [Server] INFO at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:509) [spigot1657.jar:git-Spigot-1.7.9-R0.2-207-g03373bb]
    04.02 04:13:43 [Server] INFO at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[spigot1657.jar:git-Spigot-1.7.9-R0.2-207-g03373bb]
    04.02 04:13:43 [Server] INFO at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:302) ~[spigot1657.jar:git-Spigot-1.7.9-R0.2-207-g03373bb]
    04.02 04:13:43 [Server] INFO org.bukkit.event.EventException
    04.02 04:13:43 [Server] ERROR Could not pass event PlayerInteractEvent to TheNetworkPVPGame v0.1
    04.02 04:13:41 [Server] INFO ... 15 more
     
  6. Offline

    TGRHavoc

    04.02 04:13:43 [Server] INFO at PVPGame.Listeners.InteractEvent.onPlayerClick(InteractEvent.java:26) is your problem. Post your InteractEvent class.
     
  7. Offline

    timtower Administrator Administrator Moderator

    Moved to Bukkit alternatives
     
  8. Offline

    Burnett

    @jusjus112 PVPGame.Listeners.InteractEvent.onPlayerClick(InteractEvent.java:26) This next.
     
  9. Offline

    jusjus112

    @Burnett @TGRHavoc
    Doenst matter, i have more errors, and thats given the same error but other classes.
    It concerns me that class can not enter, and it's always the same error
    this is code for each class:
    Code:
    GameManager.getManager()....
    And when i do this, doenst matter wich class. Im getting this error
    Before i have added this scoreboard code, it works, But now it isnt
     
  10. Offline

    Burnett

    @jusjus112 Instead of creating the class instance like that why not create it in your main class. Removes statics so everyone can be happy.
     
    TGRHavoc likes this.
  11. Offline

    TGRHavoc

    It does matter, it's the line that is giving you the error so, whatever you're trying to do on line 26 in your InteractEvent class is causing said error.

    A class can always "enter" as long as you call the constructor.

    More of a suggestion:
    Have you tried putting your main GameManager in your main class instead of making it handle itself.

    Edit:

    @jusjus112 are you using another plugins' API (e.g. WorldEdit) in your plugin. If you are then make sure that you're "softdepend/depend"-ing in your plugin.yml file with the name of the plugin you're using and, make sure that you have the all plugins needed installed on the server that you're testing on.
     
    Last edited: Feb 4, 2015
Thread Status:
Not open for further replies.

Share This Page