mirror of
https://github.com/plexusorg/Plex.git
synced 2024-12-23 01:27:37 +00:00
Begin fixing command system
This commit is contained in:
parent
edef4d8558
commit
587ea8f352
@ -1,12 +0,0 @@
|
|||||||
package dev.plex.command;
|
|
||||||
|
|
||||||
import dev.plex.command.source.CommandSource;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public interface IPlexCommand
|
|
||||||
{
|
|
||||||
void execute(CommandSource sender, String[] args);
|
|
||||||
|
|
||||||
List<String> onTabComplete(CommandSource sender, String[] args);
|
|
||||||
}
|
|
@ -1,6 +1,5 @@
|
|||||||
package dev.plex.command;
|
package dev.plex.command;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
|
||||||
import dev.plex.Plex;
|
import dev.plex.Plex;
|
||||||
import dev.plex.cache.DataUtils;
|
import dev.plex.cache.DataUtils;
|
||||||
import dev.plex.cache.PlayerCache;
|
import dev.plex.cache.PlayerCache;
|
||||||
@ -9,22 +8,25 @@ import dev.plex.command.annotation.CommandPermissions;
|
|||||||
import dev.plex.command.exception.CommandArgumentException;
|
import dev.plex.command.exception.CommandArgumentException;
|
||||||
import dev.plex.command.exception.CommandFailException;
|
import dev.plex.command.exception.CommandFailException;
|
||||||
import dev.plex.command.exception.PlayerNotFoundException;
|
import dev.plex.command.exception.PlayerNotFoundException;
|
||||||
import dev.plex.command.source.CommandSource;
|
|
||||||
import dev.plex.command.source.RequiredCommandSource;
|
import dev.plex.command.source.RequiredCommandSource;
|
||||||
import dev.plex.player.PlexPlayer;
|
import dev.plex.player.PlexPlayer;
|
||||||
import dev.plex.rank.enums.Rank;
|
import dev.plex.rank.enums.Rank;
|
||||||
import dev.plex.util.PlexUtils;
|
import dev.plex.util.PlexUtils;
|
||||||
|
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.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.command.*;
|
import org.bukkit.command.*;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public abstract class PlexCommand extends Command implements TabExecutor, IPlexCommand
|
public abstract class PlexCommand extends Command
|
||||||
{
|
{
|
||||||
protected static Plex plugin = Plex.get();
|
protected static Plex plugin = Plex.get();
|
||||||
|
|
||||||
@ -32,19 +34,18 @@ public abstract class PlexCommand extends Command implements TabExecutor, IPlexC
|
|||||||
private final CommandPermissions perms;
|
private final CommandPermissions perms;
|
||||||
|
|
||||||
private final Rank level;
|
private final Rank level;
|
||||||
private CommandSource sender;
|
|
||||||
private final RequiredCommandSource commandSource;
|
private final RequiredCommandSource commandSource;
|
||||||
|
|
||||||
public PlexCommand(String name)
|
public PlexCommand()
|
||||||
{
|
{
|
||||||
super(name);
|
super("");
|
||||||
this.params = getClass().getAnnotation(CommandParameters.class);
|
this.params = getClass().getAnnotation(CommandParameters.class);
|
||||||
this.perms = getClass().getAnnotation(CommandPermissions.class);
|
this.perms = getClass().getAnnotation(CommandPermissions.class);
|
||||||
|
|
||||||
setName(name);
|
setName(this.params.name());
|
||||||
setLabel(name);
|
setLabel(this.params.name());
|
||||||
setDescription(params.description());
|
setDescription(params.description());
|
||||||
setUsage(params.usage().replace("<command>", name));
|
setUsage(params.usage().replace("<command>", this.params.name()));
|
||||||
if (params.aliases().split(",").length > 0)
|
if (params.aliases().split(",").length > 0)
|
||||||
{
|
{
|
||||||
setAliases(Arrays.asList(params.aliases().split(",")));
|
setAliases(Arrays.asList(params.aliases().split(",")));
|
||||||
@ -55,16 +56,11 @@ public abstract class PlexCommand extends Command implements TabExecutor, IPlexC
|
|||||||
getMap().register("plex", this);
|
getMap().register("plex", this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected abstract Component execute(CommandSender sender, String[] args);
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(CommandSender sender, String label, String[] args)
|
public boolean execute(@NotNull CommandSender sender, @NotNull String label, String[] args)
|
||||||
{
|
|
||||||
onCommand(sender, this, label, args);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args)
|
|
||||||
{
|
{
|
||||||
if (!matches(label))
|
if (!matches(label))
|
||||||
{
|
{
|
||||||
@ -85,7 +81,6 @@ public abstract class PlexCommand extends Command implements TabExecutor, IPlexC
|
|||||||
}
|
}
|
||||||
Player player = (Player)sender;
|
Player player = (Player)sender;
|
||||||
|
|
||||||
this.sender = new CommandSource(player);
|
|
||||||
PlexPlayer plexPlayer = PlayerCache.getPlexPlayerMap().get(player.getUniqueId());
|
PlexPlayer plexPlayer = PlayerCache.getPlexPlayerMap().get(player.getUniqueId());
|
||||||
if (!plexPlayer.getRankFromString().isAtLeast(getLevel()))
|
if (!plexPlayer.getRankFromString().isAtLeast(getLevel()))
|
||||||
{
|
{
|
||||||
@ -95,55 +90,23 @@ public abstract class PlexCommand extends Command implements TabExecutor, IPlexC
|
|||||||
}
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
this.sender = new CommandSource(sender);
|
Component component = this.execute(sender, args);
|
||||||
execute(this.sender, args);
|
if (component != null)
|
||||||
|
{
|
||||||
|
sender.sendMessage(component);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (CommandArgumentException ex)
|
catch (CommandArgumentException ex)
|
||||||
{
|
{
|
||||||
send(getUsage().replace("<command>", getLabel()));
|
send(sender, getUsage().replace("<command>", getLabel()));
|
||||||
}
|
}
|
||||||
catch (PlayerNotFoundException | CommandFailException ex)
|
catch (PlayerNotFoundException | CommandFailException ex)
|
||||||
{
|
{
|
||||||
send(ex.getMessage());
|
send(sender, ex.getMessage());
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<String> tabComplete(CommandSender sender, String alias, String[] args)
|
|
||||||
{
|
|
||||||
if (!matches(alias))
|
|
||||||
{
|
|
||||||
return ImmutableList.of();
|
|
||||||
}
|
|
||||||
if (sender instanceof Player)
|
|
||||||
{
|
|
||||||
Player player = (Player)sender;
|
|
||||||
|
|
||||||
this.sender = new CommandSource(player);
|
|
||||||
|
|
||||||
PlexPlayer plexPlayer = PlayerCache.getPlexPlayerMap().get(player.getUniqueId());
|
|
||||||
if (plexPlayer.getRankFromString().isAtLeast(getLevel()))
|
|
||||||
{
|
|
||||||
return onTabComplete(this.sender, args);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return ImmutableList.of();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.sender = new CommandSource(sender);
|
|
||||||
return onTabComplete(this.sender, args);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] args)
|
|
||||||
{
|
|
||||||
return tabComplete(sender, label, args);
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean matches(String label)
|
private boolean matches(String label)
|
||||||
{
|
{
|
||||||
@ -164,11 +127,6 @@ public abstract class PlexCommand extends Command implements TabExecutor, IPlexC
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void send(String s, CommandSource sender)
|
|
||||||
{
|
|
||||||
sender.send(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void send(String s, Player player)
|
protected void send(String s, Player player)
|
||||||
{
|
{
|
||||||
player.sendMessage(s);
|
player.sendMessage(s);
|
||||||
@ -185,28 +143,35 @@ public abstract class PlexCommand extends Command implements TabExecutor, IPlexC
|
|||||||
return Plex.get().getRankManager().isAdmin(plexPlayer);
|
return Plex.get().getRankManager().isAdmin(plexPlayer);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean isConsole()
|
protected boolean isConsole(CommandSender sender)
|
||||||
{
|
{
|
||||||
return !(sender instanceof Player);
|
return !(sender instanceof Player);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String tl(String s, Object... objects)
|
protected Component tl(String s, Object... objects)
|
||||||
{
|
{
|
||||||
return PlexUtils.tl(s, objects);
|
return LegacyComponentSerializer.legacyAmpersand().deserialize(PlexUtils.tl(s, objects));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String usage(String s)
|
protected Component usage(String s)
|
||||||
{
|
{
|
||||||
return ChatColor.YELLOW + "Correct Usage: " + ChatColor.GRAY + s;
|
return Component.text("Correct Usage: ").color(NamedTextColor.YELLOW)
|
||||||
|
.append(Component.text(s).color(NamedTextColor.GRAY));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void send(String s)
|
protected void send(Audience audience, String s)
|
||||||
{
|
{
|
||||||
if (sender == null)
|
audience.sendMessage(LegacyComponentSerializer.legacyAmpersand().deserialize(s));
|
||||||
{
|
}
|
||||||
return;
|
|
||||||
}
|
protected void send(Audience audience, Component component)
|
||||||
send(s, sender);
|
{
|
||||||
|
audience.sendMessage(component);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Component fromString(String s)
|
||||||
|
{
|
||||||
|
return LegacyComponentSerializer.legacyAmpersand().deserialize(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Player getNonNullPlayer(String name)
|
protected Player getNonNullPlayer(String name)
|
||||||
@ -245,7 +210,7 @@ public abstract class PlexCommand extends Command implements TabExecutor, IPlexC
|
|||||||
World world = Bukkit.getWorld(name);
|
World world = Bukkit.getWorld(name);
|
||||||
if (world == null)
|
if (world == null)
|
||||||
{
|
{
|
||||||
throw new CommandFailException(tl("worldNotFound"));
|
throw new CommandFailException(PlexUtils.tl("worldNotFound"));
|
||||||
}
|
}
|
||||||
return world;
|
return world;
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,8 @@ import java.lang.annotation.RetentionPolicy;
|
|||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
public @interface CommandParameters
|
public @interface CommandParameters
|
||||||
{
|
{
|
||||||
|
String name();
|
||||||
|
|
||||||
String description() default "";
|
String description() default "";
|
||||||
|
|
||||||
String usage() default "/<command>";
|
String usage() default "/<command>";
|
||||||
|
@ -7,7 +7,6 @@ import dev.plex.command.annotation.CommandParameters;
|
|||||||
import dev.plex.command.annotation.CommandPermissions;
|
import dev.plex.command.annotation.CommandPermissions;
|
||||||
import dev.plex.command.exception.ConsoleOnlyException;
|
import dev.plex.command.exception.ConsoleOnlyException;
|
||||||
import dev.plex.command.exception.PlayerNotFoundException;
|
import dev.plex.command.exception.PlayerNotFoundException;
|
||||||
import dev.plex.command.source.CommandSource;
|
|
||||||
import dev.plex.command.source.RequiredCommandSource;
|
import dev.plex.command.source.RequiredCommandSource;
|
||||||
import dev.plex.event.AdminAddEvent;
|
import dev.plex.event.AdminAddEvent;
|
||||||
import dev.plex.event.AdminRemoveEvent;
|
import dev.plex.event.AdminRemoveEvent;
|
||||||
@ -15,44 +14,40 @@ import dev.plex.event.AdminSetRankEvent;
|
|||||||
import dev.plex.player.PlexPlayer;
|
import dev.plex.player.PlexPlayer;
|
||||||
import dev.plex.rank.enums.Rank;
|
import dev.plex.rank.enums.Rank;
|
||||||
import dev.plex.util.PlexUtils;
|
import dev.plex.util.PlexUtils;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = RequiredCommandSource.ANY)
|
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = RequiredCommandSource.ANY)
|
||||||
@CommandParameters(usage = "/<command> <add | remove | setrank | list> [player] [rank]", aliases = "saconfig,slconfig,adminconfig,adminmanage", description = "Manage all admins")
|
@CommandParameters(name = "admin", usage = "/<command> <add | remove | setrank | list> [player] [rank]", aliases = "saconfig,slconfig,adminconfig,adminmanage", description = "Manage all admins")
|
||||||
public class AdminCMD extends PlexCommand
|
public class AdminCMD extends PlexCommand
|
||||||
{
|
{
|
||||||
//TODO: Better return messages
|
//TODO: Better return messages
|
||||||
|
|
||||||
public AdminCMD()
|
|
||||||
{
|
|
||||||
super("admin");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSource sender, String[] args)
|
public Component execute(CommandSender sender, String[] args)
|
||||||
{
|
{
|
||||||
if (args.length == 0)
|
if (args.length == 0)
|
||||||
{
|
{
|
||||||
sender.send(usage(getUsage()));
|
return usage(getUsage());
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args[0].equalsIgnoreCase("add"))
|
if (args[0].equalsIgnoreCase("add"))
|
||||||
{
|
{
|
||||||
if (args.length != 2)
|
if (args.length != 2)
|
||||||
{
|
{
|
||||||
sender.send(usage("/admin add <player>"));
|
return usage("/admin add <player>");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!sender.isConsoleSender())
|
if (!isConsole(sender))
|
||||||
{
|
{
|
||||||
sender.send(tl("consoleOnly"));
|
send(sender, tl("consoleOnly"));
|
||||||
throw new ConsoleOnlyException();
|
throw new ConsoleOnlyException();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,24 +61,22 @@ public class AdminCMD extends PlexCommand
|
|||||||
|
|
||||||
if (isAdmin(plexPlayer))
|
if (isAdmin(plexPlayer))
|
||||||
{
|
{
|
||||||
sender.send(tl("playerIsAdmin"));
|
return tl("playerIsAdmin");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
plexPlayer.setRank(Rank.ADMIN.name());
|
plexPlayer.setRank(Rank.ADMIN.name());
|
||||||
DataUtils.update(plexPlayer);
|
DataUtils.update(plexPlayer);
|
||||||
Bukkit.getServer().getPluginManager().callEvent(new AdminAddEvent(sender, plexPlayer));
|
Bukkit.getServer().getPluginManager().callEvent(new AdminAddEvent(sender, plexPlayer));
|
||||||
return;
|
return null;
|
||||||
}
|
}
|
||||||
if (args[0].equalsIgnoreCase("remove"))
|
if (args[0].equalsIgnoreCase("remove"))
|
||||||
{
|
{
|
||||||
if (args.length != 2)
|
if (args.length != 2)
|
||||||
{
|
{
|
||||||
sender.send(usage("/admin remove <player>"));
|
return usage("/admin remove <player>");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!sender.isConsoleSender())
|
if (!isConsole(sender))
|
||||||
{
|
{
|
||||||
throw new ConsoleOnlyException();
|
throw new ConsoleOnlyException();
|
||||||
}
|
}
|
||||||
@ -98,25 +91,23 @@ public class AdminCMD extends PlexCommand
|
|||||||
|
|
||||||
if (!isAdmin(plexPlayer))
|
if (!isAdmin(plexPlayer))
|
||||||
{
|
{
|
||||||
sender.send(tl("playerNotAdmin"));
|
return tl("playerNotAdmin");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
plexPlayer.setRank("");
|
plexPlayer.setRank("");
|
||||||
DataUtils.update(plexPlayer);
|
DataUtils.update(plexPlayer);
|
||||||
Bukkit.getServer().getPluginManager().callEvent(new AdminRemoveEvent(sender, plexPlayer));
|
Bukkit.getServer().getPluginManager().callEvent(new AdminRemoveEvent(sender, plexPlayer));
|
||||||
return;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args[0].equalsIgnoreCase("setrank"))
|
if (args[0].equalsIgnoreCase("setrank"))
|
||||||
{
|
{
|
||||||
if (args.length != 3)
|
if (args.length != 3)
|
||||||
{
|
{
|
||||||
sender.send(usage("/admin setrank <player> <rank>"));
|
return usage("/admin setrank <player> <rank>");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!sender.isConsoleSender())
|
if (!isConsole(sender))
|
||||||
{
|
{
|
||||||
throw new ConsoleOnlyException();
|
throw new ConsoleOnlyException();
|
||||||
}
|
}
|
||||||
@ -130,24 +121,21 @@ public class AdminCMD extends PlexCommand
|
|||||||
|
|
||||||
if (!rankExists(args[2]))
|
if (!rankExists(args[2]))
|
||||||
{
|
{
|
||||||
sender.send(tl("rankNotFound"));
|
return tl("rankNotFound");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Rank rank = Rank.valueOf(args[2].toUpperCase());
|
Rank rank = Rank.valueOf(args[2].toUpperCase());
|
||||||
|
|
||||||
if (!rank.isAtLeast(Rank.ADMIN))
|
if (!rank.isAtLeast(Rank.ADMIN))
|
||||||
{
|
{
|
||||||
sender.send(tl("rankMustBeHigherThanAdmin"));
|
return tl("rankMustBeHigherThanAdmin");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PlexPlayer plexPlayer = DataUtils.getPlayer(targetUUID);
|
PlexPlayer plexPlayer = DataUtils.getPlayer(targetUUID);
|
||||||
|
|
||||||
if (!isAdmin(plexPlayer))
|
if (!isAdmin(plexPlayer))
|
||||||
{
|
{
|
||||||
sender.send(tl("playerNotAdmin"));
|
return tl("playerNotAdmin");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
plexPlayer.setRank(rank.name().toLowerCase());
|
plexPlayer.setRank(rank.name().toLowerCase());
|
||||||
@ -155,23 +143,23 @@ public class AdminCMD extends PlexCommand
|
|||||||
|
|
||||||
Bukkit.getServer().getPluginManager().callEvent(new AdminSetRankEvent(sender, plexPlayer, rank));
|
Bukkit.getServer().getPluginManager().callEvent(new AdminSetRankEvent(sender, plexPlayer, rank));
|
||||||
|
|
||||||
return;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args[0].equalsIgnoreCase("list"))
|
if (args[0].equalsIgnoreCase("list"))
|
||||||
{
|
{
|
||||||
if (args.length != 1)
|
if (args.length != 1)
|
||||||
{
|
{
|
||||||
sender.send(usage("/admin list"));
|
return usage("/admin list");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sender.send("Admins: " + StringUtils.join(plugin.getAdminList().getAllAdmins(), ", "));
|
return fromString("Admins: " + StringUtils.join(plugin.getAdminList().getAllAdmins(), ", "));
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> onTabComplete(CommandSource sender, String[] args)
|
public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||||
{
|
{
|
||||||
if (args.length == 1)
|
if (args.length == 1)
|
||||||
{
|
{
|
||||||
@ -184,6 +172,7 @@ public class AdminCMD extends PlexCommand
|
|||||||
return ImmutableList.of();
|
return ImmutableList.of();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private boolean rankExists(String rank)
|
private boolean rankExists(String rank)
|
||||||
{
|
{
|
||||||
for (Rank ranks : Rank.values())
|
for (Rank ranks : Rank.values())
|
||||||
|
@ -3,39 +3,32 @@ package dev.plex.command.impl;
|
|||||||
import dev.plex.command.PlexCommand;
|
import dev.plex.command.PlexCommand;
|
||||||
import dev.plex.command.annotation.CommandParameters;
|
import dev.plex.command.annotation.CommandParameters;
|
||||||
import dev.plex.command.annotation.CommandPermissions;
|
import dev.plex.command.annotation.CommandPermissions;
|
||||||
import dev.plex.command.source.CommandSource;
|
|
||||||
import dev.plex.command.source.RequiredCommandSource;
|
import dev.plex.command.source.RequiredCommandSource;
|
||||||
import dev.plex.rank.enums.Rank;
|
import dev.plex.rank.enums.Rank;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.ADMIN, source = RequiredCommandSource.IN_GAME)
|
@CommandPermissions(level = Rank.ADMIN, source = RequiredCommandSource.IN_GAME)
|
||||||
@CommandParameters(aliases = "aw", description = "Teleport to the adminworld")
|
@CommandParameters(name = "adminworld", aliases = "aw", description = "Teleport to the adminworld")
|
||||||
public class AdminworldCMD extends PlexCommand
|
public class AdminworldCMD extends PlexCommand
|
||||||
{
|
{
|
||||||
public AdminworldCMD()
|
|
||||||
{
|
|
||||||
super("adminworld");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSource sender, String[] args)
|
public Component execute(CommandSender sender, String[] args)
|
||||||
{
|
{
|
||||||
// TODO: Add adminworld settings
|
// TODO: Add adminworld settings
|
||||||
if (args.length == 0)
|
if (args.length == 0)
|
||||||
{
|
{
|
||||||
Location loc = new Location(Bukkit.getWorld("adminworld"), 0, 50, 0);
|
Location loc = new Location(Bukkit.getWorld("adminworld"), 0, 50, 0);
|
||||||
sender.getPlayer().teleportAsync(loc);
|
((Player)sender).teleportAsync(loc);
|
||||||
send(tl("teleportedToWorld", "adminworld"));
|
return tl("teleportedToWorld", "adminworld");
|
||||||
}
|
}
|
||||||
}
|
return null;
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<String> onTabComplete(CommandSource sender, String[] args)
|
|
||||||
{
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,27 +5,24 @@ import dev.plex.command.PlexCommand;
|
|||||||
import dev.plex.command.annotation.CommandParameters;
|
import dev.plex.command.annotation.CommandParameters;
|
||||||
import dev.plex.command.annotation.CommandPermissions;
|
import dev.plex.command.annotation.CommandPermissions;
|
||||||
import dev.plex.command.exception.CommandFailException;
|
import dev.plex.command.exception.CommandFailException;
|
||||||
import dev.plex.command.source.CommandSource;
|
|
||||||
import dev.plex.command.source.RequiredCommandSource;
|
import dev.plex.command.source.RequiredCommandSource;
|
||||||
import dev.plex.rank.enums.Rank;
|
import dev.plex.rank.enums.Rank;
|
||||||
import dev.plex.util.PlexUtils;
|
import dev.plex.util.PlexUtils;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.OP, source = RequiredCommandSource.ANY)
|
@CommandPermissions(level = Rank.OP, source = RequiredCommandSource.ANY)
|
||||||
@CommandParameters(aliases = "gma", description = "Set your own or another player's gamemode to adventure mode")
|
@CommandParameters(name = "adventure", aliases = "gma", description = "Set your own or another player's gamemode to adventure mode")
|
||||||
public class AdventureCMD extends PlexCommand
|
public class AdventureCMD extends PlexCommand
|
||||||
{
|
{
|
||||||
public AdventureCMD()
|
|
||||||
{
|
|
||||||
super("adventure");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSource sender, String[] args)
|
public Component execute(CommandSender sender, String[] args)
|
||||||
{
|
{
|
||||||
if (args.length == 0)
|
if (args.length == 0)
|
||||||
{
|
{
|
||||||
@ -61,7 +58,7 @@ public class AdventureCMD extends PlexCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> onTabComplete(CommandSource sender, String[] args)
|
public List<String> tabComplete(CommandSender sender, String[] args)
|
||||||
{
|
{
|
||||||
if (isAdmin(sender.getPlexPlayer()))
|
if (isAdmin(sender.getPlexPlayer()))
|
||||||
{
|
{
|
||||||
|
@ -7,7 +7,6 @@ import dev.plex.command.PlexCommand;
|
|||||||
import dev.plex.command.annotation.CommandParameters;
|
import dev.plex.command.annotation.CommandParameters;
|
||||||
import dev.plex.command.annotation.CommandPermissions;
|
import dev.plex.command.annotation.CommandPermissions;
|
||||||
import dev.plex.command.exception.PlayerNotFoundException;
|
import dev.plex.command.exception.PlayerNotFoundException;
|
||||||
import dev.plex.command.source.CommandSource;
|
|
||||||
import dev.plex.command.source.RequiredCommandSource;
|
import dev.plex.command.source.RequiredCommandSource;
|
||||||
import dev.plex.player.PlexPlayer;
|
import dev.plex.player.PlexPlayer;
|
||||||
import dev.plex.player.PunishedPlayer;
|
import dev.plex.player.PunishedPlayer;
|
||||||
@ -32,7 +31,7 @@ public class BanCMD extends PlexCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSource sender, String[] args)
|
public Component execute(CommandSender sender, String[] args)
|
||||||
{
|
{
|
||||||
if (args.length == 0)
|
if (args.length == 0)
|
||||||
{
|
{
|
||||||
@ -80,7 +79,7 @@ public class BanCMD extends PlexCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> onTabComplete(CommandSource sender, String[] args) {
|
public List<String> tabComplete(CommandSender sender, String[] args) {
|
||||||
return args.length == 1 ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
return args.length == 1 ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,6 @@ import dev.plex.command.PlexCommand;
|
|||||||
import dev.plex.command.annotation.CommandParameters;
|
import dev.plex.command.annotation.CommandParameters;
|
||||||
import dev.plex.command.annotation.CommandPermissions;
|
import dev.plex.command.annotation.CommandPermissions;
|
||||||
import dev.plex.command.exception.CommandFailException;
|
import dev.plex.command.exception.CommandFailException;
|
||||||
import dev.plex.command.source.CommandSource;
|
|
||||||
import dev.plex.command.source.RequiredCommandSource;
|
import dev.plex.command.source.RequiredCommandSource;
|
||||||
import dev.plex.rank.enums.Rank;
|
import dev.plex.rank.enums.Rank;
|
||||||
import dev.plex.util.PlexUtils;
|
import dev.plex.util.PlexUtils;
|
||||||
@ -25,7 +24,7 @@ public class CreativeCMD extends PlexCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSource sender, String[] args)
|
public Component execute(CommandSender sender, String[] args)
|
||||||
{
|
{
|
||||||
if (args.length == 0)
|
if (args.length == 0)
|
||||||
{
|
{
|
||||||
@ -60,7 +59,7 @@ public class CreativeCMD extends PlexCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> onTabComplete(CommandSource sender, String[] args)
|
public List<String> tabComplete(CommandSender sender, String[] args)
|
||||||
{
|
{
|
||||||
if (isAdmin(sender.getPlexPlayer()))
|
if (isAdmin(sender.getPlexPlayer()))
|
||||||
{
|
{
|
||||||
|
@ -7,7 +7,6 @@ import dev.plex.command.annotation.CommandParameters;
|
|||||||
import dev.plex.command.annotation.CommandPermissions;
|
import dev.plex.command.annotation.CommandPermissions;
|
||||||
import dev.plex.command.exception.CommandArgumentException;
|
import dev.plex.command.exception.CommandArgumentException;
|
||||||
import dev.plex.command.exception.CommandFailException;
|
import dev.plex.command.exception.CommandFailException;
|
||||||
import dev.plex.command.source.CommandSource;
|
|
||||||
import dev.plex.command.source.RequiredCommandSource;
|
import dev.plex.command.source.RequiredCommandSource;
|
||||||
import dev.plex.util.PlexUtils;
|
import dev.plex.util.PlexUtils;
|
||||||
import dev.plex.world.BlockMapChunkGenerator;
|
import dev.plex.world.BlockMapChunkGenerator;
|
||||||
@ -34,7 +33,7 @@ public class FionnCMD extends PlexCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSource sender, String[] args)
|
public Component execute(CommandSender sender, String[] args)
|
||||||
{
|
{
|
||||||
if (!sender.getPlayer().getUniqueId().equals(UUID.fromString("9aa3eda6-c271-440a-a578-a952ee9aee2f")))
|
if (!sender.getPlayer().getUniqueId().equals(UUID.fromString("9aa3eda6-c271-440a-a578-a952ee9aee2f")))
|
||||||
{
|
{
|
||||||
@ -125,7 +124,7 @@ public class FionnCMD extends PlexCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> onTabComplete(CommandSource sender, String[] args)
|
public List<String> tabComplete(CommandSender sender, String[] args)
|
||||||
{
|
{
|
||||||
return ImmutableList.of();
|
return ImmutableList.of();
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ package dev.plex.command.impl;
|
|||||||
import dev.plex.command.PlexCommand;
|
import dev.plex.command.PlexCommand;
|
||||||
import dev.plex.command.annotation.CommandParameters;
|
import dev.plex.command.annotation.CommandParameters;
|
||||||
import dev.plex.command.annotation.CommandPermissions;
|
import dev.plex.command.annotation.CommandPermissions;
|
||||||
import dev.plex.command.source.CommandSource;
|
|
||||||
import dev.plex.command.source.RequiredCommandSource;
|
import dev.plex.command.source.RequiredCommandSource;
|
||||||
import dev.plex.rank.enums.Rank;
|
import dev.plex.rank.enums.Rank;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -22,7 +21,7 @@ public class FlatlandsCMD extends PlexCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSource sender, String[] args)
|
public Component execute(CommandSender sender, String[] args)
|
||||||
{
|
{
|
||||||
if (args.length == 0)
|
if (args.length == 0)
|
||||||
{
|
{
|
||||||
@ -33,7 +32,7 @@ public class FlatlandsCMD extends PlexCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> onTabComplete(CommandSource sender, String[] args)
|
public List<String> tabComplete(CommandSender sender, String[] args)
|
||||||
{
|
{
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,6 @@ import dev.plex.command.PlexCommand;
|
|||||||
import dev.plex.command.annotation.CommandParameters;
|
import dev.plex.command.annotation.CommandParameters;
|
||||||
import dev.plex.command.annotation.CommandPermissions;
|
import dev.plex.command.annotation.CommandPermissions;
|
||||||
import dev.plex.command.exception.CommandArgumentException;
|
import dev.plex.command.exception.CommandArgumentException;
|
||||||
import dev.plex.command.source.CommandSource;
|
|
||||||
import dev.plex.player.PunishedPlayer;
|
import dev.plex.player.PunishedPlayer;
|
||||||
import dev.plex.punishment.Punishment;
|
import dev.plex.punishment.Punishment;
|
||||||
import dev.plex.punishment.PunishmentType;
|
import dev.plex.punishment.PunishmentType;
|
||||||
@ -29,7 +28,7 @@ public class FreezeCMD extends PlexCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSource sender, String[] args)
|
public Component execute(CommandSender sender, String[] args)
|
||||||
{
|
{
|
||||||
if (args.length != 1)
|
if (args.length != 1)
|
||||||
{
|
{
|
||||||
@ -49,7 +48,7 @@ public class FreezeCMD extends PlexCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> onTabComplete(CommandSource sender, String[] args)
|
public List<String> tabComplete(CommandSender sender, String[] args)
|
||||||
{
|
{
|
||||||
return args.length == 1 ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
return args.length == 1 ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ package dev.plex.command.impl;
|
|||||||
import dev.plex.command.PlexCommand;
|
import dev.plex.command.PlexCommand;
|
||||||
import dev.plex.command.annotation.CommandParameters;
|
import dev.plex.command.annotation.CommandParameters;
|
||||||
import dev.plex.command.annotation.CommandPermissions;
|
import dev.plex.command.annotation.CommandPermissions;
|
||||||
import dev.plex.command.source.CommandSource;
|
|
||||||
import dev.plex.command.source.RequiredCommandSource;
|
import dev.plex.command.source.RequiredCommandSource;
|
||||||
import dev.plex.rank.enums.Rank;
|
import dev.plex.rank.enums.Rank;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -22,7 +21,7 @@ public class MasterbuilderworldCMD extends PlexCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSource sender, String[] args)
|
public Component execute(CommandSender sender, String[] args)
|
||||||
{
|
{
|
||||||
// TODO: Add adminworld settings
|
// TODO: Add adminworld settings
|
||||||
if (args.length == 0)
|
if (args.length == 0)
|
||||||
@ -34,7 +33,7 @@ public class MasterbuilderworldCMD extends PlexCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> onTabComplete(CommandSource sender, String[] args)
|
public List<String> tabComplete(CommandSender sender, String[] args)
|
||||||
{
|
{
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,6 @@ import dev.plex.command.PlexCommand;
|
|||||||
import dev.plex.command.annotation.CommandParameters;
|
import dev.plex.command.annotation.CommandParameters;
|
||||||
import dev.plex.command.annotation.CommandPermissions;
|
import dev.plex.command.annotation.CommandPermissions;
|
||||||
import dev.plex.command.exception.CommandArgumentException;
|
import dev.plex.command.exception.CommandArgumentException;
|
||||||
import dev.plex.command.source.CommandSource;
|
|
||||||
import dev.plex.rank.enums.Rank;
|
import dev.plex.rank.enums.Rank;
|
||||||
import dev.plex.util.PlexUtils;
|
import dev.plex.util.PlexUtils;
|
||||||
import org.json.simple.JSONArray;
|
import org.json.simple.JSONArray;
|
||||||
@ -29,7 +28,7 @@ public class NameHistoryCMD extends PlexCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSource sender, String[] args)
|
public Component execute(CommandSender sender, String[] args)
|
||||||
{
|
{
|
||||||
if (args.length != 1)
|
if (args.length != 1)
|
||||||
{
|
{
|
||||||
@ -73,7 +72,7 @@ public class NameHistoryCMD extends PlexCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> onTabComplete(CommandSource sender, String[] args)
|
public List<String> tabComplete(CommandSender sender, String[] args)
|
||||||
{
|
{
|
||||||
return args.length == 1 ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
return args.length == 1 ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@ import com.google.common.collect.ImmutableList;
|
|||||||
import dev.plex.command.PlexCommand;
|
import dev.plex.command.PlexCommand;
|
||||||
import dev.plex.command.annotation.CommandParameters;
|
import dev.plex.command.annotation.CommandParameters;
|
||||||
import dev.plex.command.annotation.CommandPermissions;
|
import dev.plex.command.annotation.CommandPermissions;
|
||||||
import dev.plex.command.source.CommandSource;
|
|
||||||
import dev.plex.rank.enums.Rank;
|
import dev.plex.rank.enums.Rank;
|
||||||
import dev.plex.util.PlexUtils;
|
import dev.plex.util.PlexUtils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -22,7 +21,7 @@ public class OpAllCMD extends PlexCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSource sender, String[] args)
|
public Component execute(CommandSender sender, String[] args)
|
||||||
{
|
{
|
||||||
for (Player player : Bukkit.getOnlinePlayers())
|
for (Player player : Bukkit.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
@ -32,7 +31,7 @@ public class OpAllCMD extends PlexCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> onTabComplete(CommandSource sender, String[] args)
|
public List<String> tabComplete(CommandSender sender, String[] args)
|
||||||
{
|
{
|
||||||
return ImmutableList.of();
|
return ImmutableList.of();
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,6 @@ import dev.plex.command.PlexCommand;
|
|||||||
import dev.plex.command.annotation.CommandParameters;
|
import dev.plex.command.annotation.CommandParameters;
|
||||||
import dev.plex.command.annotation.CommandPermissions;
|
import dev.plex.command.annotation.CommandPermissions;
|
||||||
import dev.plex.command.exception.CommandArgumentException;
|
import dev.plex.command.exception.CommandArgumentException;
|
||||||
import dev.plex.command.source.CommandSource;
|
|
||||||
import dev.plex.rank.enums.Rank;
|
import dev.plex.rank.enums.Rank;
|
||||||
import dev.plex.util.PlexUtils;
|
import dev.plex.util.PlexUtils;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -22,7 +21,7 @@ public class OpCMD extends PlexCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSource sender, String[] args)
|
public Component execute(CommandSender sender, String[] args)
|
||||||
{
|
{
|
||||||
if (args.length != 1)
|
if (args.length != 1)
|
||||||
{
|
{
|
||||||
@ -34,7 +33,7 @@ public class OpCMD extends PlexCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> onTabComplete(CommandSource sender, String[] args)
|
public List<String> tabComplete(CommandSender sender, String[] args)
|
||||||
{
|
{
|
||||||
return args.length == 1 ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
return args.length == 1 ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
||||||
}
|
}
|
||||||
|
@ -5,12 +5,10 @@ import dev.plex.command.PlexCommand;
|
|||||||
import dev.plex.command.annotation.CommandParameters;
|
import dev.plex.command.annotation.CommandParameters;
|
||||||
import dev.plex.command.annotation.CommandPermissions;
|
import dev.plex.command.annotation.CommandPermissions;
|
||||||
import dev.plex.command.exception.CommandArgumentException;
|
import dev.plex.command.exception.CommandArgumentException;
|
||||||
import dev.plex.command.source.CommandSource;
|
|
||||||
import dev.plex.command.source.RequiredCommandSource;
|
import dev.plex.command.source.RequiredCommandSource;
|
||||||
import dev.plex.rank.enums.Rank;
|
import dev.plex.rank.enums.Rank;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.OP, source = RequiredCommandSource.ANY)
|
@CommandPermissions(level = Rank.OP, source = RequiredCommandSource.ANY)
|
||||||
@ -21,7 +19,7 @@ public class PlexCMD extends PlexCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSource sender, String[] args) {
|
public Component execute(CommandSender sender, String[] args) {
|
||||||
if (args.length == 0) {
|
if (args.length == 0) {
|
||||||
send(ChatColor.LIGHT_PURPLE + "Plex. The long awaited TotalFreedomMod rewrite starts here...");
|
send(ChatColor.LIGHT_PURPLE + "Plex. The long awaited TotalFreedomMod rewrite starts here...");
|
||||||
send(ChatColor.LIGHT_PURPLE + "Plugin version: " + ChatColor.GOLD + "1.0");
|
send(ChatColor.LIGHT_PURPLE + "Plugin version: " + ChatColor.GOLD + "1.0");
|
||||||
@ -47,7 +45,7 @@ public class PlexCMD extends PlexCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> onTabComplete(CommandSource sender, String[] args) {
|
public List<String> tabComplete(CommandSender sender, String[] args) {
|
||||||
return List.of("reload");
|
return List.of("reload");
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -4,7 +4,6 @@ import com.google.common.collect.ImmutableList;
|
|||||||
import dev.plex.command.PlexCommand;
|
import dev.plex.command.PlexCommand;
|
||||||
import dev.plex.command.annotation.CommandParameters;
|
import dev.plex.command.annotation.CommandParameters;
|
||||||
import dev.plex.command.annotation.CommandPermissions;
|
import dev.plex.command.annotation.CommandPermissions;
|
||||||
import dev.plex.command.source.CommandSource;
|
|
||||||
import dev.plex.command.source.RequiredCommandSource;
|
import dev.plex.command.source.RequiredCommandSource;
|
||||||
import dev.plex.menu.PunishmentMenu;
|
import dev.plex.menu.PunishmentMenu;
|
||||||
import dev.plex.rank.enums.Rank;
|
import dev.plex.rank.enums.Rank;
|
||||||
@ -23,14 +22,14 @@ public class PunishmentsCMD extends PlexCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSource sender, String[] args)
|
public Component execute(CommandSender sender, String[] args)
|
||||||
{
|
{
|
||||||
Player player = sender.getPlayer();
|
Player player = sender.getPlayer();
|
||||||
new PunishmentMenu().openInv(player, 0);
|
new PunishmentMenu().openInv(player, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> onTabComplete(CommandSource sender, String[] args) {
|
public List<String> tabComplete(CommandSender sender, String[] args) {
|
||||||
return args.length == 1 ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
return args.length == 1 ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ package dev.plex.command.impl;
|
|||||||
import dev.plex.command.PlexCommand;
|
import dev.plex.command.PlexCommand;
|
||||||
import dev.plex.command.annotation.CommandParameters;
|
import dev.plex.command.annotation.CommandParameters;
|
||||||
import dev.plex.command.annotation.CommandPermissions;
|
import dev.plex.command.annotation.CommandPermissions;
|
||||||
import dev.plex.command.source.CommandSource;
|
|
||||||
import dev.plex.command.source.RequiredCommandSource;
|
import dev.plex.command.source.RequiredCommandSource;
|
||||||
import dev.plex.rank.enums.Rank;
|
import dev.plex.rank.enums.Rank;
|
||||||
|
|
||||||
@ -19,12 +18,12 @@ public class RankCMD extends PlexCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSource sender, String[] args) {
|
public Component execute(CommandSender sender, String[] args) {
|
||||||
send(tl("yourRank", sender.getPlexPlayer().getRank()));
|
send(tl("yourRank", sender.getPlexPlayer().getRank()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> onTabComplete(CommandSource sender, String[] args) {
|
public List<String> tabComplete(CommandSender sender, String[] args) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -5,7 +5,6 @@ import dev.plex.command.PlexCommand;
|
|||||||
import dev.plex.command.annotation.CommandParameters;
|
import dev.plex.command.annotation.CommandParameters;
|
||||||
import dev.plex.command.annotation.CommandPermissions;
|
import dev.plex.command.annotation.CommandPermissions;
|
||||||
import dev.plex.command.exception.CommandFailException;
|
import dev.plex.command.exception.CommandFailException;
|
||||||
import dev.plex.command.source.CommandSource;
|
|
||||||
import dev.plex.command.source.RequiredCommandSource;
|
import dev.plex.command.source.RequiredCommandSource;
|
||||||
import dev.plex.rank.enums.Rank;
|
import dev.plex.rank.enums.Rank;
|
||||||
import dev.plex.util.PlexUtils;
|
import dev.plex.util.PlexUtils;
|
||||||
@ -25,7 +24,7 @@ public class SpectatorCMD extends PlexCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSource sender, String[] args)
|
public Component execute(CommandSender sender, String[] args)
|
||||||
{
|
{
|
||||||
if (args.length == 0)
|
if (args.length == 0)
|
||||||
{
|
{
|
||||||
@ -57,7 +56,7 @@ public class SpectatorCMD extends PlexCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> onTabComplete(CommandSource sender, String[] args)
|
public List<String> tabComplete(CommandSender sender, String[] args)
|
||||||
{
|
{
|
||||||
if (isAdmin(sender.getPlexPlayer()))
|
if (isAdmin(sender.getPlexPlayer()))
|
||||||
{
|
{
|
||||||
|
@ -5,7 +5,6 @@ import dev.plex.command.PlexCommand;
|
|||||||
import dev.plex.command.annotation.CommandParameters;
|
import dev.plex.command.annotation.CommandParameters;
|
||||||
import dev.plex.command.annotation.CommandPermissions;
|
import dev.plex.command.annotation.CommandPermissions;
|
||||||
import dev.plex.command.exception.CommandFailException;
|
import dev.plex.command.exception.CommandFailException;
|
||||||
import dev.plex.command.source.CommandSource;
|
|
||||||
import dev.plex.command.source.RequiredCommandSource;
|
import dev.plex.command.source.RequiredCommandSource;
|
||||||
import dev.plex.rank.enums.Rank;
|
import dev.plex.rank.enums.Rank;
|
||||||
import dev.plex.util.PlexUtils;
|
import dev.plex.util.PlexUtils;
|
||||||
@ -25,7 +24,7 @@ public class SurvivalCMD extends PlexCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSource sender, String[] args)
|
public Component execute(CommandSender sender, String[] args)
|
||||||
{
|
{
|
||||||
if (args.length == 0)
|
if (args.length == 0)
|
||||||
{
|
{
|
||||||
@ -60,7 +59,7 @@ public class SurvivalCMD extends PlexCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> onTabComplete(CommandSource sender, String[] args)
|
public List<String> tabComplete(CommandSender sender, String[] args)
|
||||||
{
|
{
|
||||||
if (isAdmin(sender.getPlexPlayer()))
|
if (isAdmin(sender.getPlexPlayer()))
|
||||||
{
|
{
|
||||||
|
@ -4,7 +4,6 @@ import com.google.common.collect.ImmutableList;
|
|||||||
import dev.plex.command.PlexCommand;
|
import dev.plex.command.PlexCommand;
|
||||||
import dev.plex.command.annotation.CommandParameters;
|
import dev.plex.command.annotation.CommandParameters;
|
||||||
import dev.plex.command.annotation.CommandPermissions;
|
import dev.plex.command.annotation.CommandPermissions;
|
||||||
import dev.plex.command.source.CommandSource;
|
|
||||||
import dev.plex.command.source.RequiredCommandSource;
|
import dev.plex.command.source.RequiredCommandSource;
|
||||||
import dev.plex.rank.enums.Rank;
|
import dev.plex.rank.enums.Rank;
|
||||||
|
|
||||||
@ -21,13 +20,13 @@ public class TestCMD extends PlexCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSource sender, String[] args)
|
public Component execute(CommandSender sender, String[] args)
|
||||||
{
|
{
|
||||||
send(tl("variableTest", sender.getName()));
|
send(tl("variableTest", sender.getName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> onTabComplete(CommandSource sender, String[] args)
|
public List<String> tabComplete(CommandSender sender, String[] args)
|
||||||
{
|
{
|
||||||
if (args.length == 1)
|
if (args.length == 1)
|
||||||
{
|
{
|
||||||
|
@ -5,7 +5,6 @@ import dev.plex.command.PlexCommand;
|
|||||||
import dev.plex.command.annotation.CommandParameters;
|
import dev.plex.command.annotation.CommandParameters;
|
||||||
import dev.plex.command.annotation.CommandPermissions;
|
import dev.plex.command.annotation.CommandPermissions;
|
||||||
import dev.plex.command.exception.CommandArgumentException;
|
import dev.plex.command.exception.CommandArgumentException;
|
||||||
import dev.plex.command.source.CommandSource;
|
|
||||||
import dev.plex.command.source.RequiredCommandSource;
|
import dev.plex.command.source.RequiredCommandSource;
|
||||||
import dev.plex.rank.enums.Rank;
|
import dev.plex.rank.enums.Rank;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -25,7 +24,7 @@ public class WorldCMD extends PlexCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSource sender, String[] args)
|
public Component execute(CommandSender sender, String[] args)
|
||||||
{
|
{
|
||||||
if (args.length != 1)
|
if (args.length != 1)
|
||||||
{
|
{
|
||||||
@ -37,7 +36,7 @@ public class WorldCMD extends PlexCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> onTabComplete(CommandSource sender, String[] args)
|
public List<String> tabComplete(CommandSender sender, String[] args)
|
||||||
{
|
{
|
||||||
List<String> worlds = new ArrayList<>();
|
List<String> worlds = new ArrayList<>();
|
||||||
for (World world : Bukkit.getWorlds())
|
for (World world : Bukkit.getWorlds())
|
||||||
|
@ -1,37 +0,0 @@
|
|||||||
package dev.plex.command.source;
|
|
||||||
|
|
||||||
import dev.plex.cache.PlayerCache;
|
|
||||||
import dev.plex.player.PlexPlayer;
|
|
||||||
import lombok.Getter;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
public class CommandSource
|
|
||||||
{
|
|
||||||
private final CommandSender sender;
|
|
||||||
private final Player player;
|
|
||||||
private final PlexPlayer plexPlayer;
|
|
||||||
private final boolean isConsoleSender;
|
|
||||||
|
|
||||||
public CommandSource(CommandSender sender)
|
|
||||||
{
|
|
||||||
this.sender = sender;
|
|
||||||
this.isConsoleSender = !(sender instanceof Player);
|
|
||||||
this.player = sender instanceof Player ? Bukkit.getPlayer(sender.getName()) : null;
|
|
||||||
this.plexPlayer = sender instanceof Player ? PlayerCache.getPlexPlayerMap().get(((Player)sender).getUniqueId()) : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// there's a bug here where it sends it to the player not the console
|
|
||||||
// i assume this is because there's no checking. no idea why but it always sends it to the player even if executed from the console
|
|
||||||
public void send(String s)
|
|
||||||
{
|
|
||||||
sender.sendMessage(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName()
|
|
||||||
{
|
|
||||||
return sender.getName();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,22 +1,18 @@
|
|||||||
package dev.plex.event;
|
package dev.plex.event;
|
||||||
|
|
||||||
import dev.plex.command.source.CommandSource;
|
|
||||||
import dev.plex.player.PlexPlayer;
|
import dev.plex.player.PlexPlayer;
|
||||||
|
import lombok.Data;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
|
@Data
|
||||||
public class AdminAddEvent extends Event
|
public class AdminAddEvent extends Event
|
||||||
{
|
{
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
private CommandSource sender;
|
private final CommandSender sender;
|
||||||
private PlexPlayer plexPlayer;
|
private final PlexPlayer plexPlayer;
|
||||||
|
|
||||||
public AdminAddEvent(CommandSource sender, PlexPlayer plexPlayer)
|
|
||||||
{
|
|
||||||
this.sender = sender;
|
|
||||||
this.plexPlayer = plexPlayer;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HandlerList getHandlers()
|
public HandlerList getHandlers()
|
||||||
@ -29,12 +25,4 @@ public class AdminAddEvent extends Event
|
|||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PlexPlayer getPlexPlayer()
|
|
||||||
{
|
|
||||||
return plexPlayer;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CommandSource getSender() {
|
|
||||||
return sender;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,22 +1,18 @@
|
|||||||
package dev.plex.event;
|
package dev.plex.event;
|
||||||
|
|
||||||
import dev.plex.command.source.CommandSource;
|
|
||||||
import dev.plex.player.PlexPlayer;
|
import dev.plex.player.PlexPlayer;
|
||||||
|
import lombok.Data;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
|
@Data
|
||||||
public class AdminRemoveEvent extends Event
|
public class AdminRemoveEvent extends Event
|
||||||
{
|
{
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
private PlexPlayer plexPlayer;
|
private final CommandSender sender;
|
||||||
private CommandSource sender;
|
private final PlexPlayer plexPlayer;
|
||||||
|
|
||||||
public AdminRemoveEvent(CommandSource sender, PlexPlayer plexPlayer)
|
|
||||||
{
|
|
||||||
this.sender = sender;
|
|
||||||
this.plexPlayer = plexPlayer;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HandlerList getHandlers()
|
public HandlerList getHandlers()
|
||||||
@ -28,13 +24,4 @@ public class AdminRemoveEvent extends Event
|
|||||||
{
|
{
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PlexPlayer getPlexPlayer()
|
|
||||||
{
|
|
||||||
return plexPlayer;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CommandSource getSender() {
|
|
||||||
return sender;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,25 +1,21 @@
|
|||||||
package dev.plex.event;
|
package dev.plex.event;
|
||||||
|
|
||||||
import dev.plex.command.source.CommandSource;
|
|
||||||
import dev.plex.player.PlexPlayer;
|
import dev.plex.player.PlexPlayer;
|
||||||
import dev.plex.rank.enums.Rank;
|
import dev.plex.rank.enums.Rank;
|
||||||
|
import lombok.Data;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
|
@Data
|
||||||
public class AdminSetRankEvent extends Event
|
public class AdminSetRankEvent extends Event
|
||||||
{
|
{
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
private CommandSource sender;
|
private final CommandSender sender;
|
||||||
private PlexPlayer plexPlayer;
|
private final PlexPlayer plexPlayer;
|
||||||
private Rank rank;
|
private final Rank rank;
|
||||||
|
|
||||||
public AdminSetRankEvent(CommandSource sender, PlexPlayer plexPlayer, Rank rank)
|
|
||||||
{
|
|
||||||
this.sender = sender;
|
|
||||||
this.plexPlayer = plexPlayer;
|
|
||||||
this.rank = rank;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HandlerList getHandlers()
|
public HandlerList getHandlers()
|
||||||
@ -31,18 +27,4 @@ public class AdminSetRankEvent extends Event
|
|||||||
{
|
{
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PlexPlayer getPlexPlayer()
|
|
||||||
{
|
|
||||||
return plexPlayer;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Rank getRank()
|
|
||||||
{
|
|
||||||
return rank;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CommandSource getSender() {
|
|
||||||
return sender;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -172,12 +172,7 @@ public class PlexUtils
|
|||||||
|
|
||||||
public static List<String> getPlayerNameList()
|
public static List<String> getPlayerNameList()
|
||||||
{
|
{
|
||||||
List<String> names = new ArrayList<>();
|
return Bukkit.getOnlinePlayers().stream().map(Player::getName).collect(Collectors.toList());
|
||||||
for (Player player : Bukkit.getOnlinePlayers())
|
|
||||||
{
|
|
||||||
names.add(player.getName());
|
|
||||||
}
|
|
||||||
return names;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void broadcast(String s)
|
public static void broadcast(String s)
|
||||||
|
Loading…
Reference in New Issue
Block a user