push ver
This commit is contained in:
parent
7d8d8993da
commit
55fe715f3b
44
.github/workflows/main.yml
vendored
Normal file
44
.github/workflows/main.yml
vendored
Normal file
@ -0,0 +1,44 @@
|
||||
name: Java CI with Maven
|
||||
|
||||
# 检测到 src 文件内 .java 文件有变动执行编译
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- '**/*src/**/*.java'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
# 配置权限
|
||||
permissions: write-all
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
# 下载代码
|
||||
- uses: actions/checkout@v3
|
||||
- name: Set up JDK 17
|
||||
# 安装 JDK
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
java-version: '17'
|
||||
distribution: 'temurin'
|
||||
cache: maven
|
||||
# Maven 打包
|
||||
- name: Build with Maven
|
||||
run: mvn -B package --file pom.xml
|
||||
# 将打包好的 Jar 包 放到 staging 文件夹
|
||||
- run: mkdir staging && cp target/*.jar staging
|
||||
# 设置 jobs Maven pom 版本环境变量
|
||||
- name: Set Release version env variable
|
||||
run: |
|
||||
echo "RELEASE_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_ENV
|
||||
- name: "Build & test"
|
||||
run: |
|
||||
echo "done!"
|
||||
# 上传文件并发布 Release
|
||||
- uses: "marvinpinto/action-automatic-releases@latest"
|
||||
with:
|
||||
repo_token: "${{ secrets.GITHUB_TOKEN }}"
|
||||
automatic_release_tag: "${{ env.RELEASE_VERSION }}"
|
||||
prerelease: false
|
||||
title: "Release ${{ env.RELEASE_VERSION }}"
|
||||
files: |
|
||||
staging/*.jar
|
60
README.md
60
README.md
@ -1,2 +1,58 @@
|
||||
# NoMoreVilliger
|
||||
村民计划生育(误)
|
||||
# NoMoreVillager
|
||||
村民计划生育(误)
|
||||
|
||||
## 说明
|
||||
|
||||
不知道各位服主有没有遇到过服务器发展到一定程度后,明明在线人数不多,也没有什么红石机器,但是服务器tps缺掉的厉害。
|
||||
|
||||
查看timings,发现在WorldDoTick项中的Entities分类里有个Villager分类占用了大量的计算时间(有的时候甚至达到了30%)。
|
||||
由于这破游戏的大量机制都依赖村民,所以玩家一般会做出**自动繁殖机**这样的东西刷出大量的村民。
|
||||
由于是自动繁殖机,所以玩家往往根本不会意识到他们搞出来了大量的村民。
|
||||
|
||||
这就导致了两个非常可怕的问题:
|
||||
1. 村民繁殖机往往会使用水流让村民卡墙角,这就会造成大量的实体挤压引起卡顿;
|
||||
2. 由于1.14版本开始加入工作方块,刚成年的村民为无业村民,而无业村民默认会以每5tick一次的频率搜寻附近的工作方块尝试工作,这就会导致大量的无业村民在服务器上搜寻工作方块,占用大量的计算时间。
|
||||
|
||||
## 功能介绍
|
||||
|
||||
1. 当一个区域内的无业村民达到了一定限制,不再允许新的村民繁殖出来;
|
||||
2. 当一个区域内的无业村民超过了一定限制,会强制处决过多的无业村民;
|
||||
|
||||
## 支持版本
|
||||
|
||||
- 1.14 及以上 Bukkit/Spigot/Paper
|
||||
|
||||
## 使用方法
|
||||
|
||||
1. 将插件放入服务器的 `plugins` 目录下
|
||||
2. 重启服务器
|
||||
3. 在 `plugins/NoMoreVillager/config.yml` 中配置
|
||||
4. 控制台或OP输入 `/nmv reload` 重载配置
|
||||
|
||||
> 也可以不修改配置文件,直接使用指令进行设置。
|
||||
>
|
||||
> 使用指令设置后也会同步更新到配置文件。
|
||||
|
||||
## 指令
|
||||
|
||||
### OP指令
|
||||
|
||||
`/nmv reload` 重载配置文件。
|
||||
|
||||
`/nmv limit <int>` 设置繁殖上限。
|
||||
|
||||
`/nmv forceDelete <int>` 设置强制处决阈值。
|
||||
|
||||
### 玩家指令
|
||||
|
||||
无
|
||||
|
||||
## 配置文件参考
|
||||
|
||||
```yaml
|
||||
# 一定区域内无业村民上限
|
||||
Limit: 3
|
||||
|
||||
# 超过多少就强制删除
|
||||
ForceDelete: 6
|
||||
```
|
||||
|
74
src/main/java/site/deercloud/nomorevillager/Commands.java
Normal file
74
src/main/java/site/deercloud/nomorevillager/Commands.java
Normal file
@ -0,0 +1,74 @@
|
||||
package site.deercloud.nomorevillager;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class Commands implements TabExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
switch (args[0]) {
|
||||
case "limit":
|
||||
if (args.length == 1) {
|
||||
sender.sendMessage("§c请输入要设置的村民上限");
|
||||
return true;
|
||||
}
|
||||
if (sender.isOp() || !(sender instanceof Player)) {
|
||||
try {
|
||||
Integer limit = Integer.parseInt(args[1]);
|
||||
NoMoreVillager.configManager.setLimit(limit);
|
||||
sender.sendMessage("§a村民繁殖上限已设置为 " + limit);
|
||||
} catch (NumberFormatException e) {
|
||||
sender.sendMessage("§c请输入正确的数字");
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage("§c你没有权限执行此命令");
|
||||
}
|
||||
break;
|
||||
case "forceDelete":
|
||||
if (args.length == 1) {
|
||||
sender.sendMessage("§c请输入要设置的强制处决阈值");
|
||||
return true;
|
||||
}
|
||||
if (sender.isOp() || !(sender instanceof Player)) {
|
||||
try {
|
||||
Integer forceDelete = Integer.parseInt(args[1]);
|
||||
NoMoreVillager.configManager.setForceDelete(forceDelete);
|
||||
sender.sendMessage("§a强制处决的开始数量已设置为 " + forceDelete);
|
||||
} catch (NumberFormatException e) {
|
||||
sender.sendMessage("§c请输入正确的数字");
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage("§c你没有权限执行此命令");
|
||||
}
|
||||
break;
|
||||
case "reload":
|
||||
if (sender.isOp() || !(sender instanceof Player)) {
|
||||
NoMoreVillager.configManager.reload();
|
||||
sender.sendMessage("§a配置已重载");
|
||||
} else {
|
||||
sender.sendMessage("§c你没有权限执行此命令");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
sender.sendMessage("§c未知的命令");
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
if (args.length == 1) {
|
||||
return Arrays.asList("limit", "forceDelete", "reload");
|
||||
} else {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
}
|
@ -7,3 +7,9 @@ load: STARTUP
|
||||
authors: [ Luming ]
|
||||
description: 限制村民行为,防止卡服。
|
||||
website: https://blog.deercloud.site
|
||||
commands:
|
||||
nomorevillager:
|
||||
description: NoMoreVillager
|
||||
usage: /nmv
|
||||
aliases: [ nmv ]
|
||||
default: true
|
||||
|
Loading…
Reference in New Issue
Block a user