Paste #38820: Diff note for paste #38819

Date: 2017/01/07 00:58:30 UTC-08:00
Type: Diff Report

View Raw Paste Download This Paste
Copy Link


 #---------------------------------------------+ 
 #Created: 05.01.17                            |
 #Last change: 06.01.17                        | 
 #dGraveyards by BloodEko                      | 
 #                                             | 
 #   Let your players spawn on the nearest     |
 #      of your predefined locations           | 
 #                                             | 
 #   spawning: no permission required          | 
 #   defining graveyards: op / dgrave.admin    |
 #                                             | 
 #---------------------------------------------+ 
 # Usage: /dgrave                              | 
 #---------------------------------------------+ 
 # When a player dies in of the defined worlds | 
 # and one/multiple graveyards exist in this   |
 # world, he will respawn on the nearest one   | 
 # to him and get affected by the defined      | 
 # settings(loose items/xp, message) , else    | 
 # he would just respawn normally and don't    |
 # get affected by dGraveyards.                |
 #---------------------------------------------+
 #
 # Only edit settings in the config documented
 # with a [] arround.
 #
 #
 dGraveyards_config:
   type: version
-  version: 0.2
+  version: 0.4
   id: 124
   link: http://one.denizenscript.com/denizen/repo/entry/124
   #
   #[When a player dies in these worlds, he will get teleported.]
   #
   affected_worlds:
   - world
   - world_nether
   - world_end
   #
   #[Whether he respawns with his items on a graveyard, or drops them normally.]
   #
   loose_items_on_death: true
   #
   #[Whether he respawns with his XP on a graveyard, or drops them normally.]
   #
   loose_xp_on_death: true
   #
   #[When a player respawns he will get this message]
   #
   respawn_message: "You respawned on a safe place."
 #
 #
 #
 #
 #
 ############################
 #BELOW INTERNAL PLUGIN CODE#
 #EDITS ARE NOT RECOMMED    #      
 ############################
 dGraveyards_handler:
   type: world
   events:
   #
   #
   #RESPAWN EVENT
   #
     on player respawns:
     - define player_location "<player.flag[dgrave.location].as_location>"
     - define location_list <server.flag[dgrave.worlds.<def[player_location].world.name>].as_list||x>
     - define respawn_location "<def[location_list].sort_by_number[distance_squared[<def[player_location]>]].get[1]||x>"
     - if <def[respawn_location]> == x {
       - queue clear
       }
     - choose "<player.flag[dgrave.getback]||nothing>":
       - case "items":
         - inventory set d:<player.inventory> o:<player.flag[dgrave.inv].as_list||li@>
         - adjust <player> "equipment:<player.flag[dgrave.armor].as_list||li@i@air|i@air|i@air|i@air>"
       - case "xp":
         - experience give <player.flag[dgrave.xp]||0> player:<player>
       - case "all":
         - experience give <player.flag[dgrave.xp]||0> player:<player>
         - inventory set d:<player.inventory> o:<player.flag[dgrave.inv].as_list||li@>
         - adjust <player> "equipment:<player.flag[dgrave.armor].as_list||li@i@air|i@air|i@air|i@air>"
     - narrate "<s@dGraveyards_config.yaml_key[respawn_message]>"
     - determine <def[respawn_location]>
     #
     #
     #DIE EVENT
     #
     on player dies:
     - define player_location "<player.flag[dgrave.location].as_location>"
     - if !<s@dGraveyards_config.yaml_key[affected_worlds].contains[<player.location.world.name>]> || <server.flag[dgrave.worlds.<def[player_location].world.name>].as_list||x> == x {
       - queue clear
       }
     - define loose_items <s@dGraveyards_config.yaml_key[loose_items_on_death]||true>
     - define loose_xp <s@dGraveyards_config.yaml_key[loose_xp_on_death]||true>
     - flag player "dgrave.location:<player.location>"
     # Verliert XP und Items
     - if <def[loose_items]> && <def[loose_xp]> {
       - flag player "dgrave.getback:nothing"
       }
     # Verliert nur XP
       else if !<def[loose_items]> && <def[loose_xp]> {
       - flag player "dgrave.getback:items"
       - determine passively NO_DROPS
       }
     # Verliert nur Items
       else if <def[loose_items]> && !<def[loose_xp]> {
       - flag player "dgrave.getback:xp"
       - determine passively NO_XP
       }
     # Verliert nichts
       else {
       - flag player "dgrave.getback:all"
       - determine passively NO_DROPS_OR_XP
       }
     - flag player "dgrave.xp:<player.xp.total>"
     - flag player "dgrave.inv:!"
     - flag player "dgrave.inv:|:<player.inventory.list_contents||li@>"
     - flag player "dgrave.armor:!"
     - flag player "dgrave.armor:|:<player.equipment>"
     on system time hourly:
     - ~webget "http://morphanone.space/webizen.aspx/tracker?script=124&version=<s@dGraveyards_config.yaml_key[version]||0.1>&players=<server.list_online_players.size||0>"
 dgrave_command_handler:
   type: command
   name: dgrave
   usage: /dgrave
   description: Managing graveyard ingame
   permission: dgrave.admin
   permission message: You don't have the permission for using this command.
   script:
   - if <context.server> { - narrate "<&4>Commands only useable ingame." - queue clear }
   - choose "<context.args.get[1]>":
     - case "set":
       - if <context.args.size> == 1 { - inject locally dgrave_false_syntax - queue clear }
       - if <server.has_flag[dgrave.names.<context.args.get[2]>]> {
         - narrate "<&4>ERROR Graveyard with the name <&6><context.args.get[2]> <&4>already exists."
         }
         else if <server.flag[dgrave.worlds.<player.location.world.name>].contains[<player.location>]> {
         - define name "<server.flag[dgrave.locations.<player.location.replace[.].with[_]>]>"
         - narrate "<&4>ERROR on your location is already a graveyard with the name <&6><def[name]>."
         }
         else {
         - narrate "<&2>Successfully <&6>created <&2>graveyard with the name <&6><context.args.get[2]>"
         - flag server dgrave.worlds.<player.location.world.name>:->:<player.location>
         - flag server dgrave.names.<context.args.get[2]>:<player.location>
         - flag server dgrave.locations.<player.location.replace[.].with[_]>:<context.args.get[2]>
         }
     - case "delete":
       - if <context.args.size> == 1 { - inject locally dgrave_false_syntax - queue clear }
       - if !<server.has_flag[dgrave.names.<context.args.get[2]>]> {
         - narrate "<&4>ERROR Graveyard with the name <&6><context.args.get[2]> <&4>doesn't exist."
         }
         else {
         - narrate "<&2>Successfully <&6>deleted <&2>graveyard with the name <&6><context.args.get[2]>"
         - define location <server.flag[dgrave.names.<context.args.get[2]>]>
         - flag server dgrave.worlds.<def[location].as_location.world.name>:<-:<def[location]>
         - flag server dgrave.locations.<server.flag[dgrave.names.<context.args.get[2]>].get[1].replace[.].with[_]>:!
         - flag server dgrave.names.<context.args.get[2]>:!
         }
     - case "list":
       - define dgrave_amount "<server.list_flags.filter[starts_with[dgrave.names.]].size||0>"
       - if <def[dgrave_amount]> < 1 { - narrate "No graveyards found." - queue clear }
       - if <context.args.get[2]||1> !matches number {
         - narrate "<&4>ERROR <&6><context.args.get[2]> <&4>is no valid number."
         - queue clear
         }
       - define pages_amount "<def[dgrave_amount].div[10].round_up>"
       - define page "<context.args.get[2].as_int||1>"
       - if <def[pages_amount]> < <context.args.get[2]||1> {
         - narrate "<&6>There are only <&f><def[pages_amount]> <&6>pages. Showing page <&f>1 <&6>instead."
         - define page "1"
         }
       #
       - if <def[dgrave_amount]> <= 10 {
         - narrate "-----[<&6>Graveyard page <&f>1/1 ]-----"
         }
         else {
         - narrate "-----[<&6>Graveyard page <&f><def[page]>/<def[pages_amount]> ]-----"
         }
       - define page_from "<el@val[1].add[<el@val[<def[page]>].sub[1].mul[10]>]>"
       - define page_to "<def[page].mul[10]>"
       - foreach <server.list_flags.filter[starts_with[dgrave.names.]].get[<def[page_from]>].to[<def[page_to]>]> {
         - narrate "   <&a><def[value].after[dgrave.names.]>"
         }
     - case "tp":
       - if <context.args.size> == 1 { - inject locally dgrave_false_syntax - queue clear }
       - if !<server.has_flag[dgrave.names.<context.args.get[2]>]> {
         - narrate "<&4>ERROR Graveyard with the name <&6><context.args.get[2]> <&4>doesn't exist."
         }
         else {
         - narrate "<&2>Successfully <&6>teleporting <&2>you to <&6><context.args.get[2]>"
         - define location <server.flag[dgrave.names.<context.args.get[2]>].as_location>
         - teleport <player> <def[location]>
         }
     - case "distance":
       - define location_list <server.flag[dgrave.worlds.<player.location.world.name>].as_list||0>
       - if <def[location_list].size||0> < 1 { - narrate "No graveyards found." - queue clear }
       - define respawn_location "<def[location_list].sort_by_number[distance_squared[<player.location>]].get[1]>"
       - define distance "<def[respawn_location].distance[<player.location>]>"
       - narrate "<&2>Nearest graveyard is <&6><server.flag[dgrave.locations.<def[respawn_location].replace[.].with[_]>]> <&2>with a distance of <&6><def[distance]> <&2>blocks."
       - showfake m@red_wool <def[respawn_location]> players:<player> d:d@5s
     - default:
       - inject locally dgrave_false_syntax
   dgrave_false_syntax:
   - narrate "/dgrave | set <&lt>name<&gt> | delete <&lt>name<&gt> | list | tp <&lt>name<&gt> | distance"
-