Repaired singeplayer command permission system.

This commit is contained in:
Szum123321 2020-03-24 22:22:26 +01:00
parent 5fd25d5a45
commit f8d2a69743
3 changed files with 7 additions and 6 deletions

View File

@ -59,6 +59,9 @@ public class ConfigHandler {
@Comment("\nMinimal permission level required to run commands\n")
public int permissionLevel = 4;
@Comment("\nPlayer on singleplayer is always allowed to run command. Warning! On lan party everyone will be allowed to run it.\n")
public boolean alwaysSingleplayerAllowed = true;
@Comment("\nPlayers allowed to run backup commands without sufficient permission level\n")
public Set<String> whitelist = new HashSet<>();

View File

@ -52,11 +52,12 @@ public class TextileBackup implements ModInitializer {
LiteralArgumentBuilder.<ServerCommandSource>literal("backup")
.requires((ctx) -> {
try {
return (config.whitelist.contains(ctx.getEntityOrThrow().getEntityName()) ||
return ((config.whitelist.contains(ctx.getEntityOrThrow().getEntityName()) ||
ctx.hasPermissionLevel(config.permissionLevel)) &&
!config.blacklist.contains(ctx.getEntityOrThrow().getEntityName());
!config.blacklist.contains(ctx.getEntityOrThrow().getEntityName())) ||
(ctx.getMinecraftServer().isSinglePlayer() &&
config.alwaysSingleplayerAllowed);
}catch (Exception e){ //Command was called from server console.
System.out.println("Server!");
return true;
}
}

View File

@ -77,9 +77,6 @@ public class BackupHelper {
)
);
}catch(Exception e){
System.out.println(e.getClass());
System.out.println(e.toString());
creationTime = LocalDateTime.from(
Utilities.getBackupDateTimeFormatter().parse(
f.getName().split(".zip")[0].split("#")[0]