mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-06-23 16:16:17 +02:00
prepare for v2
This commit is contained in:
parent
c1d67a3821
commit
eb40383068
18 changed files with 64 additions and 337 deletions
4
.github/workflows/gradle.yml
vendored
4
.github/workflows/gradle.yml
vendored
|
|
@ -9,9 +9,9 @@ name: Java CI with Gradle
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ "v1.x.x", "v2.x.x" ]
|
branches: [ "v1.x.x", "v2.x.x", "v3.x.x" ]
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [ "v1.x.x", "v2.x.x" ]
|
branches: [ "v1.x.x", "v2.x.x", "v3.x.x" ]
|
||||||
release:
|
release:
|
||||||
types: [published]
|
types: [published]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ plugins {
|
||||||
}
|
}
|
||||||
|
|
||||||
group = "xyz.alexcrea"
|
group = "xyz.alexcrea"
|
||||||
version = "1.17.5"
|
version = "2.0.0"
|
||||||
|
|
||||||
val isDevBuild = System.getenv("SMALL_COMMIT_HASH") != null
|
val isDevBuild = System.getenv("SMALL_COMMIT_HASH") != null
|
||||||
val isPreRelease = System.getenv("IS_GITHUB_PRERELEASE") == "true"
|
val isPreRelease = System.getenv("IS_GITHUB_PRERELEASE") == "true"
|
||||||
|
|
|
||||||
|
|
@ -90,29 +90,6 @@ public class AnvilRecipeBuilder {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the xp level cost per craft. (default 0)
|
|
||||||
*
|
|
||||||
* @return The xp level cost per craft
|
|
||||||
* @deprecated use {@link #getLevelCostPerCraft() getLevelCostPerCraft} instead
|
|
||||||
*/
|
|
||||||
@Deprecated(since = "1.13.0")
|
|
||||||
public int getXpCostPerCraft() {
|
|
||||||
return getLevelCostPerCraft();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the xp level cost per craft.
|
|
||||||
*
|
|
||||||
* @param xpCostPerCraft The xp level cost per craft
|
|
||||||
* @return This recipe builder instance.
|
|
||||||
* @deprecated use {@link #setLevelCostPerCraft(int) setLevelCostPerCraft} instead
|
|
||||||
*/
|
|
||||||
@Deprecated(since = "1.13.0")
|
|
||||||
public AnvilRecipeBuilder setXpCostPerCraft(int xpCostPerCraft) {
|
|
||||||
return setLevelCostPerCraft(xpCostPerCraft);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the xp level cost per craft. (default 0)
|
* Get the xp level cost per craft. (default 0)
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -387,7 +387,7 @@ public class ConflictBuilder {
|
||||||
*/
|
*/
|
||||||
protected void appendEnchantments(@NotNull EnchantConflictGroup conflict) {
|
protected void appendEnchantments(@NotNull EnchantConflictGroup conflict) {
|
||||||
for (String enchantmentName : getEnchantmentNames()) {
|
for (String enchantmentName : getEnchantmentNames()) {
|
||||||
if (appendEnchantments(conflict, EnchantmentApi.getListByName(enchantmentName)) == 0) {
|
if (appendEnchantments(conflict, EnchantmentApi.getByName(enchantmentName)) == 0) {
|
||||||
CustomAnvil.instance.getLogger().warning("Could not find enchantment " + enchantmentName + " for conflict " + getName());
|
CustomAnvil.instance.getLogger().warning("Could not find enchantment " + enchantmentName + " for conflict " + getName());
|
||||||
ConflictAPI.logConflictOrigin(this);
|
ConflictAPI.logConflictOrigin(this);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -131,27 +131,14 @@ public class EnchantmentApi {
|
||||||
return CAEnchantment.getByKey(key);
|
return CAEnchantment.getByKey(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get by name an enchantment.
|
|
||||||
*
|
|
||||||
* @param name The name used to fetch
|
|
||||||
* @return The custom anvil enchantment of this name. null if not found.
|
|
||||||
* @deprecated use {@link #getListByName(String)}
|
|
||||||
*/
|
|
||||||
@Deprecated(since = "1.6.3")
|
|
||||||
@Nullable
|
|
||||||
public static CAEnchantment getByName(@NotNull String name){
|
|
||||||
return CAEnchantment.getByName(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get list of enchantment using the provided name.
|
* Get list of enchantment using the provided name.
|
||||||
*
|
*
|
||||||
* @param name The name used to fetch
|
* @param name The name used to fetch
|
||||||
* @return List of custom anvil enchantments of this name. May be empty if not found.
|
* @return List of custom anvil enchantments of this name. May be empty if not found.
|
||||||
*/
|
*/
|
||||||
public static List<CAEnchantment> getListByName(@NotNull String name){
|
public static List<CAEnchantment> getByName(@NotNull String name){
|
||||||
return CAEnchantment.getListByName(name);
|
return CAEnchantment.getByName(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ import org.jetbrains.annotations.NotNull;
|
||||||
* Most of the time you would likely need {@link CAPreAnvilBypassEvent} or {@link CAEarlyPreAnvilBypassEvent}
|
* Most of the time you would likely need {@link CAPreAnvilBypassEvent} or {@link CAEarlyPreAnvilBypassEvent}
|
||||||
* for this event to be useful.
|
* for this event to be useful.
|
||||||
* <p>
|
* <p>
|
||||||
* There is also {@link CATreatAnvilResult2Event} that may be better for some use case.
|
* There is also {@link CATreatAnvilResultEvent} that may be better for some use case.
|
||||||
*/
|
*/
|
||||||
public class CAClickResultBypassEvent extends Event implements Cancellable {
|
public class CAClickResultBypassEvent extends Event implements Cancellable {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ import org.jetbrains.annotations.NotNull;
|
||||||
* <p>
|
* <p>
|
||||||
* You should also use {@link CAClickResultBypassEvent} if you want to use this event for something useful.
|
* You should also use {@link CAClickResultBypassEvent} if you want to use this event for something useful.
|
||||||
* <p>
|
* <p>
|
||||||
* It is also recommended that you read about {@link CAPreAnvilBypassEvent} and {@link CATreatAnvilResult2Event}
|
* It is also recommended that you read about {@link CAPreAnvilBypassEvent} and {@link CATreatAnvilResultEvent}
|
||||||
* as your use case may be more prone to use theses.
|
* as your use case may be more prone to use theses.
|
||||||
*/
|
*/
|
||||||
public class CAEarlyPreAnvilBypassEvent extends Event implements Cancellable {
|
public class CAEarlyPreAnvilBypassEvent extends Event implements Cancellable {
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ import org.jetbrains.annotations.NotNull;
|
||||||
* <p>
|
* <p>
|
||||||
* You should also use {@link CAClickResultBypassEvent} if you want to use this event for something useful.
|
* You should also use {@link CAClickResultBypassEvent} if you want to use this event for something useful.
|
||||||
* <p>
|
* <p>
|
||||||
* It is also recommended that you read about {@link CAEarlyPreAnvilBypassEvent} and {@link CATreatAnvilResult2Event}
|
* It is also recommended that you read about {@link CAEarlyPreAnvilBypassEvent} and {@link CATreatAnvilResultEvent}
|
||||||
* as your use case may be more prone to use theses.
|
* as your use case may be more prone to use theses.
|
||||||
*/
|
*/
|
||||||
public class CAPreAnvilBypassEvent extends Event implements Cancellable {
|
public class CAPreAnvilBypassEvent extends Event implements Cancellable {
|
||||||
|
|
|
||||||
|
|
@ -1,191 +0,0 @@
|
||||||
package xyz.alexcrea.cuanvil.api.event.listener;
|
|
||||||
|
|
||||||
import org.bukkit.event.Event;
|
|
||||||
import org.bukkit.event.HandlerList;
|
|
||||||
import org.bukkit.inventory.Inventory;
|
|
||||||
import org.bukkit.inventory.InventoryView;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
import org.bukkit.inventory.view.AnvilView;
|
|
||||||
import org.jetbrains.annotations.ApiStatus;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
import xyz.alexcrea.cuanvil.anvil.AnvilCost;
|
|
||||||
import xyz.alexcrea.cuanvil.anvil.AnvilUseType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called after custom anvil processed the click on the result on the anvil inventory.
|
|
||||||
* This event should be used to modify the result of an anvil use.
|
|
||||||
* <p>
|
|
||||||
* You may also want to check {@link CAClickResultBypassEvent},
|
|
||||||
* {@link CAPreAnvilBypassEvent}
|
|
||||||
* and {@link CAEarlyPreAnvilBypassEvent} for your use case
|
|
||||||
* <p>
|
|
||||||
* A null result will cancel this event
|
|
||||||
*/
|
|
||||||
@SuppressWarnings({"unused", "UnstableApiUsage"})
|
|
||||||
public class CATreatAnvilResult2Event extends Event {
|
|
||||||
|
|
||||||
private static final HandlerList HANDLERS = new HandlerList();
|
|
||||||
|
|
||||||
public static HandlerList getHandlerList() {
|
|
||||||
return HANDLERS;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NotNull HandlerList getHandlers() {
|
|
||||||
return HANDLERS;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
private final AnvilView view;
|
|
||||||
|
|
||||||
private final AnvilUseType useType;
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
private final ItemStack left;
|
|
||||||
@Nullable
|
|
||||||
private final ItemStack right;
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
private ItemStack result;
|
|
||||||
|
|
||||||
private final AnvilCost cost;
|
|
||||||
|
|
||||||
public CATreatAnvilResult2Event(
|
|
||||||
@NotNull AnvilView view,
|
|
||||||
AnvilUseType useType,
|
|
||||||
@Nullable ItemStack result,
|
|
||||||
AnvilCost cost) {
|
|
||||||
this.view = view;
|
|
||||||
this.useType = useType;
|
|
||||||
|
|
||||||
this.left = view.getItem(0);
|
|
||||||
this.right = view.getItem(1);
|
|
||||||
this.result = result;
|
|
||||||
this.cost = cost;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the bukkit inventory view.
|
|
||||||
*
|
|
||||||
* @return The inventory view of this event.
|
|
||||||
*/
|
|
||||||
public @NotNull AnvilView getView() {
|
|
||||||
return view;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the type of use source of the result.
|
|
||||||
*
|
|
||||||
* @return The craft use type.
|
|
||||||
*/
|
|
||||||
public AnvilUseType getUseType() {
|
|
||||||
return useType;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the left item of the anvil use
|
|
||||||
*
|
|
||||||
* @return the left item
|
|
||||||
*/
|
|
||||||
public @Nullable ItemStack getLeftItem() {
|
|
||||||
return left;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the right item of the anvil use
|
|
||||||
*
|
|
||||||
* @return the right item
|
|
||||||
*/
|
|
||||||
public @Nullable ItemStack getRightItem() {
|
|
||||||
return right;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the current result
|
|
||||||
* <p>
|
|
||||||
* note that it will not be null unless another listener previously set it to null.
|
|
||||||
*
|
|
||||||
* @return The current result.
|
|
||||||
*/
|
|
||||||
public @Nullable ItemStack getResult() {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the current result
|
|
||||||
* <p>
|
|
||||||
* note that a null result will cancel this anvil use.
|
|
||||||
*
|
|
||||||
* @param result The new result
|
|
||||||
*/
|
|
||||||
public void setResult(@Nullable ItemStack result) {
|
|
||||||
this.result = result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the level cost displayed on the anvil.
|
|
||||||
* <h3>Important note:</h3>
|
|
||||||
* the final price are re calculated on click for the following use case:
|
|
||||||
* <ul>
|
|
||||||
* <li>Custom craft</li>
|
|
||||||
* <li>Unit repair</li>
|
|
||||||
* <li>Lore edit</li>
|
|
||||||
* </ul>
|
|
||||||
* This value will be used as final price for:
|
|
||||||
* <li>Item merge</li>
|
|
||||||
* <li>Item rename</li>
|
|
||||||
* </ul>
|
|
||||||
*
|
|
||||||
* @return The current cost.
|
|
||||||
* @deprecated use #{@link #getCost()} instead
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true, since = "1.17.0")
|
|
||||||
public int getLevelCost() {
|
|
||||||
return cost.asXpCost();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the level cost displayed on the anvil.
|
|
||||||
* <h3>Important note:</h3>
|
|
||||||
* the final price are re calculated on click for the following use case:
|
|
||||||
* <ul>
|
|
||||||
* <li>Custom craft</li>
|
|
||||||
* <li>Unit repair</li>
|
|
||||||
* <li>Lore edit</li>
|
|
||||||
* </ul>
|
|
||||||
* This value will be used as final price for:
|
|
||||||
* <li>Item merge</li>
|
|
||||||
* <li>Item rename</li>
|
|
||||||
* </ul>
|
|
||||||
*
|
|
||||||
* @param levelCost The new cost.
|
|
||||||
* @deprecated use #{@link #getCost()} and set value on this instead
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true, since = "1.17.0")
|
|
||||||
public void setLevelCost(int levelCost) {
|
|
||||||
cost.setGeneric(levelCost - cost.getGeneric() - cost.asXpCost());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Allow access to the current cost of the event
|
|
||||||
* Note that modifying this object will change the event resulting cost
|
|
||||||
*
|
|
||||||
* <h3>Important note:</h3>
|
|
||||||
* the final price are re calculated on click for the following use case:
|
|
||||||
* <ul>
|
|
||||||
* <li>Custom craft</li>
|
|
||||||
* <li>Unit repair</li>
|
|
||||||
* <li>Lore edit</li>
|
|
||||||
* </ul>
|
|
||||||
* This value will be used as final price for:
|
|
||||||
* <li>Item merge</li>
|
|
||||||
* <li>Item rename</li>
|
|
||||||
*
|
|
||||||
* @return the current anvil cost
|
|
||||||
*/
|
|
||||||
public AnvilCost getCost() {
|
|
||||||
return cost;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -2,8 +2,8 @@ package xyz.alexcrea.cuanvil.api.event.listener;
|
||||||
|
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
import org.bukkit.event.inventory.PrepareAnvilEvent;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.view.AnvilView;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import xyz.alexcrea.cuanvil.anvil.AnvilCost;
|
import xyz.alexcrea.cuanvil.anvil.AnvilCost;
|
||||||
|
|
@ -17,13 +17,9 @@ import xyz.alexcrea.cuanvil.anvil.AnvilUseType;
|
||||||
* {@link CAPreAnvilBypassEvent}
|
* {@link CAPreAnvilBypassEvent}
|
||||||
* and {@link CAEarlyPreAnvilBypassEvent} for your use case
|
* and {@link CAEarlyPreAnvilBypassEvent} for your use case
|
||||||
* <p>
|
* <p>
|
||||||
* A null result will cancel this pre anvil event
|
* A null result will cancel this event
|
||||||
*
|
|
||||||
* @deprecated Prepare anvil Event cannot be provided as it can be called on result and therefore not have prepared anvil event
|
|
||||||
* use {@link CATreatAnvilResult2Event} instead
|
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings({"unused", "UnstableApiUsage"})
|
||||||
@Deprecated(forRemoval = true, since = "1.17.0")
|
|
||||||
public class CATreatAnvilResultEvent extends Event {
|
public class CATreatAnvilResultEvent extends Event {
|
||||||
|
|
||||||
private static final HandlerList HANDLERS = new HandlerList();
|
private static final HandlerList HANDLERS = new HandlerList();
|
||||||
|
|
@ -38,31 +34,44 @@ public class CATreatAnvilResultEvent extends Event {
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private final PrepareAnvilEvent event;
|
private final AnvilView view;
|
||||||
|
|
||||||
private final AnvilUseType useType;
|
private final AnvilUseType useType;
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
private final ItemStack left;
|
||||||
|
@Nullable
|
||||||
|
private final ItemStack right;
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private ItemStack result;
|
private ItemStack result;
|
||||||
|
|
||||||
private final AnvilCost cost;
|
private final AnvilCost cost;
|
||||||
|
|
||||||
public CATreatAnvilResultEvent(@NotNull PrepareAnvilEvent event, AnvilUseType useType, @Nullable ItemStack result, AnvilCost cost) {
|
public CATreatAnvilResultEvent(
|
||||||
this.event = event;
|
@NotNull AnvilView view,
|
||||||
|
AnvilUseType useType,
|
||||||
|
@Nullable ItemStack result,
|
||||||
|
AnvilCost cost) {
|
||||||
|
this.view = view;
|
||||||
this.useType = useType;
|
this.useType = useType;
|
||||||
|
|
||||||
|
this.left = view.getItem(0);
|
||||||
|
this.right = view.getItem(1);
|
||||||
this.result = result;
|
this.result = result;
|
||||||
this.cost = cost;
|
this.cost = cost;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the bukkit inventory click event causing to this event.
|
* Get the bukkit inventory view.
|
||||||
*
|
*
|
||||||
* @return The click event causing to this event.
|
* @return The inventory view of this event.
|
||||||
*/
|
*/
|
||||||
public @NotNull PrepareAnvilEvent getEvent() {
|
public @NotNull AnvilView getView() {
|
||||||
return event;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the type of use source of the result.
|
* Get the type of use source of the result.
|
||||||
*
|
*
|
||||||
|
|
@ -72,6 +81,24 @@ public class CATreatAnvilResultEvent extends Event {
|
||||||
return useType;
|
return useType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the left item of the anvil use
|
||||||
|
*
|
||||||
|
* @return the left item
|
||||||
|
*/
|
||||||
|
public @Nullable ItemStack getLeftItem() {
|
||||||
|
return left;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the right item of the anvil use
|
||||||
|
*
|
||||||
|
* @return the right item
|
||||||
|
*/
|
||||||
|
public @Nullable ItemStack getRightItem() {
|
||||||
|
return right;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the current result
|
* Get the current result
|
||||||
* <p>
|
* <p>
|
||||||
|
|
@ -94,50 +121,6 @@ public class CATreatAnvilResultEvent extends Event {
|
||||||
this.result = result;
|
this.result = result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the level cost displayed on the anvil.
|
|
||||||
* <h3>Important note:</h3>
|
|
||||||
* the final price are re calculated on click for the following use case:
|
|
||||||
* <ul>
|
|
||||||
* <li>Custom craft</li>
|
|
||||||
* <li>Unit repair</li>
|
|
||||||
* <li>Lore edit</li>
|
|
||||||
* </ul>
|
|
||||||
* This value will be used as final price for:
|
|
||||||
* <li>Item merge</li>
|
|
||||||
* <li>Item rename</li>
|
|
||||||
* </ul>
|
|
||||||
*
|
|
||||||
* @return The current cost.
|
|
||||||
* @deprecated use #{@link #getCost()} instead
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true, since = "1.17.0")
|
|
||||||
public int getLevelCost() {
|
|
||||||
return cost.asXpCost();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the level cost displayed on the anvil.
|
|
||||||
* <h3>Important note:</h3>
|
|
||||||
* the final price are re calculated on click for the following use case:
|
|
||||||
* <ul>
|
|
||||||
* <li>Custom craft</li>
|
|
||||||
* <li>Unit repair</li>
|
|
||||||
* <li>Lore edit</li>
|
|
||||||
* </ul>
|
|
||||||
* This value will be used as final price for:
|
|
||||||
* <li>Item merge</li>
|
|
||||||
* <li>Item rename</li>
|
|
||||||
* </ul>
|
|
||||||
*
|
|
||||||
* @param levelCost The new cost.
|
|
||||||
* @deprecated use #{@link #getCost()} and set value on this instead
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true, since = "1.17.0")
|
|
||||||
public void setLevelCost(int levelCost) {
|
|
||||||
cost.setGeneric(levelCost - cost.getGeneric() - cost.asXpCost());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allow access to the current cost of the event
|
* Allow access to the current cost of the event
|
||||||
* Note that modifying this object will change the event resulting cost
|
* Note that modifying this object will change the event resulting cost
|
||||||
|
|
@ -158,5 +141,4 @@ public class CATreatAnvilResultEvent extends Event {
|
||||||
public AnvilCost getCost() {
|
public AnvilCost getCost() {
|
||||||
return cost;
|
return cost;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -225,25 +225,14 @@ public interface CAEnchantment {
|
||||||
return CAEnchantmentRegistry.getInstance().getByKey(key);
|
return CAEnchantmentRegistry.getInstance().getByKey(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the enchantment by the provided name.
|
|
||||||
* @param name Name to fetch.
|
|
||||||
* @return Registered enchantment. null if absent.
|
|
||||||
*
|
|
||||||
* @deprecated use {@link #getListByName(String)}
|
|
||||||
*/
|
|
||||||
@Deprecated(since = "1.6.3")
|
|
||||||
static @Nullable CAEnchantment getByName(@NotNull String name){
|
|
||||||
return CAEnchantmentRegistry.getInstance().getByName(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets list of enchantment using the provided name.
|
* Gets list of enchantment using the provided name.
|
||||||
|
*
|
||||||
* @param name Name to fetch.
|
* @param name Name to fetch.
|
||||||
* @return List of registered enchantment.
|
* @return List of registered enchantment.
|
||||||
*/
|
*/
|
||||||
static List<CAEnchantment> getListByName(@NotNull String name){
|
static List<CAEnchantment> getByName(@NotNull String name){
|
||||||
return CAEnchantmentRegistry.getInstance().getListByName(name);
|
return CAEnchantmentRegistry.getInstance().getByName(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -155,22 +155,6 @@ public class CAEnchantmentRegistry {
|
||||||
return byKeyMap.get(key);
|
return byKeyMap.get(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the enchantment by the provided name.
|
|
||||||
*
|
|
||||||
* @param name Name to fetch.
|
|
||||||
* @return Registered enchantment. null if absent.
|
|
||||||
* @deprecated use {@link #getListByName(String)}
|
|
||||||
*/
|
|
||||||
@Deprecated(since = "1.6.3")
|
|
||||||
@Nullable
|
|
||||||
public CAEnchantment getByName(@NotNull String name) {
|
|
||||||
List<CAEnchantment> enchantments = getListByName(name);
|
|
||||||
if (enchantments.isEmpty()) return null;
|
|
||||||
|
|
||||||
return enchantments.get(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets list of enchantment using the provided name.
|
* Gets list of enchantment using the provided name.
|
||||||
*
|
*
|
||||||
|
|
@ -178,7 +162,7 @@ public class CAEnchantmentRegistry {
|
||||||
* @return List of registered enchantment.
|
* @return List of registered enchantment.
|
||||||
*/
|
*/
|
||||||
@NotNull
|
@NotNull
|
||||||
public List<CAEnchantment> getListByName(@NotNull String name) {
|
public List<CAEnchantment> getByName(@NotNull String name) {
|
||||||
return byNameMap.getOrDefault(name, Collections.emptyList());
|
return byNameMap.getOrDefault(name, Collections.emptyList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,13 +10,13 @@ import org.bukkit.entity.Player
|
||||||
import org.bukkit.event.inventory.InventoryClickEvent
|
import org.bukkit.event.inventory.InventoryClickEvent
|
||||||
import org.bukkit.event.inventory.PrepareAnvilEvent
|
import org.bukkit.event.inventory.PrepareAnvilEvent
|
||||||
import org.bukkit.inventory.ItemStack
|
import org.bukkit.inventory.ItemStack
|
||||||
import xyz.alexcrea.cuanvil.anvil.AnvilCost
|
|
||||||
import org.bukkit.inventory.view.AnvilView
|
import org.bukkit.inventory.view.AnvilView
|
||||||
|
import xyz.alexcrea.cuanvil.anvil.AnvilCost
|
||||||
import xyz.alexcrea.cuanvil.anvil.AnvilUseType
|
import xyz.alexcrea.cuanvil.anvil.AnvilUseType
|
||||||
import xyz.alexcrea.cuanvil.api.event.listener.CAClickResultBypassEvent
|
import xyz.alexcrea.cuanvil.api.event.listener.CAClickResultBypassEvent
|
||||||
import xyz.alexcrea.cuanvil.api.event.listener.CAEarlyPreAnvilBypassEvent
|
import xyz.alexcrea.cuanvil.api.event.listener.CAEarlyPreAnvilBypassEvent
|
||||||
import xyz.alexcrea.cuanvil.api.event.listener.CAPreAnvilBypassEvent
|
import xyz.alexcrea.cuanvil.api.event.listener.CAPreAnvilBypassEvent
|
||||||
import xyz.alexcrea.cuanvil.api.event.listener.CATreatAnvilResult2Event
|
import xyz.alexcrea.cuanvil.api.event.listener.CATreatAnvilResultEvent
|
||||||
import xyz.alexcrea.cuanvil.config.ConfigHolder
|
import xyz.alexcrea.cuanvil.config.ConfigHolder
|
||||||
import xyz.alexcrea.cuanvil.dependency.datapack.DataPackDependency
|
import xyz.alexcrea.cuanvil.dependency.datapack.DataPackDependency
|
||||||
import xyz.alexcrea.cuanvil.dependency.gui.GenericExternGuiTester
|
import xyz.alexcrea.cuanvil.dependency.gui.GenericExternGuiTester
|
||||||
|
|
@ -237,7 +237,7 @@ object DependencyManager {
|
||||||
useType: AnvilUseType,
|
useType: AnvilUseType,
|
||||||
cost: AnvilCost
|
cost: AnvilCost
|
||||||
): ItemStack? {
|
): ItemStack? {
|
||||||
val treatEvent = CATreatAnvilResult2Event(view, useType, result, cost)
|
val treatEvent = CATreatAnvilResultEvent(view, useType, result, cost)
|
||||||
try {
|
try {
|
||||||
unsafeTryTreatAnvilResult(treatEvent)
|
unsafeTryTreatAnvilResult(treatEvent)
|
||||||
return treatEvent.result
|
return treatEvent.result
|
||||||
|
|
@ -247,7 +247,7 @@ object DependencyManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun unsafeTryTreatAnvilResult(event: CATreatAnvilResult2Event) {
|
private fun unsafeTryTreatAnvilResult(event: CATreatAnvilResultEvent) {
|
||||||
Bukkit.getPluginManager().callEvent(event)
|
Bukkit.getPluginManager().callEvent(event)
|
||||||
|
|
||||||
excellentEnchantsCompatibility?.treatAnvilResult(event)
|
excellentEnchantsCompatibility?.treatAnvilResult(event)
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
@file:Suppress("DEPRECATION")
|
||||||
|
|
||||||
package xyz.alexcrea.cuanvil.dependency.economy
|
package xyz.alexcrea.cuanvil.dependency.economy
|
||||||
|
|
||||||
import net.milkbowl.vault.economy.Economy
|
import net.milkbowl.vault.economy.Economy
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ import org.bukkit.event.inventory.PrepareAnvilEvent
|
||||||
import org.bukkit.inventory.ItemStack
|
import org.bukkit.inventory.ItemStack
|
||||||
import org.bukkit.plugin.RegisteredListener
|
import org.bukkit.plugin.RegisteredListener
|
||||||
import xyz.alexcrea.cuanvil.api.EnchantmentApi
|
import xyz.alexcrea.cuanvil.api.EnchantmentApi
|
||||||
import xyz.alexcrea.cuanvil.api.event.listener.CATreatAnvilResult2Event
|
import xyz.alexcrea.cuanvil.api.event.listener.CATreatAnvilResultEvent
|
||||||
import xyz.alexcrea.cuanvil.enchant.wrapped.CAEEPreV5Enchantment
|
import xyz.alexcrea.cuanvil.enchant.wrapped.CAEEPreV5Enchantment
|
||||||
import xyz.alexcrea.cuanvil.enchant.wrapped.CAEEV5Enchantment
|
import xyz.alexcrea.cuanvil.enchant.wrapped.CAEEV5Enchantment
|
||||||
import xyz.alexcrea.cuanvil.enchant.wrapped.CAEEV5_4Enchantment
|
import xyz.alexcrea.cuanvil.enchant.wrapped.CAEEV5_4Enchantment
|
||||||
|
|
@ -222,7 +222,7 @@ class ExcellentEnchantsDependency {
|
||||||
return handleRechargeMethod.invoke(this.usedAnvilListener, event, first, second) as Boolean
|
return handleRechargeMethod.invoke(this.usedAnvilListener, event, first, second) as Boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
fun treatAnvilResult(event: CATreatAnvilResult2Event) {
|
fun treatAnvilResult(event: CATreatAnvilResultEvent) {
|
||||||
val result = event.result ?: return
|
val result = event.result ?: return
|
||||||
|
|
||||||
val first: ItemStack = treatInput(event.leftItem)
|
val first: ItemStack = treatInput(event.leftItem)
|
||||||
|
|
|
||||||
|
|
@ -178,7 +178,7 @@ class EnchantConflictManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return CAEnchantment.getListByName(enchantName)
|
return CAEnchantment.getByName(enchantName)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,8 +9,6 @@ import org.bukkit.GameMode
|
||||||
import org.bukkit.NamespacedKey
|
import org.bukkit.NamespacedKey
|
||||||
import org.bukkit.entity.HumanEntity
|
import org.bukkit.entity.HumanEntity
|
||||||
import org.bukkit.entity.Player
|
import org.bukkit.entity.Player
|
||||||
import org.bukkit.inventory.AnvilInventory
|
|
||||||
import org.bukkit.inventory.InventoryView
|
|
||||||
import org.bukkit.inventory.ItemStack
|
import org.bukkit.inventory.ItemStack
|
||||||
import org.bukkit.inventory.meta.Repairable
|
import org.bukkit.inventory.meta.Repairable
|
||||||
import org.bukkit.inventory.view.AnvilView
|
import org.bukkit.inventory.view.AnvilView
|
||||||
|
|
@ -67,7 +65,6 @@ object AnvilXpUtil {
|
||||||
// Try first just in case another plugin, or the test need this
|
// Try first just in case another plugin, or the test need this
|
||||||
view.maximumRepairCost = maximumRepairCost
|
view.maximumRepairCost = maximumRepairCost
|
||||||
view.repairCost = anvilCost
|
view.repairCost = anvilCost
|
||||||
// TODO for 2.x.x use anvil view & set directly there
|
|
||||||
|
|
||||||
/* Because Minecraft likes to have the final say in the repair cost displayed
|
/* Because Minecraft likes to have the final say in the repair cost displayed
|
||||||
* we need to wait for the event to end before overriding it, this ensures that
|
* we need to wait for the event to end before overriding it, this ensures that
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,7 @@ public class AnvilFuseTestUtil {
|
||||||
List<CAEnchantment> enchantments = new ArrayList<>();
|
List<CAEnchantment> enchantments = new ArrayList<>();
|
||||||
|
|
||||||
for (String enchantmentName : enchantmentNames) {
|
for (String enchantmentName : enchantmentNames) {
|
||||||
List<CAEnchantment> enchantmentList = CAEnchantment.getListByName(enchantmentName);
|
List<CAEnchantment> enchantmentList = CAEnchantment.getByName(enchantmentName);
|
||||||
Assertions.assertNotEquals(0, enchantmentList.size(),
|
Assertions.assertNotEquals(0, enchantmentList.size(),
|
||||||
"Could not find enchantment \"" + enchantmentName + "\"");
|
"Could not find enchantment \"" + enchantmentName + "\"");
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue