This repository has been archived by the owner on Jun 5, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
config.txt
131 lines (112 loc) · 4.9 KB
/
config.txt
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#=========================================================================#
#
# Command Helper sample config file
#
#=========================================================================#
#lines that start with # are comments
#Give command, with material name lookup
# Note that the second variable $qty is optional, and if no value
# is given, 1 is the default. The function player() returns the
# name of this player, and data_values() turns "stone" into 1
# Also note that the command is labelled with "creative". If you
# are running a creative server, and the users should always be able to give
# themselves items, then they can do so with this command, without having to be
# opped.
creative:/i $data [$qty=1] = sudo(concat(/give player() data_values($data) $qty))
###
*:/enchant wither = >>>
if(equals(@event[levels], 10),
modify_event(enchants, array(array(etype: 'ARROW_FIRE', elevel: 0)))
)
if(equals(@event[levels], 20),
#msg(@event[levels])
modify_event(enchants, array(array(etype: 'ARROW_FIRE', elevel: -1)))
assign(@level, get_itemmeta(@event[player], pinfo(@event[player], 15)))
if(nequals(@level[enchants], null),
assign(@level, @level[enchants])
assign(@level, @level[0])
assign(@level, @level[elevel])
)
)
<<<
*:/explosion = >>>
assign(@loc, ploc(player()))
#msg(@loc)
#explosion(@loc, $size, true)
msg(set_pvelocity(player(), array(x: 0, y: 20, z: 0, magnitude: 8)))
set_pvelocity(player(), array(x: 0, y: 20, z: 0))
<<<
#Give the player a diamond pickaxe, shovel, and axe
# Note that commands are separated by \ and this creates a macro
/kit diamond = /give player() data_values('diamond_pickaxe') 1 \
/give player() data_values('diamond_spade') 1 \
/give player() data_values('diamond_axe') 1
###
#Give the player 64 each of gold tools
# Note that the data_values function uses the enum values of
# the material
/kit gold = /give player() data_values('gold_pickaxe') 64 \
/give player() data_values('gold_spade') 64 \
/give player() data_values('gold_axe') 64
###
#Sets the time on the server, and uses english words to set the time
#If the english word isn't "day" or "night", it uses the number
# Note that the equals function returns a true value if the two
# parameters are the same, and if() runs the second argument if the
# first argument is true, and the third argument if it is false.
# To make an "if else" statement, you can nest if() calls, as shown
# here.
/time $time = /time set if(equals($time, 'day'), 1, if(equals($time, 'night'), 13500, $time))
###
#Better tp. If "/tp name" is used, it implies "/tp thisplayer name"
#but if "/tp name1 name2" is used, it implies "/tp name1 name2"
/tp $p1 [$p2=''] = /tp if(equals($p2, ''), player(), $p1) if(equals($p2, ''), $p1, $p2)
###
#Simple alias for /tell
# The special variable "$" must be the last variable, and it matches all
# the arguments from that point on
/msg $player $ = /tell $player $
###
#Simple alias for /save-all
# Super simple aliases can be error proofed by matching all arguments, then
# not using them. Note that this will result in a warning, but it will
# compile fine.
/save $ = /save-all
###
#Shows help information
# This demonstrates how to use die() and msg(). They work basically the same, except
# die() kills the command if evaluated. They both send a message to the player.
#/help [$cmd=''] = if(equals($cmd, ''), die('Do you need halp?'), if(equals($cmd, 'commandhelper'), msg('The best plugin ever!'), ''))
###
#Echoes information back to the user
# This demonstrates how to do string concatenation
/ping $ = die(concat('Pong!', ' ', $))
#Kills the player, optionally with a message. Demonstrates how to use the multiline construct.
thor:/thor $player [$=''] = >>>
lightning(ploc($player))
msg('Thou hast smitten the evil player ', $player, ' with thy mighty hand')
tmsg($player, color('red'), if(equals($, ''), 'You have been smitten by Thor\'s Hammer!', $))
pkill($player)
<<<
#Suppose we have a plugin that broadcasts messages only to moderators, but it doesn't include the user's name
#Also suppose that it is a very long command.
#We can use this command to fix that:
/mb $ = /mod-broadcast concat('(',player(),')') $
#Lets notify our users to use the new, shorter version
/mod-broadcast [$] = die(concat(color('red'), 'Use /mb instead of /mod-broadcast'))
#Creates a simple way to control the weather
rain:/rain $true_false = storm($true_false)
#Demonstrates the for function, as well as ivars
#Lists all players on the server
/list = >>>
#Initialize an empty string
assign(@pl, '')
assign(@ap, all_players())
#loop through the array stored in @ap, from 0 to one less than the size of the array
for(assign(@i, 0), lt(@i, array_size(@ap)), assign(@i, add(@i, 1)),
#append our player's name to the end of @pl string
assign(@pl, concat(@pl, @ap[@i], ' '))
)
#output the string
msg(@pl)
<<<