Statics.LOGGER.sendInfo is now used everywhere instead of source.sendFeedback
This commit is contained in:
parent
dd23524d98
commit
2230f28e97
@ -22,6 +22,7 @@ import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import net.minecraft.server.command.CommandManager;
|
||||
import net.minecraft.server.command.ServerCommandSource;
|
||||
import net.minecraft.text.LiteralText;
|
||||
import net.szum123321.textile_backup.Statics;
|
||||
import net.szum123321.textile_backup.core.create.BackupHelper;
|
||||
import net.szum123321.textile_backup.core.Utilities;
|
||||
|
||||
@ -32,9 +33,11 @@ public class CleanupCommand {
|
||||
}
|
||||
|
||||
private static int execute(ServerCommandSource source) {
|
||||
int a = BackupHelper.executeFileLimit(source, Utilities.getLevelName(source.getMinecraftServer()));
|
||||
|
||||
source.sendFeedback(new LiteralText("Deleted: " + a + " files."), false);
|
||||
Statics.LOGGER.sendInfo(
|
||||
source,
|
||||
"Deleted: {} files.",
|
||||
BackupHelper.executeFileLimit(source, Utilities.getLevelName(source.getMinecraftServer()))
|
||||
);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -8,8 +8,6 @@ import net.minecraft.command.arguments.EntityArgumentType;
|
||||
import net.minecraft.server.command.CommandManager;
|
||||
import net.minecraft.server.command.ServerCommandSource;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.text.LiteralText;
|
||||
import net.minecraft.text.TranslatableText;
|
||||
import net.szum123321.textile_backup.Statics;
|
||||
|
||||
public class BlacklistCommand {
|
||||
@ -29,7 +27,7 @@ public class BlacklistCommand {
|
||||
}
|
||||
|
||||
private static int help(ServerCommandSource source) {
|
||||
source.sendFeedback(new LiteralText("Available command are: add [player], remove [player], list."), false);
|
||||
Statics.LOGGER.sendInfo(source, "Available command are: add [player], remove [player], list.");
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -44,7 +42,7 @@ public class BlacklistCommand {
|
||||
builder.append(", ");
|
||||
}
|
||||
|
||||
source.sendFeedback(new LiteralText(builder.toString()), false);
|
||||
Statics.LOGGER.sendInfo(source, builder.toString());
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -53,8 +51,8 @@ public class BlacklistCommand {
|
||||
ServerPlayerEntity player = EntityArgumentType.getPlayer(ctx, "player");
|
||||
|
||||
if(Statics.CONFIG.playerBlacklist.contains(player.getEntityName())) {
|
||||
ctx.getSource().sendFeedback(new TranslatableText("Player: %s is already blacklisted.", player.getEntityName()), false);
|
||||
}else{
|
||||
Statics.LOGGER.sendInfo(ctx.getSource(), "Player: {} is already blacklisted.", player.getEntityName());
|
||||
} else {
|
||||
Statics.CONFIG.playerBlacklist.add(player.getEntityName());
|
||||
ConfigManager.saveConfig(Statics.CONFIG);
|
||||
|
||||
@ -83,20 +81,14 @@ public class BlacklistCommand {
|
||||
ServerPlayerEntity player = EntityArgumentType.getPlayer(ctx, "player");
|
||||
|
||||
if(!Statics.CONFIG.playerBlacklist.contains(player.getEntityName())) {
|
||||
ctx.getSource().sendFeedback(new TranslatableText("Player: %s newer was blacklisted.", player.getEntityName()), false);
|
||||
}else{
|
||||
Statics.LOGGER.sendInfo(ctx.getSource(), "Player: {} newer was blacklisted.", player.getEntityName());
|
||||
} else {
|
||||
Statics.CONFIG.playerBlacklist.remove(player.getEntityName());
|
||||
ConfigManager.saveConfig(Statics.CONFIG);
|
||||
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
builder.append("Player: ");
|
||||
builder.append(player.getEntityName());
|
||||
builder.append(" removed from the blacklist successfully.");
|
||||
|
||||
ctx.getSource().getMinecraftServer().getCommandManager().sendCommandTree(player);
|
||||
|
||||
Statics.LOGGER.sendInfo(ctx.getSource(), builder.toString());
|
||||
Statics.LOGGER.sendInfo(ctx.getSource(), "Player: {} removed from the blacklist successfully.", player.getEntityName());
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
@ -29,7 +29,7 @@ public class WhitelistCommand {
|
||||
}
|
||||
|
||||
private static int help(ServerCommandSource source){
|
||||
source.sendFeedback(new LiteralText("Available command are: add [player], remove [player], list."), false);
|
||||
Statics.LOGGER.sendInfo(source, "Available command are: add [player], remove [player], list.");
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -44,7 +44,7 @@ public class WhitelistCommand {
|
||||
builder.append(", ");
|
||||
}
|
||||
|
||||
source.sendFeedback(new LiteralText(builder.toString()), false);
|
||||
Statics.LOGGER.sendInfo(source, builder.toString());
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -53,8 +53,8 @@ public class WhitelistCommand {
|
||||
ServerPlayerEntity player = EntityArgumentType.getPlayer(ctx, "player");
|
||||
|
||||
if(Statics.CONFIG.playerWhitelist.contains(player.getEntityName())) {
|
||||
ctx.getSource().sendFeedback(new TranslatableText("Player: %s is already whitelisted.", player.getEntityName()), false);
|
||||
}else{
|
||||
Statics.LOGGER.sendInfo(ctx.getSource(), "Player: {} is already whitelisted.", player.getEntityName());
|
||||
} else {
|
||||
Statics.CONFIG.playerWhitelist.add(player.getEntityName());
|
||||
ConfigManager.saveConfig(Statics.CONFIG);
|
||||
|
||||
@ -83,19 +83,14 @@ public class WhitelistCommand {
|
||||
ServerPlayerEntity player = EntityArgumentType.getPlayer(ctx, "player");
|
||||
|
||||
if(!Statics.CONFIG.playerWhitelist.contains(player.getEntityName())) {
|
||||
ctx.getSource().sendFeedback(new TranslatableText("Player: %s newer was on the whitelist.", player.getEntityName()), false);
|
||||
}else{
|
||||
Statics.LOGGER.sendInfo(ctx.getSource(), "Player: {} newer was whitelisted.", player.getEntityName());
|
||||
} else {
|
||||
Statics.CONFIG.playerWhitelist.remove(player.getEntityName());
|
||||
ConfigManager.saveConfig(Statics.CONFIG);
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
builder.append("Player: ");
|
||||
builder.append(player.getEntityName());
|
||||
builder.append(" removed from the whitelist successfully.");
|
||||
|
||||
ctx.getSource().getMinecraftServer().getCommandManager().sendCommandTree(player);
|
||||
|
||||
Statics.LOGGER.sendInfo(ctx.getSource(), builder.toString());
|
||||
Statics.LOGGER.sendInfo(ctx.getSource(), "Player: {} removed from the whitelist successfully.", player.getEntityName());
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
@ -21,7 +21,6 @@ package net.szum123321.textile_backup.commands.restore;
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import net.minecraft.server.command.CommandManager;
|
||||
import net.minecraft.server.command.ServerCommandSource;
|
||||
import net.minecraft.text.LiteralText;
|
||||
import net.szum123321.textile_backup.Statics;
|
||||
|
||||
public class KillRestoreCommand {
|
||||
@ -30,13 +29,13 @@ public class KillRestoreCommand {
|
||||
.executes(ctx -> {
|
||||
if(Statics.restoreAwaitThread != null && Statics.restoreAwaitThread.isAlive()) {
|
||||
Statics.restoreAwaitThread.interrupt();
|
||||
ctx.getSource().sendFeedback(new LiteralText("Backup restoration successfully stopped"), false);
|
||||
Statics.LOGGER.sendInfo(ctx.getSource(), "Backup restoration successfully stopped");
|
||||
Statics.LOGGER.info("{} cancelled backup restoration.", ctx.getSource().getEntity() != null ?
|
||||
"Player: " + ctx.getSource().getName() :
|
||||
"SERVER"
|
||||
);
|
||||
} else {
|
||||
ctx.getSource().sendFeedback(new LiteralText("Failed to stop backup restoration"), false);
|
||||
Statics.LOGGER.sendInfo(ctx.getSource(), "Failed to stop backup restoration");
|
||||
}
|
||||
return 1;
|
||||
});
|
||||
|
@ -21,9 +21,10 @@ package net.szum123321.textile_backup.commands.restore;
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import net.minecraft.server.command.CommandManager;
|
||||
import net.minecraft.server.command.ServerCommandSource;
|
||||
import net.minecraft.text.LiteralText;
|
||||
import net.szum123321.textile_backup.Statics;
|
||||
import net.szum123321.textile_backup.core.restore.RestoreHelper;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
@ -39,6 +40,7 @@ public class ListBackupsCommand {
|
||||
builder.append("There is only one backup available: ");
|
||||
builder.append(backups.get(0).toString());
|
||||
} else {
|
||||
backups.sort(Comparator.comparing(RestoreHelper.RestoreableFile::getCreationTime));
|
||||
Iterator<RestoreHelper.RestoreableFile> iterator = backups.iterator();
|
||||
builder.append("Available backups: ");
|
||||
|
||||
@ -50,7 +52,7 @@ public class ListBackupsCommand {
|
||||
}
|
||||
}
|
||||
|
||||
ctx.getSource().sendFeedback(new LiteralText(builder.toString()), false);
|
||||
Statics.LOGGER.sendInfo(ctx.getSource(), builder.toString());
|
||||
|
||||
return 1;
|
||||
});
|
||||
|
@ -62,9 +62,9 @@ public class RestoreBackupCommand {
|
||||
).executes(context -> {
|
||||
ServerCommandSource source = context.getSource();
|
||||
|
||||
source.sendFeedback(new LiteralText("To restore given backup you have to provide exact creation time in format:"), false);
|
||||
source.sendFeedback(new LiteralText("[YEAR]-[MONTH]-[DAY]_[HOUR].[MINUTE].[SECOND]"), false);
|
||||
source.sendFeedback(new LiteralText("Example: 2020-08-05_10.58.33"), false);
|
||||
Statics.LOGGER.sendInfo(source, "To restore given backup you have to provide exact creation time in format:");
|
||||
Statics.LOGGER.sendInfo(source, "[YEAR]-[MONTH]-[DAY]_[HOUR].[MINUTE].[SECOND]");
|
||||
Statics.LOGGER.sendInfo(source, "Example: 2020-08-05_10.58.33");
|
||||
|
||||
return 1;
|
||||
});
|
||||
@ -108,7 +108,8 @@ public class RestoreBackupCommand {
|
||||
|
||||
Statics.restoreAwaitThread.start();
|
||||
} else if(Statics.restoreAwaitThread != null && Statics.restoreAwaitThread.isAlive()) {
|
||||
source.sendFeedback(new LiteralText("Someone has already started another restoration."), false);
|
||||
Statics.LOGGER.sendInfo(source, "Someone has already started another restoration.");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user