BackupConfig class
Пакет: com.hypixel.hytale.server.core.config
Файл: com/hypixel/hytale/server/core/config/BackupConfig.java
Поля (5)
| Модификаторы | Тип | Имя |
|---|---|---|
final |
int |
DEFAULT_FREQUENCY_MINUTES |
|
OptionSet |
var1 |
|
OptionSet |
var1 |
|
OptionSet |
var1 |
|
OptionSet |
var1 |
Методы (16)
| Модификаторы | Возврат | Сигнатура |
|---|---|---|
public |
int |
getArchiveMaxCountint getArchiveMaxCount() |
public |
int |
getFrequencyMinutesint getFrequencyMinutes() |
public |
int |
getMaxCountint getMaxCount() |
|
|
if if(this.hytaleServerConfig != null) |
|
|
if if(this.hytaleServerConfig != null) |
|
|
if if(this.hytaleServerConfig != null) |
|
|
if if(this.hytaleServerConfig != null) |
|
|
if if(this.hytaleServerConfig != null) |
public |
boolean |
isConfiguredboolean isConfigured() |
public |
boolean |
isEnabledboolean isEnabled() |
public |
void |
setArchiveMaxCountvoid setArchiveMaxCount(int var1) |
public |
void |
setDirectoryvoid setDirectory(@Nullable String var1) |
public |
void |
setEnabledvoid setEnabled(boolean var1) |
public |
void |
setFrequencyMinutesvoid setFrequencyMinutes(int var1) |
public |
void |
setHytaleServerConfigvoid setHytaleServerConfig(@Nonnull HytaleServerConfig var1) |
public |
void |
setMaxCountvoid setMaxCount(int var1) |
Исходный код
Показать/скрыть
class="kw">package com.hypixel.hytale.server.core.config;
class="kw">import com.hypixel.hytale.codec.Codec;
class="kw">import com.hypixel.hytale.codec.KeyedCodec;
class="kw">import com.hypixel.hytale.codec.builder.BuilderCodec;
class="kw">import com.hypixel.hytale.codec.validation.Validators;
class="kw">import com.hypixel.hytale.server.core.HytaleServerConfig;
class="kw">import com.hypixel.hytale.server.core.Options;
class="kw">import java.nio.file.Path;
class="kw">import javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;
class="kw">import joptsimple.OptionSet;
class="kw">public class BackupConfig {
class="kw">public class="kw">static class="kw">final int DEFAULT_FREQUENCY_MINUTES = 30;
class="kw">public class="kw">static class="kw">final int DEFAULT_MAX_COUNT = 5;
class="kw">public class="kw">static class="kw">final int DEFAULT_ARCHIVE_MAX_COUNT = 5;
@Nonnull
class="kw">public class="kw">static class="kw">final Codec<BackupConfig> CODEC = BuilderCodec.builder(BackupConfig.class, BackupConfig::new)
.append(new KeyedCodec<>("Enabled", Codec.BOOLEAN), (var0, var1) -> var0.enabled = var1, var0 -> var0.enabled)
.documentation("Determines whether automatic backups are enabled. Can be overridden by the --backup CLI option.")
.add()
.<Integer>append(new KeyedCodec<>("FrequencyMinutes", Codec.INTEGER), (var0, var1) -> var0.frequencyMinutes = var1, var0 -> var0.frequencyMinutes)
.addValidator(Validators.greaterThan(0))
.documentation("The backup frequency in minutes. Must be at least 1. Can be overridden by the --backup-frequency CLI option.")
.add()
.<String>append(new KeyedCodec<>("Directory", Codec.STRING), (var0, var1) -> var0.directory = var1, var0 -> var0.directory)
.addValidator(Validators.nonEmptyString())
.documentation("The backup directory path. Can be overridden by the --backup-directory CLI option.")
.add()
.<Integer>append(new KeyedCodec<>("MaxCount", Codec.INTEGER), (var0, var1) -> var0.maxCount = var1, var0 -> var0.maxCount)
.addValidator(Validators.greaterThan(0))
.documentation("The maximum number of recent backups to retain. Must be at least 1. Can be overridden by the --backup-max-count CLI option.")
.add()
.<Integer>append(new KeyedCodec<>("ArchiveMaxCount", Codec.INTEGER), (var0, var1) -> var0.archiveMaxCount = var1, var0 -> var0.archiveMaxCount)
.addValidator(Validators.greaterThan(0))
.documentation("The maximum number of archived backups to retain. Must be at least 1. Can be overridden by the --backup-archive-max-count CLI option.")
.add()
.build();
@Nullable
class="kw">private Boolean enabled;
@Nullable
class="kw">private Integer frequencyMinutes;
@Nullable
class="kw">private String directory;
@Nullable
class="kw">private Integer maxCount;
@Nullable
class="kw">private Integer archiveMaxCount;
@Nullable
class="kw">transient HytaleServerConfig hytaleServerConfig;
class="kw">public BackupConfig() {
}
class="kw">public BackupConfig(@Nonnull HytaleServerConfig var1) {
this.hytaleServerConfig = var1;
}
class="kw">public void setHytaleServerConfig(@Nonnull HytaleServerConfig var1) {
this.hytaleServerConfig = var1;
}
class="kw">public boolean isEnabled() {
if (Options.getOptionSet().has(Options.BACKUP)) {
class="kw">return true;
} else {
class="kw">return this.enabled != null ? this.enabled : false;
}
}
@Nullable
class="kw">public Boolean getEnabledConfig() {
class="kw">return this.enabled;
}
class="kw">public void setEnabled(boolean var1) {
this.enabled = var1;
if (this.hytaleServerConfig != null) {
this.hytaleServerConfig.markChanged();
}
}
class="kw">public int getFrequencyMinutes() {
OptionSet var1 = Options.getOptionSet();
if (var1.has(Options.BACKUP_FREQUENCY_MINUTES)) {
class="kw">return Math.max((Integer)var1.valueOf(Options.BACKUP_FREQUENCY_MINUTES), 1);
} else {
class="kw">return this.frequencyMinutes != null ? Math.max(this.frequencyMinutes, 1) : 30;
}
}
@Nullable
class="kw">public Integer getFrequencyMinutesConfig() {
class="kw">return this.frequencyMinutes;
}
class="kw">public void setFrequencyMinutes(int var1) {
this.frequencyMinutes = var1;
if (this.hytaleServerConfig != null) {
this.hytaleServerConfig.markChanged();
}
}
@Nullable
class="kw">public Path getDirectory() {
OptionSet var1 = Options.getOptionSet();
if (var1.has(Options.BACKUP_DIRECTORY)) {
class="kw">return (Path)var1.valueOf(Options.BACKUP_DIRECTORY);
} else {
class="kw">return this.directory != null ? Path.of(this.directory) : null;
}
}
@Nullable
class="kw">public String getDirectoryConfig() {
class="kw">return this.directory;
}
class="kw">public void setDirectory(@Nullable String var1) {
this.directory = var1;
if (this.hytaleServerConfig != null) {
this.hytaleServerConfig.markChanged();
}
}
class="kw">public int getMaxCount() {
OptionSet var1 = Options.getOptionSet();
if (var1.has(Options.BACKUP_MAX_COUNT)) {
class="kw">return (Integer)var1.valueOf(Options.BACKUP_MAX_COUNT);
} else {
class="kw">return this.maxCount != null ? this.maxCount : 5;
}
}
@Nullable
class="kw">public Integer getMaxCountConfig() {
class="kw">return this.maxCount;
}
class="kw">public void setMaxCount(int var1) {
this.maxCount = var1;
if (this.hytaleServerConfig != null) {
this.hytaleServerConfig.markChanged();
}
}
class="kw">public int getArchiveMaxCount() {
OptionSet var1 = Options.getOptionSet();
if (var1.has(Options.BACKUP_ARCHIVE_MAX_COUNT)) {
class="kw">return (Integer)var1.valueOf(Options.BACKUP_ARCHIVE_MAX_COUNT);
} else {
class="kw">return this.archiveMaxCount != null ? this.archiveMaxCount : 5;
}
}
@Nullable
class="kw">public Integer getArchiveMaxCountConfig() {
class="kw">return this.archiveMaxCount;
}
class="kw">public void setArchiveMaxCount(int var1) {
this.archiveMaxCount = var1;
if (this.hytaleServerConfig != null) {
this.hytaleServerConfig.markChanged();
}
}
class="kw">public boolean isConfigured() {
class="kw">return this.isEnabled() && this.getDirectory() != null;
}
}