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