Solved Stopwatch 1.14.4 but it doesnt work ?

Discussion in 'Plugin Development' started by monkafynix, Nov 26, 2019.

  1. Offline

    monkafynix

    Code:
    package de.monkafynix.playthrough.commands;
    
    import org.bukkit.Bukkit;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.craftbukkit.v1_14_R1.entity.CraftPlayer;
    import org.bukkit.entity.Player;
    
    import de.monkafynix.playthrough.main.Main;
    import net.minecraft.server.v1_14_R1.PacketPlayOutTitle;
    import net.minecraft.server.v1_14_R1.IChatBaseComponent.ChatSerializer;
    import net.minecraft.server.v1_14_R1.PacketPlayOutTitle.EnumTitleAction;
    
    public class TimerResume implements CommandExecutor {
    
        @Override
        public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
            if(sender instanceof Player) {
                Player player = (Player) sender;
                if(args.length == 1) {
                   
                    if(args[0].equalsIgnoreCase("resume")) {
                       
                        Bukkit.getScheduler().scheduleSyncRepeatingTask(Main.getPlugin(), new Runnable() {
                           
                            int countdowns = 00;
                            int countdownm = 00;
                            int countdownh = 00;
                           
                                                   
                            @Override                                   
                            public void run() {
                                int pog = 2147483647;
                                //Sekunden
                                switch(countdowns) {
                                default:
                                    PacketPlayOutTitle title = new PacketPlayOutTitle(EnumTitleAction.ACTIONBAR,
                                            ChatSerializer.a("{\"text\":\"§6Der Timer läuft:§f 00 : 00 : " + countdowns +"\"}"),pog,pog,pog);
                                    ((CraftPlayer)player).getHandle().playerConnection.sendPacket(title);
                                   
                                   
                           
                                    //Minuten
                                    if(countdowns >= 60) {
                                        Bukkit.getScheduler().scheduleSyncRepeatingTask(Main.getPlugin(), new Runnable() {
                                   
                                            @Override
                                            public void run() {
                                       
                                   
                                                switch(countdownm) {
                                                default:
                                                    PacketPlayOutTitle title = new PacketPlayOutTitle(EnumTitleAction.ACTIONBAR,
                                                            ChatSerializer.a("{\"text\":\"§6Der Timer läuft:§f 00 : "+ countdownm +" : " + countdowns +"\"}"),pog,pog,pog);
                                                    ((CraftPlayer)player).getHandle().playerConnection.sendPacket(title);
                                           
                                                    //Stunden       
                                                    if(countdownm >= 60) {
                                                        Bukkit.getScheduler().scheduleSyncRepeatingTask(Main.getPlugin(), new Runnable() {
                                                   
                                                            @Override
                                                            public void run() {
                                                       
                                               
                                                                switch(countdownh) {
                                                                default:
                                                                    PacketPlayOutTitle title = new PacketPlayOutTitle(EnumTitleAction.ACTIONBAR,
                                                                            ChatSerializer.a("{\"text\":\"§6Der Timer läuft:§f "+ countdownh +" : "+ countdownm +" : " + countdowns +"\"}"),pog,pog,pog);
                                                                    ((CraftPlayer)player).getHandle().playerConnection.sendPacket(title);
                                                           
                                                                    if(countdownh >= 24) {
                                                                        return;
                                                               
                                                               
                                                                    }
                                                       
                                                                }countdownh++;
                                                       
                                                       
                                                            }
                                                        }, 1, 72000);
                                               
                                               
                                               
                                                    }
                           
                                           
                                                }countdownm++;
                                       
                                       
                                            }
                                        }, 0 , 1200);
                               
                               
                                    }
                           
                                }countdowns++;
                           
                               
                               
                               
                        }
                        }, 0 , 20);
                       
                    }else if(args[0].equalsIgnoreCase("reset")) {
                       
                        int pog = 2147483647;
                        PacketPlayOutTitle title = new PacketPlayOutTitle(EnumTitleAction.ACTIONBAR,
                                ChatSerializer.a("{\"text\":\"§6Der Timer ist gestoppt\"}"),pog,pog,pog);
                        ((CraftPlayer)player).getHandle().playerConnection.sendPacket(title);
                       
                    }
                   
                }else
                    player.sendMessage("§cBitte benutze §6/timer resume §coder §6/timer reset§c!");
               
                           
            }
           
            return false;
        }
    
    }
    
     
  2. Online

    timtower Moderator Moderator

  3. Offline

    monkafynix

    Code:
    java.lang.NullPointerException: null
            at de.monkafynix.playthrough.main.Main.onEnable(Main.java:18) ~[?:?]
            at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:263) ~[spigot.jar:git-Spigot-9de398a-9c887d4]
            at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:352) [spigot.jar:git-Spigot-9de398a-9c887d4]
            at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:417) [spigot.jar:git-Spigot-9de398a-9c887d4]
            at org.bukkit.craftbukkit.v1_14_R1.CraftServer.enablePlugin(CraftServer.java:461) [spigot.jar:git-Spigot-9de398a-9c887d4]
            at org.bukkit.craftbukkit.v1_14_R1.CraftServer.enablePlugins(CraftServer.java:375) [spigot.jar:git-Spigot-9de398a-9c887d4]
            at org.bukkit.craftbukkit.v1_14_R1.CraftServer.reload(CraftServer.java:810) [spigot.jar:git-Spigot-9de398a-9c887d4]
            at org.bukkit.Bukkit.reload(Bukkit.java:576) [spigot.jar:git-Spigot-9de398a-9c887d4]
            at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:27) [spigot.jar:git-Spigot-9de398a-9c887d4]
            at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:149) [spigot.jar:git-Spigot-9de398a-9c887d4]
            at org.bukkit.craftbukkit.v1_14_R1.CraftServer.dispatchCommand(CraftServer.java:710) [spigot.jar:git-Spigot-9de398a-9c887d4]
            at org.bukkit.craftbukkit.v1_14_R1.CraftServer.dispatchServerCommand(CraftServer.java:695) [spigot.jar:git-Spigot-9de398a-9c887d4]
            at net.minecraft.server.v1_14_R1.DedicatedServer.handleCommandQueue(DedicatedServer.java:433) [spigot.jar:git-Spigot-9de398a-9c887d4]
            at net.minecraft.server.v1_14_R1.DedicatedServer.b(DedicatedServer.java:397) [spigot.jar:git-Spigot-9de398a-9c887d4]
            at net.minecraft.server.v1_14_R1.MinecraftServer.a(MinecraftServer.java:971) [spigot.jar:git-Spigot-9de398a-9c887d4]
            at net.minecraft.server.v1_14_R1.MinecraftServer.run(MinecraftServer.java:816) [spigot.jar:git-Spigot-9de398a-9c887d4

    that are the errors in my console but in total i get no errors. I'm new to coding so idk how to fix it.
     
  4. Online

    timtower Moderator Moderator

    @monkafynix You probably didn't register the command in the plugin.yml
     
  5. Offline

    monkafynix

    i did
    Code:
    name: yeet
    version: 1.0
    main: de.monkafynix.playthrough.main.Main
    commands:
       timer:
          description: Starte den Timer!
    I asked a good friend as well but he hasn't no idea either
     
  6. Online

    timtower Moderator Moderator

  7. Offline

    monkafynix

    Code:
    package de.monkafynix.playthrough.main;
    
    import org.bukkit.Bukkit;
    import org.bukkit.plugin.java.JavaPlugin;
    
    import de.monkafynix.playthrough.commands.TimerResume;
    import de.monkafynix.playthrough.listener.TimerListener;
    
    public class Main extends JavaPlugin {
        private static Main plugin;
    
        @Override
        public void onEnable() {
            plugin =this;
           
            //Commands
           
            getCommand("inv").setExecutor(new TimerResume());
           
           
            //Events
            Bukkit.getPluginManager().registerEvents(new TimerListener(), this);
        }
        public static Main getPlugin() {
            return plugin;
           
           
           
        }
    }
     
  8. Online

    timtower Moderator Moderator

    @monkafynix
    getCommand("inv").setExecutor(new TimerResume());
    inv isn't the command you registered.
     
  9. Offline

    monkafynix

    Im so stupid sry thank you xd
     
    timtower likes this.

Share This Page