IT IS HERE. THE CRAFTING UP-- lol jk

Anyway, this is just a tiny hotfix for the playerhead buttons.
Fixes back/next/prev buttons in the AWB and in crafting stations.
This commit is contained in:
Aria Sangarin 2020-01-13 19:57:26 +01:00
parent b40b5b64ad
commit 500c3c60f9
4 changed files with 22 additions and 9 deletions

View File

@ -1,13 +1,23 @@
package net.Indyuce.mmoitems.api.util;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import net.mmogroup.mmolib.version.VersionMaterial;
public class IsSimilar {
public static boolean check(ItemStack i1, ItemStack i2) {
if(i1.getType() == VersionMaterial.PLAYER_HEAD.toMaterial()) {
return i1.toString().equals(i2.toString());
/**
* Not the most optimal code,
* but it works for now.
*/
if(i1.getType() == VersionMaterial.PLAYER_HEAD.toMaterial() &&
i2.getType() == VersionMaterial.PLAYER_HEAD.toMaterial()) {
ItemMeta meta1 = i1.getItemMeta();
ItemMeta meta2 = i2.getItemMeta();
if(meta1.hasDisplayName() && meta2.hasDisplayName())
return meta1.getDisplayName().equalsIgnoreCase(meta2.getDisplayName());
}
return i1.isSimilar(i2);

View File

@ -17,6 +17,7 @@ import net.Indyuce.mmoitems.api.AdvancedRecipe;
import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.item.plugin.ConfigItem;
import net.Indyuce.mmoitems.api.util.AltChar;
import net.Indyuce.mmoitems.api.util.IsSimilar;
import net.Indyuce.mmoitems.api.util.message.Message;
import net.mmogroup.mmolib.api.item.ItemTag;
import net.mmogroup.mmolib.api.item.NBTItem;
@ -71,15 +72,15 @@ public class AdvancedRecipeList extends PluginInventory {
return;
if (MMOUtils.isPluginItem(item, false)) {
if (item.equals(ConfigItem.BACK.getItem()))
if (IsSimilar.check(item, ConfigItem.BACK.getItem()))
new AdvancedRecipeTypeList(player).open();
if (item.equals(ConfigItem.NEXT_PAGE.getItem())) {
if (IsSimilar.check(item, ConfigItem.NEXT_PAGE.getItem())) {
page++;
open();
}
if (item.equals(ConfigItem.PREVIOUS_PAGE.getItem()) && page > 1) {
if (IsSimilar.check(item, ConfigItem.PREVIOUS_PAGE.getItem()) && page > 1) {
page--;
open();
}

View File

@ -14,6 +14,7 @@ import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.AdvancedRecipe;
import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.item.plugin.ConfigItem;
import net.Indyuce.mmoitems.api.util.IsSimilar;
import net.Indyuce.mmoitems.api.util.message.Message;
import net.Indyuce.mmoitems.gui.edition.EditionInventory;
import net.mmogroup.mmolib.version.VersionMaterial;
@ -79,7 +80,7 @@ public class AdvancedRecipePreview extends EditionInventory {
event.setCancelled(true);
if (MMOUtils.isPluginItem(item, false))
if (item.equals(ConfigItem.BACK.getItem()))
if (IsSimilar.check(item, ConfigItem.BACK.getItem()))
new AdvancedRecipeList(player, type).open();
}
}

View File

@ -15,6 +15,7 @@ import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.item.plugin.ConfigItem;
import net.Indyuce.mmoitems.api.util.IsSimilar;
import net.Indyuce.mmoitems.api.util.message.Message;
import net.mmogroup.mmolib.api.item.ItemTag;
import net.mmogroup.mmolib.api.item.NBTItem;
@ -71,15 +72,15 @@ public class AdvancedRecipeTypeList extends PluginInventory {
return;
if (MMOUtils.isPluginItem(item, false)) {
if (item.equals(ConfigItem.BACK.getItem()))
if (IsSimilar.check(item, ConfigItem.BACK.getItem()))
new AdvancedWorkbench(player).open();
if (item.equals(ConfigItem.NEXT_PAGE.getItem())) {
if (IsSimilar.check(item, ConfigItem.NEXT_PAGE.getItem())) {
page++;
open();
}
if (item.equals(ConfigItem.PREVIOUS_PAGE.getItem()) && page > 1) {
if (IsSimilar.check(item, ConfigItem.PREVIOUS_PAGE.getItem()) && page > 1) {
page--;
open();
}