Skip to content

Commit

Permalink
Update __init__.py
Browse files Browse the repository at this point in the history
增加了!!rb指令的槽位显示
  • Loading branch information
FRUITS-CANDY authored Feb 14, 2024
1 parent 04f200e commit 4498c7a
Showing 1 changed file with 29 additions and 31 deletions.
60 changes: 29 additions & 31 deletions region_backup/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,27 @@
# 回档槽位
back_slot = None

help_msg = '''
------ {1} {2} ------
一个以区域为单位的§a备份回档§a插件
§3作者:FRUITS_CANDY
§d【格式说明】
#sc=!!rb<>st=点击运行指令#§7{0} §a§l[▷] §e显示帮助信息
#sc=!!rb make<>st=点击运行指令#§7{0} make §b<区块半径> <注释> §a§l[▷] §e以玩家所在区块为中心,备份边长为2倍半径+1的区块所在区域
#sc=!!rb pos_make<>st=点击运行指令#§7{0} pos_make §b<x1坐标> <z1坐标> <x2坐标> <z2坐标> <维度:0主世界,-1地狱,1末地> <注释> §a§l[▷] §e给定两个坐标点,备份以两坐标点对应的区域坐标为顶点形成的矩形区域
#sc=!!rb back<>st=点击运行指令#§7{0} back §b<槽位> §a§l[▷] §e回档指定槽位所对应的区域
#sc=!!rb del<>st=点击运行指令#§7{0} del §b<槽位> §a§l[▷] §e删除某槽位
#sc=!!rb confirm<>st=点击运行指令#§7{0} confirm §a§l[▷] §e再次确认是否回档
#sc=!!rb abort<>st=点击运行指令#§7{0} abort §a§l[▷] §e在任何时候键入此指令可中断回档
#sc=!!rb list<>st=点击运行指令#§7{0} list §a§l[▷] §e显示各槽位的存档信息
#sc=!!rb reload<>st=点击运行指令#§7{0} reload §a§l[▷] §e重载插件
'''.format(Prefix, "Region BackUp", "1.0.0")


def print_help_msg(source: CommandSource):
source.reply(Message.get_json_str(help_msg))
rb_list(source)


@new_thread("rb_make")
def rb_make(source: InfoCommandSource, dic: dict):
Expand Down Expand Up @@ -323,14 +342,20 @@ def rb_del(source: CommandSource, dic: dict):
return


def rb_abort():
def rb_abort(source: CommandSource):
global back_state
# 当前操作备份信息
if back_state is None:
source.reply("没有什么可中断的")
return
back_state = True


def rb_confirm():
def rb_confirm(source:CommandSource):
global back_state
if back_state is None:
source.reply("没有什么可确认的")
return
back_state = 1


Expand Down Expand Up @@ -384,28 +409,6 @@ def rb_list(source: CommandSource):
source.reply(f"显示备份列表出错,错误信息:§c{e}")
return

help_msg = '''
------ {1} {2} ------
一个以区域为单位的§a备份回档§a插件
§3作者:FRUITS_CANDY
§d【格式说明】
#sc=!!rb<>st=点击运行指令#§7{0} §a§l[▷] §e显示帮助信息
#sc=!!rb make<>st=点击运行指令#§7{0} make §b<区块半径> <注释> §a§l[▷] §e以玩家所在区块为中心,备份边长为2倍半径+1的区块所在区域
#sc=!!rb pos_make<>st=点击运行指令#§7{0} pos_make §b<x1坐标> <z1坐标> <x2坐标> <z2坐标> <维度 0:主世界,1:末地,-1:地狱> <注释> §a§l[▷] §e给定两个坐标点,备份以两坐标点对应的区域坐标为顶点形成的矩形区域
#sc=!!rb back<>st=点击运行指令#§7{0} back §b<槽位> §a§l[▷] §e回档指定槽位所对应的区域
#sc=!!rb del<>st=点击运行指令#§7{0} del §b<槽位> §a§l[▷] §e删除某槽位
#sc=!!rb confirm<>st=点击运行指令#§7{0} confirm §a§l[▷] §e再次确认是否回档
#sc=!!rb abort<>st=点击运行指令#§7{0} abort §a§l[▷] §e在任何时候键入此指令可中断回档
#sc=!!rb list<>st=点击运行指令#§7{0} list §a§l[▷] §e显示各槽位的存档信息
#sc=!!rb reload<>st=点击运行指令#§7{0} reload §a§l[▷] §e重载插件
'''.format(Prefix, "Region BackUp", "1.0.0")

def print_help_msg(source: CommandSource):
help_msg_output = help_msg
source.reply(Message.get_json_str(help_msg_output))
rb_list_output = rb_list(source)
source.reply(Message.get_json_str(rb_list_output))


def get_file_size(folder_list):
total_size = 0
Expand Down Expand Up @@ -448,13 +451,8 @@ def get_backup_pos(r=None, x=None, z=None, pos_list=None):
backup_pos = []

if not pos_list:
# n = (2 * r + 1) // 2

# for i in range(-n, n + 1):
# for j in range(-n, n + 1):
# backup_pos.append((x + i, z + j))

return get_backup_pos(pos_list=[((x - r)//32, (z + r)//32), ((x + r)//32, (z - r)//32)])
return get_backup_pos(pos_list=[((x - r)//32, (x + r)//32), ((z + r)//32, (z - r)//32)])

left = min(pos_list[0])
right = max(pos_list[0])
Expand Down Expand Up @@ -549,7 +547,7 @@ def search_valid_pos(data, backup_pos):
x, z = pos
file = os.path.join(path, folder, f"r.{x}.{z}.mca")

if os.path.isfile(file):
if os.path.exists(file):
positions.append(pos)

return valid_pos
Expand Down

0 comments on commit 4498c7a

Please sign in to comment.