Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@

import java.io.*;
import java.nio.file.Files;
import java.nio.file.LinkOption;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
import java.util.ArrayList;
import java.util.List;

Expand Down Expand Up @@ -82,6 +84,11 @@ private static void process(final @Nullable Blueprint blueprint, final @NotNull
return;
}

if (!message.player.isCreative())
{
return;
}

Utils.playSuccessSound(message.player);
final BlockState anchor = blueprint.getBlockState(blueprint.getPrimaryBlockOffset());
blueprint.setRotationMirror(message.rotationMirror, message.world);
Expand Down Expand Up @@ -113,14 +120,26 @@ public static void handlePlacement(final BlueprintSyncMessage blueprintSyncMessa
{
ServerFutureProcessor.queueBlueprint(new ServerFutureProcessor.BlueprintProcessingData(IOPool.submit(() ->
{
final String packName = Utils.getSafePackName(blueprintSyncMessage.structurePackId);
if (packName.isEmpty() || packName.startsWith("."))
{
return null;
}

final Path blueprintParentPath = new File(".").toPath()
.resolve(BLUEPRINT_FOLDER)
.resolve(CLIENT_FOLDER)
.resolve(player.getUUID().toString())
.resolve(blueprintSyncMessage.structurePackId);
.resolve(packName).normalize();

final Path blueprintPath = blueprintParentPath.resolve(blueprintSyncMessage.blueprintPath).normalize();

if (Files.isSymbolicLink(blueprintPath) || !blueprintPath.startsWith(blueprintParentPath) || blueprintPath.equals(blueprintParentPath) || !blueprintPath.getFileName().toString().endsWith(".blueprint"))
{
return null;
}

final Path blueprintPath = blueprintParentPath.resolve(blueprintSyncMessage.blueprintPath);
final String packId = player.getUUID() + blueprintSyncMessage.structurePackId;
final String packId = player.getUUID() + packName;
blueprintSyncMessage.structurePackId = packId;

try
Expand All @@ -139,7 +158,8 @@ public static void handlePlacement(final BlueprintSyncMessage blueprintSyncMessa
jsonObject.addProperty("name", packId);
jsonObject.addProperty("icon", "");

Files.write(blueprintParentPath.resolve("pack.json"), jsonObject.toString().getBytes());
Files.write(blueprintParentPath.resolve("pack.json"), jsonObject.toString().getBytes(), StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING,
StandardOpenOption.WRITE, LinkOption.NOFOLLOW_LINKS);

final List<String> modList = new ArrayList<>();
for (IModInfo mod : ModList.get().getMods())
Expand Down
Loading