Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions API/src/main/java/fr/maxlego08/menu/api/MenuItemStack.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,26 @@ public interface MenuItemStack extends MenuItemStackContext {
*
* @param durability the durability to apply.
*/
/**
* This méthod is deprecated, now use placeholder support
* Use getDura or parseDura
* @return durability
*/
@Deprecated
int getDurability();

String getDura();

int parseDura(Player player);

int parseDura(OfflinePlayer offlinePlayer, Placeholders placeholders);

void setDurability(int durability);

void setDurability(String durability);

Potion getPotion();

/**
* Applies a potion configuration to this item stack.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import fr.maxlego08.menu.api.utils.Placeholders;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

Expand Down Expand Up @@ -29,4 +30,6 @@ public interface BuildContext {
* @return The placeholders used by the build context.
*/
@NotNull Placeholders getPlaceholders();

ItemStack getItemStack();
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package fr.maxlego08.menu.common.context;
package fr.maxlego08.menu.api.context;

import fr.maxlego08.menu.api.context.BuildContext;
import fr.maxlego08.menu.api.utils.Placeholders;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

public class ZBuildContext implements BuildContext {
private final ItemStack baseItemStack;

private final Player player;
private final boolean useCache;
Expand All @@ -17,6 +18,7 @@ private ZBuildContext(@NotNull Builder builder) {
this.player = builder.player;
this.useCache = builder.useCache;
this.placeholders = builder.placeholders;
this.baseItemStack = builder.baseItemStack;
}

@Override
Expand All @@ -34,10 +36,16 @@ public boolean isUseCache() {
return this.placeholders;
}

@Override
public ItemStack getItemStack() {
return this.baseItemStack;
}

public static class Builder {
private Player player;
private boolean useCache = true;
private final Placeholders placeholders = new Placeholders();
private ItemStack baseItemStack;

@Contract("_ -> this")
public Builder player(@Nullable Player player) {
Expand All @@ -57,9 +65,15 @@ public Builder placeholders(@NotNull Placeholders placeholders) {
return this;
}

@Contract("_ -> this")
public Builder baseItemStack(@Nullable ItemStack baseItemStack) {
this.baseItemStack = baseItemStack;
return this;
}

@Contract("-> new")
public ZBuildContext build() {
return new ZBuildContext(this);
}
}
}
}
Loading
Loading