Fixed the MMOItems Error #253

This commit is contained in:
Sn0wStorm
2020-04-02 17:48:33 +02:00
parent 86f82f0a14
commit 948b843b59
4 changed files with 19 additions and 10 deletions
+9 -3
View File
@@ -108,7 +108,7 @@
<dependency> <dependency>
<groupId>org.bukkit</groupId> <groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId> <artifactId>bukkit</artifactId>
<version>1.15-R0.1-SNAPSHOT</version> <version>1.15.2-R0.1-SNAPSHOT</version>
<scope>provided</scope> <scope>provided</scope>
<exclusions> <exclusions>
<exclusion> <exclusion>
@@ -205,12 +205,18 @@
<version>4bb9abd247</version> <version>4bb9abd247</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <!--<dependency>
<!-- Contains proprietary api that we use for integration --> Contains proprietary api that we use for integration
<groupId>com.dre</groupId> <groupId>com.dre</groupId>
<artifactId>ExtPluginBridge</artifactId> <artifactId>ExtPluginBridge</artifactId>
<version>1.0</version> <version>1.0</version>
<scope>provided</scope> <scope>provided</scope>
</dependency>-->
<dependency>
<groupId>net.mmogroup</groupId>
<artifactId>mmolib</artifactId>
<version>1.0.9</version>
<scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.bstats</groupId> <groupId>org.bstats</groupId>
@@ -13,8 +13,8 @@ import com.dre.brewery.integration.item.MMOItemsPluginItem;
import com.dre.brewery.recipe.BCauldronRecipe; import com.dre.brewery.recipe.BCauldronRecipe;
import com.dre.brewery.recipe.RecipeItem; import com.dre.brewery.recipe.RecipeItem;
import com.dre.brewery.utility.LegacyUtil; import com.dre.brewery.utility.LegacyUtil;
import net.Indyuce.mmoitems.MMOItems; import net.mmogroup.mmolib.MMOLib;
import net.Indyuce.mmoitems.api.item.NBTItem; import net.mmogroup.mmolib.api.item.NBTItem;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
@@ -219,7 +219,7 @@ public class IntegrationListener implements Listener {
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onInteract(PlayerInteractEvent event) { public void onInteract(PlayerInteractEvent event) {
// Cancel the Interact Event early, so MMOItems does not act before us and consume the item when trying to add item to Cauldron // Catch the Interact Event early, so MMOItems does not act before us and cancel the event while we try to add it to the Cauldron
if (!P.use1_9) return; if (!P.use1_9) return;
if (BConfig.hasMMOItems == null) { if (BConfig.hasMMOItems == null) {
BConfig.hasMMOItems = P.p.getServer().getPluginManager().isPluginEnabled("MMOItems"); BConfig.hasMMOItems = P.p.getServer().getPluginManager().isPluginEnabled("MMOItems");
@@ -228,7 +228,7 @@ public class IntegrationListener implements Listener {
try { try {
if (event.getAction() == Action.RIGHT_CLICK_BLOCK && event.hasItem() && event.getHand() == EquipmentSlot.HAND) { if (event.getAction() == Action.RIGHT_CLICK_BLOCK && event.hasItem() && event.getHand() == EquipmentSlot.HAND) {
if (event.getClickedBlock() != null && event.getClickedBlock().getType() == Material.CAULDRON) { if (event.getClickedBlock() != null && event.getClickedBlock().getType() == Material.CAULDRON) {
NBTItem item = MMOItems.plugin.getNMS().getNBTItem(event.getItem()); NBTItem item = MMOLib.plugin.getNMS().getNBTItem(event.getItem());
if (item.hasType()) { if (item.hasType()) {
for (RecipeItem rItem : BCauldronRecipe.acceptedCustom) { for (RecipeItem rItem : BCauldronRecipe.acceptedCustom) {
if (rItem instanceof MMOItemsPluginItem) { if (rItem instanceof MMOItemsPluginItem) {
@@ -246,6 +246,7 @@ public class IntegrationListener implements Listener {
} catch (Throwable e) { } catch (Throwable e) {
P.p.errorLog("Could not check MMOItems for Item"); P.p.errorLog("Could not check MMOItems for Item");
e.printStackTrace(); e.printStackTrace();
BConfig.hasMMOItems = false;
} }
} }
} }
@@ -3,8 +3,8 @@ package com.dre.brewery.integration.item;
import com.dre.brewery.P; import com.dre.brewery.P;
import com.dre.brewery.filedata.BConfig; import com.dre.brewery.filedata.BConfig;
import com.dre.brewery.recipe.PluginItem; import com.dre.brewery.recipe.PluginItem;
import net.Indyuce.mmoitems.MMOItems; import net.mmogroup.mmolib.MMOLib;
import net.Indyuce.mmoitems.api.item.NBTItem; import net.mmogroup.mmolib.api.item.NBTItem;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
public class MMOItemsPluginItem extends PluginItem { public class MMOItemsPluginItem extends PluginItem {
@@ -21,11 +21,12 @@ public class MMOItemsPluginItem extends PluginItem {
if (!BConfig.hasMMOItems) return false; if (!BConfig.hasMMOItems) return false;
try { try {
NBTItem nbtItem = MMOItems.plugin.getNMS().getNBTItem(item); NBTItem nbtItem = MMOLib.plugin.getNMS().getNBTItem(item);
return nbtItem.hasType() && nbtItem.getString("MMOITEMS_ITEM_ID").equalsIgnoreCase(getItemId()); return nbtItem.hasType() && nbtItem.getString("MMOITEMS_ITEM_ID").equalsIgnoreCase(getItemId());
} catch (Throwable e) { } catch (Throwable e) {
e.printStackTrace(); e.printStackTrace();
P.p.errorLog("Could not check MMOItems for Item ID"); P.p.errorLog("Could not check MMOItems for Item ID");
BConfig.hasMMOItems = false;
return false; return false;
} }
} }
@@ -28,6 +28,7 @@ public class SlimefunPluginItem extends PluginItem {
} catch (Throwable e) { } catch (Throwable e) {
e.printStackTrace(); e.printStackTrace();
P.p.errorLog("Could not check Slimefun for Item ID"); P.p.errorLog("Could not check Slimefun for Item ID");
BConfig.hasSlimefun = false;
return false; return false;
} }
return false; return false;