From 807ed2b247f3028b6f1cecb0c35438248992ac95 Mon Sep 17 00:00:00 2001 From: Brian Neumann-Fopiano Date: Thu, 16 Mar 2023 14:10:32 -0400 Subject: [PATCH] gradelized patch I'm not including this until it can be gradle-ized for sake of public compilation --- build.gradle | 2 +- .../core/link/CustomItemsDataProvider.java | 204 +++++++++--------- .../iris/core/service/ExternalDataSVC.java | 4 +- 3 files changed, 105 insertions(+), 105 deletions(-) diff --git a/build.gradle b/build.gradle index 44279f63b..535176b28 100644 --- a/build.gradle +++ b/build.gradle @@ -24,7 +24,7 @@ plugins { id "de.undercouch.download" version "5.0.1" } -version '2.4.2-1.19.3' +version '2.4.3-1.19.3' def nmsVersion = "1.19.3" //[NMS] def apiVersion = '1.19' def specialSourceVersion = '1.11.0' //[NMS] diff --git a/src/main/java/com/volmit/iris/core/link/CustomItemsDataProvider.java b/src/main/java/com/volmit/iris/core/link/CustomItemsDataProvider.java index c9349d48a..216e94e91 100644 --- a/src/main/java/com/volmit/iris/core/link/CustomItemsDataProvider.java +++ b/src/main/java/com/volmit/iris/core/link/CustomItemsDataProvider.java @@ -1,102 +1,102 @@ -package com.volmit.iris.core.link; - -import com.jojodmo.customitems.api.CustomItemsAPI; -import com.jojodmo.customitems.item.custom.CustomItem; -import com.jojodmo.customitems.item.custom.block.CustomMushroomBlock; -import com.jojodmo.customitems.version.SafeMaterial; -import com.volmit.iris.util.collection.KList; -import com.volmit.iris.util.reflect.WrappedField; -import com.volmit.iris.util.reflect.WrappedReturningMethod; -import org.bukkit.block.BlockFace; -import org.bukkit.block.data.BlockData; -import org.bukkit.block.data.MultipleFacing; -import org.bukkit.inventory.ItemStack; - -import java.util.Map; -import java.util.MissingResourceException; - -public class CustomItemsDataProvider extends ExternalDataProvider { - - private static final String FIELD_FACES = "faces"; - private static final String METHOD_GET_MATERIAL = "getMaterial"; - - private WrappedField> mushroomFaces; - private WrappedReturningMethod mushroomMaterial; - - public CustomItemsDataProvider() { - super("CustomItems"); - } - - @Override - public void init() { - this.mushroomFaces = new WrappedField<>(CustomMushroomBlock.class, FIELD_FACES); - this.mushroomMaterial = new WrappedReturningMethod<>(CustomMushroomBlock.class, METHOD_GET_MATERIAL); - } - - @Override - public BlockData getBlockData(Identifier blockId) throws MissingResourceException { - CustomItem item = CustomItem.get(blockId.key()); - if(item == null) { - throw new MissingResourceException("Failed to find BlockData!", blockId.namespace(), blockId.key()); - } else if(item.getBlockTexture().isSpawner()) { - throw new MissingResourceException("Iris does not yet support SpawnerBlocks from CustomItems.", blockId.namespace(), blockId.key()); - } else if(item.getBlockTexture() != null && item.getBlockTexture().isValid()) { - throw new MissingResourceException("Tried to fetch BlockData for a CustomItem that is not placeable!", blockId.namespace(), blockId.key()); - } - return getMushroomData(item); - } - - @Override - public ItemStack getItemStack(Identifier itemId) throws MissingResourceException { - ItemStack stack = CustomItemsAPI.getCustomItem(itemId.key()); - if(stack == null) { - throw new MissingResourceException("Failed to find ItemData!", itemId.namespace(), itemId.key()); - } - return stack; - } - - @Override - public Identifier[] getBlockTypes() { - KList names = new KList<>(); - for (String name : CustomItemsAPI.listBlockCustomItemIDs()) { - try { - Identifier key = new Identifier("cui", name); - if (getItemStack(key) != null) - names.add(key); - } catch (MissingResourceException ignored) { } - } - - return names.toArray(new Identifier[0]); - } - - @Override - public Identifier[] getItemTypes() { - KList names = new KList<>(); - for (String name : CustomItemsAPI.listCustomItemIDs()) { - try { - Identifier key = new Identifier("cui", name); - if (getItemStack(key) != null) - names.add(key); - } catch (MissingResourceException ignored) { } - } - - return names.toArray(new Identifier[0]); - } - - @Override - public boolean isValidProvider(Identifier key, boolean isItem) { - return key.namespace().equalsIgnoreCase("cui"); - } - - private BlockData getMushroomData(CustomItem item) { - MultipleFacing data = (MultipleFacing)mushroomMaterial.invoke(item.getBlockTexture().getMushroomId()).parseMaterial().createBlockData(); - boolean[] values = mushroomFaces.get().get(item.getBlockTexture().getMushroomId()); - data.setFace(BlockFace.DOWN, values[0]); - data.setFace(BlockFace.EAST, values[1]); - data.setFace(BlockFace.NORTH, values[2]); - data.setFace(BlockFace.SOUTH, values[3]); - data.setFace(BlockFace.UP, values[4]); - data.setFace(BlockFace.WEST, values[5]); - return data; - } -} +//package com.volmit.iris.core.link; +// +//import com.jojodmo.customitems.api.CustomItemsAPI; +//import com.jojodmo.customitems.item.custom.CustomItem; +//import com.jojodmo.customitems.item.custom.block.CustomMushroomBlock; +//import com.jojodmo.customitems.version.SafeMaterial; +//import com.volmit.iris.util.collection.KList; +//import com.volmit.iris.util.reflect.WrappedField; +//import com.volmit.iris.util.reflect.WrappedReturningMethod; +//import org.bukkit.block.BlockFace; +//import org.bukkit.block.data.BlockData; +//import org.bukkit.block.data.MultipleFacing; +//import org.bukkit.inventory.ItemStack; +// +//import java.util.Map; +//import java.util.MissingResourceException; +// +//public class CustomItemsDataProvider extends ExternalDataProvider { +// +// private static final String FIELD_FACES = "faces"; +// private static final String METHOD_GET_MATERIAL = "getMaterial"; +// +// private WrappedField> mushroomFaces; +// private WrappedReturningMethod mushroomMaterial; +// +// public CustomItemsDataProvider() { +// super("CustomItems"); +// } +// +// @Override +// public void init() { +// this.mushroomFaces = new WrappedField<>(CustomMushroomBlock.class, FIELD_FACES); +// this.mushroomMaterial = new WrappedReturningMethod<>(CustomMushroomBlock.class, METHOD_GET_MATERIAL); +// } +// +// @Override +// public BlockData getBlockData(Identifier blockId) throws MissingResourceException { +// CustomItem item = CustomItem.get(blockId.key()); +// if(item == null) { +// throw new MissingResourceException("Failed to find BlockData!", blockId.namespace(), blockId.key()); +// } else if(item.getBlockTexture().isSpawner()) { +// throw new MissingResourceException("Iris does not yet support SpawnerBlocks from CustomItems.", blockId.namespace(), blockId.key()); +// } else if(item.getBlockTexture() != null && item.getBlockTexture().isValid()) { +// throw new MissingResourceException("Tried to fetch BlockData for a CustomItem that is not placeable!", blockId.namespace(), blockId.key()); +// } +// return getMushroomData(item); +// } +// +// @Override +// public ItemStack getItemStack(Identifier itemId) throws MissingResourceException { +// ItemStack stack = CustomItemsAPI.getCustomItem(itemId.key()); +// if(stack == null) { +// throw new MissingResourceException("Failed to find ItemData!", itemId.namespace(), itemId.key()); +// } +// return stack; +// } +// +// @Override +// public Identifier[] getBlockTypes() { +// KList names = new KList<>(); +// for (String name : CustomItemsAPI.listBlockCustomItemIDs()) { +// try { +// Identifier key = new Identifier("cui", name); +// if (getItemStack(key) != null) +// names.add(key); +// } catch (MissingResourceException ignored) { } +// } +// +// return names.toArray(new Identifier[0]); +// } +// +// @Override +// public Identifier[] getItemTypes() { +// KList names = new KList<>(); +// for (String name : CustomItemsAPI.listCustomItemIDs()) { +// try { +// Identifier key = new Identifier("cui", name); +// if (getItemStack(key) != null) +// names.add(key); +// } catch (MissingResourceException ignored) { } +// } +// +// return names.toArray(new Identifier[0]); +// } +// +// @Override +// public boolean isValidProvider(Identifier key, boolean isItem) { +// return key.namespace().equalsIgnoreCase("cui"); +// } +// +// private BlockData getMushroomData(CustomItem item) { +// MultipleFacing data = (MultipleFacing)mushroomMaterial.invoke(item.getBlockTexture().getMushroomId()).parseMaterial().createBlockData(); +// boolean[] values = mushroomFaces.get().get(item.getBlockTexture().getMushroomId()); +// data.setFace(BlockFace.DOWN, values[0]); +// data.setFace(BlockFace.EAST, values[1]); +// data.setFace(BlockFace.NORTH, values[2]); +// data.setFace(BlockFace.SOUTH, values[3]); +// data.setFace(BlockFace.UP, values[4]); +// data.setFace(BlockFace.WEST, values[5]); +// return data; +// } +//} diff --git a/src/main/java/com/volmit/iris/core/service/ExternalDataSVC.java b/src/main/java/com/volmit/iris/core/service/ExternalDataSVC.java index 960d7a60c..2d2c1205f 100644 --- a/src/main/java/com/volmit/iris/core/service/ExternalDataSVC.java +++ b/src/main/java/com/volmit/iris/core/service/ExternalDataSVC.java @@ -38,9 +38,9 @@ public class ExternalDataSVC implements IrisService { @Override public void onEnable() { addProvider( +// new CustomItemsDataProvider(), //need this to be gradelized before i can add it to the master repo new OraxenDataProvider(), - new ItemAdderDataProvider(), - new CustomItemsDataProvider()); + new ItemAdderDataProvider()); } @Override