添加了执行速度倍率
All checks were successful
Java CI-CD with Maven / build (push) Successful in 12m22s

This commit is contained in:
zhangyuheng 2024-01-24 11:42:13 +08:00
parent 9d7d564457
commit cead35b6a1
7 changed files with 126 additions and 38 deletions

View File

@ -27,6 +27,7 @@
5. 禁止超视距操作128以外防止玩家利用创世神插件加载大量区块导致服务器卡顿
6. 支持自动从背包里的潜影盒补充材料;
7. 支持设置是否产生掉落物;
8. 支持设置速度倍率整数默认1表示每tick操作一个方块设置为2则每次操作两个方块
## 支持版本
@ -76,6 +77,8 @@ MaxZ: 64
DropItems: false
Multiplier: 1
Debug: false
```

View File

@ -6,7 +6,7 @@
<groupId>site.deercloud</groupId>
<artifactId>LiteWorldEdit</artifactId>
<version>2.2.1.0</version>
<version>2.3.5.0</version>
<packaging>jar</packaging>
<name>LiteWorldEdit</name>

View File

@ -13,23 +13,25 @@ public final class LiteWorldEdit extends JavaPlugin {
public void onEnable() {
// Plugin startup logic
instance = this;
_config = new ConfigManager();
config = new ConfigManager();
_cache = new Cache();
Bukkit.getPluginManager().registerEvents(new Events(), this);
Objects.requireNonNull(Bukkit.getPluginCommand("LiteWorldEdit")).setExecutor(new Commands());
Objects.requireNonNull(Bukkit.getPluginCommand("LiteWorldEdit")).setTabCompleter(new Commands());
String logo = "LiteWorldEdit 已加载 版本: " + getPluginMeta().getVersion() + "\n";
LoggerX.info("LiteWorldEdit 已加载");
LoggerX.info("版本: " + getPluginMeta().getVersion());
LoggerX.info("");
// https://patorjk.com/software/taag/#p=display&f=Big&t=LiteWorldEdit
logo += " _ _ _ __ __ _ _ ______ _ _ _ \n";
logo += "| | (_) | \\ \\ / / | | | | ____| | (_) | \n";
logo += "| | _| |_ __\\ \\ /\\ / /__ _ __| | __| | |__ __| |_| |_ \n";
logo += "| | | | __/ _ \\\\/ \\/ / _ \\| '__| |/ _` | __| / _` | | __|\n";
logo += "| |____| | || __/\\ /\\ / (_) | | | | (_| | |___| (_| | | |_ \n";
logo += "|______|_|\\__\\___| \\/ \\/ \\___/|_| |_|\\__,_|______\\__,_|_|\\__|\n";
logo += "\n";
LoggerX.info(logo);
LoggerX.info(" _ _ _ __ __ _ _ ______ _ _ _ ");
LoggerX.info("| | (_) | \\ \\ / / | | | | ____| | (_) | ");
LoggerX.info("| | _| |_ __\\ \\ /\\ / /__ _ __| | __| | |__ __| |_| |_ ");
LoggerX.info("| | | | __/ _ \\\\/ \\/ / _ \\| '__| |/ _` | __| / _` | | __|");
LoggerX.info("| |____| | || __/\\ /\\ / (_) | | | | (_| | |___| (_| | | |_ ");
LoggerX.info("|______|_|\\__\\___| \\/ \\/ \\___/|_| |_|\\__,_|______\\__,_|_|\\__|");
LoggerX.info("");
}
@Override
@ -38,7 +40,7 @@ public final class LiteWorldEdit extends JavaPlugin {
}
public ConfigManager getConfigMgr() {
return _config;
return config;
}
public Cache getCache() {
@ -46,6 +48,6 @@ public final class LiteWorldEdit extends JavaPlugin {
}
public static LiteWorldEdit instance;
private ConfigManager _config;
public static ConfigManager config;
private Cache _cache;
}

View File

@ -16,7 +16,9 @@ public class ConfigManager {
_x_max = _file.getInt("MaxX", 64);
_y_max = _file.getInt("MaxY", 64);
_z_max = _file.getInt("MaxZ", 64);
_multiplier = _file.getInt("Multiplier", 1);
_drop_items = _file.getBoolean("DropItems", false);
_plugin.saveConfig();
}
public Boolean isDebug() {
@ -45,6 +47,10 @@ public class ConfigManager {
return _drop_items;
}
public Integer getMultiplier() {
return _multiplier;
}
public void setDropItems(Boolean drop_items) {
_drop_items = drop_items;
_file.set("DropItems", drop_items);
@ -73,4 +79,6 @@ public class ConfigManager {
private Integer _z_max;
private Boolean _drop_items;
private Integer _multiplier;
}

View File

@ -3,23 +3,93 @@ package site.deercloud.liteworldedit;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.Style;
import net.kyori.adventure.text.format.TextColor;
import net.kyori.adventure.title.Title;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import static site.deercloud.liteworldedit.LoggerX.*;
public class Notification {
private static final Style i_style = Style.style(TextColor.color(139, 255, 123));
private static final Style w_style = Style.style(TextColor.color(255, 185, 69));
private static final Style e_style = Style.style(TextColor.color(255, 96, 72));
private static final String prefix = "[LWE] ";
public static void info(Player player, String msg) {
player.sendMessage(Component.text("[LWE] " + msg, i_style));
player.sendMessage(Component.text(prefix + msg, i_style));
}
public static void warn(Player player, String msg) {
player.sendMessage(Component.text("[LWE] " + msg, w_style));
player.sendMessage(Component.text(prefix + msg, w_style));
}
public static void error(Player player, String msg) {
player.sendMessage(Component.text("[LWE] " + msg, e_style));
player.sendMessage(Component.text(prefix + msg, e_style));
}
public static void info(CommandSender sender, String msg) {
sender.sendMessage(Component.text(prefix + msg, i_style));
}
public static void warn(CommandSender sender, String msg) {
sender.sendMessage(Component.text(prefix + msg, w_style));
}
public static void error(CommandSender sender, String msg) {
sender.sendMessage(Component.text(prefix + msg, e_style));
}
public static void info(Player player, Component msg) {
player.sendMessage(Component.text(prefix, i_style).append(msg));
if (LiteWorldEdit.config.isDebug())
debug("来自玩家[ " + player.getName() + " ] 的提示 | " + msg);
}
public static void warn(Player player, Component msg) {
player.sendMessage(Component.text(prefix, w_style).append(msg));
if (LiteWorldEdit.config.isDebug())
debug("来自玩家[ " + player.getName() + " ] 的警告 | " + msg);
}
public static void error(Player player, Component msg) {
player.sendMessage(Component.text(prefix, e_style).append(msg));
if (LiteWorldEdit.config.isDebug())
debug("来自玩家[ " + player.getName() + " ] 的报错 | " + msg);
}
public static void info(CommandSender player, Component msg) {
player.sendMessage(Component.text(prefix, i_style).append(msg));
}
public static void warn(CommandSender player, Component msg) {
player.sendMessage(Component.text(prefix, w_style).append(msg));
}
public static void error(CommandSender player, Component msg) {
player.sendMessage(Component.text(prefix, e_style).append(msg));
}
private static void sendTitle(Player player, Component title, Component subtitle) {
Title title_t = Title.title(title, subtitle);
player.showTitle(title_t);
}
public static void titleInfo(Player player, String title, String subtitle) {
Component title_c = Component.text(title, i_style);
Component subtitle_c = Component.text(subtitle, i_style);
sendTitle(player, title_c, subtitle_c);
}
public static void titleWarn(Player player, String title, String subtitle) {
Component title_c = Component.text(title, w_style);
Component subtitle_c = Component.text(subtitle, w_style);
sendTitle(player, title_c, subtitle_c);
}
public static void titleError(Player player, String title, String subtitle) {
Component title_c = Component.text(title, e_style);
Component subtitle_c = Component.text(subtitle, e_style);
sendTitle(player, title_c, subtitle_c);
}
}

View File

@ -1,5 +1,6 @@
package site.deercloud.liteworldedit;
import net.kyori.adventure.text.Component;
import org.bukkit.entity.Player;
import site.deercloud.liteworldedit.Jobs.Job;
import site.deercloud.liteworldedit.Jobs.JobErrCode;
@ -25,6 +26,7 @@ public class Task implements Runnable{
@Override
public void run() {
for (int i = 0; i < LiteWorldEdit.config.getMultiplier(); i++) {
Job job = this.xPlayer.popJob();
if (job == null) {
return;
@ -37,18 +39,19 @@ public class Task implements Runnable{
if (max_retries <= 0) {
break;
}
Player player = job.get_creator();
if (re.canContinue()) {
job.get_creator().sendTitle("§e警告", "§e" + re.getMessage(), 10, 70, 20);
Notification.titleWarn(player, "警告", re.getMessage());
job = this.xPlayer.popJob();
if (job == null) {
return;
}
} else {
Player player = job.get_creator();
player.sendTitle("§c错误 任务已自动暂停", "§c" + re.getMessage(), 10, 70, 20);
Notification.titleError(player, "错误 任务已自动暂停", re.getMessage());
this.xPlayer.pauseJob();
return;
}
}
}
}
}

View File

@ -4,6 +4,8 @@ MaxY: 64
MaxZ: 64
Multiplier: 1
DropItems: false
Debug: false