Skip to content

Commit

Permalink
feat(bot): ✨ support MCDR 2.0
Browse files Browse the repository at this point in the history
Release-As: 0.1.0
  • Loading branch information
AnzhiZhang committed Jun 30, 2022
1 parent ec63aa7 commit a8db9a7
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 27 deletions.
44 changes: 17 additions & 27 deletions bot/Bot.py → bot/bot/__init__.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,11 @@
# -*- coding: utf-8 -*-
from typing import Dict

from mcdreforged.api.types import PluginServerInterface
from mcdreforged.api.command import *
from mcdreforged.api.rtext import *
from mcdreforged.api.utils.serializer import Serializable

PLUGIN_METADATA = {
'id': 'bot',
'version': '0.0.1',
'name': 'Bot',
'description': 'Carpet bot easy manage and set',
'author': 'Andy Zhang',
'link': 'https://github.com/AnzhiZhang/MCDReforgedPlugins/tree/master/.archived/Bot',
'dependencies': {
'config_api': '*',
'json_data_api': '*'
}
}
DIMENSIONS = {
'0': 'minecraft:overworld',
'-1': 'minecraft:the_nether',
Expand All @@ -28,30 +19,29 @@
'minecraft:the_nether': 'minecraft:the_nether',
'minecraft:the_end': 'minecraft:the_end'
}
DEFAULT_CONFIG = {
'gamemode': 'survival',
'permissions': {
HELP_MESSAGE = '''§6!!bot §7显示机器人列表
§6!!bot spawn <name> §7生成机器人
§6!!bot kill <name> §7移除机器人
§6!!bot add <name> <dim> <x> <y> <z> <facing_level> <facing_pitch> §7添加机器人到机器人列表
§6!!bot remove <name> §7从机器人列表移除机器人'''


class Config(Serializable):
gamemode: str = 'survival'
permissions: Dict[str,int] = {
'list': 1,
'spawn': 2,
'kill': 2,
'add': 3,
'remove': 3
}
}
HELP_MESSAGE = '''§6!!bot §7显示机器人列表
§6!!bot spawn <name> §7生成机器人
§6!!bot kill <name> §7移除机器人
§6!!bot add <name> <dim> <x> <y> <z> <facing_level> <facing_pitch> §7添加机器人到机器人列表
§6!!bot remove <name> §7从机器人列表移除机器人'''


def on_load(server: PluginServerInterface, old):
from ConfigAPI import Config
from JsonDataAPI import Json
config = Config(PLUGIN_METADATA['name'], DEFAULT_CONFIG)
data = Json(PLUGIN_METADATA['name'])
permissions = config['permissions']
server.register_help_message('!!bot help', '显示Bot插件帮助')
config = server.load_config_simple('config.json', target_class=Config)
data = server.load_config_simple('data.json', default_config={})
permissions = config.permissions
server.register_help_message('!!bot help', '显示 Bot 插件帮助')
server.register_help_message(
'!!bot',
RText('显示机器人列表').c(RAction.run_command, '!!bot').h('点击显示机器人列表')
Expand Down
11 changes: 11 additions & 0 deletions bot/mcdreforged.plugin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"id": "bot",
"version": "0.1.0",
"name": "Bot",
"description": {
"en_us": "Manage carpet bot",
"zh_cn": "管理地毯假人"
},
"author": "Andy Zhang",
"link": "https://github.com/AnzhiZhang/MCDReforgedPlugins/tree/master/bot"
}

0 comments on commit a8db9a7

Please sign in to comment.