Skip to content

Commit

Permalink
[1.6.1-beta4]修复spigot端无法打开烧炼配方和铁砧配方的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
YufiriaMazenta committed Dec 12, 2023
1 parent 031a84f commit 21ff328
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 12 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import java.text.SimpleDateFormat
version = "1.6.1-beta3"
version = "1.6.1-beta4"

plugins {
`java-library`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.event.inventory.PrepareAnvilEvent;
import org.bukkit.inventory.AnvilInventory;
import org.bukkit.inventory.ItemStack;

import java.util.HashMap;

@BukkitListener
public class AnvilHandler implements Listener {
public enum AnvilHandler implements Listener {

INSTANCE;

@EventHandler
public void onPrepareAnvil(PrepareAnvilEvent event) {
Expand All @@ -44,8 +45,6 @@ public void onClickAnvil(InventoryClickEvent event) {
if (!PluginConfigs.ENABLE_ANVIL_RECIPE.value())
return;

if (!event.getInventory().getType().equals(InventoryType.ANVIL))
return;
if (!(event.getInventory() instanceof AnvilInventory))
return;
AnvilInventory anvilInventory = (AnvilInventory) event.getInventory();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,7 @@ protected Icon getCostLevelIcon() {
player.closeInventory();
}
);
icon.display().setLore(Languages.MENU_RECIPE_CREATOR_ICON_ANVIL_COST_LEVEL_LORE.value());
icon.display().getLore().replaceAll(TextUtil::color);
ItemUtils.setLore(icon.display(), Languages.MENU_RECIPE_CREATOR_ICON_ANVIL_COST_LEVEL_LORE.value());
return icon;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,7 @@ protected Icon getCookingTimeIcon() {
player.closeInventory();
}
);
icon.display().setLore(Languages.MENU_RECIPE_CREATOR_ICON_COOKING_TIME_LORE.value());
icon.display().getLore().replaceAll(TextUtil::color);

ItemUtils.setLore(icon.display(), Languages.MENU_RECIPE_CREATOR_ICON_COOKING_TIME_LORE.value());
return icon;
}

Expand All @@ -230,8 +228,7 @@ protected Icon getExpIcon() {
player.closeInventory();
}
);
icon.display().setLore(Languages.MENU_RECIPE_CREATOR_ICON_COOKING_EXP_LORE.value());
icon.display().getLore().replaceAll(TextUtil::color);
ItemUtils.setLore(icon.display(), Languages.MENU_RECIPE_CREATOR_ICON_COOKING_EXP_LORE.value());
return icon;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.github.yufiriamazenta.craftorithm.config.PluginConfigs;
import com.github.yufiriamazenta.craftorithm.item.ItemManager;
import com.github.yufiriamazenta.craftorithm.item.impl.CraftorithmItemProvider;
import com.google.common.base.Preconditions;
import crypticlib.util.ItemUtil;
import crypticlib.util.TextUtil;
import org.bukkit.inventory.ItemStack;
Expand Down Expand Up @@ -91,4 +92,16 @@ public static String matchItemNameOrCreate(ItemStack item, boolean ignoreAmount)
return itemName;
}

public static void setLore(ItemStack item, List<String> lore) {
setLore(item, lore, true);
}

public static void setLore(ItemStack item, List<String> lore, boolean format) {
Preconditions.checkArgument(!ItemUtil.isAir(item), "Item can not be air");
ItemMeta itemMeta = item.getItemMeta();
itemMeta.setLore(lore);
if (format)
itemMeta.getLore().replaceAll(TextUtil::color);
}

}

0 comments on commit 21ff328

Please sign in to comment.