Sign Update

Discussion in 'Plugin Development' started by TheGamblingMan, Jun 20, 2014.

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

    TheGamblingMan

    Hey
    I have createt with the SignChangeEvent and some stats out of My database a sign but how can i make that this sign get's updatet every 1200 Ticks?
     
  2. Offline

    Lolmewn

    Create a scheduler!
     
  3. Offline

    TheGamblingMan

    Yes I know that i need a scheduler but around what?

    Do i have to get the location when it get's createt?
     
  4. Offline

    MineStein

    Using the scheduler, trigger the SignChangeEvent every 1200 ticks!
     
  5. Offline

    TheGamblingMan

    so i have to make a scheduler around the whoel class where i have the signchangeevent and the thing that i get the data from the database?

    that is how i create the sign
    Code:java
    1. @EventHandler
    2. public void onsign(SignChangeEvent e) throws SQLException {
    3. Player pa = e.getPlayer();
    4. if ((match(e.getLine(0), new String[] { "[platz1]" }))
    5. && (pa.hasPermission("rushlobby.signs"))) {
    6. e.setLine(0, "§0§l1.Platz");
    7. getTopPlayers();
    8. String uuid = Haupt.result.get(0);
    9.  
    10. String name = Bukkit.getServer()
    11. .getOfflinePlayer(UUID.fromString(uuid)).getName();
    12.  
    13. e.setLine(1, name);
    14. e.setLine(2, "§0§lSeine Kills:");
    15.  
    16. int ki = f.getkillsuu(name);
    17.  
    18. String kills = Integer.toString(ki);
    19.  
    20. e.setLine(3, "§0§r" + kills);
    21.  
    22. }
    23. if ((match(e.getLine(0), new String[] { "[platz2]" }))
    24. && (pa.hasPermission("rushlobby.signs"))) {
    25. e.setLine(0, "§0§l2.Platz");
    26. getTopPlayers();
    27. String uuid = Haupt.result.get(1);
    28.  
    29. String name = Bukkit.getServer()
    30. .getOfflinePlayer(UUID.fromString(uuid)).getName();
    31.  
    32. e.setLine(1, name);
    33. e.setLine(2, "§0§lSeine Kills:");
    34.  
    35. int ki = f.getkillsuu(name);
    36.  
    37. String kills = Integer.toString(ki);
    38.  
    39. e.setLine(3, "§0§r" + kills);
    40.  
    41. }
    42. if ((match(e.getLine(0), new String[] { "[platz3]" }))
    43. && (pa.hasPermission("rushlobby.signs"))) {
    44. e.setLine(0, "§0§l3.Platz");
    45. getTopPlayers();
    46. String uuid = Haupt.result.get(2);
    47.  
    48. String name = Bukkit.getServer()
    49. .getOfflinePlayer(UUID.fromString(uuid)).getName();
    50.  
    51. e.setLine(1, name);
    52. e.setLine(2, "§0§lSeine Kills:");
    53.  
    54. int ki = f.getkillsuu(name);
    55.  
    56. String kills = Integer.toString(ki);
    57.  
    58. e.setLine(3, "§0§r" + kills);
    59.  
    60. }
    61.  
    62. }


    How do i trigger the event?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
  6. Offline

    TechNotes

    TheGamblingMan

    Right, so if you want to make a scheduled event, do:

    Code:java
    1. plugin.getServer().getScheduler()
    2. .scheduleSyncRepeatingTask(plugin, new BukkitRunnable() {
    3. public void run() {
    4. }
    5. }, tick_delay_before_starting_event, tick_delay_before_next_iteration);


    Everything in the run() method will be called after every 1200 ticks (once you set it)
     
  7. Offline

    mythbusterma

  8. Offline

    TheGamblingMan

    I know how i make a scheduler but i don't know how i get the plugin in it and i think i have to make the scheduler in the onEnable() because when the server stops i don't want to create the signs again that the scheduler starts
     
  9. Offline

    TechNotes

    If it's in your main class, you can just do:

    Code:java
    1. this.getServer().getScheduler()...


    or if you're calling it in a different class, get an instance of your main class and do:

    Code:java
    1. instance.getServer().getScheduler()...
     
  10. Offline

    TheGamblingMan

    sry my fail i didn't mean plugin i wanted to say event i don't know how i get the event in the scheduler

    something with callEvent?

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

Share This Page