Skip to content

Commit

Permalink
Few small tweaks. Most lkely final 1.16.1 version.
Browse files Browse the repository at this point in the history
  • Loading branch information
Szum123321 committed Jun 24, 2020
1 parent 1fd25e7 commit 708659b
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 29 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ loader_version=0.8.8+build.202
fabric_version=0.13.1+build.370-1.16

# Mod Properties
mod_version = 1.2.1-1.16-pre2
mod_version = 1.2.2-1.16.1
maven_group = net.szum123321
archives_base_name = textile_backup
20 changes: 11 additions & 9 deletions src/main/java/net/szum123321/textile_backup/ConfigHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,35 +26,35 @@

@ConfigFile(name = TextileBackup.MOD_ID)
public class ConfigHandler {
@Comment("\nTime between backups in seconds\n")
@Comment("\nTime between automatic backups in seconds\n")
public long backupInterval = 3600;

@Comment("\nShould backups be done even if there is no players?\n")
@Comment("\nShould backups be done even if there are no players?\n")
public boolean doBackupsOnEmptyServer = false;

@Comment("\nShould backups be made on server shutdown\n")
@Comment("\nShould backup be made on server shutdown\n")
public boolean shutdownBackup = true;

@Comment("\nA path to backup folder\n")
public String path = "backup/";

@Comment("\nThis setting allows you to exclude files form being backuped.\n"+
"Be very careful when setting it, as it is easy to make your backuped world unusable!\n")
"Be very careful when setting it, as it is easy corrupt your world!\n")
public Set<String> fileBlacklist = new HashSet<>();

@Comment("\nShould every world has its won backup folder?\n")
public boolean perWorldBackup = false;

@Comment("\nMaximum number of backups to keep. If 0 then no backup will be deleted based on its amount\n")
@Comment("\nMaximum number of backups to keep. If set to 0 then no backup will be deleted based their its amount\n")
public int backupsToKeep = 10;

@Comment("\nMaximum age of backups to keep in seconds.\n if 0 then backups will not be deleted based on its age \n")
@Comment("\nMaximum age of backups to keep in seconds.\n If set to 0 then backups will not be deleted based their its age \n")
public long maxAge = 0;

@Comment("\nMaximum size of backup folder in kilo bytes. \n")
@Comment("\nMaximum size of backup folder in kilo bytes (1024).\n")
public int maxSize = 0;

@Comment("\nCompression level \n0 - 9\n Only available for zip compression.\n")
@Comment("\nCompression level \n0 - 9\n Only affects zip compression.\n")
public int compression = 6;

@Comment(value = "\nAvailable formats are:\n" +
Expand Down Expand Up @@ -82,7 +82,9 @@ public class ConfigHandler {
@Comment("\nPlayers banned from running backup commands besides their sufficient permission level\n")
public Set<String> playerBlacklist = new HashSet<>();

@Comment("\nFormat of date&time used to name backup files.\n")
@Comment("\nFormat of date&time used to name backup files.\n" +
"Remember not to use '#' symbol and any other character that is not allowed by your operating system such as:\n" +
"':', '\\', etc\n")
public String dateTimeFormat = "dd.MM.yyyy_HH-mm-ss";

public enum ArchiveFormat {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ private void registerCommands(){
!config.playerBlacklist.contains(ctx.getEntityOrThrow().getEntityName())) ||
(ctx.getMinecraftServer().isSinglePlayer() &&
config.alwaysSingleplayerAllowed);
}catch (Exception e){ //Command was called from server console.
} catch (Exception e) { //Command was called from server console.
return true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ public static void executeFileLimit(ServerCommandSource ctx, String worldName) {
Utilities.log("Deleting: " + f.getName(), ctx);
f.delete();
}
} catch (NullPointerException ignored3) {}
} catch (NullPointerException ignored3) {
Utilities.error("File: " + f.getName() + ", was not deleted beacuse could not parse date and time. Please delete it by hand.", ctx);
}
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public MakeBackupThread(MinecraftServer server, ServerCommandSource ctx, String

@Override
public void run() {
File world = ((MinecraftServerSessionAccessor)server) // I'm lost.
File world = ((MinecraftServerSessionAccessor)server)
.getSession()
.method_27424(RegistryKey.of(Registry.DIMENSION, DimensionType.OVERWORLD_REGISTRY_KEY.getValue()));

Expand Down
19 changes: 4 additions & 15 deletions src/main/java/net/szum123321/textile_backup/core/Utilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@

import net.minecraft.server.MinecraftServer;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.server.dedicated.DedicatedServer;
import net.minecraft.server.dedicated.MinecraftDedicatedServer;
import net.minecraft.server.integrated.IntegratedServer;
import net.minecraft.text.LiteralText;
import net.minecraft.util.Formatting;
import net.szum123321.textile_backup.TextileBackup;
import net.szum123321.textile_backup.mixin.MinecraftServerSessionAccessor;

Expand All @@ -17,11 +15,6 @@ public static String getLevelName(MinecraftServer server) {
return ((MinecraftServerSessionAccessor)server).getSession().getDirectoryName();
}

public static boolean isWindows(){
String os = System.getProperty("os.name");
return os.toLowerCase().startsWith("win");
}

public static boolean isBlacklisted(Path path) {
for(String i : TextileBackup.config.fileBlacklist) {
if(path.startsWith(i))
Expand All @@ -38,12 +31,8 @@ public static DateTimeFormatter getDateTimeFormatter(){
return getBackupDateTimeFormatter();
}

public static DateTimeFormatter getBackupDateTimeFormatter(){
if(isWindows()){
return DateTimeFormatter.ofPattern("dd.MM.yyyy_HH-mm-ss");
} else {
return DateTimeFormatter.ofPattern("dd.MM.yyyy_HH:mm:ss");
}
public static DateTimeFormatter getBackupDateTimeFormatter() {
return DateTimeFormatter.ofPattern("dd.MM.yyyy_HH-mm-ss");
}

public static void log(String s, ServerCommandSource ctx){
Expand All @@ -56,7 +45,7 @@ public static void log(String s, ServerCommandSource ctx){

public static void error(String s, ServerCommandSource ctx){
if(ctx != null)
ctx.sendFeedback(new LiteralText(s), true);
ctx.sendFeedback(new LiteralText(s).styled(style -> style.withColor(Formatting.RED)), true);

if(TextileBackup.config.log)
TextileBackup.logger.error(s);
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
],

"depends": {
"fabricloader": ">=0.7.2",
"fabricloader": ">=0.8.8",
"fabric": "*",
"minecraft": "1.16.1"
}
Expand Down

0 comments on commit 708659b

Please sign in to comment.