1.16
parent
cb55d5c9a4
commit
be3f32a282
|
@ -1,5 +1,5 @@
|
|||
plugins {
|
||||
id 'fabric-loom' version '0.9-SNAPSHOT'
|
||||
id 'fabric-loom' version '0.7-SNAPSHOT'
|
||||
id 'maven-publish'
|
||||
}
|
||||
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
# Done to increase the memory available to gradle.
|
||||
org.gradle.jvmargs=-Xmx1G
|
||||
|
||||
minecraft_version=1.17.1
|
||||
yarn_mappings=1.17.1+build.32
|
||||
minecraft_version=1.16.5
|
||||
yarn_mappings=1.16.5+build.10
|
||||
loader_version=0.11.6
|
||||
|
||||
#Fabric api
|
||||
fabric_version=0.37.0+1.17
|
||||
fabric_version=0.37.1+1.16
|
||||
|
||||
#Cloth Config
|
||||
cloth_version=5.0.37
|
||||
cloth_version=4.11.26
|
||||
|
||||
#ModMenu
|
||||
modmenu_version=2.0.4
|
||||
modmenu_version=1.16.11
|
||||
|
||||
#Lazy DFU for faster dev start
|
||||
lazydfu_version=0.1.2
|
||||
|
|
|
@ -86,7 +86,7 @@ public class TextileBackup implements ModInitializer {
|
|||
return ((config.get().playerWhitelist.contains(ctx.getEntityOrThrow().getEntityName()) ||
|
||||
ctx.hasPermissionLevel(config.get().permissionLevel)) &&
|
||||
!config.get().playerBlacklist.contains(ctx.getEntityOrThrow().getEntityName())) ||
|
||||
(ctx.getServer().isSinglePlayer() &&
|
||||
(ctx.getMinecraftServer().isSinglePlayer() &&
|
||||
config.get().alwaysSingleplayerAllowed);
|
||||
} catch (Exception ignored) { //Command was called from server console.
|
||||
return true;
|
||||
|
|
|
@ -22,6 +22,7 @@ import net.minecraft.entity.player.PlayerEntity;
|
|||
import net.minecraft.server.command.ServerCommandSource;
|
||||
import net.minecraft.text.LiteralText;
|
||||
import net.minecraft.text.MutableText;
|
||||
import net.minecraft.text.TextColor;
|
||||
import net.minecraft.util.Formatting;
|
||||
import net.szum123321.textile_backup.core.create.BackupContext;
|
||||
import org.apache.logging.log4j.Level;
|
||||
|
@ -29,7 +30,6 @@ import org.apache.logging.log4j.LogManager;
|
|||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.logging.log4j.message.MessageFactory;
|
||||
import org.apache.logging.log4j.message.ParameterizedMessageFactory;
|
||||
import org.apache.logging.log4j.util.StackLocatorUtil;
|
||||
|
||||
/*
|
||||
This is practically just a copy-pate of Cotton's ModLogger with a few changes
|
||||
|
@ -43,18 +43,11 @@ public class TextileLogger {
|
|||
private final String prefix;
|
||||
private final MutableText prefixText;
|
||||
|
||||
/* public TextileLogger(String name, String prefix) {
|
||||
this.messageFactory = ParameterizedMessageFactory.INSTANCE;
|
||||
this.logger = LogManager.getLogger(name, messageFactory);
|
||||
this.prefix = "[" + prefix + "]" + " ";
|
||||
this.prefixText = new LiteralText(this.prefix).styled(style -> style.withColor(0x5B23DA));
|
||||
}
|
||||
*/
|
||||
public TextileLogger(String prefix) {
|
||||
this.messageFactory = ParameterizedMessageFactory.INSTANCE;
|
||||
this.logger = LogManager.getLogger(StackLocatorUtil.getCallerClass(2), messageFactory);
|
||||
this.logger = LogManager.getLogger(getCallerClass(2), messageFactory);
|
||||
this.prefix = "[" + prefix + "]" + " ";
|
||||
this.prefixText = new LiteralText(this.prefix).styled(style -> style.withColor(0x5B23DA));
|
||||
this.prefixText = new LiteralText(this.prefix).styled(style -> style.withColor(TextColor.fromRgb(0x5B23DA)));
|
||||
}
|
||||
|
||||
public MutableText getPrefixText() {
|
||||
|
@ -151,4 +144,8 @@ public class TextileLogger {
|
|||
public void sendErrorAL(BackupContext context, String msg, Object... args) {
|
||||
sendErrorAL(context.getCommandSource(), msg, args);
|
||||
}
|
||||
|
||||
private static String getCallerClass(int depth) {
|
||||
return new Throwable().getStackTrace()[depth].getClassName();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ public final class FileSuggestionProvider implements SuggestionProvider<ServerCo
|
|||
public CompletableFuture<Suggestions> getSuggestions(CommandContext<ServerCommandSource> ctx, SuggestionsBuilder builder) throws CommandSyntaxException {
|
||||
String remaining = builder.getRemaining();
|
||||
|
||||
for (RestoreHelper.RestoreableFile file : RestoreHelper.getAvailableBackups(ctx.getSource().getServer())) {
|
||||
for (RestoreHelper.RestoreableFile file : RestoreHelper.getAvailableBackups(ctx.getSource().getMinecraftServer())) {
|
||||
String formattedCreationTime = file.getCreationTime().format(Statics.defaultDateTimeFormatter);
|
||||
|
||||
if (formattedCreationTime.startsWith(remaining)) {
|
||||
|
|
|
@ -38,7 +38,7 @@ public class CleanupCommand {
|
|||
log.sendInfo(
|
||||
source,
|
||||
"Deleted: {} files.",
|
||||
BackupHelper.executeFileLimit(source, Utilities.getLevelName(source.getServer()))
|
||||
BackupHelper.executeFileLimit(source, Utilities.getLevelName(source.getMinecraftServer()))
|
||||
);
|
||||
|
||||
return 1;
|
||||
|
|
|
@ -92,7 +92,7 @@ public class BlacklistCommand {
|
|||
|
||||
builder.append(" successfully.");
|
||||
|
||||
ctx.getSource().getServer().getCommandManager().sendCommandTree(player);
|
||||
ctx.getSource().getMinecraftServer().getCommandManager().sendCommandTree(player);
|
||||
|
||||
log.sendInfo(ctx.getSource(), builder.toString());
|
||||
}
|
||||
|
@ -109,7 +109,7 @@ public class BlacklistCommand {
|
|||
config.get().playerBlacklist.remove(player.getEntityName());
|
||||
config.save();
|
||||
|
||||
ctx.getSource().getServer().getCommandManager().sendCommandTree(player);
|
||||
ctx.getSource().getMinecraftServer().getCommandManager().sendCommandTree(player);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
File root = Utilities.getBackupRootPath(Utilities.getLevelName(source.getServer()));
|
||||
File root = Utilities.getBackupRootPath(Utilities.getLevelName(source.getMinecraftServer()));
|
||||
|
||||
Optional<File> optionalFile = Arrays.stream(root.listFiles())
|
||||
.filter(Utilities::isValidBackup)
|
||||
|
|
|
@ -33,7 +33,7 @@ public class ListBackupsCommand {
|
|||
public static LiteralArgumentBuilder<ServerCommandSource> register() {
|
||||
return CommandManager.literal("list")
|
||||
.executes(ctx -> { StringBuilder builder = new StringBuilder();
|
||||
List<RestoreHelper.RestoreableFile> backups = RestoreHelper.getAvailableBackups(ctx.getSource().getServer());
|
||||
List<RestoreHelper.RestoreableFile> backups = RestoreHelper.getAvailableBackups(ctx.getSource().getMinecraftServer());
|
||||
|
||||
if(backups.size() == 0) {
|
||||
builder.append("There a no backups available for this world.");
|
||||
|
|
|
@ -92,7 +92,7 @@ public class WhitelistCommand {
|
|||
|
||||
builder.append(" successfully.");
|
||||
|
||||
ctx.getSource().getServer().getCommandManager().sendCommandTree(player);
|
||||
ctx.getSource().getMinecraftServer().getCommandManager().sendCommandTree(player);
|
||||
|
||||
log.sendInfo(ctx.getSource(), builder.toString());
|
||||
}
|
||||
|
@ -109,7 +109,7 @@ public class WhitelistCommand {
|
|||
config.get().playerWhitelist.remove(player.getEntityName());
|
||||
config.save();
|
||||
|
||||
ctx.getSource().getServer().getCommandManager().sendCommandTree(player);
|
||||
ctx.getSource().getMinecraftServer().getCommandManager().sendCommandTree(player);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
Optional<RestoreHelper.RestoreableFile> backupFile = RestoreHelper.findFileAndLockIfPresent(dateTime, source.getServer());
|
||||
Optional<RestoreHelper.RestoreableFile> backupFile = RestoreHelper.findFileAndLockIfPresent(dateTime, source.getMinecraftServer());
|
||||
|
||||
if(backupFile.isPresent()) {
|
||||
log.info("Found file to restore {}", backupFile.get().getFile().getName());
|
||||
|
|
|
@ -115,7 +115,7 @@ public record BackupContext(@NotNull MinecraftServer server,
|
|||
}
|
||||
|
||||
if (server == null) {
|
||||
if (commandSource != null) setServer(commandSource.getServer());
|
||||
if (commandSource != null) setServer(commandSource.getMinecraftServer());
|
||||
else
|
||||
throw new RuntimeException("Neither MinecraftServer or ServerCommandSource were provided!");
|
||||
}
|
||||
|
|
|
@ -86,7 +86,7 @@ public record RestoreContext(RestoreHelper.RestoreableFile file,
|
|||
}
|
||||
|
||||
public RestoreContext build() {
|
||||
if (server == null) server = serverCommandSource.getServer();
|
||||
if (server == null) server = serverCommandSource.getMinecraftServer();
|
||||
|
||||
ActionInitiator initiator = serverCommandSource.getEntity() instanceof PlayerEntity ? ActionInitiator.Player : ActionInitiator.ServerConsole;
|
||||
|
||||
|
|
|
@ -39,12 +39,11 @@
|
|||
"depends": {
|
||||
"fabricloader": ">=0.11",
|
||||
"fabric": "*",
|
||||
"minecraft": "1.17.*",
|
||||
"minecraft": "1.16.*",
|
||||
"cloth-config2": "*",
|
||||
"java": ">=16"
|
||||
},
|
||||
"recommends": {
|
||||
|
||||
"modmenu": "*"
|
||||
},
|
||||
|
||||
|
|
Loading…
Reference in New Issue