mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-01 23:47:21 +00:00
Fixed Oraxen and IA Integration.
This commit is contained in:
parent
3ec2f8fb7b
commit
20ceaead09
15
build.gradle
15
build.gradle
@ -74,8 +74,15 @@ repositories {
|
||||
includeGroup("org.spigotmc")
|
||||
}
|
||||
}
|
||||
mavenCentral()
|
||||
maven { url "https://arcanearts.jfrog.io/artifactory/archives" }
|
||||
maven { url "https://mvn.lumine.io/repository/maven-public/" }
|
||||
maven { url "https://jitpack.io"}
|
||||
|
||||
maven { url "https://s01.oss.sonatype.org/content/repositories/snapshots" }
|
||||
maven { url "https://mvn.lumine.io/repository/maven/" }
|
||||
maven { url "https://repo.triumphteam.dev/snapshots" }
|
||||
maven { url "https://repo.mineinabyss.com/releases" }
|
||||
}
|
||||
|
||||
/**
|
||||
@ -123,10 +130,12 @@ dependencies {
|
||||
compileOnly 'org.projectlombok:lombok:1.18.24'
|
||||
annotationProcessor 'org.projectlombok:lombok:1.18.24'
|
||||
implementation 'org.spigotmc:spigot-api:1.19.3-R0.1-SNAPSHOT'
|
||||
implementation 'me.clip:placeholderapi:2.11.1'
|
||||
implementation 'io.th0rgal:oraxen:1.94.0'
|
||||
implementation 'org.bukkit:craftbukkit:1.19.3-R0.1-SNAPSHOT:remapped-mojang' //[NMS]
|
||||
implementation 'com.github.LoneDev6:api-itemsadder:3.1.0b'
|
||||
|
||||
// Third Party Integrations
|
||||
implementation 'com.github.oraxen:oraxen:1.152.5'
|
||||
implementation 'com.github.LoneDev6:api-itemsadder:3.2.5'
|
||||
implementation 'me.clip:placeholderapi:2.11.1'
|
||||
|
||||
// Shaded
|
||||
implementation 'com.dfsek:Paralithic:0.4.0'
|
||||
|
@ -32,5 +32,7 @@ public abstract class ExternalDataProvider {
|
||||
|
||||
public abstract NamespacedKey[] getBlockTypes();
|
||||
|
||||
public abstract boolean isValidProvider(NamespacedKey namespace);
|
||||
public abstract NamespacedKey[] getItemTypes();
|
||||
|
||||
public abstract boolean isValidProvider(NamespacedKey namespace, boolean isItem);
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ package com.volmit.iris.core.link;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import dev.lone.itemsadder.api.CustomBlock;
|
||||
import dev.lone.itemsadder.api.CustomStack;
|
||||
import dev.lone.itemsadder.api.ItemsAdder;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@ -17,8 +16,7 @@ public class ItemAdderDataProvider extends ExternalDataProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
}
|
||||
public void init() { }
|
||||
|
||||
@Override
|
||||
public BlockData getBlockData(NamespacedKey blockId) throws MissingResourceException {
|
||||
@ -28,25 +26,37 @@ public class ItemAdderDataProvider extends ExternalDataProvider {
|
||||
@Override
|
||||
public ItemStack getItemStack(NamespacedKey itemId) throws MissingResourceException {
|
||||
CustomStack stack = CustomStack.getInstance(itemId.toString());
|
||||
if (stack == null)
|
||||
if (stack == null) {
|
||||
throw new MissingResourceException("Failed to find ItemData!", itemId.getNamespace(), itemId.getKey());
|
||||
}
|
||||
return stack.getItemStack();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NamespacedKey[] getBlockTypes() {
|
||||
KList<NamespacedKey> keys = new KList<>();
|
||||
for (String s : ItemsAdder.getNamespacedBlocksNamesInConfig())
|
||||
for (String s : CustomBlock.getNamespacedIdsInRegistry()) {
|
||||
keys.add(NamespacedKey.fromString(s));
|
||||
}
|
||||
return keys.toArray(new NamespacedKey[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidProvider(NamespacedKey blockId) {
|
||||
for (NamespacedKey k : getBlockTypes())
|
||||
public NamespacedKey[] getItemTypes() {
|
||||
KList<NamespacedKey> keys = new KList<>();
|
||||
for (String s : CustomStack.getNamespacedIdsInRegistry()) {
|
||||
keys.add(NamespacedKey.fromString(s));
|
||||
}
|
||||
return keys.toArray(new NamespacedKey[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidProvider(NamespacedKey blockId, boolean isItem) {
|
||||
for (NamespacedKey k : (isItem ? getItemTypes() : getBlockTypes())) {
|
||||
if (k.equals(blockId)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,44 @@
|
||||
package com.volmit.iris.core.link;
|
||||
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.MissingResourceException;
|
||||
|
||||
public class MMOItemsDataProvider extends ExternalDataProvider {
|
||||
|
||||
public MMOItemsDataProvider(String pluginId) {
|
||||
super(pluginId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockData getBlockData(NamespacedKey blockId) throws MissingResourceException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemStack(NamespacedKey itemId) throws MissingResourceException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NamespacedKey[] getBlockTypes() {
|
||||
return new NamespacedKey[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public NamespacedKey[] getItemTypes() {
|
||||
return new NamespacedKey[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidProvider(NamespacedKey namespace, boolean isItem) {
|
||||
return false;
|
||||
}
|
||||
}
|
@ -20,14 +20,14 @@ package com.volmit.iris.core.link;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import io.th0rgal.oraxen.api.OraxenItems;
|
||||
import io.th0rgal.oraxen.items.ItemBuilder;
|
||||
import io.th0rgal.oraxen.items.OraxenItems;
|
||||
import io.th0rgal.oraxen.mechanics.MechanicFactory;
|
||||
import io.th0rgal.oraxen.mechanics.MechanicsManager;
|
||||
import io.th0rgal.oraxen.mechanics.provided.gameplay.block.BlockMechanic;
|
||||
import io.th0rgal.oraxen.mechanics.provided.gameplay.block.BlockMechanicFactory;
|
||||
import io.th0rgal.oraxen.mechanics.provided.gameplay.noteblock.NoteBlockMechanicFactory;
|
||||
import io.th0rgal.oraxen.utils.Utils;
|
||||
import io.th0rgal.oraxen.mechanics.provided.gameplay.stringblock.StringBlockMechanicFactory;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
@ -64,13 +64,15 @@ public class OraxenDataProvider extends ExternalDataProvider {
|
||||
|
||||
@Override
|
||||
public BlockData getBlockData(NamespacedKey blockId) throws MissingResourceException {
|
||||
MechanicFactory f = getFactory(blockId);
|
||||
if (f instanceof NoteBlockMechanicFactory)
|
||||
return ((NoteBlockMechanicFactory) f).createNoteBlockData(blockId.getKey());
|
||||
else if (f instanceof BlockMechanicFactory) {
|
||||
MechanicFactory factory = getFactory(blockId);
|
||||
if (factory instanceof NoteBlockMechanicFactory f)
|
||||
return f.createNoteBlockData(blockId.getKey());
|
||||
else if (factory instanceof BlockMechanicFactory f) {
|
||||
MultipleFacing newBlockData = (MultipleFacing) Bukkit.createBlockData(Material.MUSHROOM_STEM);
|
||||
Utils.setBlockFacing(newBlockData, ((BlockMechanic) f.getMechanic(blockId.getKey())).getCustomVariation());
|
||||
BlockMechanic.setBlockFacing(newBlockData, ((BlockMechanic) f.getMechanic(blockId.getKey())).getCustomVariation());
|
||||
return newBlockData;
|
||||
} else if (factory instanceof StringBlockMechanicFactory f) {
|
||||
return f.createTripwireData(blockId.getKey());
|
||||
} else
|
||||
throw new MissingResourceException("Failed to find BlockData!", blockId.getNamespace(), blockId.getKey());
|
||||
}
|
||||
@ -89,8 +91,21 @@ public class OraxenDataProvider extends ExternalDataProvider {
|
||||
NamespacedKey key = new NamespacedKey("oraxen", name);
|
||||
if (getBlockData(key) != null)
|
||||
names.add(key);
|
||||
} catch (MissingResourceException ignored) {
|
||||
}
|
||||
} catch (MissingResourceException ignored) { }
|
||||
}
|
||||
|
||||
return names.toArray(new NamespacedKey[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NamespacedKey[] getItemTypes() {
|
||||
KList<NamespacedKey> names = new KList<>();
|
||||
for (String name : OraxenItems.getItemNames()) {
|
||||
try {
|
||||
NamespacedKey key = new NamespacedKey("oraxen", name);
|
||||
if (getItemStack(key) != null)
|
||||
names.add(key);
|
||||
} catch (MissingResourceException ignored) { }
|
||||
}
|
||||
|
||||
return names.toArray(new NamespacedKey[0]);
|
||||
@ -102,7 +117,7 @@ public class OraxenDataProvider extends ExternalDataProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidProvider(NamespacedKey key) {
|
||||
public boolean isValidProvider(NamespacedKey key, boolean isItem) {
|
||||
return key.getNamespace().equalsIgnoreCase("oraxen");
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,7 @@ public class ExternalDataSVC implements IrisService {
|
||||
}
|
||||
|
||||
public Optional<BlockData> getBlockData(NamespacedKey key) {
|
||||
Optional<ExternalDataProvider> provider = providers.stream().filter(p -> p.isPresent() && p.isValidProvider(key)).findFirst();
|
||||
Optional<ExternalDataProvider> provider = providers.stream().filter(p -> p.isPresent() && p.isValidProvider(key, false)).findFirst();
|
||||
if (provider.isEmpty())
|
||||
return Optional.empty();
|
||||
try {
|
||||
@ -68,9 +68,11 @@ public class ExternalDataSVC implements IrisService {
|
||||
}
|
||||
|
||||
public Optional<ItemStack> getItemStack(NamespacedKey key) {
|
||||
Optional<ExternalDataProvider> provider = providers.stream().filter(p -> p.isPresent() && p.isValidProvider(key)).findFirst();
|
||||
if (provider.isEmpty())
|
||||
Optional<ExternalDataProvider> provider = providers.stream().filter(p -> p.isPresent() && p.isValidProvider(key, true)).findFirst();
|
||||
if (provider.isEmpty()) {
|
||||
Iris.warn("No matching Provider found for modded material \"%s\"!", key);
|
||||
return Optional.empty();
|
||||
}
|
||||
try {
|
||||
return Optional.of(provider.get().getItemStack(key));
|
||||
} catch (MissingResourceException e) {
|
||||
@ -79,9 +81,15 @@ public class ExternalDataSVC implements IrisService {
|
||||
}
|
||||
}
|
||||
|
||||
public NamespacedKey[] getAllIdentifiers() {
|
||||
public NamespacedKey[] getAllBlockIdentifiers() {
|
||||
KList<NamespacedKey> names = new KList<>();
|
||||
providers.stream().filter(ExternalDataProvider::isPresent).forEach(p -> names.add(p.getBlockTypes()));
|
||||
return names.toArray(new NamespacedKey[0]);
|
||||
}
|
||||
|
||||
public NamespacedKey[] getAllItemIdentifiers() {
|
||||
KList<NamespacedKey> names = new KList<>();
|
||||
providers.stream().filter(ExternalDataProvider::isPresent).forEach(p -> names.add(p.getItemTypes()));
|
||||
return names.toArray(new NamespacedKey[0]);
|
||||
}
|
||||
}
|
||||
|
@ -152,7 +152,7 @@ public class IrisLoot {
|
||||
Optional<ItemStack> opt = Iris.service(ExternalDataSVC.class).getItemStack(NamespacedKey.fromString(type));
|
||||
if (opt.isEmpty()) {
|
||||
Iris.warn("Unknown Material: " + type);
|
||||
return null;
|
||||
return new ItemStack(Material.AIR);
|
||||
}
|
||||
ItemStack is = opt.get();
|
||||
is.setAmount(Math.max(1, rng.i(getMinAmount(), getMaxAmount())));
|
||||
@ -198,8 +198,10 @@ public class IrisLoot {
|
||||
colorable.setColor(getDyeColor());
|
||||
}
|
||||
|
||||
m.setLocalizedName(C.translateAlternateColorCodes('&', displayName));
|
||||
m.setDisplayName(C.translateAlternateColorCodes('&', displayName));
|
||||
if(displayName != null) {
|
||||
m.setLocalizedName(C.translateAlternateColorCodes('&', displayName));
|
||||
m.setDisplayName(C.translateAlternateColorCodes('&', displayName));
|
||||
}
|
||||
|
||||
KList<String> lore = new KList<>();
|
||||
|
||||
|
@ -647,7 +647,7 @@ public class B {
|
||||
}
|
||||
}
|
||||
|
||||
for (NamespacedKey id : Iris.service(ExternalDataSVC.class).getAllIdentifiers())
|
||||
for (NamespacedKey id : Iris.service(ExternalDataSVC.class).getAllBlockIdentifiers())
|
||||
bt.add(id.toString());
|
||||
bt.addAll(custom.k());
|
||||
|
||||
@ -662,6 +662,9 @@ public class B {
|
||||
bt.add(v);
|
||||
}
|
||||
|
||||
for (NamespacedKey id : Iris.service(ExternalDataSVC.class).getAllItemIdentifiers())
|
||||
bt.add(id.toString());
|
||||
|
||||
return bt.toArray(new String[0]);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user