mirror of
https://github.com/songoda/EpicFurnaces.git
synced 2024-12-12 11:36:44 +01:00
Merge branch 'development'
This commit is contained in:
commit
304699b063
@ -4,7 +4,7 @@ stages:
|
|||||||
variables:
|
variables:
|
||||||
name: "EpicFurnaces"
|
name: "EpicFurnaces"
|
||||||
path: "/builds/$CI_PROJECT_PATH"
|
path: "/builds/$CI_PROJECT_PATH"
|
||||||
version: "4.5.3"
|
version: "4.5.4"
|
||||||
|
|
||||||
build:
|
build:
|
||||||
stage: build
|
stage: build
|
||||||
|
@ -105,23 +105,6 @@ public class StorageYaml extends Storage {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void makeBackup() {
|
public void makeBackup() {
|
||||||
File data = new File(plugin.getDataFolder(), "data.yml");
|
|
||||||
File dataClone = new File(plugin.getDataFolder(), "data-backup-" + System.currentTimeMillis() + ".yml");
|
|
||||||
try {
|
|
||||||
if (data.exists())
|
|
||||||
copyFile(data, dataClone);
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
Deque<File> backups = new ArrayDeque<>();
|
|
||||||
for (File file : Objects.requireNonNull(plugin.getDataFolder().listFiles())) {
|
|
||||||
if (file.getName().toLowerCase().contains("data-backup")) {
|
|
||||||
backups.add(file);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (backups.size() > 3) {
|
|
||||||
backups.getFirst().delete();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -129,20 +112,4 @@ public class StorageYaml extends Storage {
|
|||||||
dataFile.save();
|
dataFile.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void copyFile(File source, File dest) throws IOException {
|
|
||||||
InputStream is = null;
|
|
||||||
OutputStream os = null;
|
|
||||||
try {
|
|
||||||
is = new FileInputStream(source);
|
|
||||||
os = new FileOutputStream(dest);
|
|
||||||
byte[] buffer = new byte[1024];
|
|
||||||
int length;
|
|
||||||
while ((length = is.read(buffer)) > 0) {
|
|
||||||
os.write(buffer, 0, length);
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
is.close();
|
|
||||||
os.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user