Compare commits
14 Commits
Author | SHA1 | Date | |
---|---|---|---|
40e561bff1 | |||
11856a29a6 | |||
78de7dca65 | |||
466dd84fac | |||
283e435b70 | |||
2981ac0183 | |||
02d44610c6 | |||
31a1d409b7 | |||
9de1b5cced | |||
d629b1daf7 | |||
b52fce2479 | |||
3ffab50c9b | |||
a007966d70 | |||
ddf5ae711a |
@ -1,4 +1,4 @@
|
||||
<div style="text-align: center;">
|
||||
<div align="center">
|
||||
|
||||
<img src="https://ssl.lunadeer.cn:14437/i/2024/03/28/6604de7db2e6f.png" alt="" width="70%">
|
||||
|
||||
|
4
pom.xml
4
pom.xml
@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>cn.lunadeer</groupId>
|
||||
<artifactId>MiniPlayerTitle</artifactId>
|
||||
<version>4.2.5</version>
|
||||
<version>4.7.1</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>MiniPlayerTitle</name>
|
||||
@ -82,7 +82,7 @@
|
||||
<dependency>
|
||||
<groupId>cn.lunadeer</groupId>
|
||||
<artifactId>MinecraftPluginUtils</artifactId>
|
||||
<version>1.3.2-SNAPSHOT</version>
|
||||
<version>1.3.7-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>me.clip</groupId>
|
||||
|
@ -1,6 +1,7 @@
|
||||
package cn.lunadeer.miniplayertitle;
|
||||
|
||||
import cn.lunadeer.miniplayertitle.commands.PlayerManage;
|
||||
import cn.lunadeer.miniplayertitle.commands.TitleCard;
|
||||
import cn.lunadeer.miniplayertitle.commands.TitleManage;
|
||||
import cn.lunadeer.miniplayertitle.commands.TitleShopSale;
|
||||
import cn.lunadeer.miniplayertitle.dtos.PlayerInfoDTO;
|
||||
@ -81,6 +82,9 @@ public class Commands implements TabExecutor {
|
||||
case "grant_title": // mplt grant_title <玩家名称> <称号> <描述> [天数]
|
||||
PlayerManage.grantTitle(sender, args);
|
||||
break;
|
||||
case "get_card": // mplt get_card <商品ID>
|
||||
TitleCard.getTitleCard(sender, args);
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
@ -93,7 +97,7 @@ public class Commands implements TabExecutor {
|
||||
return Arrays.asList("menu", "all_titles", "my_titles", "shop", "custom_info", "sale_info",
|
||||
"create_sale", "set_sale", "delete_sale", "buy_sale", "use_title", "create_title",
|
||||
"delete_title", "edit_title_name", "edit_title_desc", "custom_title", "add_coin", "set_coin",
|
||||
"grant_title"
|
||||
"grant_title", "get_card"
|
||||
);
|
||||
}
|
||||
if (args.length == 2) {
|
||||
@ -101,6 +105,7 @@ public class Commands implements TabExecutor {
|
||||
case "sale_info":
|
||||
case "delete_sale":
|
||||
case "buy_sale":
|
||||
case "get_card":
|
||||
return Collections.singletonList("<商品ID>");
|
||||
case "create_sale":
|
||||
case "delete_title":
|
||||
|
@ -1,8 +1,6 @@
|
||||
package cn.lunadeer.miniplayertitle;
|
||||
|
||||
import cn.lunadeer.minecraftpluginutils.XLogger;
|
||||
import cn.lunadeer.miniplayertitle.dtos.PlayerInfoDTO;
|
||||
import cn.lunadeer.miniplayertitle.dtos.PlayerTitleDTO;
|
||||
import cn.lunadeer.miniplayertitle.dtos.TitleDTO;
|
||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -32,20 +30,11 @@ public class Expansion extends PlaceholderExpansion {
|
||||
@Override
|
||||
public String onPlaceholderRequest(Player bukkitPlayer, @NotNull String params) {
|
||||
if (params.equalsIgnoreCase("player_title")) {
|
||||
PlayerInfoDTO player = PlayerInfoDTO.get(bukkitPlayer);
|
||||
if (player == null) {
|
||||
TitleDTO t = MiniPlayerTitle.instance.getPlayerUsingTitle(bukkitPlayer.getUniqueId());
|
||||
if (t == null) {
|
||||
return "";
|
||||
}
|
||||
if (player.getUsingTitle().getId() == -1) {
|
||||
return "";
|
||||
}
|
||||
PlayerTitleDTO title = PlayerTitleDTO.get(bukkitPlayer.getUniqueId(), player.getUsingTitle().getId());
|
||||
if (title == null || title.isExpired()) {
|
||||
player.setUsingTitle(null);
|
||||
return "";
|
||||
}
|
||||
TitleDTO t = title.getTitle();
|
||||
return ChatColor.translateAlternateColorCodes('&', t.getTitleColoredBukkit());
|
||||
return t.getTitleColoredBukkit();
|
||||
}
|
||||
|
||||
return null; //
|
||||
@ -63,6 +52,6 @@ public class Expansion extends PlaceholderExpansion {
|
||||
|
||||
@Override
|
||||
public @NotNull String getVersion() {
|
||||
return plugin.getPluginMeta().getVersion();
|
||||
return MiniPlayerTitle.instance.getDescription().getVersion();
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,23 @@
|
||||
package cn.lunadeer.miniplayertitle;
|
||||
|
||||
import cn.lunadeer.minecraftpluginutils.*;
|
||||
import cn.lunadeer.minecraftpluginutils.VaultConnect.VaultConnect;
|
||||
import cn.lunadeer.minecraftpluginutils.databse.DatabaseManager;
|
||||
import cn.lunadeer.minecraftpluginutils.databse.DatabaseType;
|
||||
import cn.lunadeer.miniplayertitle.commands.TitleCard;
|
||||
import cn.lunadeer.miniplayertitle.dtos.TitleDTO;
|
||||
import cn.lunadeer.miniplayertitle.events.Events;
|
||||
import cn.lunadeer.miniplayertitle.events.PaperChat;
|
||||
import cn.lunadeer.miniplayertitle.events.SpigotChat;
|
||||
import cn.lunadeer.miniplayertitle.utils.ConfigManager;
|
||||
import cn.lunadeer.miniplayertitle.utils.DatabaseTables;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
public final class MiniPlayerTitle extends JavaPlugin {
|
||||
|
||||
@ -19,8 +30,8 @@ public final class MiniPlayerTitle extends JavaPlugin {
|
||||
new XLogger(instance);
|
||||
config = new ConfigManager(instance);
|
||||
XLogger.setDebug(config.isDebug());
|
||||
database = new DatabaseManager(this,
|
||||
DatabaseManager.TYPE.valueOf(config.getDbType().toUpperCase()),
|
||||
new DatabaseManager(this,
|
||||
DatabaseType.valueOf(config.getDbType().toUpperCase()),
|
||||
config.getDbHost(),
|
||||
config.getDbPort(),
|
||||
config.getDbName(),
|
||||
@ -37,6 +48,12 @@ public final class MiniPlayerTitle extends JavaPlugin {
|
||||
}
|
||||
|
||||
Bukkit.getPluginManager().registerEvents(new Events(), this);
|
||||
Bukkit.getPluginManager().registerEvents(new TitleCard(), this);
|
||||
if (Common.isPaper()) {
|
||||
Bukkit.getPluginManager().registerEvents(new PaperChat(), this);
|
||||
} else {
|
||||
Bukkit.getPluginManager().registerEvents(new SpigotChat(), this);
|
||||
}
|
||||
Objects.requireNonNull(Bukkit.getPluginCommand("MiniPlayerTitle")).setExecutor(new Commands());
|
||||
Objects.requireNonNull(Bukkit.getPluginCommand("MiniPlayerTitle")).setTabCompleter(new Commands());
|
||||
|
||||
@ -49,7 +66,7 @@ public final class MiniPlayerTitle extends JavaPlugin {
|
||||
}
|
||||
|
||||
XLogger.info("称号插件已加载");
|
||||
XLogger.info("版本: " + getPluginMeta().getVersion());
|
||||
XLogger.info("版本: " + this.getDescription().getVersion());
|
||||
// http://patorjk.com/software/taag/#p=display&f=Big&t=MiniPlayerTitle
|
||||
XLogger.info(" __ __ _ _ _____ _ _______ _ _ _");
|
||||
XLogger.info(" | \\/ (_) (_) __ \\| | |__ __(_) | | |");
|
||||
@ -64,15 +81,23 @@ public final class MiniPlayerTitle extends JavaPlugin {
|
||||
@Override
|
||||
public void onDisable() {
|
||||
// Plugin shutdown logic
|
||||
database.close();
|
||||
DatabaseManager.instance.close();
|
||||
}
|
||||
|
||||
public static MiniPlayerTitle instance;
|
||||
public static ConfigManager config;
|
||||
public static DatabaseManager database;
|
||||
private GiteaReleaseCheck giteaReleaseCheck;
|
||||
private Map<UUID, TitleDTO> playerUsingTitle = new HashMap<>();
|
||||
|
||||
public static boolean usingPapi() {
|
||||
return Bukkit.getPluginManager().isPluginEnabled("PlaceholderAPI");
|
||||
}
|
||||
|
||||
public void setPlayerUsingTitle(UUID uuid, TitleDTO title) {
|
||||
playerUsingTitle.put(uuid, title);
|
||||
}
|
||||
|
||||
public TitleDTO getPlayerUsingTitle(UUID uuid) {
|
||||
return playerUsingTitle.get(uuid);
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,10 @@
|
||||
package cn.lunadeer.miniplayertitle.commands;
|
||||
|
||||
import cn.lunadeer.minecraftpluginutils.Notification;
|
||||
import cn.lunadeer.minecraftpluginutils.Common;
|
||||
import cn.lunadeer.miniplayertitle.MiniPlayerTitle;
|
||||
import cn.lunadeer.miniplayertitle.dtos.TitleDTO;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@ -12,44 +13,36 @@ import static cn.lunadeer.miniplayertitle.MiniPlayerTitle.usingPapi;
|
||||
|
||||
|
||||
public class Apis {
|
||||
public static boolean notOpOrConsole(CommandSender sender) {
|
||||
if (sender instanceof Player) {
|
||||
Player player = (Player) sender;
|
||||
if (!player.isOp()) {
|
||||
Notification.warn(player, "你没有权限使用此命令");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void updateName(Player player, @Nullable TitleDTO title) {
|
||||
MiniPlayerTitle.instance.setPlayerUsingTitle(player.getUniqueId(), title);
|
||||
if (usingPapi()) {
|
||||
return;
|
||||
}
|
||||
if (title == null || title.getId() == -1) {
|
||||
|
||||
Component titleComponent = Component.text("");
|
||||
String titleBukkit = "";
|
||||
|
||||
if (title != null && title.getId() != -1) {
|
||||
titleComponent = title.getTitleColored();
|
||||
titleBukkit = ChatColor.translateAlternateColorCodes('&', title.getTitleColoredBukkit());
|
||||
}
|
||||
|
||||
if (Common.isPaper()) {
|
||||
Component newDisplayName = Component.text()
|
||||
.append(titleComponent)
|
||||
.append(Component.text("<"))
|
||||
.append(player.name())
|
||||
.append(Component.text("> ")).build();
|
||||
.append(Component.text(">")).build();
|
||||
Component newListName = Component.text()
|
||||
.append(titleComponent)
|
||||
.append(Component.text(" "))
|
||||
.append(player.name()).build();
|
||||
player.displayName(newDisplayName);
|
||||
player.playerListName(newListName);
|
||||
return;
|
||||
} else {
|
||||
player.setDisplayName(titleBukkit + "<" + player.getName() + ">");
|
||||
player.setPlayerListName(titleBukkit + " " + player.getName());
|
||||
}
|
||||
|
||||
Component titleComponent = title.getTitleColored();
|
||||
Component newDisplayName = Component.text()
|
||||
.append(titleComponent)
|
||||
.append(Component.text("<"))
|
||||
.append(player.name())
|
||||
.append(Component.text(">")).build();
|
||||
Component newListName = Component.text()
|
||||
.append(titleComponent)
|
||||
.append(Component.text(" "))
|
||||
.append(player.name()).build();
|
||||
player.displayName(newDisplayName);
|
||||
player.playerListName(newListName);
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,6 @@ import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.lunadeer.miniplayertitle.commands.Apis.notOpOrConsole;
|
||||
|
||||
public class PlayerManage {
|
||||
|
||||
@ -20,7 +19,7 @@ public class PlayerManage {
|
||||
* @param args String[]
|
||||
*/
|
||||
public static void addCoin(CommandSender sender, String[] args) {
|
||||
if (notOpOrConsole(sender)) return;
|
||||
if (!sender.hasPermission("mplt.admin")) return;
|
||||
try {
|
||||
PlayerInfoDTO playerInfo = PlayerInfoDTO.get(args[1]);
|
||||
if (playerInfo == null) {
|
||||
@ -46,7 +45,7 @@ public class PlayerManage {
|
||||
* @param args String[]
|
||||
*/
|
||||
public static void setCoin(CommandSender sender, String[] args) {
|
||||
if (notOpOrConsole(sender)) return;
|
||||
if (!sender.hasPermission("mplt.admin")) return;
|
||||
try {
|
||||
PlayerInfoDTO playerInfo = PlayerInfoDTO.get(args[1]);
|
||||
if (playerInfo == null) {
|
||||
@ -72,7 +71,7 @@ public class PlayerManage {
|
||||
* @param args String[]
|
||||
*/
|
||||
public static void grantTitle(CommandSender sender, String[] args) {
|
||||
if (notOpOrConsole(sender)) return;
|
||||
if (!sender.hasPermission("mplt.admin")) return;
|
||||
try {
|
||||
PlayerInfoDTO playerInfo = PlayerInfoDTO.get(args[1]);
|
||||
if (playerInfo == null) {
|
||||
|
@ -0,0 +1,135 @@
|
||||
package cn.lunadeer.miniplayertitle.commands;
|
||||
|
||||
import cn.lunadeer.minecraftpluginutils.Notification;
|
||||
import cn.lunadeer.miniplayertitle.dtos.PlayerTitleDTO;
|
||||
import cn.lunadeer.miniplayertitle.dtos.TitleDTO;
|
||||
import cn.lunadeer.miniplayertitle.dtos.TitleShopDTO;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class TitleCard implements Listener {
|
||||
|
||||
public static void getTitleCard(CommandSender sender, String[] args) {
|
||||
try {
|
||||
if (!sender.hasPermission("mplt.admin")) return;
|
||||
if (!(sender instanceof Player)) {
|
||||
Notification.error(sender, "该命令只能由玩家执行");
|
||||
return;
|
||||
}
|
||||
if (args.length != 2) {
|
||||
Notification.warn(sender, "用法: /mplt get_card <销售ID>");
|
||||
return;
|
||||
}
|
||||
int saleId = Integer.parseInt(args[1]);
|
||||
TitleShopDTO titleShop = TitleShopDTO.get(saleId);
|
||||
if (titleShop == null) {
|
||||
Notification.error(sender, "获取销售详情时出现错误");
|
||||
return;
|
||||
}
|
||||
if (titleShop.getDays() == 0) {
|
||||
Notification.error(sender, "不可以生成天数为0的称号卡!");
|
||||
return;
|
||||
}
|
||||
ItemStack card = TitleCard.create(titleShop);
|
||||
Player player = (Player) sender;
|
||||
player.getInventory().addItem(card);
|
||||
Notification.info(player, "成功创建称号卡");
|
||||
} catch (Exception e) {
|
||||
Notification.error(sender, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void useTitleCard(PlayerInteractEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if (player.getInventory().getItemInMainHand().getType() != Material.NAME_TAG) {
|
||||
return;
|
||||
}
|
||||
ItemStack item = player.getInventory().getItemInMainHand();
|
||||
if (item.getItemMeta() == null || item.getItemMeta().getLore() == null || item.getItemMeta().getLore().size() != 5) {
|
||||
return;
|
||||
}
|
||||
use(player, item);
|
||||
player.getInventory().removeItem(item);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
private static ItemStack create(@NotNull TitleShopDTO saleInfo) {
|
||||
ItemStack card = new ItemStack(Material.NAME_TAG);
|
||||
TitleDTO title = saleInfo.getTitle();
|
||||
card.editMeta(meta -> {
|
||||
meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', title.getTitleColoredBukkit()));
|
||||
meta.setLore(
|
||||
Arrays.asList(
|
||||
"称号ID: " + title.getId(),
|
||||
"使用后获得天数: " + (saleInfo.getDays() == -1 ? "永久" : saleInfo.getDays()),
|
||||
"称号描述: " + title.getDescription(),
|
||||
"",
|
||||
ChatColor.GRAY + "【右键使用】"
|
||||
|
||||
)
|
||||
);
|
||||
});
|
||||
return card;
|
||||
}
|
||||
|
||||
private static void use(@NotNull Player player, @NotNull ItemStack item) {
|
||||
try {
|
||||
if (item.getType() != Material.NAME_TAG) {
|
||||
return;
|
||||
}
|
||||
List<String> lore = item.getLore();
|
||||
if (lore == null || lore.size() != 5) {
|
||||
return;
|
||||
}
|
||||
int titleId = Integer.parseInt(lore.get(0).split(": ")[1]);
|
||||
int day = lore.get(1).split(": ")[1].equals("永久") ? -1 : Integer.parseInt(lore.get(1).split(": ")[1]);
|
||||
|
||||
List<PlayerTitleDTO> playerTitles = PlayerTitleDTO.getAllOf(player.getUniqueId());
|
||||
PlayerTitleDTO had = null;
|
||||
for (PlayerTitleDTO playerTitle : playerTitles) {
|
||||
if (Objects.equals(playerTitle.getTitle().getId(), titleId)) {
|
||||
had = playerTitle;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
TitleDTO title = TitleDTO.get(titleId);
|
||||
if (title == null) {
|
||||
Notification.error(player, "称号不存在");
|
||||
return;
|
||||
}
|
||||
|
||||
if (had == null) {
|
||||
had = PlayerTitleDTO.create(player.getUniqueId(), title, day == -1 ? null : LocalDateTime.now().plusDays(day));
|
||||
if (had == null) {
|
||||
Notification.error(player, "购买称号时出现错误,详情请查看控制台日志");
|
||||
return;
|
||||
}
|
||||
Notification.info(player, Component.text("成功使用称号卡: ").append(had.getTitle().getTitleColored()));
|
||||
} else if (!had.isExpired()) {
|
||||
Notification.warn(player, "你已拥有此称号,在过期前无法使用称号卡");
|
||||
} else {
|
||||
had.setExpireAt(day == -1 ? null : LocalDateTime.now().plusDays(day));
|
||||
Notification.info(player, Component.text("成功续续期称号: ").append(had.getTitle().getTitleColored()));
|
||||
}
|
||||
TitleManage.useTitle(player, new String[]{"use_title", String.valueOf(had.getId())});
|
||||
} catch (Exception e) {
|
||||
Notification.error(player, "使用称号卡时出现错误: %s", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -11,7 +11,6 @@ import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import static cn.lunadeer.miniplayertitle.commands.Apis.notOpOrConsole;
|
||||
import static cn.lunadeer.miniplayertitle.commands.Apis.updateName;
|
||||
|
||||
public class TitleManage {
|
||||
@ -23,7 +22,7 @@ public class TitleManage {
|
||||
* @param args String[]
|
||||
*/
|
||||
public static void createTitle(CommandSender sender, String[] args) {
|
||||
if (notOpOrConsole(sender)) return;
|
||||
if (!sender.hasPermission("mplt.admin")) return;
|
||||
if (args.length < 2) {
|
||||
Notification.warn(sender, "用法: /mplt create_title <称号名称> [称号描述]");
|
||||
return;
|
||||
@ -46,7 +45,7 @@ public class TitleManage {
|
||||
*/
|
||||
public static void deleteTitle(CommandSender sender, String[] args) {
|
||||
try {
|
||||
if (notOpOrConsole(sender)) return;
|
||||
if (!sender.hasPermission("mplt.admin")) return;
|
||||
if (args.length < 2) {
|
||||
Notification.warn(sender, "用法: /mplt delete_title <称号ID>");
|
||||
return;
|
||||
@ -80,7 +79,7 @@ public class TitleManage {
|
||||
*/
|
||||
public static void editTitleName(CommandSender sender, String[] args) {
|
||||
try {
|
||||
if (notOpOrConsole(sender)) return;
|
||||
if (!sender.hasPermission("mplt.admin")) return;
|
||||
if (args.length != 3) {
|
||||
Notification.warn(sender, "用法: /mplt set_title <称号ID> <称号名称>");
|
||||
return;
|
||||
@ -110,7 +109,7 @@ public class TitleManage {
|
||||
*/
|
||||
public static void editTitleDescription(CommandSender sender, String[] args) {
|
||||
try {
|
||||
if (notOpOrConsole(sender)) return;
|
||||
if (!sender.hasPermission("mplt.admin")) return;
|
||||
if (args.length != 3) {
|
||||
Notification.warn(sender, "用法: /mplt set_desc <称号ID> <称号描述>");
|
||||
return;
|
||||
@ -143,6 +142,7 @@ public class TitleManage {
|
||||
Notification.error(sender, "该命令只能由玩家执行");
|
||||
return;
|
||||
}
|
||||
if (!sender.hasPermission("mplt.command")) return;
|
||||
if (args.length < 2) {
|
||||
Notification.warn(sender, "用法: /mplt use_title <背包ID> [页码]");
|
||||
return;
|
||||
@ -158,29 +158,29 @@ public class TitleManage {
|
||||
Notification.info(sender, "已卸下称号");
|
||||
playerInfo.setUsingTitle(null);
|
||||
updateName(player, null);
|
||||
return;
|
||||
}
|
||||
PlayerTitleDTO title = PlayerTitleDTO.get(id);
|
||||
if (title == null) {
|
||||
Notification.error(sender, "称号不存在");
|
||||
return;
|
||||
}
|
||||
if (!title.getPlayerUuid().equals(player.getUniqueId())) {
|
||||
Notification.error(sender, "该称号不属于你");
|
||||
return;
|
||||
}
|
||||
if (title.isExpired()) {
|
||||
Notification.error(sender, "称号 %s 已过期", title.getTitle().getTitlePlainText());
|
||||
playerInfo.setUsingTitle(null);
|
||||
updateName(player, null);
|
||||
return;
|
||||
}
|
||||
boolean success = playerInfo.setUsingTitle(title.getTitle());
|
||||
if (success) {
|
||||
updateName((Player) sender, title.getTitle());
|
||||
Notification.info(sender, "已使用称号");
|
||||
} else {
|
||||
Notification.error(sender, "使用称号失败,具体请查看控制台日志");
|
||||
PlayerTitleDTO title = PlayerTitleDTO.get(id);
|
||||
if (title == null) {
|
||||
Notification.error(sender, "称号不存在");
|
||||
return;
|
||||
}
|
||||
if (!title.getPlayerUuid().equals(player.getUniqueId())) {
|
||||
Notification.error(sender, "该称号不属于你");
|
||||
return;
|
||||
}
|
||||
if (title.isExpired()) {
|
||||
Notification.error(sender, "称号 %s 已过期", title.getTitle().getTitlePlainText());
|
||||
playerInfo.setUsingTitle(null);
|
||||
updateName(player, null);
|
||||
return;
|
||||
}
|
||||
boolean success = playerInfo.setUsingTitle(title.getTitle());
|
||||
if (success) {
|
||||
updateName((Player) sender, title.getTitle());
|
||||
Notification.info(sender, "已使用称号");
|
||||
} else {
|
||||
Notification.error(sender, "使用称号失败,具体请查看控制台日志");
|
||||
}
|
||||
}
|
||||
|
||||
if (args.length == 3) {
|
||||
@ -201,6 +201,10 @@ public class TitleManage {
|
||||
Notification.error(sender, "该命令只能由玩家执行");
|
||||
return;
|
||||
}
|
||||
if (!sender.hasPermission("mplt.custom") && !sender.hasPermission("mplt.admin")) {
|
||||
Notification.error(sender, "你没有权限使用该命令");
|
||||
return;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
if (!MiniPlayerTitle.config.isEnableCustom()) {
|
||||
Notification.error(sender, "自定义称号功能已关闭");
|
||||
|
@ -16,7 +16,6 @@ import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import static cn.lunadeer.miniplayertitle.commands.Apis.notOpOrConsole;
|
||||
import static cn.lunadeer.miniplayertitle.tuis.Apis.getArgPage;
|
||||
import static cn.lunadeer.miniplayertitle.tuis.Apis.getLastArgsPage;
|
||||
|
||||
@ -30,7 +29,7 @@ public class TitleShopSale {
|
||||
* @param args String[]
|
||||
*/
|
||||
public static void setSale(CommandSender sender, String[] args) {
|
||||
if (notOpOrConsole(sender)) return;
|
||||
if (!sender.hasPermission("mplt.admin")) return;
|
||||
TitleShopDTO titleShop = TitleShopDTO.get(Integer.valueOf(args[2]));
|
||||
if (titleShop == null) {
|
||||
Notification.error(sender, "获取详情时出现错误,详情请查看控制台日志");
|
||||
@ -83,7 +82,7 @@ public class TitleShopSale {
|
||||
* @param args String[]
|
||||
*/
|
||||
public static void createSale(CommandSender sender, String[] args) {
|
||||
if (notOpOrConsole(sender)) return;
|
||||
if (!sender.hasPermission("mplt.admin")) return;
|
||||
TitleDTO title = TitleDTO.get(Integer.parseInt(args[1]));
|
||||
if (title == null) {
|
||||
Notification.error(sender, "获取称号详情时出现错误,详情请查看控制台日志");
|
||||
@ -108,7 +107,7 @@ public class TitleShopSale {
|
||||
* @param args String[]
|
||||
*/
|
||||
public static void deleteSale(CommandSender sender, String[] args) {
|
||||
if (notOpOrConsole(sender)) return;
|
||||
if (!sender.hasPermission("mplt.admin")) return;
|
||||
TitleShopDTO titleShop = TitleShopDTO.get(Integer.valueOf(args[1]));
|
||||
if (titleShop == null) {
|
||||
Notification.error(sender, "获取详情时出现错误");
|
||||
@ -138,6 +137,7 @@ public class TitleShopSale {
|
||||
Notification.error(sender, "该命令只能由玩家执行");
|
||||
return;
|
||||
}
|
||||
if (!sender.hasPermission("mplt.command")) return;
|
||||
Player player = (Player) sender;
|
||||
PlayerInfoDTO playerInfo = PlayerInfoDTO.get(player.getUniqueId());
|
||||
if (playerInfo == null) {
|
||||
@ -194,6 +194,7 @@ public class TitleShopSale {
|
||||
Notification.info(player, Component.text("成功续续期称号: ").append(had.getTitle().getTitleColored()));
|
||||
}
|
||||
|
||||
TitleManage.useTitle(player, new String[]{"use_title", String.valueOf(had.getId())});
|
||||
int page = getArgPage(args, 3);
|
||||
MyTitles.show(sender, new String[]{"my_titles", String.valueOf(page)});
|
||||
}
|
||||
|
@ -1,7 +1,10 @@
|
||||
package cn.lunadeer.miniplayertitle.dtos;
|
||||
|
||||
import cn.lunadeer.minecraftpluginutils.VaultConnect;
|
||||
import cn.lunadeer.minecraftpluginutils.VaultConnect.VaultConnect;
|
||||
import cn.lunadeer.minecraftpluginutils.XLogger;
|
||||
import cn.lunadeer.minecraftpluginutils.databse.DatabaseManager;
|
||||
import cn.lunadeer.minecraftpluginutils.databse.Field;
|
||||
import cn.lunadeer.minecraftpluginutils.databse.FieldType;
|
||||
import cn.lunadeer.miniplayertitle.MiniPlayerTitle;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -12,20 +15,22 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import static cn.lunadeer.minecraftpluginutils.databse.DatabaseManager.handleDatabaseError;
|
||||
|
||||
public class PlayerInfoDTO {
|
||||
private UUID uuid;
|
||||
private Double coin;
|
||||
private final Field uuid = new Field("uuid", FieldType.UUID);
|
||||
private final Field coin = new Field("coin_d", FieldType.DOUBLE);
|
||||
private TitleDTO using_title;
|
||||
private String last_use_name;
|
||||
private final Field last_use_name = new Field("last_use_name", FieldType.STRING);
|
||||
|
||||
public static PlayerInfoDTO get(UUID uuid) {
|
||||
String sql = "";
|
||||
sql = "SELECT uuid, coin_d, using_title_id, last_use_name FROM mplt_player_info WHERE uuid = ?;";
|
||||
try (ResultSet rs = MiniPlayerTitle.database.query(sql, uuid)) {
|
||||
try (ResultSet rs = DatabaseManager.instance.query(sql, uuid)) {
|
||||
if (rs.next()) return getPlayerInfoDTO(rs);
|
||||
else return null;
|
||||
} catch (Exception e) {
|
||||
MiniPlayerTitle.database.handleDatabaseError("获取玩家信息失败", e, sql);
|
||||
handleDatabaseError("获取玩家信息失败", e, sql);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -51,11 +56,11 @@ public class PlayerInfoDTO {
|
||||
public static PlayerInfoDTO get(String name) {
|
||||
String sql = "";
|
||||
sql = "SELECT uuid, coin_d, using_title_id, last_use_name FROM mplt_player_info WHERE last_use_name = ?;";
|
||||
try (ResultSet rs = MiniPlayerTitle.database.query(sql, name)) {
|
||||
try (ResultSet rs = DatabaseManager.instance.query(sql, name)) {
|
||||
if (rs.next()) return getPlayerInfoDTO(rs);
|
||||
else return null;
|
||||
} catch (Exception e) {
|
||||
MiniPlayerTitle.database.handleDatabaseError("获取玩家信息失败", e, sql);
|
||||
handleDatabaseError("获取玩家信息失败", e, sql);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -65,10 +70,10 @@ public class PlayerInfoDTO {
|
||||
sql = "INSERT INTO mplt_player_info (uuid, coin_d, last_use_name) " +
|
||||
"VALUES (?, ?, ?) " +
|
||||
"ON CONFLICT DO NOTHING;";
|
||||
try (ResultSet rs = MiniPlayerTitle.database.query(sql, player.getUniqueId(), MiniPlayerTitle.config.getDefaultCoin(), player.getName())) {
|
||||
try (ResultSet rs = DatabaseManager.instance.query(sql, player.getUniqueId(), MiniPlayerTitle.config.getDefaultCoin(), player.getName())) {
|
||||
return get(player.getUniqueId());
|
||||
} catch (Exception e) {
|
||||
MiniPlayerTitle.database.handleDatabaseError("创建玩家信息失败", e, sql);
|
||||
handleDatabaseError("创建玩家信息失败", e, sql);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -76,29 +81,29 @@ public class PlayerInfoDTO {
|
||||
private static PlayerInfoDTO updateName(Player player) {
|
||||
String sql = "";
|
||||
sql = "UPDATE mplt_player_info SET last_use_name = ? WHERE uuid = ?;";
|
||||
try (ResultSet rs = MiniPlayerTitle.database.query(sql, player.getName(), player.getUniqueId())) {
|
||||
try (ResultSet rs = DatabaseManager.instance.query(sql, player.getName(), player.getUniqueId())) {
|
||||
return get(player.getUniqueId());
|
||||
} catch (Exception e) {
|
||||
MiniPlayerTitle.database.handleDatabaseError("更新玩家名称失败", e, sql);
|
||||
handleDatabaseError("更新玩家名称失败", e, sql);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static PlayerInfoDTO getPlayerInfoDTO(ResultSet rs) throws SQLException {
|
||||
PlayerInfoDTO playerInfoDTO = new PlayerInfoDTO();
|
||||
playerInfoDTO.uuid = UUID.fromString(rs.getString("uuid"));
|
||||
playerInfoDTO.coin = rs.getDouble("coin_d");
|
||||
playerInfoDTO.uuid.value = UUID.fromString(rs.getString("uuid"));
|
||||
playerInfoDTO.coin.value = rs.getDouble("coin_d");
|
||||
playerInfoDTO.using_title = TitleDTO.get(rs.getInt("using_title_id"));
|
||||
playerInfoDTO.last_use_name = rs.getString("last_use_name");
|
||||
playerInfoDTO.last_use_name.value = rs.getString("last_use_name");
|
||||
return playerInfoDTO;
|
||||
}
|
||||
|
||||
public Double getCoin() {
|
||||
if (MiniPlayerTitle.config.isExternalEco()) {
|
||||
Player player = MiniPlayerTitle.instance.getServer().getPlayer(uuid);
|
||||
Player player = MiniPlayerTitle.instance.getServer().getPlayer(getUuid());
|
||||
return VaultConnect.instance.getBalance(player);
|
||||
}
|
||||
return coin;
|
||||
return (Double) coin.value;
|
||||
}
|
||||
|
||||
public TitleDTO getUsingTitle() {
|
||||
@ -106,37 +111,37 @@ public class PlayerInfoDTO {
|
||||
}
|
||||
|
||||
public String getLastUseName() {
|
||||
return last_use_name;
|
||||
return (String) last_use_name.value;
|
||||
}
|
||||
|
||||
public UUID getUuid() {
|
||||
return uuid;
|
||||
return (UUID) uuid.value;
|
||||
}
|
||||
|
||||
public boolean setUsingTitle(@Nullable TitleDTO title) {
|
||||
String sql = "";
|
||||
sql = "UPDATE mplt_player_info SET using_title_id = ? WHERE uuid = ?;";
|
||||
try (ResultSet rs = MiniPlayerTitle.database.query(sql, title == null ? -1 : title.getId(), uuid)) {
|
||||
try (ResultSet rs = DatabaseManager.instance.query(sql, title == null ? -1 : title.getId(), getUuid())) {
|
||||
this.using_title = title == null ? TitleDTO.get(-1) : title;
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
MiniPlayerTitle.database.handleDatabaseError("设置玩家使用称号失败", e, sql);
|
||||
handleDatabaseError("设置玩家使用称号失败", e, sql);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean addCoin(double coin) {
|
||||
if (MiniPlayerTitle.config.isExternalEco()) {
|
||||
Player player = MiniPlayerTitle.instance.getServer().getPlayer(uuid);
|
||||
Player player = MiniPlayerTitle.instance.getServer().getPlayer(getUuid());
|
||||
VaultConnect.instance.depositPlayer(player, coin);
|
||||
return true;
|
||||
}
|
||||
return setCoin(this.coin + coin);
|
||||
return setCoin(getCoin() + coin);
|
||||
}
|
||||
|
||||
public boolean setCoin(double coin) {
|
||||
if (MiniPlayerTitle.config.isExternalEco()) {
|
||||
Player player = MiniPlayerTitle.instance.getServer().getPlayer(uuid);
|
||||
Player player = MiniPlayerTitle.instance.getServer().getPlayer(getUuid());
|
||||
double balance = VaultConnect.instance.getBalance(player);
|
||||
if (balance < coin) {
|
||||
VaultConnect.instance.depositPlayer(player, coin - balance);
|
||||
@ -147,11 +152,11 @@ public class PlayerInfoDTO {
|
||||
}
|
||||
String sql = "";
|
||||
sql = "UPDATE mplt_player_info SET coin_d = ? WHERE uuid = ?;";
|
||||
try (ResultSet rs = MiniPlayerTitle.database.query(sql, coin, uuid)) {
|
||||
this.coin = coin;
|
||||
try (ResultSet rs = DatabaseManager.instance.query(sql, coin, getUuid())) {
|
||||
this.coin.value = coin;
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
MiniPlayerTitle.database.handleDatabaseError("设置玩家金币失败", e, sql);
|
||||
handleDatabaseError("设置玩家金币失败", e, sql);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -160,12 +165,12 @@ public class PlayerInfoDTO {
|
||||
String sql = "";
|
||||
sql = "SELECT last_use_name FROM mplt_player_info;";
|
||||
List<String> names = new ArrayList<>();
|
||||
try (ResultSet rs = MiniPlayerTitle.database.query(sql)) {
|
||||
try (ResultSet rs = DatabaseManager.instance.query(sql)) {
|
||||
while (rs.next()) {
|
||||
names.add(rs.getString("last_use_name"));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
MiniPlayerTitle.database.handleDatabaseError("获取玩家名称列表失败", e, sql);
|
||||
handleDatabaseError("获取玩家名称列表失败", e, sql);
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
package cn.lunadeer.miniplayertitle.dtos;
|
||||
|
||||
import cn.lunadeer.miniplayertitle.MiniPlayerTitle;
|
||||
import cn.lunadeer.minecraftpluginutils.databse.DatabaseManager;
|
||||
import cn.lunadeer.minecraftpluginutils.databse.Field;
|
||||
import cn.lunadeer.minecraftpluginutils.databse.FieldType;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.sql.ResultSet;
|
||||
@ -10,14 +12,16 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import static cn.lunadeer.minecraftpluginutils.databse.DatabaseManager.handleDatabaseError;
|
||||
|
||||
public class PlayerTitleDTO {
|
||||
private Integer id;
|
||||
private UUID player_uuid;
|
||||
private final Field id = new Field("id", FieldType.INT);
|
||||
private final Field player_uuid = new Field("player_uuid", FieldType.UUID);
|
||||
private TitleDTO title;
|
||||
private LocalDateTime expire_at;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
return (Integer) id.value;
|
||||
}
|
||||
|
||||
public TitleDTO getTitle() {
|
||||
@ -25,7 +29,7 @@ public class PlayerTitleDTO {
|
||||
}
|
||||
|
||||
public UUID getPlayerUuid() {
|
||||
return player_uuid;
|
||||
return (UUID) player_uuid.value;
|
||||
}
|
||||
|
||||
public LocalDateTime getExpireAt() {
|
||||
@ -35,14 +39,14 @@ public class PlayerTitleDTO {
|
||||
public boolean setExpireAt(LocalDateTime dateTime) {
|
||||
String sql = "";
|
||||
if (dateTime == null) {
|
||||
sql += "UPDATE mplt_player_title SET expire_at_y = -1, expire_at_m = -1, expire_at_d = -1 WHERE id = " + id + ";";
|
||||
sql += "UPDATE mplt_player_title SET expire_at_y = -1, expire_at_m = -1, expire_at_d = -1 WHERE id = " + getId() + ";";
|
||||
} else {
|
||||
sql += "UPDATE mplt_player_title SET expire_at_y = " + dateTime.getYear() + ", expire_at_m = " + dateTime.getMonthValue() + ", expire_at_d = " + dateTime.getDayOfMonth() + " WHERE id = " + id + ";";
|
||||
sql += "UPDATE mplt_player_title SET expire_at_y = " + dateTime.getYear() + ", expire_at_m = " + dateTime.getMonthValue() + ", expire_at_d = " + dateTime.getDayOfMonth() + " WHERE id = " + getId() + ";";
|
||||
}
|
||||
try (ResultSet rs = MiniPlayerTitle.database.query(sql)) {
|
||||
try (ResultSet rs = DatabaseManager.instance.query(sql)) {
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
MiniPlayerTitle.database.handleDatabaseError("设置玩家称号过期时间失败", e, sql);
|
||||
handleDatabaseError("设置玩家称号过期时间失败", e, sql);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -58,12 +62,12 @@ public class PlayerTitleDTO {
|
||||
}
|
||||
sql += "RETURNING " +
|
||||
"id, player_uuid, title_id, expire_at_y, expire_at_m, expire_at_d;";
|
||||
try (ResultSet rs = MiniPlayerTitle.database.query(sql, player_uuid, title.getId())) {
|
||||
try (ResultSet rs = DatabaseManager.instance.query(sql, player_uuid, title.getId())) {
|
||||
if (rs.next()) {
|
||||
return getRs(rs);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
MiniPlayerTitle.database.handleDatabaseError("创建玩家称号失败", e, sql);
|
||||
handleDatabaseError("创建玩家称号失败", e, sql);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -72,12 +76,12 @@ public class PlayerTitleDTO {
|
||||
String sql = "";
|
||||
sql += "SELECT id, player_uuid, title_id, expire_at_y, expire_at_m, expire_at_d FROM mplt_player_title " +
|
||||
"WHERE id = ?;";
|
||||
try (ResultSet rs = MiniPlayerTitle.database.query(sql, id)) {
|
||||
try (ResultSet rs = DatabaseManager.instance.query(sql, id)) {
|
||||
if (rs.next()) {
|
||||
return getRs(rs);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
MiniPlayerTitle.database.handleDatabaseError("获取玩家称号失败", e, sql);
|
||||
handleDatabaseError("获取玩家称号失败", e, sql);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -86,20 +90,20 @@ public class PlayerTitleDTO {
|
||||
String sql = "";
|
||||
sql += "SELECT id, player_uuid, title_id, expire_at_y, expire_at_m, expire_at_d FROM mplt_player_title " +
|
||||
"WHERE player_uuid = ? AND title_id = ?;";
|
||||
try (ResultSet rs = MiniPlayerTitle.database.query(sql, player, title)) {
|
||||
try (ResultSet rs = DatabaseManager.instance.query(sql, player, title)) {
|
||||
if (rs.next()) {
|
||||
return getRs(rs);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
MiniPlayerTitle.database.handleDatabaseError("获取玩家称号失败", e, sql);
|
||||
handleDatabaseError("获取玩家称号失败", e, sql);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static PlayerTitleDTO getRs(ResultSet rs) throws SQLException {
|
||||
PlayerTitleDTO playerTitle = new PlayerTitleDTO();
|
||||
playerTitle.id = rs.getInt("id");
|
||||
playerTitle.player_uuid = UUID.fromString(rs.getString("player_uuid"));
|
||||
playerTitle.id.value = rs.getInt("id");
|
||||
playerTitle.player_uuid.value = UUID.fromString(rs.getString("player_uuid"));
|
||||
playerTitle.title = TitleDTO.get(rs.getInt("title_id"));
|
||||
int y = rs.getInt("expire_at_y");
|
||||
int m = rs.getInt("expire_at_m");
|
||||
@ -117,12 +121,12 @@ public class PlayerTitleDTO {
|
||||
sql += "SELECT id, player_uuid, title_id, expire_at_y, expire_at_m, expire_at_d FROM mplt_player_title " +
|
||||
"WHERE player_uuid = ?;";
|
||||
List<PlayerTitleDTO> playerTitles = new ArrayList<>();
|
||||
try (ResultSet rs = MiniPlayerTitle.database.query(sql, player_uuid)) {
|
||||
try (ResultSet rs = DatabaseManager.instance.query(sql, player_uuid)) {
|
||||
while (rs.next()) {
|
||||
playerTitles.add(getRs(rs));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
MiniPlayerTitle.database.handleDatabaseError("获取玩家称号失败", e, sql);
|
||||
handleDatabaseError("获取玩家称号失败", e, sql);
|
||||
}
|
||||
return playerTitles;
|
||||
}
|
||||
|
@ -1,31 +1,32 @@
|
||||
package cn.lunadeer.miniplayertitle.dtos;
|
||||
|
||||
import cn.lunadeer.minecraftpluginutils.XLogger;
|
||||
import cn.lunadeer.miniplayertitle.Color;
|
||||
import cn.lunadeer.minecraftpluginutils.ColorParser;
|
||||
import cn.lunadeer.minecraftpluginutils.databse.DatabaseManager;
|
||||
import cn.lunadeer.minecraftpluginutils.databse.Field;
|
||||
import cn.lunadeer.minecraftpluginutils.databse.FieldType;
|
||||
import cn.lunadeer.miniplayertitle.MiniPlayerTitle;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.event.HoverEvent;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static cn.lunadeer.minecraftpluginutils.databse.DatabaseManager.handleDatabaseError;
|
||||
|
||||
public class TitleDTO {
|
||||
private int id;
|
||||
private String title;
|
||||
private String description;
|
||||
private final Field id = new Field("id", FieldType.INT);
|
||||
private final Field title = new Field("title", FieldType.STRING);
|
||||
private final Field description = new Field("description", FieldType.STRING);
|
||||
|
||||
|
||||
public static TitleDTO get(int id) {
|
||||
String sql = "";
|
||||
sql += "SELECT id, title, description FROM mplt_title WHERE id = " + id + ";";
|
||||
try (ResultSet rs = MiniPlayerTitle.database.query(sql)) {
|
||||
try (ResultSet rs = DatabaseManager.instance.query(sql)) {
|
||||
if (rs.next()) return getTitleDTO(rs);
|
||||
} catch (Exception e) {
|
||||
MiniPlayerTitle.database.handleDatabaseError("获取称号失败", e, sql);
|
||||
handleDatabaseError("获取称号失败", e, sql);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -36,10 +37,10 @@ public class TitleDTO {
|
||||
"VALUES (?, ?) " +
|
||||
"RETURNING " +
|
||||
"id, title, description;";
|
||||
try (ResultSet rs = MiniPlayerTitle.database.query(sql, title, description)) {
|
||||
try (ResultSet rs = DatabaseManager.instance.query(sql, title, description)) {
|
||||
if (rs.next()) return getTitleDTO(rs);
|
||||
} catch (Exception e) {
|
||||
MiniPlayerTitle.database.handleDatabaseError("创建称号失败", e, sql);
|
||||
handleDatabaseError("创建称号失败", e, sql);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -49,12 +50,12 @@ public class TitleDTO {
|
||||
String deleteSql = "DELETE FROM mplt_title WHERE id = ?;";
|
||||
try {
|
||||
// 执行更新操作
|
||||
MiniPlayerTitle.database.query(updateSql, this.id);
|
||||
DatabaseManager.instance.query(updateSql, getId());
|
||||
// 执行删除操作
|
||||
MiniPlayerTitle.database.query(deleteSql, this.id);
|
||||
DatabaseManager.instance.query(deleteSql, getId());
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
MiniPlayerTitle.database.handleDatabaseError("删除称号失败", e, updateSql + " " + deleteSql);
|
||||
handleDatabaseError("删除称号失败", e, updateSql + " " + deleteSql);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -63,102 +64,59 @@ public class TitleDTO {
|
||||
String sql = "";
|
||||
sql += "SELECT id, title, description FROM mplt_title;";
|
||||
List<TitleDTO> titleDTOs = new ArrayList<>();
|
||||
try (ResultSet rs = MiniPlayerTitle.database.query(sql)) {
|
||||
try (ResultSet rs = DatabaseManager.instance.query(sql)) {
|
||||
while (rs.next()) {
|
||||
titleDTOs.add(getTitleDTO(rs));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
MiniPlayerTitle.database.handleDatabaseError("获取称号列表失败", e, sql);
|
||||
handleDatabaseError("获取称号列表失败", e, sql);
|
||||
}
|
||||
return titleDTOs;
|
||||
}
|
||||
|
||||
public TextComponent getTitleColored() {
|
||||
String title = MiniPlayerTitle.config.getPrefix() + this.title + MiniPlayerTitle.config.getSuffix();
|
||||
String[] parts = title.split("&#");
|
||||
List<TextComponent> components = new ArrayList<>();
|
||||
for (String part : parts) {
|
||||
if (part.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
Color color = new Color("#ffffff");
|
||||
String content;
|
||||
if (part.length() > 6 && part.substring(0, 6).matches("^[0-9a-fA-F]{6}$")) {
|
||||
String color_str = part.substring(0, 6);
|
||||
color = new Color("#" + color_str);
|
||||
content = part.substring(6);
|
||||
} else {
|
||||
content = part;
|
||||
}
|
||||
components.add(Component.text(content, color.getStyle()));
|
||||
}
|
||||
TextComponent.Builder title_component = Component.text();
|
||||
for (TextComponent component : components) {
|
||||
title_component.append(component);
|
||||
}
|
||||
return title_component.build().hoverEvent(HoverEvent.hoverEvent(HoverEvent.Action.SHOW_TEXT, Component.text(this.description)));
|
||||
String with_pre_suf = "&#ffffff" + MiniPlayerTitle.config.getPrefix() + getTitleRaw() + "&#ffffff" + MiniPlayerTitle.config.getSuffix();
|
||||
return ColorParser.getComponentType(with_pre_suf);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取称号的颜色化字符串
|
||||
* 需要使用 translateAlternateColorCodes 方法对返回字符串进行处理
|
||||
* 需要使用 ChatColor.translateAlternateColorCodes 方法对返回字符串进行处理
|
||||
* &#FFFFFF -> &x&f&f&f&f&f
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String getTitleColoredBukkit() {
|
||||
String title = MiniPlayerTitle.config.getPrefix() + this.title + MiniPlayerTitle.config.getSuffix();
|
||||
title = title.replaceAll("&#", "#");
|
||||
Pattern pattern = Pattern.compile("#[a-fA-F0-9]{6}");
|
||||
Matcher matcher = pattern.matcher(title);
|
||||
while (matcher.find()) {
|
||||
String hexCode = matcher.group();
|
||||
StringBuilder builder = new StringBuilder("&x");
|
||||
for (char c : hexCode.substring(1).toCharArray()) {
|
||||
builder.append('&').append(c);
|
||||
}
|
||||
title = title.replace(hexCode, builder.toString());
|
||||
}
|
||||
XLogger.debug("TitleDTO.getTitleColoredBukkit: %s", title);
|
||||
return title;
|
||||
String with_pre_suf = "&#ffffff" + MiniPlayerTitle.config.getPrefix() + getTitleRaw() + "&#ffffff" + MiniPlayerTitle.config.getSuffix();
|
||||
return ColorParser.getBukkitType(with_pre_suf);
|
||||
}
|
||||
|
||||
public String getTitlePlainText() {
|
||||
String[] parts = this.title.split("&#");
|
||||
StringBuilder res = new StringBuilder();
|
||||
for (String part : parts) {
|
||||
if (part.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
String content;
|
||||
if (part.length() > 6 && part.substring(0, 6).matches("^[0-9a-fA-F]{6}$")) {
|
||||
content = part.substring(6);
|
||||
} else {
|
||||
content = part;
|
||||
}
|
||||
res.append(content);
|
||||
}
|
||||
return res.toString();
|
||||
return ColorParser.getPlainText(getTitleRaw());
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return this.id;
|
||||
return (Integer) this.id.value;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return this.description;
|
||||
return (String) this.description.value;
|
||||
}
|
||||
|
||||
public String getTitleRaw() {
|
||||
return (String) this.title.value;
|
||||
}
|
||||
|
||||
public boolean updateTitle(String title) {
|
||||
String sql = "";
|
||||
sql += "UPDATE mplt_title SET title = ? WHERE id = ?;";
|
||||
try (ResultSet rs = MiniPlayerTitle.database.query(sql, title, this.id)) {
|
||||
try (ResultSet rs = DatabaseManager.instance.query(sql, title, getId())) {
|
||||
if (rs != null && rs.next()) {
|
||||
this.title = title;
|
||||
this.title.value = title;
|
||||
return true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
MiniPlayerTitle.database.handleDatabaseError("更新称号失败", e, sql);
|
||||
handleDatabaseError("更新称号失败", e, sql);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -166,22 +124,22 @@ public class TitleDTO {
|
||||
public boolean updateDescription(String description) {
|
||||
String sql = "";
|
||||
sql += "UPDATE mplt_title SET description = ? WHERE id = ?;";
|
||||
try (ResultSet rs = MiniPlayerTitle.database.query(sql, description, this.id)) {
|
||||
try (ResultSet rs = DatabaseManager.instance.query(sql, description, getId())) {
|
||||
if (rs != null && rs.next()) {
|
||||
this.description = description;
|
||||
this.description.value = description;
|
||||
return true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
MiniPlayerTitle.database.handleDatabaseError("更新称号失败", e, sql);
|
||||
handleDatabaseError("更新称号失败", e, sql);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static TitleDTO getTitleDTO(ResultSet rs) throws SQLException {
|
||||
TitleDTO titleDTO = new TitleDTO();
|
||||
titleDTO.id = rs.getInt("id");
|
||||
titleDTO.title = rs.getString("title");
|
||||
titleDTO.description = rs.getString("description");
|
||||
titleDTO.id.value = rs.getInt("id");
|
||||
titleDTO.title.value = rs.getString("title");
|
||||
titleDTO.description.value = rs.getString("description");
|
||||
return titleDTO;
|
||||
}
|
||||
}
|
||||
|
@ -1,22 +1,27 @@
|
||||
package cn.lunadeer.miniplayertitle.dtos;
|
||||
|
||||
import cn.lunadeer.miniplayertitle.MiniPlayerTitle;
|
||||
import cn.lunadeer.minecraftpluginutils.databse.DatabaseManager;
|
||||
import cn.lunadeer.minecraftpluginutils.databse.Field;
|
||||
import cn.lunadeer.minecraftpluginutils.databse.FieldType;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.lunadeer.minecraftpluginutils.databse.DatabaseManager.handleDatabaseError;
|
||||
|
||||
public class TitleShopDTO {
|
||||
private Integer id;
|
||||
private TitleDTO title;
|
||||
private Double price;
|
||||
private Integer days;
|
||||
private Integer amount;
|
||||
private final Field id = new Field("id", FieldType.INT);
|
||||
private final Field price = new Field("price_d", FieldType.DOUBLE);
|
||||
private final Field days = new Field("days", FieldType.INT);
|
||||
private final Field amount = new Field("amount", FieldType.INT);
|
||||
|
||||
private LocalDateTime sale_end_at;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
return (Integer) id.value;
|
||||
}
|
||||
|
||||
public TitleDTO getTitle() {
|
||||
@ -24,46 +29,49 @@ public class TitleShopDTO {
|
||||
}
|
||||
|
||||
public Double getPrice() {
|
||||
return price;
|
||||
return (Double) price.value;
|
||||
}
|
||||
|
||||
public boolean setPrice(Double price) {
|
||||
String sql = "";
|
||||
sql += "UPDATE mplt_title_shop SET price_d = ? WHERE id = ?;";
|
||||
try (ResultSet rs = MiniPlayerTitle.database.query(sql, price, id)) {
|
||||
try (ResultSet rs = DatabaseManager.instance.query(sql, price, getId())) {
|
||||
this.price.value = price;
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
MiniPlayerTitle.database.handleDatabaseError("设置称号商店价格失败", e, sql);
|
||||
handleDatabaseError("设置称号商店价格失败", e, sql);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public Integer getDays() {
|
||||
return days;
|
||||
return (Integer) days.value;
|
||||
}
|
||||
|
||||
public boolean setDays(int days) {
|
||||
String sql = "";
|
||||
sql += "UPDATE mplt_title_shop SET days = ? WHERE id = ?;";
|
||||
try (ResultSet rs = MiniPlayerTitle.database.query(sql, days, id)) {
|
||||
try (ResultSet rs = DatabaseManager.instance.query(sql, days, getId())) {
|
||||
this.days.value = days;
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
MiniPlayerTitle.database.handleDatabaseError("设置称号商店天数失败", e, sql);
|
||||
handleDatabaseError("设置称号商店天数失败", e, sql);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public Integer getAmount() {
|
||||
return amount;
|
||||
return (Integer) amount.value;
|
||||
}
|
||||
|
||||
public boolean setAmount(int amount) {
|
||||
String sql = "";
|
||||
sql += "UPDATE mplt_title_shop SET amount = ? WHERE id = ?;";
|
||||
try (ResultSet rs = MiniPlayerTitle.database.query(sql, amount, id)) {
|
||||
try (ResultSet rs = DatabaseManager.instance.query(sql, amount, getId())) {
|
||||
this.amount.value = amount;
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
MiniPlayerTitle.database.handleDatabaseError("设置称号商店数量失败", e, sql);
|
||||
handleDatabaseError("设置称号商店数量失败", e, sql);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -79,10 +87,10 @@ public class TitleShopDTO {
|
||||
public boolean setSaleEndAt(int y, int m, int d) {
|
||||
String sql = "";
|
||||
sql += "UPDATE mplt_title_shop SET sale_end_at_y = ?, sale_end_at_m = ?, sale_end_at_d = ? WHERE id = ?;";
|
||||
try (ResultSet rs = MiniPlayerTitle.database.query(sql, y, m, d, id)) {
|
||||
try (ResultSet rs = DatabaseManager.instance.query(sql, y, m, d, getId())) {
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
MiniPlayerTitle.database.handleDatabaseError("设置称号商店销售结束时间失败", e, sql);
|
||||
handleDatabaseError("设置称号商店销售结束时间失败", e, sql);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -91,12 +99,12 @@ public class TitleShopDTO {
|
||||
String sql = "";
|
||||
sql += "SELECT id, title_id, price_d, days, amount, sale_end_at_y, sale_end_at_m, sale_end_at_d " +
|
||||
"FROM mplt_title_shop WHERE id = ?;";
|
||||
try (ResultSet rs = MiniPlayerTitle.database.query(sql, id)) {
|
||||
try (ResultSet rs = DatabaseManager.instance.query(sql, id)) {
|
||||
if (rs.next()) {
|
||||
return getTitleShop(rs);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
MiniPlayerTitle.database.handleDatabaseError("获取称号商店信息失败", e, sql);
|
||||
handleDatabaseError("获取称号商店信息失败", e, sql);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -106,24 +114,24 @@ public class TitleShopDTO {
|
||||
sql += "SELECT id, title_id, price_d, days, amount, sale_end_at_y, sale_end_at_m, sale_end_at_d " +
|
||||
"FROM mplt_title_shop;";
|
||||
List<TitleShopDTO> titleShops = new ArrayList<>();
|
||||
try (ResultSet rs = MiniPlayerTitle.database.query(sql)) {
|
||||
try (ResultSet rs = DatabaseManager.instance.query(sql)) {
|
||||
while (rs != null && rs.next()) {
|
||||
TitleShopDTO titleShop = getTitleShop(rs);
|
||||
titleShops.add(titleShop);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
MiniPlayerTitle.database.handleDatabaseError("获取称号商店列表失败", e, sql);
|
||||
handleDatabaseError("获取称号商店列表失败", e, sql);
|
||||
}
|
||||
return titleShops;
|
||||
}
|
||||
|
||||
private static TitleShopDTO getTitleShop(ResultSet rs) throws Exception {
|
||||
TitleShopDTO titleShop = new TitleShopDTO();
|
||||
titleShop.id = rs.getInt("id");
|
||||
titleShop.id.value = rs.getInt("id");
|
||||
titleShop.title = TitleDTO.get(rs.getInt("title_id"));
|
||||
titleShop.price = rs.getDouble("price_d");
|
||||
titleShop.days = rs.getInt("days");
|
||||
titleShop.amount = rs.getInt("amount");
|
||||
titleShop.price.value = rs.getDouble("price_d");
|
||||
titleShop.days.value = rs.getInt("days");
|
||||
titleShop.amount.value = rs.getInt("amount");
|
||||
int y = rs.getInt("sale_end_at_y");
|
||||
int m = rs.getInt("sale_end_at_m");
|
||||
int d = rs.getInt("sale_end_at_d");
|
||||
@ -141,12 +149,12 @@ public class TitleShopDTO {
|
||||
"VALUES (?, 0, -1, 0, -1, -1, -1) " +
|
||||
"RETURNING " +
|
||||
"id, title_id, price_d, days, amount, sale_end_at_y, sale_end_at_m, sale_end_at_d;";
|
||||
try (ResultSet rs = MiniPlayerTitle.database.query(sql, title.getId())) {
|
||||
try (ResultSet rs = DatabaseManager.instance.query(sql, title.getId())) {
|
||||
if (rs.next()) {
|
||||
return getTitleShop(rs);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
MiniPlayerTitle.database.handleDatabaseError("创建称号商店失败", e, sql);
|
||||
handleDatabaseError("创建称号商店失败", e, sql);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -154,10 +162,10 @@ public class TitleShopDTO {
|
||||
public boolean delete() {
|
||||
String sql = "";
|
||||
sql += "DELETE FROM mplt_title_shop WHERE id = ?;";
|
||||
try (ResultSet rs = MiniPlayerTitle.database.query(sql, id)) {
|
||||
try (ResultSet rs = DatabaseManager.instance.query(sql, getId())) {
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
MiniPlayerTitle.database.handleDatabaseError("删除称号商店失败", e, sql);
|
||||
handleDatabaseError("删除称号商店失败", e, sql);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -1,16 +1,13 @@
|
||||
package cn.lunadeer.miniplayertitle;
|
||||
package cn.lunadeer.miniplayertitle.events;
|
||||
|
||||
import cn.lunadeer.minecraftpluginutils.Notification;
|
||||
import cn.lunadeer.miniplayertitle.dtos.PlayerInfoDTO;
|
||||
import cn.lunadeer.miniplayertitle.dtos.PlayerTitleDTO;
|
||||
import io.papermc.paper.event.player.AsyncChatEvent;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
|
||||
import static cn.lunadeer.miniplayertitle.MiniPlayerTitle.usingPapi;
|
||||
import static cn.lunadeer.miniplayertitle.commands.Apis.updateName;
|
||||
|
||||
public class Events implements Listener {
|
||||
@ -36,19 +33,4 @@ public class Events implements Listener {
|
||||
updateName(bukkitPlayer, title.getTitle());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerSendChat(AsyncChatEvent event) {
|
||||
if (usingPapi()) {
|
||||
return;
|
||||
}
|
||||
Component nameComponent = event.getPlayer().displayName();
|
||||
Component chatComponent = event.message();
|
||||
Component newChatComponent = Component.text()
|
||||
.append(nameComponent)
|
||||
.append(Component.text(" "))
|
||||
.append(chatComponent).build();
|
||||
event.setCancelled(true);
|
||||
event.getPlayer().getServer().sendMessage(newChatComponent);
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package cn.lunadeer.miniplayertitle.events;
|
||||
|
||||
import io.papermc.paper.event.player.AsyncChatEvent;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import static cn.lunadeer.miniplayertitle.MiniPlayerTitle.usingPapi;
|
||||
|
||||
public class PaperChat implements Listener {
|
||||
@EventHandler
|
||||
public void onPlayerSendChat(AsyncChatEvent event) {
|
||||
if (usingPapi()) {
|
||||
return;
|
||||
}
|
||||
Component nameComponent = event.getPlayer().displayName();
|
||||
Component chatComponent = event.message();
|
||||
Component newChatComponent = Component.text()
|
||||
.append(nameComponent)
|
||||
.append(Component.text(" "))
|
||||
.append(chatComponent).build();
|
||||
event.setCancelled(true);
|
||||
event.getPlayer().getServer().sendMessage(newChatComponent);
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package cn.lunadeer.miniplayertitle.events;
|
||||
|
||||
import cn.lunadeer.miniplayertitle.MiniPlayerTitle;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerChatEvent;
|
||||
|
||||
import static cn.lunadeer.miniplayertitle.MiniPlayerTitle.usingPapi;
|
||||
|
||||
public class SpigotChat implements Listener {
|
||||
@EventHandler
|
||||
public void onPlayerSendChat(PlayerChatEvent event) {
|
||||
if (usingPapi()) {
|
||||
return;
|
||||
}
|
||||
event.setCancelled(true);
|
||||
MiniPlayerTitle.instance.getServer().broadcastMessage(event.getPlayer().getDisplayName() + " " + event.getMessage());
|
||||
}
|
||||
}
|
@ -32,7 +32,7 @@ public class AllTitles {
|
||||
Line line = Line.create()
|
||||
.append(title.getId().toString())
|
||||
.append(title.getTitleColored());
|
||||
if (player.isOp()) {
|
||||
if (player.hasPermission("mplt.admin")) {
|
||||
line.append(Button.createRed("删除").setExecuteCommand("/mplt delete_title " + title.getId() + " " + page).build());
|
||||
line.append(Button.createGreen("创建商品").setExecuteCommand("/mplt create_sale " + title.getId()).build());
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package cn.lunadeer.miniplayertitle.tuis;
|
||||
|
||||
import cn.lunadeer.minecraftpluginutils.Notification;
|
||||
import cn.lunadeer.minecraftpluginutils.VaultConnect;
|
||||
import cn.lunadeer.minecraftpluginutils.VaultConnect.VaultConnect;
|
||||
import cn.lunadeer.minecraftpluginutils.stui.ListView;
|
||||
import cn.lunadeer.minecraftpluginutils.stui.components.Button;
|
||||
import cn.lunadeer.minecraftpluginutils.stui.components.Line;
|
||||
@ -58,7 +58,7 @@ public class Menu {
|
||||
Line all = Line.create()
|
||||
.append(Button.create("所有称号").setExecuteCommand("/mplt all_titles").build()).append("查看所有称号");
|
||||
|
||||
if (player.isOp()) {
|
||||
if (player.hasPermission("mplt.admin")) {
|
||||
view.add(Line.create().append(""));
|
||||
view.add(Line.create().append("---以下选项仅OP可见---"));
|
||||
view.add(all);
|
||||
|
@ -47,7 +47,7 @@ public class MyTitles {
|
||||
} else {
|
||||
line.append("有效期至: " + title.getExpireAt().getYear() + "年" + title.getExpireAt().getMonthValue() + "月" + title.getExpireAt().getDayOfMonth() + "日");
|
||||
}
|
||||
if (Objects.equals(playerInfo.getUsingTitle().getId(), title.getId())) {
|
||||
if (Objects.equals(playerInfo.getUsingTitle().getId(), title.getTitle().getId())) {
|
||||
line.append(Button.createRed("卸下").setExecuteCommand("/mplt use_title -1 " + page).build());
|
||||
} else {
|
||||
line.append(Button.createGreen("使用").setExecuteCommand("/mplt use_title " + title.getId() + " " + page).build());
|
||||
|
@ -46,11 +46,11 @@ public class SaleInfo {
|
||||
Line price = Line.create().append("价格: ");
|
||||
if (titleShop.getPrice() <= 0) {
|
||||
price.append("免费");
|
||||
if (player.isOp()) {
|
||||
if (player.hasPermission("mplt.admin")) {
|
||||
price.append(Button.create("设置价格").setExecuteCommand("/mplt set_sale price " + titleShop.getId() + " 100 " + page).build());
|
||||
}
|
||||
} else {
|
||||
if (player.isOp()) {
|
||||
if (player.hasPermission("mplt.admin")) {
|
||||
price.append(NumChanger.create(titleShop.getPrice(), "/mplt set_sale price " + titleShop.getId()).setPageNumber(page).build());
|
||||
price.append(Button.create("设置为免费").setExecuteCommand("/mplt set_sale price " + titleShop.getId() + " 0 " + page).build());
|
||||
} else {
|
||||
@ -62,11 +62,11 @@ public class SaleInfo {
|
||||
Line day = Line.create().append("购买天数: ");
|
||||
if (titleShop.getDays() <= 0) {
|
||||
day.append("永久");
|
||||
if (player.isOp()) {
|
||||
if (player.hasPermission("mplt.admin")) {
|
||||
day.append(Button.create("转为限时").setExecuteCommand("/mplt set_sale days " + titleShop.getId() + " 7 " + page).build());
|
||||
}
|
||||
} else {
|
||||
if (player.isOp()) {
|
||||
if (player.hasPermission("mplt.admin")) {
|
||||
day.append(NumChanger.create(titleShop.getDays(), "/mplt set_sale days " + titleShop.getId()).setPageNumber(page).build());
|
||||
day.append(Button.create("转为永久").setExecuteCommand("/mplt set_sale days " + titleShop.getId() + " -1 " + page).build());
|
||||
} else {
|
||||
@ -78,12 +78,12 @@ public class SaleInfo {
|
||||
Line amount = Line.create().append("剩余数量: ");
|
||||
if (titleShop.getAmount() == -1) {
|
||||
amount.append("无限");
|
||||
if (player.isOp()) {
|
||||
if (player.hasPermission("mplt.admin")) {
|
||||
amount.append(Button.create("转为限量").setExecuteCommand("/mplt set_sale amount " + titleShop.getId() + " 0 " + page).build());
|
||||
}
|
||||
} else {
|
||||
|
||||
if (player.isOp()) {
|
||||
if (player.hasPermission("mplt.admin")) {
|
||||
amount.append(NumChanger.create(titleShop.getAmount(), "/mplt set_sale amount " + titleShop.getId()).setPageNumber(page).build());
|
||||
amount.append(Button.create("转为无限").setExecuteCommand("/mplt set_sale amount " + titleShop.getId() + " -1 " + page).build());
|
||||
} else {
|
||||
@ -95,11 +95,11 @@ public class SaleInfo {
|
||||
Line end_at = Line.create().append("售卖结束时间: ");
|
||||
if (titleShop.getSaleEndAt() == null) {
|
||||
end_at.append("常驻");
|
||||
if (player.isOp()) {
|
||||
if (player.hasPermission("mplt.admin")) {
|
||||
end_at.append(Button.create("转为限时").setExecuteCommand("/mplt set_sale end_at " + titleShop.getId() + " " + now_year + ":" + now_month + ":" + now_day + " " + page).build());
|
||||
}
|
||||
} else {
|
||||
if (player.isOp()) {
|
||||
if (player.hasPermission("mplt.admin")) {
|
||||
end_at.append(Button.create("<<").setPreSufIx("", "").setHoverText("提前10天").setExecuteCommand("/mplt set_sale less_end_at " + titleShop.getId() + " 10 " + page).build()
|
||||
.append(Button.create("-").setPreSufIx("", "").setHoverText("提前1天").setExecuteCommand("/mplt set_sale less_end_at " + titleShop.getId() + " 1 " + page).build())
|
||||
.append(Component.text(titleShop.getSaleEndAt().getYear() + "年" + titleShop.getSaleEndAt().getMonthValue() + "月" + titleShop.getSaleEndAt().getDayOfMonth() + "日"))
|
||||
@ -120,8 +120,9 @@ public class SaleInfo {
|
||||
} else {
|
||||
operate.append(Button.createGreen("购买").setExecuteCommand("/mplt buy_sale " + titleShop.getId()).build());
|
||||
}
|
||||
if (player.isOp()) {
|
||||
if (player.hasPermission("mplt.admin")) {
|
||||
operate.append(Button.create("删除").setExecuteCommand("/mplt delete_sale " + args[1] + " b").build());
|
||||
operate.append(Button.createGreen("导出称号卡").setExecuteCommand("/mplt get_card " + args[1]).build());
|
||||
}
|
||||
view.add(Line.create().append("---------------------"));
|
||||
view.add(operate);
|
||||
|
@ -1,126 +1,172 @@
|
||||
package cn.lunadeer.miniplayertitle.utils;
|
||||
|
||||
import cn.lunadeer.miniplayertitle.MiniPlayerTitle;
|
||||
import cn.lunadeer.minecraftpluginutils.databse.DatabaseManager;
|
||||
import cn.lunadeer.minecraftpluginutils.databse.Field;
|
||||
import cn.lunadeer.minecraftpluginutils.databse.FieldType;
|
||||
import cn.lunadeer.minecraftpluginutils.databse.TableColumn;
|
||||
import cn.lunadeer.minecraftpluginutils.databse.syntax.AddColumn;
|
||||
import cn.lunadeer.minecraftpluginutils.databse.syntax.CreateTable;
|
||||
import cn.lunadeer.minecraftpluginutils.databse.syntax.InsertRow;
|
||||
import cn.lunadeer.minecraftpluginutils.databse.syntax.RemoveColumn;
|
||||
|
||||
import static cn.lunadeer.minecraftpluginutils.databse.Common.IsFieldExist;
|
||||
|
||||
public class DatabaseTables {
|
||||
|
||||
public static void migrate() {
|
||||
String sql = "";
|
||||
|
||||
// title table
|
||||
sql = "CREATE TABLE IF NOT EXISTS mplt_title (" +
|
||||
" id SERIAL PRIMARY KEY," +
|
||||
" title TEXT NOT NULL UNIQUE," +
|
||||
" description TEXT NOT NULL," +
|
||||
" enabled BOOLEAN NOT NULL DEFAULT TRUE," +
|
||||
" created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP," +
|
||||
" updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP" +
|
||||
");";
|
||||
MiniPlayerTitle.database.query(sql);
|
||||
TableColumn mplt_title_id = new TableColumn("id", FieldType.INT, true, true, true, true, 0);
|
||||
TableColumn mplt_title_title = new TableColumn("title", FieldType.STRING, false, false, true, false, "'unknown'");
|
||||
TableColumn mplt_title_description = new TableColumn("description", FieldType.STRING, false, false, true, false, "'unknown'");
|
||||
TableColumn mplt_title_enabled = new TableColumn("enabled", FieldType.BOOLEAN, false, false, true, false, "true");
|
||||
TableColumn mplt_title_created_at = new TableColumn("created_at", FieldType.DATETIME, false, false, true, false, "CURRENT_TIMESTAMP");
|
||||
TableColumn mplt_title_updated_at = new TableColumn("updated_at", FieldType.DATETIME, false, false, true, false, "CURRENT_TIMESTAMP");
|
||||
CreateTable mplt_title = new CreateTable().ifNotExists();
|
||||
mplt_title.table("mplt_title")
|
||||
.field(mplt_title_id)
|
||||
.field(mplt_title_title)
|
||||
.field(mplt_title_description)
|
||||
.field(mplt_title_enabled)
|
||||
.field(mplt_title_created_at)
|
||||
.field(mplt_title_updated_at);
|
||||
mplt_title.execute();
|
||||
|
||||
|
||||
// title shop table
|
||||
sql = "CREATE TABLE IF NOT EXISTS mplt_title_shop (" +
|
||||
" id SERIAL PRIMARY KEY," +
|
||||
" title_id INTEGER NOT NULL," +
|
||||
" price INTEGER NOT NULL DEFAULT 0," +
|
||||
" days INTEGER NOT NULL DEFAULT 0," +
|
||||
" amount INTEGER NOT NULL DEFAULT -1," +
|
||||
" sale_end_at BIGINT NOT NULL DEFAULT -1," +
|
||||
" created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP," +
|
||||
" updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP," +
|
||||
" FOREIGN KEY (title_id) REFERENCES mplt_title(id) ON DELETE CASCADE" +
|
||||
");";
|
||||
MiniPlayerTitle.database.query(sql);
|
||||
TableColumn mplt_title_shop_id = new TableColumn("id", FieldType.INT, true, true, true, true, 0);
|
||||
TableColumn mplt_title_shop_title_id = new TableColumn("title_id", FieldType.INT, false, false, true, false, 0);
|
||||
TableColumn mplt_title_shop_price = new TableColumn("price", FieldType.INT, false, false, true, false, 0);
|
||||
TableColumn mplt_title_shop_days = new TableColumn("days", FieldType.INT, false, false, true, false, 0);
|
||||
TableColumn mplt_title_shop_amount = new TableColumn("amount", FieldType.INT, false, false, true, false, -1);
|
||||
TableColumn mplt_title_shop_sale_end_at = new TableColumn("sale_end_at", FieldType.LONG, false, false, true, false, -1);
|
||||
TableColumn mplt_title_shop_created_at = new TableColumn("created_at", FieldType.DATETIME, false, false, true, false, "CURRENT_TIMESTAMP");
|
||||
TableColumn mplt_title_shop_updated_at = new TableColumn("updated_at", FieldType.DATETIME, false, false, true, false, "CURRENT_TIMESTAMP");
|
||||
CreateTable.ForeignKey mplt_title_shop_title_id_fk = new CreateTable.ForeignKey(mplt_title_shop_title_id, "mplt_title", mplt_title_id, true);
|
||||
CreateTable mplt_title_shop = new CreateTable().ifNotExists();
|
||||
mplt_title_shop.table("mplt_title_shop")
|
||||
.field(mplt_title_shop_id)
|
||||
.field(mplt_title_shop_title_id)
|
||||
.field(mplt_title_shop_price)
|
||||
.field(mplt_title_shop_days)
|
||||
.field(mplt_title_shop_amount)
|
||||
.field(mplt_title_shop_sale_end_at)
|
||||
.field(mplt_title_shop_created_at)
|
||||
.field(mplt_title_shop_updated_at)
|
||||
.foreignKey(mplt_title_shop_title_id_fk);
|
||||
mplt_title_shop.execute();
|
||||
|
||||
// player title info table
|
||||
sql = "CREATE TABLE IF NOT EXISTS mplt_player_info (" +
|
||||
" uuid UUID PRIMARY KEY," +
|
||||
" coin INTEGER NOT NULL DEFAULT 0," +
|
||||
" using_title_id INTEGER NOT NULL DEFAULT -1," +
|
||||
" created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP," +
|
||||
" updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP," +
|
||||
" FOREIGN KEY (using_title_id) REFERENCES mplt_title(id) ON DELETE CASCADE" +
|
||||
");";
|
||||
MiniPlayerTitle.database.query(sql);
|
||||
TableColumn mplt_player_info_uuid = new TableColumn("uuid", FieldType.UUID, true, false, true, false, "'00000000-0000-0000-0000-000000000000'");
|
||||
TableColumn mplt_player_info_coin = new TableColumn("coin", FieldType.INT, false, false, true, false, 0);
|
||||
TableColumn mplt_player_info_using_title_id = new TableColumn("using_title_id", FieldType.INT, false, false, true, false, -1);
|
||||
TableColumn mplt_player_info_created_at = new TableColumn("created_at", FieldType.DATETIME, false, false, true, false, "CURRENT_TIMESTAMP");
|
||||
TableColumn mplt_player_info_updated_at = new TableColumn("updated_at", FieldType.DATETIME, false, false, true, false, "CURRENT_TIMESTAMP");
|
||||
CreateTable.ForeignKey mplt_player_info_using_title_id_fk = new CreateTable.ForeignKey(mplt_player_info_using_title_id, "mplt_title", mplt_title_id, true);
|
||||
CreateTable mplt_player_info = new CreateTable().ifNotExists();
|
||||
mplt_player_info.table("mplt_player_info")
|
||||
.field(mplt_player_info_uuid)
|
||||
.field(mplt_player_info_coin)
|
||||
.field(mplt_player_info_using_title_id)
|
||||
.field(mplt_player_info_created_at)
|
||||
.field(mplt_player_info_updated_at)
|
||||
.foreignKey(mplt_player_info_using_title_id_fk);
|
||||
mplt_player_info.execute();
|
||||
|
||||
|
||||
// player title table
|
||||
sql = "CREATE TABLE IF NOT EXISTS mplt_player_title (" +
|
||||
" id SERIAL PRIMARY KEY," +
|
||||
" player_uuid UUID NOT NULL," +
|
||||
" title_id INTEGER NOT NULL," +
|
||||
" expire_at BIGINT NOT NULL DEFAULT -1," +
|
||||
" created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP," +
|
||||
" updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP," +
|
||||
" FOREIGN KEY (title_id) REFERENCES mplt_title(id) ON DELETE CASCADE," +
|
||||
" FOREIGN KEY (player_uuid) REFERENCES mplt_player_info(uuid) ON DELETE CASCADE" +
|
||||
");";
|
||||
MiniPlayerTitle.database.query(sql);
|
||||
TableColumn mplt_player_title_id = new TableColumn("id", FieldType.INT, true, true, true, true, 0);
|
||||
TableColumn mplt_player_title_player_uuid = new TableColumn("player_uuid", FieldType.UUID, false, false, true, false, "'00000000-0000-0000-0000-000000000000'");
|
||||
TableColumn mplt_player_title_title_id = new TableColumn("title_id", FieldType.INT, false, false, true, false, 0);
|
||||
TableColumn mplt_player_title_expire_at = new TableColumn("expire_at", FieldType.LONG, false, false, true, false, -1);
|
||||
TableColumn mplt_player_title_created_at = new TableColumn("created_at", FieldType.DATETIME, false, false, true, false, "CURRENT_TIMESTAMP");
|
||||
TableColumn mplt_player_title_updated_at = new TableColumn("updated_at", FieldType.DATETIME, false, false, true, false, "CURRENT_TIMESTAMP");
|
||||
CreateTable.ForeignKey mplt_player_title_title_id_fk = new CreateTable.ForeignKey(mplt_player_title_title_id, "mplt_title", mplt_title_id, true);
|
||||
CreateTable.ForeignKey mplt_player_title_player_uuid_fk = new CreateTable.ForeignKey(mplt_player_title_player_uuid, "mplt_player_info", mplt_player_info_uuid, true);
|
||||
CreateTable mplt_player_title = new CreateTable().ifNotExists();
|
||||
mplt_player_title.table("mplt_player_title")
|
||||
.field(mplt_player_title_id)
|
||||
.field(mplt_player_title_player_uuid)
|
||||
.field(mplt_player_title_title_id)
|
||||
.field(mplt_player_title_expire_at)
|
||||
.field(mplt_player_title_created_at)
|
||||
.field(mplt_player_title_updated_at)
|
||||
.foreignKey(mplt_player_title_title_id_fk)
|
||||
.foreignKey(mplt_player_title_player_uuid_fk);
|
||||
mplt_player_title.execute();
|
||||
|
||||
MiniPlayerTitle.database.deleteColumnIfExists("mplt_title", "created_at");
|
||||
MiniPlayerTitle.database.deleteColumnIfExists("mplt_title", "updated_at");
|
||||
MiniPlayerTitle.database.deleteColumnIfExists("mplt_title", "enabled");
|
||||
new RemoveColumn("expire_at").IfExists().table("mplt_title").execute();
|
||||
new RemoveColumn("sale_end_at").IfExists().table("mplt_title_shop").execute();
|
||||
new RemoveColumn("expire_at").IfExists().table("mplt_player_title").execute();
|
||||
new RemoveColumn("created_at").IfExists().table("mplt_title").execute();
|
||||
new RemoveColumn("updated_at").IfExists().table("mplt_title").execute();
|
||||
new RemoveColumn("created_at").IfExists().table("mplt_player_info").execute();
|
||||
new RemoveColumn("updated_at").IfExists().table("mplt_player_info").execute();
|
||||
new RemoveColumn("created_at").IfExists().table("mplt_player_title").execute();
|
||||
new RemoveColumn("updated_at").IfExists().table("mplt_player_title").execute();
|
||||
|
||||
MiniPlayerTitle.database.deleteColumnIfExists("mplt_title_shop", "created_at");
|
||||
MiniPlayerTitle.database.deleteColumnIfExists("mplt_title_shop", "updated_at");
|
||||
|
||||
MiniPlayerTitle.database.deleteColumnIfExists("mplt_player_info", "created_at");
|
||||
MiniPlayerTitle.database.deleteColumnIfExists("mplt_player_info", "updated_at");
|
||||
|
||||
MiniPlayerTitle.database.deleteColumnIfExists("mplt_player_title", "created_at");
|
||||
MiniPlayerTitle.database.deleteColumnIfExists("mplt_player_title", "updated_at");
|
||||
|
||||
MiniPlayerTitle.database.addColumnIfNotExists("mplt_title_shop", "sale_end_at_y", "INTEGER NOT NULL DEFAULT -1");
|
||||
MiniPlayerTitle.database.addColumnIfNotExists("mplt_title_shop", "sale_end_at_m", "INTEGER NOT NULL DEFAULT -1");
|
||||
MiniPlayerTitle.database.addColumnIfNotExists("mplt_title_shop", "sale_end_at_d", "INTEGER NOT NULL DEFAULT -1");
|
||||
TableColumn mplt_title_shop_sale_end_at_y = new TableColumn("sale_end_at_y", FieldType.INT, false, false, true, false, -1);
|
||||
TableColumn mplt_title_shop_sale_end_at_m = new TableColumn("sale_end_at_m", FieldType.INT, false, false, true, false, -1);
|
||||
TableColumn mplt_title_shop_sale_end_at_d = new TableColumn("sale_end_at_d", FieldType.INT, false, false, true, false, -1);
|
||||
new AddColumn(mplt_title_shop_sale_end_at_y).table("mplt_title_shop").ifNotExists().execute();
|
||||
new AddColumn(mplt_title_shop_sale_end_at_m).table("mplt_title_shop").ifNotExists().execute();
|
||||
new AddColumn(mplt_title_shop_sale_end_at_d).table("mplt_title_shop").ifNotExists().execute();
|
||||
// convert sale_end_at(YYYYMMDD) to sale_end_at_y, sale_end_at_m, sale_end_at_d if sale_end_at column exists
|
||||
if (MiniPlayerTitle.database.isColumnExist("mplt_title_shop", "sale_end_at")) {
|
||||
sql = "UPDATE mplt_title_shop SET " +
|
||||
if (IsFieldExist("mplt_title_shop", "sale_end_at")) {
|
||||
String sql = "UPDATE mplt_title_shop SET " +
|
||||
"sale_end_at_y = (sale_end_at / 10000), " +
|
||||
"sale_end_at_m = (sale_end_at % 10000 / 100), " +
|
||||
"sale_end_at_d = (sale_end_at % 100) " +
|
||||
"WHERE sale_end_at != -1;";
|
||||
MiniPlayerTitle.database.query(sql);
|
||||
DatabaseManager.instance.query(sql);
|
||||
new RemoveColumn("sale_end_at").IfExists().table("mplt_title_shop").execute();
|
||||
}
|
||||
MiniPlayerTitle.database.deleteColumnIfExists("mplt_title_shop", "sale_end_at");
|
||||
|
||||
MiniPlayerTitle.database.addColumnIfNotExists("mplt_player_title", "expire_at_y", "INTEGER NOT NULL DEFAULT -1");
|
||||
MiniPlayerTitle.database.addColumnIfNotExists("mplt_player_title", "expire_at_m", "INTEGER NOT NULL DEFAULT -1");
|
||||
MiniPlayerTitle.database.addColumnIfNotExists("mplt_player_title", "expire_at_d", "INTEGER NOT NULL DEFAULT -1");
|
||||
if (MiniPlayerTitle.database.isColumnExist("mplt_player_title", "expire_at")) {
|
||||
sql = "UPDATE mplt_player_title SET " +
|
||||
|
||||
TableColumn mplt_player_title_expire_at_y = new TableColumn("expire_at_y", FieldType.INT, false, false, true, false, -1);
|
||||
TableColumn mplt_player_title_expire_at_m = new TableColumn("expire_at_m", FieldType.INT, false, false, true, false, -1);
|
||||
TableColumn mplt_player_title_expire_at_d = new TableColumn("expire_at_d", FieldType.INT, false, false, true, false, -1);
|
||||
new AddColumn(mplt_player_title_expire_at_y).table("mplt_player_title").ifNotExists().execute();
|
||||
new AddColumn(mplt_player_title_expire_at_m).table("mplt_player_title").ifNotExists().execute();
|
||||
new AddColumn(mplt_player_title_expire_at_d).table("mplt_player_title").ifNotExists().execute();
|
||||
|
||||
if (IsFieldExist("mplt_player_title", "expire_at")) {
|
||||
String sql = "UPDATE mplt_player_title SET " +
|
||||
"expire_at_y = (expire_at / 10000), " +
|
||||
"expire_at_m = (expire_at % 10000 / 100), " +
|
||||
"expire_at_d = (expire_at % 100) " +
|
||||
"WHERE expire_at != -1;";
|
||||
MiniPlayerTitle.database.query(sql);
|
||||
DatabaseManager.instance.query(sql);
|
||||
new RemoveColumn("expire_at").IfExists().table("mplt_player_title").execute();
|
||||
}
|
||||
MiniPlayerTitle.database.deleteColumnIfExists("mplt_player_title", "expire_at");
|
||||
|
||||
sql = "INSERT INTO mplt_title (" +
|
||||
"id, " +
|
||||
"title, " +
|
||||
"description " +
|
||||
") VALUES (" +
|
||||
"-1, " +
|
||||
"'default', " +
|
||||
"'default' " +
|
||||
") ON CONFLICT (id) DO NOTHING;";
|
||||
MiniPlayerTitle.database.query(sql);
|
||||
Field mplt_title_id_field = new Field("id", -1);
|
||||
Field mplt_title_title_field = new Field("title", "default");
|
||||
Field mplt_title_description_field = new Field("description", "default");
|
||||
InsertRow mplt_title_default = new InsertRow().table("mplt_title");
|
||||
mplt_title_default.field(mplt_title_id_field)
|
||||
.field(mplt_title_title_field)
|
||||
.field(mplt_title_description_field).onConflictDoNothing(mplt_title_id_field);
|
||||
mplt_title_default.execute();
|
||||
|
||||
MiniPlayerTitle.database.addColumnIfNotExists("mplt_player_info", "last_use_name", "TEXT NOT NULL DEFAULT 'null'");
|
||||
|
||||
TableColumn mplt_player_info_last_use_name = new TableColumn("last_use_name", FieldType.STRING, false, false, true, false, "'null'");
|
||||
new AddColumn(mplt_player_info_last_use_name).table("mplt_player_info").ifNotExists().execute();
|
||||
|
||||
// 3.0.6
|
||||
MiniPlayerTitle.database.addColumnIfNotExists("mplt_player_info", "coin_d", "DOUBLE PRECISION NOT NULL DEFAULT 0");
|
||||
MiniPlayerTitle.database.addColumnIfNotExists("mplt_title_shop", "price_d", "DOUBLE PRECISION NOT NULL DEFAULT 0");
|
||||
if (MiniPlayerTitle.database.isColumnExist("mplt_player_info", "coin")) {
|
||||
sql = "UPDATE mplt_player_info SET coin_d = coin;";
|
||||
MiniPlayerTitle.database.query(sql);
|
||||
TableColumn mplt_player_info_coin_d = new TableColumn("coin_d", FieldType.DOUBLE, false, false, true, false, 0);
|
||||
TableColumn mplt_title_shop_price_d = new TableColumn("price_d", FieldType.DOUBLE, false, false, true, false, 0);
|
||||
new AddColumn(mplt_player_info_coin_d).table("mplt_player_info").ifNotExists().execute();
|
||||
new AddColumn(mplt_title_shop_price_d).table("mplt_title_shop").ifNotExists().execute();
|
||||
if (IsFieldExist("mplt_player_info", "coin")) {
|
||||
String sql = "UPDATE mplt_player_info SET coin_d = coin;";
|
||||
DatabaseManager.instance.query(sql);
|
||||
new RemoveColumn("coin").IfExists().table("mplt_player_info").execute();
|
||||
}
|
||||
if (MiniPlayerTitle.database.isColumnExist("mplt_title_shop", "price")) {
|
||||
sql = "UPDATE mplt_title_shop SET price_d = price;";
|
||||
MiniPlayerTitle.database.query(sql);
|
||||
if (IsFieldExist("mplt_title_shop", "price")) {
|
||||
String sql = "UPDATE mplt_title_shop SET price_d = price;";
|
||||
DatabaseManager.instance.query(sql);
|
||||
new RemoveColumn("price").IfExists().table("mplt_title_shop").execute();
|
||||
}
|
||||
MiniPlayerTitle.database.deleteColumnIfExists("mplt_player_info", "coin");
|
||||
MiniPlayerTitle.database.deleteColumnIfExists("mplt_title_shop", "price");
|
||||
}
|
||||
}
|
||||
|
@ -5,9 +5,20 @@ api-version: '1.20'
|
||||
description: 称号插件。
|
||||
website: https://lunadeer.cn
|
||||
folia-supported: true
|
||||
softdepend: [PlaceholderAPI, Vault]
|
||||
softdepend: [ PlaceholderAPI, Vault ]
|
||||
commands:
|
||||
MiniPlayerTitle:
|
||||
description: 称号插件命令
|
||||
usage: /mplt <cmd>
|
||||
aliases: [mplt]
|
||||
aliases: [ mplt ]
|
||||
permission: mplt.command
|
||||
permissions:
|
||||
mplt.command:
|
||||
description: 普通命令
|
||||
default: true
|
||||
mplt.custom:
|
||||
description: 是否可以自定义称号
|
||||
default: true
|
||||
mplt.admin:
|
||||
description: 是否可以使用管理员命令
|
||||
default: op
|
||||
|
Loading…
Reference in New Issue
Block a user