rename project
All checks were successful
Java CI-CD with Maven / build (push) Successful in 1h27m1s

This commit is contained in:
zhangyuheng 2024-01-09 01:30:03 +08:00
parent 7b41d0f591
commit e83e4578bb
17 changed files with 144 additions and 148 deletions

View File

@ -1,2 +1,2 @@
# NewbTitle
# MiniPlayerTitle

View File

@ -5,11 +5,11 @@
<modelVersion>4.0.0</modelVersion>
<groupId>cn.lunadeer</groupId>
<artifactId>NewbTitle</artifactId>
<version>0.36-alpha</version>
<artifactId>MiniPlayerTitle</artifactId>
<version>1.0-beta</version>
<packaging>jar</packaging>
<name>NewbTitle</name>
<name>MiniPlayerTitle</name>
<properties>
<java.version>1.8</java.version>

View File

@ -33,7 +33,7 @@ public class Commands implements TabExecutor {
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
switch (label) {
case "nt":
case "mplt":
if (args.length == 0) {
printHelp(sender);
return true;
@ -79,13 +79,13 @@ public class Commands implements TabExecutor {
private void printHelp(@NotNull CommandSender sender) {
if (sender instanceof Player) {
Player player = (Player) sender;
Notification.warn(player, "用法: /nt <use|list|shop|buy>");
if (player.isOp()){
Notification.warn(player, "用法: /nt <create|delete|setdesc|setname|addshop|removeshop|setprice|setamount|setendat|listall>");
Notification.warn(player, "用法: /mplt <use|list|shop|buy>");
if (player.isOp()) {
Notification.warn(player, "用法: /mplt <create|delete|setdesc|setname|addshop|removeshop|setprice|setamount|setendat|listall>");
}
} else {
XLogger.info("用法: /nt <use|list|shop|buy>");
XLogger.info("用法: /nt <create|delete|setdesc|setname|addshop|removeshop|setprice|setamount|setendat|listall>");
XLogger.info("用法: /mplt <use|list|shop|buy>");
XLogger.info("用法: /mplt <create|delete|setdesc|setname|addshop|removeshop|setprice|setamount|setendat|listall>");
}
}
@ -104,9 +104,7 @@ public class Commands implements TabExecutor {
*/
@Override
public @Nullable List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
switch (label) {
case "nt":
if (args.length == 0) {
if (args.length == 1) {
String[] player_cmd = {"use", "list", "shop", "buy"};
String[] admin_cmd = {"create", "delete", "setdesc", "setname", "addshop", "removeshop", "setprice", "setamount", "setendat", "listall"};
List<String> res = new ArrayList<>();
@ -152,9 +150,7 @@ public class Commands implements TabExecutor {
default:
return Arrays.asList("use", "list", "shop", "buy");
}
default:
return null;
}
}

View File

@ -8,7 +8,7 @@ import org.bukkit.plugin.java.JavaPlugin;
import java.util.Objects;
public final class NewbTitle extends JavaPlugin {
public final class MiniPlayerTitle extends JavaPlugin {
@Override
public void onEnable() {
@ -18,8 +18,8 @@ public final class NewbTitle extends JavaPlugin {
Database.migrate();
Bukkit.getPluginManager().registerEvents(new Events(), this);
Objects.requireNonNull(Bukkit.getPluginCommand("NewbTitle")).setExecutor(new Commands());
Objects.requireNonNull(Bukkit.getPluginCommand("NewbTitle")).setTabCompleter(new Commands());
Objects.requireNonNull(Bukkit.getPluginCommand("MiniPlayerTitle")).setExecutor(new Commands());
Objects.requireNonNull(Bukkit.getPluginCommand("MiniPlayerTitle")).setTabCompleter(new Commands());
XLogger.info("NewbTitle 称号插件已加载");
}
@ -29,6 +29,6 @@ public final class NewbTitle extends JavaPlugin {
// Plugin shutdown logic
}
public static NewbTitle instance;
public static MiniPlayerTitle instance;
public static ConfigManager config;
}

View File

@ -17,7 +17,7 @@ public class PlayerTitle extends Title {
public static PlayerTitle create(Integer title_id, UUID player_uuid) {
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 += "RETURNING id;";
try (ResultSet rs = Database.query(sql)) {
@ -59,7 +59,7 @@ public class PlayerTitle extends Title {
private void save() {
String sql = "";
sql += "UPDATE nt_player_title ";
sql += "UPDATE mplt_player_title ";
sql += "SET expire_at = " + this._expire_at + ", ";
sql += "updated_at = CURRENT_TIMESTAMP ";
sql += "WHERE player_uuid = '" + _player_uuid.toString() + "', ";

View File

@ -25,7 +25,7 @@ public class SaleTitle extends Title {
public static SaleTitle create(Integer title_id) {
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 += "RETURNING id;";
try (ResultSet rs = Database.query(sql)) {
@ -111,7 +111,7 @@ public class SaleTitle extends Title {
private void save() {
String sql = "";
sql += "UPDATE nt_title_shop ";
sql += "UPDATE mplt_title_shop ";
sql += "SET title_id = " + this._id + ", ";
sql += "price = " + this._price + ", ";
sql += "days = " + this._days + ", ";

View File

@ -8,7 +8,6 @@ import cn.lunadeer.newbtitle.utils.STUI.View;
import cn.lunadeer.newbtitle.utils.XLogger;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.event.ClickEvent;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -42,7 +41,7 @@ public class Shop {
TextComponent idx = Component.text("[" + title_sale_id + "] ");
SaleTitle title = titles.get(title_sale_id);
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)
.append(title.getTitle())
.append("价格:" + title.getPrice() + " 有效期:" + title.getDays() + "")
@ -51,13 +50,13 @@ public class Shop {
.append(button);
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);
}
public static void deleteTitle(Integer id) {
String sql = "";
sql += "DELETE FROM nt_title_shop WHERE id = " + id + ";";
sql += "DELETE FROM mplt_title_shop WHERE id = " + id + ";";
Database.query(sql);
}
@ -70,7 +69,7 @@ public class Shop {
sql += "days, ";
sql += "amount, ";
sql += "sale_end_at ";
sql += "FROM nt_title_shop;";
sql += "FROM mplt_title_shop;";
Map<Integer, SaleTitle> titles = new HashMap<>();
try (ResultSet rs = Database.query(sql)) {
while (rs != null && rs.next()) {
@ -98,7 +97,7 @@ public class Shop {
sql += "days, ";
sql += "amount, ";
sql += "sale_end_at ";
sql += "FROM nt_title_shop ";
sql += "FROM mplt_title_shop ";
sql += "WHERE id = " + sale_id + ";";
try (ResultSet rs = Database.query(sql)) {
if (rs != null && rs.next()) {

View File

@ -8,7 +8,6 @@ import cn.lunadeer.newbtitle.utils.XLogger;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.JoinConfiguration;
import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.event.ClickEvent;
import net.kyori.adventure.text.event.HoverEvent;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -26,7 +25,7 @@ public class Title {
public static Title create(String title, String description) {
String sql = "";
sql += "INSERT INTO nt_title (title, description, enabled) VALUES (";
sql += "INSERT INTO mplt_title (title, description, enabled) VALUES (";
sql += "'" + title + "', ";
sql += "'" + description + "', ";
sql += "true ";
@ -45,7 +44,7 @@ public class Title {
public static List<Title> all() {
List<Title> titles = new ArrayList<>();
String sql = "";
sql += "SELECT id FROM nt_title;";
sql += "SELECT id FROM mplt_title;";
try (ResultSet rs = Database.query(sql)) {
if (rs != null) {
while (rs.next()) {
@ -84,7 +83,7 @@ public class Title {
line.append(idx).append(titles.get(i).getTitle());
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);
}
@ -92,7 +91,7 @@ public class Title {
this._id = id;
String sql = "";
sql += "SELECT id, title, description, enabled ";
sql += "FROM nt_title ";
sql += "FROM mplt_title ";
sql += "WHERE id = " + id + ";";
try (ResultSet rs = Database.query(sql)) {
if (rs != null && rs.next()) {
@ -107,20 +106,20 @@ public class Title {
public static void delete(Integer id) {
String sql = "";
sql += "DELETE FROM nt_title WHERE id = " + id + ";";
sql += "DELETE FROM mplt_title WHERE id = " + id + ";";
Database.query(sql);
}
private void save() {
String sql = "";
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._description + "', ";
sql += this._enabled + " ";
sql += ");";
} else {
sql += "UPDATE nt_title SET ";
sql += "UPDATE mplt_title SET ";
sql += "title = '" + this._title + "', ";
sql += "description = '" + this._description + "', ";
sql += "enabled = " + this._enabled + " ";
@ -135,8 +134,8 @@ public class Title {
}
public Component getTitle() {
TextComponent prefix = Component.text(NewbTitle.config.getPrefix());
TextComponent suffix = Component.text(NewbTitle.config.getSuffix());
TextComponent prefix = Component.text(MiniPlayerTitle.config.getPrefix());
TextComponent suffix = Component.text(MiniPlayerTitle.config.getSuffix());
String[] parts = this._title.split("&#");
List<TextComponent> components = new ArrayList<>();
components.add(prefix);

View File

@ -8,7 +8,6 @@ import cn.lunadeer.newbtitle.utils.STUI.View;
import cn.lunadeer.newbtitle.utils.XLogger;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.event.ClickEvent;
import org.bukkit.entity.Player;
import java.sql.ResultSet;
@ -56,14 +55,14 @@ public class XPlayer {
PlayerTitle title = titles.get(title_id);
Line line = Line.create();
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)
.append(title.getTitle())
.append(Component.text("有效期至:" + title.getExpireAt()))
.append(button);
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);
}
@ -74,7 +73,7 @@ public class XPlayer {
return;
}
String sql = "";
sql += "UPDATE nt_player_using_title ";
sql += "UPDATE mplt_player_using_title ";
sql += "SET title_id = " + _current_title_id + ", ";
sql += "updated_at = CURRENT_TIMESTAMP ";
sql += "WHERE uuid = '" + _player.getUniqueId().toString() + "';";
@ -103,7 +102,7 @@ public class XPlayer {
public void set_coin(Integer coin) {
_coin = coin;
String sql = "";
sql += "UPDATE nt_player_coin ";
sql += "UPDATE mplt_player_coin ";
sql += "SET coin = " + coin + ", ";
sql += "updated_at = CURRENT_TIMESTAMP ";
sql += "WHERE uuid = '" + _player.getUniqueId().toString() + "';";
@ -118,7 +117,7 @@ public class XPlayer {
String sql = "";
sql += "SELECT ";
sql += "title_id, expire_at ";
sql += "FROM nt_player_title ";
sql += "FROM mplt_player_title ";
sql += "WHERE player_uuid = '" + uuid.toString() + "';";
Map<Integer, PlayerTitle> titles = new HashMap<>();
try (ResultSet rs = Database.query(sql)) {
@ -137,7 +136,7 @@ public class XPlayer {
private static Integer getCurrentTitleId(UUID uuid) {
String sql = "";
sql += "SELECT title_id ";
sql += "FROM nt_player_using_title ";
sql += "FROM mplt_player_using_title ";
sql += "WHERE uuid = '" + uuid.toString() + "';";
Integer current_title_id = null;
try (ResultSet rs = Database.query(sql)) {
@ -146,7 +145,7 @@ public class XPlayer {
} else {
current_title_id = -1;
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 += current_title_id + ");";
Database.query(sql);
@ -160,7 +159,7 @@ public class XPlayer {
private static Integer getCoin(UUID uuid) {
String sql = "";
sql += "SELECT coin ";
sql += "FROM nt_player_coin ";
sql += "FROM mplt_player_coin ";
sql += "WHERE uuid = '" + uuid.toString() + "';";
Integer coin = null;
try (ResultSet rs = Database.query(sql)) {
@ -169,7 +168,7 @@ public class XPlayer {
} else {
coin = 0;
sql = "";
sql += "INSERT INTO nt_player_coin (uuid, coin) VALUES (";
sql += "INSERT INTO mplt_player_coin (uuid, coin) VALUES (";
sql += "'" + uuid + "', ";
sql += coin + ");";
Database.query(sql);

View File

@ -17,7 +17,7 @@ public class AdminCommands {
}
}
if (args.length != 3) {
Notification.warn(sender, "用法: /nt create <称号名称> <称号描述>");
Notification.warn(sender, "用法: /mplt create <称号名称> <称号描述>");
return true;
}
Title.create(args[1], args[2]);
@ -33,7 +33,7 @@ public class AdminCommands {
}
}
if (args.length != 2) {
Notification.warn(sender, "用法: /nt delete <称号ID>");
Notification.warn(sender, "用法: /mplt delete <称号ID>");
return true;
}
Title.delete(Integer.parseInt(args[1]));
@ -70,7 +70,7 @@ public class AdminCommands {
}
}
if (args.length != 3) {
Notification.warn(sender, "用法: /nt setdesc <称号ID> <称号描述>");
Notification.warn(sender, "用法: /mplt setdesc <称号ID> <称号描述>");
return true;
}
Title title = new Title(Integer.parseInt(args[1]));
@ -87,7 +87,7 @@ public class AdminCommands {
}
}
if (args.length != 3) {
Notification.warn(sender, "用法: /nt setname <称号ID> <称号名称>");
Notification.warn(sender, "用法: /mplt setname <称号ID> <称号名称>");
return true;
}
Title title = new Title(Integer.parseInt(args[1]));
@ -104,7 +104,7 @@ public class AdminCommands {
}
}
if (args.length != 2) {
Notification.warn(sender, "用法: /nt addshop <称号ID>");
Notification.warn(sender, "用法: /mplt addshop <称号ID>");
return true;
}
SaleTitle title = SaleTitle.create(Integer.parseInt(args[1]));
@ -126,7 +126,7 @@ public class AdminCommands {
}
}
if (args.length != 2) {
Notification.warn(sender, "用法: /nt removeshop <商品ID>");
Notification.warn(sender, "用法: /mplt removeshop <商品ID>");
return true;
}
SaleTitle.delete(Integer.parseInt(args[1]));
@ -142,7 +142,7 @@ public class AdminCommands {
}
}
if (args.length != 4) {
Notification.warn(sender, "用法: /nt setprice <商品ID> <价格> <天数>(-1为永久)");
Notification.warn(sender, "用法: /mplt setprice <商品ID> <价格> <天数>(-1为永久)");
return true;
}
SaleTitle.setPrice(Integer.parseInt(args[1]), Integer.parseInt(args[2]));
@ -159,7 +159,7 @@ public class AdminCommands {
}
}
if (args.length != 3) {
Notification.warn(sender, "用法: /nt setamount <商品ID> <数量>(-1为无限)");
Notification.warn(sender, "用法: /mplt setamount <商品ID> <数量>(-1为无限)");
return true;
}
SaleTitle.setAmount(Integer.parseInt(args[1]), Integer.parseInt(args[2]));
@ -175,7 +175,7 @@ public class AdminCommands {
}
}
if (args.length != 3) {
Notification.warn(sender, "用法: /nt setendat <商品ID> <时间YYYYMMDD>(-1为永久)");
Notification.warn(sender, "用法: /mplt setendat <商品ID> <时间YYYYMMDD>(-1为永久)");
return true;
}
long time_stamp;

View File

@ -15,7 +15,7 @@ public class PlayerCommands {
}
org.bukkit.entity.Player player = (org.bukkit.entity.Player) sender;
if (args.length != 2) {
Notification.warn(player, "用法: /nt use <称号ID>");
Notification.warn(player, "用法: /mplt use <称号ID>");
return true;
}
@ -64,7 +64,7 @@ public class PlayerCommands {
}
org.bukkit.entity.Player player = (org.bukkit.entity.Player) sender;
if (args.length != 2) {
Notification.warn(player, "用法: /nt buy <称号ID>");
Notification.warn(player, "用法: /mplt buy <称号ID>");
return true;
}
XPlayer xPlayer = new XPlayer(player);

View File

@ -1,10 +1,10 @@
package cn.lunadeer.newbtitle.utils;
import cn.lunadeer.newbtitle.NewbTitle;
import cn.lunadeer.newbtitle.MiniPlayerTitle;
import org.bukkit.configuration.file.FileConfiguration;
public class ConfigManager {
public ConfigManager(NewbTitle plugin) {
public ConfigManager(MiniPlayerTitle plugin) {
_plugin = plugin;
_plugin.saveDefaultConfig();
reload();
@ -94,7 +94,7 @@ public class ConfigManager {
}
private final NewbTitle _plugin;
private final MiniPlayerTitle _plugin;
private FileConfiguration _file;
private Boolean _debug;

View File

@ -1,6 +1,6 @@
package cn.lunadeer.newbtitle.utils;
import cn.lunadeer.newbtitle.NewbTitle;
import cn.lunadeer.newbtitle.MiniPlayerTitle;
import java.sql.*;
@ -9,7 +9,7 @@ public class Database {
private static Connection getConnection() {
try {
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) {
XLogger.err("Database connection failed: " + e.getMessage());
return null;
@ -35,7 +35,7 @@ public class Database {
String sql = "";
// title table
sql += "CREATE TABLE IF NOT EXISTS nt_title (" +
sql += "CREATE TABLE IF NOT EXISTS mplt_title (" +
" id SERIAL PRIMARY KEY," +
" title TEXT NOT NULL," +
" description TEXT NOT NULL," +
@ -45,7 +45,7 @@ public class Database {
");";
// 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," +
" title_id INTEGER NOT NULL," +
" price INTEGER NOT NULL DEFAULT 0," +
@ -54,11 +54,11 @@ public class Database {
" 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 nt_title(id) ON DELETE CASCADE" +
" FOREIGN KEY (title_id) REFERENCES mplt_title(id) ON DELETE CASCADE" +
");";
// 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," +
" coin INTEGER NOT NULL DEFAULT 0," +
" created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP," +
@ -66,26 +66,26 @@ public class Database {
");";
// 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," +
" 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 nt_title(id) ON DELETE CASCADE" +
" FOREIGN KEY (title_id) REFERENCES mplt_title(id) ON DELETE CASCADE" +
");";
// 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," +
" title_id INTEGER NOT NULL," +
" created_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, " +
"title, " +
"description," +

View File

@ -11,51 +11,53 @@ public class Notification {
private static final Style w_style = Style.style(TextColor.color(255, 185, 69));
private static final Style e_style = Style.style(TextColor.color(255, 96, 72));
private static final String prefix = "[MiniPlayerTitle] ";
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) {
player.sendMessage(Component.text("[NewbTitle] " + msg, w_style));
player.sendMessage(Component.text(prefix + msg, w_style));
}
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) {
sender.sendMessage(Component.text("[NewbTitle] " + msg, i_style));
sender.sendMessage(Component.text(prefix + msg, i_style));
}
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) {
sender.sendMessage(Component.text("[NewbTitle] " + msg, e_style));
sender.sendMessage(Component.text(prefix + msg, e_style));
}
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) {
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) {
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) {
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) {
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) {
player.sendMessage(Component.text("[NewbTitle] " + msg, e_style).append(msg));
player.sendMessage(Component.text(prefix + msg, e_style).append(msg));
}
}

View File

@ -2,7 +2,6 @@ package cn.lunadeer.newbtitle.utils.STUI;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.event.ClickEvent;
import net.kyori.adventure.text.format.TextColor;
import org.bukkit.entity.Player;

View File

@ -1,17 +1,19 @@
package cn.lunadeer.newbtitle.utils;
import cn.lunadeer.newbtitle.NewbTitle;
import cn.lunadeer.newbtitle.MiniPlayerTitle;
import org.bukkit.entity.Player;
import java.util.logging.Logger;
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 String prefix = "[MiniPlayerTitle] ";
public static void info(Player player, String message) {
Notification.info(player, "NewbTitle I | " + message);
if (NewbTitle.config.isDebug())
Notification.info(player, prefix + "I | " + message);
if (MiniPlayerTitle.config.isDebug())
debug("来自玩家[ " + player.getName() + " ] 的信息 | " + message);
}
@ -20,8 +22,8 @@ public class XLogger {
}
public static void warn(Player player, String message) {
Notification.warn(player, "NewbTitle W | " + message);
if (NewbTitle.config.isDebug())
Notification.warn(player, prefix + "W | " + message);
if (MiniPlayerTitle.config.isDebug())
debug("来自玩家[ " + player.getName() + " ] 的警告 | " + message);
}
@ -30,8 +32,8 @@ public class XLogger {
}
public static void err(Player player, String message) {
Notification.error(player, "NewbTitle E | " + message);
if (NewbTitle.config.isDebug())
Notification.error(player, prefix + "E | " + message);
if (MiniPlayerTitle.config.isDebug())
debug("来自玩家[ " + player.getName() + " ] 的报错 | " + message);
}
@ -40,15 +42,15 @@ public class XLogger {
}
public static void debug(Player player, String message) {
if (!NewbTitle.config.isDebug()) return;
if (!MiniPlayerTitle.config.isDebug()) return;
if (player.isOp())
Notification.info(player, "NewbTitle D | " + message);
Notification.info(player, prefix + "D | " + message);
else
debug("来自玩家[ " + player.getName() + " ] 的调试 | " + message);
}
public static void debug(String message) {
if (!NewbTitle.config.isDebug()) return;
if (!MiniPlayerTitle.config.isDebug()) return;
_logger.info(" D | " + message);
}
}

View File

@ -1,12 +1,12 @@
name: NewbTitle
name: MiniPlayerTitle
version: '${project.version}'
main: cn.lunadeer.newbtitle.NewbTitle
main: cn.lunadeer.miniplayertitle.MiniPlayerTitle
api-version: '1.20'
description: 称号插件。
website: https://lunadeer.cn
folia-supported: true
commands:
NewbTitle:
MiniPlayerTitle:
description: 称号插件命令
usage: /nt <cmd>
aliases: [nt]
usage: /mplt <cmd>
aliases: [mplt]