Skip to content

Commit ec27291

Browse files
committed
fix: bug fixes
- Shortened help message. - Fixed an issue where tabs (\t) can't be correctly displayed in game. - Ops can override view list. - Add lower bound limit to the cycle interval (1s).
1 parent b938c1c commit ec27291

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

scoreboardHelper/scoreboardHelper.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -102,19 +102,19 @@ def help(self, player, args: list):
102102
return
103103

104104
help_info = f'''\
105-
------------------ ScoreboardHelper Command List ------------------
105+
----------- ScoreboardHelper Command List -----------
106106
"{self._cmd_prefix} help": Show this help message.
107107
"{self._cmd_prefix} list": List all scoreboards.
108108
"{self._cmd_prefix} view <name>": View a certain scoreboard for a period of time.
109-
-------------------------------------------------------------------'''
110-
op_help_info = f'''\
111-
----------------- ScoreboardHelper OP Command List ----------------
109+
----------------------------------------------------'''
110+
op_help_info = f'''
111+
---------- ScoreboardHelper OP Command List ---------
112112
"{self._cmd_prefix} cycle <true|t|false|f>": Turn on/off scoreboard cycling.
113113
"{self._cmd_prefix} <add|rm> <visible|cycle> <name>":
114114
Add/remove a scoreboard from visible/cycle list.
115115
"{self._cmd_prefix} settime <view|cycle> <time_in_sec>":
116116
Set cycle interval / view duration time in sec.
117-
-------------------------------------------------------------------'''
117+
----------------------------------------------------'''
118118
help_msg = help_info + (op_help_info if player.is_op() else '')
119119
self.utils.tell(player, help_msg)
120120

@@ -125,13 +125,13 @@ def list_visible_sb(self, player, args: list):
125125
return
126126

127127
if player.is_op():
128-
self.utils.tell(player, 'Scoreboards cycling:', bold=True)
129-
msg = '\t' + '\n\t'.join(self.configs.get('cycle_scoreboards', []))
128+
self.utils.tell(player, f'Scoreboards cycling (interval {self.configs["sec_between_cycle"]}s):')
129+
msg = ' ' + '\n '.join(self.configs.get('cycle_scoreboards', []))
130130
self.utils.tell(player, msg)
131-
self.utils.tell(player, 'Scoreboards visible to players:', bold=True)
131+
self.utils.tell(player, f'Scoreboards visible to players (stay {self.configs["sec_view_stay"]}s):')
132132
else:
133-
self.utils.tell(player, 'Scoreboards available:', bold=True)
134-
msg = '\t' + '\n\t'.join(self.configs.get('visible_scoreboards', []))
133+
self.utils.tell(player, 'Scoreboards available:')
134+
msg = ' ' + '\n '.join(self.configs.get('visible_scoreboards', []))
135135
self.utils.tell(player, msg)
136136

137137

@@ -141,7 +141,7 @@ def view_sb(self, player, args: list):
141141
return
142142

143143
sb_name = args[0]
144-
if sb_name not in self.configs.get('visible_scoreboards', []):
144+
if not player.is_op() and sb_name not in self.configs.get('visible_scoreboards', []): # op can override the visible list
145145
self.utils.tell(player, f'Invalid scoreboard \'{sb_name}\'. Use \'{self._cmd_prefix} list\' to see available scoreboards.')
146146
return
147147

@@ -226,8 +226,10 @@ def set_time(self, player, args: list):
226226

227227
try:
228228
sec = int(args[1])
229+
if sec < 1: raise ValueError('Interval too short')
229230
except: # ValueError
230-
self.utils.tell(player, 'Invalid input. Please enter an integer for the new interval.')
231+
self.utils.tell(player, 'Invalid input. Please enter an integer (>= 1) for the new interval.')
232+
return
231233

232234
if args[0] == 'view':
233235
self.configs['sec_view_stay'] = sec

0 commit comments

Comments
 (0)