Fix migration log being sent to the console twice

This commit is contained in:
Luck
2017-01-31 12:29:06 +00:00
Unverified
parent 0be6d658ed
commit 8dbb083b90
11 changed files with 39 additions and 10 deletions
@@ -180,7 +180,9 @@ public class MigrationBPermissions extends SubCommand<Object> {
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Object o, List<String> args, String label) throws CommandException {
Consumer<String> log = s -> {
Message.MIGRATION_LOG.send(sender, s);
Message.MIGRATION_LOG.send(plugin.getConsoleSender(), s);
if (!sender.isConsole()) {
Message.MIGRATION_LOG.send(plugin.getConsoleSender(), s);
}
};
log.accept("Starting bPermissions migration.");
@@ -64,7 +64,9 @@ public class MigrationGroupManager extends SubCommand<Object> {
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Object o, List<String> args, String label) throws CommandException {
Consumer<String> log = s -> {
Message.MIGRATION_LOG.send(sender, s);
Message.MIGRATION_LOG.send(plugin.getConsoleSender(), s);
if (!sender.isConsole()) {
Message.MIGRATION_LOG.send(plugin.getConsoleSender(), s);
}
};
log.accept("Starting GroupManager migration.");
@@ -65,7 +65,9 @@ public class MigrationPermissionsEx extends SubCommand<Object> {
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Object o, List<String> args, String label) throws CommandException {
Consumer<String> log = s -> {
Message.MIGRATION_LOG.send(sender, s);
Message.MIGRATION_LOG.send(plugin.getConsoleSender(), s);
if (!sender.isConsole()) {
Message.MIGRATION_LOG.send(plugin.getConsoleSender(), s);
}
};
log.accept("Starting PermissionsEx migration.");
@@ -200,7 +200,9 @@ public class MigrationPowerfulPerms extends SubCommand<Object> {
private CommandResult run(LuckPermsPlugin plugin, Sender sender, List<String> args) {
Consumer<String> log = s -> {
Message.MIGRATION_LOG.send(sender, s);
Message.MIGRATION_LOG.send(plugin.getConsoleSender(), s);
if (!sender.isConsole()) {
Message.MIGRATION_LOG.send(plugin.getConsoleSender(), s);
}
};
log.accept("Starting PowerfulPerms migration.");
@@ -60,7 +60,9 @@ public class MigrationZPermissions extends SubCommand<Object> {
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Object o, List<String> args, String label) throws CommandException {
Consumer<String> log = s -> {
Message.MIGRATION_LOG.send(sender, s);
Message.MIGRATION_LOG.send(plugin.getConsoleSender(), s);
if (!sender.isConsole()) {
Message.MIGRATION_LOG.send(plugin.getConsoleSender(), s);
}
};
log.accept("Starting zPermissions migration.");
@@ -57,7 +57,9 @@ public class MigrationBungeePerms extends SubCommand<Object> {
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Object o, List<String> args, String label) throws CommandException {
Consumer<String> log = s -> {
Message.MIGRATION_LOG.send(sender, s);
Message.MIGRATION_LOG.send(plugin.getConsoleSender(), s);
if (!sender.isConsole()) {
Message.MIGRATION_LOG.send(plugin.getConsoleSender(), s);
}
};
log.accept("Starting BungeePerms migration.");
@@ -110,7 +110,12 @@ public class ExportCommand extends SingleCommand {
@Override
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, List<String> args, String label) {
Consumer<String> log = s -> Message.EXPORT_LOG.send(sender, s);
Consumer<String> log = s -> {
Message.EXPORT_LOG.send(sender, s);
if (!sender.isConsole()) {
Message.EXPORT_LOG.send(plugin.getConsoleSender(), s);
}
};
File f = new File(plugin.getDataDirectory(), args.get(0));
if (f.exists()) {
@@ -86,7 +86,8 @@ public class AbstractSender<T> implements Sender {
return false;
}
private boolean isConsole() {
@Override
public boolean isConsole() {
return this.uuid.equals(Constants.CONSOLE_UUID) || this.uuid.equals(Constants.IMPORT_UUID);
}
@@ -78,4 +78,11 @@ public interface Sender {
*/
boolean hasPermission(Permission permission);
/**
* Gets whether this sender is the console
*
* @return if the sender is the console
*/
boolean isConsole();
}
@@ -57,7 +57,9 @@ public class MigrationPermissionManager extends SubCommand<Object> {
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Object o, List<String> args, String label) throws CommandException {
Consumer<String> log = s -> {
Message.MIGRATION_LOG.send(sender, s);
Message.MIGRATION_LOG.send(plugin.getConsoleSender(), s);
if (!sender.isConsole()) {
Message.MIGRATION_LOG.send(plugin.getConsoleSender(), s);
}
};
log.accept("Starting PermissionManager migration.");
@@ -64,7 +64,9 @@ public class MigrationPermissionsEx extends SubCommand<Object> {
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, Object o, List<String> args, String label) throws CommandException {
Consumer<String> log = s -> {
Message.MIGRATION_LOG.send(sender, s);
Message.MIGRATION_LOG.send(plugin.getConsoleSender(), s);
if (!sender.isConsole()) {
Message.MIGRATION_LOG.send(plugin.getConsoleSender(), s);
}
};
log.accept("Starting PermissionsEx migration.");