rename project
This commit is contained in:
parent
7b41d0f591
commit
52805b0720
6
pom.xml
6
pom.xml
@ -5,11 +5,11 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<groupId>cn.lunadeer</groupId>
|
<groupId>cn.lunadeer</groupId>
|
||||||
<artifactId>NewbTitle</artifactId>
|
<artifactId>MiniPlayerTitle</artifactId>
|
||||||
<version>0.36-alpha</version>
|
<version>1.2-beta</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>NewbTitle</name>
|
<name>MiniPlayerTitle</name>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<java.version>1.8</java.version>
|
<java.version>1.8</java.version>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package cn.lunadeer.newbtitle;
|
package cn.lunadeer.miniplayertitle;
|
||||||
|
|
||||||
import cn.lunadeer.newbtitle.utils.XLogger;
|
import cn.lunadeer.miniplayertitle.utils.XLogger;
|
||||||
import net.kyori.adventure.text.format.Style;
|
import net.kyori.adventure.text.format.Style;
|
||||||
import net.kyori.adventure.text.format.TextColor;
|
import net.kyori.adventure.text.format.TextColor;
|
||||||
|
|
@ -1,8 +1,8 @@
|
|||||||
package cn.lunadeer.newbtitle;
|
package cn.lunadeer.miniplayertitle;
|
||||||
|
|
||||||
import cn.lunadeer.newbtitle.commands.AdminCommands;
|
import cn.lunadeer.miniplayertitle.commands.AdminCommands;
|
||||||
import cn.lunadeer.newbtitle.utils.Notification;
|
import cn.lunadeer.miniplayertitle.utils.Notification;
|
||||||
import cn.lunadeer.newbtitle.utils.XLogger;
|
import cn.lunadeer.miniplayertitle.utils.XLogger;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.command.TabExecutor;
|
import org.bukkit.command.TabExecutor;
|
||||||
@ -15,7 +15,7 @@ import java.util.Arrays;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static cn.lunadeer.newbtitle.commands.PlayerCommands.*;
|
import static cn.lunadeer.miniplayertitle.commands.PlayerCommands.*;
|
||||||
|
|
||||||
public class Commands implements TabExecutor {
|
public class Commands implements TabExecutor {
|
||||||
/**
|
/**
|
||||||
@ -33,7 +33,7 @@ public class Commands implements TabExecutor {
|
|||||||
@Override
|
@Override
|
||||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||||
switch (label) {
|
switch (label) {
|
||||||
case "nt":
|
case "mplt":
|
||||||
if (args.length == 0) {
|
if (args.length == 0) {
|
||||||
printHelp(sender);
|
printHelp(sender);
|
||||||
return true;
|
return true;
|
||||||
@ -79,13 +79,13 @@ public class Commands implements TabExecutor {
|
|||||||
private void printHelp(@NotNull CommandSender sender) {
|
private void printHelp(@NotNull CommandSender sender) {
|
||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
Notification.warn(player, "用法: /nt <use|list|shop|buy>");
|
Notification.warn(player, "用法: /mplt <use|list|shop|buy>");
|
||||||
if (player.isOp()) {
|
if (player.isOp()) {
|
||||||
Notification.warn(player, "用法: /nt <create|delete|setdesc|setname|addshop|removeshop|setprice|setamount|setendat|listall>");
|
Notification.warn(player, "用法: /mplt <create|delete|setdesc|setname|addshop|removeshop|setprice|setamount|setendat|listall>");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
XLogger.info("用法: /nt <use|list|shop|buy>");
|
XLogger.info("用法: /mplt <use|list|shop|buy>");
|
||||||
XLogger.info("用法: /nt <create|delete|setdesc|setname|addshop|removeshop|setprice|setamount|setendat|listall>");
|
XLogger.info("用法: /mplt <create|delete|setdesc|setname|addshop|removeshop|setprice|setamount|setendat|listall>");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,9 +104,7 @@ public class Commands implements TabExecutor {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public @Nullable List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
public @Nullable List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||||
switch (label) {
|
if (args.length == 1) {
|
||||||
case "nt":
|
|
||||||
if (args.length == 0) {
|
|
||||||
String[] player_cmd = {"use", "list", "shop", "buy"};
|
String[] player_cmd = {"use", "list", "shop", "buy"};
|
||||||
String[] admin_cmd = {"create", "delete", "setdesc", "setname", "addshop", "removeshop", "setprice", "setamount", "setendat", "listall"};
|
String[] admin_cmd = {"create", "delete", "setdesc", "setname", "addshop", "removeshop", "setprice", "setamount", "setendat", "listall"};
|
||||||
List<String> res = new ArrayList<>();
|
List<String> res = new ArrayList<>();
|
||||||
@ -152,9 +150,7 @@ public class Commands implements TabExecutor {
|
|||||||
default:
|
default:
|
||||||
return Arrays.asList("use", "list", "shop", "buy");
|
return Arrays.asList("use", "list", "shop", "buy");
|
||||||
}
|
}
|
||||||
default:
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package cn.lunadeer.newbtitle;
|
package cn.lunadeer.miniplayertitle;
|
||||||
|
|
||||||
import io.papermc.paper.event.player.AsyncChatEvent;
|
import io.papermc.paper.event.player.AsyncChatEvent;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
@ -27,7 +27,7 @@ public class Events implements Listener {
|
|||||||
.append(chatComponent).build();
|
.append(chatComponent).build();
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
event.getPlayer().getServer().sendMessage(newChatComponent);
|
event.getPlayer().getServer().sendMessage(newChatComponent);
|
||||||
}
|
} else {
|
||||||
Component titleComponent = title.getTitle();
|
Component titleComponent = title.getTitle();
|
||||||
Component newChatComponent = Component.text().append(titleComponent)
|
Component newChatComponent = Component.text().append(titleComponent)
|
||||||
.append(Component.text("<"))
|
.append(Component.text("<"))
|
||||||
@ -38,3 +38,4 @@ public class Events implements Listener {
|
|||||||
event.getPlayer().getServer().sendMessage(newChatComponent);
|
event.getPlayer().getServer().sendMessage(newChatComponent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
@ -1,14 +1,14 @@
|
|||||||
package cn.lunadeer.newbtitle;
|
package cn.lunadeer.miniplayertitle;
|
||||||
|
|
||||||
import cn.lunadeer.newbtitle.utils.ConfigManager;
|
import cn.lunadeer.miniplayertitle.utils.ConfigManager;
|
||||||
import cn.lunadeer.newbtitle.utils.Database;
|
import cn.lunadeer.miniplayertitle.utils.Database;
|
||||||
import cn.lunadeer.newbtitle.utils.XLogger;
|
import cn.lunadeer.miniplayertitle.utils.XLogger;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
public final class NewbTitle extends JavaPlugin {
|
public final class MiniPlayerTitle extends JavaPlugin {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
@ -18,8 +18,8 @@ public final class NewbTitle extends JavaPlugin {
|
|||||||
Database.migrate();
|
Database.migrate();
|
||||||
|
|
||||||
Bukkit.getPluginManager().registerEvents(new Events(), this);
|
Bukkit.getPluginManager().registerEvents(new Events(), this);
|
||||||
Objects.requireNonNull(Bukkit.getPluginCommand("NewbTitle")).setExecutor(new Commands());
|
Objects.requireNonNull(Bukkit.getPluginCommand("MiniPlayerTitle")).setExecutor(new Commands());
|
||||||
Objects.requireNonNull(Bukkit.getPluginCommand("NewbTitle")).setTabCompleter(new Commands());
|
Objects.requireNonNull(Bukkit.getPluginCommand("MiniPlayerTitle")).setTabCompleter(new Commands());
|
||||||
|
|
||||||
XLogger.info("NewbTitle 称号插件已加载");
|
XLogger.info("NewbTitle 称号插件已加载");
|
||||||
}
|
}
|
||||||
@ -29,6 +29,6 @@ public final class NewbTitle extends JavaPlugin {
|
|||||||
// Plugin shutdown logic
|
// Plugin shutdown logic
|
||||||
}
|
}
|
||||||
|
|
||||||
public static NewbTitle instance;
|
public static MiniPlayerTitle instance;
|
||||||
public static ConfigManager config;
|
public static ConfigManager config;
|
||||||
}
|
}
|
@ -1,6 +1,6 @@
|
|||||||
package cn.lunadeer.newbtitle;
|
package cn.lunadeer.miniplayertitle;
|
||||||
|
|
||||||
import cn.lunadeer.newbtitle.utils.Database;
|
import cn.lunadeer.miniplayertitle.utils.Database;
|
||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -17,15 +17,15 @@ public class PlayerTitle extends Title {
|
|||||||
|
|
||||||
public static PlayerTitle create(Integer title_id, UUID player_uuid) {
|
public static PlayerTitle create(Integer title_id, UUID player_uuid) {
|
||||||
String sql = "";
|
String sql = "";
|
||||||
sql += "INSERT INTO nt_player_title (title_id, player_uuid, expire_at) ";
|
sql += "INSERT INTO mplt_player_title (title_id, player_uuid, expire_at) ";
|
||||||
sql += "VALUES (" + title_id + ", '" + player_uuid.toString() + "', -1) ";
|
sql += "VALUES (" + title_id + ", '" + player_uuid.toString() + "', " + System.currentTimeMillis() + ") ";
|
||||||
sql += "RETURNING id;";
|
sql += "RETURNING id;";
|
||||||
try (ResultSet rs = Database.query(sql)) {
|
try (ResultSet rs = Database.query(sql)) {
|
||||||
if (rs != null && rs.next()) {
|
if (rs != null && rs.next()) {
|
||||||
return new PlayerTitle(title_id, player_uuid, -1L);
|
return new PlayerTitle(title_id, player_uuid, -1L);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
cn.lunadeer.newbtitle.utils.XLogger.err("PlayerTitle create failed: " + e.getMessage());
|
cn.lunadeer.miniplayertitle.utils.XLogger.err("PlayerTitle create failed: " + e.getMessage());
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -59,7 +59,7 @@ public class PlayerTitle extends Title {
|
|||||||
|
|
||||||
private void save() {
|
private void save() {
|
||||||
String sql = "";
|
String sql = "";
|
||||||
sql += "UPDATE nt_player_title ";
|
sql += "UPDATE mplt_player_title ";
|
||||||
sql += "SET expire_at = " + this._expire_at + ", ";
|
sql += "SET expire_at = " + this._expire_at + ", ";
|
||||||
sql += "updated_at = CURRENT_TIMESTAMP ";
|
sql += "updated_at = CURRENT_TIMESTAMP ";
|
||||||
sql += "WHERE player_uuid = '" + _player_uuid.toString() + "', ";
|
sql += "WHERE player_uuid = '" + _player_uuid.toString() + "', ";
|
@ -1,8 +1,8 @@
|
|||||||
package cn.lunadeer.newbtitle;
|
package cn.lunadeer.miniplayertitle;
|
||||||
|
|
||||||
|
|
||||||
import cn.lunadeer.newbtitle.utils.Database;
|
import cn.lunadeer.miniplayertitle.utils.Database;
|
||||||
import cn.lunadeer.newbtitle.utils.XLogger;
|
import cn.lunadeer.miniplayertitle.utils.XLogger;
|
||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
|
|
||||||
@ -25,7 +25,7 @@ public class SaleTitle extends Title {
|
|||||||
|
|
||||||
public static SaleTitle create(Integer title_id) {
|
public static SaleTitle create(Integer title_id) {
|
||||||
String sql = "";
|
String sql = "";
|
||||||
sql += "INSERT INTO nt_title_shop (title_id, price, days, amount, sale_end_at) ";
|
sql += "INSERT INTO mplt_title_shop (title_id, price, days, amount, sale_end_at) ";
|
||||||
sql += "VALUES (" + title_id + ", 0, 0, 0, -1) ";
|
sql += "VALUES (" + title_id + ", 0, 0, 0, -1) ";
|
||||||
sql += "RETURNING id;";
|
sql += "RETURNING id;";
|
||||||
try (ResultSet rs = Database.query(sql)) {
|
try (ResultSet rs = Database.query(sql)) {
|
||||||
@ -109,9 +109,13 @@ public class SaleTitle extends Title {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Integer getSaleId(){
|
||||||
|
return this._sale_id;
|
||||||
|
}
|
||||||
|
|
||||||
private void save() {
|
private void save() {
|
||||||
String sql = "";
|
String sql = "";
|
||||||
sql += "UPDATE nt_title_shop ";
|
sql += "UPDATE mplt_title_shop ";
|
||||||
sql += "SET title_id = " + this._id + ", ";
|
sql += "SET title_id = " + this._id + ", ";
|
||||||
sql += "price = " + this._price + ", ";
|
sql += "price = " + this._price + ", ";
|
||||||
sql += "days = " + this._days + ", ";
|
sql += "days = " + this._days + ", ";
|
@ -1,14 +1,13 @@
|
|||||||
package cn.lunadeer.newbtitle;
|
package cn.lunadeer.miniplayertitle;
|
||||||
|
|
||||||
import cn.lunadeer.newbtitle.utils.Database;
|
import cn.lunadeer.miniplayertitle.utils.Database;
|
||||||
import cn.lunadeer.newbtitle.utils.Notification;
|
import cn.lunadeer.miniplayertitle.utils.Notification;
|
||||||
import cn.lunadeer.newbtitle.utils.STUI.Button;
|
import cn.lunadeer.miniplayertitle.utils.STUI.Button;
|
||||||
import cn.lunadeer.newbtitle.utils.STUI.Line;
|
import cn.lunadeer.miniplayertitle.utils.STUI.Line;
|
||||||
import cn.lunadeer.newbtitle.utils.STUI.View;
|
import cn.lunadeer.miniplayertitle.utils.STUI.View;
|
||||||
import cn.lunadeer.newbtitle.utils.XLogger;
|
import cn.lunadeer.miniplayertitle.utils.XLogger;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.TextComponent;
|
import net.kyori.adventure.text.TextComponent;
|
||||||
import net.kyori.adventure.text.event.ClickEvent;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@ -20,9 +19,9 @@ public class Shop {
|
|||||||
public static void open(CommandSender sender, Integer page) {
|
public static void open(CommandSender sender, Integer page) {
|
||||||
Map<Integer, SaleTitle> titles = getSaleTitles();
|
Map<Integer, SaleTitle> titles = getSaleTitles();
|
||||||
if (!(sender instanceof Player)) {
|
if (!(sender instanceof Player)) {
|
||||||
for (Integer title_sale_id : titles.keySet()) {
|
for (SaleTitle title : titles.values()) {
|
||||||
SaleTitle title = titles.get(title_sale_id);
|
Notification.info(sender, "[" + title.getSaleId() + "]");
|
||||||
XLogger.info("[" + title_sale_id + "] " + title.getTitle().toString() + " price:" + title.getPrice() + " days:" + title.getDays() + " amount:" + title.getAmount());
|
Notification.info(sender, title.getTitle());
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -34,6 +33,7 @@ public class Shop {
|
|||||||
}
|
}
|
||||||
View view = View.create();
|
View view = View.create();
|
||||||
view.title("称号商店");
|
view.title("称号商店");
|
||||||
|
view.subtitle("当前余额: " + XPlayer.getCoin(player) + "金币");
|
||||||
for (int i = offset; i < offset + 4; i++) {
|
for (int i = offset; i < offset + 4; i++) {
|
||||||
if (i >= titles.size()) {
|
if (i >= titles.size()) {
|
||||||
break;
|
break;
|
||||||
@ -42,22 +42,22 @@ public class Shop {
|
|||||||
TextComponent idx = Component.text("[" + title_sale_id + "] ");
|
TextComponent idx = Component.text("[" + title_sale_id + "] ");
|
||||||
SaleTitle title = titles.get(title_sale_id);
|
SaleTitle title = titles.get(title_sale_id);
|
||||||
Line line = Line.create();
|
Line line = Line.create();
|
||||||
Component button = Button.create("购买", "/nt buy " + title_sale_id);
|
Component button = Button.create("购买", "/mplt buy " + title_sale_id);
|
||||||
line.append(idx)
|
line.append(idx)
|
||||||
.append(title.getTitle())
|
.append(title.getTitle())
|
||||||
.append("价格:" + title.getPrice() + " 有效期:" + title.getDays() + "天")
|
.append("价格:" + title.getPrice() + " 有效期:" + (title.getDays()==-1?"永久":title.getDays() + "天"))
|
||||||
.append("售卖截止:" + title.getSaleEndAt())
|
.append("售卖截止:" + title.getSaleEndAt())
|
||||||
.append("剩余:" + ((title.getAmount() == -1) ? "无限" : title.getAmount()))
|
.append("剩余:" + ((title.getAmount() == -1) ? "无限" : title.getAmount()))
|
||||||
.append(button);
|
.append(button);
|
||||||
view.set(i, line);
|
view.set(i, line);
|
||||||
}
|
}
|
||||||
view.set(View.Slot.ACTIONBAR, View.pagination(page, titles.size(), "/nt shop"));
|
view.set(View.Slot.ACTIONBAR, View.pagination(page, titles.size(), "/mplt shop"));
|
||||||
view.showOn(player);
|
view.showOn(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void deleteTitle(Integer id) {
|
public static void deleteTitle(Integer id) {
|
||||||
String sql = "";
|
String sql = "";
|
||||||
sql += "DELETE FROM nt_title_shop WHERE id = " + id + ";";
|
sql += "DELETE FROM mplt_title_shop WHERE id = " + id + ";";
|
||||||
Database.query(sql);
|
Database.query(sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,7 +70,7 @@ public class Shop {
|
|||||||
sql += "days, ";
|
sql += "days, ";
|
||||||
sql += "amount, ";
|
sql += "amount, ";
|
||||||
sql += "sale_end_at ";
|
sql += "sale_end_at ";
|
||||||
sql += "FROM nt_title_shop;";
|
sql += "FROM mplt_title_shop;";
|
||||||
Map<Integer, SaleTitle> titles = new HashMap<>();
|
Map<Integer, SaleTitle> titles = new HashMap<>();
|
||||||
try (ResultSet rs = Database.query(sql)) {
|
try (ResultSet rs = Database.query(sql)) {
|
||||||
while (rs != null && rs.next()) {
|
while (rs != null && rs.next()) {
|
||||||
@ -88,31 +88,4 @@ public class Shop {
|
|||||||
}
|
}
|
||||||
return titles;
|
return titles;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SaleTitle getSaleTitle(Integer sale_id) {
|
|
||||||
String sql = "";
|
|
||||||
sql += "SELECT ";
|
|
||||||
sql += "id, ";
|
|
||||||
sql += "title_id, ";
|
|
||||||
sql += "price, ";
|
|
||||||
sql += "days, ";
|
|
||||||
sql += "amount, ";
|
|
||||||
sql += "sale_end_at ";
|
|
||||||
sql += "FROM nt_title_shop ";
|
|
||||||
sql += "WHERE id = " + sale_id + ";";
|
|
||||||
try (ResultSet rs = Database.query(sql)) {
|
|
||||||
if (rs != null && rs.next()) {
|
|
||||||
Integer id = rs.getInt("id");
|
|
||||||
Integer title_id = rs.getInt("title_id");
|
|
||||||
Integer price = rs.getInt("price");
|
|
||||||
Integer days = rs.getInt("days");
|
|
||||||
Integer amount = rs.getInt("amount");
|
|
||||||
Long sale_end_at = rs.getLong("sale_end_at");
|
|
||||||
return new SaleTitle(id, title_id, price, days, amount, sale_end_at);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
XLogger.err("XPlayer getTitles failed: " + e.getMessage());
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,14 +1,13 @@
|
|||||||
package cn.lunadeer.newbtitle;
|
package cn.lunadeer.miniplayertitle;
|
||||||
|
|
||||||
import cn.lunadeer.newbtitle.utils.Database;
|
import cn.lunadeer.miniplayertitle.utils.Database;
|
||||||
import cn.lunadeer.newbtitle.utils.Notification;
|
import cn.lunadeer.miniplayertitle.utils.Notification;
|
||||||
import cn.lunadeer.newbtitle.utils.STUI.Line;
|
import cn.lunadeer.miniplayertitle.utils.STUI.Line;
|
||||||
import cn.lunadeer.newbtitle.utils.STUI.View;
|
import cn.lunadeer.miniplayertitle.utils.STUI.View;
|
||||||
import cn.lunadeer.newbtitle.utils.XLogger;
|
import cn.lunadeer.miniplayertitle.utils.XLogger;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.JoinConfiguration;
|
import net.kyori.adventure.text.JoinConfiguration;
|
||||||
import net.kyori.adventure.text.TextComponent;
|
import net.kyori.adventure.text.TextComponent;
|
||||||
import net.kyori.adventure.text.event.ClickEvent;
|
|
||||||
import net.kyori.adventure.text.event.HoverEvent;
|
import net.kyori.adventure.text.event.HoverEvent;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -26,7 +25,7 @@ public class Title {
|
|||||||
|
|
||||||
public static Title create(String title, String description) {
|
public static Title create(String title, String description) {
|
||||||
String sql = "";
|
String sql = "";
|
||||||
sql += "INSERT INTO nt_title (title, description, enabled) VALUES (";
|
sql += "INSERT INTO mplt_title (title, description, enabled) VALUES (";
|
||||||
sql += "'" + title + "', ";
|
sql += "'" + title + "', ";
|
||||||
sql += "'" + description + "', ";
|
sql += "'" + description + "', ";
|
||||||
sql += "true ";
|
sql += "true ";
|
||||||
@ -45,7 +44,7 @@ public class Title {
|
|||||||
public static List<Title> all() {
|
public static List<Title> all() {
|
||||||
List<Title> titles = new ArrayList<>();
|
List<Title> titles = new ArrayList<>();
|
||||||
String sql = "";
|
String sql = "";
|
||||||
sql += "SELECT id FROM nt_title;";
|
sql += "SELECT id FROM mplt_title;";
|
||||||
try (ResultSet rs = Database.query(sql)) {
|
try (ResultSet rs = Database.query(sql)) {
|
||||||
if (rs != null) {
|
if (rs != null) {
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
@ -63,7 +62,8 @@ public class Title {
|
|||||||
List<Title> titles = all();
|
List<Title> titles = all();
|
||||||
if (!(sender instanceof Player)) {
|
if (!(sender instanceof Player)) {
|
||||||
for (Title title : titles) {
|
for (Title title : titles) {
|
||||||
Notification.info(sender, title.getId() + " " + title.getTitle().toString());
|
Notification.info(sender, "[" + title.getId() + "]");
|
||||||
|
Notification.info(sender, title.getTitle());
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -84,7 +84,7 @@ public class Title {
|
|||||||
line.append(idx).append(titles.get(i).getTitle());
|
line.append(idx).append(titles.get(i).getTitle());
|
||||||
view.set(i, line);
|
view.set(i, line);
|
||||||
}
|
}
|
||||||
view.set(View.Slot.ACTIONBAR, View.pagination(page, titles.size(), "/nt listall"));
|
view.set(View.Slot.ACTIONBAR, View.pagination(page, titles.size(), "/mplt listall"));
|
||||||
view.showOn(player);
|
view.showOn(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,7 +92,7 @@ public class Title {
|
|||||||
this._id = id;
|
this._id = id;
|
||||||
String sql = "";
|
String sql = "";
|
||||||
sql += "SELECT id, title, description, enabled ";
|
sql += "SELECT id, title, description, enabled ";
|
||||||
sql += "FROM nt_title ";
|
sql += "FROM mplt_title ";
|
||||||
sql += "WHERE id = " + id + ";";
|
sql += "WHERE id = " + id + ";";
|
||||||
try (ResultSet rs = Database.query(sql)) {
|
try (ResultSet rs = Database.query(sql)) {
|
||||||
if (rs != null && rs.next()) {
|
if (rs != null && rs.next()) {
|
||||||
@ -107,20 +107,20 @@ public class Title {
|
|||||||
|
|
||||||
public static void delete(Integer id) {
|
public static void delete(Integer id) {
|
||||||
String sql = "";
|
String sql = "";
|
||||||
sql += "DELETE FROM nt_title WHERE id = " + id + ";";
|
sql += "DELETE FROM mplt_title WHERE id = " + id + ";";
|
||||||
Database.query(sql);
|
Database.query(sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void save() {
|
private void save() {
|
||||||
String sql = "";
|
String sql = "";
|
||||||
if (this._id == null) {
|
if (this._id == null) {
|
||||||
sql += "INSERT INTO nt_title (title, description, enabled) VALUES (";
|
sql += "INSERT INTO mplt_title (title, description, enabled) VALUES (";
|
||||||
sql += "'" + this._title + "', ";
|
sql += "'" + this._title + "', ";
|
||||||
sql += "'" + this._description + "', ";
|
sql += "'" + this._description + "', ";
|
||||||
sql += this._enabled + " ";
|
sql += this._enabled + " ";
|
||||||
sql += ");";
|
sql += ");";
|
||||||
} else {
|
} else {
|
||||||
sql += "UPDATE nt_title SET ";
|
sql += "UPDATE mplt_title SET ";
|
||||||
sql += "title = '" + this._title + "', ";
|
sql += "title = '" + this._title + "', ";
|
||||||
sql += "description = '" + this._description + "', ";
|
sql += "description = '" + this._description + "', ";
|
||||||
sql += "enabled = " + this._enabled + " ";
|
sql += "enabled = " + this._enabled + " ";
|
||||||
@ -135,8 +135,8 @@ public class Title {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Component getTitle() {
|
public Component getTitle() {
|
||||||
TextComponent prefix = Component.text(NewbTitle.config.getPrefix());
|
TextComponent prefix = Component.text(MiniPlayerTitle.config.getPrefix());
|
||||||
TextComponent suffix = Component.text(NewbTitle.config.getSuffix());
|
TextComponent suffix = Component.text(MiniPlayerTitle.config.getSuffix());
|
||||||
String[] parts = this._title.split("&#");
|
String[] parts = this._title.split("&#");
|
||||||
List<TextComponent> components = new ArrayList<>();
|
List<TextComponent> components = new ArrayList<>();
|
||||||
components.add(prefix);
|
components.add(prefix);
|
@ -1,14 +1,13 @@
|
|||||||
package cn.lunadeer.newbtitle;
|
package cn.lunadeer.miniplayertitle;
|
||||||
|
|
||||||
import cn.lunadeer.newbtitle.utils.Database;
|
import cn.lunadeer.miniplayertitle.utils.Database;
|
||||||
import cn.lunadeer.newbtitle.utils.Notification;
|
import cn.lunadeer.miniplayertitle.utils.Notification;
|
||||||
import cn.lunadeer.newbtitle.utils.STUI.Button;
|
import cn.lunadeer.miniplayertitle.utils.STUI.Button;
|
||||||
import cn.lunadeer.newbtitle.utils.STUI.Line;
|
import cn.lunadeer.miniplayertitle.utils.STUI.Line;
|
||||||
import cn.lunadeer.newbtitle.utils.STUI.View;
|
import cn.lunadeer.miniplayertitle.utils.STUI.View;
|
||||||
import cn.lunadeer.newbtitle.utils.XLogger;
|
import cn.lunadeer.miniplayertitle.utils.XLogger;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.TextComponent;
|
import net.kyori.adventure.text.TextComponent;
|
||||||
import net.kyori.adventure.text.event.ClickEvent;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
@ -56,14 +55,14 @@ public class XPlayer {
|
|||||||
PlayerTitle title = titles.get(title_id);
|
PlayerTitle title = titles.get(title_id);
|
||||||
Line line = Line.create();
|
Line line = Line.create();
|
||||||
boolean is_using = Objects.equals(title.getId(), _current_title_id);
|
boolean is_using = Objects.equals(title.getId(), _current_title_id);
|
||||||
Component button = Button.create(is_using ? "卸下" : "使用", "/nt use " + (is_using ? -1 : title.getId()));
|
Component button = Button.create(is_using ? "卸下" : "使用", "/mplt use " + (is_using ? -1 : title.getId()));
|
||||||
line.append(idx)
|
line.append(idx)
|
||||||
.append(title.getTitle())
|
.append(title.getTitle())
|
||||||
.append(Component.text("有效期至:" + title.getExpireAt()))
|
.append(Component.text("有效期至:" + title.getExpireAt()))
|
||||||
.append(button);
|
.append(button);
|
||||||
view.set(i, line);
|
view.set(i, line);
|
||||||
}
|
}
|
||||||
view.set(View.Slot.ACTIONBAR, View.pagination(page, titles.size(), "/nt list"));
|
view.set(View.Slot.ACTIONBAR, View.pagination(page, titles.size(), "/mplt list"));
|
||||||
view.showOn(_player);
|
view.showOn(_player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,7 +73,7 @@ public class XPlayer {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String sql = "";
|
String sql = "";
|
||||||
sql += "UPDATE nt_player_using_title ";
|
sql += "UPDATE mplt_player_using_title ";
|
||||||
sql += "SET title_id = " + _current_title_id + ", ";
|
sql += "SET title_id = " + _current_title_id + ", ";
|
||||||
sql += "updated_at = CURRENT_TIMESTAMP ";
|
sql += "updated_at = CURRENT_TIMESTAMP ";
|
||||||
sql += "WHERE uuid = '" + _player.getUniqueId().toString() + "';";
|
sql += "WHERE uuid = '" + _player.getUniqueId().toString() + "';";
|
||||||
@ -103,7 +102,7 @@ public class XPlayer {
|
|||||||
public void set_coin(Integer coin) {
|
public void set_coin(Integer coin) {
|
||||||
_coin = coin;
|
_coin = coin;
|
||||||
String sql = "";
|
String sql = "";
|
||||||
sql += "UPDATE nt_player_coin ";
|
sql += "UPDATE mplt_player_coin ";
|
||||||
sql += "SET coin = " + coin + ", ";
|
sql += "SET coin = " + coin + ", ";
|
||||||
sql += "updated_at = CURRENT_TIMESTAMP ";
|
sql += "updated_at = CURRENT_TIMESTAMP ";
|
||||||
sql += "WHERE uuid = '" + _player.getUniqueId().toString() + "';";
|
sql += "WHERE uuid = '" + _player.getUniqueId().toString() + "';";
|
||||||
@ -114,11 +113,20 @@ public class XPlayer {
|
|||||||
set_coin(_coin + coin);
|
set_coin(_coin + coin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Integer get_coin() {
|
||||||
|
return _coin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Integer getCoin(Player player) {
|
||||||
|
XPlayer xplayer = new XPlayer(player);
|
||||||
|
return xplayer.get_coin();
|
||||||
|
}
|
||||||
|
|
||||||
private static Map<Integer, PlayerTitle> getTitles(UUID uuid) {
|
private static Map<Integer, PlayerTitle> getTitles(UUID uuid) {
|
||||||
String sql = "";
|
String sql = "";
|
||||||
sql += "SELECT ";
|
sql += "SELECT ";
|
||||||
sql += "title_id, expire_at ";
|
sql += "title_id, expire_at ";
|
||||||
sql += "FROM nt_player_title ";
|
sql += "FROM mplt_player_title ";
|
||||||
sql += "WHERE player_uuid = '" + uuid.toString() + "';";
|
sql += "WHERE player_uuid = '" + uuid.toString() + "';";
|
||||||
Map<Integer, PlayerTitle> titles = new HashMap<>();
|
Map<Integer, PlayerTitle> titles = new HashMap<>();
|
||||||
try (ResultSet rs = Database.query(sql)) {
|
try (ResultSet rs = Database.query(sql)) {
|
||||||
@ -137,7 +145,7 @@ public class XPlayer {
|
|||||||
private static Integer getCurrentTitleId(UUID uuid) {
|
private static Integer getCurrentTitleId(UUID uuid) {
|
||||||
String sql = "";
|
String sql = "";
|
||||||
sql += "SELECT title_id ";
|
sql += "SELECT title_id ";
|
||||||
sql += "FROM nt_player_using_title ";
|
sql += "FROM mplt_player_using_title ";
|
||||||
sql += "WHERE uuid = '" + uuid.toString() + "';";
|
sql += "WHERE uuid = '" + uuid.toString() + "';";
|
||||||
Integer current_title_id = null;
|
Integer current_title_id = null;
|
||||||
try (ResultSet rs = Database.query(sql)) {
|
try (ResultSet rs = Database.query(sql)) {
|
||||||
@ -146,7 +154,7 @@ public class XPlayer {
|
|||||||
} else {
|
} else {
|
||||||
current_title_id = -1;
|
current_title_id = -1;
|
||||||
sql = "";
|
sql = "";
|
||||||
sql += "INSERT INTO nt_player_using_title (uuid, title_id) VALUES (";
|
sql += "INSERT INTO mplt_player_using_title (uuid, title_id) VALUES (";
|
||||||
sql += "'" + uuid + "', ";
|
sql += "'" + uuid + "', ";
|
||||||
sql += current_title_id + ");";
|
sql += current_title_id + ");";
|
||||||
Database.query(sql);
|
Database.query(sql);
|
||||||
@ -160,7 +168,7 @@ public class XPlayer {
|
|||||||
private static Integer getCoin(UUID uuid) {
|
private static Integer getCoin(UUID uuid) {
|
||||||
String sql = "";
|
String sql = "";
|
||||||
sql += "SELECT coin ";
|
sql += "SELECT coin ";
|
||||||
sql += "FROM nt_player_coin ";
|
sql += "FROM mplt_player_coin ";
|
||||||
sql += "WHERE uuid = '" + uuid.toString() + "';";
|
sql += "WHERE uuid = '" + uuid.toString() + "';";
|
||||||
Integer coin = null;
|
Integer coin = null;
|
||||||
try (ResultSet rs = Database.query(sql)) {
|
try (ResultSet rs = Database.query(sql)) {
|
||||||
@ -169,7 +177,7 @@ public class XPlayer {
|
|||||||
} else {
|
} else {
|
||||||
coin = 0;
|
coin = 0;
|
||||||
sql = "";
|
sql = "";
|
||||||
sql += "INSERT INTO nt_player_coin (uuid, coin) VALUES (";
|
sql += "INSERT INTO mplt_player_coin (uuid, coin) VALUES (";
|
||||||
sql += "'" + uuid + "', ";
|
sql += "'" + uuid + "', ";
|
||||||
sql += coin + ");";
|
sql += coin + ");";
|
||||||
Database.query(sql);
|
Database.query(sql);
|
||||||
@ -181,7 +189,7 @@ public class XPlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void buyTitle(SaleTitle title) {
|
public void buyTitle(SaleTitle title) {
|
||||||
if (title.isSaleExpired()) {
|
if (title.isSaleExpired() || title.getDays() == 0) {
|
||||||
Notification.error(_player, "此称号已停止销售");
|
Notification.error(_player, "此称号已停止销售");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -211,7 +219,7 @@ public class XPlayer {
|
|||||||
if (title_bought.isExpired()) {
|
if (title_bought.isExpired()) {
|
||||||
title_bought.setExpireAtTimestamp(System.currentTimeMillis() + title.getDays() * 24 * 60 * 60 * 1000L);
|
title_bought.setExpireAtTimestamp(System.currentTimeMillis() + title.getDays() * 24 * 60 * 60 * 1000L);
|
||||||
Notification.info(_player, title.getTitle());
|
Notification.info(_player, title.getTitle());
|
||||||
Notification.info(_player, "称号已重新激活,有效期至 " + title_bought.getExpireAt());
|
Notification.info(_player, "称号已激活,有效期至 " + title_bought.getExpireAt());
|
||||||
} else {
|
} else {
|
||||||
title_bought.setExpireAtTimestamp(title_bought.getExpireAtTimestamp() + title.getDays() * 24 * 60 * 60 * 1000L);
|
title_bought.setExpireAtTimestamp(title_bought.getExpireAtTimestamp() + title.getDays() * 24 * 60 * 60 * 1000L);
|
||||||
Notification.info(_player, title.getTitle());
|
Notification.info(_player, title.getTitle());
|
@ -1,9 +1,9 @@
|
|||||||
package cn.lunadeer.newbtitle.commands;
|
package cn.lunadeer.miniplayertitle.commands;
|
||||||
|
|
||||||
import cn.lunadeer.newbtitle.SaleTitle;
|
import cn.lunadeer.miniplayertitle.SaleTitle;
|
||||||
import cn.lunadeer.newbtitle.Title;
|
import cn.lunadeer.miniplayertitle.Title;
|
||||||
import cn.lunadeer.newbtitle.utils.Notification;
|
import cn.lunadeer.miniplayertitle.utils.Notification;
|
||||||
import cn.lunadeer.newbtitle.utils.XLogger;
|
import cn.lunadeer.miniplayertitle.utils.XLogger;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@ -17,7 +17,7 @@ public class AdminCommands {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (args.length != 3) {
|
if (args.length != 3) {
|
||||||
Notification.warn(sender, "用法: /nt create <称号名称> <称号描述>");
|
Notification.warn(sender, "用法: /mplt create <称号名称> <称号描述>");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Title.create(args[1], args[2]);
|
Title.create(args[1], args[2]);
|
||||||
@ -33,7 +33,7 @@ public class AdminCommands {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (args.length != 2) {
|
if (args.length != 2) {
|
||||||
Notification.warn(sender, "用法: /nt delete <称号ID>");
|
Notification.warn(sender, "用法: /mplt delete <称号ID>");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Title.delete(Integer.parseInt(args[1]));
|
Title.delete(Integer.parseInt(args[1]));
|
||||||
@ -70,7 +70,7 @@ public class AdminCommands {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (args.length != 3) {
|
if (args.length != 3) {
|
||||||
Notification.warn(sender, "用法: /nt setdesc <称号ID> <称号描述>");
|
Notification.warn(sender, "用法: /mplt setdesc <称号ID> <称号描述>");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Title title = new Title(Integer.parseInt(args[1]));
|
Title title = new Title(Integer.parseInt(args[1]));
|
||||||
@ -87,7 +87,7 @@ public class AdminCommands {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (args.length != 3) {
|
if (args.length != 3) {
|
||||||
Notification.warn(sender, "用法: /nt setname <称号ID> <称号名称>");
|
Notification.warn(sender, "用法: /mplt setname <称号ID> <称号名称>");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Title title = new Title(Integer.parseInt(args[1]));
|
Title title = new Title(Integer.parseInt(args[1]));
|
||||||
@ -104,7 +104,7 @@ public class AdminCommands {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (args.length != 2) {
|
if (args.length != 2) {
|
||||||
Notification.warn(sender, "用法: /nt addshop <称号ID>");
|
Notification.warn(sender, "用法: /mplt addshop <称号ID>");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
SaleTitle title = SaleTitle.create(Integer.parseInt(args[1]));
|
SaleTitle title = SaleTitle.create(Integer.parseInt(args[1]));
|
||||||
@ -126,7 +126,7 @@ public class AdminCommands {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (args.length != 2) {
|
if (args.length != 2) {
|
||||||
Notification.warn(sender, "用法: /nt removeshop <商品ID>");
|
Notification.warn(sender, "用法: /mplt removeshop <商品ID>");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
SaleTitle.delete(Integer.parseInt(args[1]));
|
SaleTitle.delete(Integer.parseInt(args[1]));
|
||||||
@ -142,7 +142,7 @@ public class AdminCommands {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (args.length != 4) {
|
if (args.length != 4) {
|
||||||
Notification.warn(sender, "用法: /nt setprice <商品ID> <价格> <天数>(-1为永久)");
|
Notification.warn(sender, "用法: /mplt setprice <商品ID> <价格> <天数>(-1为永久)");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
SaleTitle.setPrice(Integer.parseInt(args[1]), Integer.parseInt(args[2]));
|
SaleTitle.setPrice(Integer.parseInt(args[1]), Integer.parseInt(args[2]));
|
||||||
@ -159,7 +159,7 @@ public class AdminCommands {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (args.length != 3) {
|
if (args.length != 3) {
|
||||||
Notification.warn(sender, "用法: /nt setamount <商品ID> <数量>(-1为无限)");
|
Notification.warn(sender, "用法: /mplt setamount <商品ID> <数量>(-1为无限)");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
SaleTitle.setAmount(Integer.parseInt(args[1]), Integer.parseInt(args[2]));
|
SaleTitle.setAmount(Integer.parseInt(args[1]), Integer.parseInt(args[2]));
|
||||||
@ -175,7 +175,7 @@ public class AdminCommands {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (args.length != 3) {
|
if (args.length != 3) {
|
||||||
Notification.warn(sender, "用法: /nt setendat <商品ID> <时间YYYYMMDD>(-1为永久)");
|
Notification.warn(sender, "用法: /mplt setendat <商品ID> <时间YYYYMMDD>(-1为永久)");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
long time_stamp;
|
long time_stamp;
|
@ -1,10 +1,10 @@
|
|||||||
package cn.lunadeer.newbtitle.commands;
|
package cn.lunadeer.miniplayertitle.commands;
|
||||||
|
|
||||||
import cn.lunadeer.newbtitle.SaleTitle;
|
import cn.lunadeer.miniplayertitle.SaleTitle;
|
||||||
import cn.lunadeer.newbtitle.Shop;
|
import cn.lunadeer.miniplayertitle.Shop;
|
||||||
import cn.lunadeer.newbtitle.XPlayer;
|
import cn.lunadeer.miniplayertitle.XPlayer;
|
||||||
import cn.lunadeer.newbtitle.utils.Notification;
|
import cn.lunadeer.miniplayertitle.utils.Notification;
|
||||||
import cn.lunadeer.newbtitle.utils.XLogger;
|
import cn.lunadeer.miniplayertitle.utils.XLogger;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
public class PlayerCommands {
|
public class PlayerCommands {
|
||||||
@ -15,7 +15,7 @@ public class PlayerCommands {
|
|||||||
}
|
}
|
||||||
org.bukkit.entity.Player player = (org.bukkit.entity.Player) sender;
|
org.bukkit.entity.Player player = (org.bukkit.entity.Player) sender;
|
||||||
if (args.length != 2) {
|
if (args.length != 2) {
|
||||||
Notification.warn(player, "用法: /nt use <称号ID>");
|
Notification.warn(player, "用法: /mplt use <称号ID>");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,12 +64,12 @@ public class PlayerCommands {
|
|||||||
}
|
}
|
||||||
org.bukkit.entity.Player player = (org.bukkit.entity.Player) sender;
|
org.bukkit.entity.Player player = (org.bukkit.entity.Player) sender;
|
||||||
if (args.length != 2) {
|
if (args.length != 2) {
|
||||||
Notification.warn(player, "用法: /nt buy <称号ID>");
|
Notification.warn(player, "用法: /mplt buy <称号ID>");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
XPlayer xPlayer = new XPlayer(player);
|
XPlayer xPlayer = new XPlayer(player);
|
||||||
Integer sale_id = Integer.parseInt(args[1]);
|
Integer sale_id = Integer.parseInt(args[1]);
|
||||||
SaleTitle saleTitle = Shop.getSaleTitle(sale_id);
|
SaleTitle saleTitle = Shop.getSaleTitles().get(sale_id);
|
||||||
if (saleTitle == null) {
|
if (saleTitle == null) {
|
||||||
Notification.error(player, "该称号不存在");
|
Notification.error(player, "该称号不存在");
|
||||||
return true;
|
return true;
|
@ -1,10 +1,10 @@
|
|||||||
package cn.lunadeer.newbtitle.utils;
|
package cn.lunadeer.miniplayertitle.utils;
|
||||||
|
|
||||||
import cn.lunadeer.newbtitle.NewbTitle;
|
import cn.lunadeer.miniplayertitle.MiniPlayerTitle;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
|
||||||
public class ConfigManager {
|
public class ConfigManager {
|
||||||
public ConfigManager(NewbTitle plugin) {
|
public ConfigManager(MiniPlayerTitle plugin) {
|
||||||
_plugin = plugin;
|
_plugin = plugin;
|
||||||
_plugin.saveDefaultConfig();
|
_plugin.saveDefaultConfig();
|
||||||
reload();
|
reload();
|
||||||
@ -94,7 +94,7 @@ public class ConfigManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private final NewbTitle _plugin;
|
private final MiniPlayerTitle _plugin;
|
||||||
private FileConfiguration _file;
|
private FileConfiguration _file;
|
||||||
private Boolean _debug;
|
private Boolean _debug;
|
||||||
|
|
@ -1,6 +1,6 @@
|
|||||||
package cn.lunadeer.newbtitle.utils;
|
package cn.lunadeer.miniplayertitle.utils;
|
||||||
|
|
||||||
import cn.lunadeer.newbtitle.NewbTitle;
|
import cn.lunadeer.miniplayertitle.MiniPlayerTitle;
|
||||||
|
|
||||||
import java.sql.*;
|
import java.sql.*;
|
||||||
|
|
||||||
@ -9,7 +9,7 @@ public class Database {
|
|||||||
private static Connection getConnection() {
|
private static Connection getConnection() {
|
||||||
try {
|
try {
|
||||||
Class.forName("org.postgresql.Driver");
|
Class.forName("org.postgresql.Driver");
|
||||||
return DriverManager.getConnection(NewbTitle.config.getDBConnectionUrl(), NewbTitle.config.getDbUser(), NewbTitle.config.getDbPass());
|
return DriverManager.getConnection(MiniPlayerTitle.config.getDBConnectionUrl(), MiniPlayerTitle.config.getDbUser(), MiniPlayerTitle.config.getDbPass());
|
||||||
} catch (ClassNotFoundException | SQLException e) {
|
} catch (ClassNotFoundException | SQLException e) {
|
||||||
XLogger.err("Database connection failed: " + e.getMessage());
|
XLogger.err("Database connection failed: " + e.getMessage());
|
||||||
return null;
|
return null;
|
||||||
@ -23,7 +23,12 @@ public class Database {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
Statement stmt = conn.createStatement();
|
Statement stmt = conn.createStatement();
|
||||||
return stmt.executeQuery(sql);
|
// if query with no result return null
|
||||||
|
if (stmt.execute(sql)) {
|
||||||
|
return stmt.getResultSet();
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
XLogger.err("Database query failed: " + e.getMessage());
|
XLogger.err("Database query failed: " + e.getMessage());
|
||||||
XLogger.err("SQL: " + sql);
|
XLogger.err("SQL: " + sql);
|
||||||
@ -35,7 +40,7 @@ public class Database {
|
|||||||
String sql = "";
|
String sql = "";
|
||||||
|
|
||||||
// title table
|
// title table
|
||||||
sql += "CREATE TABLE IF NOT EXISTS nt_title (" +
|
sql += "CREATE TABLE IF NOT EXISTS mplt_title (" +
|
||||||
" id SERIAL PRIMARY KEY," +
|
" id SERIAL PRIMARY KEY," +
|
||||||
" title TEXT NOT NULL," +
|
" title TEXT NOT NULL," +
|
||||||
" description TEXT NOT NULL," +
|
" description TEXT NOT NULL," +
|
||||||
@ -45,7 +50,7 @@ public class Database {
|
|||||||
");";
|
");";
|
||||||
|
|
||||||
// title shop table
|
// title shop table
|
||||||
sql += "CREATE TABLE IF NOT EXISTS nt_title_shop (" +
|
sql += "CREATE TABLE IF NOT EXISTS mplt_title_shop (" +
|
||||||
" id SERIAL PRIMARY KEY," +
|
" id SERIAL PRIMARY KEY," +
|
||||||
" title_id INTEGER NOT NULL," +
|
" title_id INTEGER NOT NULL," +
|
||||||
" price INTEGER NOT NULL DEFAULT 0," +
|
" price INTEGER NOT NULL DEFAULT 0," +
|
||||||
@ -54,11 +59,11 @@ public class Database {
|
|||||||
" sale_end_at BIGINT NOT NULL DEFAULT -1," +
|
" sale_end_at BIGINT NOT NULL DEFAULT -1," +
|
||||||
" created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP," +
|
" created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP," +
|
||||||
" updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP," +
|
" updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP," +
|
||||||
" FOREIGN KEY (title_id) REFERENCES nt_title(id) ON DELETE CASCADE" +
|
" FOREIGN KEY (title_id) REFERENCES mplt_title(id) ON DELETE CASCADE" +
|
||||||
");";
|
");";
|
||||||
|
|
||||||
// player coin table
|
// player coin table
|
||||||
sql += "CREATE TABLE IF NOT EXISTS nt_player_coin (" +
|
sql += "CREATE TABLE IF NOT EXISTS mplt_player_coin (" +
|
||||||
" uuid UUID PRIMARY KEY," +
|
" uuid UUID PRIMARY KEY," +
|
||||||
" coin INTEGER NOT NULL DEFAULT 0," +
|
" coin INTEGER NOT NULL DEFAULT 0," +
|
||||||
" created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP," +
|
" created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP," +
|
||||||
@ -66,26 +71,26 @@ public class Database {
|
|||||||
");";
|
");";
|
||||||
|
|
||||||
// player title table
|
// player title table
|
||||||
sql += "CREATE TABLE IF NOT EXISTS nt_player_title (" +
|
sql += "CREATE TABLE IF NOT EXISTS mplt_player_title (" +
|
||||||
" id SERIAL PRIMARY KEY," +
|
" id SERIAL PRIMARY KEY," +
|
||||||
" player_uuid UUID NOT NULL," +
|
" player_uuid UUID NOT NULL," +
|
||||||
" title_id INTEGER NOT NULL," +
|
" title_id INTEGER NOT NULL," +
|
||||||
" expire_at BIGINT NOT NULL DEFAULT -1," +
|
" expire_at BIGINT NOT NULL DEFAULT -1," +
|
||||||
" created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP," +
|
" created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP," +
|
||||||
" updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP," +
|
" updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP," +
|
||||||
" FOREIGN KEY (title_id) REFERENCES nt_title(id) ON DELETE CASCADE" +
|
" FOREIGN KEY (title_id) REFERENCES mplt_title(id) ON DELETE CASCADE" +
|
||||||
");";
|
");";
|
||||||
|
|
||||||
// player using title table
|
// player using title table
|
||||||
sql += "CREATE TABLE IF NOT EXISTS nt_player_using_title (" +
|
sql += "CREATE TABLE IF NOT EXISTS mplt_player_using_title (" +
|
||||||
" uuid UUID PRIMARY KEY," +
|
" uuid UUID PRIMARY KEY," +
|
||||||
" title_id INTEGER NOT NULL," +
|
" title_id INTEGER NOT NULL," +
|
||||||
" created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP," +
|
" created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP," +
|
||||||
" updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP," +
|
" updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP," +
|
||||||
" FOREIGN KEY (title_id) REFERENCES nt_title(id) ON DELETE CASCADE" +
|
" FOREIGN KEY (title_id) REFERENCES mplt_title(id) ON DELETE CASCADE" +
|
||||||
");";
|
");";
|
||||||
|
|
||||||
sql += "INSERT INTO nt_title (" +
|
sql += "INSERT INTO mplt_title (" +
|
||||||
"id, " +
|
"id, " +
|
||||||
"title, " +
|
"title, " +
|
||||||
"description," +
|
"description," +
|
@ -1,4 +1,4 @@
|
|||||||
package cn.lunadeer.newbtitle.utils;
|
package cn.lunadeer.miniplayertitle.utils;
|
||||||
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.format.Style;
|
import net.kyori.adventure.text.format.Style;
|
||||||
@ -11,51 +11,53 @@ public class Notification {
|
|||||||
private static final Style w_style = Style.style(TextColor.color(255, 185, 69));
|
private static final Style w_style = Style.style(TextColor.color(255, 185, 69));
|
||||||
private static final Style e_style = Style.style(TextColor.color(255, 96, 72));
|
private static final Style e_style = Style.style(TextColor.color(255, 96, 72));
|
||||||
|
|
||||||
|
private static final String prefix = "[MiniPlayerTitle] ";
|
||||||
|
|
||||||
public static void info(Player player, String msg) {
|
public static void info(Player player, String msg) {
|
||||||
player.sendMessage(Component.text("[NewbTitle] " + msg, i_style));
|
player.sendMessage(Component.text(prefix + msg, i_style));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void warn(Player player, String msg) {
|
public static void warn(Player player, String msg) {
|
||||||
player.sendMessage(Component.text("[NewbTitle] " + msg, w_style));
|
player.sendMessage(Component.text(prefix + msg, w_style));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void error(Player player, String msg) {
|
public static void error(Player player, String msg) {
|
||||||
player.sendMessage(Component.text("[NewbTitle] " + msg, e_style));
|
player.sendMessage(Component.text(prefix + msg, e_style));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void info(CommandSender sender, String msg) {
|
public static void info(CommandSender sender, String msg) {
|
||||||
sender.sendMessage(Component.text("[NewbTitle] " + msg, i_style));
|
sender.sendMessage(Component.text(prefix + msg, i_style));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void warn(CommandSender sender, String msg) {
|
public static void warn(CommandSender sender, String msg) {
|
||||||
sender.sendMessage(Component.text("[NewbTitle] " + msg, w_style));
|
sender.sendMessage(Component.text(prefix + msg, w_style));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void error(CommandSender sender, String msg) {
|
public static void error(CommandSender sender, String msg) {
|
||||||
sender.sendMessage(Component.text("[NewbTitle] " + msg, e_style));
|
sender.sendMessage(Component.text(prefix + msg, e_style));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void info(Player player, Component msg) {
|
public static void info(Player player, Component msg) {
|
||||||
player.sendMessage(Component.text("[NewbTitle] ", i_style).append(msg));
|
player.sendMessage(Component.text(prefix, i_style).append(msg));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void warn(Player player, Component msg) {
|
public static void warn(Player player, Component msg) {
|
||||||
player.sendMessage(Component.text("[NewbTitle] " + msg, w_style).append(msg));
|
player.sendMessage(Component.text(prefix + msg, w_style).append(msg));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void error(Player player, Component msg) {
|
public static void error(Player player, Component msg) {
|
||||||
player.sendMessage(Component.text("[NewbTitle] " + msg, e_style).append(msg));
|
player.sendMessage(Component.text(prefix + msg, e_style).append(msg));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void info(CommandSender player, Component msg) {
|
public static void info(CommandSender player, Component msg) {
|
||||||
player.sendMessage(Component.text("[NewbTitle] ", i_style).append(msg));
|
player.sendMessage(Component.text(prefix, i_style).append(msg));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void warn(CommandSender player, Component msg) {
|
public static void warn(CommandSender player, Component msg) {
|
||||||
player.sendMessage(Component.text("[NewbTitle] " + msg, w_style).append(msg));
|
player.sendMessage(Component.text(prefix + msg, w_style).append(msg));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void error(CommandSender player, Component msg) {
|
public static void error(CommandSender player, Component msg) {
|
||||||
player.sendMessage(Component.text("[NewbTitle] " + msg, e_style).append(msg));
|
player.sendMessage(Component.text(prefix + msg, e_style).append(msg));
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package cn.lunadeer.newbtitle.utils.STUI;
|
package cn.lunadeer.miniplayertitle.utils.STUI;
|
||||||
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package cn.lunadeer.newbtitle.utils.STUI;
|
package cn.lunadeer.miniplayertitle.utils.STUI;
|
||||||
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.TextComponent;
|
import net.kyori.adventure.text.TextComponent;
|
@ -1,8 +1,7 @@
|
|||||||
package cn.lunadeer.newbtitle.utils.STUI;
|
package cn.lunadeer.miniplayertitle.utils.STUI;
|
||||||
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.TextComponent;
|
import net.kyori.adventure.text.TextComponent;
|
||||||
import net.kyori.adventure.text.event.ClickEvent;
|
|
||||||
import net.kyori.adventure.text.format.TextColor;
|
import net.kyori.adventure.text.format.TextColor;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@ -82,6 +81,21 @@ public class View {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public View title(TextComponent title) {
|
||||||
|
this.title = title;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public View subtitle(String subtitle) {
|
||||||
|
this.subtitle = Component.text(subtitle);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public View subtitle(TextComponent subtitle) {
|
||||||
|
this.subtitle = subtitle;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public View set(Slot line, TextComponent component) {
|
public View set(Slot line, TextComponent component) {
|
||||||
switch (line) {
|
switch (line) {
|
||||||
case SUBTITLE:
|
case SUBTITLE:
|
@ -1,17 +1,19 @@
|
|||||||
package cn.lunadeer.newbtitle.utils;
|
package cn.lunadeer.miniplayertitle.utils;
|
||||||
|
|
||||||
import cn.lunadeer.newbtitle.NewbTitle;
|
import cn.lunadeer.miniplayertitle.MiniPlayerTitle;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
public class XLogger {
|
public class XLogger {
|
||||||
private static final NewbTitle _plugin = NewbTitle.instance;
|
private static final MiniPlayerTitle _plugin = MiniPlayerTitle.instance;
|
||||||
private static final Logger _logger = _plugin.getLogger();
|
private static final Logger _logger = _plugin.getLogger();
|
||||||
|
|
||||||
|
private static final String prefix = "[MiniPlayerTitle] ";
|
||||||
|
|
||||||
public static void info(Player player, String message) {
|
public static void info(Player player, String message) {
|
||||||
Notification.info(player, "NewbTitle I | " + message);
|
Notification.info(player, prefix + "I | " + message);
|
||||||
if (NewbTitle.config.isDebug())
|
if (MiniPlayerTitle.config.isDebug())
|
||||||
debug("来自玩家[ " + player.getName() + " ] 的信息 | " + message);
|
debug("来自玩家[ " + player.getName() + " ] 的信息 | " + message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -20,8 +22,8 @@ public class XLogger {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void warn(Player player, String message) {
|
public static void warn(Player player, String message) {
|
||||||
Notification.warn(player, "NewbTitle W | " + message);
|
Notification.warn(player, prefix + "W | " + message);
|
||||||
if (NewbTitle.config.isDebug())
|
if (MiniPlayerTitle.config.isDebug())
|
||||||
debug("来自玩家[ " + player.getName() + " ] 的警告 | " + message);
|
debug("来自玩家[ " + player.getName() + " ] 的警告 | " + message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,8 +32,8 @@ public class XLogger {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void err(Player player, String message) {
|
public static void err(Player player, String message) {
|
||||||
Notification.error(player, "NewbTitle E | " + message);
|
Notification.error(player, prefix + "E | " + message);
|
||||||
if (NewbTitle.config.isDebug())
|
if (MiniPlayerTitle.config.isDebug())
|
||||||
debug("来自玩家[ " + player.getName() + " ] 的报错 | " + message);
|
debug("来自玩家[ " + player.getName() + " ] 的报错 | " + message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,15 +42,15 @@ public class XLogger {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void debug(Player player, String message) {
|
public static void debug(Player player, String message) {
|
||||||
if (!NewbTitle.config.isDebug()) return;
|
if (!MiniPlayerTitle.config.isDebug()) return;
|
||||||
if (player.isOp())
|
if (player.isOp())
|
||||||
Notification.info(player, "NewbTitle D | " + message);
|
Notification.info(player, prefix + "D | " + message);
|
||||||
else
|
else
|
||||||
debug("来自玩家[ " + player.getName() + " ] 的调试 | " + message);
|
debug("来自玩家[ " + player.getName() + " ] 的调试 | " + message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void debug(String message) {
|
public static void debug(String message) {
|
||||||
if (!NewbTitle.config.isDebug()) return;
|
if (!MiniPlayerTitle.config.isDebug()) return;
|
||||||
_logger.info(" D | " + message);
|
_logger.info(" D | " + message);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,9 +1,9 @@
|
|||||||
Database:
|
Database:
|
||||||
Host: localhost
|
Host: localhost
|
||||||
Port: 5432
|
Port: 5432
|
||||||
Name: newbtitle
|
Name: miniplayertitle
|
||||||
User: postgres
|
User: miniplayertitle
|
||||||
Pass: postgres
|
Pass: miniplayertitle
|
||||||
|
|
||||||
Prefix: "["
|
Prefix: "["
|
||||||
Suffix: "]"
|
Suffix: "]"
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
name: NewbTitle
|
name: MiniPlayerTitle
|
||||||
version: '${project.version}'
|
version: '${project.version}'
|
||||||
main: cn.lunadeer.newbtitle.NewbTitle
|
main: cn.lunadeer.miniplayertitle.MiniPlayerTitle
|
||||||
api-version: '1.20'
|
api-version: '1.20'
|
||||||
description: 称号插件。
|
description: 称号插件。
|
||||||
website: https://lunadeer.cn
|
website: https://lunadeer.cn
|
||||||
folia-supported: true
|
folia-supported: true
|
||||||
commands:
|
commands:
|
||||||
NewbTitle:
|
MiniPlayerTitle:
|
||||||
description: 称号插件命令
|
description: 称号插件命令
|
||||||
usage: /nt <cmd>
|
usage: /mplt <cmd>
|
||||||
aliases: [nt]
|
aliases: [mplt]
|
||||||
|
Loading…
Reference in New Issue
Block a user