Paste #36991: Diff note for paste #36990

Date: 2016/10/17 18:31:51 UTC-07:00
Type: Diff Report

View Raw Paste Download This Paste
Copy Link


 # ClearLag - A replacement script for the plugin called ClearLagg 
 # By Mwthorn 
 
 # Use "/clearlag clear" to request a clear. (goes outside the normal timer) 
 # Use "/clearlag" to check when the next clear is inbound. 
 
 # Config Area below 
 ClearLag_Data: 
     type: yaml data 
     config: 
         timer: 
             # Here you can change the time for each clear and adjust it to the player-base on the server. 
             # This means that there will be faster clear times if more players are online. 
             # This is because; if a lot of players are online, many items could be dropped. (depends on your server gamemode) 
             # The example goes like this: 
             # Players 0-40 = 3m delay per clear 
             # Players 40-70 = 2m delay per clear 
             # Players 70-100 = 1m delay per clear 
             # Players 100-1000 = 1m delay per clear 
             1:  
                 players: 40 
                 time: 3m 
             2:  
                 players: 70 
                 time: 2m 
             3:  
                 players: 100 
                 time: 1m 
             4:  
                 players: 1000 
                 time: 1m 
 
 # End of config (beyond is the actual script code, edit if you know what you are doing) 
 
 ClearLag_Version:
     type: version
     name: ClearLag
     id: 118
     description: A replacement script for the plugin called ClearLagg
     version: 1
 
 ClearLag_Events: 
     type: world 
     events: 
 
         on server start: 
         - run Clearlag_Event_Cycle instantly 
         
         on system time hourly: 
         - webget "http://stats.denizenscript.com/tracker?script=<s@ClearLag_Version.yaml_key[id]>&version=<s@ClearLag_Version.yaml_key[version]>"        
         - wait 25s 
         - if <server.has_flag[ClearLag_Countdown].not> { 
             - wait 5s 
             - if <server.has_flag[ClearLag_Countdown].not> { 
                 - run Clearlag_Event_Cycle instantly 
             } 
         } 
 
 Clearlag_Event_Cycle: 
     type: task 
     debug: false 
     script: 
     - announce format:util_ff "<&7>Removing all ground items in 10 seconds" 
     - wait 10s 
     - flag server ClearLag_While 
     - define size <server.list_online_players.size> 
     - while <server.has_flag[ClearLag_While]> { 
         - if <def[size]> < <s@ClearLag_Data.yaml_key[config.timer.<def[loop_index]>.players]> { 
             - define time <s@ClearLag_Data.yaml_key[config.timer.<def[loop_index]>.time]> 
             - flag server ClearLag_While:! 
         } 
         - wait 1t 
     } 
     - flag server ClearLag_Countdown duration:<def[time]> 
     - inject Clearlag_Task 
     - wait <def[time].as_duration.sub[10]> 
     - run Clearlag_Event_Cycle instantly 
      
 Clearlag_Task_Forced: 
     type: task 
     script: 
     - announce format:util_ff "<&7>Staff has requested to remove items in 3 seconds" 
     - wait 3s 
     - inject Clearlag_Task 
      
 Clearlag_Task: 
     type: task 
     debug: false 
     script: 
     - define arrows <w@world.entities.filter[name.is[EQUALS].to[ARROW]].filter[is_on_ground]> 
     - define items <w@world.entities.filter[name.is[EQUALS].to[DROPPED_ITEM]]> 
     - define total <def[items].include[<def[arrows]>]> 
     - remove <def[total]> 
     - announce format:util_ff "<&7>Removed <&e><def[total].size> <&7>items." 
      
 Clearlag_Commands: 
     type: command 
     debug: false 
     name: clearlag 
     aliases: 
     - lagg 
     - cleartime 
     - cleart 
     - cleartid 
     - clearlagtime 
     - clearlagtid 
     - clearlagg 
     - clearlaggtime 
     script: 
     - if <player.has_permission[qmod.mod].global> && <context.args.size> >= 1 { 
         - if <context.args.get[1]> == "clear" { 
             - inject Clearlag_Task_Forced 
         } 
         - queue clear 
     } 
     - narrate format:util_ff "Next clear lag is in <&b><server.flag[ClearLag_Countdown].expiration.formatted||0>"