Removed redundant BufferStreams and LivingServer subsystem
parent
f6cd361fff
commit
afe9c8d051
|
@ -1,23 +0,0 @@
|
||||||
/*
|
|
||||||
* A simple backup mod for Fabric
|
|
||||||
* Copyright (C) 2021 Szum123321
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.szum123321.textile_backup.core;
|
|
||||||
|
|
||||||
public interface LivingServer {
|
|
||||||
boolean isAlive();
|
|
||||||
}
|
|
|
@ -59,9 +59,8 @@ public class GenericTarDecompressor {
|
||||||
} else {
|
} else {
|
||||||
Files.createDirectories(file.getParent());
|
Files.createDirectories(file.getParent());
|
||||||
try (OutputStream outputStream = Files.newOutputStream(file);
|
try (OutputStream outputStream = Files.newOutputStream(file);
|
||||||
HashingOutputStream hashingStream = new HashingOutputStream(outputStream, file, null, treeBuilder);
|
HashingOutputStream out = new HashingOutputStream(outputStream, file, treeBuilder)) {
|
||||||
BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(hashingStream)) {
|
IOUtils.copy(archiveInputStream, out);
|
||||||
IOUtils.copy(archiveInputStream, bufferedOutputStream);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,9 +52,8 @@ public class ZipDecompressor {
|
||||||
} else {
|
} else {
|
||||||
Files.createDirectories(file.getParent());
|
Files.createDirectories(file.getParent());
|
||||||
try (OutputStream outputStream = Files.newOutputStream(file);
|
try (OutputStream outputStream = Files.newOutputStream(file);
|
||||||
HashingOutputStream hashingStream = new HashingOutputStream(outputStream, file, null, hashBuilder);
|
HashingOutputStream out = new HashingOutputStream(outputStream, file, hashBuilder)) {
|
||||||
BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(hashingStream)) {
|
IOUtils.copy(zipFile.getInputStream(entry), out);
|
||||||
IOUtils.copy(zipFile.getInputStream(entry), bufferedOutputStream);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,44 +0,0 @@
|
||||||
/*
|
|
||||||
A simple backup mod for Fabric
|
|
||||||
Copyright (C) 2020 Szum123321
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.szum123321.textile_backup.mixin;
|
|
||||||
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
|
||||||
import net.szum123321.textile_backup.core.LivingServer;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
|
||||||
import org.spongepowered.asm.mixin.Unique;
|
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|
||||||
|
|
||||||
@Mixin(MinecraftServer.class)
|
|
||||||
public class MinecraftServerMixin implements LivingServer {
|
|
||||||
@Unique
|
|
||||||
private boolean isAlive = true;
|
|
||||||
|
|
||||||
@Inject(method = "shutdown", at = @At("TAIL"))
|
|
||||||
public void onFinalWorldSave(CallbackInfo ci) {
|
|
||||||
isAlive = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Unique
|
|
||||||
@Override
|
|
||||||
public boolean isAlive() {
|
|
||||||
return isAlive;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -4,7 +4,6 @@
|
||||||
"compatibilityLevel": "JAVA_16",
|
"compatibilityLevel": "JAVA_16",
|
||||||
"mixins": [
|
"mixins": [
|
||||||
"DedicatedServerWatchdogMixin",
|
"DedicatedServerWatchdogMixin",
|
||||||
"MinecraftServerMixin",
|
|
||||||
"MinecraftServerSessionAccessor"
|
"MinecraftServerSessionAccessor"
|
||||||
],
|
],
|
||||||
"client": [
|
"client": [
|
||||||
|
|
Loading…
Reference in New Issue