Date: 2017/10/13 08:06:41 UTC-07:00
Type: Denizen Script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
###############################################################################
# #
# GRANDPARTYUTILITIES: VANILLA POTION BEHAVIOR #
# #
###############################################################################
#
# This script does not require "gpa_gpu_main.yml" to work. Without
# "gpa_gpu_versionCheck", this script will assume you are running the latest
# stable Spigot build.
#
#
# ----| ABOUT THIS SCRIPT
#
# This script allows users to cast multiple potion effects at once while
# maintaining vanilla potion effect casting behavior. This means casted effects
# will not override existing potion effects on an entity if the said potion
# effect fulfills one of two requirements:
# 1. has a stronger potency level
# 2. has the same potency level but higher duration
#
#
# ----| HOW TO USE
#
# Run this command in your script:
# - run gpa_gpu_vanilla_potion_behavior def:entity|SPIGOT_POTION_EFFECT_NAME,
# power,duration_in_ticks,ambience,hide_particles|SPIGOT_POTION_EFFECT_NAME
# ,power,duration_in_ticks,ambience,hide_particles|...
#
# You can specify as many potion effects, for as long as you follow that
# command format.
#
# If any of your potion effects are invalid, the script will skip over it while
# notifying you via console.
# If the entity is invalid, the script won't run.
# If you don't specify a potion effect, the script won't run.
#
#
gpa_gpu_vanilla_potion_behavior:
type: task
debug: false
speed: 0
script:
- if <queue.definitions.size> < 2 {
- queue clear
}
- if <def[1].as_entity||null> == null {
- queue clear
}
- define valid_effects 'li@ABSORPTION|BLINDNESS|CONFUSION|DAMAGE_RESISTANCE|FAST_DIGGING|FIRE_RESISTANCE|HARM|HEAL|HEALTH_BOOST|HUNGER|INCREASE_DAMAGE|INVISIBILITY|JUMP|NIGHT_VISION|POISON|REGENERATION|SATURATION|SLOW|SLOW_DIGGING|SPEED|WATER_BREATHING|WEAKNESS|WITHER'
- if <proc[gpa_gpu_versionCheck]||9999> >= 1 {
- define valid_effects '<def[valid_effects].include[GLOWING|LEVITATION|LUCK|UNLUCK]>'
}
- foreach <def[raw_context].as_list.remove[1]||li@> {
- define edata '<def[value].split[,]>'
- if <def[edata].size> != 5 {
- announce '<&c>Invalid amount of arguments! Syntax is <&dq>SPIGOT_POTION_EFFECT_NAME,power,duration_in_ticks,hide_ambience,hide_particles<&dq>, you input <&dq><def[value]><&dq>' format:gpa_gpu_vanilla_potion_behavior_chat_format to_console
- foreach next
}
- if !<def[valid_effects].contains[<def[edata].get[1]||null>]> {
- announce '<&c>Invalid potion effect! You input <&dq><&6><def[edata].set[<&6><def[edata].get[1]><&c>].at[1].separated_by[,]><&dq>' format:gpa_gpu_vanilla_potion_behavior_chat_format to_console
- foreach next
}
- if <def[edata].get[2].as_decimal||null> == null || <def[edata].get[2].contains_text[.]||true> || <def[edata].get[2]||-100> < 0 {
- announce '<&c>Invalid power! You input <&dq><def[edata].set[<&6><def[edata].get[2]><&c>].at[2].separated_by[,]><&dq>' format:gpa_gpu_vanilla_potion_behavior_chat_format to_console
- foreach next
}
- if <def[edata].get[2]> > 255 {
- announce '<&c>Power cannot exceed 255! You input <&dq><def[edata].set[<&6><def[edata].get[2]><&c>].at[2].separated_by[,]><&dq>' format:gpa_gpu_vanilla_potion_behavior_chat_format to_console
- foreach next
}
- if <def[edata].get[3].as_decimal||null> == null || <def[edata].get[3].contains_text[.]||true> || <def[edata].get[3]||-100> < 0 {
- announce '<&c>Invalid duration (in ticks)! You input <&dq><def[edata].set[<&6><def[edata].get[3]><&c>].at[3].separated_by[,]><&dq>' format:gpa_gpu_vanilla_potion_behavior_chat_format to_console
- foreach next
}
- if <def[edata].get[3]> > 20000000 {
- announce '<&c>Duration cannot exceed 1000000s (20000000 ticks)! You input <&dq><def[edata].set[<&6><def[edata].get[3]><&c>].at[3].separated_by[,]><&dq>' format:gpa_gpu_vanilla_potion_behavior_chat_format to_console
- foreach next
}
- if !<li@true|false.contains[<def[edata].get[4]>]> {
- announce '<&c>hide_ambience must be true or false! You input <&dq><def[edata].set[<&6><def[edata].get[4]><&c>].at[4].separated_by[,]><&dq>' format:gpa_gpu_vanilla_potion_behavior_chat_format to_console
- foreach next
}
- if !<li@true|false.contains[<def[edata].get[5]>]> {
- announce '<&c>hide_particles must be true or false! You input <&dq><def[edata].set[<&6><def[edata].get[5]><&c>].at[5].separated_by[,]><&dq>' format:gpa_gpu_vanilla_potion_behavior_chat_format to_console
- foreach next
}
- define effect '<def[1].list_effects.filter[starts_with[<def[edata].get[1]>]].get[1].split[,]||NULL_EFFECT>'
- if <def[effect]> != 'NULL_EFFECT' {
- if <def[effect].get[2]> > <def[edata].get[2]> {
- foreach next
}
- if <def[effect].get[2]> == <def[edata].get[2]> && <def[effect].get[3].as_duration.in_ticks> > <def[edata].get[3]> {
- foreach next
}
}
- if <def[edata].get[5]> {
- cast <def[edata].get[1]> power:<def[edata].get[2]> d:<def[edata].get[3]>t <def[1]> hide_particles
}
else if <def[edata].get[4]> {
- cast <def[edata].get[1]> power:<def[edata].get[2]> d:<def[edata].get[3]>t <def[1]> no_ambient
}
else {
- cast <def[edata].get[1]> power:<def[edata].get[2]> d:<def[edata].get[3]>t <def[1]>
}
}
gpa_gpu_vanilla_potion_behavior_chat_format:
type: format
debug: false
format: '[<&a>GPU<&r> <&2>VPB<&r>] <text>'