Skip to content

Commit

Permalink
修复圈地系统上架bug
Browse files Browse the repository at this point in the history
  • Loading branch information
NIANIANKNIA committed Oct 28, 2023
1 parent 4453bea commit a64e5e9
Show file tree
Hide file tree
Showing 14 changed files with 149 additions and 38 deletions.
24 changes: 17 additions & 7 deletions CHANGELOG-PRE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# v1.4.0-pre-2 更新日志
# v1.4.1-pre-1 更新日志

[![BDS VERSION](https://img.shields.io/badge/BDS-1.20.31.01-green?style=for-the-badge&logo=appveyor)](https://www.minecraft.net/en-us/download/server/bedrock)
[![LiteLoader VERSION](https://img.shields.io/badge/LiteLoader-2.16.2-green?style=for-the-badge&logo=appveyor)](https://github.com/LiteLDev/LiteLoaderBDS/releases/)
Expand All @@ -10,21 +10,31 @@

## 新增

圈地系统正式上线
1.屏蔽词系统,支持自定义屏蔽词,自动禁言发送屏蔽词的玩家

## 调整
2.圈地系统管理面板上线,使管理员可以更方便的管理玩家圈地

1.修改玩家交易市场离线收益获取途径
3.圈地系统新增防爆系统,可以防止领地被爆炸破坏

2.暂时下线自动备份系统
4.圈地系统新增虚拟围墙系统,可以在领地周围生成虚拟围墙,防止玩家进入领地

## 优化

文件读取时间计算方式
1.优化圈地系统性能表现

1.新增圈地系统配置文件,可以自定义圈地系统的一些参数

2.现在在转移圈地时,会重新计算圈地的索引值

3.更改系统信息前缀

## 修复

玩家交易市场在依赖服务器离线时数据不能正常处理的bug
1.圈地系统上架圈地时,输入价格为0时出现bug的问题

2.在圈地数量过多时不会再出现hang报错(需要正确配置配置文件)

3.玩家无法正常摧毁(回收)领地的bug

**配置说明:您可以前往[NIA服务器官方文档站](https://docs.mcnia.com/zh-CN/deploy.html)查看具体部署过程!**

4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
[![GitHub last commit](https://img.shields.io/github/last-commit/NIANIANKNIA/NIASERVER-V4?style=for-the-badge)](https://github.com/NIANIANKNIA/NIASERVER-V4/commits)
[![QQ GROUNP](https://img.shields.io/badge/QQ%20GROUNP-724360499-blue?style=for-the-badge)](https://jq.qq.com/?_wv=1027&k=uk57fVr0)
[![website](https://img.shields.io/badge/website-docs.mcnia.com-blue?style=for-the-badge)](https://docs.mcnia.com)
![NIASERVER-V4](https://socialify.git.ci/NIANIANKNIA/NIASERVER-V4/image?description=1&font=KoHo&forks=1&issues=1&logo=https%3A%2F%2Fdocs.mcnia.com%2Flogo.png&name=1&pattern=Circuit%20Board&pulls=1&stargazers=1&theme=Light)

![NIASERVER-V4](https://socialify.git.ci/NIANIANKNIA/NIASERVER-V4/image?description=1&descriptionEditable=A%20BDS-based%20Minecraft%20server!&font=KoHo&forks=1&issues=1&logo=https%3A%2F%2Fdocs.mcnia.com%2Flogo.png&name=1&pattern=Circuit%20Board&pulls=1&stargazers=1&theme=Light)


**语言: 简体中文 | [English](README-EN.md)**

Expand Down
4 changes: 2 additions & 2 deletions development_behavior_packs/NIA_V4.0_BP/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"name": "NIA V4.0 BP",
"description": "§bNIA服务器V4-行为包\n作者:NIANIANKNIA\n项目地址:https://github.com/NIANIANKNIA/NIASERVER-V4",
"uuid": "cab0bbe3-eb10-465e-b1de-b09facc076c8",
"version": [ 1, 4, 0 ],
"version": [ 1, 4, 1 ],
"min_engine_version": [ 1, 20, 30 ]
},
"modules": [
Expand All @@ -14,7 +14,7 @@
"description": "gametest module",
"uuid": "92cd3fe1-e764-425a-aa40-a7e4d7760922",
"entry": "scripts/main.js",
"version": [ 1, 4, 0 ]
"version": [ 1, 4, 1 ]
}
],
"dependencies": [
Expand Down
13 changes: 13 additions & 0 deletions development_behavior_packs/NIA_V4.0_BP/scripts/basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {system, world, DynamicPropertiesDefinition} from '@minecraft/server';
import {Broadcast,Tell,RunCmd,AddScoreboard,GetScore,getNumberInNormalDistribution,log, GetShortTime} from './customFunction.js'
import { cfg } from './config.js';
import { ExternalFS } from './API/filesystem.js';
import { LAST_UPGRATE,VERSION,CODE_BRANCH } from './main.js';

//定义一些常数
const fs = new ExternalFS();
Expand Down Expand Up @@ -149,6 +150,18 @@ world.afterEvents.worldInitialize.subscribe((event) => {
world.setDynamicProperty("state",true);
} else if (world.getDynamicProperty("state") == true) {
log("NIA V4已经初始化完成!");
world.scoreboard.removeObjective("menu");
//英文
// world.scoreboard.addObjective("menu","");
world.scoreboard.addObjective("menu","");
//world.scoreboard.addObjective("menu","");
RunCmd(`scoreboard objectives setdisplay sidebar menu ascending`);
world.scoreboard.getObjective("menu").addScore(`§e当前测试阶段:PRE-2`,0);
world.scoreboard.getObjective("menu").addScore(`§e当前版本:${VERSION}`,1);
world.scoreboard.getObjective("menu").addScore("§c上次更新时间:",2);
world.scoreboard.getObjective("menu").addScore(`${LAST_UPGRATE}`,3);
world.scoreboard.getObjective("menu").addScore(`§7测试版本并不代表`,4);
world.scoreboard.getObjective("menu").addScore(`§7最终发布版本`,5);
}

})
Expand Down
8 changes: 8 additions & 0 deletions development_behavior_packs/NIA_V4.0_BP/scripts/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ const config = {
"Port": 10086
},
"LandCfg": {
"Distance": 100,
"MaxSquare": 10000,
"MinSquare": 100,
"Price_2D": 300,
"Price_3D": 3,
"XRange": [-100000,100000],
"ZRange": [-100000,100000],
"YRange": [-64,256]
},
"MarketCfg": {
"BanItems" : ["minecraft:paper","minecraft:clock"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,3 +150,4 @@ function randomNormalDistribution(){
export function getNumberInNormalDistribution(mean,std_dev){
return mean+(randomNormalDistribution()*std_dev);
}

118 changes: 97 additions & 21 deletions development_behavior_packs/NIA_V4.0_BP/scripts/land.js
Original file line number Diff line number Diff line change
Expand Up @@ -935,7 +935,12 @@ const GUI = {
}
//再判断价格是否为数字
if (isNaN(parseInt(response.formValues[1]))) {
player.sendMessage("§c 价格必须为正整数!");
player.sendMessage("§c 价格必须为数字!");
return;
}
//开始判断价格是否为大于0的数字
if (parseInt(response.formValues[1]) <= 0) {
player.sendMessage("§c 您输入的价格必须大于0!请重新输入!");
return;
}
//判断领地名称是否为空
Expand All @@ -951,7 +956,7 @@ const GUI = {
//开始上架领地
let old_land_data = JSON.parse(JSON.stringify(land_data));
land_data[LandUUID].on_sale = response.formValues[0];
land_data[LandUUID].sale_price = Math.abs(parseInt(response.formValues[1]));
land_data[LandUUID].sale_price = parseInt(response.formValues[1]);
land_data[LandUUID].land_name = response.formValues[2];
land_data[LandUUID].land_description = response.formValues[3];
//开始覆写文件land.json
Expand Down Expand Up @@ -1037,6 +1042,13 @@ const GUI = {
player.sendMessage("§c 您未选择任何玩家!");
return;
}
//判断该玩家是否已经在白名单中
for (let key in land_data[LandUUID].allowlist) {
if (players[response.formValues[0] - 1].id == key) {
player.sendMessage("§c 该玩家已在白名单中,无需重复添加!");
return;
}
}
//开始添加白名单
let old_land_data = JSON.parse(JSON.stringify(land_data));
//首先获取要添加的玩家对象
Expand All @@ -1060,16 +1072,14 @@ const GUI = {
},

ManageLandAllowlistDelete(player,LandUUID) {
//首先获取所有在线玩家的对象
let players = world.getPlayers();
//然后获取所有在线玩家的名称
let players_name = ["-未选择任何玩家-"];
for (let i = 0; i < players.length; i++) {
players_name.push(players[i].name);
//首先获取所有白名单玩家的对象
let allowlist_players = ["-未选择任何玩家-"];
for (let key in land_data[LandUUID].allowlist) {
allowlist_players.push(land_data[LandUUID].allowlist[key]);
}
const ManageLandAllowlistDeleteForm = new ModalFormData()
.title(`删除白名单[${LandUUID}] ${land_data[LandUUID].land_name}`)
.dropdown("请选择要删除的玩家",players_name)
.dropdown("请选择要删除的玩家",allowlist_players)
.show(player).then((response) => {
if (!response.canceled) {
if (response.formValues[0] == 0) {
Expand All @@ -1078,29 +1088,26 @@ const GUI = {
}
//开始删除白名单
let old_land_data = JSON.parse(JSON.stringify(land_data));
//检查该玩家是否在白名单中
if (!land_data[LandUUID].allowlist.hasOwnProperty(players[response.formValues[0] - 1].id)) {
player.sendMessage("§c 该玩家不在白名单中!");
return;
}
//首先获取要删除的玩家对象
delete land_data[LandUUID].allowlist[players[response.formValues[0] - 1].id];
delete land_data[LandUUID].allowlist[Object.keys(land_data[LandUUID].allowlist)[response.formValues[0] - 1]];
//开始覆写文件land.json
fs.OverwriteJsonFile("land.json",land_data).then((result) => {
if (result === "success") {
player.sendMessage(`§a 您已将玩家 §l§e${players[response.formValues[0] - 1].name} §r§a成功从领地§e ${land_data[LandUUID].land_name} §a的白名单中删除!`);
} else if (result === "-1") {
if (result === "success")
player.sendMessage(`§a 您已将玩家 §l§e${allowlist_players[response.formValues[0]]} §r§a成功从领地§e ${land_data[LandUUID].land_name} §a的白名单中删除!`);
else if (result === "-1") {
player.sendMessage("§c 服务器连接失败,请联系在线管理员!");
land_data = old_land_data;
} else {
player.sendMessage("§c 未知错误,请联系在线管理员!");
land_data = old_land_data;
}
})
}
)
} else {
this.ManageLandAllowlist(player,LandUUID);
}
})

},

//购买出售中领地
Expand Down Expand Up @@ -2360,6 +2367,11 @@ const GUI = {
player.sendMessage("§c 您输入的价格不是数字!请重新输入!");
return;
}
//开始判断价格是否为大于0的数字
if (parseInt(response.formValues[0]) <= 0) {
player.sendMessage("§c 您输入的价格必须大于0!请重新输入!");
return;
}
let new_land_data = JSON.parse(JSON.stringify(land_data));
//开始修改数据
new_land_data[LandUUID].sale_price = parseInt(response.formValues[0]);
Expand All @@ -2386,13 +2398,77 @@ const GUI = {
}
}


//玩家进入领地判断

system.runInterval(() => {
for (const player of world.getAllPlayers()) {
player_in_index(player);
try {
for (const player of world.getAllPlayers()) {
player_in_index(player);
}
} catch (error) {
console.warn(`[NIA V4] 领地系统发生了一次错误,错误原因:${error}`);
Broadcast(" §c领地系统发生了一次错误,错误原因:" + error);
Broadcast(" §e服务器正在尝试自动修复中,请截图并联系在线管理员!");
//圈地系统文件
let start_1 = Date.now();
fs.GetJSONFileData("land.json").then((result) => {
//文件不存在
if (result === 0) {
fs.CreateNewJsonFile("land.json",{}).then((result) => {
if (result === "success") {
land_data = {};
Broadcast(" §e领地数据文件不存在,已成功创建!");
} else if (result === -1) {
Broadcast(" §c依赖服务器连接失败!请检查依赖服务器是否成功启动,以及端口是否设置正确!");
}
});
} else if (result === -1) {
Broadcast(" §c依赖服务器连接失败!请检查依赖服务器是否成功启动,以及端口是否设置正确!");
} else {
//文件存在且服务器连接成功
land_data = result;
let LandNum = 0;
for (let Land in land_data) {
add_index(land_data[Land].pos1, land_data[Land].pos2, land_data[Land].dimid, Land);
LandNum++;
}
Broadcast(` §e领地数据自动重载成功,共获取到 ${LandNum} 块领地,本次读取用时:${Date.now() - start_1}ms`)
}
})

//玩家金币缓存文件
let start_2 = Date.now();
fs.GetJSONFileData("land_temp_player_money.json").then((result) => {
if (result === 0) {
fs.CreateNewJsonFile("land_temp_player_money.json",{}).then((result) => {
if (result === "success") {
log("玩家金币数据文件不存在,已成功创建!");
} else if (result === -1) {
Broadcast(" §c依赖服务器连接失败!请检查依赖服务器是否成功启动,以及端口是否设置正确!");
}
});
} else if (result === -1) {
Broadcast(" §c依赖服务器连接失败!请检查依赖服务器是否成功启动,以及端口是否设置正确!");
} else {
//文件存在且服务器连接成功
temp_player_money = result;
Broadcast(` §e玩家金币数据自动重载成功,本次读取用时:${Date.now() - start_2}ms`)
}
})

//删除所有常加载区块
let land_tickingarea = JSON.parse(world.getDynamicProperty("land_tickingarea"));
for (let key = 0;key < land_tickingarea.length;key++) {
RunCmd(`tickingarea remove ${land_tickingarea[key]}`);
Broadcast(` §7已删除常加载区块:${land_tickingarea[key]}`);
world.setDynamicProperty("land_tickingarea",JSON.stringify(land_tickingarea));
}
}

},1)


//玩家破坏方块监听
world.beforeEvents.playerBreakBlock.subscribe((event) => {
let land = pos_in_land([event.block.x,event.block.y,event.block.z],event.block.dimension.id);
Expand Down
3 changes: 2 additions & 1 deletion development_behavior_packs/NIA_V4.0_BP/scripts/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ import './log.js'

export const VERSION = "v1.4.0";
export const BDS_VERSION = "1.20.31.01";
export const LAST_UPGRATE = "2023/10/20";
export const LAST_UPGRATE = "2023/10/28";
export const CODE_BRANCH = "dev";


console.log(`\x1b[33m[NIA V4] NIA V4 已经成功在本服务器上启动!\x1b[0m`);
Expand Down
Binary file modified development_resource_packs/NIA_V4.0_RP/font/glyph_E1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions development_resource_packs/NIA_V4.0_RP/manifest.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
{
"format_version": 1,
"format_version": 2,
"header": {
"description": "§cNIA服务器V4-资源包\n作者:NIANIANKNIA\n项目地址:https://github.com/NIANIANKNIA/NIASERVER-V4",
"name": "NIA V4.0 RP",
"uuid": "981f1ce2-370b-4f58-99d9-9c504a118ec0",
"min_engine_version": [1, 20, 10],
"version": [1, 4, 0]
"min_engine_version": [1, 20, 30],
"version": [1, 4, 1]
},
"modules": [
{
"description": "NIANIANKNIA",
"type": "resources",
"uuid": "7e41869f-82f7-40f5-87c0-4dcfbc61d91b",
"version": [1, 4, 0]
"version": [1, 4, 1]
}
],
"metadata": {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion world_behavior_packs.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
"pack_id": "cab0bbe3-eb10-465e-b1de-b09facc076c8",
"version": [
1,4,0
1,4,1
]
}
]
2 changes: 1 addition & 1 deletion world_resource_packs.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
"pack_id": "981f1ce2-370b-4f58-99d9-9c504a118ec0",
"version": [
1,4,0
1,4,1
]
}
]

0 comments on commit a64e5e9

Please sign in to comment.