Skip to content

Commit 9c1648c

Browse files
committed
v12.1.0 Candidate - MC v1.21.4 Support
* Added XItemFlag. * Added XPatternType. (Fixes #315) * Fixed XMaterial.BLACK_DYE for v1.8 (Fixes #313) * Fixed an error caused by XSound in older versions (issue with pulling system values) * Fixed an issue with XPotion name matching system. * MethodMemberHandles are now more lenient when it comes to public methods that are in superclasses of the target class. * Unit testing is now improved.
1 parent a3983fe commit 9c1648c

29 files changed

+1520
-636
lines changed

CONTRIBUTING.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,11 @@ mvn clean package -Ptester,latest
3636
3737
### Rules
3838

39-
* One of the main principles of XSeries is that each utility should be independent except the ones that cannot be
39+
* ~~One of the main principles of XSeries is that each utility should be independent except the ones that cannot be
4040
independent. Functions such as the common ISFLAT boolean check should not depend on XMaterial's isNewVersion() except
41-
XBlock which is intended, since it already uses XMaterial for materials. Same for Particles and ParticleDisplay.
41+
XBlock which is intended, since it already uses XMaterial for materials. Same for Particles and ParticleDisplay.~~
42+
This is no longer the case because of Minecraft's new registry system. It's going to make a lot of boilerplate code
43+
if we decide to stick to this principle.
4244
* Only Java 8 should be used. All the functions in the latest version of Java 8 can be used.
4345
* Make sure the utility works on different Minecraft server versions.
4446
* Use method and variable names that make sense and are related to the context.

pom.xml

Lines changed: 177 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -92,15 +92,19 @@
9292
<spigotVersion>1.21.4-R0.1-SNAPSHOT</spigotVersion>
9393
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
9494
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
95+
<jopt>5.0.4</jopt>
96+
<testVer/>
97+
<testJavaPath/>
98+
<testJava>21</testJava>
9599
</properties>
96100

97101
<dependencies>
98-
<!-- <dependency>-->
99-
<!-- <groupId>com.mojang</groupId>-->
100-
<!-- <artifactId>authlib</artifactId>-->
101-
<!-- <version>6.0.55</version>-->
102-
<!-- <scope>provided</scope>-->
103-
<!-- </dependency>-->
102+
<!-- <dependency>-->
103+
<!-- <groupId>com.mojang</groupId>-->
104+
<!-- <artifactId>authlib</artifactId>-->
105+
<!-- <version>6.0.55</version>-->
106+
<!-- <scope>provided</scope>-->
107+
<!-- </dependency>-->
104108
<dependency>
105109
<groupId>org.spigotmc</groupId>
106110
<artifactId>spigot</artifactId>
@@ -219,7 +223,7 @@
219223
<plugin>
220224
<groupId>org.apache.maven.plugins</groupId>
221225
<artifactId>maven-surefire-plugin</artifactId>
222-
<version>3.2.5</version>
226+
<version>3.5.2</version>
223227
<configuration>
224228
<!--<failIfNoTests>true</failIfNoTests>-->
225229
<!-- <skipTests>true</skipTests>-->
@@ -231,8 +235,74 @@
231235
<includes>
232236
<include>**/*.java</include>
233237
</includes>
238+
<!-- Any way to do this without exposing the path and without using a toolchain? -->
239+
<!-- https://maven.apache.org/surefire/maven-surefire-plugin/examples/toolchains.html -->
240+
<!-- <jvm>${testJavaPath}</jvm>-->
241+
<!-- You can also use the following argument from the cmd line: -->
242+
<!-- <dash><dash>toolchains "\.m2\toolchains.xml" -->
243+
<jdkToolchain>
244+
<version>${testJava}</version>
245+
</jdkToolchain>
234246
</configuration>
235247
</plugin>
248+
<plugin>
249+
<!-- mvn exec:exec@compile exec:exec@test -->
250+
<!-- Doesn't work... Failed to execute goal org.codehaus.mojo:exec-maven-plugin:3.5.0:exec (default-cli) on project XSeries: Command execution failed.: Cannot run program "mvn" (in directory): CreateProcess error=2, The system cannot find the file specified(default-cli) on project XSeries: Command execution failed.: Cannot run program "mvn" (in directory): CreateProcess error=2, The system cannot find the file specified -->
251+
<groupId>org.codehaus.mojo</groupId>
252+
<artifactId>exec-maven-plugin</artifactId>
253+
<version>3.5.0</version>
254+
<configuration>
255+
<!-- <executable>IntelliJ\plugins\maven\lib\maven3\bin\mvn.cmd</executable>-->
256+
<executable>mvn</executable>
257+
</configuration>
258+
259+
<executions>
260+
<execution>
261+
<id>compile</id>
262+
<phase>none</phase>
263+
<goals>
264+
<goal>exec</goal>
265+
</goals>
266+
<configuration>
267+
<arguments>
268+
<argument>compiler:compile</argument>
269+
<argument>compiler:testCompile</argument>
270+
</arguments>
271+
</configuration>
272+
</execution>
273+
<execution>
274+
<id>test</id>
275+
<phase>none</phase>
276+
<!-- Configuring the correct phase here, which would be 'test' causes this to get run twice. -->
277+
<!-- https://stackoverflow.com/questions/4253700/maven-phase-executing-twice -->
278+
279+
<goals>
280+
<goal>exec</goal>
281+
</goals>
282+
<configuration>
283+
<arguments>
284+
<argument>test</argument>
285+
<argument>-Ptester,${testVer}</argument>
286+
</arguments>
287+
</configuration>
288+
</execution>
289+
<execution>
290+
<!-- This won't properly set the propery for some reason: -->
291+
<!-- mvn exec:exec@everything -DtestVer=8 -->
292+
<id>everything</id>
293+
<phase>none</phase>
294+
<goals>
295+
<goal>exec</goal>
296+
</goals>
297+
<configuration>
298+
<arguments>
299+
<argument>exec:exec@compile</argument>
300+
<argument>exec:exec@test</argument>
301+
</arguments>
302+
</configuration>
303+
</execution>
304+
</executions>
305+
</plugin>
236306
</plugins>
237307

238308
<testSourceDirectory>src/test</testSourceDirectory>
@@ -257,15 +327,61 @@
257327
</dependencies>
258328
<build>
259329
<plugins>
330+
<plugin>
331+
<groupId>org.apache.maven.plugins</groupId>
332+
<artifactId>maven-toolchains-plugin</artifactId>
333+
<version>3.2.0</version>
334+
<executions>
335+
<execution>
336+
<phase>validate</phase>
337+
<goals>
338+
<goal>toolchain</goal>
339+
</goals>
340+
</execution>
341+
</executions>
342+
<configuration>
343+
<toolchains>
344+
<jdk>
345+
<version>[${testJava}]</version>
346+
</jdk>
347+
</toolchains>
348+
</configuration>
349+
</plugin>
350+
351+
<!-- <plugin>-->
352+
<!-- &lt;!&ndash; For cleaning the tests folder that the server files are generated in &ndash;&gt;-->
353+
<!-- <artifactId>maven-clean-plugin</artifactId>-->
354+
<!-- <version>3.4.0</version>-->
355+
<!-- <executions>-->
356+
<!-- <execution>-->
357+
<!-- <id>auto-clean</id>-->
358+
<!-- <phase>initialize</phase>-->
359+
<!-- <goals>-->
360+
<!-- <goal>clean</goal>-->
361+
<!-- </goals>-->
362+
<!-- <configuration>-->
363+
<!-- <excludeDefaultDirectories>true</excludeDefaultDirectories>-->
364+
<!-- <filesets>-->
365+
<!-- <fileset>-->
366+
<!-- <directory>target/tests</directory>-->
367+
<!-- </fileset>-->
368+
<!-- </filesets>-->
369+
<!-- </configuration>-->
370+
<!-- </execution>-->
371+
<!-- </executions>-->
372+
<!-- </plugin>-->
260373
<plugin>
261374
<groupId>org.apache.maven.plugins</groupId>
262375
<artifactId>maven-compiler-plugin</artifactId>
263376
<version>3.13.0</version>
264377
<configuration>
265378
<encoding>UTF-8</encoding>
266379
<proc>none</proc>
267-
<source>21</source>
268-
<target>21</target>
380+
<source>1.8</source>
381+
<target>1.8</target>
382+
<testSource>1.8</testSource>
383+
<testTarget>1.8</testTarget>
384+
<useIncrementalCompilation>false</useIncrementalCompilation>
269385
</configuration>
270386
<executions>
271387
<execution>
@@ -290,34 +406,47 @@
290406
<id>latest</id>
291407
<properties>
292408
<nms>21_R0</nms>
409+
<testJava>21</testJava>
410+
</properties>
411+
</profile>
412+
<profile>
413+
<id>21</id>
414+
<properties>
415+
<nms>21_R0</nms>
416+
<spigotVersion>1.21.1-R0.1-SNAPSHOT</spigotVersion>
417+
<testJava>21</testJava>
293418
</properties>
294419
</profile>
295420
<profile>
296421
<id>20</id>
297422
<properties>
298423
<nms>20_R0</nms>
299424
<spigotVersion>1.20.6-R0.1-SNAPSHOT</spigotVersion>
425+
<testJava>21</testJava>
300426
</properties>
301427
</profile>
302428
<profile>
303429
<id>19</id>
304430
<properties>
305431
<nms>19_R1</nms>
306432
<spigotVersion>1.19.4-R0.1-SNAPSHOT</spigotVersion>
433+
<testJava>21</testJava>
307434
</properties>
308435
</profile>
309436
<profile>
310437
<id>18</id>
311438
<properties>
312439
<nms>18_R1</nms>
313440
<spigotVersion>1.18.2-R0.1-SNAPSHOT</spigotVersion>
441+
<testJava>21</testJava>
314442
</properties>
315443
</profile>
316444
<profile>
317445
<id>17</id>
318446
<properties>
319447
<nms>17_R1</nms>
320448
<spigotVersion>1.17.1-R0.1-SNAPSHOT</spigotVersion>
449+
<testJava>21</testJava>
321450
</properties>
322451
</profile>
323452
<profile>
@@ -326,7 +455,46 @@
326455
<properties>
327456
<nms>16_R3</nms>
328457
<spigotVersion>1.16.5-R0.1-SNAPSHOT</spigotVersion>
458+
<testJava>11</testJava>
459+
</properties>
460+
</profile>
461+
<profile>
462+
<id>15</id>
463+
<properties>
464+
<nms>15_R3</nms>
465+
<spigotVersion>1.15.2-R0.1-SNAPSHOT</spigotVersion>
466+
<testJava>11</testJava>
329467
</properties>
330468
</profile>
469+
<profile>
470+
<id>12</id>
471+
<properties>
472+
<nms>12_R3</nms>
473+
<spigotVersion>1.12.2-R0.1-SNAPSHOT</spigotVersion>
474+
<testJava>1.8</testJava>
475+
</properties>
476+
<dependencies>
477+
<dependency>
478+
<groupId>net.sf.jopt-simple</groupId>
479+
<artifactId>jopt-simple</artifactId>
480+
<version>${jopt}</version>
481+
</dependency>
482+
</dependencies>
483+
</profile>
484+
<profile>
485+
<id>8</id>
486+
<properties>
487+
<nms>8_R3</nms>
488+
<spigotVersion>1.8.8-R0.1-SNAPSHOT</spigotVersion>
489+
<testJava>1.8</testJava>
490+
</properties>
491+
<dependencies>
492+
<dependency>
493+
<groupId>net.sf.jopt-simple</groupId>
494+
<artifactId>jopt-simple</artifactId>
495+
<version>${jopt}</version>
496+
</dependency>
497+
</dependencies>
498+
</profile>
331499
</profiles>
332500
</project>

src/main/java/com/cryptomorin/xseries/NoteBlockMusic.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ public void setPitch(Note note) {
630630

631631
@Override
632632
public void play(Player player, Supplier<Location> location, boolean playAtLocation) {
633-
org.bukkit.Sound bukkitSound = sound.parseSound();
633+
org.bukkit.Sound bukkitSound = sound.get();
634634
for (int repeat = restatement; repeat > 0; repeat--) {
635635
Location finalLocation = location.get();
636636
if (bukkitSound != null) {

src/main/java/com/cryptomorin/xseries/XBiome.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
import com.cryptomorin.xseries.base.XModule;
2525
import com.cryptomorin.xseries.base.XRegistry;
26+
import com.cryptomorin.xseries.base.annotations.XInfo;
2627
import org.bukkit.Chunk;
2728
import org.bukkit.Location;
2829
import org.bukkit.Registry;
@@ -140,7 +141,11 @@ public final class XBiome extends XModule<XBiome, Biome> {
140141
TAIGA_HILLS = std("TAIGA_HILLS"),
141142
TAIGA_MOUNTAINS = std(WINDSWEPT_FOREST, "TAIGA_MOUNTAINS", "MUTATED_TAIGA");
142143

143-
// CUSTOM = std("CUSTOM"), Since 1.21.3-1.21.3 ??? why add it in the first place?
144+
/**
145+
* Why add it in the first place if it was removed in a few builds?
146+
*/
147+
@XInfo(since = "1.21.3", removedSince = "1.21.3")
148+
public static final XBiome CUSTOM = std("CUSTOM");
144149

145150
/**
146151
* Removed from 1.18

src/main/java/com/cryptomorin/xseries/XBlock.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ public static boolean setType(@NotNull Block block, @Nullable XMaterial material
248248
XMaterial smartConversion = ITEM_TO_BLOCK.get(material);
249249
if (smartConversion != null) material = smartConversion;
250250

251-
Material parsedMat = material.parseMaterial();
251+
Material parsedMat = material.get();
252252
if (parsedMat == null) return false;
253253

254254
String parsedName = parsedMat.name();

0 commit comments

Comments
 (0)