Skip to content

Commit

Permalink
Add item resolver for Eco plugins items (EcoItems, Talismans, EcoArmo…
Browse files Browse the repository at this point in the history
…r, EcoScrolls, etc)
  • Loading branch information
ErikSzabo committed Jul 22, 2024
1 parent 00027a6 commit 158fdfc
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 5 deletions.
2 changes: 2 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ repositories {
maven("https://nexus.phoenixdevt.fr/repository/maven-public/")
maven("https://repo.oraxen.com/snapshots")
maven("https://mvn.lumine.io/repository/maven-public/")
maven("https://repo.auxilor.io/repository/maven-public/")
}

dependencies {
Expand All @@ -59,6 +60,7 @@ dependencies {
compileOnly("io.lumine:MythicLib-dist:1.6.2-SNAPSHOT")
compileOnly("net.Indyuce:MMOItems-API:6.10-SNAPSHOT")
compileOnly("io.th0rgal:oraxen:2.0-SNAPSHOT")
compileOnly("com.willfp:eco:6.73.0")

// 3rd party local
compileOnly(name = "CMI9.0.0.0API", group = "com.Zrips.CMI", version = "9.0.0.0")
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/gg/auroramc/aurora/api/dependency/Dep.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ public enum Dep {
PROTCOLLIB("ProtocolLib"),
MULTIVERSECORE("Multiverse-Core"),
WILDREGENERATION("WildRegeneration"),
ECONOMYSHOPGUIPREMIUM("EconomyShopGUI-Premium");
ECONOMYSHOPGUIPREMIUM("EconomyShopGUI-Premium"),
ECO("Eco");

private String id;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@
import gg.auroramc.aurora.api.dependency.DependencyManager;
import gg.auroramc.aurora.api.expansions.AuroraExpansion;
import gg.auroramc.aurora.api.item.ItemManager;
import gg.auroramc.aurora.expansions.item.resolvers.CustomFishingItemResolver;
import gg.auroramc.aurora.expansions.item.resolvers.MMOItemResolver;
import gg.auroramc.aurora.expansions.item.resolvers.MythicItemResolver;
import gg.auroramc.aurora.expansions.item.resolvers.OraxenItemResolver;
import gg.auroramc.aurora.expansions.item.resolvers.*;
import gg.auroramc.aurora.expansions.item.resolvers.EcoItemsResolver;
import lombok.Getter;

@Getter
Expand Down Expand Up @@ -38,6 +36,11 @@ public void hook() {
itemManager.registerResolver(Dep.ORAXEN, new OraxenItemResolver());
Aurora.logger().debug("Hooked into Oraxen for item resolvers.");
}

if(DependencyManager.hasDep(Dep.ECO)) {
itemManager.registerResolver(Dep.ECO, new EcoItemsResolver());
Aurora.logger().debug("Hooked into EcoItems for item resolvers.");
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package gg.auroramc.aurora.expansions.item.resolvers;

import com.willfp.eco.core.items.Items;
import gg.auroramc.aurora.api.item.ItemResolver;
import gg.auroramc.aurora.api.item.TypeId;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.Nullable;

public class EcoItemsResolver implements ItemResolver {
@Override
public boolean matches(ItemStack item) {
return Items.isCustomItem(item);
}

@Override
public TypeId resolveId(ItemStack item) {
var ecoItem = Items.getCustomItem(item).getKey();
return new TypeId("eco", ecoItem.toString());
}

@Override
public ItemStack resolveItem(String id, @Nullable Player player) {
return Items.lookup(id).getItem();
}
}

0 comments on commit 158fdfc

Please sign in to comment.