Skip to content
This repository has been archived by the owner on Feb 1, 2023. It is now read-only.

Commit

Permalink
doc change and sync changes in server
Browse files Browse the repository at this point in the history
  • Loading branch information
Ra1ny-Yuki committed Aug 23, 2021
1 parent ae4b661 commit e16f992
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 11 deletions.
2 changes: 1 addition & 1 deletion mcdreforged.plugin.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "simple_op_modified",
"version": "1.0.0",
"version": "1.1.0",
"name": "Simple OP Modified",
"description": "!!op to get op, !!restart to restart",
"author": [
Expand Down
11 changes: 11 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,14 @@
`!!restart` restart the server (requires confirm)

config path: `config/SimpleOPModified.json`

config items:

permission: you can edit `restart_permission` and `get_op_permission` to decide who can use these functions

`auto_op`: if this is `true`, you will be op unless you are in the `manual_list`, these 2 items could also be changed in-game with commands

`restart_need_confirm`: Plugin will ask you to confirm restart if this is `true`

`restart_countdown`: Restart countdown time (seconds)

23 changes: 13 additions & 10 deletions simple_op_modified/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ def show_help(source: CommandSource):
def restart_confirm(source: CommandSource):
acq = restart_lock.acquire(blocking=False)
if not acq:
for i in range(5):
source.get_server().broadcast(RText(tr('text.restart_countdown', 5 - i), color=RColor.red))
for i in range(config.restart_countdown):
source.get_server().broadcast(RText(tr('text.restart_countdown', config.restart_countdown - i), color=RColor.red))
time.sleep(1)
source.get_server().restart()
else:
Expand All @@ -76,15 +76,18 @@ def restart_unlock(source: CommandSource):
restart_already_called(source)
return
else:
confirm = RESTART_PREFIX + ' confirm'
abort = RESTART_PREFIX + ' abort'
text = tr('text.request_restart').split('/')
source.get_server().broadcast(RTextList(
text[0], RText(confirm, color=RColor.gray).c(RAction.run_command, confirm).h(tr('hover.run', confirm)),
text[1], RText(abort, color=RColor.gray).c(RAction.run_command, abort).h(tr('hover.run', abort)),
text[2]
if config.restart_need_confirm:
confirm = RESTART_PREFIX + ' confirm'
abort = RESTART_PREFIX + ' abort'
text = tr('text.request_restart').split('/')
source.get_server().broadcast(RTextList(
text[0], RText(confirm, color=RColor.gray).c(RAction.run_command, confirm).h(tr('hover.run', confirm)),
text[1], RText(abort, color=RColor.gray).c(RAction.run_command, abort).h(tr('hover.run', abort)),
text[2]
)
)
)
else:
restart_confirm(source)


def restart_abort(source: CommandSource):
Expand Down
2 changes: 2 additions & 0 deletions simple_op_modified/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ class Config(Serializable):
get_op_permission: int = 3
auto_op: bool = False
manual_list: List[str] = []
restart_need_confirm: bool = True
restart_countdown: int = 5

def save(self):
with open(CONFIG_PATH, 'w') as f:
Expand Down

0 comments on commit e16f992

Please sign in to comment.