Solved Why static doesn't work ?

Discussion in 'Spigot Plugin Development' started by Froyzz, May 27, 2016.

  1. Hi guys !
    I'm trying to use static but it doesn't work:
    Code (Text):
    @EventHandler
        public static void onmort(EntityDeathEvent event) throws IOException{
           
            Entity p = event.getEntity();
           
            if (p.getType() == EntityType.PIG_ZOMBIE){
                if (p.isCustomNameVisible()){
                    if (p.getWorld().getName().equals("world")){
                       
                        long iaabc = System.currentTimeMillis();
                        Config.setTimeHero(iaabc);
                        Config.save();
                        if (plugin.getConfig().getLong("Time") != 0){
                           
                        Bukkit.broadcastMessage("There is a reload so this is this step");
                       
                    long time = plugin.getConfig().getLong("Time");
                    long tempshero = plugin.getConfig().getLong("TempsHero");
                    long tth = time-tempshero;
                    long temps = 86400000-tth;
                    long finaltime = temps*1000/20;                                                
                                 
                     Integer Schedule = Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {                                
                                 
                        @Override
                        public void run() {                        
    I need to use "Schedule" variable for :
    Code (Text):
    public void onDisable(){
            if(Bukkit.getServer().getScheduler().isCurrentlyRunning(););
                long i = System.currentTimeMillis();
                try {
                    Config.setTime(i);
                    Config.save();
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
        }
            }
    My static doesn't appear in is currentlyrunning so it doesn't works :/
    I dont know why, may you help me please
     
    • Funny Funny x 3
    • Put the exception in a try/catch instead of adding "throws" in the event constructor.
    • Follow Java conventions and name your variables in camelCase form, not like This.
    • Use primitive types and use int instead of Integer.
    • isCurrentlyRunning(int taskId)
    • Why do you have a semicolon in the middle of the statement?
    • Events shouldn't be in static, as you aren't supposed to directly call them by using the method name.
     
    • Useful Useful x 1
  2. Thank you very much :)