This commit is contained in:
parent
a007966d70
commit
3ffab50c9b
2
pom.xml
2
pom.xml
@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>cn.lunadeer</groupId>
|
||||
<artifactId>MiniPlayerTitle</artifactId>
|
||||
<version>4.2.7</version>
|
||||
<version>4.2.8</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>MiniPlayerTitle</name>
|
||||
|
@ -32,19 +32,10 @@ public class Expansion extends PlaceholderExpansion {
|
||||
@Override
|
||||
public String onPlaceholderRequest(Player bukkitPlayer, @NotNull String params) {
|
||||
if (params.equalsIgnoreCase("player_title")) {
|
||||
PlayerInfoDTO player = PlayerInfoDTO.get(bukkitPlayer);
|
||||
if (player == null) {
|
||||
TitleDTO t = MiniPlayerTitle.instance.getPlayerUsingTitle(bukkitPlayer.getUniqueId());
|
||||
if (t == null) {
|
||||
return "";
|
||||
}
|
||||
if (player.getUsingTitle().getId() == -1) {
|
||||
return "";
|
||||
}
|
||||
PlayerTitleDTO title = PlayerTitleDTO.get(bukkitPlayer.getUniqueId(), player.getUsingTitle().getId());
|
||||
if (title == null || title.isExpired()) {
|
||||
player.setUsingTitle(null);
|
||||
return "";
|
||||
}
|
||||
TitleDTO t = title.getTitle();
|
||||
return ChatColor.translateAlternateColorCodes('&', t.getTitleColoredBukkit());
|
||||
}
|
||||
|
||||
|
@ -1,12 +1,16 @@
|
||||
package cn.lunadeer.miniplayertitle;
|
||||
|
||||
import cn.lunadeer.minecraftpluginutils.*;
|
||||
import cn.lunadeer.miniplayertitle.dtos.TitleDTO;
|
||||
import cn.lunadeer.miniplayertitle.utils.ConfigManager;
|
||||
import cn.lunadeer.miniplayertitle.utils.DatabaseTables;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
public final class MiniPlayerTitle extends JavaPlugin {
|
||||
|
||||
@ -71,8 +75,17 @@ public final class MiniPlayerTitle extends JavaPlugin {
|
||||
public static ConfigManager config;
|
||||
public static DatabaseManager database;
|
||||
private GiteaReleaseCheck giteaReleaseCheck;
|
||||
private Map<UUID, TitleDTO> playerUsingTitle = new HashMap<>();
|
||||
|
||||
public static boolean usingPapi() {
|
||||
return Bukkit.getPluginManager().isPluginEnabled("PlaceholderAPI");
|
||||
}
|
||||
|
||||
public void setPlayerUsingTitle(UUID uuid, TitleDTO title) {
|
||||
playerUsingTitle.put(uuid, title);
|
||||
}
|
||||
|
||||
public TitleDTO getPlayerUsingTitle(UUID uuid) {
|
||||
return playerUsingTitle.get(uuid);
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package cn.lunadeer.miniplayertitle.commands;
|
||||
|
||||
import cn.lunadeer.minecraftpluginutils.Notification;
|
||||
import cn.lunadeer.miniplayertitle.MiniPlayerTitle;
|
||||
import cn.lunadeer.miniplayertitle.dtos.TitleDTO;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -24,6 +25,7 @@ public class Apis {
|
||||
}
|
||||
|
||||
public static void updateName(Player player, @Nullable TitleDTO title) {
|
||||
MiniPlayerTitle.instance.setPlayerUsingTitle(player.getUniqueId(), title);
|
||||
if (usingPapi()) {
|
||||
return;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user