Namespace support in old schematic command

Changes to be committed:
	modified:   src/main/java/org/dimdev/dimdoors/command/SchematicCommand.java
This commit is contained in:
SD 2020-09-26 14:30:46 +05:30
parent 88210b1965
commit b204259fe1
No known key found for this signature in database
GPG key ID: E36B57EE08544BC5

View file

@ -5,6 +5,7 @@ import java.io.InputStream;
import org.dimdev.dimcore.schematic.Schematic; import org.dimdev.dimcore.schematic.Schematic;
import org.dimdev.dimcore.schematic.SchematicConverter; import org.dimdev.dimcore.schematic.SchematicConverter;
import org.dimdev.dimdoors.command.arguments.SchematicNamespaceArgumentType;
import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.StringArgumentType; import com.mojang.brigadier.arguments.StringArgumentType;
@ -19,13 +20,14 @@ public class SchematicCommand {
public static void register(CommandDispatcher<ServerCommandSource> dispatcher) { public static void register(CommandDispatcher<ServerCommandSource> dispatcher) {
dispatcher.register(literal("schematicold") dispatcher.register(literal("schematicold")
.then(literal("place") .then(literal("place")
.then(argument("namespace", new SchematicNamespaceArgumentType())
.then(argument("schematic_name", StringArgumentType.string()) .then(argument("schematic_name", StringArgumentType.string())
.executes(ctx -> { .executes(ctx -> {
SchematicConverter.reloadConversions(); SchematicConverter.reloadConversions();
ServerPlayerEntity player = ctx.getSource().getPlayer(); ServerPlayerEntity player = ctx.getSource().getPlayer();
String id = StringArgumentType.getString(ctx, "schematic_name"); String id = StringArgumentType.getString(ctx, "schematic_name");
String ns = SchematicNamespaceArgumentType.getValue(ctx, "namespace");
try (InputStream in = SchematicCommand.class.getResourceAsStream("/data/dimdoors/pockets/schematic/ruins/" + id + ".schem")) { try (InputStream in = SchematicCommand.class.getResourceAsStream("/data/dimdoors/pockets/schematic/" + ns + "/" + id + ".schem")) {
Schematic.fromTag(NbtIo.readCompressed(in)) Schematic.fromTag(NbtIo.readCompressed(in))
.place( .place(
player.world, player.world,
@ -44,6 +46,7 @@ public class SchematicCommand {
) )
) )
) )
)
); );
} }
} }