Skip to content

Commit

Permalink
v1.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
zyxkad committed Feb 1, 2025
1 parent 8faac5f commit 58f2cb8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
16 changes: 9 additions & 7 deletions kpi/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,11 +336,9 @@ def on_saved(self):
def on_loaded(self):
pass

class Config: pass
class Config(JSONStorage): # type: ignore # ignore no-redef
class Config(JSONStorage):
msg_id: ClassVar[MCDR.RTextBase]
def_level: ClassVar[int]
instance: 'ClassVar[Optional[Config]]'

# 0:guest 1:user 2:helper 3:admin 4:owner
minimum_permission_level: dict[str, int] = {}
Expand All @@ -349,15 +347,19 @@ def __init_subclass__(cls, msg_id, def_level: int = 4, **kwargs):
super().__init_subclass__(**kwargs)
cls.msg_id = msg_id
cls.def_level = def_level
cls.instance = None
cls._instance = None # type: ignore

@classmethod
def instance(cls) -> Self:
return cls._instance # type: ignore

@classmethod
def init_instance(cls, plugin: MCDR.PluginServerInterface, *args,
sync_update: bool = True, **kwargs) -> Self:
if cls.instance is not None:
if cls._instance is not None: # type: ignore
raise RuntimeError('Cannot init instance twice')
cls.instance = cls(plugin, *args, sync_update=sync_update, **kwargs)
return cls.instance
cls._instance = cls(plugin, *args, sync_update=sync_update, **kwargs) # type: ignore
return cls._instance # type: ignore

@property
def server(self) -> MCDR.PluginServerInterface:
Expand Down
2 changes: 1 addition & 1 deletion mcdreforged.plugin.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "kpi",
"version": "1.4.12",
"version": "1.5.0",
"name": "KPI",
"description": {
"en_us": "A MCDR plugins codes share library",
Expand Down
2 changes: 1 addition & 1 deletion publisher.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ cd $(dirname $0)
echo '==> Checking...'
echo

mypy . || exit $?
python3.11 -m mypy . || exit $?

echo '==> Reading plugin metadata...'
echo
Expand Down

0 comments on commit 58f2cb8

Please sign in to comment.