Stats Plugin

Discussion in 'Spigot Plugin Development' started by Tycoons, Apr 17, 2017.

  1. Hey. I'm currently making a stats plugin for my network.

    I'm trying to do 'how many blocks placed' and 'how many blocks broken'. I tried the following code:

    Code (Text):
        @EventHandler
        public void onBlockBreak(BlockBreakEvent e) {
            Player p = e.getPlayer();
       
            if (!(e.isCancelled())) {
                // code to add one to the total
            }
       
        }
    However, even if I break a block in a WorldGuard region (and it cancels it), it still counts to the stats.

    Any suggestions? :/

    I tried looking at the WorldGuard API however there was nothing there that seemed like it could help me.

    I'm trying to make a GUI automatically update every second. The reason for this is because I have a play time feature:

    [​IMG]

    And I want it to auto update without having to close the GUI menu.

    I already tried to put it in a runnable and update it every second but it didn't work. Any suggestions?
     
    #1 Tycoons, Apr 17, 2017
    Last edited: Apr 17, 2017
  2. Use priority monitor and see if it's cancelled after worldguard instead.
     
  3. I tried this:

    Code (Text):
    @EventHandler(priority=EventPriority.LOWEST)
    But it didn't work.
     
  4. It doesn't work because that is only checking if it was canceled in your plugin. The cancellation of the event is not tracked server side.
     
  5. The order for executing listeners goes:
    - LOWEST
    - LOW
    - NORMAL
    - HIGH
    - HIGHEST
    - MONITOR, and though it is last (making it perfect for monitoring), it shouldn't change shit with the event.
     
  6. Fixed, thanks :p
     
  7. I'm trying to make a GUI automatically update every second. The reason for this is because I have a play time feature:

    [​IMG]

    And I want it to auto update without having to close the GUI menu.

    I already tried to put it in a runnable and update it every second but it didn't work. Any suggestions?
     
  8. Just change the item. This won't close inventory, won't reset mouse or anything alike.
    Don't call updateInventory either.
     
  9. FIixed it. Thanks :p