mirror of
https://gitlab.com/phoenix-dvpmt/mmoitems.git
synced 2024-12-23 04:47:34 +01:00
Alternative validation code for buttons to prevent a bug in latest paper
(And I actually remembered to delete debug messages this time!)
This commit is contained in:
parent
710227ec93
commit
cfe1827e14
17
src/main/java/net/Indyuce/mmoitems/api/util/IsSimilar.java
Normal file
17
src/main/java/net/Indyuce/mmoitems/api/util/IsSimilar.java
Normal file
@ -0,0 +1,17 @@
|
||||
package net.Indyuce.mmoitems.api.util;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import net.Indyuce.mmoitems.version.VersionMaterial;
|
||||
|
||||
public class IsSimilar {
|
||||
public static boolean check(ItemStack i1, ItemStack i2) {
|
||||
if(i1.getType() == VersionMaterial.PLAYER_HEAD.toMaterial()) {
|
||||
System.out.println("IS SIMILAR: head");
|
||||
return i1.toString().equals(i2.toString());
|
||||
}
|
||||
|
||||
System.out.println("IS SIMILAR: non head");
|
||||
return i1.isSimilar(i2);
|
||||
}
|
||||
}
|
@ -19,6 +19,7 @@ import net.Indyuce.mmoitems.api.crafting.recipe.CraftingRecipe;
|
||||
import net.Indyuce.mmoitems.api.crafting.recipe.RecipeInfo;
|
||||
import net.Indyuce.mmoitems.api.crafting.recipe.UpgradingRecipe;
|
||||
import net.Indyuce.mmoitems.api.item.plugin.ConfigItem;
|
||||
import net.Indyuce.mmoitems.api.util.IsSimilar;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
|
||||
public class CraftingStationPreview extends PluginInventory {
|
||||
@ -97,26 +98,26 @@ public class CraftingStationPreview extends PluginInventory {
|
||||
if (!MMOUtils.isPluginItem(event.getCurrentItem(), false))
|
||||
return;
|
||||
|
||||
if (event.getCurrentItem().isSimilar(ConfigItem.CONFIRM.getItem())) {
|
||||
if (IsSimilar.check(event.getCurrentItem(), ConfigItem.CONFIRM.getItem())) {
|
||||
CraftingStationView csv = new CraftingStationView(player, station, previousPage);
|
||||
csv.processRecipe(recipe);
|
||||
csv.open();
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getCurrentItem().isSimilar(ConfigItem.PREVIOUS_PAGE.getItem())) {
|
||||
if (IsSimilar.check(event.getCurrentItem(), ConfigItem.PREVIOUS_PAGE.getItem())) {
|
||||
page--;
|
||||
open();
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getCurrentItem().isSimilar(ConfigItem.NEXT_PAGE.getItem())) {
|
||||
if (IsSimilar.check(event.getCurrentItem(), ConfigItem.NEXT_PAGE.getItem())) {
|
||||
page++;
|
||||
open();
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getCurrentItem().isSimilar(ConfigItem.BACK.getItem())) {
|
||||
if (IsSimilar.check(event.getCurrentItem(), ConfigItem.BACK.getItem())) {
|
||||
new CraftingStationView(player, station, previousPage).open();
|
||||
return;
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ import net.Indyuce.mmoitems.api.event.crafting.PlayerUseRecipeEvent;
|
||||
import net.Indyuce.mmoitems.api.item.NBTItem;
|
||||
import net.Indyuce.mmoitems.api.item.plugin.ConfigItem;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerData;
|
||||
import net.Indyuce.mmoitems.api.util.IsSimilar;
|
||||
import net.Indyuce.mmoitems.api.util.message.Message;
|
||||
import net.Indyuce.mmoitems.listener.CustomSoundListener;
|
||||
|
||||
@ -129,25 +130,25 @@ public class CraftingStationView extends PluginInventory {
|
||||
if (!MMOUtils.isPluginItem(event.getCurrentItem(), false))
|
||||
return;
|
||||
|
||||
if (event.getCurrentItem().isSimilar(ConfigItem.PREVIOUS_IN_QUEUE.getItem())) {
|
||||
if (IsSimilar.check(event.getCurrentItem(), ConfigItem.PREVIOUS_IN_QUEUE.getItem())) {
|
||||
queueOffset--;
|
||||
open();
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getCurrentItem().isSimilar(ConfigItem.NEXT_IN_QUEUE.getItem())) {
|
||||
if (IsSimilar.check(event.getCurrentItem(), ConfigItem.NEXT_IN_QUEUE.getItem())) {
|
||||
queueOffset++;
|
||||
open();
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getCurrentItem().isSimilar(ConfigItem.NEXT_PAGE.getItem())) {
|
||||
if (IsSimilar.check(event.getCurrentItem(), ConfigItem.NEXT_PAGE.getItem())) {
|
||||
page++;
|
||||
open();
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getCurrentItem().isSimilar(ConfigItem.PREVIOUS_PAGE.getItem())) {
|
||||
if (IsSimilar.check(event.getCurrentItem(), ConfigItem.PREVIOUS_PAGE.getItem())) {
|
||||
page--;
|
||||
open();
|
||||
return;
|
||||
|
@ -24,6 +24,7 @@ import net.Indyuce.mmoitems.api.ConfigFile;
|
||||
import net.Indyuce.mmoitems.api.Type;
|
||||
import net.Indyuce.mmoitems.api.item.MMOItem;
|
||||
import net.Indyuce.mmoitems.api.item.NBTItem;
|
||||
import net.Indyuce.mmoitems.api.util.IsSimilar;
|
||||
import net.Indyuce.mmoitems.stat.type.ItemStat;
|
||||
import net.Indyuce.mmoitems.version.durability.DurabilityHandler;
|
||||
|
||||
@ -78,7 +79,7 @@ public class UpdaterManager implements Listener {
|
||||
return;
|
||||
|
||||
ItemStack newItem = getUpdated(item);
|
||||
if (!newItem.isSimilar(item))
|
||||
if (!IsSimilar.check(newItem, item))
|
||||
event.setCurrentItem(newItem);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user