- Fix banning bug + make plex name color config option work

This commit is contained in:
Taah 2022-02-24 23:50:11 -08:00
parent 90c2426987
commit f13bd8a5d5
13 changed files with 20 additions and 24 deletions

View File

@ -34,6 +34,10 @@ public class PlayerCache
public static PunishedPlayer getPunishedPlayer(UUID uuid)
{
if (!getPunishedPlayerMap().containsKey(uuid))
{
getPunishedPlayerMap().put(uuid, new PunishedPlayer(uuid));
}
return getPunishedPlayerMap().get(uuid);
}

View File

@ -20,6 +20,7 @@ public class AdminworldCMD extends PlexCommand
@Override
protected Component execute(@NotNull CommandSender sender, @Nullable Player playerSender, String[] args)
{
assert playerSender != null;
// TODO: Add adminworld settings
if (args.length == 0)
{

View File

@ -53,6 +53,7 @@ public class BanCMD extends PlexCommand
{
if (!isConsole(sender))
{
assert playerSender != null;
PlexPlayer plexPlayer1 = getPlexPlayer(playerSender);
if (!plexPlayer1.getRankFromString().isAtLeast(plexPlayer.getRankFromString()))
{

View File

@ -21,6 +21,7 @@ public class FlatlandsCMD extends PlexCommand
@Override
protected Component execute(@NotNull CommandSender sender, @Nullable Player playerSender, String[] args)
{
assert playerSender != null;
if (args.length == 0)
{
Location loc = new Location(Bukkit.getWorld("flatlands"), 0, 50, 0);

View File

@ -18,6 +18,7 @@ public class LocalSpawnCMD extends PlexCommand
@Override
protected Component execute(@NotNull CommandSender sender, @Nullable Player playerSender, String[] args)
{
assert playerSender != null;
playerSender.teleportAsync(playerSender.getWorld().getSpawnLocation());
return messageComponent("teleportedToWorldSpawn");
}

View File

@ -21,6 +21,7 @@ public class MasterbuilderworldCMD extends PlexCommand
@Override
protected Component execute(@NotNull CommandSender sender, @Nullable Player playerSender, String[] args)
{
assert playerSender != null;
// TODO: Add masterbuilderworld settings
if (args.length == 0)
{

View File

@ -38,6 +38,7 @@ public class TagCMD extends PlexCommand
{
return messageComponent("noPermissionConsole");
}
assert playerSender != null;
PlexPlayer player = DataUtils.getPlayer(playerSender.getUniqueId());
if (args.length < 2)
{

View File

@ -17,6 +17,7 @@ import net.kyori.adventure.text.Component;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@CommandParameters(name = "unban", usage = "/<command> <player>", description = "Unbans a player, offline or online")
@CommandPermissions(level = Rank.ADMIN, permission = "plex.ban", source = RequiredCommandSource.ANY)
@ -24,7 +25,7 @@ import org.jetbrains.annotations.NotNull;
public class UnbanCMD extends PlexCommand
{
@Override
public Component execute(@NotNull CommandSender sender, @NotNull Player playerSender, String[] args)
public Component execute(@NotNull CommandSender sender, @Nullable Player playerSender, String[] args)
{
if (args.length == 0)
{

View File

@ -24,6 +24,7 @@ public class WorldCMD extends PlexCommand
@Override
protected Component execute(@NotNull CommandSender sender, @Nullable Player playerSender, String[] args)
{
assert playerSender != null;
if (args.length != 1)
{
return usage();

View File

@ -73,7 +73,7 @@ public class ChatListener extends PlexListener
{
return Component.empty().append(LegacyComponentSerializer.legacyAmpersand().deserialize(prefix))
.append(Component.space())
.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())

View File

@ -57,17 +57,8 @@ public class PlayerListener extends PlexListener
plexPlayer = DataUtils.getPlayer(player.getUniqueId());
}
PunishedPlayer punishedPlayer;
PunishedPlayer punishedPlayer = PlayerCache.getPunishedPlayer(player.getUniqueId());
PlayerCache.getPlexPlayerMap().put(player.getUniqueId(), plexPlayer); //put them into the cache
if (!PlayerCache.getPunishedPlayerMap().containsKey(player.getUniqueId()))
{
punishedPlayer = new PunishedPlayer(player.getUniqueId());
PlayerCache.getPunishedPlayerMap().put(player.getUniqueId(), punishedPlayer);
}
else
{
punishedPlayer = PlayerCache.getPunishedPlayer(player.getUniqueId());
}
punishedPlayer.convertPunishments();
assert plexPlayer != null;

View File

@ -95,7 +95,7 @@ public class PunishmentManager extends PlexBase
public boolean isBanned(UUID uuid)
{
return PlayerCache.getPunishedPlayerMap().containsKey(uuid) && PlayerCache.getPunishedPlayer(uuid).getPunishments().stream().anyMatch(punishment -> punishment.getType() == PunishmentType.BAN && punishment.isActive());
return PlayerCache.getPunishedPlayer(uuid).getPunishments().stream().anyMatch(punishment -> punishment.getType() == PunishmentType.BAN && punishment.isActive());
}
public boolean isBanned(PunishedPlayer player)
@ -160,15 +160,8 @@ public class PunishmentManager extends PlexBase
jedis.set(uuid.toString(), object.toString());
}
PunishedPlayer player;
if (PlayerCache.getPunishedPlayerMap().containsKey(uuid))
{
player = PlayerCache.getPunishedPlayer(uuid);
}
else
{
player = new PunishedPlayer(uuid);
}
PunishedPlayer player = PlayerCache.getPunishedPlayer(uuid);
File file = player.getPunishmentsFile();
if (isNotEmpty(file))
{

View File

@ -41,8 +41,8 @@ public class PlexUtils extends PlexBase
public static Map<String, ChatColor> CHAT_COLOR_NAMES;
public static List<ChatColor> CHAT_COLOR_POOL;
public static List<String> DEVELOPERS =
Arrays.asList("78408086-1991-4c33-a571-d8fa325465b2", // Telesphoreo
"f5cd54c4-3a24-4213-9a56-c06c49594dff" // Taahh
Arrays.asList("78408086-1991-4c33-a571-d8fa325465b2" // Telesphoreo
// "f5cd54c4-3a24-4213-9a56-c06c49594dff" // Taahh
);
private static final Random RANDOM;