dGraveyards
By
BloodEkoCreated: 2017/01/05 21:52:49 UTC-08:00 (7 years and 352 days ago)
Edited: 2018/12/02 11:44:01 UTC-08:00 (6 years and 21 days ago)
Likes: 2
Denizen Version: tested for 1.12, should work in other versions as well
Script Version: 1.0
Description:
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.
Download script |
View raw script#---------------------------------------------+
#Created: 05.01.17 |
#Last rewrite: 02.12.18 |
#Last change: 02.12.18 |
# |
#dGraveyards by BloodEko |
# |
# Let your players spawn on the nearest |
# of your predefined locations |
# |
# spawning: no permission required |
# editing 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. |
#---------------------------------------------+
# This is a version script to use certain functions of the repo.
dGraveyards_config:
type: version
version: 1.0
id: 124
link: http://one.denizenscript.com/denizen/repo/entry/124
dGraveyards_eventHandler:
type: world
#Teleport the player, when he dies in these worlds.
worlds:
- w@Spielplatz
- w@world
- w@world_nether
- w@world_end
# KEEP_NOTHING = Loose XP and Items
# KEEP_INV = Loose XP
# KEEP_LEVEL = LOOSE ITEMS
# KEEP_ALL = LOOSE NOTHING
deathType: KEEP_ALL
#Message showed to player after respawn.
message: "You respawned on a safe place."
############################
#BELOW INTERNAL PLUGIN CODE#
#EDITS ARE NOT RECOMMED #
############################
events:
on player respawns:
- if !<player.has_flag[dGrave.respawn]> queue clear
- define loc <server.flag[dGrave.locs.<pl.world>].sort_by_number[distance_squared[<pl.location>]].get[1]||x>
- if <def[loc]> == x queue clear
- narrate <script.yaml_key[message]>
- determine <def[loc]>
on player dies:
- if !<script.yaml_key[worlds].contains[<pl.world>]>
|| !<server.has_flag[dGrave.locs.<pl.world>]> queue clear
Line with no clear purpose - missing a -dash- or :colon:?
- choose <script.yaml_key[deathType]||all>:
- case KEEP_INV:
- determine passively KEEP_INV
- case KEEP_LEVEL:
- determine passively KEEP_LEVEL
- case KEEP_ALL:
- determine passively KEEP_INV
- determine passively KEEP_LEVEL
- default:
- define 1 1
- flag player dGrave.respawn
#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_CommandHandler:
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> {
- debug error "/dGrave is only useable ingame."
- queue clear
}
- choose <context.args.get[1]||x>:
- case set:
- if <context.args.size> < 2 inject locally syntaxError
- define name <c.args.get[2]||x>
- if <server.has_flag[dGrave.name.<def[name]>]> {
- narrate "<&4>ERROR Graveyard with the name <&6><def[name]> <&4>already exists."
- queue clear
}
- narrate "<&2>Created <&2>graveyard<&6>[<def[name]>]"
- define loc <pl.location>
- flag server dGrave.locs.<pl.world>:->:<def[loc]>
- flag server dGrave.name.<def[name]>:<def[loc]>
- flag server dGrave.loc.<def[loc].escaped>:<def[name]>
- case delete:
- if <context.args.size> < 2 inject locally syntaxError
- define name <c.args.get[2]||x>
- if !<server.has_flag[dGrave.name.<def[name]>]> {
- narrate "<&4>ERROR Graveyard with the name <&6><def[name]> <&4>doesn't exists."
- queue clear
}
- narrate "<&2>Deleted <&2>graveyard<&6>[<def[name]>]"
- define loc <server.flag[dGrave.name.<def[name]>]>
- flag server dGrave.locs.<pl.world>:<-:<def[loc]>
- flag server dGrave.name.<def[name]>:!
- flag server dGrave.loc.<def[loc].escaped>:!
- case list:
- define list <server.list_flags[dGrave.name].remove[1]||li@>
- define size <def[list].size||0>
- if <def[size]> == 0 {
- narrate "No graveyards found."
- queue clear
}
- define page <context.args.get[2].as_int||1>
- if <def[page]> !matches number {
- narrate "<&4>ERROR <&6><def[page]> <&4>is no valid number."
- queue clear
}
- define pages <def[size].div[10].round_up>
- if <def[pages]> < <context.args.get[2]||1> {
- narrate "<&6>There are only <&f><def[pages]> <&6>pages. Showing page <&f>1 <&6>instead."
- define page "1"
}
- if <def[size]> <= 10 {
- narrate "-----[<&6>Graveyard page <&f>1/1]-----"
}
else {
- narrate "-----[<&6>Graveyard page <&f><def[page]>/<def[pages]>]-----"
}
- define pageFrom <el@val[1].add[<def[page].sub[1].mul[10]>]>
- define pageTo <def[page].mul[10]>
- foreach <def[list].get[<def[pageFrom]>].to[<def[pageTo]>]> {
- narrate " <&a><def[value].after[dGrave.name.]>"
}
- case tp:
- if <context.args.size> < 2 inject locally syntaxError
- define name <c.args.get[2]||x>
- if !<server.has_flag[dGrave.name.<def[name]>]> {
- narrate "<&4>ERROR Graveyard with the name <&6><def[name]> <&4>doesn't exists."
- queue clear
}
- narrate "<&2>Teleporting <&2> to <&6>[<def[name]>]"
- teleport <server.flag[dGrave.name.<def[name]>]>
- case nearest:
- if !<server.has_flag[dGrave.locs.<pl.world>]> {
- narrate "No graveyards found."
- queue clear
}
- define nearest <server.flag[dGrave.locs.<pl.world>].sort_by_number[distance_squared[<pl.location>]].get[1]||x>
- define distance <def[nearest].distance[<pl.location>].round_to[2]>
- narrate "<&2>Nearest graveyard is <&6><server.flag[dGrave.loc.<def[nearest].escaped>]> <&2>with a distance of <&6><def[distance]> <&2>blocks."
- showfake red_wool <def[nearest]> d:5s
- default:
- inject locally syntaxError
syntaxError:
- narrate "/dGrave | set (name) | delete (name) | list | tp (name) | nearest"
- queue clear
View History