mirror of
https://github.com/BGHDDevelopment/PlayerBalancer.git
synced 2024-11-23 11:15:30 +01:00
Removed the custom commands
This commit is contained in:
parent
3533077c9b
commit
d925ba4fea
@ -1,7 +1,9 @@
|
|||||||
package com.jaimemartz.playerbalancer;
|
package com.jaimemartz.playerbalancer;
|
||||||
|
|
||||||
import com.google.common.reflect.TypeToken;
|
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.connection.ServerAssignRegistry;
|
||||||
import com.jaimemartz.playerbalancer.helper.NetworkManager;
|
import com.jaimemartz.playerbalancer.helper.NetworkManager;
|
||||||
import com.jaimemartz.playerbalancer.helper.PasteHelper;
|
import com.jaimemartz.playerbalancer.helper.PasteHelper;
|
||||||
@ -24,7 +26,6 @@ import java.io.*;
|
|||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLConnection;
|
import java.net.URLConnection;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
import java.util.logging.Handler;
|
import java.util.logging.Handler;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.LogRecord;
|
import java.util.logging.LogRecord;
|
||||||
@ -179,28 +180,6 @@ public class PlayerBalancer extends Plugin {
|
|||||||
getProxy().getPluginManager().registerListener(this, kickListener);
|
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();
|
PasteHelper.reset();
|
||||||
getLogger().info("The plugin has finished loading without any problems");
|
getLogger().info("The plugin has finished loading without any problems");
|
||||||
} else {
|
} else {
|
||||||
@ -281,27 +260,6 @@ public class PlayerBalancer extends Plugin {
|
|||||||
manageCommand = null;
|
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) {
|
if (sectionManager != null) {
|
||||||
sectionManager.flush();
|
sectionManager.flush();
|
||||||
}
|
}
|
||||||
|
@ -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());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -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());
|
|
||||||
}
|
|
||||||
}
|
|
@ -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());
|
|
||||||
}
|
|
||||||
}
|
|
@ -23,15 +23,6 @@ public class FeaturesProps {
|
|||||||
@Setting(value = "server-refresh")
|
@Setting(value = "server-refresh")
|
||||||
private ServerRefreshProps serverRefreshProps;
|
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")
|
@Setting(value = "permission-router")
|
||||||
private PermissionRouterProps permissionRouterProps;
|
private PermissionRouterProps permissionRouterProps;
|
||||||
}
|
}
|
||||||
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
@ -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 {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -222,54 +222,8 @@ features {
|
|||||||
interval=5000
|
interval=5000
|
||||||
}
|
}
|
||||||
|
|
||||||
custom-find-command {
|
# Redirect players when connecting to a section in case they have a permission, useful for special lobbies
|
||||||
enabled=false
|
# Players will not get redirected if they are connected to a server where they were previously redirected to
|
||||||
|
|
||||||
# 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 <user>"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
permission-router {
|
permission-router {
|
||||||
enabled=false
|
enabled=false
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user