parent
e9f6a29eb2
commit
cdd2b78c43
|
@ -1,12 +1,12 @@
|
||||||
# Done to increase the memory available to gradle.
|
# Done to increase the memory available to gradle.
|
||||||
org.gradle.jvmargs=-Xmx1G
|
org.gradle.jvmargs=-Xmx1G
|
||||||
|
|
||||||
minecraft_version=1.17
|
minecraft_version=1.17.1
|
||||||
yarn_mappings=1.17+build.10
|
yarn_mappings=1.17.1+build.1
|
||||||
loader_version=0.11.5
|
loader_version=0.11.6
|
||||||
|
|
||||||
#Fabric api
|
#Fabric api
|
||||||
fabric_version=0.35.1+1.17
|
fabric_version=0.36.1+1.17
|
||||||
|
|
||||||
#Cloth Config
|
#Cloth Config
|
||||||
cloth_version=5.0.34
|
cloth_version=5.0.34
|
||||||
|
|
|
@ -98,7 +98,7 @@ public class TextileBackup implements ModInitializer {
|
||||||
return ((config.get().playerWhitelist.contains(ctx.getEntityOrThrow().getEntityName()) ||
|
return ((config.get().playerWhitelist.contains(ctx.getEntityOrThrow().getEntityName()) ||
|
||||||
ctx.hasPermissionLevel(config.get().permissionLevel)) &&
|
ctx.hasPermissionLevel(config.get().permissionLevel)) &&
|
||||||
!config.get().playerBlacklist.contains(ctx.getEntityOrThrow().getEntityName())) ||
|
!config.get().playerBlacklist.contains(ctx.getEntityOrThrow().getEntityName())) ||
|
||||||
(ctx.getMinecraftServer().isSinglePlayer() &&
|
(ctx.getServer().isSinglePlayer() &&
|
||||||
config.get().alwaysSingleplayerAllowed);
|
config.get().alwaysSingleplayerAllowed);
|
||||||
} catch (Exception ignored) { //Command was called from server console.
|
} catch (Exception ignored) { //Command was called from server console.
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -28,7 +28,6 @@ import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.server.command.ServerCommandSource;
|
import net.minecraft.server.command.ServerCommandSource;
|
||||||
import net.szum123321.textile_backup.Statics;
|
import net.szum123321.textile_backup.Statics;
|
||||||
import net.szum123321.textile_backup.core.restore.RestoreHelper;
|
import net.szum123321.textile_backup.core.restore.RestoreHelper;
|
||||||
import org.lwjgl.system.CallbackI;
|
|
||||||
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
|
@ -43,7 +42,7 @@ public final class FileSuggestionProvider implements SuggestionProvider<ServerCo
|
||||||
public CompletableFuture<Suggestions> getSuggestions(CommandContext<ServerCommandSource> ctx, SuggestionsBuilder builder) throws CommandSyntaxException {
|
public CompletableFuture<Suggestions> getSuggestions(CommandContext<ServerCommandSource> ctx, SuggestionsBuilder builder) throws CommandSyntaxException {
|
||||||
String remaining = builder.getRemaining();
|
String remaining = builder.getRemaining();
|
||||||
|
|
||||||
for (RestoreHelper.RestoreableFile file : RestoreHelper.getAvailableBackups(ctx.getSource().getMinecraftServer())) {
|
for (RestoreHelper.RestoreableFile file : RestoreHelper.getAvailableBackups(ctx.getSource().getServer())) {
|
||||||
String formattedCreationTime = file.getCreationTime().format(Statics.defaultDateTimeFormatter);
|
String formattedCreationTime = file.getCreationTime().format(Statics.defaultDateTimeFormatter);
|
||||||
|
|
||||||
if (formattedCreationTime.startsWith(remaining)) {
|
if (formattedCreationTime.startsWith(remaining)) {
|
||||||
|
|
|
@ -38,7 +38,7 @@ public class CleanupCommand {
|
||||||
log.sendInfo(
|
log.sendInfo(
|
||||||
source,
|
source,
|
||||||
"Deleted: {} files.",
|
"Deleted: {} files.",
|
||||||
BackupHelper.executeFileLimit(source, Utilities.getLevelName(source.getMinecraftServer()))
|
BackupHelper.executeFileLimit(source, Utilities.getLevelName(source.getServer()))
|
||||||
);
|
);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
@ -73,7 +73,7 @@ public class BlacklistCommand {
|
||||||
|
|
||||||
builder.append(" successfully.");
|
builder.append(" successfully.");
|
||||||
|
|
||||||
ctx.getSource().getMinecraftServer().getCommandManager().sendCommandTree(player);
|
ctx.getSource().getServer().getCommandManager().sendCommandTree(player);
|
||||||
|
|
||||||
log.sendInfo(ctx.getSource(), builder.toString());
|
log.sendInfo(ctx.getSource(), builder.toString());
|
||||||
}
|
}
|
||||||
|
@ -90,7 +90,7 @@ public class BlacklistCommand {
|
||||||
config.get().playerBlacklist.remove(player.getEntityName());
|
config.get().playerBlacklist.remove(player.getEntityName());
|
||||||
config.save();
|
config.save();
|
||||||
|
|
||||||
ctx.getSource().getMinecraftServer().getCommandManager().sendCommandTree(player);
|
ctx.getSource().getServer().getCommandManager().sendCommandTree(player);
|
||||||
|
|
||||||
log.sendInfo(ctx.getSource(), "Player: {} removed from the blacklist successfully.", player.getEntityName());
|
log.sendInfo(ctx.getSource(), "Player: {} removed from the blacklist successfully.", player.getEntityName());
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,7 @@ public class DeleteCommand {
|
||||||
throw CommandExceptions.DATE_TIME_PARSE_COMMAND_EXCEPTION_TYPE.create(e);
|
throw CommandExceptions.DATE_TIME_PARSE_COMMAND_EXCEPTION_TYPE.create(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
File root = Utilities.getBackupRootPath(Utilities.getLevelName(source.getMinecraftServer()));
|
File root = Utilities.getBackupRootPath(Utilities.getLevelName(source.getServer()));
|
||||||
|
|
||||||
Optional<File> optionalFile = Arrays.stream(root.listFiles())
|
Optional<File> optionalFile = Arrays.stream(root.listFiles())
|
||||||
.filter(Utilities::isValidBackup)
|
.filter(Utilities::isValidBackup)
|
||||||
|
|
|
@ -33,7 +33,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().getServer());
|
||||||
|
|
||||||
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.");
|
||||||
|
|
|
@ -73,7 +73,7 @@ public class WhitelistCommand {
|
||||||
|
|
||||||
builder.append(" successfully.");
|
builder.append(" successfully.");
|
||||||
|
|
||||||
ctx.getSource().getMinecraftServer().getCommandManager().sendCommandTree(player);
|
ctx.getSource().getServer().getCommandManager().sendCommandTree(player);
|
||||||
|
|
||||||
log.sendInfo(ctx.getSource(), builder.toString());
|
log.sendInfo(ctx.getSource(), builder.toString());
|
||||||
}
|
}
|
||||||
|
@ -90,7 +90,7 @@ public class WhitelistCommand {
|
||||||
config.get().playerWhitelist.remove(player.getEntityName());
|
config.get().playerWhitelist.remove(player.getEntityName());
|
||||||
config.save();
|
config.save();
|
||||||
|
|
||||||
ctx.getSource().getMinecraftServer().getCommandManager().sendCommandTree(player);
|
ctx.getSource().getServer().getCommandManager().sendCommandTree(player);
|
||||||
|
|
||||||
log.sendInfo(ctx.getSource(), "Player: {} removed from the whitelist successfully.", player.getEntityName());
|
log.sendInfo(ctx.getSource(), "Player: {} removed from the whitelist successfully.", player.getEntityName());
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,7 +79,7 @@ public class RestoreBackupCommand {
|
||||||
throw CommandExceptions.DATE_TIME_PARSE_COMMAND_EXCEPTION_TYPE.create(e);
|
throw CommandExceptions.DATE_TIME_PARSE_COMMAND_EXCEPTION_TYPE.create(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
Optional<RestoreHelper.RestoreableFile> backupFile = RestoreHelper.findFileAndLockIfPresent(dateTime, source.getMinecraftServer());
|
Optional<RestoreHelper.RestoreableFile> backupFile = RestoreHelper.findFileAndLockIfPresent(dateTime, source.getServer());
|
||||||
|
|
||||||
if(backupFile.isPresent()) {
|
if(backupFile.isPresent()) {
|
||||||
log.info("Found file to restore {}", backupFile.get().getFile().getName());
|
log.info("Found file to restore {}", backupFile.get().getFile().getName());
|
||||||
|
|
|
@ -121,8 +121,7 @@ public record BackupContext(MinecraftServer server,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (server == null) {
|
if (server == null) {
|
||||||
if (commandSource != null)
|
if (commandSource != null) setServer(commandSource.getServer());
|
||||||
setServer(commandSource.getMinecraftServer());
|
|
||||||
else
|
else
|
||||||
throw new RuntimeException("Both MinecraftServer and ServerCommandSource weren't provided!");
|
throw new RuntimeException("Both MinecraftServer and ServerCommandSource weren't provided!");
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,7 +92,7 @@ public record RestoreContext(RestoreHelper.RestoreableFile file,
|
||||||
}
|
}
|
||||||
|
|
||||||
public RestoreContext build() {
|
public RestoreContext build() {
|
||||||
if (server == null) server = serverCommandSource.getMinecraftServer();
|
if (server == null) server = serverCommandSource.getServer();
|
||||||
|
|
||||||
ActionInitiator initiator = serverCommandSource.getEntity() instanceof PlayerEntity ? ActionInitiator.Player : ActionInitiator.ServerConsole;
|
ActionInitiator initiator = serverCommandSource.getEntity() instanceof PlayerEntity ? ActionInitiator.Player : ActionInitiator.ServerConsole;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue