Interval Update every 10 min.

Discussion in 'Plugin Development' started by edocsyl, Feb 15, 2012.

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

    edocsyl

    Hi

    I wanna post something on a sign. But the informating changes every 10 Min. This means i need to auto update this every 10 Min.

    My quesstion is now:
    How could i do this. I thought about a interval or something else.
    Any other idea?
     
  2. Offline

    Njol

  3. Offline

    edocsyl

  4. Offline

    theaxeman

    also don't forget you need to update the chunk to update the sign. Something along the lines of (i think).

    block.getWorld().refreshChunk(block.getChunk().getX(), block.getChunk().getZ());
     
  5. Offline

    TopGear93

    wouldnt that just cuase unneeded stress on the server? edocsyl just do a repeating aSync on the specific sign. Maybe give each sign a title and track it.


    PHP:
                    Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable(){
                        public 
    void run(){
                      
    String title sign.getLine(0);
                      if(
    title.equals("<signtitle>")){
                      
    sign.update();
                            }
                        }}, 
    20L72800L);//every minecraft week. you can set any time :P
     
  6. Offline

    theaxeman

    Ah, yes you have a point, got the code from one of my plugins that happen to update the chunk and also sign text. Didn't look at the rest of the code with sign.updates in ! well spotted. :)
     
  7. Offline

    edocsyl

    Where am I going to past this part?
    Code:
        @Override
        public void onEnable() {
            log.info("[Test] has been enabled.");
            
              Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable(){
                  public void run(){
                      Bukkit.getServer().broadcastMessage("Test");
                  }
              }, 20L, 200L);
        }
    
    This is wrong.

    Code:
    2012-02-18 11:11:32 [SEVERE] Error occurred while enabling Test v1.0 (Is it up to date?): Plugin cannot be null
    java.lang.IllegalArgumentException: Plugin cannot be null
        at org.bukkit.craftbukkit.scheduler.CraftScheduler.scheduleSyncRepeatingTask(CraftScheduler.java:200)
        at me.edocsyl.Test.Test.onEnable(Test.java:33)
        at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:230)
        at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:1057)
        at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:380)
        at org.bukkit.craftbukkit.CraftServer.loadPlugin(CraftServer.java:199)
        at org.bukkit.craftbukkit.CraftServer.enablePlugins(CraftServer.java:182)
        at net.minecraft.server.MinecraftServer.t(MinecraftServer.java:357)
        at net.minecraft.server.MinecraftServer.a(MinecraftServer.java:344)
        at net.minecraft.server.MinecraftServer.init(MinecraftServer.java:175)
        at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:408)
        at net.minecraft.server.ThreadServerApplication.run(SourceFile:465)
     
  8. Actually it is not.
    Can you next time look what the error is and think about it? " 'plugin' cannot be null" doesn't mean it's wrong.
     
  9. Offline

    blargh

    edocsyl replace plugin with this?basically its the pluginClass and you can give him the Plugin Object with that
     
  10. Offline

    edocsyl

    blargh Thx. It works! Just copied and don't think -.-

    Code:
             Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable(){
                  public void run(){
                      World world = Bukkit.getWorld("test_mc");
                      Block block = world.getBlockAt(40, 75, 32);
                      if (block.getType() == Material.SIGN || block.getType() == Material.SIGN_POST){
                          Sign sign = (Sign) block.getState();
                              sign.setLine(0, "Current time:");
                              sign.setLine(1, getTime()); 
                      }      
                  }
              }, 20L, 30L);
    
    This is just a simple test to look how it updates, but well it doesn't.
    When i start the server, it update after not.
    Any idea why?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 24, 2016
Thread Status:
Not open for further replies.

Share This Page