Solved Plugin not loading unless /reload

Discussion in 'Plugin Development' started by TheBlueBlaster, Dec 3, 2015.

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

    TheBlueBlaster

    So when I restart my server my server doesn't load. But when I do /reload it loads up. Can someone help me fix this?
    Code:
    03.12 19:04:53 [Server] INFO ... 6 more
    03.12 19:04:53 [Server] INFO at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:131) ~[spigot.jar:git-Spigot-d97e08b-880a532]
    03.12 19:04:53 [Server] INFO at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:76) ~[spigot.jar:git-Spigot-d97e08b-880a532]
    03.12 19:04:53 [Server] INFO at java.lang.Class.newInstance(Unknown Source) ~[?:1.8.0_60]
    03.12 19:04:53 [Server] INFO at java.lang.reflect.Constructor.newInstance(Unknown Source) ~[?:1.8.0_60]
    03.12 19:04:53 [Server] INFO at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) ~[?:1.8.0_60]
    03.12 19:04:53 [Server] INFO at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) ~[?:1.8.0_60]
    03.12 19:04:53 [Server] INFO at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_60]
    03.12 19:04:53 [Server] INFO at me.BlastedStar.UHCTeleport.Main.<init>(Main.java:48) ~[?:?]
    03.12 19:04:53 [Server] INFO Caused by: java.lang.NullPointerException
    03.12 19:04:53 [Server] INFO at java.lang.Thread.run(Unknown Source) [?:1.8.0_60]
    03.12 19:04:53 [Server] INFO at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:524) [spigot.jar:git-Spigot-d97e08b-880a532]
    03.12 19:04:53 [Server] INFO at net.minecraft.server.v1_8_R3.DedicatedServer.init(DedicatedServer.java:198) [spigot.jar:git-Spigot-d97e08b-880a532]
    03.12 19:04:53 [Server] INFO at org.bukkit.craftbukkit.v1_8_R3.CraftServer.loadPlugins(CraftServer.java:292) [spigot.jar:git-Spigot-d97e08b-880a532]
    03.12 19:04:53 [Server] INFO at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:251) [spigot.jar:git-Spigot-d97e08b-880a532]
    03.12 19:04:53 [Server] INFO at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:329) ~[spigot.jar:git-Spigot-d97e08b-880a532]
    03.12 19:04:53 [Server] INFO at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:135) ~[spigot.jar:git-Spigot-d97e08b-880a532]
    03.12 19:04:53 [Server] INFO org.bukkit.plugin.InvalidPluginException: java.lang.NullPointerException
    03.12 19:04:53 [Server] ERROR Could not load 'plugins/UHCTeleport.jar' in folder 'plugins'
    I cant really find where its null?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Nov 26, 2017
  2. Offline

    Scimiguy

  3. Offline

    Zombie_Striker

    @TheBlueBlaster
    We can't do that either, you haven't showed us your code.

    BTW: I don't see how you can't find it. You know the line (Main class, line 48), and if you have any knowledge of Java, you should be able to create null checks for all the variables on that line.
     
  4. Offline

    TheBlueBlaster

    Well on 48 there is nothing. Well there was before but then I removed what was there, updated it, and it still says 48 when there is nothing
     
  5. Offline

    Scimiguy

  6. Offline

    TheBlueBlaster

    If you mean use the export button i already did that.

    EDIT:

    Nvm. I look in the console there is no errors but when I join it does not do what I want it to do unless i do /reload

    PHP:
    @EventHandler
        
    public void onJoin(PlayerJoinEvent e) {
            
    Player player e.getPlayer();
            for (
    PotionEffect pe player.getActivePotionEffects()) {
                
    player.removePotionEffect(pe.getType());
            }
            
    player.getInventory().setHelmet(null);
            
    player.getInventory().setChestplate(null);
            
    player.getInventory().setLeggings(null);
            
    player.getInventory().setBoots(null);
            if (
    GameState.isState(GameState.LOBBY)) {
                
    player.setGameMode(GameMode.ADVENTURE);
            }
            if (
    GameState.isState(GameState.GAME)) {
                
    player.setGameMode(GameMode.SPECTATOR);
                
    spectators.add(player);
                return;
            }
            
    players.add(player);
            
    player.getInventory().clear();
            if (
    playerAmount >= 1) {
                
    Bukkit.dispatchCommand(Bukkit.getConsoleSender(),
                        
    "countdown start 10s lobby");
                for (
    Player p Bukkit.getOnlinePlayers()) {
                    
    GameState.setState(GameState.GAME);
                    
    p.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS,
                            
    200255));
                    
    p.addPotionEffect(new PotionEffect(PotionEffectType.JUMP200,
                            
    250));
                    
    p.addPotionEffect(new PotionEffect(PotionEffectType.SLOW200,
                            
    255));
                    
    p.addPotionEffect(new PotionEffect(
                            
    PotionEffectType.REGENERATION500255));
                    
    p.addPotionEffect(new PotionEffect(
                            
    PotionEffectType.DAMAGE_RESISTANCE500255));
                    
    p.addPotionEffect(new PotionEffect(
                            
    PotionEffectType.FIRE_RESISTANCE500255));
                    
    p.addPotionEffect(new PotionEffect(
                            
    PotionEffectType.WATER_BREATHING500255));
                    
    p.addPotionEffect(new PotionEffect(PotionEffectType.SATURATION,
                            
    15255));
                    
    p.addPotionEffect(new PotionEffect(
                            
    PotionEffectType.NIGHT_VISION181001));
                    
    p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED,
                            
    181001));
                    
    p.addPotionEffect(new PotionEffect(
                            
    PotionEffectType.FAST_DIGGING181001));

                 
                    
    Bukkit.dispatchCommand(Bukkit.getConsoleSender(),
                            
    "gamerule naturalRegeneration false");
                
                    
    WorldBorder b Bukkit.getWorld("world").getWorldBorder();
                    
    World world Bukkit.getWorld("world");

                    
    p.playSound(p.getLocation(), Sound.LEVEL_UP31);
                    
    canKit true;
                    
    world.setTime(0);

                    
    ItemStack boots = new ItemStack(Material.LEATHER_BOOTS1);
                    
    boots.addEnchantment(Enchantment.DEPTH_STRIDER3);
                    
    player.getInventory().setBoots(boots);

                    
    b.setCenter(new Location(Bukkit.getWorld("world"), 010));
                    
    b.setSize(1000);
                }
            }
        }
     
    Last edited: Dec 4, 2015
  7. Offline

    MCMatters

    any bukkit variables need to be instanced onEnable not in class load
     
  8. Offline

    TheBlueBlaster

    What do you exactly mean by bukkit variables?
     
  9. Offline

    mcdorli

    Don't feel yourself stupid, I myself don't understand it too.
     
  10. Offline

    TheBlueBlaster

  11. Offline

    Scimiguy

    I think he means any methods relating to the server or other plugins or something, in which he would be correct.

    How he came to that conclusion though, I have no idea
     
  12. Offline

    TheBlueBlaster

    yeah... i dont get that... well would you know how to fix it. the plugin all works except for player join but it works on /reload
     
  13. Offline

    Scimiguy

    Show us your full class
     
  14. Offline

    TheBlueBlaster

    Removed code.
     
    Last edited: Dec 4, 2015
  15. Offline

    Scimiguy

    int playerAmount =this.getServer().getOnlinePlayers().size();

    There's your problem.

    That line will be called as soon as the server loads your class (which is well before the worlds, or the server is even loaded).
    There will never be any players on at that point, and there probably wouldn't even be a players collection by that point either
     
  16. Offline

    TheBlueBlaster

    YES! Thank you so much xD. Marking as Solved
     
Thread Status:
Not open for further replies.

Share This Page