Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
40e561bff1 | |||
11856a29a6 | |||
78de7dca65 | |||
466dd84fac | |||
283e435b70 |
@ -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%">
|
<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>
|
<groupId>cn.lunadeer</groupId>
|
||||||
<artifactId>MiniPlayerTitle</artifactId>
|
<artifactId>MiniPlayerTitle</artifactId>
|
||||||
<version>4.6.0</version>
|
<version>4.7.1</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>MiniPlayerTitle</name>
|
<name>MiniPlayerTitle</name>
|
||||||
@ -82,7 +82,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>cn.lunadeer</groupId>
|
<groupId>cn.lunadeer</groupId>
|
||||||
<artifactId>MinecraftPluginUtils</artifactId>
|
<artifactId>MinecraftPluginUtils</artifactId>
|
||||||
<version>1.3.4-SNAPSHOT</version>
|
<version>1.3.7-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>me.clip</groupId>
|
<groupId>me.clip</groupId>
|
||||||
|
@ -34,7 +34,7 @@ public class Expansion extends PlaceholderExpansion {
|
|||||||
if (t == null) {
|
if (t == null) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
return ChatColor.translateAlternateColorCodes('&', t.getTitleColoredBukkit());
|
return t.getTitleColoredBukkit();
|
||||||
}
|
}
|
||||||
|
|
||||||
return null; //
|
return null; //
|
||||||
@ -52,6 +52,6 @@ public class Expansion extends PlaceholderExpansion {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull String getVersion() {
|
public @NotNull String getVersion() {
|
||||||
return plugin.getPluginMeta().getVersion();
|
return MiniPlayerTitle.instance.getDescription().getVersion();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@ import cn.lunadeer.minecraftpluginutils.Notification;
|
|||||||
import cn.lunadeer.miniplayertitle.dtos.PlayerTitleDTO;
|
import cn.lunadeer.miniplayertitle.dtos.PlayerTitleDTO;
|
||||||
import cn.lunadeer.miniplayertitle.dtos.TitleDTO;
|
import cn.lunadeer.miniplayertitle.dtos.TitleDTO;
|
||||||
import cn.lunadeer.miniplayertitle.dtos.TitleShopDTO;
|
import cn.lunadeer.miniplayertitle.dtos.TitleShopDTO;
|
||||||
import cn.lunadeer.miniplayertitle.tuis.MyTitles;
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -40,6 +39,10 @@ public class TitleCard implements Listener {
|
|||||||
Notification.error(sender, "获取销售详情时出现错误");
|
Notification.error(sender, "获取销售详情时出现错误");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (titleShop.getDays() == 0) {
|
||||||
|
Notification.error(sender, "不可以生成天数为0的称号卡!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
ItemStack card = TitleCard.create(titleShop);
|
ItemStack card = TitleCard.create(titleShop);
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
player.getInventory().addItem(card);
|
player.getInventory().addItem(card);
|
||||||
@ -61,6 +64,7 @@ public class TitleCard implements Listener {
|
|||||||
}
|
}
|
||||||
use(player, item);
|
use(player, item);
|
||||||
player.getInventory().removeItem(item);
|
player.getInventory().removeItem(item);
|
||||||
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ItemStack create(@NotNull TitleShopDTO saleInfo) {
|
private static ItemStack create(@NotNull TitleShopDTO saleInfo) {
|
||||||
|
@ -5,13 +5,11 @@ import cn.lunadeer.miniplayertitle.MiniPlayerTitle;
|
|||||||
import cn.lunadeer.miniplayertitle.dtos.PlayerInfoDTO;
|
import cn.lunadeer.miniplayertitle.dtos.PlayerInfoDTO;
|
||||||
import cn.lunadeer.miniplayertitle.dtos.PlayerTitleDTO;
|
import cn.lunadeer.miniplayertitle.dtos.PlayerTitleDTO;
|
||||||
import cn.lunadeer.miniplayertitle.dtos.TitleDTO;
|
import cn.lunadeer.miniplayertitle.dtos.TitleDTO;
|
||||||
import cn.lunadeer.miniplayertitle.dtos.TitleShopDTO;
|
|
||||||
import cn.lunadeer.miniplayertitle.tuis.AllTitles;
|
import cn.lunadeer.miniplayertitle.tuis.AllTitles;
|
||||||
import cn.lunadeer.miniplayertitle.tuis.MyTitles;
|
import cn.lunadeer.miniplayertitle.tuis.MyTitles;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
|
|
||||||
import static cn.lunadeer.miniplayertitle.commands.Apis.updateName;
|
import static cn.lunadeer.miniplayertitle.commands.Apis.updateName;
|
||||||
|
|
||||||
|
@ -1,21 +1,16 @@
|
|||||||
package cn.lunadeer.miniplayertitle.dtos;
|
package cn.lunadeer.miniplayertitle.dtos;
|
||||||
|
|
||||||
import cn.lunadeer.minecraftpluginutils.XLogger;
|
import cn.lunadeer.minecraftpluginutils.ColorParser;
|
||||||
import cn.lunadeer.minecraftpluginutils.databse.DatabaseManager;
|
import cn.lunadeer.minecraftpluginutils.databse.DatabaseManager;
|
||||||
import cn.lunadeer.minecraftpluginutils.databse.Field;
|
import cn.lunadeer.minecraftpluginutils.databse.Field;
|
||||||
import cn.lunadeer.minecraftpluginutils.databse.FieldType;
|
import cn.lunadeer.minecraftpluginutils.databse.FieldType;
|
||||||
import cn.lunadeer.miniplayertitle.Color;
|
|
||||||
import cn.lunadeer.miniplayertitle.MiniPlayerTitle;
|
import cn.lunadeer.miniplayertitle.MiniPlayerTitle;
|
||||||
import net.kyori.adventure.text.Component;
|
|
||||||
import net.kyori.adventure.text.TextComponent;
|
import net.kyori.adventure.text.TextComponent;
|
||||||
import net.kyori.adventure.text.event.HoverEvent;
|
|
||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
import static cn.lunadeer.minecraftpluginutils.databse.DatabaseManager.handleDatabaseError;
|
import static cn.lunadeer.minecraftpluginutils.databse.DatabaseManager.handleDatabaseError;
|
||||||
|
|
||||||
@ -80,32 +75,8 @@ public class TitleDTO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public TextComponent getTitleColored() {
|
public TextComponent getTitleColored() {
|
||||||
TextComponent prefix = Component.text(MiniPlayerTitle.config.getPrefix(), new Color("#ffffff").getStyle());
|
String with_pre_suf = "&#ffffff" + MiniPlayerTitle.config.getPrefix() + getTitleRaw() + "&#ffffff" + MiniPlayerTitle.config.getSuffix();
|
||||||
TextComponent suffix = Component.text(MiniPlayerTitle.config.getSuffix(), new Color("#ffffff").getStyle());
|
return ColorParser.getComponentType(with_pre_suf);
|
||||||
String[] parts = getTitleRaw().split("&#");
|
|
||||||
List<TextComponent> components = new ArrayList<>();
|
|
||||||
components.add(prefix);
|
|
||||||
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()));
|
|
||||||
}
|
|
||||||
components.add(suffix);
|
|
||||||
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(getDescription())));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -116,38 +87,12 @@ public class TitleDTO {
|
|||||||
* @return String
|
* @return String
|
||||||
*/
|
*/
|
||||||
public String getTitleColoredBukkit() {
|
public String getTitleColoredBukkit() {
|
||||||
String title = "&f" + MiniPlayerTitle.config.getPrefix() + getTitleRaw() + "&f" + MiniPlayerTitle.config.getSuffix();
|
String with_pre_suf = "&#ffffff" + MiniPlayerTitle.config.getPrefix() + getTitleRaw() + "&#ffffff" + MiniPlayerTitle.config.getSuffix();
|
||||||
title = title.replaceAll("&#", "#");
|
return ColorParser.getBukkitType(with_pre_suf);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTitlePlainText() {
|
public String getTitlePlainText() {
|
||||||
String[] parts = getTitleRaw().split("&#");
|
return ColorParser.getPlainText(getTitleRaw());
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getId() {
|
public Integer getId() {
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
package cn.lunadeer.miniplayertitle.events;
|
package cn.lunadeer.miniplayertitle.events;
|
||||||
|
|
||||||
import cn.lunadeer.minecraftpluginutils.Notification;
|
|
||||||
import cn.lunadeer.miniplayertitle.MiniPlayerTitle;
|
import cn.lunadeer.miniplayertitle.MiniPlayerTitle;
|
||||||
import net.kyori.adventure.text.Component;
|
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerChatEvent;
|
import org.bukkit.event.player.PlayerChatEvent;
|
||||||
|
Loading…
Reference in New Issue
Block a user