This commit is contained in:
parent
9d7d564457
commit
cead35b6a1
@ -27,6 +27,7 @@
|
||||
5. 禁止超视距操作(128以外),防止玩家利用创世神插件加载大量区块导致服务器卡顿;
|
||||
6. 支持自动从背包里的潜影盒补充材料;
|
||||
7. 支持设置是否产生掉落物;
|
||||
8. 支持设置速度倍率(整数,默认1表示每tick操作一个方块,设置为2则每次操作两个方块)
|
||||
|
||||
## 支持版本
|
||||
|
||||
@ -76,6 +77,8 @@ MaxZ: 64
|
||||
|
||||
DropItems: false
|
||||
|
||||
Multiplier: 1
|
||||
|
||||
Debug: false
|
||||
```
|
||||
|
||||
|
2
pom.xml
2
pom.xml
@ -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>
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,11 @@
|
||||
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;
|
||||
|
||||
public class Task implements Runnable{
|
||||
public class Task implements Runnable {
|
||||
/**
|
||||
* When an object implementing interface {@code Runnable} is used
|
||||
* to create a thread, starting the thread causes the object's
|
||||
@ -25,29 +26,31 @@ public class Task implements Runnable{
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Job job = this.xPlayer.popJob();
|
||||
if (job == null) {
|
||||
return;
|
||||
}
|
||||
// 如果任务不可执行 允许在一个tick内多次执行直到任务可执行
|
||||
int max_retries = 100;
|
||||
JobErrCode re;
|
||||
while ((re = job.Do()) != JobErrCode.OK) {
|
||||
max_retries--;
|
||||
if (max_retries <= 0) {
|
||||
break;
|
||||
for (int i = 0; i < LiteWorldEdit.config.getMultiplier(); i++) {
|
||||
Job job = this.xPlayer.popJob();
|
||||
if (job == null) {
|
||||
return;
|
||||
}
|
||||
if (re.canContinue()) {
|
||||
job.get_creator().sendTitle("§e警告", "§e" + re.getMessage(), 10, 70, 20);
|
||||
job = this.xPlayer.popJob();
|
||||
if (job == null) {
|
||||
// 如果任务不可执行 允许在一个tick内多次执行直到任务可执行
|
||||
int max_retries = 100;
|
||||
JobErrCode re;
|
||||
while ((re = job.Do()) != JobErrCode.OK) {
|
||||
max_retries--;
|
||||
if (max_retries <= 0) {
|
||||
break;
|
||||
}
|
||||
Player player = job.get_creator();
|
||||
if (re.canContinue()) {
|
||||
Notification.titleWarn(player, "警告", re.getMessage());
|
||||
job = this.xPlayer.popJob();
|
||||
if (job == null) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
Notification.titleError(player, "错误 任务已自动暂停", re.getMessage());
|
||||
this.xPlayer.pauseJob();
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
Player player = job.get_creator();
|
||||
player.sendTitle("§c错误 任务已自动暂停", "§c" + re.getMessage(), 10, 70, 20);
|
||||
this.xPlayer.pauseJob();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,8 @@ MaxY: 64
|
||||
|
||||
MaxZ: 64
|
||||
|
||||
Multiplier: 1
|
||||
|
||||
DropItems: false
|
||||
|
||||
Debug: false
|
Loading…
Reference in New Issue
Block a user