From 65768cf878fb69e7f0ae6fd75671ad9643ba0520 Mon Sep 17 00:00:00 2001 From: ZQHD Date: Sat, 27 Apr 2024 13:42:34 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E7=BC=96=E5=86=99=E5=B0=81=E7=A6=81?= =?UTF-8?q?=E5=A4=84=E7=BD=9A=E5=87=BD=E6=95=B0=EF=BC=8C=E5=8A=A0=E5=85=A5?= =?UTF-8?q?=E6=97=B6=E9=97=B4=E6=A0=BC=E5=BC=8F=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/login.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/plugins/login.py b/plugins/login.py index a1c7657..296d3e3 100644 --- a/plugins/login.py +++ b/plugins/login.py @@ -1,7 +1,8 @@ -from mcdreforged.api.command import SimpleCommandBuilder +from mcdreforged.api.command import * from mcdreforged.info_reactor.info import Info from mcdreforged.minecraft.rcon.rcon_connection import RconConnection import time +import requests PLUGIN_METADATA = { 'id': 'login', 'version': '1.0.0', @@ -12,14 +13,21 @@ } rcon = RconConnection("127.0.0.123",38324,"123456") +userKeys = "" +serverName = "" +name = "" +password = "" def on_load(server, old): buider = SimpleCommandBuilder() - # buider.command("mpwa bind",bind) + buider.command("mpwa ban ",ban) + + buider.arg("name",Text) + buider.arg("description",Text) server.logger.info('Hello world!') buider.register(server) def on_user_info(server, info:Info): if info.content == 'mpwa bind': user = info.player server.reply(info, '绑定开始!用户名:{},时间:{}'.format(user,time.time())) -# def bind(): -# print("succeed") +def ban(): + print("succeed") From 282e780189ca6ece47947b677783c54763b3bb1f Mon Sep 17 00:00:00 2001 From: ZQHD Date: Wed, 1 May 2024 17:08:28 +0800 Subject: [PATCH 2/5] =?UTF-8?q?Revert=20"=E7=BC=96=E5=86=99=E5=B0=81?= =?UTF-8?q?=E7=A6=81=E5=A4=84=E7=BD=9A=E5=87=BD=E6=95=B0=EF=BC=8C=E5=8A=A0?= =?UTF-8?q?=E5=85=A5=E6=97=B6=E9=97=B4=E6=A0=BC=E5=BC=8F=E5=8C=96"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 65768cf878fb69e7f0ae6fd75671ad9643ba0520. --- plugins/login.py | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/plugins/login.py b/plugins/login.py index 296d3e3..a1c7657 100644 --- a/plugins/login.py +++ b/plugins/login.py @@ -1,8 +1,7 @@ -from mcdreforged.api.command import * +from mcdreforged.api.command import SimpleCommandBuilder from mcdreforged.info_reactor.info import Info from mcdreforged.minecraft.rcon.rcon_connection import RconConnection import time -import requests PLUGIN_METADATA = { 'id': 'login', 'version': '1.0.0', @@ -13,21 +12,14 @@ } rcon = RconConnection("127.0.0.123",38324,"123456") -userKeys = "" -serverName = "" -name = "" -password = "" def on_load(server, old): buider = SimpleCommandBuilder() - buider.command("mpwa ban ",ban) - - buider.arg("name",Text) - buider.arg("description",Text) + # buider.command("mpwa bind",bind) server.logger.info('Hello world!') buider.register(server) def on_user_info(server, info:Info): if info.content == 'mpwa bind': user = info.player server.reply(info, '绑定开始!用户名:{},时间:{}'.format(user,time.time())) -def ban(): - print("succeed") +# def bind(): +# print("succeed") From b8e10259ec55a5a021d27c4e18747a6dbabc92f0 Mon Sep 17 00:00:00 2001 From: ZQHD Date: Wed, 1 May 2024 18:10:38 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/login.py | 77 ++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 68 insertions(+), 9 deletions(-) diff --git a/plugins/login.py b/plugins/login.py index a1c7657..85c1ae9 100644 --- a/plugins/login.py +++ b/plugins/login.py @@ -1,25 +1,84 @@ -from mcdreforged.api.command import SimpleCommandBuilder +from mcdreforged.api.command import * +from mcdreforged.command.command_source import CommandSource from mcdreforged.info_reactor.info import Info from mcdreforged.minecraft.rcon.rcon_connection import RconConnection +from threading import Thread import time +import requests +import json +import os PLUGIN_METADATA = { - 'id': 'login', + 'id': 'unionWhitelist', 'version': '1.0.0', - 'name': 'My Plugin', + 'name': 'login', 'description': 'MPWA联盟验证mcdr端', 'author': 'ZQHD', 'link': 'https://github.com', } -rcon = RconConnection("127.0.0.123",38324,"123456") +jsonFile = open('setting.json', "r") +json = json.load(jsonFile) +rconSetting = json['rcon'] +rcon = RconConnection(rconSetting['address'], rconSetting['port'], rconSetting['password']) +userKeys = "" +serverName = "" +accountName = "" +password = "" + def on_load(server, old): buider = SimpleCommandBuilder() - # buider.command("mpwa bind",bind) - server.logger.info('Hello world!') + buider.command("!!mpwa ban ", ban) # 永封 + buider.command("!!mpwa prosecute ", prosecute) # 处罚 + buider.arg("name", Text) + buider.arg("description", Text) + buider.arg("level", Integer) + server.logger.info('load is successful') buider.register(server) + setting = json['setting'] + serverName = setting['serverName'] + accountName = setting['accountName'] + password = setting['password'] + # response = requests.get("https://www.mpwa.cn/McServerSig",headers={ + # "sname":serverName, + # "lname":accountName, + # "lpwd":password + # }) + # userKeys = response.text + thread = Thread(target=loop) + thread.start() def on_user_info(server, info:Info): if info.content == 'mpwa bind': user = info.player - server.reply(info, '绑定开始!用户名:{},时间:{}'.format(user,time.time())) -# def bind(): -# print("succeed") + timeNow = time.time() + server.reply(info, '绑定开始!用户名:{},时间:{}'.format(user, time.strftime("%Y.%m.%d %h:%n:%s"))) + + +def ban(source: CommandSource, context: CommandContext): + name = context['name'] + description = context['description'] + # Todo : 请求接口,推送黑名单 + + +def prosecute(source: CommandSource, context: CommandContext): + level = context['level'] + description = ['description'] + + +def on_server_stop(server, server_return_code: int): + json.close() + + +def loop(): + """ + 循环执行部分的代码,如请求接口 + :return: + """ + while True: + # todo:编写请求白名单黑名单的接口 + newWhitelist = [] # 新白名单表单 + newBanList = [] # 新黑名单表单 + for whitelist in newWhitelist: + rcon.send_command("whitelist add {}".format(whitelist)) + for banList in newBanList: + rcon.send_command("ban {}".format(banList)) + time.sleep(300) From 0fa8aaf6a62e7e13e67575e002df0cda5ca3d938 Mon Sep 17 00:00:00 2001 From: ZQHD Date: Wed, 1 May 2024 18:34:47 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- setting.json | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 setting.json diff --git a/setting.json b/setting.json new file mode 100644 index 0000000..e14ae5c --- /dev/null +++ b/setting.json @@ -0,0 +1,12 @@ +{ + "setting": { + "serverName": "", + "accountName": "", + "password": "" + }, + "rcon": { + "address": "", + "port": 38324, + "password": "" + } +} \ No newline at end of file From 1098c70f4c3b62edf2be356ec4e165d6ca5aaa10 Mon Sep 17 00:00:00 2001 From: ZQHD Date: Wed, 1 May 2024 20:29:51 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E6=9B=B4=E6=94=B9=E6=9C=89=E5=85=B3?= =?UTF-8?q?=E5=86=85=E5=AE=B9=EF=BC=8C=E6=9B=B4=E6=94=B9=E5=91=BD=E4=BB=A4?= =?UTF-8?q?=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/login.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/login.py b/plugins/login.py index 85c1ae9..fbe66df 100644 --- a/plugins/login.py +++ b/plugins/login.py @@ -8,12 +8,12 @@ import json import os PLUGIN_METADATA = { - 'id': 'unionWhitelist', + 'id': 'UnionWhitelist', 'version': '1.0.0', - 'name': 'login', + 'name': 'UnionWhitelist', 'description': 'MPWA联盟验证mcdr端', 'author': 'ZQHD', - 'link': 'https://github.com', + 'link': 'https://github.com/Minecraft-Public-Welfare-Alliance/UnionWhitelist.MCDR', } jsonFile = open('setting.json', "r") @@ -28,7 +28,7 @@ def on_load(server, old): buider = SimpleCommandBuilder() buider.command("!!mpwa ban ", ban) # 永封 - buider.command("!!mpwa prosecute ", prosecute) # 处罚 + buider.command("!!mpwa punish ", prosecute) # 处罚 buider.arg("name", Text) buider.arg("description", Text) buider.arg("level", Integer)