mirror of
https://github.com/bloodmc/GriefDefender.git
synced 2024-11-12 10:44:42 +01:00
Fix sponge schematics not loading at startup.
This commit is contained in:
parent
ef3659b33e
commit
29824075e2
@ -30,6 +30,7 @@
|
||||
import com.griefdefender.api.claim.ClaimSchematic;
|
||||
import com.griefdefender.internal.util.VecHelper;
|
||||
import org.spongepowered.api.data.DataContainer;
|
||||
import org.spongepowered.api.data.DataQuery;
|
||||
import org.spongepowered.api.data.persistence.DataFormats;
|
||||
import org.spongepowered.api.data.persistence.DataTranslators;
|
||||
import org.spongepowered.api.world.BlockChangeFlags;
|
||||
@ -55,10 +56,10 @@ public class GDClaimSchematic implements ClaimSchematic {
|
||||
private final Instant dateCreated;
|
||||
|
||||
// Used during server startup to load schematic
|
||||
public GDClaimSchematic(Claim claim, Schematic schematic, String name) {
|
||||
public GDClaimSchematic(Claim claim, Schematic schematic, String fileName) {
|
||||
this.claim = claim;
|
||||
this.schematic = schematic;
|
||||
this.name = name;
|
||||
this.name = schematic.getMetadata().getString(DataQuery.of(".", Schematic.METADATA_NAME)).orElse(fileName);
|
||||
this.origin = claim.getLesserBoundaryCorner();
|
||||
this.dateCreated = Instant.now();
|
||||
}
|
||||
@ -169,7 +170,7 @@ public Optional<ClaimSchematic> build() {
|
||||
} catch (IOException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
File outputFile = schematicPath.resolve(name + ".schematic").toFile();
|
||||
File outputFile = schematicPath.resolve(this.name + ".schematic").toFile();
|
||||
try {
|
||||
DataFormats.NBT.writeTo(new GZIPOutputStream(new FileOutputStream(outputFile)), schematicData);
|
||||
} catch (Exception e) {
|
||||
|
@ -33,7 +33,6 @@
|
||||
import com.griefdefender.api.claim.Claim;
|
||||
import com.griefdefender.api.claim.ClaimResult;
|
||||
import com.griefdefender.api.claim.ClaimResultType;
|
||||
import com.griefdefender.api.permission.option.type.CreateModeType;
|
||||
import com.griefdefender.api.permission.option.type.CreateModeTypes;
|
||||
import com.griefdefender.cache.MessageCache;
|
||||
import com.griefdefender.claim.GDClaim;
|
||||
@ -49,7 +48,6 @@
|
||||
import com.griefdefender.internal.provider.worldedit.cui.event.MultiSelectionGridEvent;
|
||||
import com.griefdefender.internal.provider.worldedit.cui.event.MultiSelectionPointEvent;
|
||||
import com.griefdefender.internal.util.BlockUtil;
|
||||
import com.griefdefender.storage.FileStorage;
|
||||
import com.griefdefender.util.PlayerUtil;
|
||||
import com.sk89q.worldedit.IncompleteRegionException;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
@ -72,7 +70,6 @@
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.HashMap;
|
||||
@ -331,18 +328,14 @@ public void loadSchematics(org.spongepowered.api.world.World world) {
|
||||
for (Claim claim : claimWorldManager.getWorldClaims()) {
|
||||
Path path = this.schematicWorldMap.get(claim.getWorldUniqueId()).resolve(claim.getUniqueId().toString());
|
||||
if (!Files.exists(path)) {
|
||||
try {
|
||||
Files.createDirectories(path);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return;
|
||||
continue;
|
||||
}
|
||||
|
||||
File files[] = path.toFile().listFiles();
|
||||
for (File file : files) {
|
||||
DataContainer schematicData = null;
|
||||
Schematic schematic = null;
|
||||
final String fileName = file.getName().replaceFirst("[.][^.]+$", "");
|
||||
try {
|
||||
schematicData = DataFormats.NBT.readFrom(new GZIPInputStream(new FileInputStream(file)));
|
||||
schematic = DataTranslators.SCHEMATIC.translate(schematicData);
|
||||
@ -350,8 +343,8 @@ public void loadSchematics(org.spongepowered.api.world.World world) {
|
||||
e.printStackTrace();
|
||||
continue;
|
||||
}
|
||||
GDClaimSchematic claimSchematic = new GDClaimSchematic(claim, schematic, schematic.METADATA_NAME);
|
||||
((GDClaim) claim).schematics.put(file.getName(), claimSchematic);
|
||||
final GDClaimSchematic claimSchematic = new GDClaimSchematic(claim, schematic, fileName);
|
||||
((GDClaim) claim).schematics.put(fileName, claimSchematic);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user