Skip to content

Commit

Permalink
📦 新增死亡返回与更新作者信息与版本号
Browse files Browse the repository at this point in the history
  • Loading branch information
wling-art committed Feb 15, 2024
1 parent e14b5fa commit a31730f
Show file tree
Hide file tree
Showing 4 changed files with 388 additions and 89 deletions.
188 changes: 101 additions & 87 deletions plugin_market/market_tree.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,96 +5,110 @@
"DownloadRefURL": "https://mirror.ghproxy.com/raw.githubusercontent.com/ToolDelta/ToolDelta/main/plugin_market",
"DirectoryFileURL": "https://mirror.ghproxy.com/raw.githubusercontent.com/ToolDelta/ToolDelta/main/plugin_market/directory.json",
"MarketPlugins": {
"自定义聊天栏菜单": {
"author": "SuperScript",
"version": "0.0.1",
"description": "自定义聊天栏菜单触发词触发的指令, 方便简洁",
"limit_launcher": null,
"pre-plugins": {
"聊天栏菜单": "0.0.3"
},
"plugin-type": "classic"
"自定义聊天栏菜单": {
"author": "SuperScript",
"version": "0.0.1",
"description": "自定义聊天栏菜单触发词触发的指令, 方便简洁",
"limit_launcher": null,
"pre-plugins": {
"聊天栏菜单": "0.0.3"
},
"控制台执行MCFB指令": {
"author": "SuperScript",
"version": "0.0.2",
"description": "可以在控制台让机器人执行指令, 特殊指令等",
"limit_launcher": null,
"pre-plugins": {},
"plugin-type": "classic"
"plugin-type": "classic"
},
"控制台执行MCFB指令": {
"author": "SuperScript",
"version": "0.0.2",
"description": "可以在控制台让机器人执行指令, 特殊指令等",
"limit_launcher": null,
"pre-plugins": {},
"plugin-type": "classic"
},
"@玩家": {
"author": "wling",
"version": "0.0.2",
"description": "让@更有效果!",
"limit_launcher": null,
"pre-plugins": {},
"plugin-type": "injected"
},
"井字棋": {
"author": "SuperScript/wling",
"version": "0.0.2",
"description": "娱乐小游戏: 3x3井字棋",
"limit_launcher": null,
"pre-plugins": {},
"plugin-type": "injected"
},
"清空末影箱": {
"author": "wling",
"version": "0.0.1",
"description": "还在担心玩家在末影箱藏小东西吗?直接清空末影箱!",
"limit_launcher": null,
"pre-plugins": {},
"plugin-type": "injected"
},
"简易建造": {
"author": "SuperScript",
"version": "0.0.1",
"description": "使用一些更简便的方法建造服务器",
"limit_launcher": null,
"pre-plugins": {
"聊天栏菜单": "0.0.4",
"库-基本组件API": "0.0.1"
},
"@玩家": {
"author": "wling",
"version": "0.0.2",
"description": "让@更有效果!",
"limit_launcher": null,
"pre-plugins": {
},
"plugin-type": "injected"
"plugin-type": "classic"
},
"封禁系统": {
"author": "SuperScript",
"version": "0.0.1",
"description": "服内有大哥或者熊孩子? 更方便地ban掉! 同时也是一个前置插件.",
"limit_launcher": null,
"pre-plugins": {
"聊天栏菜单": "0.0.4"
},
"井字棋": {
"author": "SuperScript/wling",
"version": "0.0.1",
"description": "娱乐小游戏: 3x3井字棋",
"limit_launcher": null,
"pre-plugins": {},
"plugin-type": "injected"
"plugin-type": "classic"
},
"库-基本组件API": {
"author": "SuperScript",
"version": "0.0.1",
"description": "所有使用基本组件API的插件的前置",
"limit_launcher": null,
"pre-plugins": {},
"plugin-type": "classic"
},
"库-世界交互": {
"author": "SuperScript",
"version": "0.0.1",
"description": "所有使用世界交互的插件的前置",
"limit_launcher": null,
"pre-plugins": {
"聊天栏菜单": "0.0.1"
},
"清空末影箱": {
"author": "wling",
"version": "0.0.1",
"description": "还在担心玩家在末影箱藏小东西吗?直接清空末影箱!",
"limit_launcher": null,
"pre-plugins": {
},
"plugin-type": "injected"
},
"简易建造": {
"author": "SuperScript",
"version": "0.0.1",
"description": "使用一些更简便的方法建造服务器",
"limit_launcher": null,
"pre-plugins": {
"聊天栏菜单": "0.0.4",
"库-基本组件API": "0.0.1"
},
"plugin-type": "classic"
},
"封禁系统": {
"author": "SuperScript",
"version": "0.0.1",
"description": "服内有大哥或者熊孩子? 更方便地ban掉! 同时也是一个前置插件.",
"limit_launcher": null,
"pre-plugins": {
"聊天栏菜单": "0.0.4"
},
"plugin-type": "classic"
},
"库-基本组件API": {
"author": "SuperScript",
"version": "0.0.1",
"description": "所有使用基本组件API的插件的前置",
"limit_launcher": null,
"pre-plugins": {},
"plugin-type": "classic"
},
"库-世界交互": {
"author": "SuperScript",
"version": "0.0.1",
"description": "所有使用世界交互的插件的前置",
"limit_launcher": null,
"pre-plugins": {
"聊天栏菜单": "0.0.1"
},
"plugin-type": "classic"
},
"聊天栏菜单": {
"author": "SuperScript",
"version": "0.0.4",
"description": "所有使用到聊天栏菜单的组件的前置组件",
"limit_launcher": null,
"pre-plugins": {},
"plugin-type": "classic"
}
"plugin-type": "classic"
},
"聊天栏菜单": {
"author": "SuperScript",
"version": "0.0.4",
"description": "所有使用到聊天栏菜单的组件的前置组件",
"limit_launcher": null,
"pre-plugins": {},
"plugin-type": "classic"
},
"死亡返回": {
"author": "wling/7912",
"version": "0.0.1",
"description": "死了啊?没事,哥们给你记着,让我帮你返回吧!",
"limit_launcher": null,
"pre-plugins": { "维度传送": "0.0.1" },
"plugin-type": "injected"
},
"维度传送": {
"author": "SuperScript",
"version": "0.0.1",
"description": "作用如其名,跨纬度传送,谁都爱",
"limit_launcher": null,
"pre-plugins": {},
"plugin-type": "injected"
}
}
}
4 changes: 2 additions & 2 deletions plugin_market/井字棋/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

__plugin_meta__ = {
"name": "井字棋",
"version": "1.0",
"author": "SuperScript",
"version": "0.0.2",
"author": "SuperScript/wling",
}
class JZQStage:
def __init__(self):
Expand Down
97 changes: 97 additions & 0 deletions plugin_market/死亡返回/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
import os, time
from genericpath import isfile
from logging import config
from traceback import print_tb
from tooldelta.plugin_load.injected_plugin import player_death
from 维度传送 import tp
from tooldelta.plugin_load import player_message, tellrawText, getPos
import ujson as json

__plugin_meta__ = {
"name": "死亡返回",
"version": "0.0.1",
"author": "wling/7912",
}


LOG_DEATH_TIME = 30 # 记录最小频率 (秒)
plugin_path = r"插件配置文件/死亡返回"
config_path = plugin_path + r"/死亡位置.json"
os.makedirs(plugin_path, exist_ok=True)
if os.path.isfile(config_path):
os.makedirs(config_path, exist_ok=True)
with open(config_path, "w", encoding="utf-8") as f:
json.dump("{}", f, indent=4, ensure_ascii=False)


def translateDim(dimension):
if dimension == 0:
return "主世界"
if dimension == 1:
return "地狱"
if dimension == 2:
return "末地"
raise ValueError("维度只能是0, 1或2.")


@player_message
async def _(playername, msg):
if msg == ".backdeath":
with open(config, "r", encoding="utf-8") as f:
data = json.loads(f)
if playername not in data:
tellrawText('@a[name="%s"]' % playername, "§l§4ERROR§r", "§c未找到记录.")
return
deathData = data[playername]
tp(
'@a[name="%s"]' % playername,
x=deathData["position"]["x"],
y=deathData["position"]["y"],
z=deathData["position"]["z"],
dimension=deathData["dimension"],
)
tellrawText(
'@a[name="%s"]' % playername,
"§l死亡点记录§r",
"已传送到上次死亡点: [§l%s§r, (§l%s§r, §l%s§r, §l%s§r)]."
% (
translateDim(deathData["dimension"]),
deathData["position"]["x"],
deathData["position"]["y"],
deathData["position"]["z"],
),
)
data[playername] = deathData
with open(config_path, "w", encoding="utf-8") as f:
json.dump(data, f, indent=4, ensure_ascii=False)


@player_death()
async def _(playername):
deathTime = int(time.time())
with open(config, "r", encoding="utf-8") as f:
data = json.loads(f)
if playername not in data:
data[playername] = {}
deathData_old = data[playername]
if deathData_old:
deathTimeDelta = deathTime - deathData_old["time"]
if deathTimeDelta < LOG_DEATH_TIME:
tellrawText(
'@a[name="%s"]' % playername,
"§l§4ERROR§r",
"§c时间间隔过短, 未保存此次记录. (冷却时间: §l%d§r§cs)"
% (LOG_DEATH_TIME - deathTimeDelta),
)
return

deathData = getPos(f'@a[name="{playername}"]')
deathData["time"] = deathTime
data[playername] = deathData
with open(config_path, "w", encoding="utf-8") as f:
json.dump(data, f, indent=4, ensure_ascii=False)
tellrawText(
f'@a[name="{playername}"]',
"§l死亡点记录§r",
f"已记录死亡点: [§l{translateDim(deathData['dimension'])}§r, (§l{deathData['position']['x']}§r, §l{deathData['position']['y']}§r, §l{deathData['position']['z']}§r)], 输入§l.backdeath§r返回.",
)
Loading

0 comments on commit a31730f

Please sign in to comment.