diff --git a/pom.xml b/pom.xml
index 03fd0b4..48532d3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -18,15 +18,15 @@
- spigot-repo
- https://hub.spigotmc.org/nexus/content/repositories/snapshots/
+ papermc
+ https://papermc.io/repo/repository/maven-public/
- org.spigotmc
- spigot-api
+ com.destroystokyo.paper
+ paper-api
1.16.3-R0.1-SNAPSHOT
provided
diff --git a/src/main/java/me/totalfreedom/plex/Plex.java b/src/main/java/me/totalfreedom/plex/Plex.java
index abb2bef..8a945d7 100644
--- a/src/main/java/me/totalfreedom/plex/Plex.java
+++ b/src/main/java/me/totalfreedom/plex/Plex.java
@@ -5,8 +5,8 @@ import lombok.Setter;
import me.totalfreedom.plex.cache.MongoPlayerData;
import me.totalfreedom.plex.cache.SQLPlayerData;
import me.totalfreedom.plex.config.MainConfig;
-import me.totalfreedom.plex.listener.ChatListener;
-import me.totalfreedom.plex.listener.PlayerListener;
+import me.totalfreedom.plex.handlers.CommandHandler;
+import me.totalfreedom.plex.handlers.ListenerHandler;
import me.totalfreedom.plex.rank.RankManager;
import me.totalfreedom.plex.storage.MongoConnection;
import me.totalfreedom.plex.storage.RedisConnection;
@@ -86,8 +86,8 @@ public class Plex extends JavaPlugin
sqlPlayerData = new SQLPlayerData();
}
- getServer().getPluginManager().registerEvents(new PlayerListener(), this);
- getServer().getPluginManager().registerEvents(new ChatListener(), this);
+ new ListenerHandler(); // this doesn't need a variable.
+ new CommandHandler();
rankManager = new RankManager();
rankManager.generateDefaultRanks();
diff --git a/src/main/java/me/totalfreedom/plex/command/CommandSource.java b/src/main/java/me/totalfreedom/plex/command/CommandSource.java
deleted file mode 100644
index 894fa7e..0000000
--- a/src/main/java/me/totalfreedom/plex/command/CommandSource.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package me.totalfreedom.plex.command;
-
-import lombok.Getter;
-import me.totalfreedom.plex.player.PlexPlayer;
-import org.bukkit.Bukkit;
-import org.bukkit.command.CommandSender;
-import org.bukkit.entity.Player;
-
-public class CommandSource
-{
- @Getter
- private CommandSender sender;
- @Getter
- private Player player;
- private PlexPlayer plexPlayer;
-
- public CommandSource(CommandSender sender)
- {
- this.sender = sender;
- this.player = Bukkit.getPlayer(sender.getName());
- this.plexPlayer = null;
- }
-
-
-}
\ No newline at end of file
diff --git a/src/main/java/me/totalfreedom/plex/command/IPlexCommand.java b/src/main/java/me/totalfreedom/plex/command/IPlexCommand.java
new file mode 100644
index 0000000..ef053ae
--- /dev/null
+++ b/src/main/java/me/totalfreedom/plex/command/IPlexCommand.java
@@ -0,0 +1,13 @@
+package me.totalfreedom.plex.command;
+
+import org.bukkit.command.CommandSender;
+
+import java.util.List;
+
+public interface IPlexCommand
+{
+
+ void execute(CommandSender sender, String[] args);
+ List onTabComplete(CommandSender sender, String[] args);
+
+}
diff --git a/src/main/java/me/totalfreedom/plex/command/PlexCommand.java b/src/main/java/me/totalfreedom/plex/command/PlexCommand.java
index 7ff8067..a5e320b 100644
--- a/src/main/java/me/totalfreedom/plex/command/PlexCommand.java
+++ b/src/main/java/me/totalfreedom/plex/command/PlexCommand.java
@@ -1,106 +1,157 @@
package me.totalfreedom.plex.command;
-import me.totalfreedom.plex.PlexBase;
+import com.google.common.collect.ImmutableList;
+import me.totalfreedom.plex.Plex;
+import me.totalfreedom.plex.cache.PlayerCache;
+import me.totalfreedom.plex.command.annotations.CommandParameters;
+import me.totalfreedom.plex.command.annotations.CommandPermissions;
+import me.totalfreedom.plex.command.source.RequiredCommandSource;
+import me.totalfreedom.plex.player.PlexPlayer;
import me.totalfreedom.plex.rank.enums.Rank;
-import org.bukkit.Bukkit;
import org.bukkit.command.*;
+import org.bukkit.entity.Player;
-import java.lang.reflect.Field;
import java.util.Arrays;
import java.util.List;
-import java.util.Objects;
-public abstract class PlexCommand extends PlexBase implements CommandExecutor, TabCompleter
+public abstract class PlexCommand extends Command implements TabExecutor, IPlexCommand
{
- private static final String COMMAND_PREFIX = "Command_";
- private static CommandMap COMMAND_MAP;
-
private final CommandParameters params;
private final CommandPermissions perms;
- private final String name;
- private final String description;
- private final String usage;
- private final List aliases;
+
private final Rank level;
- private final RequiredCommandSource source;
+ private final RequiredCommandSource commandSource;
- protected PlexCommand()
+ public PlexCommand(String name)
{
- this.params = this.getClass().getAnnotation(CommandParameters.class);
- this.perms = this.getClass().getAnnotation(CommandPermissions.class);
- this.name = this.getClass().getSimpleName().toLowerCase().replace(COMMAND_PREFIX.toLowerCase(), "");
- this.description = this.params.description();
- this.usage = this.params.usage();
- this.aliases = Arrays.asList(this.params.aliases().split(","));
- this.level = this.perms.level();
- this.source = this.perms.source();
- }
+ super(name);
+ this.params = getClass().getAnnotation(CommandParameters.class);
+ this.perms = getClass().getAnnotation(CommandPermissions.class);
- public void register()
- {
- PCommand command = new PCommand(this.name);
- command.setDescription(this.description);
- command.setUsage(this.usage);
- command.setAliases(this.aliases);
- this.getCommandMap().register("", command);
- command.setExecutor(this);
- }
-
- protected CommandMap getCommandMap()
- {
- if (COMMAND_MAP == null)
+ setName(name);
+ setLabel(name);
+ setDescription(params.description());
+ setUsage(params.usage());
+ if (params.aliases().split(",").length > 0)
{
- try
+ setAliases(Arrays.asList(params.aliases().split(",")));
+ }
+ this.level = perms.level();
+ this.commandSource = perms.source();
+
+ getMap().register("", this);
+ }
+
+
+ @Override
+ public boolean execute(CommandSender sender, 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)) return false;
+ if (commandSource == RequiredCommandSource.CONSOLE)
+ {
+ if (sender instanceof Player)
{
- final Field f = Bukkit.getServer().getClass().getDeclaredField("commandMap");
- f.setAccessible(true);
- COMMAND_MAP = (CommandMap) f.get(Bukkit.getServer());
- return getCommandMap();
+ //TODO: Enter console only msg
+ return true;
}
- catch (Exception e)
+ execute(sender, args);
+ return true;
+
+ } else if (commandSource == RequiredCommandSource.IN_GAME)
+ {
+ if (!(sender instanceof Player))
{
- e.printStackTrace();
+ //TODO: Enter player only msg
+ return true;
+ }
+
+ Player player = (Player) sender;
+ PlexPlayer plexPlayer = PlayerCache.getPlexPlayerMap().get(player.getUniqueId());
+ if (!plexPlayer.getRankFromString().isAtleast(getLevel()))
+ {
+ //TODO: Enter only and higher msg
+ return true;
+ }
+ execute(sender, args);
+ return true;
+ } else {
+ if (!(sender instanceof Player))
+ {
+ execute(sender, args);
+ return true;
+ } else {
+ Player player = (Player) sender;
+ PlexPlayer plexPlayer = PlayerCache.getPlexPlayerMap().get(player.getUniqueId());
+ if (!plexPlayer.getRankFromString().isAtleast(getLevel()))
+ {
+ //TODO: Enter only and higher msg
+ return true;
+ }
+ execute(sender, args);
+ return true;
}
}
- else
- return COMMAND_MAP;
- return getCommandMap();
}
- private static class PCommand extends Command
+
+ @Override
+ public List tabComplete(CommandSender sender, String alias, String[] args)
{
- private PlexCommand command = null;
-
- private PCommand(String name)
+ if (!matches(alias)) return ImmutableList.of();
+ if (sender instanceof Player)
{
- super(name);
- }
-
- public void setExecutor(PlexCommand command)
- {
- this.command = command;
- }
-
- @Override
- public boolean execute(CommandSender sender, String c, String[] args)
- {
- if (command == null)
- return false;
- return command.onCommand(sender, this, c, args);
- }
-
- @Override
- public List tabComplete(CommandSender sender, String alias, String[] args)
- {
- if (command == null)
- return null;
- return Objects.requireNonNull(command.onTabComplete(sender, this, alias, args));
+ Player player = (Player) sender;
+ PlexPlayer plexPlayer = PlayerCache.getPlexPlayerMap().get(player.getUniqueId());
+ if (plexPlayer.getRankFromString().isAtleast(getLevel()))
+ {
+ return onTabComplete(sender, args);
+ } else {
+ return ImmutableList.of();
+ }
+ } else {
+ return onTabComplete(sender, args);
}
}
@Override
- public boolean onCommand(CommandSender sender, Command cmd, String c, String[] args)
+ public List onTabComplete(CommandSender sender, Command cmd, String label, String[] args)
{
+ return tabComplete(sender, label, args);
+ }
+
+ private boolean matches(String label)
+ {
+ if (params.aliases().split(",").length > 0)
+ {
+ for (String alias : params.aliases().split(","))
+ {
+ if (alias.equalsIgnoreCase(label) || getName().equalsIgnoreCase(label))
+ {
+ return true;
+ }
+ }
+ } else if (params.aliases().split(",").length < 1)
+ {
+ return getName().equalsIgnoreCase(label);
+ }
return false;
}
+
+
+ public Rank getLevel()
+ {
+ return level;
+ }
+
+ public CommandMap getMap()
+ {
+ return Plex.get().getServer().getCommandMap();
+ }
}
diff --git a/src/main/java/me/totalfreedom/plex/command/CommandParameters.java b/src/main/java/me/totalfreedom/plex/command/annotations/CommandParameters.java
similarity index 84%
rename from src/main/java/me/totalfreedom/plex/command/CommandParameters.java
rename to src/main/java/me/totalfreedom/plex/command/annotations/CommandParameters.java
index 00d8a40..7b9545f 100644
--- a/src/main/java/me/totalfreedom/plex/command/CommandParameters.java
+++ b/src/main/java/me/totalfreedom/plex/command/annotations/CommandParameters.java
@@ -1,4 +1,4 @@
-package me.totalfreedom.plex.command;
+package me.totalfreedom.plex.command.annotations;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
diff --git a/src/main/java/me/totalfreedom/plex/command/CommandPermissions.java b/src/main/java/me/totalfreedom/plex/command/annotations/CommandPermissions.java
similarity index 70%
rename from src/main/java/me/totalfreedom/plex/command/CommandPermissions.java
rename to src/main/java/me/totalfreedom/plex/command/annotations/CommandPermissions.java
index 1b093e6..4f64503 100644
--- a/src/main/java/me/totalfreedom/plex/command/CommandPermissions.java
+++ b/src/main/java/me/totalfreedom/plex/command/annotations/CommandPermissions.java
@@ -1,5 +1,6 @@
-package me.totalfreedom.plex.command;
+package me.totalfreedom.plex.command.annotations;
+import me.totalfreedom.plex.command.source.RequiredCommandSource;
import me.totalfreedom.plex.rank.enums.Rank;
import java.lang.annotation.Retention;
diff --git a/src/main/java/me/totalfreedom/plex/command/impl/PlexCMD.java b/src/main/java/me/totalfreedom/plex/command/impl/PlexCMD.java
new file mode 100644
index 0000000..0a98ccb
--- /dev/null
+++ b/src/main/java/me/totalfreedom/plex/command/impl/PlexCMD.java
@@ -0,0 +1,31 @@
+package me.totalfreedom.plex.command.impl;
+
+import me.totalfreedom.plex.command.annotations.CommandParameters;
+import me.totalfreedom.plex.command.annotations.CommandPermissions;
+import me.totalfreedom.plex.command.PlexCommand;
+import me.totalfreedom.plex.command.source.RequiredCommandSource;
+import me.totalfreedom.plex.rank.enums.Rank;
+import org.bukkit.command.CommandSender;
+
+import java.util.Arrays;
+import java.util.List;
+
+@CommandPermissions(level = Rank.OP, source = RequiredCommandSource.ANY)
+@CommandParameters(usage = "/", aliases = "plexhelp", description = "Help with plex")
+public class PlexCMD extends PlexCommand
+{
+ public PlexCMD() {
+ super("plex");
+ }
+
+ @Override
+ public void execute(CommandSender sender, String[] args)
+ {
+ sender.sendMessage("HI");
+ }
+
+ @Override
+ public List onTabComplete(CommandSender sender, String[] args) {
+ return Arrays.asList("Telesphoreo", "super", "Taahh");
+ }
+}
diff --git a/src/main/java/me/totalfreedom/plex/command/impl/TestCMD.java b/src/main/java/me/totalfreedom/plex/command/impl/TestCMD.java
new file mode 100644
index 0000000..c800736
--- /dev/null
+++ b/src/main/java/me/totalfreedom/plex/command/impl/TestCMD.java
@@ -0,0 +1,36 @@
+package me.totalfreedom.plex.command.impl;
+
+import com.google.common.collect.ImmutableList;
+import me.totalfreedom.plex.command.annotations.CommandParameters;
+import me.totalfreedom.plex.command.annotations.CommandPermissions;
+import me.totalfreedom.plex.command.PlexCommand;
+import me.totalfreedom.plex.command.source.RequiredCommandSource;
+import me.totalfreedom.plex.rank.enums.Rank;
+import org.bukkit.command.CommandSender;
+
+import java.util.Arrays;
+import java.util.List;
+
+@CommandPermissions(level = Rank.OP, source = RequiredCommandSource.ANY)
+@CommandParameters(usage = "/", aliases = "tst,tast", description = "HELLO")
+public class TestCMD extends PlexCommand
+{
+ public TestCMD() {
+ super("test");
+ }
+
+ @Override
+ public void execute(CommandSender sender, String[] args) {
+ sender.sendMessage("HIIII BICH");
+ }
+
+ @Override
+ public List onTabComplete(CommandSender sender, String[] args) {
+ if (args.length == 1)
+ {
+ return Arrays.asList("WHATTHEFAWK", "LUL");
+ }
+ return ImmutableList.of();
+ }
+
+}
diff --git a/src/main/java/me/totalfreedom/plex/command/source/CommandSource.java b/src/main/java/me/totalfreedom/plex/command/source/CommandSource.java
new file mode 100644
index 0000000..8abcbf4
--- /dev/null
+++ b/src/main/java/me/totalfreedom/plex/command/source/CommandSource.java
@@ -0,0 +1,25 @@
+package me.totalfreedom.plex.command.source;
+
+import lombok.Getter;
+import me.totalfreedom.plex.cache.PlayerCache;
+import me.totalfreedom.plex.player.PlexPlayer;
+import org.bukkit.Bukkit;
+import org.bukkit.command.CommandSender;
+import org.bukkit.entity.Player;
+
+@Getter
+public class CommandSource
+{
+ private CommandSender sender;
+ private final Player player;
+ private final PlexPlayer plexPlayer;
+
+ public CommandSource(CommandSender sender)
+ {
+ this.sender = sender;
+ this.player = sender instanceof Player ? Bukkit.getPlayer(sender.getName()) : null;
+ this.plexPlayer = sender instanceof Player ? PlayerCache.getPlexPlayerMap().get(((Player)sender).getUniqueId()) : null;
+ }
+
+
+}
\ No newline at end of file
diff --git a/src/main/java/me/totalfreedom/plex/command/RequiredCommandSource.java b/src/main/java/me/totalfreedom/plex/command/source/RequiredCommandSource.java
similarity index 60%
rename from src/main/java/me/totalfreedom/plex/command/RequiredCommandSource.java
rename to src/main/java/me/totalfreedom/plex/command/source/RequiredCommandSource.java
index df9b23d..569fce9 100644
--- a/src/main/java/me/totalfreedom/plex/command/RequiredCommandSource.java
+++ b/src/main/java/me/totalfreedom/plex/command/source/RequiredCommandSource.java
@@ -1,4 +1,4 @@
-package me.totalfreedom.plex.command;
+package me.totalfreedom.plex.command.source;
public enum RequiredCommandSource
{
diff --git a/src/main/java/me/totalfreedom/plex/handlers/CommandHandler.java b/src/main/java/me/totalfreedom/plex/handlers/CommandHandler.java
new file mode 100644
index 0000000..b63ca27
--- /dev/null
+++ b/src/main/java/me/totalfreedom/plex/handlers/CommandHandler.java
@@ -0,0 +1,24 @@
+package me.totalfreedom.plex.handlers;
+
+import com.google.common.collect.Lists;
+import me.totalfreedom.plex.command.PlexCommand;
+import me.totalfreedom.plex.command.impl.PlexCMD;
+import me.totalfreedom.plex.command.impl.TestCMD;
+import me.totalfreedom.plex.util.PlexLog;
+
+import java.util.List;
+
+public class CommandHandler
+{
+
+ private List commands = Lists.newArrayList();
+
+ public CommandHandler()
+ {
+ commands.add(new TestCMD());
+ commands.add(new PlexCMD());
+
+ PlexLog.log(String.format("Registered %s commands!", commands.size()));
+ }
+
+}
diff --git a/src/main/java/me/totalfreedom/plex/handlers/ListenerHandler.java b/src/main/java/me/totalfreedom/plex/handlers/ListenerHandler.java
new file mode 100644
index 0000000..4994098
--- /dev/null
+++ b/src/main/java/me/totalfreedom/plex/handlers/ListenerHandler.java
@@ -0,0 +1,24 @@
+package me.totalfreedom.plex.handlers;
+
+import com.google.common.collect.Lists;
+import me.totalfreedom.plex.listener.PlexListener;
+import me.totalfreedom.plex.listener.impl.ChatListener;
+import me.totalfreedom.plex.listener.impl.PlayerListener;
+import me.totalfreedom.plex.util.PlexLog;
+
+import java.util.List;
+
+public class ListenerHandler
+{
+
+ private List listeners = Lists.newArrayList();
+
+ public ListenerHandler()
+ {
+ listeners.add(new ChatListener());
+ listeners.add(new PlayerListener());
+
+ PlexLog.log(String.format("Registered %s listeners!", listeners.size()));
+ }
+
+}
diff --git a/src/main/java/me/totalfreedom/plex/listener/PlexListener.java b/src/main/java/me/totalfreedom/plex/listener/PlexListener.java
new file mode 100644
index 0000000..b09ad6b
--- /dev/null
+++ b/src/main/java/me/totalfreedom/plex/listener/PlexListener.java
@@ -0,0 +1,14 @@
+package me.totalfreedom.plex.listener;
+
+import me.totalfreedom.plex.PlexBase;
+import org.bukkit.event.Listener;
+
+public abstract class PlexListener extends PlexBase implements Listener
+{
+
+ public PlexListener()
+ {
+ plugin.getServer().getPluginManager().registerEvents(this, plugin);
+ }
+
+}
diff --git a/src/main/java/me/totalfreedom/plex/listener/ChatListener.java b/src/main/java/me/totalfreedom/plex/listener/impl/ChatListener.java
similarity index 86%
rename from src/main/java/me/totalfreedom/plex/listener/ChatListener.java
rename to src/main/java/me/totalfreedom/plex/listener/impl/ChatListener.java
index 8447b22..20d908a 100644
--- a/src/main/java/me/totalfreedom/plex/listener/ChatListener.java
+++ b/src/main/java/me/totalfreedom/plex/listener/impl/ChatListener.java
@@ -1,14 +1,15 @@
-package me.totalfreedom.plex.listener;
+package me.totalfreedom.plex.listener.impl;
import me.totalfreedom.plex.Plex;
import me.totalfreedom.plex.cache.PlayerCache;
+import me.totalfreedom.plex.listener.PlexListener;
import me.totalfreedom.plex.player.PlexPlayer;
import net.md_5.bungee.api.ChatColor;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;
-public class ChatListener implements Listener
+public class ChatListener extends PlexListener
{
@EventHandler
diff --git a/src/main/java/me/totalfreedom/plex/listener/PlayerListener.java b/src/main/java/me/totalfreedom/plex/listener/impl/PlayerListener.java
similarity index 86%
rename from src/main/java/me/totalfreedom/plex/listener/PlayerListener.java
rename to src/main/java/me/totalfreedom/plex/listener/impl/PlayerListener.java
index aa7f8cd..1273c04 100644
--- a/src/main/java/me/totalfreedom/plex/listener/PlayerListener.java
+++ b/src/main/java/me/totalfreedom/plex/listener/impl/PlayerListener.java
@@ -1,10 +1,11 @@
-package me.totalfreedom.plex.listener;
+package me.totalfreedom.plex.listener.impl;
import java.util.Arrays;
import me.totalfreedom.plex.Plex;
import me.totalfreedom.plex.cache.MongoPlayerData;
import me.totalfreedom.plex.cache.PlayerCache;
import me.totalfreedom.plex.cache.SQLPlayerData;
+import me.totalfreedom.plex.listener.PlexListener;
import me.totalfreedom.plex.player.PlexPlayer;
import me.totalfreedom.plex.player.PunishedPlayer;
import me.totalfreedom.plex.util.PlexLog;
@@ -16,10 +17,10 @@ import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
-public class PlayerListener implements Listener
+public class PlayerListener extends PlexListener
{
- private final MongoPlayerData mongoPlayerData = Plex.get().getMongoPlayerData() != null ? Plex.get().getMongoPlayerData() : null;
- private final SQLPlayerData sqlPlayerData = Plex.get().getSqlPlayerData() != null ? Plex.get().getSqlPlayerData() : null;
+ private final MongoPlayerData mongoPlayerData = plugin.getMongoPlayerData() != null ? plugin.getMongoPlayerData() : null;
+ private final SQLPlayerData sqlPlayerData = plugin.getSqlPlayerData() != null ? plugin.getSqlPlayerData() : null;
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerSetup(PlayerJoinEvent event)
@@ -47,13 +48,13 @@ public class PlayerListener implements Listener
}
else if (sqlPlayerData != null)
{
- if (!sqlPlayerData.exists(player.getUniqueId())) //okay, we're saving with mongo! now check if the player's document exists
+ if (!sqlPlayerData.exists(player.getUniqueId())) //okay, we're saving with sql! now check if the player's document exists
{
PlexLog.log("AYO THIS MAN DONT EXIST"); // funi msg
plexPlayer = new PlexPlayer(player.getUniqueId()); //it doesn't! okay so now create the object
plexPlayer.setName(player.getName()); //set the name of the player
plexPlayer.setIps(Arrays.asList(player.getAddress().getAddress().getHostAddress().trim())); //set the arraylist of ips
- sqlPlayerData.insert(plexPlayer); //and put their document in mongo collection
+ sqlPlayerData.insert(plexPlayer); //and put their row into the sql table
}
else
{
@@ -67,7 +68,7 @@ public class PlayerListener implements Listener
assert plexPlayer != null;
- if (Plex.get().getRankManager().isAdmin(plexPlayer))
+ if (plugin.getRankManager().isAdmin(plexPlayer))
{
if (!plexPlayer.getLoginMSG().isEmpty())
{
@@ -88,7 +89,7 @@ public class PlayerListener implements Listener
{
mongoPlayerData.update(plexPlayer); //update the player's document
}
- else if (sqlPlayerData != null)
+ else if (sqlPlayerData != null) //sql checking
{
sqlPlayerData.update(plexPlayer);
}
diff --git a/src/main/java/me/totalfreedom/plex/player/PlexPlayer.java b/src/main/java/me/totalfreedom/plex/player/PlexPlayer.java
index cae059e..0f23062 100644
--- a/src/main/java/me/totalfreedom/plex/player/PlexPlayer.java
+++ b/src/main/java/me/totalfreedom/plex/player/PlexPlayer.java
@@ -11,6 +11,8 @@ import lombok.AccessLevel;
import lombok.Getter;
import lombok.Setter;
import me.totalfreedom.plex.rank.enums.Rank;
+import org.bukkit.Bukkit;
+import org.bukkit.OfflinePlayer;
@Getter
@Setter
@@ -59,6 +61,17 @@ public class PlexPlayer
public Rank getRankFromString()
{
- return Rank.valueOf(rank.toUpperCase());
+ OfflinePlayer player = Bukkit.getOfflinePlayer(UUID.fromString(uuid));
+ if (rank.isEmpty())
+ {
+ if (player.isOp())
+ {
+ return Rank.OP;
+ } else {
+ return Rank.NONOP;
+ }
+ } else {
+ return Rank.valueOf(rank.toUpperCase());
+ }
}
}
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index c839e8a..17982c6 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -2,8 +2,4 @@ name: ${project.name}
version: ${project.version}
author: Telesphoreo
main: me.totalfreedom.plex.Plex
-api-version: 1.16
-commands:
- plex:
- description: Test
- usage: /
\ No newline at end of file
+api-version: 1.16
\ No newline at end of file