fixed config issues, fixed sending clickable to console, added reload
This commit is contained in:
parent
2841b3f924
commit
21cf4e1aee
|
|
@ -45,7 +45,7 @@ public class DiscordLink {
|
|||
@Subscribe
|
||||
public void onProxyInitialization(ProxyInitializeEvent event) {
|
||||
ALogger.init(logger);
|
||||
ReloadConfig();
|
||||
reloadConfig();
|
||||
try {
|
||||
DatabaseConnection.initialize();
|
||||
} catch (SQLException exception) {
|
||||
|
|
@ -57,7 +57,7 @@ public class DiscordLink {
|
|||
loadCommands();
|
||||
}
|
||||
|
||||
public void ReloadConfig() {
|
||||
public void reloadConfig() {
|
||||
Config.init();
|
||||
ALogger.info("Reloaded DiscordLink config.");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,11 +2,13 @@ package com.alttd.proxydiscordlink.commands;
|
|||
|
||||
import com.alttd.proxydiscordlink.commands.subcommands.CheckLinked;
|
||||
import com.alttd.proxydiscordlink.commands.subcommands.Link;
|
||||
import com.alttd.proxydiscordlink.commands.subcommands.Reload;
|
||||
import com.alttd.proxydiscordlink.commands.subcommands.Unlink;
|
||||
import com.alttd.proxydiscordlink.config.Config;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import com.velocitypowered.api.command.CommandSource;
|
||||
import com.velocitypowered.api.command.SimpleCommand;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.kyori.adventure.text.minimessage.Template;
|
||||
|
|
@ -21,7 +23,7 @@ public class DiscordCommand implements SimpleCommand {
|
|||
private final MiniMessage miniMessage;
|
||||
|
||||
public DiscordCommand() {
|
||||
subCommands = Arrays.asList(new CheckLinked(), new Link(), new Unlink());
|
||||
subCommands = Arrays.asList(new CheckLinked(), new Link(), new Unlink(), new Reload());
|
||||
miniMessage = MiniMessage.get();
|
||||
}
|
||||
|
||||
|
|
@ -33,8 +35,10 @@ public class DiscordCommand implements SimpleCommand {
|
|||
if (args.length < 1) {
|
||||
if (!source.hasPermission("discordlink.link"))
|
||||
source.sendMessage(miniMessage.parse(Config.NO_PERMISSION));
|
||||
else
|
||||
else if (source instanceof Player)
|
||||
source.sendMessage(miniMessage.parse(Config.DISCORD_LINK));
|
||||
else
|
||||
source.sendMessage(miniMessage.parse(Config.NO_CONSOLE));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ public class Link implements SubCommand {
|
|||
@Override
|
||||
public void execute(String[] args, CommandSource source) {
|
||||
if (!(source instanceof Player player)) {
|
||||
source.sendMessage(miniMessage.parse(Config.CONSOLE));
|
||||
source.sendMessage(miniMessage.parse(Config.NO_CONSOLE));
|
||||
return;
|
||||
}
|
||||
if (!player.hasPermission(getPermission())) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,48 @@
|
|||
package com.alttd.proxydiscordlink.commands.subcommands;
|
||||
|
||||
import com.alttd.proxydiscordlink.DiscordLink;
|
||||
import com.alttd.proxydiscordlink.commands.SubCommand;
|
||||
import com.alttd.proxydiscordlink.config.Config;
|
||||
import com.velocitypowered.api.command.CommandSource;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Reload implements SubCommand {
|
||||
|
||||
private final String name;
|
||||
private final String permission;
|
||||
private final MiniMessage miniMessage;
|
||||
|
||||
public Reload() {
|
||||
name = "reload";
|
||||
permission = "discordlink.reload";
|
||||
miniMessage = MiniMessage.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermission() {
|
||||
return permission;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(String[] args, CommandSource source) {
|
||||
DiscordLink.getPlugin().reloadConfig();
|
||||
source.sendMessage(miniMessage.parse(Config.RELOAD_CONFIG));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> suggest(String[] args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelpMessage() {
|
||||
return Config.HELP_RELOAD;
|
||||
}
|
||||
}
|
||||
|
|
@ -35,7 +35,7 @@ public class Unlink implements SubCommand {
|
|||
@Override
|
||||
public void execute(String[] args, CommandSource source) {
|
||||
if (!(source instanceof Player player)) {
|
||||
source.sendMessage(miniMessage.parse(Config.CONSOLE));
|
||||
source.sendMessage(miniMessage.parse(Config.NO_CONSOLE));
|
||||
return;
|
||||
}
|
||||
if (!player.hasPermission(getPermission())) {
|
||||
|
|
|
|||
|
|
@ -195,14 +195,17 @@ public final class Config {
|
|||
public static String IS_LINKED = "<yellow><player> is <linked_status>.</yellow>";
|
||||
public static String INVALID_PLAYER = "<red><player> is not online or is not a valid player.</red>";
|
||||
public static String NO_PERMISSION = "<red>You do not have permission to do that.</red>";
|
||||
public static String CONSOLE = "<red>This command can not be executed from console.</red>";
|
||||
public static String NO_CONSOLE = "<red>This command can not be executed from console.</red>";
|
||||
public static String RELOAD_CONFIG = "<green>Reloaded DiscordLink config.</green>";
|
||||
public static String HELP_MESSAGE = "<yellow>DiscordLink commands:\n<commands></yellow>";
|
||||
public static String HELP_LINK = "<yellow><gold>/discord link</gold>: Get a code which can be used to link your Minecraft and Discord accounts.</yellow>";
|
||||
public static String HELP_UNLINK = "<yellow><gold>/discord unlink</gold>: Unlink your Minecraft and Discord accounts.</yellow>";
|
||||
public static String HELP_CHECK_LINKED = "<yellow><gold>/discord checklinked <user></gold>: Check if the specified user has their Minecraft and Discord accounts linked.</yellow>";
|
||||
public static String HELP_RELOAD = "<yellow><gold>/discord reload</gold>: Reload the config.</yellow>";
|
||||
|
||||
private static void loadMessages() {
|
||||
DISCORD_MESSAGE = getList("messages.discord-message", DISCORD_MESSAGE);
|
||||
DISCORD_LINK = getString("messages.discord-link", DISCORD_LINK);
|
||||
GIVE_CODE = getString("messages.give-code", GIVE_CODE);
|
||||
ALREADY_LINKED_ACCOUNTS = getString("messages.already-linked-accounts", ALREADY_LINKED_ACCOUNTS);
|
||||
ALREADY_GOT_CODE = getString("messages.already-got-code", ALREADY_GOT_CODE);
|
||||
|
|
@ -211,10 +214,12 @@ public final class Config {
|
|||
IS_LINKED = getString("messages.is-linked", IS_LINKED);
|
||||
INVALID_PLAYER = getString("messages.invalid-player", INVALID_PLAYER);
|
||||
NO_PERMISSION = getString("messages.no-permission", NO_PERMISSION);
|
||||
CONSOLE = getString("messages.console", CONSOLE);
|
||||
HELP_MESSAGE = getString("message.help-message", HELP_MESSAGE);
|
||||
HELP_LINK = getString("message.help-link", HELP_LINK);
|
||||
HELP_UNLINK = getString("message.help-unlink", HELP_UNLINK);
|
||||
HELP_CHECK_LINKED = getString("message.help-check-linked", HELP_CHECK_LINKED);
|
||||
NO_CONSOLE = getString("messages.no-console", NO_CONSOLE);
|
||||
RELOAD_CONFIG = getString("messages.reload-config", RELOAD_CONFIG);
|
||||
HELP_MESSAGE = getString("messages.help-message", HELP_MESSAGE);
|
||||
HELP_LINK = getString("messages.help-link", HELP_LINK);
|
||||
HELP_UNLINK = getString("messages.help-unlink", HELP_UNLINK);
|
||||
HELP_CHECK_LINKED = getString("messages.help-check-linked", HELP_CHECK_LINKED);
|
||||
HELP_RELOAD = getString("messages.help-reload", HELP_RELOAD);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user