Date: 2021/04/06 13:59:34 UTC-07:00
Type: Diff Report
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
-# +-------------------------
+# +--------------------------
# |
# | M a g i c S i d e b a r
# |
# | Provides a working live-updating per-player sidebar!
+# |
+# +--------------------------
#
# @author mcmonkey
# @date 2019/03/01
-# @denizen-build REL-1679
+# @denizen-build REL-1714
# @script-version 1.0
#
# Installation:
# 1. Put the script in your scripts folder.
# 2. Edit the config script below to your liking.
# 3. Reload
#
# Usage:
# Type "/sidebar" in-game to toggle the sidebar on or off.
#
# ---------------------------- END HEADER ----------------------------
# ------------------------- Begin configuration -------------------------
magic_sidebar_config:
- type: yaml data
+ type: data
# How many updates per second (acceptable values: 1, 2, 4, 5, 10)
per_second: 5
# Set this to your sidebar title.
title: <&b><&l>Player Info
# Set this to the list of sidebar lines you want to display.
# Start a line with "[scroll:#/#]" to make it automatically scroll
# with a specified width and scroll speed (characters shifted per second).
# Note that width must always be less than the line's actual length.
# There should also be at least one normal line that's as wide as the width, to prevent the sidebar resizing constantly.
lines:
- "[scroll:20/5]<&a>Welcome to <&6>my server<&a>, <&b><player.name><&a>!"
- "<&8>-----------------------"
- "Ping: <&b><player.ping>"
- "Location: <&b><player.location.simple.before_last[,].replace[,].with[<&f>,<&b>]>"
- - "Online Players: <&b><server.list_online_players.size><&f>/<&b><server.max_players>"
+ - "Online Players: <&b><server.online_players.size><&f>/<&b><server.max_players>"
# ------------------------- End of configuration -------------------------
magic_sidebar_world:
type: world
debug: false
events:
on delta time secondly:
- - define per_second <script[magic_sidebar_config].yaml_key[per_second]>
+ - define per_second <script[magic_sidebar_config].data_key[per_second]>
- define wait_time <element[1].div[<[per_second]>]>s
- - define players <server.list_online_players.filter[has_flag[sidebar_disabled].not]>
- - define title <script[magic_sidebar_config].yaml_key[title]>
+ - define players <server.online_players.filter[has_flag[sidebar_disabled].not]>
+ - define title <script[magic_sidebar_config].data_key[title]>
- repeat <[per_second]>:
- sidebar title:<[title].parsed> values:<proc[magic_sidebar_lines_proc]> players:<[players]> per_player
- wait <[wait_time]>
magic_sidebar_lines_proc:
type: procedure
debug: false
script:
- - define list <script[magic_sidebar_config].yaml_key[lines]>
+ - define list <script[magic_sidebar_config].data_key[lines]>
- foreach <[list]> as:line:
- define list_index <[loop_index]>
- define line <[line].parsed>
- if <[line].starts_with[<&lb>scroll<&co>]>:
- define width <[line].after[<&co>].before[/]>
- define rate <[line].after[/].before[<&rb>]>
- define line <[line].after[<&rb>]>
- define index <server.current_time_millis.div[1000].mul[<[rate]>].round.mod[<[line].strip_color.length>].add[1]>
- define end <[index].add[<[width]>]>
- repeat <[line].length> as:charpos:
- if <[line].char_at[<[charpos]>]> == <&ss>:
- define index <[index].add[2]>
- if <[index]> <= <[charpos]>:
- repeat stop
- define start_color <[line].substring[0,<[index]>].last_color>
- if <[end]> > <[line].strip_color.length>:
- define end <[end].sub[<[line].strip_color.length>]>
- repeat <[line].length> as:charpos:
- if <[line].char_at[<[charpos]>]> == <&ss>:
- define end <[end].add[2]>
- if <[end]> < <[charpos]>:
- repeat stop
- define line "<[start_color]><[line].substring[<[index]>]> <&f><[line].substring[0,<[end]>]>"
- else:
- repeat <[line].length> as:charpos:
- if <[line].char_at[<[charpos]>]> == <&ss>:
- define end <[end].add[2]>
- if <[end]> < <[charpos]>:
- repeat stop
- define line <[start_color]><[line].substring[<[index]>,<[end]>]>
- define list <[list].set[<[line]>].at[<[list_index]>]>
- determine <[list]>
magic_sidebar_command:
type: command
debug: false
name: sidebar
usage: /sidebar
description: Toggles your sidebar on or off.
script:
- if <player.has_flag[sidebar_disabled]>:
- flag player sidebar_disabled:!
- narrate "<&b>Sidebar enabled."
- else:
- flag player sidebar_disabled
- narrate "<&b>Sidebar disabled."
- wait 1
- sidebar remove players:<player>
+