Skip to content
This repository was archived by the owner on May 27, 2023. It is now read-only.

Commit 634bdb8

Browse files
authored
refactor: move to hypera.dev
2 parents b3c06dc + 1741239 commit 634bdb8

File tree

17 files changed

+400
-167
lines changed

17 files changed

+400
-167
lines changed

.github/FUNDING.yml

Lines changed: 0 additions & 1 deletion
This file was deleted.

LICENSE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright © 2022 CrystalGames, SLLCoding <luisjk266@gmail.com>
3+
Copyright (c) 2022 SLLCoding <luisjk266@gmail.com>
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the “Software”), to deal

README.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,17 @@ schematic.write(new FileOutputStream("schematics/my_schematic.schematic"), regio
2929

3030
## Build Tools
3131

32-
/!\ Repository is currently down, cloning the repository will be required until fixed.
33-
3432
### Repository
3533
```xml
3634
<repository>
37-
<id>crystalgames</id>
38-
<url>https://repo.crystalgames.net/snapshots/</url>
35+
<id>hypera-snapshots</id>
36+
<url>https://repo.hypera.dev/snapshots/</url>
3937
</repository>
4038
```
4139
### Dependency
4240
```xml
4341
<dependency>
44-
<groupId>net.crystalgames</groupId>
42+
<groupId>dev.hypera</groupId>
4543
<artifactId>Scaffolding</artifactId>
4644
<version>0.1.1-SNAPSHOT</version>
4745
</dependency>

pom.xml

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,33 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
~ Scaffolding - Schematic library for Minestom
4+
~ Copyright (c) 2022 SLLCoding <luisjk266@gmail.com>
5+
~
6+
~ Permission is hereby granted, free of charge, to any person obtaining a copy
7+
~ of this software and associated documentation files (the “Software”), to deal
8+
~ in the Software without restriction, including without limitation the rights
9+
~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
~ copies of the Software, and to permit persons to whom the Software is
11+
~ furnished to do so, subject to the following conditions:
12+
~
13+
~ The above copyright notice and this permission notice shall be included in
14+
~ all copies or substantial portions of the Software.
15+
~
16+
~ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
~ THE SOFTWARE.
23+
-->
24+
225
<project xmlns="http://maven.apache.org/POM/4.0.0"
326
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
427
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
528
<modelVersion>4.0.0</modelVersion>
629

7-
<groupId>net.crystalgames</groupId>
30+
<groupId>dev.hypera</groupId>
831
<artifactId>Scaffolding</artifactId>
932
<version>0.1.3-SNAPSHOT</version>
1033

@@ -37,12 +60,12 @@
3760

3861
<distributionManagement>
3962
<repository>
40-
<id>crystalgames</id>
41-
<url>https://repo.crystalgames.net/releases/</url>
63+
<id>hypera-releases</id>
64+
<url>https://repo.hypera.dev/releases/</url>
4265
</repository>
4366
<snapshotRepository>
44-
<id>crystalgames</id>
45-
<url>https://repo.crystalgames.net/snapshots/</url>
67+
<id>hypera-snapshots</id>
68+
<url>https://repo.hypera.dev/snapshots/</url>
4669
</snapshotRepository>
4770
</distributionManagement>
4871

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
/*
2+
* Scaffolding - Schematic library for Minestom
3+
* Copyright (c) 2022 SLLCoding <luisjk266@gmail.com>
4+
*
5+
* Permission is hereby granted, free of charge, to any person obtaining a copy
6+
* of this software and associated documentation files (the “Software”), to deal
7+
* in the Software without restriction, including without limitation the rights
8+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
* copies of the Software, and to permit persons to whom the Software is
10+
* furnished to do so, subject to the following conditions:
11+
*
12+
* The above copyright notice and this permission notice shall be included in
13+
* all copies or substantial portions of the Software.
14+
*
15+
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
* THE SOFTWARE.
22+
*/
23+
package dev.hypera.scaffolding;
24+
25+
import java.nio.file.Files;
26+
import java.nio.file.Path;
27+
import kotlin.Pair;
28+
import dev.hypera.scaffolding.schematic.Schematic;
29+
import dev.hypera.scaffolding.schematic.impl.MCEditSchematic;
30+
import dev.hypera.scaffolding.schematic.impl.SpongeSchematic;
31+
import org.jetbrains.annotations.NotNull;
32+
import org.jetbrains.annotations.Nullable;
33+
import org.jglrxavpok.hephaistos.nbt.*;
34+
35+
import java.io.*;
36+
37+
public class Scaffolding {
38+
39+
/**
40+
* Automatically detects the type of schematic and parses the input stream
41+
* @param inputStream Schematic input
42+
* @return parsed schematic
43+
* @throws IOException if the input stream is invalid
44+
* @throws NBTException if the schematic is invalid
45+
*/
46+
public static @Nullable Schematic fromStream(@NotNull InputStream inputStream) throws IOException, NBTException {
47+
NBTReader reader = new NBTReader(inputStream, CompressedProcesser.GZIP);
48+
Pair<String, NBT> pair = reader.readNamed();
49+
NBTCompound nbtTag = (NBTCompound) pair.getSecond();
50+
51+
Schematic schematic = null;
52+
if (nbtTag.contains("Blocks")) schematic = new MCEditSchematic();
53+
else if (nbtTag.contains("Palette")) schematic = new SpongeSchematic();
54+
55+
if (schematic != null) schematic.read(nbtTag);
56+
return schematic;
57+
}
58+
59+
/**
60+
* Automatically detects the type of schematic and parses the file
61+
* @param path Schematic path
62+
* @return parsed schematic
63+
* @throws IOException if the file is invalid
64+
* @throws NBTException if the schematic is invalid
65+
*/
66+
public static @Nullable Schematic fromPath(@NotNull Path path) throws IOException, NBTException {
67+
if (!Files.exists(path)) throw new FileNotFoundException("Invalid Schematic: File does not exist");
68+
return fromStream(Files.newInputStream(path));
69+
}
70+
71+
/**
72+
* Automatically detects the type of schematic and parses the file
73+
* @param file Schematic file
74+
* @return parsed schematic
75+
* @throws IOException if the file is invalid
76+
* @throws NBTException if the schematic is invalid
77+
*/
78+
public static @Nullable Schematic fromFile(@NotNull File file) throws IOException, NBTException {
79+
if (!file.exists()) throw new FileNotFoundException("Invalid Schematic: File does not exist");
80+
return fromStream(new FileInputStream(file));
81+
}
82+
83+
}

src/main/java/net/crystalgames/scaffolding/instance/SchematicChunkLoader.java renamed to src/main/java/dev/hypera/scaffolding/instance/SchematicChunkLoader.java

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,29 @@
1-
package net.crystalgames.scaffolding.instance;
2-
1+
/*
2+
* Scaffolding - Schematic library for Minestom
3+
* Copyright (c) 2022 SLLCoding <luisjk266@gmail.com>
4+
*
5+
* Permission is hereby granted, free of charge, to any person obtaining a copy
6+
* of this software and associated documentation files (the “Software”), to deal
7+
* in the Software without restriction, including without limitation the rights
8+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
* copies of the Software, and to permit persons to whom the Software is
10+
* furnished to do so, subject to the following conditions:
11+
*
12+
* The above copyright notice and this permission notice shall be included in
13+
* all copies or substantial portions of the Software.
14+
*
15+
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
* THE SOFTWARE.
22+
*/
23+
package dev.hypera.scaffolding.instance;
24+
25+
import dev.hypera.scaffolding.schematic.Schematic;
326
import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
4-
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
5-
import net.crystalgames.scaffolding.schematic.Schematic;
627
import net.minestom.server.instance.Chunk;
728
import net.minestom.server.instance.DynamicChunk;
829
import net.minestom.server.instance.IChunkLoader;
@@ -93,8 +114,7 @@ public static class Builder {
93114
private int yOffset;
94115
private int zOffset;
95116

96-
private Builder() {
97-
}
117+
private Builder() {}
98118

99119
/**
100120
* Adds a schematic to this chunk loader.
@@ -138,5 +158,7 @@ private Builder() {
138158
public @NotNull SchematicChunkLoader build() {
139159
return new SchematicChunkLoader(handler, List.copyOf(schematics), xOffset, yOffset, zOffset);
140160
}
161+
141162
}
163+
142164
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
* Scaffolding - Schematic library for Minestom
3+
* Copyright (c) 2022 SLLCoding <luisjk266@gmail.com>
4+
*
5+
* Permission is hereby granted, free of charge, to any person obtaining a copy
6+
* of this software and associated documentation files (the “Software”), to deal
7+
* in the Software without restriction, including without limitation the rights
8+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
* copies of the Software, and to permit persons to whom the Software is
10+
* furnished to do so, subject to the following conditions:
11+
*
12+
* The above copyright notice and this permission notice shall be included in
13+
* all copies or substantial portions of the Software.
14+
*
15+
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
* THE SOFTWARE.
22+
*/
23+
package dev.hypera.scaffolding.region;
24+
25+
import net.minestom.server.coordinate.Point;
26+
import net.minestom.server.coordinate.Pos;
27+
import net.minestom.server.instance.Instance;
28+
import org.jetbrains.annotations.NotNull;
29+
30+
public record Region(@NotNull Instance instance, @NotNull Point lower, @NotNull Point upper) {
31+
32+
public int sizeX() {
33+
return (upper.blockX() - lower.blockX()) + 1;
34+
}
35+
36+
public int sizeY() {
37+
return (upper.blockY() - lower.blockY()) + 1;
38+
}
39+
40+
public int sizeZ() {
41+
return (upper.blockZ() - lower.blockZ()) + 1;
42+
}
43+
44+
public record Block(Pos position, short stateId) {}
45+
46+
}

src/main/java/net/crystalgames/scaffolding/schematic/Schematic.java renamed to src/main/java/dev/hypera/scaffolding/schematic/Schematic.java

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,29 @@
1-
package net.crystalgames.scaffolding.schematic;
1+
/*
2+
* Scaffolding - Schematic library for Minestom
3+
* Copyright (c) 2022 SLLCoding <luisjk266@gmail.com>
4+
*
5+
* Permission is hereby granted, free of charge, to any person obtaining a copy
6+
* of this software and associated documentation files (the “Software”), to deal
7+
* in the Software without restriction, including without limitation the rights
8+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
* copies of the Software, and to permit persons to whom the Software is
10+
* furnished to do so, subject to the following conditions:
11+
*
12+
* The above copyright notice and this permission notice shall be included in
13+
* all copies or substantial portions of the Software.
14+
*
15+
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
* THE SOFTWARE.
22+
*/
23+
package dev.hypera.scaffolding.schematic;
224

3-
import net.crystalgames.scaffolding.region.Region;
25+
import dev.hypera.scaffolding.region.Region;
426
import net.minestom.server.coordinate.Point;
5-
import net.minestom.server.coordinate.Pos;
627
import net.minestom.server.instance.Instance;
728
import net.minestom.server.instance.block.Block;
829
import org.jetbrains.annotations.NotNull;
@@ -42,4 +63,5 @@ default void read(@NotNull InputStream inputStream) throws IOException, NBTExcep
4263
* @param setter the block setter
4364
*/
4465
void apply(@NotNull Block.Setter setter);
66+
4567
}

src/main/java/net/crystalgames/scaffolding/schematic/impl/MCEditSchematic.java renamed to src/main/java/dev/hypera/scaffolding/schematic/impl/MCEditSchematic.java

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,29 @@
1-
package net.crystalgames.scaffolding.schematic.impl;
2-
3-
import net.crystalgames.scaffolding.region.Region;
4-
import net.crystalgames.scaffolding.schematic.Schematic;
1+
/*
2+
* Scaffolding - Schematic library for Minestom
3+
* Copyright (c) 2022 SLLCoding <luisjk266@gmail.com>
4+
*
5+
* Permission is hereby granted, free of charge, to any person obtaining a copy
6+
* of this software and associated documentation files (the “Software”), to deal
7+
* in the Software without restriction, including without limitation the rights
8+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
* copies of the Software, and to permit persons to whom the Software is
10+
* furnished to do so, subject to the following conditions:
11+
*
12+
* The above copyright notice and this permission notice shall be included in
13+
* all copies or substantial portions of the Software.
14+
*
15+
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
* THE SOFTWARE.
22+
*/
23+
package dev.hypera.scaffolding.schematic.impl;
24+
25+
import dev.hypera.scaffolding.schematic.Schematic;
26+
import dev.hypera.scaffolding.region.Region;
527
import net.minestom.server.coordinate.Point;
628
import net.minestom.server.coordinate.Pos;
729
import net.minestom.server.instance.Instance;
@@ -182,4 +204,5 @@ public void apply(Block.@NotNull Setter setter) {
182204
}
183205
}
184206
}
207+
185208
}

src/main/java/net/crystalgames/scaffolding/schematic/impl/SpongeSchematic.java renamed to src/main/java/dev/hypera/scaffolding/schematic/impl/SpongeSchematic.java

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,29 @@
1-
package net.crystalgames.scaffolding.schematic.impl;
2-
3-
import net.crystalgames.scaffolding.region.Region;
4-
import net.crystalgames.scaffolding.schematic.Schematic;
1+
/*
2+
* Scaffolding - Schematic library for Minestom
3+
* Copyright (c) 2022 SLLCoding <luisjk266@gmail.com>
4+
*
5+
* Permission is hereby granted, free of charge, to any person obtaining a copy
6+
* of this software and associated documentation files (the “Software”), to deal
7+
* in the Software without restriction, including without limitation the rights
8+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
* copies of the Software, and to permit persons to whom the Software is
10+
* furnished to do so, subject to the following conditions:
11+
*
12+
* The above copyright notice and this permission notice shall be included in
13+
* all copies or substantial portions of the Software.
14+
*
15+
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
* THE SOFTWARE.
22+
*/
23+
package dev.hypera.scaffolding.schematic.impl;
24+
25+
import dev.hypera.scaffolding.schematic.Schematic;
26+
import dev.hypera.scaffolding.region.Region;
527
import net.minestom.server.coordinate.Point;
628
import net.minestom.server.coordinate.Pos;
729
import net.minestom.server.instance.Instance;
@@ -218,7 +240,7 @@ public int getOffsetZ() {
218240
}
219241

220242
@Override
221-
public void apply(Block.@NotNull Setter setter) {
243+
public void apply(@NotNull Block.Setter setter) {
222244
for (Region.Block block : regionBlocks) {
223245
Pos pos = block.position();
224246
Block minestomBlock = Block.fromStateId(block.stateId());

0 commit comments

Comments
 (0)