Date: 2022/11/04 10:24:39 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
dcommands_tempban:
type: command
name: tempban
description: Bans someone temporarily.
usage: /tempban [name] [duration] [reason]
permission: dcommands.tempban
tab completions:
1: <server.online_players.parse[name]>
data:
arguments:
minimum: 3
maximum: 999
debug: true
script:
- inject dcommands_inject_arguments
- inject dcommands_inject_player
#- if <[player]> == <player>:
# - narrate "<&[error]>You cannot tempban yourself!"
# - stop
- define duration <context.args.get[2]>
- if <duration[<[duration]>].exists>:
- if <[player].is_banned>:
- narrate "<&[error]>This player is already banned!"
- stop
- inject dcommands_server_definitions
- inject dcommands_ban_definitions
- define reason <context.raw_args.after[<[duration]>].substring[2]>
- define duration <duration[<[duration]>]>
- announce "<[server.prefix]><&color[<[server.color]>]><[server.name]><&r><[server.suffix]> <&color[<[ban.message.color]>]>Player <[name]> has been temporarily banned for <&color[<[ban.value]>]><[duration].formatted_words><&color[<[ban.message.color]>]>, for <&dq><&color[<[ban.value]>]><[reason]><&color[<[ban.message.color]>]><&dq>."
- announce to_console "<&color[<[ban.message.color]>]><player.name> has temporarily banned <[name]> for <[duration].formatted_words>, for <&dq><[reason]><&dq>."
- flag <[player]> dcommands.tempbanned.expiration:<util.time_now.add[<[duration]>]> expire:<[duration]>
- kick <[player]> reason:Disconnected
- ban <[player]> reason:<[reason]> source:<player.name.if_null[Console]> expire:<[duration]>
- else:
- narrate "<&[error]>Invalid duration! Examples of valid durations:"
- narrate "<&[error]>1d, 5m, 30s"
dcommands_tempban_proc:
type: procedure
definitions: player|reason|expiration
debug: true
script:
- inject dcommands_server_definitions
- inject dcommands_ban_definitions
- determine "<[server.prefix]><&color[<[server.color]>]><[server.name]><&r><[server.suffix]><&nl><&color[<[ban.message.color]>]><[ban.message.temp.header]><&nl><&nl><&color[<[ban.message.color]>]>Reason: <&color[<[ban.value]>]><[reason]><&nl><&color[<[ban.message.color]>]><[ban.message.temp.footer]> <&color[<[ban.value]>]><[expiration].format>"
dcommands_ban_handler:
type: world
debug: true
events:
on player prelogin flagged:dcommands.banned:
- determine kicked+<proc[dcommands_ban_proc].context[<player>|<player.ban_reason>]>
on player prelogin flagged:dcommands.tempbanned:
- determine kicked+<proc[dcommands_tempban_proc].context[<player>|<player.ban_reason>|<player.flag[dcommands.tempbanned.expiration]>]>