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