This commit is contained in:
parent
aa8dc8aecf
commit
af7223c27f
4
pom.xml
4
pom.xml
@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>cn.lunadeer</groupId>
|
||||
<artifactId>EssentialsD</artifactId>
|
||||
<version>1.21.0</version>
|
||||
<version>1.22.0</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>EssentialsD</name>
|
||||
@ -82,7 +82,7 @@
|
||||
<dependency>
|
||||
<groupId>cn.lunadeer</groupId>
|
||||
<artifactId>MinecraftPluginUtils</artifactId>
|
||||
<version>1.2.0-SNAPSHOT</version>
|
||||
<version>1.3.2-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.MilkBowl</groupId>
|
||||
|
@ -22,19 +22,19 @@ public final class EssentialsD extends JavaPlugin {
|
||||
public void onEnable() {
|
||||
// Plugin startup logic
|
||||
instance = this;
|
||||
logger = new XLogger(instance);
|
||||
new XLogger(instance);
|
||||
config = new ConfigManager(instance);
|
||||
logger.setDebug(config.isDebug());
|
||||
notification = new Notification(instance);
|
||||
XLogger.setDebug(config.isDebug());
|
||||
new Notification(instance);
|
||||
database = new DatabaseManager(this,
|
||||
config.getDbType().equals("pgsql") ? DatabaseManager.TYPE.POSTGRESQL : DatabaseManager.TYPE.SQLITE,
|
||||
DatabaseManager.TYPE.valueOf(config.getDbType().toUpperCase()),
|
||||
config.getDbHost(),
|
||||
config.getDbPort(),
|
||||
config.getDbName(),
|
||||
config.getDbUser(),
|
||||
config.getDbPass());
|
||||
DatabaseTables.migrate();
|
||||
scheduler = new Scheduler(this);
|
||||
new Scheduler(this);
|
||||
tpManager = new TeleportManager();
|
||||
|
||||
Bukkit.getPluginManager().registerEvents(new InvisibleItemFrameEvent(), this);
|
||||
@ -97,16 +97,16 @@ public final class EssentialsD extends JavaPlugin {
|
||||
|
||||
config.ApplyForceLoadChunks(); // 应用强加载区块
|
||||
|
||||
logger.info("EssentialsD 已加载");
|
||||
logger.info("版本: " + getPluginMeta().getVersion());
|
||||
XLogger.info("EssentialsD 已加载");
|
||||
XLogger.info("版本: " + getPluginMeta().getVersion());
|
||||
// https://patorjk.com/software/taag/#p=display&f=Big&t=EssentialsD
|
||||
logger.info(" ______ _ _ _ _____");
|
||||
logger.info(" | ____| | | (_) | | | __ \\");
|
||||
logger.info(" | |__ ___ ___ ___ _ __ | |_ _ __ _| |___| | | |");
|
||||
logger.info(" | __| / __/ __|/ _ \\ '_ \\| __| |/ _` | / __| | | |");
|
||||
logger.info(" | |____\\__ \\__ \\ __/ | | | |_| | (_| | \\__ \\ |__| |");
|
||||
logger.info(" |______|___/___/\\___|_| |_|\\__|_|\\__,_|_|___/_____/");
|
||||
logger.info("");
|
||||
XLogger.info(" ______ _ _ _ _____");
|
||||
XLogger.info(" | ____| | | (_) | | | __ \\");
|
||||
XLogger.info(" | |__ ___ ___ ___ _ __ | |_ _ __ _| |___| | | |");
|
||||
XLogger.info(" | __| / __/ __|/ _ \\ '_ \\| __| |/ _` | / __| | | |");
|
||||
XLogger.info(" | |____\\__ \\__ \\ __/ | | | |_| | (_| | \\__ \\ |__| |");
|
||||
XLogger.info(" |______|___/___/\\___|_| |_|\\__|_|\\__,_|_|___/_____/");
|
||||
XLogger.info("");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -116,9 +116,7 @@ public final class EssentialsD extends JavaPlugin {
|
||||
|
||||
public static EssentialsD instance;
|
||||
public static ConfigManager config;
|
||||
public static Scheduler scheduler;
|
||||
public static Notification notification;
|
||||
public static XLogger logger;
|
||||
|
||||
public static TeleportManager tpManager;
|
||||
public static DatabaseManager database;
|
||||
private GiteaReleaseCheck releaseCheck;
|
||||
|
@ -1,6 +1,8 @@
|
||||
package cn.lunadeer.essentialsd.commands;
|
||||
|
||||
import cn.lunadeer.essentialsd.EssentialsD;
|
||||
import cn.lunadeer.minecraftpluginutils.Notification;
|
||||
import cn.lunadeer.minecraftpluginutils.XLogger;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -18,13 +20,13 @@ public class Apis {
|
||||
if (sender instanceof Player) {
|
||||
Player player = (Player) sender;
|
||||
if (!player.isOp()) {
|
||||
EssentialsD.logger.warn("玩家 " + player.getName() + " 被拒绝执行命令");
|
||||
EssentialsD.notification.warn(player, "你没有权限使用此命令");
|
||||
XLogger.warn("玩家 %s 被拒绝执行命令", player.getName());
|
||||
Notification.warn(player, "你没有权限使用此命令");
|
||||
return null;
|
||||
}
|
||||
return player;
|
||||
}
|
||||
EssentialsD.notification.warn(sender, "只有玩家才能使用此命令");
|
||||
Notification.warn(sender, "只有玩家才能使用此命令");
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -40,12 +42,12 @@ public class Apis {
|
||||
if (args.length == 1) {
|
||||
target = EssentialsD.instance.getServer().getPlayer(args[0]);
|
||||
if (target == null) {
|
||||
EssentialsD.notification.warn(sender, "玩家 " + args[0] + " 不在线");
|
||||
Notification.warn(sender, "玩家 %s 不在线", args[0]);
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
if (!(sender instanceof Player)) {
|
||||
EssentialsD.notification.warn(sender, "请指定要操作的玩家");
|
||||
Notification.warn(sender, "请指定要操作的玩家");
|
||||
return null;
|
||||
}
|
||||
target = (Player) sender;
|
||||
@ -63,8 +65,8 @@ public class Apis {
|
||||
if (sender instanceof Player) {
|
||||
Player player = (Player) sender;
|
||||
if (!player.isOp()) {
|
||||
EssentialsD.logger.warn("玩家 " + player.getName() + " 被拒绝执行命令");
|
||||
EssentialsD.notification.warn(player, "你没有权限使用此命令");
|
||||
XLogger.warn("玩家 %s 被拒绝执行命令", player.getName());
|
||||
Notification.warn(player, "你没有权限使用此命令");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package cn.lunadeer.essentialsd.commands;
|
||||
|
||||
import cn.lunadeer.essentialsd.EssentialsD;
|
||||
import cn.lunadeer.minecraftpluginutils.Notification;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
@ -14,11 +15,11 @@ public class Back implements TabExecutor {
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
EssentialsD.notification.warn(sender, "只有玩家可以使用此命令");
|
||||
Notification.warn(sender, "只有玩家可以使用此命令");
|
||||
return true;
|
||||
}
|
||||
if (!EssentialsD.config.getCommandsBack()) {
|
||||
EssentialsD.notification.error(sender, "这个命令已被管理员禁用");
|
||||
Notification.error(sender, "这个命令已被管理员禁用");
|
||||
return false;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
|
@ -1,6 +1,8 @@
|
||||
package cn.lunadeer.essentialsd.commands;
|
||||
|
||||
import cn.lunadeer.essentialsd.EssentialsD;
|
||||
import cn.lunadeer.minecraftpluginutils.Notification;
|
||||
import cn.lunadeer.minecraftpluginutils.Scheduler;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -28,13 +30,13 @@ public class Day implements CommandExecutor {
|
||||
return false;
|
||||
}
|
||||
// set time to 1000
|
||||
EssentialsD.scheduler.runTask(() -> {
|
||||
Scheduler.runTask(() -> {
|
||||
if (sender instanceof Player) {
|
||||
((Player) sender).getWorld().setTime(1000);
|
||||
EssentialsD.notification.info(sender, "设置 " + ((Player) sender).getWorld().getName() + " 时间为白天");
|
||||
Notification.info(sender, "设置 %s 时间为白天", ((Player) sender).getWorld().getName());
|
||||
} else {
|
||||
EssentialsD.instance.getServer().getWorlds().forEach(world -> world.setTime(1000));
|
||||
EssentialsD.notification.info(sender, "设置时间为白天");
|
||||
Notification.info(sender, "设置时间为白天");
|
||||
}
|
||||
});
|
||||
return true;
|
||||
|
@ -1,6 +1,7 @@
|
||||
package cn.lunadeer.essentialsd.commands;
|
||||
|
||||
import cn.lunadeer.essentialsd.EssentialsD;
|
||||
import cn.lunadeer.minecraftpluginutils.Notification;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -14,11 +15,11 @@ public class EnderChest implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
EssentialsD.notification.error(sender, "只有玩家才能使用这个命令");
|
||||
Notification.error(sender, "只有玩家才能使用这个命令");
|
||||
return false;
|
||||
}
|
||||
if (!EssentialsD.config.getCommandsEnderchest()) {
|
||||
EssentialsD.notification.error(sender, "这个命令已被管理员禁用");
|
||||
Notification.error(sender, "这个命令已被管理员禁用");
|
||||
return false;
|
||||
}
|
||||
// 打开玩家的末影箱
|
||||
@ -26,7 +27,7 @@ public class EnderChest implements CommandExecutor {
|
||||
Inventory chest = player.getEnderChest();
|
||||
InventoryView view = player.openInventory(chest);
|
||||
if (view == null) {
|
||||
EssentialsD.notification.error(sender, "无法打开末影箱");
|
||||
Notification.error(sender, "无法打开末影箱");
|
||||
return false;
|
||||
}
|
||||
InventoryOpenEvent event = new InventoryOpenEvent(view);
|
||||
|
@ -1,6 +1,8 @@
|
||||
package cn.lunadeer.essentialsd.commands;
|
||||
|
||||
import cn.lunadeer.essentialsd.EssentialsD;
|
||||
import cn.lunadeer.minecraftpluginutils.Notification;
|
||||
import cn.lunadeer.minecraftpluginutils.Scheduler;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -16,19 +18,19 @@ public class Fly implements CommandExecutor {
|
||||
if (notOpOrConsole(sender)) {
|
||||
return false;
|
||||
}
|
||||
EssentialsD.scheduler.runTask(() -> {
|
||||
Scheduler.runTask(() -> {
|
||||
Player target = opCommandGetPlayer(sender, args);
|
||||
if (target == null) {
|
||||
return;
|
||||
}
|
||||
if (target.getAllowFlight()) {
|
||||
target.setAllowFlight(false);
|
||||
EssentialsD.notification.info(sender, "已关闭玩家 " + target.getName() + " 的飞行模式");
|
||||
EssentialsD.notification.info(target, "已关闭飞行模式");
|
||||
Notification.info(sender, "已关闭玩家 %s 的飞行模式", target.getName());
|
||||
Notification.info(target, "已关闭飞行模式");
|
||||
} else {
|
||||
target.setAllowFlight(true);
|
||||
EssentialsD.notification.info(sender, "已开启玩家 " + target.getName() + " 的飞行模式");
|
||||
EssentialsD.notification.info(target, "已开启飞行模式");
|
||||
Notification.info(sender, "已开启玩家 %s 的飞行模式", target.getName());
|
||||
Notification.info(target, "已开启飞行模式");
|
||||
}
|
||||
});
|
||||
return true;
|
||||
|
@ -1,6 +1,8 @@
|
||||
package cn.lunadeer.essentialsd.commands;
|
||||
|
||||
import cn.lunadeer.essentialsd.EssentialsD;
|
||||
import cn.lunadeer.minecraftpluginutils.Notification;
|
||||
import cn.lunadeer.minecraftpluginutils.Scheduler;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -16,19 +18,19 @@ public class God implements CommandExecutor {
|
||||
if (notOpOrConsole(sender)) {
|
||||
return false;
|
||||
}
|
||||
EssentialsD.scheduler.runTask(() -> {
|
||||
Scheduler.runTask(() -> {
|
||||
Player target = opCommandGetPlayer(sender, args);
|
||||
if (target == null) {
|
||||
return;
|
||||
}
|
||||
if (target.isInvulnerable()) {
|
||||
target.setInvulnerable(false);
|
||||
EssentialsD.notification.info(sender, "已关闭玩家 " + target.getName() + " 的无敌模式");
|
||||
EssentialsD.notification.info(target, "已关闭无敌模式");
|
||||
Notification.info(sender, "已关闭玩家 %s 的无敌模式", target.getName());
|
||||
Notification.info(target, "已关闭无敌模式");
|
||||
} else {
|
||||
target.setInvulnerable(true);
|
||||
EssentialsD.notification.info(sender, "已开启玩家 " + target.getName() + " 的无敌模式");
|
||||
EssentialsD.notification.info(target, "已开启无敌模式");
|
||||
Notification.info(sender, "已开启玩家 %s 的无敌模式", target.getName());
|
||||
Notification.info(target, "已开启无敌模式");
|
||||
}
|
||||
});
|
||||
return true;
|
||||
|
@ -1,6 +1,7 @@
|
||||
package cn.lunadeer.essentialsd.commands;
|
||||
|
||||
import cn.lunadeer.essentialsd.EssentialsD;
|
||||
import cn.lunadeer.minecraftpluginutils.Notification;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -13,24 +14,24 @@ public class Hat implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
EssentialsD.notification.warn(sender, "只有玩家可以使用此命令");
|
||||
Notification.warn(sender, "只有玩家可以使用此命令");
|
||||
return true;
|
||||
}
|
||||
if (!EssentialsD.config.getCommandsHat()) {
|
||||
EssentialsD.notification.error(sender, "这个命令已被管理员禁用");
|
||||
Notification.error(sender, "这个命令已被管理员禁用");
|
||||
return false;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
PlayerInventory inventory = player.getInventory();
|
||||
ItemStack right_hand_item = inventory.getItemInMainHand();
|
||||
if (right_hand_item.getType().isAir()) {
|
||||
EssentialsD.notification.warn(player, "你的主手为空");
|
||||
Notification.warn(player, "你的主手为空");
|
||||
return true;
|
||||
}
|
||||
ItemStack head_item = inventory.getHelmet();
|
||||
inventory.setItemInMainHand(head_item);
|
||||
inventory.setHelmet(right_hand_item);
|
||||
EssentialsD.notification.info(player, "已将你的主物品放到了你的头上");
|
||||
Notification.info(player, "已将你的主物品放到了你的头上");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,9 @@
|
||||
package cn.lunadeer.essentialsd.commands;
|
||||
|
||||
import cn.lunadeer.essentialsd.EssentialsD;
|
||||
import cn.lunadeer.minecraftpluginutils.Notification;
|
||||
import cn.lunadeer.minecraftpluginutils.Scheduler;
|
||||
import cn.lunadeer.minecraftpluginutils.XLogger;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -8,6 +11,7 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static cn.lunadeer.essentialsd.commands.Apis.notOpOrConsole;
|
||||
import static cn.lunadeer.essentialsd.commands.Apis.opCommandGetPlayer;
|
||||
|
||||
public class Inspect implements CommandExecutor {
|
||||
@ -26,16 +30,14 @@ public class Inspect implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
EssentialsD.notification.error(sender, "只有玩家才能使用这个命令");
|
||||
Notification.error(sender, "只有玩家才能使用这个命令");
|
||||
return false;
|
||||
}
|
||||
Player op = (Player) sender;
|
||||
if (!op.isOp()) {
|
||||
EssentialsD.logger.warn("玩家 " + op.getName() + " 试图使用检查命令");
|
||||
EssentialsD.notification.error(op, "你没有权限使用这个命令");
|
||||
if (notOpOrConsole(sender)) {
|
||||
return false;
|
||||
}
|
||||
EssentialsD.scheduler.runTask(() -> {
|
||||
Scheduler.runTask(() -> {
|
||||
Player target = opCommandGetPlayer(sender, args);
|
||||
if (target == null) {
|
||||
return;
|
||||
|
@ -1,6 +1,7 @@
|
||||
package cn.lunadeer.essentialsd.commands;
|
||||
|
||||
import cn.lunadeer.essentialsd.EssentialsD;
|
||||
import cn.lunadeer.minecraftpluginutils.Notification;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -24,13 +25,13 @@ public class More implements CommandExecutor {
|
||||
try {
|
||||
amount = Integer.parseInt(args[0]);
|
||||
} catch (NumberFormatException e) {
|
||||
EssentialsD.notification.error(sender, "参数错误");
|
||||
Notification.error(sender, "参数错误");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
ItemStack item = player.getInventory().getItemInMainHand();
|
||||
if (item.getType().isAir()) {
|
||||
EssentialsD.notification.error(sender, "你手上没有物品");
|
||||
Notification.error(sender, "你手上没有物品");
|
||||
return false;
|
||||
}
|
||||
int failed_add_count = 0;
|
||||
@ -41,7 +42,7 @@ public class More implements CommandExecutor {
|
||||
}
|
||||
}
|
||||
if (failed_add_count != 0) {
|
||||
EssentialsD.notification.warn(sender, "背包已满,有 " + failed_add_count + " 个物品未能添加");
|
||||
Notification.warn(sender, "背包已满,有 %d 个物品未能添加", failed_add_count);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
package cn.lunadeer.essentialsd.commands;
|
||||
|
||||
import cn.lunadeer.essentialsd.EssentialsD;
|
||||
import cn.lunadeer.minecraftpluginutils.Notification;
|
||||
import cn.lunadeer.minecraftpluginutils.Scheduler;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -28,13 +30,13 @@ public class Night implements CommandExecutor {
|
||||
return false;
|
||||
}
|
||||
// set time to 13000
|
||||
EssentialsD.scheduler.runTask(() -> {
|
||||
Scheduler.runTask(() -> {
|
||||
if (sender instanceof Player) {
|
||||
((Player) sender).getWorld().setTime(13000);
|
||||
EssentialsD.notification.info(sender, "设置 " + ((Player) sender).getWorld().getName() + " 时间为夜晚");
|
||||
Notification.info(sender, "设置 %s 时间为夜晚", ((Player) sender).getWorld().getName());
|
||||
} else {
|
||||
EssentialsD.instance.getServer().getWorlds().forEach(world -> world.setTime(13000));
|
||||
EssentialsD.notification.info(sender, "设置时间为夜晚");
|
||||
Notification.info(sender, "设置时间为夜晚");
|
||||
}
|
||||
});
|
||||
return true;
|
||||
|
@ -1,6 +1,8 @@
|
||||
package cn.lunadeer.essentialsd.commands;
|
||||
|
||||
import cn.lunadeer.essentialsd.EssentialsD;
|
||||
import cn.lunadeer.minecraftpluginutils.Notification;
|
||||
import cn.lunadeer.minecraftpluginutils.Scheduler;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -28,13 +30,13 @@ public class Noon implements CommandExecutor {
|
||||
return false;
|
||||
}
|
||||
// set time to 6000
|
||||
EssentialsD.scheduler.runTask(() -> {
|
||||
Scheduler.runTask(() -> {
|
||||
if (sender instanceof Player) {
|
||||
((Player) sender).getWorld().setTime(6000);
|
||||
EssentialsD.notification.info(sender, "设置 " + ((Player) sender).getWorld().getName() + " 时间为正午");
|
||||
Notification.info(sender, "设置 %s 时间为正午", ((Player) sender).getWorld().getName());
|
||||
} else {
|
||||
EssentialsD.instance.getServer().getWorlds().forEach(world -> world.setTime(6000));
|
||||
EssentialsD.notification.info(sender, "设置时间为正午");
|
||||
Notification.info(sender, "设置时间为正午");
|
||||
}
|
||||
});
|
||||
return true;
|
||||
|
@ -1,6 +1,8 @@
|
||||
package cn.lunadeer.essentialsd.commands;
|
||||
|
||||
import cn.lunadeer.essentialsd.EssentialsD;
|
||||
import cn.lunadeer.minecraftpluginutils.Notification;
|
||||
import cn.lunadeer.minecraftpluginutils.Scheduler;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -17,10 +19,10 @@ public class Rain implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
// 设置天气为雨天
|
||||
EssentialsD.scheduler.runTask(() -> {
|
||||
Scheduler.runTask(() -> {
|
||||
player.getWorld().setStorm(true);
|
||||
player.getWorld().setThundering(false);
|
||||
EssentialsD.notification.info(player, "设置 " + player.getWorld().getName() + " 天气为雨天");
|
||||
Notification.info(player, "设置 %s 天气为雨天", player.getWorld().getName());
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package cn.lunadeer.essentialsd.commands;
|
||||
|
||||
import cn.lunadeer.essentialsd.EssentialsD;
|
||||
import cn.lunadeer.minecraftpluginutils.Notification;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
@ -14,11 +15,11 @@ public class Rtp implements TabExecutor {
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
EssentialsD.notification.warn(sender, "只有玩家可以使用此命令");
|
||||
Notification.warn(sender, "只有玩家可以使用此命令");
|
||||
return true;
|
||||
}
|
||||
if (!EssentialsD.config.getCommandsRtp()) {
|
||||
EssentialsD.notification.error(sender, "这个命令已被管理员禁用");
|
||||
Notification.error(sender, "这个命令已被管理员禁用");
|
||||
return false;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
|
@ -1,6 +1,7 @@
|
||||
package cn.lunadeer.essentialsd.commands;
|
||||
|
||||
import cn.lunadeer.essentialsd.EssentialsD;
|
||||
import cn.lunadeer.minecraftpluginutils.Notification;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
@ -28,10 +29,10 @@ public class Save implements CommandExecutor {
|
||||
return false;
|
||||
}
|
||||
// 保存服务器存档
|
||||
EssentialsD.notification.info(sender, "正在保存服务器存档...");
|
||||
Notification.info(sender, "正在保存服务器存档...");
|
||||
EssentialsD.instance.getServer().savePlayers();
|
||||
EssentialsD.instance.getServer().getWorlds().forEach(World::save);
|
||||
EssentialsD.notification.info(sender, "服务器存档已保存");
|
||||
Notification.info(sender, "服务器存档已保存");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package cn.lunadeer.essentialsd.commands;
|
||||
|
||||
import cn.lunadeer.essentialsd.EssentialsD;
|
||||
import cn.lunadeer.minecraftpluginutils.Notification;
|
||||
import cn.lunadeer.minecraftpluginutils.stui.components.Button;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
@ -23,11 +24,11 @@ public class ShowItem implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
EssentialsD.notification.warn(sender, "只有玩家可以使用此命令");
|
||||
Notification.warn(sender, "只有玩家可以使用此命令");
|
||||
return true;
|
||||
}
|
||||
if (!EssentialsD.config.getCommandsShowItem()) {
|
||||
EssentialsD.notification.error(sender, "这个命令已被管理员禁用");
|
||||
Notification.error(sender, "这个命令已被管理员禁用");
|
||||
return false;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
@ -38,7 +39,7 @@ public class ShowItem implements CommandExecutor {
|
||||
PlayerInventory backpack = player.getInventory();
|
||||
ItemStack item = backpack.getItemInMainHand().clone();
|
||||
if (item.getType().isAir()) {
|
||||
EssentialsD.notification.warn(player, "你的主手为空");
|
||||
Notification.warn(player, "你的主手为空");
|
||||
return true;
|
||||
}
|
||||
String name_str = item.getType().name();
|
||||
@ -61,7 +62,7 @@ public class ShowItem implements CommandExecutor {
|
||||
|
||||
private static void openView(Player player, String name) {
|
||||
if (!cache.containsKey(name)) {
|
||||
EssentialsD.notification.warn(player, "物品不存在");
|
||||
Notification.warn(player, "物品不存在");
|
||||
return;
|
||||
}
|
||||
Inventory inv = cache.get(name);
|
||||
|
@ -1,6 +1,7 @@
|
||||
package cn.lunadeer.essentialsd.commands;
|
||||
|
||||
import cn.lunadeer.essentialsd.EssentialsD;
|
||||
import cn.lunadeer.minecraftpluginutils.Notification;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
@ -19,11 +20,11 @@ public class Skull implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
EssentialsD.notification.warn(sender, "只有玩家可以使用此命令");
|
||||
Notification.warn(sender, "只有玩家可以使用此命令");
|
||||
return true;
|
||||
}
|
||||
if (!EssentialsD.config.getCommandsSkull()) {
|
||||
EssentialsD.notification.error(sender, "这个命令已被管理员禁用");
|
||||
Notification.error(sender, "这个命令已被管理员禁用");
|
||||
return false;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
@ -41,7 +42,7 @@ public class Skull implements CommandExecutor {
|
||||
skulls.putAll(dragon_skulls);
|
||||
skulls.putAll(wither_skulls);
|
||||
if (skulls.isEmpty()) {
|
||||
EssentialsD.notification.warn(player, "你的背包中没有可以用来交换的头颅");
|
||||
Notification.warn(player, "你的背包中没有可以用来交换的头颅");
|
||||
return true;
|
||||
}
|
||||
// 交换头颅
|
||||
@ -53,7 +54,7 @@ public class Skull implements CommandExecutor {
|
||||
}
|
||||
ItemStack player_skull = getPlayerSkull(player);
|
||||
player.getWorld().dropItem(player.getLocation(), player_skull);
|
||||
EssentialsD.notification.info(player, "交换成功");
|
||||
Notification.info(player, "交换成功");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
package cn.lunadeer.essentialsd.commands;
|
||||
|
||||
import cn.lunadeer.essentialsd.EssentialsD;
|
||||
import cn.lunadeer.minecraftpluginutils.Notification;
|
||||
import cn.lunadeer.minecraftpluginutils.Scheduler;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -17,10 +19,10 @@ public class Storm implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
// 设置天气为雷雨
|
||||
EssentialsD.scheduler.runTask(() -> {
|
||||
Scheduler.runTask(() -> {
|
||||
player.getWorld().setStorm(true);
|
||||
player.getWorld().setThundering(true);
|
||||
EssentialsD.notification.info(player, "设置 " + player.getWorld().getName() + " 天气为雷雨");
|
||||
Notification.info(player, "设置 %s 天气为雷雨", player.getWorld().getName());
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package cn.lunadeer.essentialsd.commands;
|
||||
|
||||
import cn.lunadeer.essentialsd.EssentialsD;
|
||||
import cn.lunadeer.minecraftpluginutils.Notification;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -12,17 +13,17 @@ public class Suicide implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
EssentialsD.notification.warn(sender, "只有玩家可以使用此命令");
|
||||
Notification.warn(sender, "只有玩家可以使用此命令");
|
||||
return true;
|
||||
}
|
||||
if (!EssentialsD.config.getCommandsSuicide()) {
|
||||
EssentialsD.notification.error(sender, "这个命令已被管理员禁用");
|
||||
Notification.error(sender, "这个命令已被管理员禁用");
|
||||
return false;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
player.setHealth(0.0);
|
||||
player.setKiller(player);
|
||||
EssentialsD.notification.info(player, "你自杀了");
|
||||
Notification.info(player, "你自杀了");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
package cn.lunadeer.essentialsd.commands;
|
||||
|
||||
import cn.lunadeer.essentialsd.EssentialsD;
|
||||
import cn.lunadeer.minecraftpluginutils.Notification;
|
||||
import cn.lunadeer.minecraftpluginutils.Scheduler;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -16,11 +18,11 @@ public class Sun implements CommandExecutor {
|
||||
if (player == null) {
|
||||
return true;
|
||||
}
|
||||
EssentialsD.scheduler.runTask(() -> {
|
||||
Scheduler.runTask(() -> {
|
||||
// 设置天气为晴朗
|
||||
player.getWorld().setStorm(false);
|
||||
player.getWorld().setThundering(false);
|
||||
EssentialsD.notification.info(player, "设置 " + player.getWorld().getName() + " 天气为晴朗");
|
||||
Notification.info(player, "设置 %s 天气为晴朗", player.getWorld().getName());
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package cn.lunadeer.essentialsd.commands;
|
||||
|
||||
import cn.lunadeer.essentialsd.EssentialsD;
|
||||
import cn.lunadeer.minecraftpluginutils.Notification;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
@ -16,18 +17,18 @@ public class Tpa implements TabExecutor {
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
EssentialsD.notification.warn(sender, "只有玩家可以使用此命令");
|
||||
Notification.warn(sender, "只有玩家可以使用此命令");
|
||||
return true;
|
||||
}
|
||||
if (!EssentialsD.config.getCommandsTpa()) {
|
||||
EssentialsD.notification.error(sender, "这个命令已被管理员禁用");
|
||||
Notification.error(sender, "这个命令已被管理员禁用");
|
||||
return false;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
if (args.length == 1) {
|
||||
Player target = EssentialsD.instance.getServer().getPlayer(args[0]);
|
||||
if (target == null) {
|
||||
EssentialsD.notification.warn(player, "玩家 " + args[0] + " 不在线");
|
||||
Notification.warn(player, "玩家 %s 不在线", args[0]);
|
||||
return true;
|
||||
}
|
||||
EssentialsD.tpManager.request(player, target);
|
||||
@ -40,11 +41,11 @@ public class Tpa implements TabExecutor {
|
||||
EssentialsD.tpManager.deny(player, UUID.fromString(args[1]));
|
||||
return true;
|
||||
} else {
|
||||
EssentialsD.notification.error(player, "参数错误");
|
||||
Notification.error(player, "参数错误");
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
EssentialsD.notification.error(player, "参数错误");
|
||||
Notification.error(player, "参数错误");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package cn.lunadeer.essentialsd.commands.home;
|
||||
import cn.lunadeer.essentialsd.EssentialsD;
|
||||
import cn.lunadeer.essentialsd.dtos.HomeInfo;
|
||||
import cn.lunadeer.essentialsd.tuis.HomeList;
|
||||
import cn.lunadeer.minecraftpluginutils.Notification;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
@ -17,11 +18,11 @@ public class DelHome implements TabExecutor {
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
EssentialsD.notification.warn(sender, "只有玩家可以使用此命令");
|
||||
Notification.warn(sender, "只有玩家可以使用此命令");
|
||||
return true;
|
||||
}
|
||||
if (!EssentialsD.config.getCommandsHome()) {
|
||||
EssentialsD.notification.error(sender, "这个命令已被管理员禁用");
|
||||
Notification.error(sender, "这个命令已被管理员禁用");
|
||||
return false;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
@ -33,9 +34,9 @@ public class DelHome implements TabExecutor {
|
||||
}
|
||||
boolean res = HomeInfo.deleteHome(player.getUniqueId(), homeName);
|
||||
if (res) {
|
||||
EssentialsD.notification.info(player, "成功删除家 " + homeName);
|
||||
Notification.info(player, "成功删除家 %s", homeName);
|
||||
} else {
|
||||
EssentialsD.notification.error(player, "删除家 " + homeName + " 失败, 请联系管理员");
|
||||
Notification.error(player, "删除家 %s 失败, 请联系管理员", homeName);
|
||||
}
|
||||
if (args.length == 2) {
|
||||
try {
|
||||
|
@ -2,6 +2,7 @@ package cn.lunadeer.essentialsd.commands.home;
|
||||
|
||||
import cn.lunadeer.essentialsd.EssentialsD;
|
||||
import cn.lunadeer.essentialsd.dtos.HomeInfo;
|
||||
import cn.lunadeer.minecraftpluginutils.Notification;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
@ -16,11 +17,11 @@ public class Home implements TabExecutor {
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
EssentialsD.notification.warn(sender, "只有玩家可以使用此命令");
|
||||
Notification.warn(sender, "只有玩家可以使用此命令");
|
||||
return true;
|
||||
}
|
||||
if (!EssentialsD.config.getCommandsHome()) {
|
||||
EssentialsD.notification.error(sender, "这个命令已被管理员禁用");
|
||||
Notification.error(sender, "这个命令已被管理员禁用");
|
||||
return false;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
@ -28,7 +29,7 @@ public class Home implements TabExecutor {
|
||||
String homeName;
|
||||
if (args.length == 0) {
|
||||
if (homes.size() == 0) {
|
||||
EssentialsD.notification.error(player, "你还没有设置家");
|
||||
Notification.error(player, "你还没有设置家");
|
||||
return true;
|
||||
}
|
||||
homeName = homes.get(0).homeName;
|
||||
@ -37,17 +38,17 @@ public class Home implements TabExecutor {
|
||||
}
|
||||
HomeInfo home = HomeInfo.getHome(player.getUniqueId(), homeName);
|
||||
if (home == null) {
|
||||
EssentialsD.notification.error(player, "不存在名为 " + homeName + " 的家");
|
||||
Notification.error(player, "不存在名为 %s 的家", homeName);
|
||||
return true;
|
||||
}
|
||||
try {
|
||||
EssentialsD.tpManager.doTeleportDelayed(player, home.location, EssentialsD.config.getTpDelay(), () -> {
|
||||
EssentialsD.notification.info(player, "正在传送到家 " + homeName);
|
||||
Notification.info(player, "正在传送到家 %s", homeName);
|
||||
}, () -> {
|
||||
EssentialsD.notification.info(player, "成功传送到家 " + homeName);
|
||||
Notification.info(player, "成功传送到家 %s", homeName);
|
||||
});
|
||||
} catch (RuntimeException e) {
|
||||
EssentialsD.notification.error(player, "传送到家 " + homeName + " 失败: " + e.getMessage());
|
||||
Notification.error(player, "传送到家 %s 失败: %s", homeName, e.getMessage());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package cn.lunadeer.essentialsd.commands.home;
|
||||
|
||||
import cn.lunadeer.essentialsd.EssentialsD;
|
||||
import cn.lunadeer.essentialsd.tuis.HomeList;
|
||||
import cn.lunadeer.minecraftpluginutils.Notification;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
@ -14,7 +15,7 @@ public class Homes implements TabExecutor {
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if (!EssentialsD.config.getCommandsHome()) {
|
||||
EssentialsD.notification.error(sender, "这个命令已被管理员禁用");
|
||||
Notification.error(sender, "这个命令已被管理员禁用");
|
||||
return false;
|
||||
}
|
||||
HomeList.show(sender, args);
|
||||
|
@ -2,6 +2,7 @@ package cn.lunadeer.essentialsd.commands.home;
|
||||
|
||||
import cn.lunadeer.essentialsd.EssentialsD;
|
||||
import cn.lunadeer.essentialsd.dtos.HomeInfo;
|
||||
import cn.lunadeer.minecraftpluginutils.Notification;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
@ -16,17 +17,17 @@ public class SetHome implements TabExecutor {
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
EssentialsD.notification.warn(sender, "只有玩家可以使用此命令");
|
||||
Notification.warn(sender, "只有玩家可以使用此命令");
|
||||
return true;
|
||||
}
|
||||
if (!EssentialsD.config.getCommandsHome()) {
|
||||
EssentialsD.notification.error(sender, "这个命令已被管理员禁用");
|
||||
Notification.error(sender, "这个命令已被管理员禁用");
|
||||
return false;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
List<HomeInfo> homes = HomeInfo.getHomesOf(((Player) sender).getUniqueId());
|
||||
if (homes.size() > EssentialsD.config.getHomeLimitAmount()) {
|
||||
EssentialsD.notification.error(player, "你的家数量已达上限");
|
||||
Notification.error(player, "你的家数量已达上限");
|
||||
return true;
|
||||
}
|
||||
HomeInfo info = new HomeInfo();
|
||||
@ -39,14 +40,14 @@ public class SetHome implements TabExecutor {
|
||||
info.location = player.getLocation();
|
||||
HomeInfo exist = HomeInfo.getHome(player.getUniqueId(), info.homeName);
|
||||
if (exist != null) {
|
||||
EssentialsD.notification.error(player, "已经存在名为 " + info.homeName + " 的家");
|
||||
Notification.error(player, "已经存在名为 %s 的家", info.homeName);
|
||||
return true;
|
||||
}
|
||||
boolean res = HomeInfo.newHome(info);
|
||||
if (res) {
|
||||
EssentialsD.notification.info(player, "成功设置家 " + info.homeName);
|
||||
Notification.info(player, "成功设置家 %s", info.homeName);
|
||||
} else {
|
||||
EssentialsD.notification.error(player, "设置家 " + info.homeName + " 失败, 请联系管理员");
|
||||
Notification.error(player, "设置家 %s 失败, 请联系管理员", info.homeName);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package cn.lunadeer.essentialsd.events;
|
||||
|
||||
import cn.lunadeer.essentialsd.EssentialsD;
|
||||
import cn.lunadeer.minecraftpluginutils.XLogger;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
@ -97,9 +98,9 @@ public class ChairEvent implements Listener {
|
||||
// Changing the drop material is only necessary for the item merge feature of CB++
|
||||
// The client won't update the material, though.
|
||||
if (!drop.addPassenger(player)) {
|
||||
EssentialsD.logger.debug("Failed to make player " + player.getName() + " sit on a chair.");
|
||||
XLogger.debug("Failed to make player " + player.getName() + " sit on a chair.");
|
||||
} else {
|
||||
EssentialsD.logger.debug("Player " + player.getName() + " is sitting on a chair.");
|
||||
XLogger.debug("Player " + player.getName() + " is sitting on a chair.");
|
||||
}
|
||||
|
||||
// Cancel BlockPlaceEvent Result, if player is rightclicking with a block in his hand.
|
||||
@ -186,7 +187,7 @@ public class ChairEvent implements Listener {
|
||||
armorStand.setGravity(false);
|
||||
armorStand.setInvulnerable(true);
|
||||
armorStand.setSmall(true);
|
||||
EssentialsD.logger.debug("Chair dropped at " + location.toString());
|
||||
XLogger.debug("Chair dropped at " + location.toString());
|
||||
return armorStand;
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@ package cn.lunadeer.essentialsd.events;
|
||||
|
||||
import cn.lunadeer.essentialsd.EssentialsD;
|
||||
import cn.lunadeer.essentialsd.recipes.Crowbar;
|
||||
import cn.lunadeer.minecraftpluginutils.Notification;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.block.Block;
|
||||
@ -46,7 +47,7 @@ public class CrowEvent implements Listener {
|
||||
}
|
||||
Rail rail = (Rail) blockData;
|
||||
if (!Crowbar.changeable(rail.getShape())) {
|
||||
EssentialsD.notification.warn(player, "无法使用撬棍修改此铁轨的方向");
|
||||
Notification.warn(player, "无法使用撬棍修改此铁轨的方向");
|
||||
return;
|
||||
}
|
||||
rail.setShape(Crowbar.changeToNext(rail.getShape()));
|
||||
|
@ -2,6 +2,7 @@ package cn.lunadeer.essentialsd.events;
|
||||
|
||||
import cn.lunadeer.essentialsd.EssentialsD;
|
||||
import cn.lunadeer.essentialsd.commands.ShowItem;
|
||||
import cn.lunadeer.minecraftpluginutils.XLogger;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.event.HoverEvent;
|
||||
@ -29,7 +30,7 @@ public class ShowItemEvent implements Listener {
|
||||
return;
|
||||
}
|
||||
TextComponent hoverEventValue = (TextComponent) hoverEvent.value();
|
||||
EssentialsD.logger.debug("ShowItemEvent: " + hoverEventValue.content());
|
||||
XLogger.debug("ShowItemEvent: " + hoverEventValue.content());
|
||||
if (!ShowItem.cache.containsKey(hoverEventValue.content())) {
|
||||
return;
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
package cn.lunadeer.essentialsd.managers;
|
||||
|
||||
import cn.lunadeer.essentialsd.EssentialsD;
|
||||
import cn.lunadeer.minecraftpluginutils.Scheduler;
|
||||
import cn.lunadeer.minecraftpluginutils.XLogger;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
@ -54,7 +56,7 @@ public class ConfigManager {
|
||||
_home_world_blacklist = _file.getStringList("HomeLimit.WorldBlacklist");
|
||||
_db_type = _file.getString("Database.Type", "sqlite");
|
||||
if (!_db_type.equals("pgsql") && !_db_type.equals("sqlite")) {
|
||||
EssentialsD.logger.err("当前数据库只支持 pgsql 或 sqlite,已重置为 sqlite");
|
||||
XLogger.err("当前数据库只支持 pgsql 或 sqlite,已重置为 sqlite");
|
||||
setDbType("sqlite");
|
||||
}
|
||||
_db_host = _file.getString("Database.Host", "localhost");
|
||||
@ -226,26 +228,26 @@ public class ConfigManager {
|
||||
|
||||
public void ApplyForceLoadChunks() {
|
||||
if (_chunk_operate_delay < 0) {
|
||||
EssentialsD.logger.info("加载区块操作已禁用");
|
||||
XLogger.info("加载区块操作已禁用");
|
||||
return;
|
||||
}
|
||||
EssentialsD.scheduler.runTaskLater(() -> {
|
||||
Scheduler.runTaskLater(() -> {
|
||||
// remove all force loaded chunks
|
||||
int count = 0;
|
||||
for (World world : EssentialsD.instance.getServer().getWorlds()) {
|
||||
EssentialsD.logger.debug("清除所有强加载区块: " + world.getName());
|
||||
XLogger.debug("清除所有强加载区块: " + world.getName());
|
||||
Collection<Chunk> chunks = world.getForceLoadedChunks();
|
||||
for (Chunk chunk : chunks) {
|
||||
count++;
|
||||
world.setChunkForceLoaded(chunk.getX(), chunk.getZ(), false);
|
||||
}
|
||||
}
|
||||
EssentialsD.logger.info("清除所有强加载区块: " + count);
|
||||
XLogger.info("清除所有强加载区块: " + count);
|
||||
// world:0:0
|
||||
for (String s : _force_load_chunks) {
|
||||
String[] split = s.split(":");
|
||||
if (split.length != 3) {
|
||||
EssentialsD.logger.warn("ForceLoadChunks 配置错误: " + s);
|
||||
XLogger.warn("ForceLoadChunks 配置错误: " + s);
|
||||
continue;
|
||||
}
|
||||
String world_name = split[0];
|
||||
@ -253,11 +255,11 @@ public class ConfigManager {
|
||||
int z = Integer.parseInt(split[2]);
|
||||
World world = _plugin.getServer().getWorld(world_name);
|
||||
if (world == null) {
|
||||
EssentialsD.logger.warn("ForceLoadChunks 配置错误: 世界 " + world_name + " 不存在");
|
||||
XLogger.warn("ForceLoadChunks 配置错误: 世界 " + world_name + " 不存在");
|
||||
continue;
|
||||
}
|
||||
world.setChunkForceLoaded(x, z, true);
|
||||
EssentialsD.logger.info("标记强加载区块: " + world_name + " " + x + " " + z);
|
||||
XLogger.info("标记强加载区块: " + world_name + " " + x + " " + z);
|
||||
}
|
||||
}, _chunk_operate_delay * 20);
|
||||
}
|
||||
|
@ -1,6 +1,9 @@
|
||||
package cn.lunadeer.essentialsd.managers;
|
||||
|
||||
import cn.lunadeer.essentialsd.EssentialsD;
|
||||
import cn.lunadeer.minecraftpluginutils.Notification;
|
||||
import cn.lunadeer.minecraftpluginutils.Scheduler;
|
||||
import cn.lunadeer.minecraftpluginutils.XLogger;
|
||||
import cn.lunadeer.minecraftpluginutils.stui.components.Button;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
@ -33,37 +36,39 @@ public class TeleportManager {
|
||||
|
||||
public void request(Player initiator, Player target) {
|
||||
if (initiator == target) {
|
||||
EssentialsD.notification.error(initiator, "不能传送到自己的位置");
|
||||
Notification.error(initiator, "不能传送到自己的位置");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!target.isOnline()) {
|
||||
EssentialsD.notification.error(initiator, "玩家 " + target.getName() + " 不在线");
|
||||
Notification.error(initiator, "玩家 " + target.getName() + " 不在线");
|
||||
return;
|
||||
}
|
||||
|
||||
if (EssentialsD.config.getTpWorldBlackList().contains(target.getWorld().getName())) {
|
||||
EssentialsD.notification.error(initiator, "目的地所在世界 " + initiator.getWorld().getName() + " 不允许传送");
|
||||
Notification.error(initiator, "目的地所在世界 " + initiator.getWorld().getName() + " 不允许传送");
|
||||
return;
|
||||
}
|
||||
|
||||
if (CoolingDown(initiator)) return;
|
||||
|
||||
TpTask task = new TpTask();
|
||||
task.initiator = initiator;
|
||||
task.target = target;
|
||||
task.taskId = UUID.randomUUID();
|
||||
_tasks.put(task.taskId, task);
|
||||
|
||||
EssentialsD.notification.info(initiator, "已向 " + target.getName() + " 发送传送请求");
|
||||
Notification.info(initiator, "已向 " + target.getName() + " 发送传送请求");
|
||||
|
||||
TextComponent acceptBtn = Button.createGreen("接受").setExecuteCommand("/tpa accept " + task.taskId).build();
|
||||
TextComponent denyBtn = Button.createRed("拒绝").setExecuteCommand("/tpa deny " + task.taskId).build();
|
||||
EssentialsD.notification.info(target, Component.text("━━━━━━━━━━━━━━━━━━━━━━━━━━━━", main_color));
|
||||
EssentialsD.notification.info(target, Component.text("| 玩家 " + initiator.getName() + " 请求传送到你的位置", main_color));
|
||||
EssentialsD.notification.info(target, Component.text("| 此请求将在 " + EssentialsD.config.getTpTpaExpire() + " 秒后失效", main_color));
|
||||
EssentialsD.notification.info(target, Component.text("| ", main_color).append(acceptBtn).append(Component.text(" ", main_color)).append(denyBtn));
|
||||
EssentialsD.notification.info(target, Component.text("━━━━━━━━━━━━━━━━━━━━━━━━━━━━", main_color));
|
||||
Notification.info(target, Component.text("━━━━━━━━━━━━━━━━━━━━━━━━━━━━", main_color));
|
||||
Notification.info(target, Component.text("| 玩家 " + initiator.getName() + " 请求传送到你的位置", main_color));
|
||||
Notification.info(target, Component.text("| 此请求将在 " + EssentialsD.config.getTpTpaExpire() + " 秒后失效", main_color));
|
||||
Notification.info(target, Component.text("| ", main_color).append(acceptBtn).append(Component.text(" ", main_color)).append(denyBtn));
|
||||
Notification.info(target, Component.text("━━━━━━━━━━━━━━━━━━━━━━━━━━━━", main_color));
|
||||
|
||||
EssentialsD.scheduler.runTaskLater(() -> {
|
||||
Scheduler.runTaskLater(() -> {
|
||||
_tasks.remove(task.taskId);
|
||||
}, 20L * EssentialsD.config.getTpTpaExpire());
|
||||
}
|
||||
@ -71,30 +76,30 @@ public class TeleportManager {
|
||||
public void deny(Player player, UUID taskId) {
|
||||
TpTask task = _tasks.get(taskId);
|
||||
if (task == null) {
|
||||
EssentialsD.notification.error(player, "传送请求不存在或已过期");
|
||||
Notification.error(player, "传送请求不存在或已过期");
|
||||
return;
|
||||
}
|
||||
if (task.target != player) {
|
||||
EssentialsD.notification.error(player, "这不是你的传送请求");
|
||||
Notification.error(player, "这不是你的传送请求");
|
||||
return;
|
||||
}
|
||||
_tasks.remove(taskId);
|
||||
if (task.initiator.isOnline()) {
|
||||
EssentialsD.notification.error(task.initiator, "玩家 " + player.getName() + " 拒绝了你的传送请求");
|
||||
Notification.error(task.initiator, "玩家 " + player.getName() + " 拒绝了你的传送请求");
|
||||
}
|
||||
if (task.target.isOnline()) {
|
||||
EssentialsD.notification.error(player, "已拒绝 " + task.initiator.getName() + " 的传送请求");
|
||||
Notification.error(player, "已拒绝 " + task.initiator.getName() + " 的传送请求");
|
||||
}
|
||||
}
|
||||
|
||||
public void accept(Player player, UUID taskId) {
|
||||
TpTask task = _tasks.get(taskId);
|
||||
if (task == null) {
|
||||
EssentialsD.notification.error(player, "传送请求不存在或已过期");
|
||||
Notification.error(player, "传送请求不存在或已过期");
|
||||
return;
|
||||
}
|
||||
if (task.target != player) {
|
||||
EssentialsD.notification.error(player, "这不是你的传送请求");
|
||||
Notification.error(player, "这不是你的传送请求");
|
||||
return;
|
||||
}
|
||||
_tasks.remove(taskId);
|
||||
@ -103,63 +108,65 @@ public class TeleportManager {
|
||||
return;
|
||||
}
|
||||
|
||||
EssentialsD.notification.info(task.target, "已接受 " + task.initiator.getName() + " 的传送请求");
|
||||
EssentialsD.notification.info(task.initiator, "玩家 " + task.target.getName() + " 已接受你的传送请求");
|
||||
Notification.info(task.target, "已接受 " + task.initiator.getName() + " 的传送请求");
|
||||
Notification.info(task.initiator, "玩家 " + task.target.getName() + " 已接受你的传送请求");
|
||||
try {
|
||||
doTeleportDelayed(task.initiator, task.target.getLocation(), EssentialsD.config.getTpDelay(), () -> {
|
||||
EssentialsD.notification.info(task.initiator, "正在传送到 " + task.initiator.getName() + " 的位置");
|
||||
Notification.info(task.initiator, "正在传送到 " + task.initiator.getName() + " 的位置");
|
||||
}, () -> {
|
||||
EssentialsD.notification.info(task.initiator, "已传送到 " + task.initiator.getName() + " 的位置");
|
||||
EssentialsD.notification.info(task.target, "玩家 " + task.initiator.getName() + " 已传送到你的位置");
|
||||
Notification.info(task.initiator, "已传送到 " + task.initiator.getName() + " 的位置");
|
||||
Notification.info(task.target, "玩家 " + task.initiator.getName() + " 已传送到你的位置");
|
||||
});
|
||||
} catch (RuntimeException e) {
|
||||
EssentialsD.notification.error(player, e.getMessage());
|
||||
Notification.error(player, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void back(Player player) {
|
||||
if (!_last_tp_location.containsKey(player.getUniqueId())) {
|
||||
EssentialsD.notification.error(player, "没有找到可返回的位置");
|
||||
Notification.error(player, "没有找到可返回的位置");
|
||||
return;
|
||||
}
|
||||
Location target = _last_tp_location.get(player.getUniqueId());
|
||||
if (EssentialsD.config.getTpWorldBlackList().contains(target.getWorld().getName())) {
|
||||
EssentialsD.notification.error(player, "目的地所在世界 " + target.getWorld().getName() + " 不允许传送");
|
||||
Notification.error(player, "目的地所在世界 " + target.getWorld().getName() + " 不允许传送");
|
||||
return;
|
||||
}
|
||||
if (CoolingDown(player)) return;
|
||||
if (EssentialsD.config.getTpDelay() > 0) {
|
||||
EssentialsD.notification.info(player, "将在 " + EssentialsD.config.getTpDelay() + " 秒后返回上次传送的位置");
|
||||
Notification.info(player, "将在 " + EssentialsD.config.getTpDelay() + " 秒后返回上次传送的位置");
|
||||
}
|
||||
try {
|
||||
doTeleportDelayed(player, target, EssentialsD.config.getTpDelay(), () -> {
|
||||
EssentialsD.notification.info(player, "正在返回上次传送的位置");
|
||||
Notification.info(player, "正在返回上次传送的位置");
|
||||
}, () -> {
|
||||
EssentialsD.notification.info(player, "已返回上次传送的位置");
|
||||
Notification.info(player, "已返回上次传送的位置");
|
||||
});
|
||||
} catch (RuntimeException e) {
|
||||
EssentialsD.notification.error(player, e.getMessage());
|
||||
Notification.error(player, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void rtp(Player player) {
|
||||
if (EssentialsD.config.getTpWorldBlackList().contains(player.getWorld().getName())) {
|
||||
EssentialsD.notification.error(player, "此世界 " + player.getWorld().getName() + " 不允许传送");
|
||||
Notification.error(player, "此世界 " + player.getWorld().getName() + " 不允许传送");
|
||||
return;
|
||||
}
|
||||
if (CoolingDown(player)) return;
|
||||
int radius = EssentialsD.config.getTpRtpRadius();
|
||||
World world = player.getWorld();
|
||||
int x = (int) (Math.random() * radius * 2) - radius + (int) player.getLocation().getX();
|
||||
int z = (int) (Math.random() * radius * 2) - radius + (int) player.getLocation().getZ();
|
||||
EssentialsD.logger.debug("RTP: " + x + " " + z);
|
||||
XLogger.debug("RTP: " + x + " " + z);
|
||||
Location location = new Location(world, x + 0.5, player.getY(), z + 0.5);
|
||||
try {
|
||||
doTeleportDelayed(player, location, EssentialsD.config.getTpDelay(), () -> {
|
||||
EssentialsD.notification.info(player, "正在传送到随机位置");
|
||||
Notification.info(player, "正在传送到随机位置");
|
||||
}, () -> {
|
||||
EssentialsD.notification.info(player, "已传送到随机位置");
|
||||
Notification.info(player, "已传送到随机位置");
|
||||
});
|
||||
} catch (RuntimeException e) {
|
||||
EssentialsD.notification.error(player, e.getMessage());
|
||||
Notification.error(player, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@ -167,14 +174,15 @@ public class TeleportManager {
|
||||
doTeleportDelayed(player, location, delay.longValue(), before, after);
|
||||
}
|
||||
|
||||
public void doTeleportDelayed(Player player, Location location, Long delay, Runnable before, Runnable after) throws RuntimeException {
|
||||
public void doTeleportDelayed(Player player, Location location, Long delay, Runnable before, Runnable after) {
|
||||
if (EssentialsD.config.getTpWorldBlackList().contains(location.getWorld().getName())) {
|
||||
EssentialsD.notification.error(player, "目的地所在世界 " + location.getWorld().getName() + " 不允许传送");
|
||||
Notification.error(player, "目的地所在世界 %s 不允许传送", location.getWorld().getName());
|
||||
return;
|
||||
}
|
||||
if (CoolingDown(player)) return;
|
||||
if (delay > 0) {
|
||||
EssentialsD.notification.info(player, "将在 " + EssentialsD.config.getTpDelay() + " 秒后执行传送");
|
||||
EssentialsD.scheduler.runTaskLater(() -> {
|
||||
Notification.info(player, "将在 %d 秒后执行传送", EssentialsD.config.getTpDelay());
|
||||
Scheduler.runTaskLater(() -> {
|
||||
before.run();
|
||||
doTeleportSafely(player, location);
|
||||
after.run();
|
||||
@ -186,21 +194,28 @@ public class TeleportManager {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean CoolingDown(Player player) {
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
LocalDateTime next_time = _next_time_allow_tp.get(player.getUniqueId());
|
||||
if (next_time != null) {
|
||||
if (now.isBefore(next_time)) {
|
||||
long secs_until_next = now.until(next_time, java.time.temporal.ChronoUnit.SECONDS);
|
||||
Notification.warn(player, "请等待 %d 秒后再次传送", secs_until_next);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 把玩家传送到指定位置 并更新上次传送的位置
|
||||
*
|
||||
* @param player 玩家
|
||||
* @param location 位置
|
||||
*/
|
||||
public void doTeleportSafely(Player player, Location location) throws RuntimeException {
|
||||
public void doTeleportSafely(Player player, Location location) {
|
||||
if (CoolingDown(player)) return;
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
LocalDateTime next_time = _next_time_allow_tp.get(player.getUniqueId());
|
||||
if (next_time != null) {
|
||||
if (now.isBefore(next_time)) {
|
||||
long secs_until_next = now.until(next_time, java.time.temporal.ChronoUnit.SECONDS);
|
||||
throw new RuntimeException("请等待 " + secs_until_next + " 秒后再次传送");
|
||||
}
|
||||
}
|
||||
_next_time_allow_tp.put(player.getUniqueId(), now.plusSeconds(EssentialsD.config.getTpCoolDown()));
|
||||
location.getWorld().getChunkAtAsyncUrgently(location).thenAccept((chunk) -> {
|
||||
int max_attempts = 512;
|
||||
@ -208,7 +223,8 @@ public class TeleportManager {
|
||||
location.setY(location.getY() - 1);
|
||||
max_attempts--;
|
||||
if (max_attempts <= 0) {
|
||||
throw new RuntimeException("传送目的地不安全,已取消传送");
|
||||
Notification.error(player, "传送目的地不安全,已取消传送");
|
||||
return;
|
||||
}
|
||||
}
|
||||
Block up1 = location.getBlock().getRelative(BlockFace.UP);
|
||||
@ -220,12 +236,14 @@ public class TeleportManager {
|
||||
up2 = up1.getRelative(BlockFace.UP);
|
||||
max_attempts--;
|
||||
if (max_attempts <= 0) {
|
||||
throw new RuntimeException("传送目的地不安全,已取消传送");
|
||||
Notification.error(player, "传送目的地不安全,已取消传送");
|
||||
return;
|
||||
}
|
||||
}
|
||||
location.setY(location.getY() + 1);
|
||||
if (location.getBlock().getRelative(BlockFace.DOWN).getType() == Material.LAVA) {
|
||||
throw new RuntimeException("传送目的地不安全,已取消传送");
|
||||
Notification.error(player, "传送目的地不安全,已取消传送");
|
||||
return;
|
||||
}
|
||||
updateLastTpLocation(player);
|
||||
player.teleportAsync(location, PlayerTeleportEvent.TeleportCause.PLUGIN);
|
||||
|
@ -2,6 +2,7 @@ package cn.lunadeer.essentialsd.tuis;
|
||||
|
||||
import cn.lunadeer.essentialsd.EssentialsD;
|
||||
import cn.lunadeer.essentialsd.dtos.HomeInfo;
|
||||
import cn.lunadeer.minecraftpluginutils.Notification;
|
||||
import cn.lunadeer.minecraftpluginutils.stui.ListView;
|
||||
import cn.lunadeer.minecraftpluginutils.stui.components.Button;
|
||||
import cn.lunadeer.minecraftpluginutils.stui.components.Line;
|
||||
@ -13,13 +14,13 @@ import java.util.List;
|
||||
public class HomeList {
|
||||
public static void show(CommandSender sender, String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
EssentialsD.notification.warn(sender, "只有玩家可以使用此命令");
|
||||
Notification.warn(sender, "只有玩家可以使用此命令");
|
||||
return;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
List<HomeInfo> homes = HomeInfo.getHomesOf(((Player) sender).getUniqueId());
|
||||
if (homes.size() == 0) {
|
||||
EssentialsD.notification.warn(player, "你还没有设置家");
|
||||
Notification.warn(player, "你还没有设置家");
|
||||
return;
|
||||
}
|
||||
int page = 1;
|
||||
|
Loading…
Reference in New Issue
Block a user