Stop Ingame-Access from disallowing console access

This commit is contained in:
ME1312 2019-04-01 22:13:43 -04:00
parent 935a59bb34
commit 463861744c
No known key found for this signature in database
GPG Key ID: FEFFE2F698E88FA8
4 changed files with 11 additions and 12 deletions

View File

@ -40,6 +40,8 @@ public final class SubCommand implements CommandExecutor {
} else if (plugin.lang == null) {
new IllegalStateException("There are no lang options available at this time").printStackTrace();
if (!(sender instanceof ConsoleCommandSender)) sender.sendMessage(ChatColor.RED + "An exception has occurred while running this command");
} else if (!(sender instanceof ConsoleCommandSender || plugin.config.get().getSection("Settings").getBoolean("Ingame-Access", true))) {
sender.sendMessage(plugin.api.getLang("SubServers", "Command.Generic.Invalid-Permission").replace("$str$", "subservers.command"));
} else {
if (sender.hasPermission("subservers.command")) {
if (args.length > 0) {

View File

@ -77,13 +77,11 @@ public final class SubPlugin extends JavaPlugin {
reload(false);
if (config.get().getSection("Settings").getBoolean("Ingame-Access", true)) {
gui = new DefaultUIHandler(this);
SubCommand cmd = new SubCommand(this);
getCommand("subservers").setExecutor(cmd);
getCommand("subserver").setExecutor(cmd);
getCommand("sub").setExecutor(cmd);
}
gui = new DefaultUIHandler(this);
SubCommand cmd = new SubCommand(this);
getCommand("subservers").setExecutor(cmd);
getCommand("subserver").setExecutor(cmd);
getCommand("sub").setExecutor(cmd);
new Metrics(this);
Bukkit.getScheduler().runTaskTimerAsynchronously(this, () -> {

View File

@ -17,6 +17,7 @@ import org.spongepowered.api.command.CommandResult;
import org.spongepowered.api.command.CommandSource;
import org.spongepowered.api.command.args.CommandContext;
import org.spongepowered.api.command.args.GenericArguments;
import org.spongepowered.api.command.source.ConsoleSource;
import org.spongepowered.api.command.spec.CommandExecutor;
import org.spongepowered.api.command.spec.CommandSpec;
import org.spongepowered.api.entity.living.player.Player;
@ -115,7 +116,7 @@ public final class SubCommand implements CommandExecutor {
} else if (plugin.lang == null) {
throw new CommandException(Text.builder("An exception has occurred while running this command").color(TextColors.RED).build(), new IllegalStateException("There are no lang options available at this time"), false);
} else {
return sender.hasPermission("subservers.command");
return (sender instanceof ConsoleSource || plugin.config.get().getSection("Settings").getBoolean("Ingame-Access", true)) && sender.hasPermission("subservers.command");
}
}

View File

@ -102,10 +102,8 @@ public final class SubPlugin {
reload(false);
if (config.get().getSection("Settings").getBoolean("Ingame-Access", true)) {
//gui = new InternalUIHandler(this);
Sponge.getCommandManager().register(plugin, new SubCommand(this).spec(), "sub", "subserver", "subservers");
}
//gui = new InternalUIHandler(this);
Sponge.getCommandManager().register(plugin, new SubCommand(this).spec(), "sub", "subserver", "subservers");
new Metrics(this);
game.getScheduler().createTaskBuilder().async().execute(() -> {