diff --git a/Main Plugin/src/main/java/com/jaimemartz/playerbalancer/PlayerBalancer.java b/Main Plugin/src/main/java/com/jaimemartz/playerbalancer/PlayerBalancer.java index c479b1b..3297d72 100644 --- a/Main Plugin/src/main/java/com/jaimemartz/playerbalancer/PlayerBalancer.java +++ b/Main Plugin/src/main/java/com/jaimemartz/playerbalancer/PlayerBalancer.java @@ -1,7 +1,9 @@ package com.jaimemartz.playerbalancer; import com.google.common.reflect.TypeToken; -import com.jaimemartz.playerbalancer.commands.*; +import com.jaimemartz.playerbalancer.commands.FallbackCommand; +import com.jaimemartz.playerbalancer.commands.MainCommand; +import com.jaimemartz.playerbalancer.commands.ManageCommand; import com.jaimemartz.playerbalancer.connection.ServerAssignRegistry; import com.jaimemartz.playerbalancer.helper.NetworkManager; import com.jaimemartz.playerbalancer.helper.PasteHelper; @@ -24,7 +26,6 @@ import java.io.*; import java.net.URL; import java.net.URLConnection; import java.nio.file.Files; -import java.util.concurrent.TimeUnit; import java.util.logging.Handler; import java.util.logging.Level; import java.util.logging.LogRecord; @@ -179,28 +180,6 @@ public class PlayerBalancer extends Plugin { getProxy().getPluginManager().registerListener(this, kickListener); } - //After the modules have loaded (hopefully?) - getProxy().getScheduler().schedule(this, () -> { - if (settings.getFeaturesProps().getCustomFindCommandProps().isEnabled()) { - tryUnregisterCommands("cmd_find"); - findCommand = new CustomFindCommand(this); - getProxy().getPluginManager().registerCommand(this, findCommand); - } - - if (settings.getFeaturesProps().getCustomListCommandProps().isEnabled()) { - tryUnregisterCommands("cmd_list"); - listCommand = new CustomListCommand(this); - getProxy().getPluginManager().registerCommand(this, listCommand); - } - - if (settings.getFeaturesProps().getCustomServerCommandProps().isEnabled()) { - tryUnregisterCommands("cmd_server"); - serverCommand = new CustomServerCommand(this); - getProxy().getPluginManager().registerCommand(this, serverCommand); - } - - }, 5L, TimeUnit.SECONDS); - PasteHelper.reset(); getLogger().info("The plugin has finished loading without any problems"); } else { @@ -281,27 +260,6 @@ public class PlayerBalancer extends Plugin { manageCommand = null; } - if (settings.getFeaturesProps().getCustomFindCommandProps().isEnabled()) { - if (findCommand != null) { - getProxy().getPluginManager().unregisterCommand(findCommand); - findCommand = null; - } - } - - if (settings.getFeaturesProps().getCustomListCommandProps().isEnabled()) { - if (listCommand != null) { - getProxy().getPluginManager().unregisterCommand(listCommand); - listCommand = null; - } - } - - if (settings.getFeaturesProps().getCustomServerCommandProps().isEnabled()) { - if (serverCommand != null) { - getProxy().getPluginManager().unregisterCommand(serverCommand); - serverCommand = null; - } - } - if (sectionManager != null) { sectionManager.flush(); } diff --git a/Main Plugin/src/main/java/com/jaimemartz/playerbalancer/commands/CustomFindCommand.java b/Main Plugin/src/main/java/com/jaimemartz/playerbalancer/commands/CustomFindCommand.java deleted file mode 100644 index ed6868d..0000000 --- a/Main Plugin/src/main/java/com/jaimemartz/playerbalancer/commands/CustomFindCommand.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.jaimemartz.playerbalancer.commands; - -import com.jaimemartz.playerbalancer.PlayerBalancer; -import com.jaimemartz.playerbalancer.settings.props.features.CustomFindCommandProps; -import com.jaimemartz.playerbalancer.utils.MessageUtils; -import net.md_5.bungee.api.CommandSender; -import net.md_5.bungee.api.connection.ProxiedPlayer; -import net.md_5.bungee.api.plugin.Command; - -public class CustomFindCommand extends Command { - private final PlayerBalancer plugin; - private final CustomFindCommandProps props; - - public CustomFindCommand(PlayerBalancer plugin) { - this(plugin, plugin.getSettings().getFeaturesProps().getCustomFindCommandProps()); - } - - private CustomFindCommand(PlayerBalancer plugin, CustomFindCommandProps props) { - super( - props.getCommand().getName(), - props.getCommand().getPermission(), - props.getCommand().getAliasesArray() - ); - - this.plugin = plugin; - this.props = props; - } - - @Override - public void execute(CommandSender sender, String[] args) { - if (args.length == 1) { - ProxiedPlayer player = plugin.getProxy().getPlayer(args[0]); - - if (player != null && player.getServer() != null) { - MessageUtils.send(player, props.getFormats().getResult(), (str) -> - str.replace("{server}", player.getServer().getInfo().getName()) - .replace("{name}", player.getName()) - ); - } else { - MessageUtils.send(player, props.getFormats().getMissing(), (str) -> - str.replace("{name}", player.getName()) - ); - } - } else { - MessageUtils.send(sender, props.getFormats().getUsage()); - } - } -} diff --git a/Main Plugin/src/main/java/com/jaimemartz/playerbalancer/commands/CustomListCommand.java b/Main Plugin/src/main/java/com/jaimemartz/playerbalancer/commands/CustomListCommand.java deleted file mode 100644 index 7fc301b..0000000 --- a/Main Plugin/src/main/java/com/jaimemartz/playerbalancer/commands/CustomListCommand.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.jaimemartz.playerbalancer.commands; - -import com.jaimemartz.playerbalancer.PlayerBalancer; -import com.jaimemartz.playerbalancer.settings.props.features.CustomListCommandProps; -import net.md_5.bungee.api.ChatColor; -import net.md_5.bungee.api.CommandSender; -import net.md_5.bungee.api.chat.ComponentBuilder; -import net.md_5.bungee.api.plugin.Command; - -public class CustomListCommand extends Command { - private final PlayerBalancer plugin; - private final CustomListCommandProps props; - - public CustomListCommand(PlayerBalancer plugin) { - this(plugin, plugin.getSettings().getFeaturesProps().getCustomListCommandProps()); - } - - private CustomListCommand(PlayerBalancer plugin, CustomListCommandProps props) { - super( - props.getCommand().getName(), - props.getCommand().getPermission(), - props.getCommand().getAliasesArray() - ); - - this.plugin = plugin; - this.props = props; - } - - @Override - public void execute(CommandSender sender, String[] args) { - sender.sendMessage(new ComponentBuilder("Not implemented yet.").color(ChatColor.RED).create()); - } -} diff --git a/Main Plugin/src/main/java/com/jaimemartz/playerbalancer/commands/CustomServerCommand.java b/Main Plugin/src/main/java/com/jaimemartz/playerbalancer/commands/CustomServerCommand.java deleted file mode 100644 index 782486b..0000000 --- a/Main Plugin/src/main/java/com/jaimemartz/playerbalancer/commands/CustomServerCommand.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.jaimemartz.playerbalancer.commands; - -import com.jaimemartz.playerbalancer.PlayerBalancer; -import com.jaimemartz.playerbalancer.settings.props.features.CustomServerCommandProps; -import net.md_5.bungee.api.ChatColor; -import net.md_5.bungee.api.CommandSender; -import net.md_5.bungee.api.chat.ComponentBuilder; -import net.md_5.bungee.api.plugin.Command; - -public class CustomServerCommand extends Command { - private final PlayerBalancer plugin; - private final CustomServerCommandProps props; - - public CustomServerCommand(PlayerBalancer plugin) { - this(plugin, plugin.getSettings().getFeaturesProps().getCustomServerCommandProps()); - } - - private CustomServerCommand(PlayerBalancer plugin, CustomServerCommandProps props) { - super( - props.getCommand().getName(), - props.getCommand().getPermission(), - props.getCommand().getAliasesArray() - ); - - this.plugin = plugin; - this.props = props; - } - - @Override - public void execute(CommandSender sender, String[] args) { - sender.sendMessage(new ComponentBuilder("Not implemented yet.").color(ChatColor.RED).create()); - } -} diff --git a/Main Plugin/src/main/java/com/jaimemartz/playerbalancer/settings/props/FeaturesProps.java b/Main Plugin/src/main/java/com/jaimemartz/playerbalancer/settings/props/FeaturesProps.java index 3a54d93..167aaee 100644 --- a/Main Plugin/src/main/java/com/jaimemartz/playerbalancer/settings/props/FeaturesProps.java +++ b/Main Plugin/src/main/java/com/jaimemartz/playerbalancer/settings/props/FeaturesProps.java @@ -23,15 +23,6 @@ public class FeaturesProps { @Setting(value = "server-refresh") private ServerRefreshProps serverRefreshProps; - @Setting(value = "custom-find-command") - private CustomFindCommandProps customFindCommandProps; - - @Setting(value = "custom-list-command") - private CustomListCommandProps customListCommandProps; - - @Setting(value = "custom-server-command") - private CustomServerCommandProps customServerCommandProps; - @Setting(value = "permission-router") private PermissionRouterProps permissionRouterProps; } diff --git a/Main Plugin/src/main/java/com/jaimemartz/playerbalancer/settings/props/features/CustomFindCommandProps.java b/Main Plugin/src/main/java/com/jaimemartz/playerbalancer/settings/props/features/CustomFindCommandProps.java deleted file mode 100644 index 7fc598b..0000000 --- a/Main Plugin/src/main/java/com/jaimemartz/playerbalancer/settings/props/features/CustomFindCommandProps.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.jaimemartz.playerbalancer.settings.props.features; - -import com.jaimemartz.playerbalancer.settings.props.shared.CommandProps; -import lombok.Data; -import ninja.leaping.configurate.objectmapping.Setting; -import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable; - -@ConfigSerializable -@Data -public class CustomFindCommandProps { - @Setting - private boolean enabled; - - @Setting - private CommandProps command; - - @Setting - private Formats formats; - - @ConfigSerializable - @Data - public static class Formats { - @Setting - private String result; - - @Setting - private String missing; - - @Setting - private String usage; - } -} diff --git a/Main Plugin/src/main/java/com/jaimemartz/playerbalancer/settings/props/features/CustomListCommandProps.java b/Main Plugin/src/main/java/com/jaimemartz/playerbalancer/settings/props/features/CustomListCommandProps.java deleted file mode 100644 index a0c6eb9..0000000 --- a/Main Plugin/src/main/java/com/jaimemartz/playerbalancer/settings/props/features/CustomListCommandProps.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.jaimemartz.playerbalancer.settings.props.features; - -import com.jaimemartz.playerbalancer.settings.props.shared.CommandProps; -import lombok.Data; -import ninja.leaping.configurate.objectmapping.Setting; -import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable; - -@ConfigSerializable -@Data -public class CustomListCommandProps { - @Setting - private boolean enabled; - - @Setting - private CommandProps command; - - @Setting - private Formats formats; - - @ConfigSerializable - @Data - private static class Formats { - @Setting - private String server; - - @Setting - private String total; - } -} diff --git a/Main Plugin/src/main/java/com/jaimemartz/playerbalancer/settings/props/features/CustomServerCommandProps.java b/Main Plugin/src/main/java/com/jaimemartz/playerbalancer/settings/props/features/CustomServerCommandProps.java deleted file mode 100644 index 2935d17..0000000 --- a/Main Plugin/src/main/java/com/jaimemartz/playerbalancer/settings/props/features/CustomServerCommandProps.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.jaimemartz.playerbalancer.settings.props.features; - -import com.jaimemartz.playerbalancer.settings.props.shared.CommandProps; -import lombok.Data; -import ninja.leaping.configurate.objectmapping.Setting; -import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable; - -@ConfigSerializable -@Data -public class CustomServerCommandProps { - @Setting - private boolean enabled; - - @Setting - private CommandProps command; - - @Setting - private Formats formats; - - @ConfigSerializable - @Data - private static class Formats { - - } -} diff --git a/Main Plugin/src/main/resources/default.conf b/Main Plugin/src/main/resources/default.conf index 3babc3e..7fb683f 100644 --- a/Main Plugin/src/main/resources/default.conf +++ b/Main Plugin/src/main/resources/default.conf @@ -222,54 +222,8 @@ features { interval=5000 } - custom-find-command { - enabled=false - - # Leave permission empty for no permission - command { - name=find - permission="" - aliases=[] - } - - formats { - result="&a{name} &cis online at &a{server}" - missing="&cThere is no such player named {name}" - usage="&cUsage: /find " - } - } - - custom-list-command { - enabled=false - - # Leave permission empty for no permission - command { - name=glist - permission="" - aliases=[] - } - - formats { - server = "" - total = "" - } - } - - custom-server-command { - enabled=false - - # Leave permission empty for no permission - command { - name=server - permission="" - aliases=[] - } - - formats { - # Nothing yet - } - } - + # Redirect players when connecting to a section in case they have a permission, useful for special lobbies + # Players will not get redirected if they are connected to a server where they were previously redirected to permission-router { enabled=false