Update for Plex 2.0

This commit is contained in:
2026-05-21 18:35:50 -04:00
parent c44fcccd59
commit 45f893688a
25 changed files with 355 additions and 394 deletions
@@ -1,9 +1,7 @@
package dev.plex.command.sub;
import dev.plex.Guilds;
import dev.plex.command.PlexCommand;
import dev.plex.command.annotation.CommandParameters;
import dev.plex.command.annotation.CommandPermissions;
import dev.plex.command.SimplePlexCommand;
import dev.plex.command.source.RequiredCommandSource;
import dev.plex.guild.data.Member;
import java.util.Collections;
@@ -18,13 +16,16 @@ import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@CommandParameters(name = "chat", usage = "/guild <command> [message]", description = "Toggles guild chat or sends a guild chat message")
@CommandPermissions(source = RequiredCommandSource.IN_GAME, permission = "plex.guilds.chat")
public class ChatSubCommand extends PlexCommand
public class ChatSubCommand extends SimplePlexCommand
{
public ChatSubCommand()
{
super(false);
super(command("chat")
.description("Toggles guild chat or sends a guild chat message")
.usage("/guild <command> [message]")
.permission("plex.guilds.chat")
.source(RequiredCommandSource.IN_GAME)
.build());
}
@Override
@@ -44,7 +45,7 @@ public class ChatSubCommand extends PlexCommand
{
send(player1, messageComponent("guildChatMessage", player.getName(), StringUtils.join(args, " ")));
});
if (Guilds.get().getConfig().isBoolean("guilds.log-chat-message"))
if (Guilds.get().getConfig().getBoolean("guilds.log-chat-message"))
{
send(Bukkit.getConsoleSender(), messageComponent("guildChatConsoleLog", guild.getName(), guild.getGuildUuid(), player.getName(), StringUtils.join(args, " ")));
}
@@ -53,7 +54,7 @@ public class ChatSubCommand extends PlexCommand
}
@Override
public @NotNull List<String> smartTabComplete(@NotNull CommandSender commandSender, @NotNull String s, @NotNull String[] strings) throws IllegalArgumentException
protected @NotNull List<String> suggestions(@NotNull CommandSender commandSender, @NotNull String s, @NotNull String[] strings) throws IllegalArgumentException
{
return Collections.emptyList();
}
@@ -1,9 +1,7 @@
package dev.plex.command.sub;
import dev.plex.Guilds;
import dev.plex.command.PlexCommand;
import dev.plex.command.annotation.CommandParameters;
import dev.plex.command.annotation.CommandPermissions;
import dev.plex.command.SimplePlexCommand;
import dev.plex.command.source.RequiredCommandSource;
import dev.plex.guild.Guild;
import java.util.Collections;
@@ -15,13 +13,17 @@ import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@CommandParameters(name = "create", aliases = "make", usage = "/guild <command> <name>", description = "Creates a guild with a specified name")
@CommandPermissions(source = RequiredCommandSource.IN_GAME, permission = "plex.guilds.create")
public class CreateSubCommand extends PlexCommand
public class CreateSubCommand extends SimplePlexCommand
{
public CreateSubCommand()
{
super(false);
super(command("create")
.description("Creates a guild with a specified name")
.usage("/guild <command> <name>")
.aliases("make")
.permission("plex.guilds.create")
.source(RequiredCommandSource.IN_GAME)
.build());
}
@Override
@@ -45,7 +47,7 @@ public class CreateSubCommand extends PlexCommand
}
@Override
public @NotNull List<String> smartTabComplete(@NotNull CommandSender commandSender, @NotNull String s, @NotNull String[] strings) throws IllegalArgumentException
protected @NotNull List<String> suggestions(@NotNull CommandSender commandSender, @NotNull String s, @NotNull String[] strings) throws IllegalArgumentException
{
return Collections.emptyList();
}
@@ -1,9 +1,7 @@
package dev.plex.command.sub;
import dev.plex.Guilds;
import dev.plex.command.PlexCommand;
import dev.plex.command.annotation.CommandParameters;
import dev.plex.command.annotation.CommandPermissions;
import dev.plex.command.SimplePlexCommand;
import dev.plex.command.source.RequiredCommandSource;
import java.util.Collections;
import java.util.List;
@@ -13,13 +11,17 @@ import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@CommandParameters(name = "home", aliases = "spawn", usage = "/guild <command>", description = "Teleports to the guild home")
@CommandPermissions(source = RequiredCommandSource.IN_GAME, permission = "plex.guilds.home")
public class HomeSubCommand extends PlexCommand
public class HomeSubCommand extends SimplePlexCommand
{
public HomeSubCommand()
{
super(false);
super(command("home")
.description("Teleports to the guild home")
.usage("/guild <command>")
.aliases("spawn")
.permission("plex.guilds.home")
.source(RequiredCommandSource.IN_GAME)
.build());
}
@Override
@@ -39,7 +41,7 @@ public class HomeSubCommand extends PlexCommand
}
@Override
public @NotNull List<String> smartTabComplete(@NotNull CommandSender commandSender, @NotNull String s, @NotNull String[] strings) throws IllegalArgumentException
protected @NotNull List<String> suggestions(@NotNull CommandSender commandSender, @NotNull String s, @NotNull String[] strings) throws IllegalArgumentException
{
return Collections.emptyList();
}
@@ -1,10 +1,8 @@
package dev.plex.command.sub;
import dev.plex.Guilds;
import dev.plex.cache.DataUtils;
import dev.plex.command.PlexCommand;
import dev.plex.command.annotation.CommandParameters;
import dev.plex.command.annotation.CommandPermissions;
import dev.plex.api.player.PlexPlayerView;
import dev.plex.command.SimplePlexCommand;
import dev.plex.command.source.RequiredCommandSource;
import java.time.format.DateTimeFormatter;
import java.util.Collections;
@@ -17,13 +15,17 @@ import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@CommandParameters(name = "info", aliases = "information", usage = "/guild <command>", description = "Shows the guild's information")
@CommandPermissions(source = RequiredCommandSource.IN_GAME, permission = "plex.guilds.info")
public class InfoSubCommand extends PlexCommand
public class InfoSubCommand extends SimplePlexCommand
{
public InfoSubCommand()
{
super(false);
super(command("info")
.description("Shows the guild's information")
.usage("/guild <command>")
.aliases("information")
.permission("plex.guilds.info")
.source(RequiredCommandSource.IN_GAME)
.build());
}
private final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy hh:mm:ss a");
@@ -38,26 +40,24 @@ public class InfoSubCommand extends PlexCommand
{
send(player, mmString("<gradient:yellow:gold>====<aqua>" + guild.getName() + "<gradient:yellow:gold>===="));
send(player, mmString(""));
try
{
send(player, mmString("<gold>Owner: <yellow>" + DataUtils.getPlayer(guild.getOwner().getUuid(), false).getName()));
}
catch (NullPointerException e)
{
send(player, mmString("<gold>Owner: <yellow>Unable to load cache..."));
}
List<String> members = guild.getMembers().stream().filter(member -> !member.getUuid().equals(guild.getOwner().getUuid())).map(member -> DataUtils.getPlayer(member.getUuid(), false).getName()).toList();
send(player, mmString("<gold>Owner: <yellow>" + playerName(guild.getOwner().getUuid())));
List<String> members = guild.getMembers().stream().filter(member -> !member.getUuid().equals(guild.getOwner().getUuid())).map(member -> playerName(member.getUuid())).toList();
send(player, mmString("<gold>Members (" + members.size() + "): " + StringUtils.join(members, ", ")));
send(player, mmString("<gold>Moderators (" + guild.getModerators().size() + "): " + StringUtils.join(guild.getModerators().stream().map(uuid -> DataUtils.getPlayer(uuid, false).getName()).toList(), ", ")));
send(player, mmString("<gold>Moderators (" + guild.getModerators().size() + "): " + StringUtils.join(guild.getModerators().stream().map(this::playerName).toList(), ", ")));
send(player, mmString("<gold>Prefix: " + (guild.getPrefix() == null ? "N/A" : guild.getPrefix())));
send(player, mmString("<gold>Created At: " + formatter.format(guild.getCreatedAt())));
}, () -> send(player, messageComponent("guildNotFound")));
});
}, Guilds.get().api().scheduler().asyncExecutor());
return null;
}
private String playerName(java.util.UUID uuid)
{
return api().players().byUuid(uuid).map(PlexPlayerView::name).orElse("Unable to load cache...");
}
@Override
public @NotNull List<String> smartTabComplete(@NotNull CommandSender commandSender, @NotNull String s, @NotNull String[] strings) throws IllegalArgumentException
protected @NotNull List<String> suggestions(@NotNull CommandSender commandSender, @NotNull String s, @NotNull String[] strings) throws IllegalArgumentException
{
return Collections.emptyList();
}
@@ -2,14 +2,11 @@ package dev.plex.command.sub;
import com.google.common.collect.ImmutableList;
import dev.plex.Guilds;
import dev.plex.command.PlexCommand;
import dev.plex.command.annotation.CommandParameters;
import dev.plex.command.annotation.CommandPermissions;
import dev.plex.command.SimplePlexCommand;
import dev.plex.command.source.RequiredCommandSource;
import dev.plex.guild.Guild;
import dev.plex.guild.GuildHolder;
import dev.plex.guild.data.Member;
import dev.plex.util.PlexLog;
import net.kyori.adventure.text.Component;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.command.CommandSender;
@@ -25,13 +22,17 @@ import java.util.stream.Collectors;
// TODO: 5/9/2022 deny command maybe?
// TODO: 5/9/2022 deny members from inviting themselves or existing members in the current guild
@CommandParameters(name = "invite", aliases = "inv", usage = "/guild <command> <player name>", description = "Invites a player to the guild")
@CommandPermissions(source = RequiredCommandSource.IN_GAME, permission = "plex.guilds.invite")
public class InviteSubCommand extends PlexCommand
public class InviteSubCommand extends SimplePlexCommand
{
public InviteSubCommand()
{
super(false);
super(command("invite")
.description("Invites a player to the guild")
.usage("/guild <command> <player name>")
.aliases("inv")
.permission("plex.guilds.invite")
.source(RequiredCommandSource.IN_GAME)
.build());
}
@Override
@@ -116,7 +117,7 @@ public class InviteSubCommand extends PlexCommand
}
@Override
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
protected @NotNull List<String> suggestions(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
{
if (!(sender instanceof Player player))
{
@@ -132,7 +133,7 @@ public class InviteSubCommand extends PlexCommand
{
return ImmutableList.of();
}
PlexLog.debug("Tab Completing moment");
api().logging().debug("Completing pending guild invites");
return GuildHolder.PENDING_INVITES.get(player.getUniqueId()).stream().map(Guild::getName).collect(Collectors.toList());
}
return ImmutableList.of();
@@ -1,13 +1,10 @@
package dev.plex.command.sub;
import dev.plex.Guilds;
import dev.plex.cache.DataUtils;
import dev.plex.command.PlexCommand;
import dev.plex.command.annotation.CommandParameters;
import dev.plex.command.annotation.CommandPermissions;
import dev.plex.api.player.PlexPlayerView;
import dev.plex.command.SimplePlexCommand;
import dev.plex.command.source.RequiredCommandSource;
import dev.plex.guild.data.Member;
import dev.plex.player.PlexPlayer;
import java.util.Collections;
import java.util.List;
import net.kyori.adventure.text.Component;
@@ -16,13 +13,17 @@ import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@CommandParameters(name = "owner", aliases = "setowner", usage = "/guild <command> <player name>", description = "Sets the guild owner")
@CommandPermissions(source = RequiredCommandSource.IN_GAME, permission = "plex.guilds.owner")
public class OwnerSubCommand extends PlexCommand
public class OwnerSubCommand extends SimplePlexCommand
{
public OwnerSubCommand()
{
super(false);
super(command("owner")
.description("Sets the guild owner")
.usage("/guild <command> <player name>")
.aliases("setowner")
.permission("plex.guilds.owner")
.source(RequiredCommandSource.IN_GAME)
.build());
}
@Override
@@ -41,13 +42,13 @@ public class OwnerSubCommand extends PlexCommand
return;
}
Member memberSender = guild.getMember(player.getUniqueId());
PlexPlayer plexPlayer = DataUtils.getPlayer(args[0], false);
PlexPlayerView plexPlayer = api().players().byName(args[0]).orElse(null);
if (plexPlayer == null)
{
send(player, messageComponent("playerNotFound"));
return;
}
Member member = guild.getMember(plexPlayer.getUuid());
Member member = guild.getMember(plexPlayer.uuid());
if (member == null)
{
send(player, messageComponent("guildMemberNotFound"));
@@ -56,13 +57,13 @@ public class OwnerSubCommand extends PlexCommand
guild.setOwner(member);
guild.getMembers().remove(member);
guild.getMembers().add(memberSender);
send(player, messageComponent("guildOwnerSet", plexPlayer.getName()));
send(player, messageComponent("guildOwnerSet", plexPlayer.name()));
}, () -> send(player, messageComponent("guildNotFound")));
return null;
}
@Override
public @NotNull List<String> smartTabComplete(@NotNull CommandSender commandSender, @NotNull String s, @NotNull String[] strings) throws IllegalArgumentException
protected @NotNull List<String> suggestions(@NotNull CommandSender commandSender, @NotNull String s, @NotNull String[] strings) throws IllegalArgumentException
{
return Collections.emptyList();
}
@@ -1,11 +1,9 @@
package dev.plex.command.sub;
import dev.plex.Guilds;
import dev.plex.command.PlexCommand;
import dev.plex.command.annotation.CommandParameters;
import dev.plex.command.annotation.CommandPermissions;
import dev.plex.command.SimplePlexCommand;
import dev.plex.command.source.RequiredCommandSource;
import dev.plex.util.minimessage.SafeMiniMessage;
import dev.plex.util.GuildUtil;
import java.util.Collections;
import java.util.List;
import net.kyori.adventure.text.Component;
@@ -15,13 +13,17 @@ import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@CommandParameters(name = "prefix", aliases = "tag,settag,setprefix", usage = "/guild <command> <prefix>", description = "Sets the guild's default prefix")
@CommandPermissions(source = RequiredCommandSource.IN_GAME, permission = "plex.guilds.prefix")
public class PrefixSubCommand extends PlexCommand
public class PrefixSubCommand extends SimplePlexCommand
{
public PrefixSubCommand()
{
super(false);
super(command("prefix")
.description("Sets the guild's default prefix")
.usage("/guild <command> <prefix>")
.aliases("tag,settag,setprefix")
.permission("plex.guilds.prefix")
.source(RequiredCommandSource.IN_GAME)
.build());
}
@Override
@@ -46,13 +48,13 @@ public class PrefixSubCommand extends PlexCommand
return;
}
guild.setPrefix(StringUtils.join(args, " "));
send(player, messageComponent("guildPrefixSet", SafeMiniMessage.mmDeserializeWithoutEvents(guild.getPrefix())));
send(player, messageComponent("guildPrefixSet", GuildUtil.miniMessageWithoutEvents(guild.getPrefix())));
}, () -> send(player, messageComponent("guildNotFound")));
return null;
}
@Override
public @NotNull List<String> smartTabComplete(@NotNull CommandSender commandSender, @NotNull String s, @NotNull String[] strings) throws IllegalArgumentException
protected @NotNull List<String> suggestions(@NotNull CommandSender commandSender, @NotNull String s, @NotNull String[] strings) throws IllegalArgumentException
{
return Collections.emptyList();
}
@@ -1,9 +1,7 @@
package dev.plex.command.sub;
import dev.plex.Guilds;
import dev.plex.command.PlexCommand;
import dev.plex.command.annotation.CommandParameters;
import dev.plex.command.annotation.CommandPermissions;
import dev.plex.command.SimplePlexCommand;
import dev.plex.command.source.RequiredCommandSource;
import dev.plex.util.CustomLocation;
import java.util.Collections;
@@ -14,13 +12,17 @@ import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@CommandParameters(name = "sethome", aliases = "setspawn", usage = "/guild <command>", description = "Sets the guild's home")
@CommandPermissions(source = RequiredCommandSource.IN_GAME, permission = "plex.guilds.sethome")
public class SetHomeSubCommand extends PlexCommand
public class SetHomeSubCommand extends SimplePlexCommand
{
public SetHomeSubCommand()
{
super(false);
super(command("sethome")
.description("Sets the guild's home")
.usage("/guild <command>")
.aliases("setspawn")
.permission("plex.guilds.sethome")
.source(RequiredCommandSource.IN_GAME)
.build());
}
@Override
@@ -52,7 +54,7 @@ public class SetHomeSubCommand extends PlexCommand
}
@Override
public @NotNull List<String> smartTabComplete(@NotNull CommandSender commandSender, @NotNull String s, @NotNull String[] strings) throws IllegalArgumentException
protected @NotNull List<String> suggestions(@NotNull CommandSender commandSender, @NotNull String s, @NotNull String[] strings) throws IllegalArgumentException
{
return Collections.emptyList();
}
@@ -1,9 +1,7 @@
package dev.plex.command.sub;
import dev.plex.Guilds;
import dev.plex.command.PlexCommand;
import dev.plex.command.annotation.CommandParameters;
import dev.plex.command.annotation.CommandPermissions;
import dev.plex.command.SimplePlexCommand;
import dev.plex.command.source.RequiredCommandSource;
import dev.plex.util.CustomLocation;
import java.util.Collections;
@@ -16,13 +14,17 @@ import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@CommandParameters(name = "setwarp", aliases = "makewarp,createwarp", usage = "/guild <command> <name>", description = "Creates a new warp at player's location with a specified name")
@CommandPermissions(source = RequiredCommandSource.IN_GAME, permission = "plex.guilds.setwarp")
public class SetWarpSubCommand extends PlexCommand
public class SetWarpSubCommand extends SimplePlexCommand
{
public SetWarpSubCommand()
{
super(false);
super(command("setwarp")
.description("Creates a new warp at player's location with a specified name")
.usage("/guild <command> <name>")
.aliases("makewarp,createwarp")
.permission("plex.guilds.setwarp")
.source(RequiredCommandSource.IN_GAME)
.build());
}
@Override
@@ -63,7 +65,7 @@ public class SetWarpSubCommand extends PlexCommand
}
@Override
public @NotNull List<String> smartTabComplete(@NotNull CommandSender commandSender, @NotNull String s, @NotNull String[] strings) throws IllegalArgumentException
protected @NotNull List<String> suggestions(@NotNull CommandSender commandSender, @NotNull String s, @NotNull String[] strings) throws IllegalArgumentException
{
return Collections.emptyList();
}
@@ -2,9 +2,7 @@ package dev.plex.command.sub;
import com.google.common.collect.Lists;
import dev.plex.Guilds;
import dev.plex.command.PlexCommand;
import dev.plex.command.annotation.CommandParameters;
import dev.plex.command.annotation.CommandPermissions;
import dev.plex.command.SimplePlexCommand;
import dev.plex.command.source.RequiredCommandSource;
import dev.plex.guild.Guild;
import java.util.Collections;
@@ -16,13 +14,17 @@ import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@CommandParameters(name = "warps", aliases = "listwarps", usage = "/guild <command>", description = "Displays a clickable list of warps")
@CommandPermissions(source = RequiredCommandSource.IN_GAME, permission = "plex.guilds.warps")
public class WarpListSubCommand extends PlexCommand
public class WarpListSubCommand extends SimplePlexCommand
{
public WarpListSubCommand()
{
super(false);
super(command("warps")
.description("Displays a clickable list of warps")
.usage("/guild <command>")
.aliases("listwarps")
.permission("plex.guilds.warps")
.source(RequiredCommandSource.IN_GAME)
.build());
}
@Override
@@ -55,7 +57,7 @@ public class WarpListSubCommand extends PlexCommand
}
@Override
public @NotNull List<String> smartTabComplete(@NotNull CommandSender commandSender, @NotNull String s, @NotNull String[] strings) throws IllegalArgumentException
protected @NotNull List<String> suggestions(@NotNull CommandSender commandSender, @NotNull String s, @NotNull String[] strings) throws IllegalArgumentException
{
return Collections.emptyList();
}
@@ -1,9 +1,7 @@
package dev.plex.command.sub;
import dev.plex.Guilds;
import dev.plex.command.PlexCommand;
import dev.plex.command.annotation.CommandParameters;
import dev.plex.command.annotation.CommandPermissions;
import dev.plex.command.SimplePlexCommand;
import dev.plex.command.source.RequiredCommandSource;
import java.util.Collections;
import java.util.List;
@@ -14,13 +12,17 @@ import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@CommandParameters(name = "warp", aliases = "goto", usage = "/guild <command> <name>", description = "Warps to a specified guild warp")
@CommandPermissions(source = RequiredCommandSource.IN_GAME, permission = "plex.guilds.warp")
public class WarpSubCommand extends PlexCommand
public class WarpSubCommand extends SimplePlexCommand
{
public WarpSubCommand()
{
super(false);
super(command("warp")
.description("Warps to a specified guild warp")
.usage("/guild <command> <name>")
.aliases("goto")
.permission("plex.guilds.warp")
.source(RequiredCommandSource.IN_GAME)
.build());
}
@Override
@@ -45,7 +47,7 @@ public class WarpSubCommand extends PlexCommand
}
@Override
public @NotNull List<String> smartTabComplete(@NotNull CommandSender commandSender, @NotNull String s, @NotNull String[] strings) throws IllegalArgumentException
protected @NotNull List<String> suggestions(@NotNull CommandSender commandSender, @NotNull String s, @NotNull String[] strings) throws IllegalArgumentException
{
return Collections.emptyList();
}