mirror of
https://github.com/Xiao-MoMi/Custom-Fishing.git
synced 2025-12-29 03:49:07 +00:00
Added eco custom items integration
This commit is contained in:
@@ -22,6 +22,7 @@ import net.momirealms.customcrops.helper.Log;
|
||||
import net.momirealms.customfishing.competition.CompetitionConfig;
|
||||
import net.momirealms.customfishing.competition.Goal;
|
||||
import net.momirealms.customfishing.competition.bossbar.BossBarConfig;
|
||||
import net.momirealms.customfishing.hook.EcoItemRegister;
|
||||
import net.momirealms.customfishing.hook.season.CustomCropsSeason;
|
||||
import net.momirealms.customfishing.hook.season.RealisticSeason;
|
||||
import net.momirealms.customfishing.hook.season.SeasonInterface;
|
||||
@@ -81,6 +82,9 @@ public class ConfigReader{
|
||||
loadBait();
|
||||
loadEnchants();
|
||||
loadCompetitions();
|
||||
if (Bukkit.getPluginManager().isPluginEnabled("eco")) {
|
||||
EcoItemRegister.registerItems();
|
||||
}
|
||||
}
|
||||
|
||||
public static class Config {
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
package net.momirealms.customfishing.hook;
|
||||
|
||||
import com.willfp.eco.core.items.CustomItem;
|
||||
import net.momirealms.customfishing.ConfigReader;
|
||||
import net.momirealms.customfishing.CustomFishing;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class EcoItemRegister {
|
||||
public static void registerItems() {
|
||||
// Rods
|
||||
for (Map.Entry<String, ItemStack> entry : ConfigReader.RodItem.entrySet()) {
|
||||
new CustomItem(
|
||||
new NamespacedKey(CustomFishing.instance, "rod_" + entry.getKey()),
|
||||
itemStack -> {
|
||||
try {
|
||||
return itemStack.getItemMeta().getPersistentDataContainer()
|
||||
.get(new NamespacedKey(CustomFishing.instance, "type"),
|
||||
PersistentDataType.STRING).equalsIgnoreCase("rod")
|
||||
&& itemStack.getItemMeta().getPersistentDataContainer()
|
||||
.get(new NamespacedKey(CustomFishing.instance, "id"),
|
||||
PersistentDataType.STRING).equalsIgnoreCase(entry.getKey());
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
entry.getValue()
|
||||
).register();
|
||||
}
|
||||
// Baits
|
||||
for (Map.Entry<String, ItemStack> entry : ConfigReader.BaitItem.entrySet()) {
|
||||
new CustomItem(
|
||||
new NamespacedKey(CustomFishing.instance, "bait_" + entry.getKey()),
|
||||
itemStack -> {
|
||||
try {
|
||||
return itemStack.getItemMeta().getPersistentDataContainer()
|
||||
.get(new NamespacedKey(CustomFishing.instance, "type"),
|
||||
PersistentDataType.STRING).equalsIgnoreCase("bait")
|
||||
&& itemStack.getItemMeta().getPersistentDataContainer()
|
||||
.get(new NamespacedKey(CustomFishing.instance, "id"),
|
||||
PersistentDataType.STRING).equalsIgnoreCase(entry.getKey());
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
entry.getValue()
|
||||
).register();
|
||||
}
|
||||
// Utils
|
||||
for (Map.Entry<String, ItemStack> entry : ConfigReader.UtilItem.entrySet()) {
|
||||
new CustomItem(
|
||||
new NamespacedKey(CustomFishing.instance, "util_" + entry.getKey()),
|
||||
itemStack -> {
|
||||
try {
|
||||
return itemStack.getItemMeta().getPersistentDataContainer()
|
||||
.get(new NamespacedKey(CustomFishing.instance, "type"),
|
||||
PersistentDataType.STRING).equalsIgnoreCase("util")
|
||||
&& itemStack.getItemMeta().getPersistentDataContainer()
|
||||
.get(new NamespacedKey(CustomFishing.instance, "id"),
|
||||
PersistentDataType.STRING).equalsIgnoreCase(entry.getKey());
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
entry.getValue()
|
||||
).register();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user