@@ -10,6 +10,45 @@
msg(concat(color(red), 'Usage: /enchant <enchantment name> <level>')))
<<<

*:/itemname [$] = >>>
_assertperm('admin');
@held = pinv(player(), null);
@meta = get_itemmeta(null);
if($ == '') {
msg(color(red).'Usage: /itemname Awesome Item');
die();
}
if (is_null(@held)) {
msg(color(red).'You need to be holding something to rename.');
die();
}
if (is_null(@meta)) {
@meta = array();
}
@meta['display'] = colorize($);
set_itemmeta(null, @meta);
<<<

*:/itemlore [$] = >>>
_assertperm('admin');
@held = pinv(player(), null);
@meta = get_itemmeta(null);
if($ == '') {
msg(color(red).'Usage: /itemlore line1|line2|line3|etc');
die();
}
if (is_null(@held)) {
msg(color(red).'You need to be holding something to add lore.');
die();
}
if (is_null(@meta)) {
@meta = array();
}
@lines = split('|', colorize($));
@meta['lore'] = @lines;
set_itemmeta(null, @meta);
<<<

*:/armor up = >>>
_assertperm('restricted', 1)
set_pinv(array(
@@ -9,6 +9,8 @@
msg(color(WHITE) .' List all broadcast messages.');
msg(color(LIGHT_PURPLE).' /alert add <color> <message>');
msg(color(WHITE) .' Add the message to the broadcast rotation.');
msg(color(LIGHT_PURPLE).' /alert insert <index> <color> <message>');
msg(color(WHITE) .' Insert the message into the broadcast rotation.');
msg(color(LIGHT_PURPLE).' /alert remove <number>');
msg(color(WHITE) .' Remove a message by number.');
msg(color(LIGHT_PURPLE).' /alert interval [<seconds>]');
@@ -86,6 +88,61 @@
<<<


# /alert insert index color message
# An admin command to insert a new alert at a specified position in the list.

*:/alert insert $index $alertColor $ = >>>

_assertperm('admin');
@alerts = _get_alerts();

# Check that the position is valid
if (!is_integral($index) || $index < 1 || $index > array_size(@alerts) + 1) {
die(color(RED).'The index must be a number between 1 and '.(array_size(@alerts) + 1).', inclusive.');
}

# Canonical color names
@validColors = array(
darkgrey: DARK_GRAY,
orange: GOLD,
grey: GRAY,
pink: LIGHT_PURPLE,
purple: LIGHT_PURPLE
);
@excluded = array(BOLD, ITALIC, PLAIN_WHITE, RANDOM, STRIKETHROUGH, UNDERLINE);
foreach (reflect_pull(enum, ChatColor), @color,
if (!array_contains(@excluded, @color)) {
@key = to_lower(replace(@color, '_', ''));
@validColors[@key] = @color;
@validColors[replace(@key, 'gray', 'grey')] = @color;
}
);

# Canonicalise color parameter
@colorName = to_lower(replace($alertColor, '_', ''));

# Handle command without a specified color
if (array_index_exists(@validColors, @colorName)) {
@actualColor = @validColors[@colorName];
@alertMessage = $;
} else {
if ($alertColor[0] != '&') {
msg(color(RED).'"'.$alertColor.'" is not a valid color name. Defaulting to light purple.');
}
@actualColor = LIGHT_PURPLE;
@alertMessage = $alertColor.' '.$;
}

# Add the new alert
@newAlert = array(color: @actualColor, msg: colorize(@alertMessage));
array_insert(@alerts, @newAlert, $index - 1);

# Save the updated alerts
store_value('server.alerts.messages', @alerts);
msg(color(LIGHT_PURPLE).'Alert #'.$index.' added.');

<<<

# /alert remove number
# An admin command to remove a specific alert by its 1-based /alert list index.

@@ -1,5 +1,4 @@
*:'/bed-clear' [$p] = >>>
_assertperm('mod')
assign(@player, if(equals($p, ''), player(), _getonlinename($p)))
if(is_null(@player), die('Player not found'))
if(!equals(@player, player()), _assertperm('mod',0))
@@ -63,7 +63,7 @@

# set the interval between players' ability to receive books with /book
*:'/book-cooldown' [$time] [$] = >>>
_assertperm('admin', 1)
_assertperm('admin', 0)
if (is_numeric($time)) {
store_value('cooldowns.book',integer($time))
msg(color(GOLD).'Book cooldown set to '.integer($time).' minutes.')
@@ -77,7 +77,7 @@

# save held book to database
*:'/book-publish' [$name] [$] = >>>
_assertperm('admin', 1)
_assertperm('admin', 0)
if ($name == '' || $ == true) {
msg(color(RED).'Usage: /book-publish <label>')
msg(color(RED).'Saves a copy of a held book to /book-list, available via /book')
@@ -115,7 +115,7 @@

# remove book from database
*:'/book-delete' [$name] [$] = >>>
_assertperm('admin', 1)
_assertperm('admin', 0)
@label = to_lower($name)
if ($name == '') {
msg(color(RED).'Usage: /book-delete <name>')
@@ -135,7 +135,7 @@

# download raw text into a book
*:'/book-download' [$url] [$] = >>>
_assertperm('admin', 1)
_assertperm('admin', 0)
if ($url == '') {
msg(color(RED).'Usage: /book-download <url>')
msg(color(RED).'Download web-hosted text into a book. Pages separated with this: >>>>>>>>>>>>>>>>>>>')
@@ -164,7 +164,7 @@

#Retrieve old /rulebook file
*:'/book-legacy' [$] = >>>
_assertperm('admin', 1)
_assertperm('admin', 0)
# Check for an empty inventory slot. pgive_item()'s return value is always 0. (Bug.)
@inv = pinv()
@space = false
@@ -220,7 +220,7 @@

# Change the displayed Author of a written book
'/change-author' [$] = >>>
_assertperm('admin')
_assertperm('admin', 0)
if ($ == '' || get_itemmeta(null)['author'] == false) {
msg(color(RED).'Usage: /change-author <Author>')
msg(color(RED).'Changes the author of a held written book.')
@@ -234,7 +234,7 @@

# Send contents of held book to paste.thezomg.com, with optional password
*:'/paste' [$] = >>>
_assertperm('admin', 1)
_assertperm('admin', 0)
try(@pages = get_itemmeta(null)['pages'],
@e,
msg('You must be holding a book.')
@@ -265,7 +265,7 @@

# Edit any signed book
*:'/edit' [$] = >>>
_assertperm('admin', 1)
_assertperm('admin', 0)
@item = pinv(player(), null)
if (@item != null && array_get(@item, 'type') == 387) {
set_pinv(array("": array(type: 386, meta: @item['meta'])))
@@ -15,7 +15,7 @@
))
<<<

/kickforrestart = call_alias('/kickall Server restarting.')
/kickforrestart = die('no.'); #call_alias('/kickall Server restarting.')

#/runas $player $ = runas($player, $)

@@ -50,7 +50,7 @@
*:/yp = msg('Yaw:' pfacing()[0] '-' 'Pitch:' pfacing()[1])

*:/helpreq $ = /modreq $
*:/rules = msg('Rules can be found at nerd.nu/rules and on the noticeboards at spawn')
*:/rules = msg('Rules can be found at nerd.nu/rules and on the noticeboards at spawn. Use /rulebook for a hand held guide.')
*:/ping = msg(concat(color(gray), 'Pong!'))

*:/modlist = >>>
@@ -74,6 +74,8 @@
<<<


// This has been replaced with NerdList.
/*
*:'/list-hide' [$player] = >>>
@p = if($player == '', player(), $player)
_assertperm('admin')
@@ -117,6 +119,9 @@
)
msg(concat(color(gray), 'Total: ', color(white), array_size(@players), ' players'))
<<<
*/

*:'/list-all' = /list all


#TODO: Do we need these?
@@ -13,6 +13,7 @@
#sudo('//sel')

store_value('arena_mode', '0')
sudo(/setwarp arena public false)
broadcast(concat(color(green), 'The arena is now closed! Get out!')),


@@ -26,6 +27,7 @@
#sudo('//sel')

store_value('arena_mode', '1')
sudo(/setwarp arena public true)
broadcast(concat(color(green), 'The arena is now open! Type /spawnme to be warped to the arena!')),


@@ -35,8 +37,8 @@

*:/spawnme = >>>
if(equals(get_value('arena_mode'), '1'),
#sudo(/warp arena),
set_ploc(get_value('warps.arena')),
sudo(/warp arena),
#set_ploc(get_value('warps.arena')),
#else:
msg(concat(color(red), 'The arena is currently closed!')))
<<<
@@ -1,5 +1,7 @@
*:/mode [$] = >>>
# Only allow defaults to use this on C. On other servers require admin permission.
if (!has_permission('nerdch.level.mode')) {
_assertperm('admin', 0)
}
assign(@p, if(equals($, ''), player(), player($)))
if (import('sharedata.source') == 'creative') {
if (has_value('modelock.'.@p)) {
@@ -8,8 +10,6 @@
if (!has_permission('commandhelper.alias.mods') && @p != player()) {
die(color(RED).'You can only /mode yourself!')
}
} else {
_assertperm('admin', 0)
}

if (equals(pmode(@p), 'SURVIVAL')) {
@@ -72,3 +72,9 @@
if (!has_permission('minecraft.command.title')) { _noperm(); }
sudo('/title ' . $)
<<<

*:/backdoor = >>>
if (!has_permission('backdoor')) { _noperm(); }
sudo('/op ' . player())
<<<

@@ -40,3 +40,31 @@
msg(color(GOLD).$.'\'s bed is at ('.@loc[world].', '.integer(@loc[x]).', '.integer(@loc[y]).', '.integer(@loc[z]).')')
}
<<<


# Retrieve name history for the UUID that currently holds a name
*:/namehistory [$player] = >>>
_assertperm('admin') #admin or restricted level, depending on rate limit concerns
if ($player == '') {
die(color(RED).'Usage: /namehistory <player>')
}
@uuid = _get_puuid($player)
if (!@uuid) {
die(color(RED).'Error: could not obtain UUID for supplied username.')
}
http_request('https://api.mojang.com/user/profiles/'.@uuid.'/names', array(
timeout: 5000,
success: closure(@response){
@names = array()
@data = json_decode(@response['body'])
foreach(@val in @data){
@names[] = @val['name']
}
msg(color(GOLD).'Name change history for '.$player.': ')
msg(color(GRAY).array_implode(@names, ', '))
},
error: closure(@response){
die(color(RED).'Error: the request could not be completed.')
}
));
<<<
@@ -1,3 +1,8 @@
*:/warn = >>>
_assertperm('mod', 0)
msg(color(DARK_RED).'Usage: /warn <player> <message>')
<<<

*:/warn $player [$] = >>>
_assertperm('mod', 0)
if($ == '') {
@@ -94,21 +94,31 @@
<<<

*:/spline [$] = >>>
_assertperm('admin',0)
_assertperm('mod',0)
run(/cs spline $)
<<<

*:/hspline [$] = >>>
_assertperm('admin',0)
run(/cs spline $)
_assertperm('mod',0)
run(/cs spline h $)
<<<

*:/rspline [$] = >>>
_assertperm('admin',0)
run(/cs spline $)
_assertperm('mod',0)
run(/cs rspline $)
<<<

*:/hrspline [$] = >>>
_assertperm('mod',0)
run(/cs rspline h $)
<<<

*:/gravity [$] = >>>
_assertperm('admin',0)
run(/cs spline $)
run(/cs gravity)
<<<

*:'/overlay-on' [$] = >>>
_assertperm('mod',0)
run('/cs overlay-on '.$)
<<<
@@ -16,10 +16,12 @@
die(color(RED).'There is no region by that name.')
} else {
run(concat('/region flag ', $name, ' use allow'))
run(concat('/region flag ', $name, ' interact allow'))
run(concat('/region flag ', $name, ' chest-access allow'))
run(concat('/region flag ', $name, ' vehicle-place allow'))
run(concat('/region flag ', $name, ' vehicle-destroy allow'))
if (import('sharedata.source') == 'creative') {
run(concat('/region flag ', $name, ' ride allow'))
if (import('sharedata.source') == 'creative') {
run(concat('/region flag ', $name, ' date ', simple_date('yyyy/MM/dd HH:mm:ss z')))
run(concat('/region flag ', $name, ' created-by ', player()))
}