Skip to content

Commit

Permalink
#33: Add basic untested support for Oraxen v2
Browse files Browse the repository at this point in the history
  • Loading branch information
DerFrZocker committed Apr 20, 2024
1 parent 76ee42f commit fd42e10
Show file tree
Hide file tree
Showing 13 changed files with 400 additions and 39 deletions.
25 changes: 12 additions & 13 deletions custom-ore-generator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,6 @@
<version>${ItemMods.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.th0rgal</groupId>
<artifactId>oraxen</artifactId>
<version>${Oraxen.version}</version>
<classifier>dev</classifier>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.bstats</groupId>
<artifactId>bstats-bukkit</artifactId>
Expand Down Expand Up @@ -226,6 +213,18 @@
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>de.derfrzocker</groupId>
<artifactId>custom-ore-generator-plugin-oraxen-v1</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>de.derfrzocker</groupId>
<artifactId>custom-ore-generator-plugin-oraxen-v2</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
import de.derfrzocker.custom.ore.generator.impl.customdata.FacingCustomData;
import de.derfrzocker.custom.ore.generator.impl.customdata.ItemModsCustomData;
import de.derfrzocker.custom.ore.generator.impl.customdata.NBTTagCustomData;
import de.derfrzocker.custom.ore.generator.impl.customdata.OraxenCustomData;
import de.derfrzocker.custom.ore.generator.impl.customdata.SkullTextureCustomData;
import de.derfrzocker.custom.ore.generator.impl.customdata.TickBlockCustomData;
import de.derfrzocker.custom.ore.generator.impl.customdata.VariantCustomData;
Expand Down Expand Up @@ -101,6 +100,8 @@
import de.derfrzocker.custom.ore.generator.impl.v1_9_R1.oregenerator.MinableGenerator_v1_9_R1;
import de.derfrzocker.custom.ore.generator.impl.v_1_9_R2.CustomOreBlockPopulator_v1_9_R2;
import de.derfrzocker.custom.ore.generator.impl.v_1_9_R2.oregenerator.MinableGenerator_v1_9_R2;
import de.derfrzocker.custom.ore.generator.plugin.oraxen.v1.OraxenCustomData_v1;
import de.derfrzocker.custom.ore.generator.plugin.oraxen.v2.OraxenCustomData_v2;
import de.derfrzocker.custom.ore.generator.utils.InfoUtil;
import de.derfrzocker.custom.ore.generator.utils.RegisterUtil;
import de.derfrzocker.spigot.utils.Config;
Expand Down Expand Up @@ -276,7 +277,8 @@ private void registerStandardCustomDatas(@NotNull final RegisterUtil registerUti
registerUtil.register(Version.v1_13_R1, () -> new DirectionCustomData(BlockFace.EAST, infoFunction));
registerUtil.register(Version.v1_13_R1, () -> new DirectionCustomData(BlockFace.WEST, infoFunction));
registerUtil.register(Version.v1_14_R1, "ItemMods", () -> new ItemModsCustomData(infoFunction));
registerUtil.register(Version.v1_14_R1, "Oraxen", () -> new OraxenCustomData(infoFunction));
registerUtil.register(Version.v1_17_R1, "Oraxen", plugin -> plugin.getDescription().getVersion().startsWith("1."), () -> new OraxenCustomData_v1(infoFunction));
registerUtil.register(Version.v1_18_R1, "Oraxen", plugin -> plugin.getDescription().getVersion().startsWith("2."), () -> new OraxenCustomData_v2(infoFunction));
}

private void initWorldHandler() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import de.derfrzocker.custom.ore.generator.api.OreGenerator;
import de.derfrzocker.custom.ore.generator.api.customdata.CustomData;
import de.derfrzocker.spigot.utils.Version;
import java.util.function.Predicate;
import org.apache.commons.lang.Validate;
import org.bukkit.plugin.Plugin;
import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -123,6 +124,17 @@ public void register(@NotNull final Version minimalVersion, @NotNull final Strin
}
}

public void register(@NotNull final Version minimalVersion, @NotNull final String pluginName, Predicate<Plugin> shouldRegister, @NotNull final CustomDataSupplier customData) {
if (currentVersion.isNewerOrSameThan(minimalVersion)) {
Plugin otherPlugin = this.plugin.getServer().getPluginManager().getPlugin(pluginName);
if (otherPlugin == null || !shouldRegister.test(otherPlugin)) {
return;
}

register(customData.get());
}
}

public void register(@NotNull final Version minimalVersion, @NotNull final Version maximumVersion, @NotNull final CustomDataSupplier customData) {
if (currentVersion.isNewerOrSameThan(minimalVersion)) {
if (currentVersion.isOlderOrSameThan(maximumVersion)) {
Expand Down
13 changes: 0 additions & 13 deletions impl/v1_16_R3-post/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,6 @@
<version>${ItemMods.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.th0rgal</groupId>
<artifactId>oraxen</artifactId>
<version>${Oraxen.version}</version>
<classifier>dev</classifier>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>de.derfrzocker</groupId>
<artifactId>custom-ore-generator-api</artifactId>
Expand Down
21 changes: 21 additions & 0 deletions plugin/oraxen/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<artifactId>custom-ore-generator-plugin</artifactId>
<groupId>de.derfrzocker</groupId>
<version>${revision}</version>
</parent>

<modules>
<module>v1</module>
<module>v2</module>
</modules>

<artifactId>custom-ore-generator-plugin-oraxen</artifactId>
<packaging>pom</packaging>

</project>
50 changes: 50 additions & 0 deletions plugin/oraxen/v1/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<artifactId>custom-ore-generator-plugin-oraxen</artifactId>
<groupId>de.derfrzocker</groupId>
<version>${revision}</version>
</parent>

<artifactId>custom-ore-generator-plugin-oraxen-v1</artifactId>

<dependencies>
<dependency>
<groupId>io.th0rgal</groupId>
<artifactId>oraxen</artifactId>
<version>${Oraxen.version}</version>
<classifier>dev</classifier>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>de.derfrzocker</groupId>
<artifactId>custom-ore-generator-api</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.17.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>de.derfrzocker</groupId>
<artifactId>custom-ore-generator-impl-abstract</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*
*/

package de.derfrzocker.custom.ore.generator.impl.v1_16_R3_post.customdata;
package de.derfrzocker.custom.ore.generator.plugin.oraxen.v1;

import de.derfrzocker.custom.ore.generator.api.OreConfig;
import de.derfrzocker.custom.ore.generator.api.customdata.CustomData;
Expand All @@ -45,7 +45,7 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

public class OraxenApplier_v1_16_R3_post implements CustomDataApplier {
public class OraxenApplier implements CustomDataApplier {

private final static BlockFace[] BLOCK_FACES = new BlockFace[]{BlockFace.EAST, BlockFace.WEST, BlockFace.SOUTH,
BlockFace.NORTH, BlockFace.DOWN, BlockFace.UP};
Expand All @@ -59,7 +59,7 @@ public class OraxenApplier_v1_16_R3_post implements CustomDataApplier {
@Nullable
private StringBlockMechanicFactory stringBlockMechanicFactory;

public OraxenApplier_v1_16_R3_post(@NotNull CustomData customData) {
public OraxenApplier(@NotNull CustomData customData) {
Validate.notNull(customData, "CustomData can not be null");

this.customData = customData;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@
*
*/

package de.derfrzocker.custom.ore.generator.impl.customdata;
package de.derfrzocker.custom.ore.generator.plugin.oraxen.v1;

import de.derfrzocker.custom.ore.generator.api.Info;
import de.derfrzocker.custom.ore.generator.api.OreConfig;
import de.derfrzocker.custom.ore.generator.api.customdata.CustomDataApplier;
import de.derfrzocker.custom.ore.generator.api.customdata.CustomDataType;
import de.derfrzocker.custom.ore.generator.impl.v1_16_R3_post.customdata.OraxenApplier_v1_16_R3_post;
import de.derfrzocker.custom.ore.generator.impl.customdata.AbstractCustomData;
import de.derfrzocker.spigot.utils.Version;
import io.th0rgal.oraxen.api.OraxenBlocks;
import org.bukkit.Bukkit;
Expand All @@ -40,15 +40,15 @@

import java.util.function.Function;

public class OraxenCustomData extends AbstractCustomData<CustomDataApplier> {
public class OraxenCustomData_v1 extends AbstractCustomData<CustomDataApplier> {

public OraxenCustomData(@NotNull Function<String, Info> infoFunction) {
public OraxenCustomData_v1(@NotNull Function<String, Info> infoFunction) {
super("ORAXEN", CustomDataType.STRING, infoFunction);
}

@Override
public boolean canApply(@NotNull OreConfig oreConfig) {
return oreConfig.getMaterial() == Material.NOTE_BLOCK;
return oreConfig.getMaterial() == Material.NOTE_BLOCK || oreConfig.getMaterial() == Material.TRIPWIRE;
}

@Override
Expand Down Expand Up @@ -104,7 +104,7 @@ public Object getCustomData(@NotNull BlockState blockState) {
@Override
protected CustomDataApplier getCustomDataApplier0() {
if (Version.getServerVersion(Bukkit.getServer()).isNewerThan(Version.v1_16_R3)) {
return new OraxenApplier_v1_16_R3_post(this);
return new OraxenApplier(this);
}

throw new UnsupportedOperationException("Version not supported jet!");
Expand Down
50 changes: 50 additions & 0 deletions plugin/oraxen/v2/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<artifactId>custom-ore-generator-plugin-oraxen</artifactId>
<groupId>de.derfrzocker</groupId>
<version>${revision}</version>
</parent>

<artifactId>custom-ore-generator-plugin-oraxen-v2</artifactId>

<dependencies>
<dependency>
<groupId>io.th0rgal</groupId>
<artifactId>oraxen</artifactId>
<version>${Oraxen.version.v2}</version>
<classifier>dev</classifier>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>de.derfrzocker</groupId>
<artifactId>custom-ore-generator-api</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.18-R0.1-SNAPSHOT</version>
<scope>provided</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>de.derfrzocker</groupId>
<artifactId>custom-ore-generator-impl-abstract</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>

</project>
Loading

0 comments on commit fd42e10

Please sign in to comment.