mirror of
https://github.com/Xiao-MoMi/Custom-Nameplates.git
synced 2025-12-19 15:09:23 +00:00
2.0.6
This commit is contained in:
@@ -4,7 +4,7 @@ plugins {
|
||||
}
|
||||
|
||||
group = 'net.momirealms'
|
||||
version = '2.0.5-hotfix-2'
|
||||
version = '2.0.6'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
@@ -54,6 +54,7 @@ dependencies {
|
||||
implementation('net.kyori:adventure-platform-bukkit:4.1.2')
|
||||
implementation('net.kyori:adventure-text-minimessage:4.11.0')
|
||||
implementation('net.kyori:adventure-text-serializer-gson:4.11.0')
|
||||
implementation("org.bstats:bstats-bukkit:3.0.0")
|
||||
}
|
||||
|
||||
def targetJavaVersion = 16
|
||||
@@ -86,7 +87,8 @@ tasks.withType(JavaCompile) {
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
relocate ('net.kyori', 'net.momirealms.customnameplates.libs')
|
||||
relocate ('net.kyori', 'net.momirealms.customnameplates.libs.net.kyori')
|
||||
relocate ('org.bstats', 'net.momirealms.customnameplates.libs.org.bstats')
|
||||
}
|
||||
|
||||
tasks.register("delete", Delete).get().delete("build/libs/"+project.name+"-"+project.version+".jar")
|
||||
|
||||
@@ -107,7 +107,7 @@ public class ConfigManager {
|
||||
public static String ss_folder_path;
|
||||
public static String bb_folder_path;
|
||||
public static String font;
|
||||
public static String trChatChannel;
|
||||
public static String[] trChatChannel;
|
||||
|
||||
public static boolean itemsAdder;
|
||||
public static boolean placeholderAPI;
|
||||
@@ -147,7 +147,7 @@ public class ConfigManager {
|
||||
tab_bc = config.getBoolean("config.integrations.TAB-BC",false);
|
||||
oraxen = config.getBoolean("config.integrations.Oraxen",false);
|
||||
trChat = config.getBoolean("config.integrations.TrChat",false);
|
||||
trChatChannel = config.getString("config.integrations.TrChat-private-channel","Private");
|
||||
trChatChannel = config.getStringList("config.integrations.TrChat-exlude-channels").toArray(new String[0]);
|
||||
offsets = config.getIntegerList("config.ascii-y-offset.offset");
|
||||
|
||||
if(config.getBoolean("config.extract-shader",true)) {
|
||||
|
||||
@@ -48,6 +48,7 @@ import net.momirealms.customnameplates.nameplates.mode.tmpackets.TeamPacketUtil;
|
||||
import net.momirealms.customnameplates.nameplates.mode.tp.TeleportingTag;
|
||||
import net.momirealms.customnameplates.resource.ResourceManager;
|
||||
import net.momirealms.customnameplates.utils.AdventureUtil;
|
||||
import org.bstats.bukkit.Metrics;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
@@ -102,6 +103,8 @@ public final class CustomNameplates extends JavaPlugin {
|
||||
this.resourceManager.generateResourcePack();
|
||||
|
||||
AdventureUtil.consoleMessage("<gradient:#2E8B57:#48D1CC>[CustomNameplates]</gradient> <color:#baffd1>Plugin Enabled!");
|
||||
|
||||
new Metrics(this, 16649);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -29,7 +29,7 @@ import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
public class ActionBarTask {
|
||||
|
||||
private ActionBarConfig config;
|
||||
private final ActionBarConfig config;
|
||||
private int timer_1;
|
||||
private int timer_2;
|
||||
private int counter;
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
package net.momirealms.customnameplates.api.events;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class BubblesEvent extends PlayerEvent implements Cancellable {
|
||||
|
||||
private boolean cancelled;
|
||||
private String bubble;
|
||||
private String text;
|
||||
private static final HandlerList handlerList = new HandlerList();
|
||||
|
||||
public BubblesEvent(@NotNull Player who, String bubble, String text) {
|
||||
super(who);
|
||||
this.cancelled = false;
|
||||
this.bubble = bubble;
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
cancelled = cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return handlerList;
|
||||
}
|
||||
|
||||
public String getBubble() {
|
||||
return bubble;
|
||||
}
|
||||
|
||||
public void setBubble(String bubble) {
|
||||
this.bubble = bubble;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
public void setText(String text) {
|
||||
this.text = text;
|
||||
}
|
||||
}
|
||||
@@ -26,10 +26,11 @@ import org.bukkit.entity.Player;
|
||||
import java.util.HashMap;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class DataManager {
|
||||
|
||||
private final HashMap<UUID, PlayerData> cache = new HashMap<>();
|
||||
private final ConcurrentHashMap<UUID, PlayerData> cache = new ConcurrentHashMap<>();
|
||||
|
||||
public PlayerData getOrEmpty(Player player) {
|
||||
if (cache.get(player.getUniqueId()) == null) {
|
||||
@@ -107,7 +108,7 @@ public class DataManager {
|
||||
else return false;
|
||||
}
|
||||
|
||||
public HashMap<UUID, PlayerData> getCache() {
|
||||
public ConcurrentHashMap<UUID, PlayerData> getCache() {
|
||||
return cache;
|
||||
}
|
||||
}
|
||||
@@ -27,6 +27,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import java.sql.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class SqlHandler {
|
||||
|
||||
@@ -63,8 +64,9 @@ public class SqlHandler {
|
||||
}
|
||||
|
||||
public static void createTable() {
|
||||
Connection connection = database.getConnectionAndCheck();
|
||||
|
||||
try {
|
||||
Connection connection = database.getConnectionAndCheck();
|
||||
Statement statement = connection.createStatement();
|
||||
if (statement == null) {
|
||||
return;
|
||||
@@ -116,7 +118,8 @@ public class SqlHandler {
|
||||
ResultSet rs = statement.executeQuery();
|
||||
if (rs.next()) {
|
||||
playerData = new PlayerData(rs.getString(2), rs.getString(3));
|
||||
}else {
|
||||
}
|
||||
else {
|
||||
sql = "INSERT INTO " + ConfigManager.Database.tableName + "(player,equipped,bubble) values(?,?,?)";
|
||||
statement = connection.prepareStatement(sql);
|
||||
statement.setString(1, uuid.toString());
|
||||
@@ -151,7 +154,7 @@ public class SqlHandler {
|
||||
|
||||
public static void saveAll() {
|
||||
Connection connection = database.getConnectionAndCheck();
|
||||
HashMap<UUID, PlayerData> data = CustomNameplates.instance.getDataManager().getCache();
|
||||
ConcurrentHashMap<UUID, PlayerData> data = CustomNameplates.instance.getDataManager().getCache();
|
||||
Bukkit.getOnlinePlayers().forEach(player -> {
|
||||
try {
|
||||
PlayerData playerData = data.get(player.getUniqueId());
|
||||
|
||||
@@ -24,6 +24,7 @@ import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
import net.momirealms.customnameplates.ConfigManager;
|
||||
import net.momirealms.customnameplates.CustomNameplates;
|
||||
import net.momirealms.customnameplates.api.events.BubblesEvent;
|
||||
import net.momirealms.customnameplates.data.PlayerData;
|
||||
import net.momirealms.customnameplates.nameplates.ArmorStandManager;
|
||||
import net.momirealms.customnameplates.nameplates.BubbleConfig;
|
||||
@@ -33,6 +34,7 @@ import net.momirealms.customnameplates.nameplates.mode.EntityTag;
|
||||
import net.momirealms.customnameplates.nameplates.mode.EventListener;
|
||||
import net.momirealms.customnameplates.resource.ResourceManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
@@ -129,13 +131,23 @@ public class ChatBubblesManager extends EntityTag {
|
||||
|
||||
public void onChat(Player player, String text) {
|
||||
|
||||
if (player.getGameMode() == GameMode.SPECTATOR) return;
|
||||
if (!player.hasPermission("bubbles.use")) return;
|
||||
|
||||
long time = System.currentTimeMillis();
|
||||
if (time - (coolDown.getOrDefault(player, time - ConfigManager.Bubbles.coolDown)) < ConfigManager.Bubbles.coolDown) return;
|
||||
coolDown.put(player, time);
|
||||
|
||||
PlayerData playerData = CustomNameplates.instance.getDataManager().getOrEmpty(player);
|
||||
String bubbles = playerData.getBubbles();
|
||||
BubbleConfig bubbleConfig = ResourceManager.BUBBLES.get(bubbles);
|
||||
|
||||
BubblesEvent bubblesEvent = new BubblesEvent(player, bubbles, text);
|
||||
Bukkit.getPluginManager().callEvent(bubblesEvent);
|
||||
if (bubblesEvent.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
text = bubblesEvent.getText();
|
||||
BubbleConfig bubbleConfig = ResourceManager.BUBBLES.get(bubblesEvent.getBubble());
|
||||
WrappedChatComponent wrappedChatComponent;
|
||||
if (CustomNameplates.instance.getImageParser() != null) {
|
||||
text = CustomNameplates.instance.getImageParser().parse(player, text);
|
||||
|
||||
@@ -22,6 +22,7 @@ import org.bukkit.ChatColor;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerChatEvent;
|
||||
|
||||
public class ChatListener implements Listener {
|
||||
|
||||
@@ -32,7 +33,7 @@ public class ChatListener implements Listener {
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onChat(AsyncPlayerChatEvent event) {
|
||||
public void onChat(PlayerChatEvent event) {
|
||||
if (!event.isCancelled()) {
|
||||
chatBubblesManager.onChat(event.getPlayer(), MiniMessage.miniMessage().stripTags(ChatColor.stripColor(event.getMessage())));
|
||||
}
|
||||
|
||||
@@ -29,7 +29,9 @@ public record TrChatListener(
|
||||
public void onTrChat(TrChatEvent event) {
|
||||
if (event.isCancelled()) return;
|
||||
if (!event.getForward()) return;
|
||||
if (event.getChannel().getId().equals(ConfigManager.Main.trChatChannel)) return;
|
||||
for (String channel : ConfigManager.Main.trChatChannel) {
|
||||
if (event.getChannel().getId().equals(channel)) return;
|
||||
}
|
||||
chatBubblesManager.onChat(event.getSession().getPlayer(), event.getMessage());
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
# Do not change
|
||||
config-version: '11'
|
||||
config-version: '12'
|
||||
|
||||
config:
|
||||
# Language
|
||||
@@ -24,7 +24,10 @@ config:
|
||||
TAB-BC: false
|
||||
# TrChat
|
||||
TrChat: false
|
||||
TrChat-private-channel: 'Private'
|
||||
# Prevent players from seeing chatting bubble texts in specified channels
|
||||
TrChat-exlude-channels:
|
||||
- 'Private'
|
||||
- 'Staff'
|
||||
|
||||
# Your namespace
|
||||
# If you don't know how font works, don't change this
|
||||
|
||||
@@ -59,6 +59,7 @@ permissions:
|
||||
bubbles.forceequip: true
|
||||
bubbles.forceunequip: true
|
||||
bubbles.list: true
|
||||
bubbles.use: true
|
||||
|
||||
bubbles.help:
|
||||
default: op
|
||||
@@ -71,4 +72,6 @@ permissions:
|
||||
bubbles.forceequip:
|
||||
default: op
|
||||
bubbles.forceunequip:
|
||||
default: op
|
||||
default: op
|
||||
bubbles.use:
|
||||
default: true
|
||||
Reference in New Issue
Block a user