Skip to content

Commit

Permalink
[1.10.8]修复#69
Browse files Browse the repository at this point in the history
  • Loading branch information
YufiriaMazenta committed Aug 3, 2024
1 parent 9e072d2 commit badf7b3
Show file tree
Hide file tree
Showing 20 changed files with 123 additions and 94 deletions.
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import java.text.SimpleDateFormat
version = "1.10.7"
version = "1.10.8"

plugins {
`java-library`
Expand Down Expand Up @@ -45,7 +45,7 @@ dependencies {
compileOnly("io.lumine:MythicLib-dist:1.6.2-SNAPSHOT")
compileOnly("net.Indyuce:MMOItems-API:6.9.5-SNAPSHOT")
compileOnly("com.willfp:EcoEnchants:12.5.1")
implementation("com.crypticlib:CrypticLib:0.18.3")
implementation("com.crypticlib:CrypticLib:0.18.10-viewfix5")
// implementation("de.tr7zw:item-nbt-api:2.12.4")
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
package com.github.yufiriamazenta.craftorithm.config;

import crypticlib.config.ConfigHandler;
import crypticlib.config.entry.BooleanConfigEntry;
import crypticlib.config.entry.StringConfigEntry;
import crypticlib.config.entry.StringListConfigEntry;
import crypticlib.config.entry.BooleanConfig;
import crypticlib.config.entry.StringConfig;
import crypticlib.config.entry.StringListConfig;

import java.util.ArrayList;
import java.util.Collections;

@ConfigHandler(path = "config.yml")
public class PluginConfigs {

public final static BooleanConfigEntry CHECK_UPDATE = new BooleanConfigEntry("check_update", true);
public final static BooleanConfigEntry REMOVE_ALL_VANILLA_RECIPE = new BooleanConfigEntry("remove_all_vanilla_recipe", false);
public final static StringConfigEntry LORE_CANNOT_CRAFT = new StringConfigEntry("lore_cannot_craft", ".*不可用于合成.*");
public final static BooleanConfigEntry DEFAULT_RECIPE_UNLOCK = new BooleanConfigEntry("default_recipe_unlock", false);
public final static BooleanConfigEntry BSTATS = new BooleanConfigEntry("bstats", true);
public final static BooleanConfigEntry RELEASE_DEFAULT_RECIPES = new BooleanConfigEntry("release_default_recipes", false);
public final static BooleanConfigEntry ENABLE_ANVIL_RECIPE = new BooleanConfigEntry("enable_anvil_recipe", true);
public final static BooleanConfigEntry RELOAD_WHEN_IA_RELOAD = new BooleanConfigEntry("reload_when_ia_reload", true);
public final static BooleanConfigEntry DEBUG = new BooleanConfigEntry("debug", false);
public final static BooleanConfig CHECK_UPDATE = new BooleanConfig("check_update", true);
public final static BooleanConfig REMOVE_ALL_VANILLA_RECIPE = new BooleanConfig("remove_all_vanilla_recipe", false);
public final static StringConfig LORE_CANNOT_CRAFT = new StringConfig("lore_cannot_craft", ".*不可用于合成.*");
public final static BooleanConfig DEFAULT_RECIPE_UNLOCK = new BooleanConfig("default_recipe_unlock", false);
public final static BooleanConfig BSTATS = new BooleanConfig("bstats", true);
public final static BooleanConfig RELEASE_DEFAULT_RECIPES = new BooleanConfig("release_default_recipes", false);
public final static BooleanConfig ENABLE_ANVIL_RECIPE = new BooleanConfig("enable_anvil_recipe", true);
public final static BooleanConfig RELOAD_WHEN_IA_RELOAD = new BooleanConfig("reload_when_ia_reload", true);
public final static BooleanConfig DEBUG = new BooleanConfig("debug", false);

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
import com.github.yufiriamazenta.craftorithm.util.CollectionsUtil;
import com.github.yufiriamazenta.craftorithm.util.ItemUtils;
import crypticlib.listener.BukkitListener;
import crypticlib.util.InventoryUtil;
import crypticlib.util.ItemUtil;
import org.bukkit.OfflinePlayer;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
Expand Down Expand Up @@ -53,7 +53,8 @@ public void runConditions(PrepareAnvilEvent event) {
//进行condition判断
YamlConfiguration config = RecipeManager.INSTANCE.getRecipeConfig(anvilRecipe.key());
if (config != null) {
Player player = (Player) event.getView().getPlayer();
Object inventoryView = InventoryUtil.getInventoryView(event);
Player player = (Player) InventoryUtil.getInventoryViewPlayer(inventoryView);
String condition = config.getString("condition", "true");
condition = "if " + condition;
boolean conditionResult = (boolean) ArcencielDispatcher.INSTANCE.dispatchArcencielBlock(player, condition).obj();
Expand Down Expand Up @@ -147,15 +148,15 @@ public void matchAnvilResult(InventoryClickEvent event) {
if (ItemUtil.isAir(cursor)) {
base.setAmount(baseNum - needBaseNum);
addition.setAmount(additionNum - needAdditionNum);
event.getView().setCursor(result);
event.setCursor(result);
player.setLevel(player.getLevel() - costLevel);
} else {
int resultCursor = cursor.getAmount() + result.getAmount();
if (resultCursor > result.getMaxStackSize())
break;
base.setAmount(baseNum - needBaseNum);
addition.setAmount(additionNum - needAdditionNum);
event.getView().getCursor().setAmount(resultCursor);
event.getCursor().setAmount(resultCursor);
player.setLevel(player.getLevel() - costLevel);
}
craftResult = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.github.yufiriamazenta.craftorithm.recipe.RecipeManager;
import com.github.yufiriamazenta.craftorithm.util.ItemUtils;
import crypticlib.listener.BukkitListener;
import crypticlib.util.InventoryUtil;
import org.bukkit.NamespacedKey;
import org.bukkit.OfflinePlayer;
import org.bukkit.configuration.file.YamlConfiguration;
Expand Down Expand Up @@ -56,7 +57,8 @@ public void runConditions(PrepareItemCraftEvent event) {
if (config == null)
return;

Player player = (Player) event.getView().getPlayer();
Object inventoryView = InventoryUtil.getInventoryView(event);
Player player = (Player) InventoryUtil.getInventoryViewPlayer(inventoryView);
String condition = config.getString("condition", "true");
condition = "if " + condition;
boolean result = (boolean) ArcencielDispatcher.INSTANCE.dispatchArcencielBlock(player, condition).obj();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.github.yufiriamazenta.craftorithm.item.ItemManager;
import crypticlib.listener.BukkitListener;
import crypticlib.util.InventoryUtil;
import crypticlib.util.ItemUtil;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
Expand All @@ -20,10 +21,9 @@ public class CustomFuelHandler implements Listener {
public void putFuelOnClick(InventoryClickEvent event) {
if (event.isCancelled())
return;
Inventory topInventory = event.getView().getTopInventory();
if (!(topInventory instanceof FurnaceInventory))
Inventory topInventory = InventoryUtil.getTopInventory(event);
if (!(topInventory instanceof FurnaceInventory furnaceInventory))
return;
FurnaceInventory furnaceInventory = (FurnaceInventory) topInventory;
Inventory clickInv = event.getClickedInventory();
ItemStack current = event.getCurrentItem();
int slot = event.getSlot();
Expand All @@ -48,9 +48,9 @@ public void putFuelOnClick(InventoryClickEvent event) {
current.setAmount(current.getAmount() + Math.min(cursor.getAmount(), canPlaceAmount));
cursor.setAmount(cursor.getAmount() - canPlaceAmount);
event.setCurrentItem(current);
event.getView().setCursor(cursor);
event.setCursor(cursor);
} else {
event.getView().setCursor(current);
event.setCursor(current);
event.setCurrentItem(cursor);
}
((Player) event.getWhoClicked()).updateInventory();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ public void executeListener(Event event, List<RegisteredListener> registeredList
for (RegisteredListener prepareCraftIAListener : registeredListeners) {
try {
getRegisteredListenerExecutor(prepareCraftIAListener).execute(prepareCraftIAListener.getListener(), event);
} catch (EventException e) {
} catch (Throwable e) {
e.printStackTrace();
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.github.yufiriamazenta.craftorithm.util.CollectionsUtil;
import com.github.yufiriamazenta.craftorithm.util.ItemUtils;
import crypticlib.listener.BukkitListener;
import crypticlib.util.InventoryUtil;
import org.bukkit.NamespacedKey;
import org.bukkit.OfflinePlayer;
import org.bukkit.configuration.file.YamlConfiguration;
Expand Down Expand Up @@ -90,7 +91,8 @@ public void runConditions(PrepareSmithingEvent event) {
if (config == null)
return;

Player player = (Player) event.getView().getPlayer();
Object inventoryView = InventoryUtil.getInventoryView(event);
Player player = (Player) InventoryUtil.getInventoryViewPlayer(inventoryView);
String condition = config.getString("condition", "true");
condition = "if " + condition;
boolean result = (boolean) ArcencielDispatcher.INSTANCE.dispatchArcencielBlock(player, condition).obj();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.function.Supplier;

public class AnvilRecipeCreator extends RecipeCreator {

Expand All @@ -50,13 +51,13 @@ public AnvilRecipeCreator(@NotNull Player player, @NotNull String recipeName) {
"#***#%%%#",
"#########"
), () -> {
Map<Character, Icon> layoutMap = new HashMap<>();
layoutMap.put('#', getFrameIcon());
layoutMap.put('%', getResultFrameIcon());
layoutMap.put('*', new Icon(Material.CYAN_STAINED_GLASS_PANE, Languages.MENU_RECIPE_CREATOR_ICON_ANVIL_FRAME.value(player)));
layoutMap.put('B', getCopyNbtIcon());
layoutMap.put('C', getCostLevelIcon());
layoutMap.put('A', new Icon(Material.ANVIL, Languages.MENU_RECIPE_CREATOR_ICON_CONFIRM.value(player))
Map<Character, Supplier<Icon>> layoutMap = new HashMap<>();
layoutMap.put('#', this::getFrameIcon);
layoutMap.put('%', this::getResultFrameIcon);
layoutMap.put('*', () -> new Icon(Material.CYAN_STAINED_GLASS_PANE, Languages.MENU_RECIPE_CREATOR_ICON_ANVIL_FRAME.value(player)));
layoutMap.put('B', this::getCopyNbtIcon);
layoutMap.put('C', this::getCostLevelIcon);
layoutMap.put('A', () -> new Icon(Material.ANVIL, Languages.MENU_RECIPE_CREATOR_ICON_CONFIRM.value(player))
.setClickAction(
event -> {
StoredMenu creator = (StoredMenu) event.getClickedInventory().getHolder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.jetbrains.annotations.Nullable;

import java.util.*;
import java.util.function.Supplier;

public class CookingRecipeCreator extends UnlockableRecipeCreator {

Expand Down Expand Up @@ -52,21 +53,21 @@ public CookingRecipeCreator(@NotNull Player player, @NotNull String recipeName)
"#***#%%%#",
"##BC#DE##"
), () -> {
Map<Character, Icon> layoutMap = new HashMap<>();
layoutMap.put('#', getFrameIcon());
layoutMap.put('%', getResultFrameIcon());
layoutMap.put('*', new Icon(
Map<Character, Supplier<Icon>> layoutMap = new HashMap<>();
layoutMap.put('#', this::getFrameIcon);
layoutMap.put('%', this::getResultFrameIcon);
layoutMap.put('*', () -> new Icon(
Material.CYAN_STAINED_GLASS_PANE,
Languages.MENU_RECIPE_CREATOR_ICON_COOKING_FRAME.value(player)
));
layoutMap.put('B', getCookingToggleIcon(Material.FURNACE));
layoutMap.put('C', getCookingToggleIcon(Material.BLAST_FURNACE));
layoutMap.put('D', getCookingToggleIcon(Material.SMOKER));
layoutMap.put('E', getCookingToggleIcon(Material.CAMPFIRE));
layoutMap.put('F', getUnlockIcon());
layoutMap.put('G', getCookingTimeIcon());
layoutMap.put('H', getExpIcon());
layoutMap.put('A', new Icon(
layoutMap.put('B', () -> getCookingToggleIcon(Material.FURNACE));
layoutMap.put('C', () -> getCookingToggleIcon(Material.BLAST_FURNACE));
layoutMap.put('D', () -> getCookingToggleIcon(Material.SMOKER));
layoutMap.put('E', () -> getCookingToggleIcon(Material.CAMPFIRE));
layoutMap.put('F', this::getUnlockIcon);
layoutMap.put('G', this::getCookingTimeIcon);
layoutMap.put('H', this::getExpIcon);
layoutMap.put('A', () -> new Icon(
Material.FURNACE, Languages.MENU_RECIPE_CREATOR_ICON_CONFIRM.value(player)
).setClickAction(
event -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.jetbrains.annotations.NotNull;

import java.util.*;
import java.util.function.Supplier;

public class CraftingRecipeCreator extends UnlockableRecipeCreator {

Expand All @@ -35,11 +36,11 @@ public CraftingRecipeCreator(@NotNull Player player, RecipeType recipeType, @Not
"# #***#",
"#########"
), () -> {
Map<Character, Icon> layoutMap = new HashMap<>();
layoutMap.put('#', getFrameIcon());
layoutMap.put('*', getResultFrameIcon());
layoutMap.put('F', getUnlockIcon());
layoutMap.put('A', new Icon(
Map<Character, Supplier<Icon>> layoutMap = new HashMap<>();
layoutMap.put('#', this::getFrameIcon);
layoutMap.put('*', this::getResultFrameIcon);
layoutMap.put('F', this::getUnlockIcon);
layoutMap.put('A', () -> new Icon(
Material.CRAFTING_TABLE,
Languages.MENU_RECIPE_CREATOR_ICON_CONFIRM.value(player)
).setClickAction(event -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.function.Supplier;

public class PotionMixCreator extends RecipeCreator {

Expand All @@ -34,14 +35,14 @@ public PotionMixCreator(@NotNull Player player, @NotNull String recipeName) {
"#***#%%%#",
"#########"
), () -> {
Map<Character, Icon> layoutMap = new HashMap<>();
layoutMap.put('#', getFrameIcon());
layoutMap.put('%', getResultFrameIcon());
layoutMap.put('*', new Icon(
Map<Character, Supplier<Icon>> layoutMap = new HashMap<>();
layoutMap.put('#', this::getFrameIcon);
layoutMap.put('%', this::getResultFrameIcon);
layoutMap.put('*', () -> new Icon(
Material.CYAN_STAINED_GLASS_PANE,
Languages.MENU_RECIPE_CREATOR_ICON_POTION_FRAME.value(player)
));
layoutMap.put('A', new Icon(
layoutMap.put('A', () -> new Icon(
Material.BREWING_STAND,
Languages.MENU_RECIPE_CREATOR_ICON_CONFIRM.value(player)
).setClickAction(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.function.Supplier;

public class SmithingRecipeCreator extends UnlockableRecipeCreator {

Expand All @@ -40,16 +41,16 @@ public SmithingRecipeCreator(@NotNull Player player, @NotNull String recipeName)
"####B####"
),
() -> {
Map<Character, Icon> layoutMap = new HashMap<>();
layoutMap.put('#', getFrameIcon());
layoutMap.put('*', new Icon(
Map<Character, Supplier<Icon>> layoutMap = new HashMap<>();
layoutMap.put('#', this::getFrameIcon);
layoutMap.put('*', () -> new Icon(
Material.CYAN_STAINED_GLASS_PANE,
Languages.MENU_RECIPE_CREATOR_ICON_SMITHING_FRAME.value(player)
));
layoutMap.put('%', getResultFrameIcon());
layoutMap.put('F', getUnlockIcon());
layoutMap.put('B', getCopyNbtIcon());
layoutMap.put('A', new Icon(
layoutMap.put('%', this::getResultFrameIcon);
layoutMap.put('F', this::getUnlockIcon);
layoutMap.put('B', this::getCopyNbtIcon);
layoutMap.put('A', () -> new Icon(
Material.SMITHING_TABLE,
Languages.MENU_RECIPE_CREATOR_ICON_CONFIRM.value(player)
).setClickAction(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.jetbrains.annotations.NotNull;

import java.util.*;
import java.util.function.Supplier;

public class StoneCuttingRecipeCreator extends UnlockableRecipeCreator {

Expand All @@ -31,10 +32,10 @@ public StoneCuttingRecipeCreator(@NotNull Player player, @NotNull String recipeN
"# #",
"#########"
), () -> {
Map<Character, Icon> layoutMap = new HashMap<>();
layoutMap.put('#', getFrameIcon());
layoutMap.put('F', getUnlockIcon());
layoutMap.put('A', new Icon(
Map<Character, Supplier<Icon>> layoutMap = new HashMap<>();
layoutMap.put('#', this::getFrameIcon);
layoutMap.put('F', this::getUnlockIcon);
layoutMap.put('A', () -> new Icon(
Material.STONECUTTER,
Languages.MENU_RECIPE_CREATOR_ICON_CONFIRM.value(player)
).setClickAction(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.jetbrains.annotations.Nullable;

import java.util.*;
import java.util.function.Supplier;

public class AnvilRecipeGroupEditor extends RecipeGroupEditor {

Expand All @@ -39,12 +40,12 @@ public AnvilRecipeGroupEditor(@NotNull Player player, @NotNull RecipeGroup recip
"#########"
),
() -> {
Map<Character, Icon> iconMap = new HashMap<>();
iconMap.put('#', getFrameIcon());
iconMap.put('A', getSortIdEditIcon(4));
iconMap.put('X', getPreviousIcon());
iconMap.put('Y', getNextIcon());
iconMap.put('Z', getRemoveIcon());
Map<Character, Supplier<Icon>> iconMap = new HashMap<>();
iconMap.put('#', this::getFrameIcon);
iconMap.put('A', () -> getSortIdEditIcon(4));
iconMap.put('X', this::getPreviousIcon);
iconMap.put('Y', this::getNextIcon);
iconMap.put('Z', this::getRemoveIcon);
//TODO condition和action
return iconMap;
}
Expand Down
Loading

0 comments on commit badf7b3

Please sign in to comment.