mirror of
https://github.com/plexusorg/Plex.git
synced 2024-12-23 01:27:37 +00:00
- Fix banning bug + make plex name color config option work
This commit is contained in:
parent
90c2426987
commit
f13bd8a5d5
@ -34,6 +34,10 @@ public class PlayerCache
|
|||||||
|
|
||||||
public static PunishedPlayer getPunishedPlayer(UUID uuid)
|
public static PunishedPlayer getPunishedPlayer(UUID uuid)
|
||||||
{
|
{
|
||||||
|
if (!getPunishedPlayerMap().containsKey(uuid))
|
||||||
|
{
|
||||||
|
getPunishedPlayerMap().put(uuid, new PunishedPlayer(uuid));
|
||||||
|
}
|
||||||
return getPunishedPlayerMap().get(uuid);
|
return getPunishedPlayerMap().get(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@ public class AdminworldCMD extends PlexCommand
|
|||||||
@Override
|
@Override
|
||||||
protected Component execute(@NotNull CommandSender sender, @Nullable Player playerSender, String[] args)
|
protected Component execute(@NotNull CommandSender sender, @Nullable Player playerSender, String[] args)
|
||||||
{
|
{
|
||||||
|
assert playerSender != null;
|
||||||
// TODO: Add adminworld settings
|
// TODO: Add adminworld settings
|
||||||
if (args.length == 0)
|
if (args.length == 0)
|
||||||
{
|
{
|
||||||
|
@ -53,6 +53,7 @@ public class BanCMD extends PlexCommand
|
|||||||
{
|
{
|
||||||
if (!isConsole(sender))
|
if (!isConsole(sender))
|
||||||
{
|
{
|
||||||
|
assert playerSender != null;
|
||||||
PlexPlayer plexPlayer1 = getPlexPlayer(playerSender);
|
PlexPlayer plexPlayer1 = getPlexPlayer(playerSender);
|
||||||
if (!plexPlayer1.getRankFromString().isAtLeast(plexPlayer.getRankFromString()))
|
if (!plexPlayer1.getRankFromString().isAtLeast(plexPlayer.getRankFromString()))
|
||||||
{
|
{
|
||||||
|
@ -21,6 +21,7 @@ public class FlatlandsCMD extends PlexCommand
|
|||||||
@Override
|
@Override
|
||||||
protected Component execute(@NotNull CommandSender sender, @Nullable Player playerSender, String[] args)
|
protected Component execute(@NotNull CommandSender sender, @Nullable Player playerSender, String[] args)
|
||||||
{
|
{
|
||||||
|
assert playerSender != null;
|
||||||
if (args.length == 0)
|
if (args.length == 0)
|
||||||
{
|
{
|
||||||
Location loc = new Location(Bukkit.getWorld("flatlands"), 0, 50, 0);
|
Location loc = new Location(Bukkit.getWorld("flatlands"), 0, 50, 0);
|
||||||
|
@ -18,6 +18,7 @@ public class LocalSpawnCMD extends PlexCommand
|
|||||||
@Override
|
@Override
|
||||||
protected Component execute(@NotNull CommandSender sender, @Nullable Player playerSender, String[] args)
|
protected Component execute(@NotNull CommandSender sender, @Nullable Player playerSender, String[] args)
|
||||||
{
|
{
|
||||||
|
assert playerSender != null;
|
||||||
playerSender.teleportAsync(playerSender.getWorld().getSpawnLocation());
|
playerSender.teleportAsync(playerSender.getWorld().getSpawnLocation());
|
||||||
return messageComponent("teleportedToWorldSpawn");
|
return messageComponent("teleportedToWorldSpawn");
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ public class MasterbuilderworldCMD extends PlexCommand
|
|||||||
@Override
|
@Override
|
||||||
protected Component execute(@NotNull CommandSender sender, @Nullable Player playerSender, String[] args)
|
protected Component execute(@NotNull CommandSender sender, @Nullable Player playerSender, String[] args)
|
||||||
{
|
{
|
||||||
|
assert playerSender != null;
|
||||||
// TODO: Add masterbuilderworld settings
|
// TODO: Add masterbuilderworld settings
|
||||||
if (args.length == 0)
|
if (args.length == 0)
|
||||||
{
|
{
|
||||||
|
@ -38,6 +38,7 @@ public class TagCMD extends PlexCommand
|
|||||||
{
|
{
|
||||||
return messageComponent("noPermissionConsole");
|
return messageComponent("noPermissionConsole");
|
||||||
}
|
}
|
||||||
|
assert playerSender != null;
|
||||||
PlexPlayer player = DataUtils.getPlayer(playerSender.getUniqueId());
|
PlexPlayer player = DataUtils.getPlayer(playerSender.getUniqueId());
|
||||||
if (args.length < 2)
|
if (args.length < 2)
|
||||||
{
|
{
|
||||||
|
@ -17,6 +17,7 @@ import net.kyori.adventure.text.Component;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
@CommandParameters(name = "unban", usage = "/<command> <player>", description = "Unbans a player, offline or online")
|
@CommandParameters(name = "unban", usage = "/<command> <player>", description = "Unbans a player, offline or online")
|
||||||
@CommandPermissions(level = Rank.ADMIN, permission = "plex.ban", source = RequiredCommandSource.ANY)
|
@CommandPermissions(level = Rank.ADMIN, permission = "plex.ban", source = RequiredCommandSource.ANY)
|
||||||
@ -24,7 +25,7 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
public class UnbanCMD extends PlexCommand
|
public class UnbanCMD extends PlexCommand
|
||||||
{
|
{
|
||||||
@Override
|
@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)
|
if (args.length == 0)
|
||||||
{
|
{
|
||||||
|
@ -24,6 +24,7 @@ public class WorldCMD extends PlexCommand
|
|||||||
@Override
|
@Override
|
||||||
protected Component execute(@NotNull CommandSender sender, @Nullable Player playerSender, String[] args)
|
protected Component execute(@NotNull CommandSender sender, @Nullable Player playerSender, String[] args)
|
||||||
{
|
{
|
||||||
|
assert playerSender != null;
|
||||||
if (args.length != 1)
|
if (args.length != 1)
|
||||||
{
|
{
|
||||||
return usage();
|
return usage();
|
||||||
|
@ -73,7 +73,7 @@ public class ChatListener extends PlexListener
|
|||||||
{
|
{
|
||||||
return Component.empty().append(LegacyComponentSerializer.legacyAmpersand().deserialize(prefix))
|
return Component.empty().append(LegacyComponentSerializer.legacyAmpersand().deserialize(prefix))
|
||||||
.append(Component.space())
|
.append(Component.space())
|
||||||
.append(sourceDisplayName)
|
.append(LegacyComponentSerializer.legacyAmpersand().deserialize("&" + plugin.config.getString("chat.name-color") + LegacyComponentSerializer.legacyAmpersand().serialize(sourceDisplayName)))
|
||||||
.append(Component.space())
|
.append(Component.space())
|
||||||
.append(Component.text("»").color(NamedTextColor.GRAY))
|
.append(Component.text("»").color(NamedTextColor.GRAY))
|
||||||
.append(Component.space())
|
.append(Component.space())
|
||||||
|
@ -57,17 +57,8 @@ public class PlayerListener extends PlexListener
|
|||||||
plexPlayer = DataUtils.getPlayer(player.getUniqueId());
|
plexPlayer = DataUtils.getPlayer(player.getUniqueId());
|
||||||
}
|
}
|
||||||
|
|
||||||
PunishedPlayer punishedPlayer;
|
PunishedPlayer punishedPlayer = PlayerCache.getPunishedPlayer(player.getUniqueId());
|
||||||
PlayerCache.getPlexPlayerMap().put(player.getUniqueId(), plexPlayer); //put them into the cache
|
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();
|
punishedPlayer.convertPunishments();
|
||||||
|
|
||||||
assert plexPlayer != null;
|
assert plexPlayer != null;
|
||||||
|
@ -95,7 +95,7 @@ public class PunishmentManager extends PlexBase
|
|||||||
|
|
||||||
public boolean isBanned(UUID uuid)
|
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)
|
public boolean isBanned(PunishedPlayer player)
|
||||||
@ -160,15 +160,8 @@ public class PunishmentManager extends PlexBase
|
|||||||
jedis.set(uuid.toString(), object.toString());
|
jedis.set(uuid.toString(), object.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
PunishedPlayer player;
|
PunishedPlayer player = PlayerCache.getPunishedPlayer(uuid);
|
||||||
if (PlayerCache.getPunishedPlayerMap().containsKey(uuid))
|
|
||||||
{
|
|
||||||
player = PlayerCache.getPunishedPlayer(uuid);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
player = new PunishedPlayer(uuid);
|
|
||||||
}
|
|
||||||
File file = player.getPunishmentsFile();
|
File file = player.getPunishmentsFile();
|
||||||
if (isNotEmpty(file))
|
if (isNotEmpty(file))
|
||||||
{
|
{
|
||||||
|
@ -41,8 +41,8 @@ public class PlexUtils extends PlexBase
|
|||||||
public static Map<String, ChatColor> CHAT_COLOR_NAMES;
|
public static Map<String, ChatColor> CHAT_COLOR_NAMES;
|
||||||
public static List<ChatColor> CHAT_COLOR_POOL;
|
public static List<ChatColor> CHAT_COLOR_POOL;
|
||||||
public static List<String> DEVELOPERS =
|
public static List<String> DEVELOPERS =
|
||||||
Arrays.asList("78408086-1991-4c33-a571-d8fa325465b2", // Telesphoreo
|
Arrays.asList("78408086-1991-4c33-a571-d8fa325465b2" // Telesphoreo
|
||||||
"f5cd54c4-3a24-4213-9a56-c06c49594dff" // Taahh
|
// "f5cd54c4-3a24-4213-9a56-c06c49594dff" // Taahh
|
||||||
);
|
);
|
||||||
private static final Random RANDOM;
|
private static final Random RANDOM;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user