升级工具库版本

This commit is contained in:
zhangyuheng 2024-06-18 10:37:05 +08:00
parent c1df7a44c2
commit 118a4e72d0
14 changed files with 103 additions and 105 deletions

View File

@ -26,6 +26,7 @@
- 本插件使用 **TUI** 作为简易的交互方式,非 PlayerTitle 的箱子UI
- 支持设置称号**限量销售、限时销售**
- 支持玩家使用称号币自定义称号
- 支持外部经济系统(需要 Vault 前置支持)
## 支持版本

View File

@ -1,5 +1,6 @@
package cn.lunadeer.miniplayertitle;
import cn.lunadeer.minecraftpluginutils.XLogger;
import net.kyori.adventure.text.format.Style;
import net.kyori.adventure.text.format.TextColor;
@ -27,7 +28,7 @@ public class Color {
this.g = 0;
this.b = 0;
this.hex = "#000000";
MiniPlayerTitle.logger.err("Invalid color: " + r + ", " + g + ", " + b);
XLogger.err("Invalid color: " + r + ", " + g + ", " + b);
}
}
@ -42,7 +43,7 @@ public class Color {
this.g = 0;
this.b = 0;
this.hex = "#000000";
MiniPlayerTitle.logger.err("Invalid color: " + hex);
XLogger.err("Invalid color: " + hex);
}
}

View File

@ -1,5 +1,6 @@
package cn.lunadeer.miniplayertitle;
import cn.lunadeer.minecraftpluginutils.Notification;
import cn.lunadeer.miniplayertitle.dtos.PlayerInfoDTO;
import cn.lunadeer.miniplayertitle.dtos.PlayerTitleDTO;
import io.papermc.paper.event.player.AsyncChatEvent;
@ -18,7 +19,7 @@ public class Events implements Listener {
Player bukkitPlayer = event.getPlayer();
PlayerInfoDTO player = PlayerInfoDTO.get(bukkitPlayer);
if (player == null) {
MiniPlayerTitle.notification.error(bukkitPlayer, "获取玩家信息时出现错误,请联系管理员");
Notification.error(bukkitPlayer, "获取玩家信息时出现错误,请联系管理员");
return;
}
if (player.getUsingTitle().getId() == -1) {
@ -27,7 +28,7 @@ public class Events implements Listener {
}
PlayerTitleDTO title = PlayerTitleDTO.get(bukkitPlayer.getUniqueId(), player.getUsingTitle().getId());
if (title == null || title.isExpired()) {
MiniPlayerTitle.notification.warn(bukkitPlayer, "你当前使用的称号 %s 已过期", player.getUsingTitle().getTitlePlainText());
Notification.warn(bukkitPlayer, "你当前使用的称号 %s 已过期", player.getUsingTitle().getTitlePlainText());
player.setUsingTitle(null);
updateName(bukkitPlayer, null);
} else {

View File

@ -15,10 +15,10 @@ public final class MiniPlayerTitle extends JavaPlugin {
// Plugin startup logic
instance = this;
new Scheduler(this);
notification = new Notification(this);
logger = new XLogger(instance);
config = new ConfigManager(instance);
logger.setDebug(config.isDebug());
new Notification(this);
new XLogger(instance);
new ConfigManager(instance);
XLogger.setDebug(config.isDebug());
database = new DatabaseManager(this,
DatabaseManager.TYPE.valueOf(config.getDbType().toUpperCase()),
config.getDbHost(),
@ -29,7 +29,7 @@ public final class MiniPlayerTitle extends JavaPlugin {
DatabaseTables.migrate();
if (config.isExternalEco()) {
logger.info("已启用外部经济插件");
XLogger.info("已启用外部经济插件");
new VaultConnect(this);
}
@ -45,17 +45,17 @@ public final class MiniPlayerTitle extends JavaPlugin {
"MiniPlayerTitle");
}
logger.info("称号插件已加载");
logger.info("版本: " + getPluginMeta().getVersion());
XLogger.info("称号插件已加载");
XLogger.info("版本: " + getPluginMeta().getVersion());
// http://patorjk.com/software/taag/#p=display&f=Big&t=MiniPlayerTitle
logger.info(" __ __ _ _ _____ _ _______ _ _ _");
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(" __/ |");
XLogger.info(" |___/");
}
@Override
@ -66,7 +66,5 @@ public final class MiniPlayerTitle extends JavaPlugin {
public static MiniPlayerTitle instance;
public static ConfigManager config;
public static DatabaseManager database;
public static XLogger logger;
public static Notification notification;
private GiteaReleaseCheck giteaReleaseCheck;
}

View File

@ -1,6 +1,6 @@
package cn.lunadeer.miniplayertitle.commands;
import cn.lunadeer.miniplayertitle.MiniPlayerTitle;
import cn.lunadeer.minecraftpluginutils.Notification;
import cn.lunadeer.miniplayertitle.dtos.TitleDTO;
import net.kyori.adventure.text.Component;
import org.bukkit.command.CommandSender;
@ -13,7 +13,7 @@ public class Apis {
if (sender instanceof Player) {
Player player = (Player) sender;
if (!player.isOp()) {
MiniPlayerTitle.notification.warn(player, "你没有权限使用此命令");
Notification.warn(player, "你没有权限使用此命令");
return true;
}
}

View File

@ -1,6 +1,6 @@
package cn.lunadeer.miniplayertitle.commands;
import cn.lunadeer.miniplayertitle.MiniPlayerTitle;
import cn.lunadeer.minecraftpluginutils.Notification;
import cn.lunadeer.miniplayertitle.dtos.PlayerInfoDTO;
import org.bukkit.command.CommandSender;
@ -20,17 +20,17 @@ public class PlayerManage {
try {
PlayerInfoDTO playerInfo = PlayerInfoDTO.get(args[1]);
if (playerInfo == null) {
MiniPlayerTitle.notification.error(sender, "玩家不存在");
Notification.error(sender, "玩家不存在");
return;
}
if (playerInfo.addCoin(Integer.parseInt(args[2]))) {
MiniPlayerTitle.notification.info(sender, "成功给玩家 %s 添加 %s 称号币", playerInfo.getLastUseName(), args[2]);
MiniPlayerTitle.notification.info(sender, "玩家 %s 当前余额 %f 称号币", playerInfo.getLastUseName(), playerInfo.getCoin());
Notification.info(sender, "成功给玩家 %s 添加 %s 称号币", playerInfo.getLastUseName(), args[2]);
Notification.info(sender, "玩家 %s 当前余额 %f 称号币", playerInfo.getLastUseName(), playerInfo.getCoin());
} else {
MiniPlayerTitle.notification.error(sender, "给玩家添加称号币失败,详细错误请查看控制台日志");
Notification.error(sender, "给玩家添加称号币失败,详细错误请查看控制台日志");
}
} catch (Exception e) {
MiniPlayerTitle.notification.error(sender, "给玩家添加称号币时出错:%s", e.getMessage());
Notification.error(sender, "给玩家添加称号币时出错:%s", e.getMessage());
}
}
@ -46,17 +46,17 @@ public class PlayerManage {
try {
PlayerInfoDTO playerInfo = PlayerInfoDTO.get(args[1]);
if (playerInfo == null) {
MiniPlayerTitle.notification.error(sender, "玩家不存在");
Notification.error(sender, "玩家不存在");
return;
}
if (playerInfo.setCoin(Integer.parseInt(args[2]))) {
MiniPlayerTitle.notification.info(sender, "成功给玩家 %s 设置 %s 称号币", playerInfo.getLastUseName(), args[2]);
MiniPlayerTitle.notification.info(sender, "玩家 %s 当前余额 %f 称号币", playerInfo.getLastUseName(), playerInfo.getCoin());
Notification.info(sender, "成功给玩家 %s 设置 %s 称号币", playerInfo.getLastUseName(), args[2]);
Notification.info(sender, "玩家 %s 当前余额 %f 称号币", playerInfo.getLastUseName(), playerInfo.getCoin());
} else {
MiniPlayerTitle.notification.error(sender, "给玩家设置称号币失败,详细错误请查看控制台日志");
Notification.error(sender, "给玩家设置称号币失败,详细错误请查看控制台日志");
}
} catch (Exception e) {
MiniPlayerTitle.notification.error(sender, "给玩家设置称号币时出错:%s", e.getMessage());
Notification.error(sender, "给玩家设置称号币时出错:%s", e.getMessage());
}
}
}

View File

@ -1,5 +1,6 @@
package cn.lunadeer.miniplayertitle.commands;
import cn.lunadeer.minecraftpluginutils.Notification;
import cn.lunadeer.miniplayertitle.MiniPlayerTitle;
import cn.lunadeer.miniplayertitle.dtos.PlayerInfoDTO;
import cn.lunadeer.miniplayertitle.dtos.PlayerTitleDTO;
@ -10,8 +11,6 @@ import net.kyori.adventure.text.Component;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.time.LocalDateTime;
import static cn.lunadeer.miniplayertitle.commands.Apis.notOpOrConsole;
import static cn.lunadeer.miniplayertitle.commands.Apis.updateName;
@ -26,15 +25,15 @@ public class TitleManage {
public static void createTitle(CommandSender sender, String[] args) {
if (notOpOrConsole(sender)) return;
if (args.length < 2) {
MiniPlayerTitle.notification.warn(sender, "用法: /mplt create_title <称号名称> [称号描述]");
Notification.warn(sender, "用法: /mplt create_title <称号名称> [称号描述]");
return;
}
TitleDTO title = TitleDTO.create(args[1], args.length == 3 ? args[2] : "这是一个管理员创建的称号");
if (title != null) {
MiniPlayerTitle.notification.info(sender, Component.text("成功创建称号: [" + title.getId() + "]").append(title.getTitleColored()));
Notification.info(sender, Component.text("成功创建称号: [" + title.getId() + "]").append(title.getTitleColored()));
AllTitles.show(sender, new String[]{"all_titles"});
} else {
MiniPlayerTitle.notification.error(sender, "创建称号失败,具体请查看控制台日志");
Notification.error(sender, "创建称号失败,具体请查看控制台日志");
}
}
@ -49,26 +48,26 @@ public class TitleManage {
try {
if (notOpOrConsole(sender)) return;
if (args.length < 2) {
MiniPlayerTitle.notification.warn(sender, "用法: /mplt delete_title <称号ID>");
Notification.warn(sender, "用法: /mplt delete_title <称号ID>");
return;
}
TitleDTO title = TitleDTO.get(Integer.parseInt(args[1]));
if (title == null) {
MiniPlayerTitle.notification.error(sender, "称号不存在");
Notification.error(sender, "称号不存在");
return;
}
boolean success = title.delete();
if (!success) {
MiniPlayerTitle.notification.error(sender, "删除称号失败,具体请查看控制台日志");
Notification.error(sender, "删除称号失败,具体请查看控制台日志");
return;
}
MiniPlayerTitle.notification.info(sender, "已删除称号");
Notification.info(sender, "已删除称号");
if (args.length == 3) {
int page = Integer.parseInt(args[2]);
AllTitles.show(sender, new String[]{"all_titles", String.valueOf(page)});
}
} catch (Exception e) {
MiniPlayerTitle.notification.error(sender, e.getMessage());
Notification.error(sender, e.getMessage());
}
}
@ -83,22 +82,22 @@ public class TitleManage {
try {
if (notOpOrConsole(sender)) return;
if (args.length != 3) {
MiniPlayerTitle.notification.warn(sender, "用法: /mplt set_title <称号ID> <称号名称>");
Notification.warn(sender, "用法: /mplt set_title <称号ID> <称号名称>");
return;
}
TitleDTO title = TitleDTO.get(Integer.parseInt(args[1]));
if (title == null) {
MiniPlayerTitle.notification.error(sender, "称号不存在");
Notification.error(sender, "称号不存在");
return;
}
boolean success = title.updateTitle(args[2]);
if (success) {
MiniPlayerTitle.notification.info(sender, "已更新称号名称");
Notification.info(sender, "已更新称号名称");
} else {
MiniPlayerTitle.notification.error(sender, "更新称号名称失败,具体请查看控制台日志");
Notification.error(sender, "更新称号名称失败,具体请查看控制台日志");
}
} catch (Exception e) {
MiniPlayerTitle.notification.error(sender, e.getMessage());
Notification.error(sender, e.getMessage());
}
}
@ -113,22 +112,22 @@ public class TitleManage {
try {
if (notOpOrConsole(sender)) return;
if (args.length != 3) {
MiniPlayerTitle.notification.warn(sender, "用法: /mplt set_desc <称号ID> <称号描述>");
Notification.warn(sender, "用法: /mplt set_desc <称号ID> <称号描述>");
return;
}
TitleDTO title = TitleDTO.get(Integer.parseInt(args[1]));
if (title == null) {
MiniPlayerTitle.notification.error(sender, "称号不存在");
Notification.error(sender, "称号不存在");
return;
}
boolean success = title.updateDescription(args[2]);
if (success) {
MiniPlayerTitle.notification.info(sender, "已更新称号描述");
Notification.info(sender, "已更新称号描述");
} else {
MiniPlayerTitle.notification.error(sender, "更新称号描述失败,具体请查看控制台日志");
Notification.error(sender, "更新称号描述失败,具体请查看控制台日志");
}
} catch (Exception e) {
MiniPlayerTitle.notification.error(sender, e.getMessage());
Notification.error(sender, e.getMessage());
}
}
@ -141,30 +140,30 @@ public class TitleManage {
*/
public static void useTitle(CommandSender sender, String[] args) {
if (!(sender instanceof Player)) {
MiniPlayerTitle.notification.error(sender, "该命令只能由玩家执行");
Notification.error(sender, "该命令只能由玩家执行");
return;
}
if (args.length < 2) {
MiniPlayerTitle.notification.warn(sender, "用法: /mplt use_title <背包ID> [页码]");
Notification.warn(sender, "用法: /mplt use_title <背包ID> [页码]");
return;
}
Player player = (Player) sender;
PlayerTitleDTO title = PlayerTitleDTO.get(Integer.parseInt(args[1]));
if (title == null) {
MiniPlayerTitle.notification.error(sender, "称号不存在");
Notification.error(sender, "称号不存在");
return;
}
if (!title.getPlayerUuid().equals(player.getUniqueId())) {
MiniPlayerTitle.notification.error(sender, "该称号不属于你");
Notification.error(sender, "该称号不属于你");
return;
}
PlayerInfoDTO playerInfo = PlayerInfoDTO.get((player).getUniqueId());
if (playerInfo == null) {
MiniPlayerTitle.notification.error(sender, "获取玩家信息时出现错误");
Notification.error(sender, "获取玩家信息时出现错误");
return;
}
if (title.isExpired()) {
MiniPlayerTitle.notification.error(sender, "称号 %s 已过期", title.getTitle().getTitlePlainText());
Notification.error(sender, "称号 %s 已过期", title.getTitle().getTitlePlainText());
playerInfo.setUsingTitle(null);
updateName(player, null);
return;
@ -172,9 +171,9 @@ public class TitleManage {
boolean success = playerInfo.setUsingTitle(title.getTitle());
if (success) {
updateName((Player) sender, title.getTitle());
MiniPlayerTitle.notification.info(sender, "已使用称号");
Notification.info(sender, "已使用称号");
} else {
MiniPlayerTitle.notification.error(sender, "使用称号失败,具体请查看控制台日志");
Notification.error(sender, "使用称号失败,具体请查看控制台日志");
}
if (args.length == 3) {
@ -192,45 +191,45 @@ public class TitleManage {
*/
public static void customTitle(CommandSender sender, String[] args) {
if (!(sender instanceof Player)) {
MiniPlayerTitle.notification.error(sender, "该命令只能由玩家执行");
Notification.error(sender, "该命令只能由玩家执行");
return;
}
Player player = (Player) sender;
if (!MiniPlayerTitle.config.isEnableCustom()) {
MiniPlayerTitle.notification.error(sender, "自定义称号功能已关闭");
Notification.error(sender, "自定义称号功能已关闭");
return;
}
PlayerInfoDTO playerInfo = PlayerInfoDTO.get(player.getUniqueId());
if (playerInfo == null) {
MiniPlayerTitle.notification.error(sender, "获取玩家信息时出现错误");
Notification.error(sender, "获取玩家信息时出现错误");
return;
}
if (MiniPlayerTitle.config.getCustomCost() > playerInfo.getCoin()) {
MiniPlayerTitle.notification.error(sender, "称号币不足");
Notification.error(sender, "称号币不足");
return;
}
if (args.length < 2) {
MiniPlayerTitle.notification.warn(sender, "用法: /mplt custom_title <称号>");
Notification.warn(sender, "用法: /mplt custom_title <称号>");
return;
}
TitleDTO title = TitleDTO.create(args[1], player.getName() + "的自定义称号");
if (title == null) {
MiniPlayerTitle.notification.error(sender, "创建称号失败,具体请查看控制台日志");
Notification.error(sender, "创建称号失败,具体请查看控制台日志");
return;
}
if (title.getTitlePlainText().length() > MiniPlayerTitle.config.getMaxLength()) {
MiniPlayerTitle.notification.error(sender, "称号长度超过限制");
Notification.error(sender, "称号长度超过限制");
title.delete();
return;
}
PlayerTitleDTO created_rec = PlayerTitleDTO.create(player.getUniqueId(), title, null);
if (created_rec == null) {
MiniPlayerTitle.notification.error(sender, "创建称号记录失败,具体请查看控制台日志");
Notification.error(sender, "创建称号记录失败,具体请查看控制台日志");
title.delete();
return;
}
playerInfo.setCoin(playerInfo.getCoin() - MiniPlayerTitle.config.getCustomCost());
MiniPlayerTitle.notification.info(sender, "成功创建自定义称号");
Notification.info(sender, "成功创建自定义称号");
MyTitles.show(sender, new String[]{"my_titles"});
}
}

View File

@ -1,6 +1,6 @@
package cn.lunadeer.miniplayertitle.commands;
import cn.lunadeer.miniplayertitle.MiniPlayerTitle;
import cn.lunadeer.minecraftpluginutils.Notification;
import cn.lunadeer.miniplayertitle.dtos.PlayerInfoDTO;
import cn.lunadeer.miniplayertitle.dtos.PlayerTitleDTO;
import cn.lunadeer.miniplayertitle.dtos.TitleDTO;
@ -33,7 +33,7 @@ public class TitleShopSale {
if (notOpOrConsole(sender)) return;
TitleShopDTO titleShop = TitleShopDTO.get(Integer.valueOf(args[2]));
if (titleShop == null) {
MiniPlayerTitle.notification.error(sender, "获取详情时出现错误,详情请查看控制台日志");
Notification.error(sender, "获取详情时出现错误,详情请查看控制台日志");
return;
}
boolean success;
@ -63,11 +63,11 @@ public class TitleShopSale {
success = titleShop.setSaleEndAt(titleShop.getSaleEndAt().minusDays(days2));
break;
default:
MiniPlayerTitle.notification.warn(sender, "用法: /mplt set_sale <price|days|amount|end_at|end_at_y|end_at_m|end_at_d> <商品ID> <值> [页数]");
Notification.warn(sender, "用法: /mplt set_sale <price|days|amount|end_at|end_at_y|end_at_m|end_at_d> <商品ID> <值> [页数]");
return;
}
if (!success) {
MiniPlayerTitle.notification.error(sender, "设置商品信息时出现错误,详情请查看控制台日志");
Notification.error(sender, "设置商品信息时出现错误,详情请查看控制台日志");
}
if (args.length == 5) {
int page = getLastArgsPage(args);
@ -86,15 +86,15 @@ public class TitleShopSale {
if (notOpOrConsole(sender)) return;
TitleDTO title = TitleDTO.get(Integer.parseInt(args[1]));
if (title == null) {
MiniPlayerTitle.notification.error(sender, "获取称号详情时出现错误,详情请查看控制台日志");
Notification.error(sender, "获取称号详情时出现错误,详情请查看控制台日志");
return;
}
TitleShopDTO sale = TitleShopDTO.create(title);
if (sale == null) {
MiniPlayerTitle.notification.error(sender, "创建商品时出现错误,详情请查看控制台日志");
Notification.error(sender, "创建商品时出现错误,详情请查看控制台日志");
return;
}
MiniPlayerTitle.notification.info(sender, "已创建称号商品");
Notification.info(sender, "已创建称号商品");
if (sender instanceof Player) {
SaleInfo.show(sender, new String[]{"sale_info", String.valueOf(sale.getId())});
}
@ -111,14 +111,14 @@ public class TitleShopSale {
if (notOpOrConsole(sender)) return;
TitleShopDTO titleShop = TitleShopDTO.get(Integer.valueOf(args[1]));
if (titleShop == null) {
MiniPlayerTitle.notification.error(sender, "获取详情时出现错误");
Notification.error(sender, "获取详情时出现错误");
return;
}
boolean success = titleShop.delete();
if (success) {
MiniPlayerTitle.notification.info(sender, "已删除商品");
Notification.info(sender, "已删除商品");
} else {
MiniPlayerTitle.notification.error(sender, "删除商品时出现错误,详情请查看控制台日志");
Notification.error(sender, "删除商品时出现错误,详情请查看控制台日志");
}
if (args.length == 3) {
@ -135,31 +135,31 @@ public class TitleShopSale {
*/
public static void buySale(CommandSender sender, String[] args) {
if (!(sender instanceof Player)) {
MiniPlayerTitle.notification.error(sender, "该命令只能由玩家执行");
Notification.error(sender, "该命令只能由玩家执行");
return;
}
Player player = (Player) sender;
PlayerInfoDTO playerInfo = PlayerInfoDTO.get(player.getUniqueId());
if (playerInfo == null) {
MiniPlayerTitle.notification.error(player, "获取玩家信息时出现错误,详情请查看控制台日志");
Notification.error(player, "获取玩家信息时出现错误,详情请查看控制台日志");
return;
}
TitleShopDTO titleShop = TitleShopDTO.get(Integer.valueOf(args[1]));
if (titleShop == null) {
MiniPlayerTitle.notification.error(player, "获取详情时出现错误,详情请查看控制台日志");
Notification.error(player, "获取详情时出现错误,详情请查看控制台日志");
return;
}
if (titleShop.isExpired() || titleShop.getDays() == 0) {
MiniPlayerTitle.notification.error(player, "此称号已停止销售");
Notification.error(player, "此称号已停止销售");
return;
}
if (titleShop.getAmount() != -1 && titleShop.getAmount() <= 0) {
MiniPlayerTitle.notification.error(player, "此称号已售罄");
Notification.error(player, "此称号已售罄");
return;
}
if (titleShop.getPrice() > playerInfo.getCoin()) {
MiniPlayerTitle.notification.error(player, "你的余额不足");
Notification.error(player, "你的余额不足");
return;
}
@ -175,19 +175,19 @@ public class TitleShopSale {
if (had == null) {
had = PlayerTitleDTO.create(player.getUniqueId(), titleShop.getTitle(), titleShop.getDays() == -1 ? null : LocalDateTime.now().plusDays(titleShop.getDays()));
if (had == null) {
MiniPlayerTitle.notification.error(player, "购买称号时出现错误,详情请查看控制台日志");
Notification.error(player, "购买称号时出现错误,详情请查看控制台日志");
return;
}
titleShop.setAmount(titleShop.getAmount() - 1);
playerInfo.setCoin(playerInfo.getCoin() - titleShop.getPrice());
MiniPlayerTitle.notification.info(player, Component.text("成功购买称号: ").append(had.getTitle().getTitleColored()));
Notification.info(player, Component.text("成功购买称号: ").append(had.getTitle().getTitleColored()));
} else if (!had.isExpired()) {
MiniPlayerTitle.notification.warn(player, "你已拥有此称号,在过期前无法再次购买");
Notification.warn(player, "你已拥有此称号,在过期前无法再次购买");
} else {
had.setExpireAt(titleShop.getDays() == -1 ? null : LocalDateTime.now().plusDays(titleShop.getDays()));
titleShop.setAmount(titleShop.getAmount() - 1);
playerInfo.setCoin(playerInfo.getCoin() - titleShop.getPrice());
MiniPlayerTitle.notification.info(player, Component.text("成功续续期称号: ").append(had.getTitle().getTitleColored()));
Notification.info(player, Component.text("成功续续期称号: ").append(had.getTitle().getTitleColored()));
}
int page = getArgPage(args, 3);

View File

@ -1,6 +1,7 @@
package cn.lunadeer.miniplayertitle.dtos;
import cn.lunadeer.minecraftpluginutils.VaultConnect;
import cn.lunadeer.minecraftpluginutils.XLogger;
import cn.lunadeer.miniplayertitle.MiniPlayerTitle;
import org.bukkit.entity.Player;
@ -34,13 +35,13 @@ public class PlayerInfoDTO {
if (info == null) {
info = create(player);
if (info == null) {
MiniPlayerTitle.logger.err("创建玩家信息时失败");
XLogger.err("创建玩家信息时失败");
return null;
}
} else {
info = updateName(player);
if (info == null) {
MiniPlayerTitle.logger.err("更新玩家名称时失败");
XLogger.err("更新玩家名称时失败");
return null;
}
}

View File

@ -1,13 +1,13 @@
package cn.lunadeer.miniplayertitle.tuis;
import cn.lunadeer.miniplayertitle.MiniPlayerTitle;
import cn.lunadeer.minecraftpluginutils.Notification;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class Apis {
public static Player playerOnly(CommandSender sender) {
if (!(sender instanceof Player)) {
MiniPlayerTitle.notification.error(sender, "该命令只能由玩家执行");
Notification.error(sender, "该命令只能由玩家执行");
return null;
}
return (Player) sender;

View File

@ -1,5 +1,6 @@
package cn.lunadeer.miniplayertitle.tuis;
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;
@ -20,7 +21,7 @@ public class Menu {
PlayerInfoDTO playerInfo = PlayerInfoDTO.get(player.getUniqueId());
if (playerInfo == null) {
MiniPlayerTitle.notification.error(player, "获取玩家信息时出现错误");
Notification.error(player, "获取玩家信息时出现错误");
return;
}
Line balance = Line.create()

View File

@ -1,9 +1,9 @@
package cn.lunadeer.miniplayertitle.tuis;
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;
import cn.lunadeer.miniplayertitle.MiniPlayerTitle;
import cn.lunadeer.miniplayertitle.dtos.PlayerInfoDTO;
import cn.lunadeer.miniplayertitle.dtos.PlayerTitleDTO;
import org.bukkit.command.CommandSender;
@ -24,7 +24,7 @@ public class MyTitles {
PlayerInfoDTO playerInfo = PlayerInfoDTO.get(player.getUniqueId());
if (playerInfo == null) {
MiniPlayerTitle.notification.error(player, "获取玩家信息时出现错误,详情请查看控制台日志");
Notification.error(player, "获取玩家信息时出现错误,详情请查看控制台日志");
return;
}
List<PlayerTitleDTO> titles = PlayerTitleDTO.getAllOf(player.getUniqueId());

View File

@ -1,10 +1,10 @@
package cn.lunadeer.miniplayertitle.tuis;
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;
import cn.lunadeer.minecraftpluginutils.stui.components.NumChanger;
import cn.lunadeer.miniplayertitle.MiniPlayerTitle;
import cn.lunadeer.miniplayertitle.dtos.TitleDTO;
import cn.lunadeer.miniplayertitle.dtos.TitleShopDTO;
import net.kyori.adventure.text.Component;
@ -23,12 +23,12 @@ public class SaleInfo {
int page = getArgPage(args, 3);
TitleShopDTO titleShop = TitleShopDTO.get(Integer.valueOf(args[1]));
if (titleShop == null) {
MiniPlayerTitle.notification.error(player, "获取详情时出现错误");
Notification.error(player, "获取详情时出现错误");
return;
}
TitleDTO title = titleShop.getTitle();
if (title == null) {
MiniPlayerTitle.notification.error(player, "获取详情时出现错误");
Notification.error(player, "获取详情时出现错误");
return;
}
int now_year = LocalDateTime.now().getYear();

View File

@ -16,10 +16,6 @@ public class ConfigManager {
_file = _plugin.getConfig();
_debug = _file.getBoolean("Debug", false);
_db_type = _file.getString("Database.Type", "sqlite");
if (!_db_type.equals("pgsql") && !_db_type.equals("sqlite")) {
MiniPlayerTitle.logger.err("当前数据库只支持 pgsql 或 sqlite已重置为 sqlite");
setDbType("sqlite");
}
_db_host = _file.getString("Database.Host", "localhost");
_db_port = _file.getString("Database.Port", "5432");
_db_name = _file.getString("Database.Name", "miniplayertitle");