mirror of
https://github.com/plexusorg/Plex.git
synced 2024-12-22 17:17:37 +00:00
Fix many bugs
This commit is contained in:
parent
d8c6c3b4a8
commit
6a569bb638
@ -10,8 +10,6 @@ import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
|
||||
/**
|
||||
* SQL fetching utilities for players
|
||||
@ -68,7 +66,7 @@ public class SQLPlayerData
|
||||
{
|
||||
String name = set.getString("name");
|
||||
String loginMSG = set.getString("login_msg");
|
||||
Component prefix = Component.text(set.getString("prefix"));
|
||||
String prefix = set.getString("prefix");
|
||||
String rankName = set.getString("rank").toUpperCase();
|
||||
long coins = set.getLong("coins");
|
||||
boolean vanished = set.getBoolean("vanished");
|
||||
@ -107,7 +105,7 @@ public class SQLPlayerData
|
||||
PreparedStatement statement = con.prepareStatement(UPDATE);
|
||||
statement.setString(1, player.getName());
|
||||
statement.setString(2, player.getLoginMessage());
|
||||
statement.setString(3, LegacyComponentSerializer.legacySection().serialize(player.getPrefix()));
|
||||
statement.setString(3, player.getPrefix());
|
||||
statement.setString(4, player.getRank().toLowerCase());
|
||||
statement.setString(5, new Gson().toJson(player.getIps()));
|
||||
statement.setLong(6, player.getCoins());
|
||||
@ -136,7 +134,7 @@ public class SQLPlayerData
|
||||
statement.setString(1, player.getUuid());
|
||||
statement.setString(2, player.getName());
|
||||
statement.setString(3, player.getLoginMessage());
|
||||
statement.setString(4, LegacyComponentSerializer.legacySection().serialize(player.getPrefix()));
|
||||
statement.setString(4, player.getPrefix());
|
||||
statement.setString(5, player.getRank().toLowerCase());
|
||||
statement.setString(6, new Gson().toJson(player.getIps()));
|
||||
statement.setLong(7, player.getCoins());
|
||||
|
@ -1,13 +1,16 @@
|
||||
package dev.plex.command.impl;
|
||||
|
||||
import dev.plex.cache.PlayerCache;
|
||||
import dev.plex.command.PlexCommand;
|
||||
import dev.plex.command.annotation.CommandParameters;
|
||||
import dev.plex.command.annotation.CommandPermissions;
|
||||
import dev.plex.command.source.RequiredCommandSource;
|
||||
import dev.plex.listener.impl.ChatListener;
|
||||
import dev.plex.player.PlexPlayer;
|
||||
import dev.plex.rank.enums.Rank;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@ -25,7 +28,30 @@ public class AdminChatCMD extends PlexCommand
|
||||
return usage();
|
||||
}
|
||||
|
||||
ChatListener.adminChat(sender, StringUtils.join(args, " "));
|
||||
adminChat(sender, StringUtils.join(args, " "));
|
||||
return null;
|
||||
}
|
||||
|
||||
private void adminChat(CommandSender sender, String message)
|
||||
{
|
||||
for (Player player : Bukkit.getOnlinePlayers())
|
||||
{
|
||||
if (plugin.getSystem().equalsIgnoreCase("ranks"))
|
||||
{
|
||||
PlexPlayer plexPlayer = PlayerCache.getPlexPlayerMap().get(player.getUniqueId());
|
||||
if (plexPlayer.getRankFromString().isAtLeast(Rank.ADMIN))
|
||||
{
|
||||
player.sendMessage(PlexUtils.messageComponent("adminChatFormat", sender.getName(), message));
|
||||
}
|
||||
}
|
||||
else if (plugin.getSystem().equalsIgnoreCase("permissions"))
|
||||
{
|
||||
if (player.hasPermission("plex.adminchat"))
|
||||
{
|
||||
player.sendMessage(PlexUtils.messageComponent("adminChatFormat", sender.getName(), message));
|
||||
}
|
||||
}
|
||||
}
|
||||
plugin.getServer().getConsoleSender().sendMessage(PlexUtils.messageComponent("adminChatFormat", sender.getName(), message));
|
||||
}
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ public class TagCMD extends PlexCommand
|
||||
return messageComponent("maximumPrefixLength", plugin.config.getInt("chat.max-tag-length", 16));
|
||||
}
|
||||
|
||||
player.setPrefix(Component.text(MiniMessage.miniMessage().serialize(convertedComponent)));
|
||||
player.setPrefix(MiniMessage.miniMessage().serialize(convertedComponent));
|
||||
return messageComponent("prefixSetTo", MiniMessage.miniMessage().serialize(convertedComponent));
|
||||
}
|
||||
|
||||
@ -69,14 +69,14 @@ public class TagCMD extends PlexCommand
|
||||
}
|
||||
|
||||
PlexPlayer player = DataUtils.getPlayer(playerSender.getUniqueId());
|
||||
player.setPrefix(null);
|
||||
player.setPrefix("");
|
||||
return messageComponent("prefixCleared");
|
||||
}
|
||||
|
||||
checkRank(sender, Rank.ADMIN, "plex.tag.clear.others");
|
||||
Player target = getNonNullPlayer(args[1]);
|
||||
PlexPlayer plexTarget = DataUtils.getPlayer(target.getUniqueId());
|
||||
plexTarget.setPrefix(null);
|
||||
plexTarget.setPrefix("");
|
||||
messageComponent("otherPrefixCleared");
|
||||
}
|
||||
return usage();
|
||||
|
@ -1,6 +1,7 @@
|
||||
package dev.plex.handlers;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import dev.plex.Plex;
|
||||
import dev.plex.listener.PlexListener;
|
||||
import dev.plex.listener.impl.AdminListener;
|
||||
import dev.plex.listener.impl.BanListener;
|
||||
@ -23,7 +24,10 @@ public class ListenerHandler
|
||||
List<PlexListener> listeners = Lists.newArrayList();
|
||||
listeners.add(new AdminListener());
|
||||
listeners.add(new BanListener());
|
||||
listeners.add(new ChatListener());
|
||||
if (Plex.get().config.getBoolean("chat.enabled"))
|
||||
{
|
||||
listeners.add(new ChatListener());
|
||||
}
|
||||
listeners.add(new CommandListener());
|
||||
listeners.add(new FreezeListener());
|
||||
listeners.add(new GameModeListener());
|
||||
|
@ -3,7 +3,6 @@ package dev.plex.listener.impl;
|
||||
import dev.plex.cache.PlayerCache;
|
||||
import dev.plex.listener.PlexListener;
|
||||
import dev.plex.player.PlexPlayer;
|
||||
import dev.plex.rank.enums.Rank;
|
||||
import dev.plex.util.PlexLog;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import io.papermc.paper.chat.ChatRenderer;
|
||||
@ -12,8 +11,6 @@ import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@ -22,29 +19,6 @@ public class ChatListener extends PlexListener
|
||||
{
|
||||
private final PlexChatRenderer renderer = new PlexChatRenderer();
|
||||
|
||||
public static void adminChat(CommandSender sender, String message)
|
||||
{
|
||||
for (Player player : Bukkit.getOnlinePlayers())
|
||||
{
|
||||
if (plugin.getSystem().equalsIgnoreCase("ranks"))
|
||||
{
|
||||
PlexPlayer plexPlayer = PlayerCache.getPlexPlayerMap().get(player.getUniqueId());
|
||||
if (plexPlayer.getRankFromString().isAtLeast(Rank.ADMIN))
|
||||
{
|
||||
player.sendMessage(PlexUtils.messageComponent("adminChatFormat", sender.getName(), message));
|
||||
}
|
||||
}
|
||||
else if (plugin.getSystem().equalsIgnoreCase("permissions"))
|
||||
{
|
||||
if (player.hasPermission("plex.adminchat"))
|
||||
{
|
||||
player.sendMessage(PlexUtils.messageComponent("adminChatFormat", sender.getName(), message));
|
||||
}
|
||||
}
|
||||
}
|
||||
plugin.getServer().getConsoleSender().sendMessage(PlexUtils.messageComponent("adminChatFormat", sender.getName(), message));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onChat(AsyncChatEvent event)
|
||||
{
|
||||
@ -80,7 +54,8 @@ public class ChatListener extends PlexListener
|
||||
{
|
||||
if (hasPrefix)
|
||||
{
|
||||
return Component.empty().append(prefix)
|
||||
return Component.empty()
|
||||
.append(prefix)
|
||||
.append(Component.space())
|
||||
.append(LegacyComponentSerializer.legacyAmpersand().deserialize("&" + plugin.config.getString("chat.name-color") + LegacyComponentSerializer.legacyAmpersand().serialize(sourceDisplayName)))
|
||||
.append(Component.space())
|
||||
@ -89,7 +64,7 @@ public class ChatListener extends PlexListener
|
||||
.append(message);
|
||||
}
|
||||
return Component.empty()
|
||||
.append(sourceDisplayName)
|
||||
.append(LegacyComponentSerializer.legacyAmpersand().deserialize("&" + plugin.config.getString("chat.name-color") + LegacyComponentSerializer.legacyAmpersand().serialize(sourceDisplayName)))
|
||||
.append(Component.space())
|
||||
.append(Component.text("»").color(NamedTextColor.GRAY))
|
||||
.append(Component.space())
|
||||
|
@ -35,7 +35,7 @@ public class PlexPlayer
|
||||
private Player player;
|
||||
|
||||
private String loginMessage;
|
||||
private Component prefix;
|
||||
private String prefix;
|
||||
|
||||
private boolean vanished;
|
||||
private boolean commandSpy;
|
||||
@ -60,7 +60,7 @@ public class PlexPlayer
|
||||
this.player = Bukkit.getPlayer(name);
|
||||
|
||||
this.loginMessage = "";
|
||||
this.prefix = null;
|
||||
this.prefix = "";
|
||||
|
||||
this.vanished = false;
|
||||
this.commandSpy = false;
|
||||
|
@ -4,6 +4,7 @@ import dev.plex.Plex;
|
||||
import dev.plex.player.PlexPlayer;
|
||||
import dev.plex.rank.enums.Rank;
|
||||
import dev.plex.rank.enums.Title;
|
||||
import dev.plex.util.PlexLog;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
@ -14,6 +15,7 @@ import java.util.stream.Collectors;
|
||||
import lombok.SneakyThrows;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
import org.json.JSONTokener;
|
||||
@ -92,9 +94,9 @@ public class RankManager
|
||||
|
||||
public Component getPrefix(PlexPlayer player)
|
||||
{
|
||||
if (Component.IS_NOT_EMPTY.test(player.getPrefix()))
|
||||
if (!player.getPrefix().equals(""))
|
||||
{
|
||||
return player.getPrefix();
|
||||
return MiniMessage.miniMessage().deserialize(player.getPrefix());
|
||||
}
|
||||
if (Plex.get().config.contains("titles.owners") && Plex.get().config.getStringList("titles.owners").contains(player.getName()))
|
||||
{
|
||||
|
@ -18,6 +18,10 @@ banning:
|
||||
ban_url: "https://forum.plex.us.org"
|
||||
|
||||
chat:
|
||||
# Should the server use Plex's chat system? It is recommended to keep this on if you are using ranks.
|
||||
# If you are using permissions, you should turn this off and use Vault to handle prefixes with a different chat plugin
|
||||
enabled: true
|
||||
# The maximum amount of characters a player can have for their tag
|
||||
max-tag-length: 16
|
||||
# Color code for name color
|
||||
name-color: 'f'
|
||||
|
Loading…
Reference in New Issue
Block a user