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

Commit fbc3c76

Browse files
author
Shynixn
committed
#97 Upgraded version to release version.
1 parent 4ef7a9b commit fbc3c76

File tree

17 files changed

+127
-50
lines changed

17 files changed

+127
-50
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ RUN ./gradlew build pluginJar --no-daemon
4343
# 4. Launch a minecraft server with jdk17 and plugin
4444
FROM amazoncorretto:17
4545
# Change to the current plugin version present in build.gradle
46-
ENV PLUGIN_VERSION=2.6.0
46+
ENV PLUGIN_VERSION=2.7.0
4747
# Change to the server version you want to test.
4848
ENV SERVER_VERSION=spigot-1.18.2.jar
4949
# Port of the Minecraft Server.

README.md

Lines changed: 80 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@ Support development with a small tip :heart: :coffee:.
3535
<dependency>
3636
<groupId>com.github.shynixn.structureblocklib</groupId>
3737
<artifactId>structureblocklib-bukkit-api</artifactId>
38-
<version>2.6.0</version>
38+
<version>2.7.0</version>
3939
<scope>provided</scope>
4040
</dependency>
4141
```
4242
**Gradle**
4343

4444
```xml
4545
dependencies {
46-
compileOnly("com.github.shynixn.structureblocklib:structureblocklib-bukkit-api:2.6.0")
46+
compileOnly("com.github.shynixn.structureblocklib:structureblocklib-bukkit-api:2.7.0")
4747
}
4848
```
4949

@@ -178,6 +178,78 @@ StructureBlockLibApi.INSTANCE
178178
.onResult(e -> plugin.getLogger().log(Level.INFO, ChatColor.GREEN + "Loaded structure 'mystructure'."));
179179
```
180180

181+
#### Load a structure on your server and manipulate the entities
182+
183+
```java
184+
// Minimal configuration
185+
Plugin plugin;
186+
187+
StructureBlockLibApi.INSTANCE
188+
.loadStructure(plugin)
189+
.at(new Location(Bukkit.getWorld("world"), 100, 100, 100))
190+
.includeEntities(true)
191+
.onProcessEntity(part -> {
192+
// onProcessEntity is called for every entity before it is placed.
193+
if (part.getEntity().isPresent()) {
194+
if (part.getEntity().get().getType() == EntityType.COW) {
195+
// When the entity in the structure file equals COW, we do not want to place it -> return false.
196+
return false;
197+
}
198+
}
199+
200+
// When the entity in the structure file is something else, we do want to place it -> return true.
201+
return true;
202+
})
203+
.loadFromWorld("world", "me", "mystructure")
204+
.onException(e -> plugin.getLogger().log(Level.SEVERE, "Failed to load structure.", e))
205+
.onResult(e -> plugin.getLogger().log(Level.INFO, ChatColor.GREEN + "Loaded structure 'mystructure'."));
206+
```
207+
208+
#### Load entities in memory and iterate them
209+
210+
```java
211+
List<StructureEntity<Entity, Location>> entities = new ArrayList<>();
212+
StructureBlockLibApi.INSTANCE
213+
.loadStructure(plugin)
214+
.at(player.getLocation()) // We do need an existing world.
215+
.includeEntities(false) // Do not place entities.
216+
.includeBlocks(false) // Do not place blocks.
217+
.onProcessEntity(entity -> {
218+
entities.add(entity);
219+
return false;
220+
})
221+
.loadFromWorld("world", "me", "mystructure")
222+
.onException(c -> c.printStackTrace())
223+
.onResult(e -> {
224+
for (StructureEntity<Entity, Location> structureEntity : entities) {
225+
// Do something with the entities
226+
structureEntity.spawnEntity(player.getLocation().add(-3, 0, 0));
227+
}
228+
});
229+
```
230+
231+
#### Load blocks in memory and iterate them
232+
233+
```java
234+
List<StructurePlacePart<Block, World>> blocks = new ArrayList<>();
235+
StructureBlockLibApi.INSTANCE
236+
.loadStructure(plugin)
237+
.at(player.getLocation()) // We do need an existing world.
238+
.includeEntities(false) // Do not place entities.
239+
.includeBlocks(false) // Do not place blocks.
240+
.onProcessBlock(part -> {
241+
blocks.add(part);
242+
return false;
243+
})
244+
.loadFromWorld("world", "me", "mystructure")
245+
.onException(c -> c.printStackTrace())
246+
.onResult(e -> {
247+
for (StructurePlacePart<Block, World> structureBlock : blocks) {
248+
// Do something with the blocks
249+
System.out.println(structureBlock.getSourceBlock().getType());
250+
}
251+
});
252+
```
181253

182254
##### Modify and use an existing structure block
183255
```java
@@ -205,8 +277,8 @@ structureBlock.update();
205277
**plugin.yml**
206278
```yaml
207279
libraries:
208-
- com.github.shynixn.structureblocklib:structureblocklib-bukkit-api:2.6.0
209-
- com.github.shynixn.structureblocklib:structureblocklib-bukkit-core:2.6.0
280+
- com.github.shynixn.structureblocklib:structureblocklib-bukkit-api:2.7.0
281+
- com.github.shynixn.structureblocklib:structureblocklib-bukkit-core:2.7.0
210282
```
211283
212284
### For version < 1.17
@@ -225,22 +297,22 @@ go with the option above instead. There are several tutorials on spigotmc.org.
225297
<dependency>
226298
<groupId>com.github.shynixn.structureblocklib</groupId>
227299
<artifactId>structureblocklib-bukkit-api</artifactId>
228-
<version>2.6.0</version>
300+
<version>2.7.0</version>
229301
<scope>compile</scope>
230302
</dependency>
231303
<dependency>
232304
<groupId>com.github.shynixn.structureblocklib</groupId>
233305
<artifactId>structureblocklib-bukkit-core</artifactId>
234-
<version>2.6.0</version>
306+
<version>2.7.0</version>
235307
<scope>compile</scope>
236308
</dependency>
237309
```
238310
**Gradle**
239311

240312
```xml
241313
dependencies {
242-
implementation("com.github.shynixn.structureblocklib:structureblocklib-bukkit-api:2.6.0")
243-
implementation("com.github.shynixn.structureblocklib:structureblocklib-bukkit-core:2.6.0")
314+
implementation("com.github.shynixn.structureblocklib:structureblocklib-bukkit-api:2.7.0")
315+
implementation("com.github.shynixn.structureblocklib:structureblocklib-bukkit-core:2.7.0")
244316
}
245317
```
246318

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ tasks.register("printVersion") {
4444

4545
subprojects {
4646
group 'com.github.shynixn.structureblocklib'
47-
version '2.6.0'
47+
version '2.7.0'
4848

4949
apply plugin: 'kotlin-platform-jvm'
5050
apply plugin: 'signing'

structureblocklib-bukkit-core/bukkit-nms-109R2/src/test/java/integrationtest/CraftStructureBlockIT.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,16 +146,16 @@ private CraftStructureBlock createWithDependencies(ProxyService proxyService, Ti
146146

147147
StructureWorldService worldService = new MockedStructureWorldService();
148148
StructureSerializationService serializationService = new StructureSerializationServiceImpl();
149-
StructureLoaderAbstract<Location, Vector, Block, World> structureLoader = new StructureLoaderAbstractImpl<>(proxyService, serializationService, worldService);
149+
StructureLoaderAbstract<Location, Vector, Block,org.bukkit.entity.Entity, World> structureLoader = new StructureLoaderAbstractImpl<>(proxyService, serializationService, worldService);
150150
StructureSaverAbstract<Location, Vector> structureSaver = new StructureSaverAbstractImpl<>(proxyService, serializationService, worldService);
151-
StructureBlockAbstractImpl<Location, Vector, Block, World> vector = new StructureBlockAbstractImpl<>(proxyService, structureLoader, structureSaver);
151+
StructureBlockAbstractImpl<Location, Vector, Block,org.bukkit.entity.Entity, World> vector = new StructureBlockAbstractImpl<>(proxyService, structureLoader, structureSaver);
152152
TypeConversionService conversionService = new TypeConversionServiceImpl();
153153

154154
return new WrappedCraftStructureBlock(vector, conversionService, block);
155155
}
156156

157157
private static class WrappedCraftStructureBlock extends CraftStructureBlock {
158-
public WrappedCraftStructureBlock(StructureBlockAbstractImpl<Location, Vector, Block, World> structure, TypeConversionService conversionService, Block block) {
158+
public WrappedCraftStructureBlock(StructureBlockAbstractImpl<Location, Vector, Block,org.bukkit.entity.Entity, World> structure, TypeConversionService conversionService, Block block) {
159159
super(structure, conversionService, block);
160160
}
161161

structureblocklib-bukkit-core/bukkit-nms-110R1/src/test/java/integrationtest/CraftStructureBlockIT.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,16 +154,16 @@ private CraftStructureBlock createWithDependencies(ProxyService proxyService, Ti
154154

155155
StructureWorldService worldService = new MockedStructureWorldService();
156156
StructureSerializationService serializationService = new StructureSerializationServiceImpl();
157-
StructureLoaderAbstract<Location, Vector, Block, World> structureLoader = new StructureLoaderAbstractImpl<>(proxyService, serializationService, worldService);
157+
StructureLoaderAbstract<Location, Vector, Block,org.bukkit.entity.Entity, World> structureLoader = new StructureLoaderAbstractImpl<>(proxyService, serializationService, worldService);
158158
StructureSaverAbstract<Location, Vector> structureSaver = new StructureSaverAbstractImpl<>(proxyService, serializationService, worldService);
159-
StructureBlockAbstractImpl<Location, Vector, Block, World> vector = new StructureBlockAbstractImpl<>(proxyService, structureLoader, structureSaver);
159+
StructureBlockAbstractImpl<Location, Vector, Block,org.bukkit.entity.Entity, World> vector = new StructureBlockAbstractImpl<>(proxyService, structureLoader, structureSaver);
160160
TypeConversionService conversionService = new TypeConversionServiceImpl();
161161

162162
return new WrappedCraftStructureBlock(vector, conversionService, block);
163163
}
164164

165165
private static class WrappedCraftStructureBlock extends CraftStructureBlock {
166-
public WrappedCraftStructureBlock(StructureBlockAbstractImpl<Location, Vector, Block, World> structure, TypeConversionService conversionService, Block block) {
166+
public WrappedCraftStructureBlock(StructureBlockAbstractImpl<Location, Vector, Block,org.bukkit.entity.Entity, World> structure, TypeConversionService conversionService, Block block) {
167167
super(structure, conversionService, block);
168168
}
169169

structureblocklib-bukkit-core/bukkit-nms-111R1/src/test/java/integrationtest/CraftStructureBlockIT.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,16 +154,16 @@ private CraftStructureBlock createWithDependencies(ProxyService proxyService, Ti
154154

155155
StructureWorldService worldService = new MockedStructureWorldService();
156156
StructureSerializationService serializationService = new StructureSerializationServiceImpl();
157-
StructureLoaderAbstract<Location, Vector, Block, World> structureLoader = new StructureLoaderAbstractImpl<>(proxyService, serializationService, worldService);
157+
StructureLoaderAbstract<Location, Vector, Block,org.bukkit.entity.Entity, World> structureLoader = new StructureLoaderAbstractImpl<>(proxyService, serializationService, worldService);
158158
StructureSaverAbstract<Location, Vector> structureSaver = new StructureSaverAbstractImpl<>(proxyService, serializationService, worldService);
159-
StructureBlockAbstractImpl<Location, Vector, Block, World> vector = new StructureBlockAbstractImpl<>(proxyService, structureLoader, structureSaver);
159+
StructureBlockAbstractImpl<Location, Vector, Block,org.bukkit.entity.Entity, World> vector = new StructureBlockAbstractImpl<>(proxyService, structureLoader, structureSaver);
160160
TypeConversionService conversionService = new TypeConversionServiceImpl();
161161

162162
return new WrappedCraftStructureBlock(vector, conversionService, block);
163163
}
164164

165165
private static class WrappedCraftStructureBlock extends CraftStructureBlock {
166-
public WrappedCraftStructureBlock(StructureBlockAbstractImpl<Location, Vector, Block, World> structure, TypeConversionService conversionService, Block block) {
166+
public WrappedCraftStructureBlock(StructureBlockAbstractImpl<Location, Vector, Block,org.bukkit.entity.Entity, World> structure, TypeConversionService conversionService, Block block) {
167167
super(structure, conversionService, block);
168168
}
169169

structureblocklib-bukkit-core/bukkit-nms-112R1/src/test/java/integrationtest/CraftStructureBlockIT.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,16 +154,16 @@ private CraftStructureBlock createWithDependencies(ProxyService proxyService, Ti
154154

155155
StructureWorldService worldService = new MockedStructureWorldService();
156156
StructureSerializationService serializationService = new StructureSerializationServiceImpl();
157-
StructureLoaderAbstract<Location, Vector, Block, World> structureLoader = new StructureLoaderAbstractImpl<>(proxyService, serializationService, worldService);
157+
StructureLoaderAbstract<Location, Vector, Block,org.bukkit.entity.Entity, World> structureLoader = new StructureLoaderAbstractImpl<>(proxyService, serializationService, worldService);
158158
StructureSaverAbstract<Location, Vector> structureSaver = new StructureSaverAbstractImpl<>(proxyService, serializationService, worldService);
159-
StructureBlockAbstractImpl<Location, Vector, Block, World> vector = new StructureBlockAbstractImpl<>(proxyService, structureLoader, structureSaver);
159+
StructureBlockAbstractImpl<Location, Vector, Block,org.bukkit.entity.Entity, World> vector = new StructureBlockAbstractImpl<>(proxyService, structureLoader, structureSaver);
160160
TypeConversionService conversionService = new TypeConversionServiceImpl();
161161

162162
return new WrappedCraftStructureBlock(vector, conversionService, block);
163163
}
164164

165165
private static class WrappedCraftStructureBlock extends CraftStructureBlock {
166-
public WrappedCraftStructureBlock(StructureBlockAbstractImpl<Location, Vector, Block, World> structure, TypeConversionService conversionService, Block block) {
166+
public WrappedCraftStructureBlock(StructureBlockAbstractImpl<Location, Vector, Block,org.bukkit.entity.Entity, World> structure, TypeConversionService conversionService, Block block) {
167167
super(structure, conversionService, block);
168168
}
169169

structureblocklib-bukkit-core/bukkit-nms-113R2/src/test/java/integrationtest/CraftStructureBlockIT.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,16 +157,16 @@ private CraftStructureBlock createWithDependencies(ProxyService proxyService, Ti
157157

158158
StructureWorldService worldService = new MockedStructureWorldService();
159159
StructureSerializationService serializationService = new StructureSerializationServiceImpl();
160-
StructureLoaderAbstract<Location, Vector, Block, World> structureLoader = new StructureLoaderAbstractImpl<>(proxyService, serializationService, worldService);
160+
StructureLoaderAbstract<Location, Vector, Block,org.bukkit.entity.Entity, World> structureLoader = new StructureLoaderAbstractImpl<>(proxyService, serializationService, worldService);
161161
StructureSaverAbstract<Location, Vector> structureSaver = new StructureSaverAbstractImpl<>(proxyService, serializationService, worldService);
162-
StructureBlockAbstractImpl<Location, Vector, Block, World> vector = new StructureBlockAbstractImpl<>(proxyService, structureLoader, structureSaver);
162+
StructureBlockAbstractImpl<Location, Vector, Block,org.bukkit.entity.Entity, World> vector = new StructureBlockAbstractImpl<>(proxyService, structureLoader, structureSaver);
163163
TypeConversionService conversionService = new TypeConversionServiceImpl();
164164

165165
return new WrappedCraftStructureBlock(vector, conversionService, block);
166166
}
167167

168168
private static class WrappedCraftStructureBlock extends CraftStructureBlock {
169-
public WrappedCraftStructureBlock(StructureBlockAbstractImpl<Location, Vector, Block, World> structure, TypeConversionService conversionService, Block block) {
169+
public WrappedCraftStructureBlock(StructureBlockAbstractImpl<Location, Vector, Block,org.bukkit.entity.Entity, World> structure, TypeConversionService conversionService, Block block) {
170170
super(structure, conversionService, block);
171171
}
172172

structureblocklib-bukkit-core/bukkit-nms-114R1/src/test/java/integrationtest/CraftStructureBlockIT.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,16 +156,16 @@ private CraftStructureBlock createWithDependencies(ProxyService proxyService, Ti
156156

157157
StructureWorldService worldService = new MockedStructureWorldService();
158158
StructureSerializationService serializationService = new StructureSerializationServiceImpl();
159-
StructureLoaderAbstract<Location, Vector, Block, World> structureLoader = new StructureLoaderAbstractImpl<>(proxyService, serializationService, worldService);
159+
StructureLoaderAbstract<Location, Vector, Block,org.bukkit.entity.Entity, World> structureLoader = new StructureLoaderAbstractImpl<>(proxyService, serializationService, worldService);
160160
StructureSaverAbstract<Location, Vector> structureSaver = new StructureSaverAbstractImpl<>(proxyService, serializationService, worldService);
161-
StructureBlockAbstractImpl<Location, Vector, Block, World> vector = new StructureBlockAbstractImpl<>(proxyService, structureLoader, structureSaver);
161+
StructureBlockAbstractImpl<Location, Vector, Block,org.bukkit.entity.Entity, World> vector = new StructureBlockAbstractImpl<>(proxyService, structureLoader, structureSaver);
162162
TypeConversionService conversionService = new TypeConversionServiceImpl();
163163

164164
return new WrappedCraftStructureBlock(vector, conversionService, block);
165165
}
166166

167167
private static class WrappedCraftStructureBlock extends CraftStructureBlock {
168-
public WrappedCraftStructureBlock(StructureBlockAbstractImpl<Location, Vector, Block, World> structure, TypeConversionService conversionService, Block block) {
168+
public WrappedCraftStructureBlock(StructureBlockAbstractImpl<Location, Vector, Block,org.bukkit.entity.Entity, World> structure, TypeConversionService conversionService, Block block) {
169169
super(structure, conversionService, block);
170170
}
171171

structureblocklib-bukkit-core/bukkit-nms-115R1/src/test/java/integrationtest/CraftStructureBlockIT.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,16 +156,16 @@ private CraftStructureBlock createWithDependencies(ProxyService proxyService, Ti
156156

157157
StructureWorldService worldService = new MockedStructureWorldService();
158158
StructureSerializationService serializationService = new StructureSerializationServiceImpl();
159-
StructureLoaderAbstract<Location, Vector, Block, World> structureLoader = new StructureLoaderAbstractImpl<>(proxyService, serializationService, worldService);
159+
StructureLoaderAbstract<Location, Vector, Block,org.bukkit.entity.Entity, World> structureLoader = new StructureLoaderAbstractImpl<>(proxyService, serializationService, worldService);
160160
StructureSaverAbstract<Location, Vector> structureSaver = new StructureSaverAbstractImpl<>(proxyService, serializationService, worldService);
161-
StructureBlockAbstractImpl<Location, Vector, Block, World> vector = new StructureBlockAbstractImpl<>(proxyService, structureLoader, structureSaver);
161+
StructureBlockAbstractImpl<Location, Vector, Block,org.bukkit.entity.Entity, World> vector = new StructureBlockAbstractImpl<>(proxyService, structureLoader, structureSaver);
162162
TypeConversionService conversionService = new TypeConversionServiceImpl();
163163

164164
return new WrappedCraftStructureBlock(vector, conversionService, block);
165165
}
166166

167167
private static class WrappedCraftStructureBlock extends CraftStructureBlock {
168-
public WrappedCraftStructureBlock(StructureBlockAbstractImpl<Location, Vector, Block, World> structure, TypeConversionService conversionService, Block block) {
168+
public WrappedCraftStructureBlock(StructureBlockAbstractImpl<Location, Vector, Block,org.bukkit.entity.Entity, World> structure, TypeConversionService conversionService, Block block) {
169169
super(structure, conversionService, block);
170170
}
171171

0 commit comments

Comments
 (0)