the type of object to build
+ * @author anjoismysign
+ *
+ * A BlobObjectBuilder is an inventory that allows the user to build an object.
+ * The idea behind it is that through the Minecraft client, while connected
+ * to the Minecraft server, the user can build an object by interacting with
+ * a Bukkit Inventory / GUI.
+ */
+public abstract class BlobObjectBuilder extends BlobInventory {
+ private final UUID builderId;
+ private final HashMap> objectBuilderButtons;
+ private Function, T> function;
+
+ /**
+ * Constructs a new ObjectBuilder.
+ *
+ * @param blobInventory the inventory to use
+ * @param builderId the builder's UUID
+ */
+ public BlobObjectBuilder(@NotNull BlobInventory blobInventory,
+ @NotNull UUID builderId) {
+ super(Objects.requireNonNull(blobInventory,
+ "blobInventory cannot be null").getTitle(),
+ blobInventory.getSize(), blobInventory.getButtonManager());
+ this.builderId = Objects.requireNonNull(builderId,
+ "builderId cannot be null");
+ this.objectBuilderButtons = new HashMap<>();
+ }
+
+ /**
+ * Retrieves an ObjectBuilderButton.
+ *
+ * @param key the key that points to the button
+ * @return the ObjectBuilderButton
+ */
+ public ObjectBuilderButton> getObjectBuilderButton(String key) {
+ return objectBuilderButtons.get(key);
+ }
+
+ /**
+ * @return player matching builderId.
+ * null if no player is found.
+ */
+ @Nullable
+ public Player getPlayer() {
+ return Bukkit.getPlayer(builderId);
+ }
+
+ /**
+ * Retrieves builder's UUID
+ *
+ * @return builder's UUID
+ */
+ public UUID getBuilderId() {
+ return builderId;
+ }
+
+ /**
+ * Opens the inventory for the player.
+ */
+ public void openInventory() {
+ getPlayer().openInventory(getInventory());
+ }
+
+ /**
+ * Updates a default button.
+ *
+ * @param key the key of the button
+ * @param regex the regex to replace
+ * @param replacement the replacement
+ */
+ public void updateDefaultButton(String key, String regex, String replacement) {
+ modifyDefaultButton(key, modder -> modder.replace(regex, replacement));
+ }
+
+ /**
+ * Modifies a default button.
+ *
+ * @param key the key of the button
+ * @param function the function to modify the button
+ */
+ public void modifyDefaultButton(String key,
+ Function function) {
+ Set slots = getSlots(key);
+ if (slots == null)
+ throw new NullPointerException("'" + key + "' is not a valid button key " +
+ "inside '" + getTitle() + "' inventory");
+ slots.forEach(i -> {
+ ItemStack itemStack = cloneDefaultButton(key);
+ ItemStackModder modder = ItemStackModder.mod(itemStack);
+ function.apply(modder);
+ this.setButton(i, itemStack);
+ });
+ }
+
+ /**
+ * Will attempt to build the object
+ * using the function. The idea is
+ * that the function will
+ *
+ * @return the object
+ */
+ public T build() {
+ if (function != null)
+ return function.apply(this);
+ return null;
+ }
+
+ public abstract T construct();
+
+ /**
+ * Checks if it's a build button.
+ *
+ * @param slot the slot to check
+ * @return true if it's a build button
+ */
+ public boolean isBuildButton(int slot) {
+ return getSlots("Build").contains(slot);
+ }
+
+ /**
+ * Checks if it's an ObjectBuilderButton.
+ *
+ * @param slot the slot to check
+ * @return true if it's an ObjectBuilderButton
+ */
+ public boolean isObjectBuilderButton(int slot) {
+ Uber is = new Uber<>(false);
+ objectBuilderButtons.values().forEach(button -> {
+ if (getSlots(button.getButtonKey()).contains(slot))
+ is.talk(true);
+ });
+ return is.thanks();
+ }
+
+ /**
+ * If the slot is an object builder button, adds the listener.
+ *
+ * @param slot the slot
+ * @param player the player
+ * @param sound the sound
+ */
+ public void ifObjectBuilderButtonAddListener(int slot, Player player,
+ BlobSound sound) {
+ objectBuilderButtons.values().forEach(button -> {
+ if (getSlots(button.getButtonKey()).contains(slot))
+ button.addListener(player, Optional.ofNullable(sound));
+ });
+ }
+
+ /**
+ * If the slot is an object builder button, adds the listener.
+ *
+ * @param slot the slot
+ * @param player the player
+ */
+ public boolean ifObjectBuilderButtonAddListener(int slot, Player player) {
+ for (ObjectBuilderButton> button : objectBuilderButtons.values()) {
+ String key = button.getButtonKey();
+ Set set = getSlots(key);
+ if (set == null) {
+ continue;
+ }
+ if (getSlots(button.getButtonKey()).contains(slot)) {
+ button.addListener(player);
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Handles all buttons, including build button.
+ * Used in InventoryClickEvent, slot parameter
+ * should be event.getRawSlot().
+ *
+ * @param slot the slot
+ * @param player the player
+ */
+ public void handle(int slot, Player player) {
+ boolean isObjectBuilderButton = ifObjectBuilderButtonAddListener(slot, player);
+ if (isObjectBuilderButton)
+ return;
+ if (isBuildButton(slot))
+ build();
+ }
+
+ /**
+ * Adds an object builder button.
+ *
+ * @param builderButton the button
+ * @return this
+ */
+ public BlobObjectBuilder addObjectBuilderButton(ObjectBuilderButton> builderButton) {
+ objectBuilderButtons.put(builderButton.getButtonKey(), builderButton);
+ return this;
+ }
+
+ /**
+ * Add a quick String button.
+ *
+ * @param buttonKey the button key
+ * @param timeout the timeout
+ * @return this
+ */
+ public BlobObjectBuilder addQuickStringButton(String buttonKey, long timeout) {
+ return addObjectBuilderButton(ObjectBuilderButtonBuilder.QUICK_STRING(buttonKey, timeout, this));
+ }
+
+ /**
+ * Add a quick byte button. Accepts negative values.
+ * If input equalsIgnoreCase 'null', button's value will be set null.
+ *
+ * @param buttonKey the button key
+ * @param timeout the timeout
+ * @return this
+ */
+ public BlobObjectBuilder addQuickByteButton(String buttonKey, long timeout) {
+ return addObjectBuilderButton(ObjectBuilderButtonBuilder.QUICK_BYTE(buttonKey, timeout, this));
+ }
+
+ /**
+ * Add a quick short button. Accepts negative values.
+ * If input equalsIgnoreCase 'null', button's value will be set null.
+ *
+ * @param buttonKey the button key
+ * @param timeout the timeout
+ * @return this
+ */
+ public BlobObjectBuilder addQuickShortButton(String buttonKey, long timeout) {
+ return addObjectBuilderButton(ObjectBuilderButtonBuilder.QUICK_SHORT(buttonKey, timeout, this));
+ }
+
+ /**
+ * Add a quick integer button. Accepts negative values.
+ * If input equalsIgnoreCase 'null', button's value will be set null.
+ *
+ * @param buttonKey the button key
+ * @param timeout the timeout
+ * @return this
+ */
+ public BlobObjectBuilder addQuickIntegerButton(String buttonKey, long timeout) {
+ return addObjectBuilderButton(ObjectBuilderButtonBuilder.QUICK_INTEGER(buttonKey, timeout, this));
+ }
+
+ /**
+ * Add a quick long button. Accepts negative values.
+ * If input equalsIgnoreCase 'null', button's value will be set null.
+ *
+ * @param buttonKey the button key
+ * @param timeout the timeout
+ * @return this
+ */
+ public BlobObjectBuilder addQuickLongButton(String buttonKey, long timeout) {
+ return addObjectBuilderButton(ObjectBuilderButtonBuilder.QUICK_LONG(buttonKey, timeout, this));
+ }
+
+ /**
+ * Add a quick float button. Accepts negative values.
+ * If input equalsIgnoreCase 'null', button's value will be set null.
+ *
+ * @param buttonKey the button key
+ * @param timeout the timeout
+ * @return this
+ */
+ public BlobObjectBuilder addQuickFloatButton(String buttonKey, long timeout) {
+ return addObjectBuilderButton(ObjectBuilderButtonBuilder.QUICK_FLOAT(buttonKey, timeout, this));
+ }
+
+ /**
+ * Add a quick double button. Accepts negative values.
+ * If input equalsIgnoreCase 'null', button's value will be set null.
+ *
+ * @param buttonKey the button key
+ * @param timeout the timeout
+ * @return this
+ */
+ public BlobObjectBuilder addQuickDoubleButton(String buttonKey, long timeout) {
+ return addObjectBuilderButton(ObjectBuilderButtonBuilder.QUICK_DOUBLE(buttonKey, timeout, this));
+ }
+
+ /**
+ * Add a quick block button.
+ *
+ * @param buttonKey the button key
+ * @param timeout the timeout
+ * @return this
+ */
+ public BlobObjectBuilder addQuickBlockButton(String buttonKey, long timeout) {
+ return addObjectBuilderButton(ObjectBuilderButtonBuilder.QUICK_BLOCK(buttonKey, timeout, this));
+ }
+
+ /**
+ * Add a quick block button.
+ * Will use the block above selection.
+ *
+ * @param buttonKey the button key
+ * @param timeout the timeout
+ * @return this
+ */
+ public BlobObjectBuilder addQuickAboveBlockButton(String buttonKey, long timeout) {
+ return addObjectBuilderButton(ObjectBuilderButtonBuilder.QUICK_ABOVE_BLOCK(buttonKey, timeout, this));
+ }
+
+ /**
+ * Add a quick item button.
+ *
+ * @param buttonKey the button key
+ * @return this
+ */
+ public BlobObjectBuilder addQuickItemButton(String buttonKey) {
+ return addObjectBuilderButton(ObjectBuilderButtonBuilder.QUICK_ITEM(buttonKey, this));
+ }
+
+ /**
+ * Add a quick selector button.
+ *
+ * @param buttonKey the button key
+ * @param selector the selector
+ * @param ifAvailable the if available
+ * @return this
+ */
+ public BlobObjectBuilder addQuickSelectorButton(String buttonKey,
+ VariableSelector selector,
+ Function ifAvailable) {
+ return addObjectBuilderButton(ObjectBuilderButtonBuilder.QUICK_SELECTOR(buttonKey, selector, ifAvailable, this));
+ }
+
+ /**
+ * Add a quick message button.
+ *
+ * @param buttonKey the button key
+ * @param timeout the timeout
+ * @return this
+ */
+ public BlobObjectBuilder addQuickMessageButton(String buttonKey, long timeout) {
+ return addObjectBuilderButton(ObjectBuilderButtonBuilder.QUICK_MESSAGE(buttonKey, timeout, this));
+ }
+
+ /**
+ * Add a quick world button.
+ *
+ * @param buttonKey the button key
+ * @param timeout the timeout
+ * @return this
+ */
+ public BlobObjectBuilder addQuickWorldButton(String buttonKey, long timeout) {
+ return addObjectBuilderButton(ObjectBuilderButtonBuilder.QUICK_WORLD(buttonKey, timeout, this));
+ }
+
+ /**
+ * Add a quick action block button which accepts a consumer when input is given.
+ *
+ * @param buttonKey the button key
+ * @param timeout the timeout
+ * @param consumer the consumer (which is of Block type)
+ * @return The button
+ */
+ public BlobObjectBuilder addQuickActionBlockButton(String buttonKey, long timeout, Consumer consumer) {
+ return addObjectBuilderButton(ObjectBuilderButtonBuilder.QUICK_ACTION_BLOCK(
+ buttonKey, timeout, this, consumer));
+ }
+
+ /**
+ * Add a quick action item button which accepts a consumer when input is given.
+ *
+ * @param buttonKey the button key
+ * @param consumer the consumer (which is of ItemStack type)
+ * @return The button
+ */
+ public BlobObjectBuilder addQuickActionItemButton(String buttonKey, Consumer consumer) {
+ return addObjectBuilderButton(ObjectBuilderButtonBuilder.QUICK_ACTION_ITEM(
+ buttonKey, this, consumer));
+ }
+
+ /**
+ * Add a quick action selector button which accepts a consumer when input is given.
+ *
+ * @param buttonKey The key of the button
+ * @param selector The selector
+ * @param ifAvailable The if available
+ * @param consumer The consumer (which is of T type)
+ * @return The button
+ */
+ public BlobObjectBuilder addQuickActionSelectorButton(String buttonKey,
+ VariableSelector selector,
+ Function ifAvailable,
+ Consumer consumer) {
+ return addObjectBuilderButton(ObjectBuilderButtonBuilder.QUICK_ACTION_SELECTOR(
+ buttonKey, selector, ifAvailable, this, consumer));
+ }
+
+ /**
+ * Add a quick world button which accepts a consumer when input is given.
+ *
+ * @param buttonKey The key of the button
+ * @param timeout The timeout
+ * @param consumer The consumer (which is a ReferenceBlobMessage)
+ * @return The button
+ */
+ public BlobObjectBuilder addQuickActionMessageButton(String buttonKey, long timeout, Consumer consumer) {
+ return addObjectBuilderButton(ObjectBuilderButtonBuilder.QUICK_ACTION_MESSAGE(
+ buttonKey, timeout, this, consumer));
+ }
+
+ /**
+ * A quick ObjectBuilderButton for Worlds that accepts
+ * a consumer when input is given.
+ *
+ * @param buttonKey The key of the button
+ * @param timeout The timeout
+ * @param consumer The consumer (which is a World)
+ * @return The button
+ */
+ public BlobObjectBuilder addQuickActionWorldButton(String buttonKey, long timeout, Consumer consumer) {
+ return addObjectBuilderButton(ObjectBuilderButtonBuilder.QUICK_ACTION_WORLD(
+ buttonKey, timeout, this, consumer));
+ }
+
+
+ /**
+ * Add a positive byte button.
+ * if input is lower than 0, button
+ * will be empty.
+ *
+ * @param buttonKey the button key
+ * @param timeout the timeout
+ * @return this
+ */
+ public BlobObjectBuilder addPositiveByteButton(String buttonKey, long timeout) {
+ return addObjectBuilderButton(ObjectBuilderButtonBuilder.POSITIVE_BYTE(buttonKey, timeout, this));
+ }
+
+ /**
+ * Add a positive short button.
+ * if input is lower than 0, button
+ * will be empty.
+ *
+ * @param buttonKey the button key
+ * @param timeout the timeout
+ * @return this
+ */
+ public BlobObjectBuilder addPositiveShortButton(String buttonKey, long timeout) {
+ return addObjectBuilderButton(ObjectBuilderButtonBuilder.POSITIVE_SHORT(buttonKey, timeout, this));
+ }
+
+ /**
+ * Add a positive integer button.
+ * if input is lower than 0, button
+ * will be empty.
+ *
+ * @param buttonKey the button key
+ * @param timeout the timeout
+ * @return this
+ */
+ public BlobObjectBuilder addPositiveIntegerButton(String buttonKey, long timeout) {
+ return addObjectBuilderButton(ObjectBuilderButtonBuilder.POSITIVE_INTEGER(buttonKey, timeout, this));
+ }
+
+ /**
+ * Add a positive long button.
+ * if input is lower than 0, button
+ * will be empty.
+ *
+ * @param buttonKey the button key
+ * @param timeout the timeout
+ * @return this
+ */
+ public BlobObjectBuilder addPositiveLongButton(String buttonKey, long timeout) {
+ return addObjectBuilderButton(ObjectBuilderButtonBuilder.POSITIVE_LONG(buttonKey, timeout, this));
+ }
+
+ /**
+ * Add a positive float button.
+ * if input is lower than 0, button
+ * will be empty.
+ *
+ * @param buttonKey the button key
+ * @param timeout the timeout
+ * @return this
+ */
+ public BlobObjectBuilder addPositiveFloatButton(String buttonKey, long timeout) {
+ return addObjectBuilderButton(ObjectBuilderButtonBuilder.POSITIVE_FLOAT(buttonKey, timeout, this));
+ }
+
+ /**
+ * Add a positive double button.
+ * if input is lower than 0, button
+ * will be empty.
+ *
+ * @param buttonKey the button key
+ * @param timeout the timeout
+ * @return this
+ */
+ public BlobObjectBuilder addPositiveDoubleButton(String buttonKey, long timeout) {
+ return addObjectBuilderButton(ObjectBuilderButtonBuilder.POSITIVE_DOUBLE(buttonKey, timeout, this));
+ }
+
+ /**
+ * A quick navigator for booleans.
+ * Value cannot be empty nor null.
+ * By default, the value is false.
+ *
+ * @param buttonKey The key of the button
+ * @return The button
+ */
+ public BlobObjectBuilder addBoolean(String buttonKey) {
+ return addObjectBuilderButton(ObjectBuilderButtonBuilder.BOOLEAN(buttonKey, this));
+ }
+
+ /**
+ * A quick navigator for booleans.
+ * Value cannot be empty nor null.
+ * By default, the value is true.
+ *
+ * @param buttonKey The key of the button
+ * @return The button
+ */
+ public BlobObjectBuilder addBooleanDefaultTrue(String buttonKey) {
+ return addObjectBuilderButton(ObjectBuilderButtonBuilder.BOOLEAN_DEFAULT_TRUE(buttonKey, this));
+ }
+
+ /**
+ * A quick navigator for any type of array.
+ * Value cannot be empty nor null.
+ * By default, the value is the first element of the array.
+ *
+ * @param buttonKey The key of the button
+ * @param enumClass The enum class
+ * @return The button
+ */
+ public > BlobObjectBuilder addEnumNavigator(String buttonKey, Class enumClass) {
+ return addObjectBuilderButton(ObjectBuilderButtonBuilder.ENUM_NAVIGATOR(buttonKey, enumClass, this));
+ }
+
+ /**
+ * Set the function to be called when the build button is clicked
+ *
+ * @param function the function to be called
+ * @return this
+ */
+ public BlobObjectBuilder setFunction(Function, T> function) {
+ this.function = function;
+ return this;
+ }
+}
diff --git a/src/main/java/us/mytheria/bloblib/entities/inventory/ObjectBuilder.java b/src/main/java/us/mytheria/bloblib/entities/inventory/ObjectBuilder.java
index 7a495af9..7eeeb1ee 100644
--- a/src/main/java/us/mytheria/bloblib/entities/inventory/ObjectBuilder.java
+++ b/src/main/java/us/mytheria/bloblib/entities/inventory/ObjectBuilder.java
@@ -1,22 +1,10 @@
package us.mytheria.bloblib.entities.inventory;
-import me.anjoismysign.anjo.entities.Uber;
-import org.bukkit.Bukkit;
-import org.bukkit.World;
-import org.bukkit.block.Block;
-import org.bukkit.entity.Player;
-import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
import us.mytheria.bloblib.entities.BlobObject;
import us.mytheria.bloblib.entities.ObjectDirector;
-import us.mytheria.bloblib.entities.message.BlobMessage;
-import us.mytheria.bloblib.entities.message.BlobSound;
-import us.mytheria.bloblib.itemstack.ItemStackModder;
-import java.util.*;
-import java.util.function.Consumer;
-import java.util.function.Function;
+import java.util.UUID;
/**
* @param the type of object to build
@@ -27,10 +15,7 @@
* to the Minecraft server, the user can build an object by interacting with
* a Bukkit Inventory / GUI.
*/
-public abstract class ObjectBuilder extends BlobInventory {
- private final UUID builderId;
- private final HashMap> objectBuilderButtons;
- private Function, T> function;
+public abstract class ObjectBuilder extends BlobObjectBuilder {
private final ObjectDirector objectDirector;
/**
@@ -43,14 +28,8 @@ public abstract class ObjectBuilder extends BlobInventory
public ObjectBuilder(@NotNull BlobInventory blobInventory,
@NotNull UUID builderId,
@NotNull ObjectDirector objectDirector) {
- super(Objects.requireNonNull(blobInventory,
- "blobInventory cannot be null").getTitle(),
- blobInventory.getSize(), blobInventory.getButtonManager());
- this.objectDirector = Objects.requireNonNull(objectDirector,
- "objectDirector cannot be null");
- this.builderId = Objects.requireNonNull(builderId,
- "builderId cannot be null");
- this.objectBuilderButtons = new HashMap<>();
+ super(blobInventory, builderId);
+ this.objectDirector = objectDirector;
}
/**
@@ -62,521 +41,4 @@ public ObjectBuilder(@NotNull BlobInventory blobInventory,
public ObjectDirector getObjectDirector() {
return objectDirector;
}
-
- /**
- * Retrieves an ObjectBuilderButton.
- *
- * @param key the key that points to the button
- * @return the ObjectBuilderButton
- */
- public ObjectBuilderButton> getObjectBuilderButton(String key) {
- return objectBuilderButtons.get(key);
- }
-
- /**
- * @return player matching builderId.
- * null if no player is found.
- */
- @Nullable
- public Player getPlayer() {
- return Bukkit.getPlayer(builderId);
- }
-
- /**
- * Retrieves builder's UUID
- *
- * @return builder's UUID
- */
- public UUID getBuilderId() {
- return builderId;
- }
-
- /**
- * Opens the inventory for the player.
- */
- public void openInventory() {
- getPlayer().openInventory(getInventory());
- }
-
- /**
- * Updates a default button.
- *
- * @param key the key of the button
- * @param regex the regex to replace
- * @param replacement the replacement
- */
- public void updateDefaultButton(String key, String regex, String replacement) {
- modifyDefaultButton(key, modder -> modder.replace(regex, replacement));
- }
-
- /**
- * Modifies a default button.
- *
- * @param key the key of the button
- * @param function the function to modify the button
- */
- public void modifyDefaultButton(String key,
- Function function) {
- Set slots = getSlots(key);
- if (slots == null)
- throw new NullPointerException("'" + key + "' is not a valid button key " +
- "inside '" + getTitle() + "' inventory");
- slots.forEach(i -> {
- ItemStack itemStack = cloneDefaultButton(key);
- ItemStackModder modder = ItemStackModder.mod(itemStack);
- function.apply(modder);
- this.setButton(i, itemStack);
- });
- }
-
- /**
- * Will attempt to build the object
- * using the function. The idea is
- * that the function will
- *
- * @return the object
- */
- public T build() {
- if (function != null)
- return function.apply(this);
- return null;
- }
-
- public abstract T construct();
-
- /**
- * Checks if it's a build button.
- *
- * @param slot the slot to check
- * @return true if it's a build button
- */
- public boolean isBuildButton(int slot) {
- return getSlots("Build").contains(slot);
- }
-
- /**
- * Checks if it's an ObjectBuilderButton.
- *
- * @param slot the slot to check
- * @return true if it's an ObjectBuilderButton
- */
- public boolean isObjectBuilderButton(int slot) {
- Uber is = new Uber<>(false);
- objectBuilderButtons.values().forEach(button -> {
- if (getSlots(button.getButtonKey()).contains(slot))
- is.talk(true);
- });
- return is.thanks();
- }
-
- /**
- * If the slot is an object builder button, adds the listener.
- *
- * @param slot the slot
- * @param player the player
- * @param sound the sound
- */
- public void ifObjectBuilderButtonAddListener(int slot, Player player,
- BlobSound sound) {
- objectBuilderButtons.values().forEach(button -> {
- if (getSlots(button.getButtonKey()).contains(slot))
- button.addListener(player, Optional.ofNullable(sound));
- });
- }
-
- /**
- * If the slot is an object builder button, adds the listener.
- *
- * @param slot the slot
- * @param player the player
- */
- public boolean ifObjectBuilderButtonAddListener(int slot, Player player) {
- for (ObjectBuilderButton> button : objectBuilderButtons.values()) {
- String key = button.getButtonKey();
- Set set = getSlots(key);
- if (set == null) {
- continue;
- }
- if (getSlots(button.getButtonKey()).contains(slot)) {
- button.addListener(player);
- return true;
- }
- }
- return false;
- }
-
- /**
- * Handles all buttons, including build button.
- * Used in InventoryClickEvent, slot parameter
- * should be event.getRawSlot().
- *
- * @param slot the slot
- * @param player the player
- */
- public void handle(int slot, Player player) {
- boolean isObjectBuilderButton = ifObjectBuilderButtonAddListener(slot, player);
- if (isObjectBuilderButton)
- return;
- if (isBuildButton(slot))
- build();
- }
-
- /**
- * Adds an object builder button.
- *
- * @param builderButton the button
- * @return this
- */
- public ObjectBuilder addObjectBuilderButton(ObjectBuilderButton> builderButton) {
- objectBuilderButtons.put(builderButton.getButtonKey(), builderButton);
- return this;
- }
-
- /**
- * Add a quick String button.
- *
- * @param buttonKey the button key
- * @param timeout the timeout
- * @return this
- */
- public ObjectBuilder addQuickStringButton(String buttonKey, long timeout) {
- return addObjectBuilderButton(ObjectBuilderButtonBuilder.QUICK_STRING(buttonKey, timeout, this));
- }
-
- /**
- * Add a quick byte button. Accepts negative values.
- * If input equalsIgnoreCase 'null', button's value will be set null.
- *
- * @param buttonKey the button key
- * @param timeout the timeout
- * @return this
- */
- public ObjectBuilder addQuickByteButton(String buttonKey, long timeout) {
- return addObjectBuilderButton(ObjectBuilderButtonBuilder.QUICK_BYTE(buttonKey, timeout, this));
- }
-
- /**
- * Add a quick short button. Accepts negative values.
- * If input equalsIgnoreCase 'null', button's value will be set null.
- *
- * @param buttonKey the button key
- * @param timeout the timeout
- * @return this
- */
- public ObjectBuilder addQuickShortButton(String buttonKey, long timeout) {
- return addObjectBuilderButton(ObjectBuilderButtonBuilder.QUICK_SHORT(buttonKey, timeout, this));
- }
-
- /**
- * Add a quick integer button. Accepts negative values.
- * If input equalsIgnoreCase 'null', button's value will be set null.
- *
- * @param buttonKey the button key
- * @param timeout the timeout
- * @return this
- */
- public ObjectBuilder addQuickIntegerButton(String buttonKey, long timeout) {
- return addObjectBuilderButton(ObjectBuilderButtonBuilder.QUICK_INTEGER(buttonKey, timeout, this));
- }
-
- /**
- * Add a quick long button. Accepts negative values.
- * If input equalsIgnoreCase 'null', button's value will be set null.
- *
- * @param buttonKey the button key
- * @param timeout the timeout
- * @return this
- */
- public ObjectBuilder addQuickLongButton(String buttonKey, long timeout) {
- return addObjectBuilderButton(ObjectBuilderButtonBuilder.QUICK_LONG(buttonKey, timeout, this));
- }
-
- /**
- * Add a quick float button. Accepts negative values.
- * If input equalsIgnoreCase 'null', button's value will be set null.
- *
- * @param buttonKey the button key
- * @param timeout the timeout
- * @return this
- */
- public ObjectBuilder addQuickFloatButton(String buttonKey, long timeout) {
- return addObjectBuilderButton(ObjectBuilderButtonBuilder.QUICK_FLOAT(buttonKey, timeout, this));
- }
-
- /**
- * Add a quick double button. Accepts negative values.
- * If input equalsIgnoreCase 'null', button's value will be set null.
- *
- * @param buttonKey the button key
- * @param timeout the timeout
- * @return this
- */
- public ObjectBuilder addQuickDoubleButton(String buttonKey, long timeout) {
- return addObjectBuilderButton(ObjectBuilderButtonBuilder.QUICK_DOUBLE(buttonKey, timeout, this));
- }
-
- /**
- * Add a quick block button.
- *
- * @param buttonKey the button key
- * @param timeout the timeout
- * @return this
- */
- public ObjectBuilder addQuickBlockButton(String buttonKey, long timeout) {
- return addObjectBuilderButton(ObjectBuilderButtonBuilder.QUICK_BLOCK(buttonKey, timeout, this));
- }
-
- /**
- * Add a quick block button.
- * Will use the block above selection.
- *
- * @param buttonKey the button key
- * @param timeout the timeout
- * @return this
- */
- public ObjectBuilder addQuickAboveBlockButton(String buttonKey, long timeout) {
- return addObjectBuilderButton(ObjectBuilderButtonBuilder.QUICK_ABOVE_BLOCK(buttonKey, timeout, this));
- }
-
- /**
- * Add a quick item button.
- *
- * @param buttonKey the button key
- * @return this
- */
- public ObjectBuilder addQuickItemButton(String buttonKey) {
- return addObjectBuilderButton(ObjectBuilderButtonBuilder.QUICK_ITEM(buttonKey, this));
- }
-
- /**
- * Add a quick selector button.
- *
- * @param buttonKey the button key
- * @param selector the selector
- * @param ifAvailable the if available
- * @return this
- */
- public ObjectBuilder addQuickSelectorButton(String buttonKey,
- VariableSelector selector,
- Function ifAvailable) {
- return addObjectBuilderButton(ObjectBuilderButtonBuilder.QUICK_SELECTOR(buttonKey, selector, ifAvailable, this));
- }
-
- /**
- * Add a quick message button.
- *
- * @param buttonKey the button key
- * @param timeout the timeout
- * @return this
- */
- public ObjectBuilder addQuickMessageButton(String buttonKey, long timeout) {
- return addObjectBuilderButton(ObjectBuilderButtonBuilder.QUICK_MESSAGE(buttonKey, timeout, this));
- }
-
- /**
- * Add a quick world button.
- *
- * @param buttonKey the button key
- * @param timeout the timeout
- * @return this
- */
- public ObjectBuilder addQuickWorldButton(String buttonKey, long timeout) {
- return addObjectBuilderButton(ObjectBuilderButtonBuilder.QUICK_WORLD(buttonKey, timeout, this));
- }
-
- /**
- * Add a quick action block button which accepts a consumer when input is given.
- *
- * @param buttonKey the button key
- * @param timeout the timeout
- * @param consumer the consumer (which is of Block type)
- * @return The button
- */
- public ObjectBuilder addQuickActionBlockButton(String buttonKey, long timeout, Consumer consumer) {
- return addObjectBuilderButton(ObjectBuilderButtonBuilder.QUICK_ACTION_BLOCK(
- buttonKey, timeout, this, consumer));
- }
-
- /**
- * Add a quick action item button which accepts a consumer when input is given.
- *
- * @param buttonKey the button key
- * @param consumer the consumer (which is of ItemStack type)
- * @return The button
- */
- public ObjectBuilder addQuickActionItemButton(String buttonKey, Consumer consumer) {
- return addObjectBuilderButton(ObjectBuilderButtonBuilder.QUICK_ACTION_ITEM(
- buttonKey, this, consumer));
- }
-
- /**
- * Add a quick action selector button which accepts a consumer when input is given.
- *
- * @param buttonKey The key of the button
- * @param selector The selector
- * @param ifAvailable The if available
- * @param consumer The consumer (which is of T type)
- * @return The button
- */
- public ObjectBuilder addQuickActionSelectorButton(String buttonKey,
- VariableSelector selector,
- Function ifAvailable,
- Consumer consumer) {
- return addObjectBuilderButton(ObjectBuilderButtonBuilder.QUICK_ACTION_SELECTOR(
- buttonKey, selector, ifAvailable, this, consumer));
- }
-
- /**
- * Add a quick world button which accepts a consumer when input is given.
- *
- * @param buttonKey The key of the button
- * @param timeout The timeout
- * @param consumer The consumer (which is a ReferenceBlobMessage)
- * @return The button
- */
- public ObjectBuilder addQuickActionMessageButton(String buttonKey, long timeout, Consumer consumer) {
- return addObjectBuilderButton(ObjectBuilderButtonBuilder.QUICK_ACTION_MESSAGE(
- buttonKey, timeout, this, consumer));
- }
-
- /**
- * A quick ObjectBuilderButton for Worlds that accepts
- * a consumer when input is given.
- *
- * @param buttonKey The key of the button
- * @param timeout The timeout
- * @param consumer The consumer (which is a World)
- * @return The button
- */
- public ObjectBuilder addQuickActionWorldButton(String buttonKey, long timeout, Consumer consumer) {
- return addObjectBuilderButton(ObjectBuilderButtonBuilder.QUICK_ACTION_WORLD(
- buttonKey, timeout, this, consumer));
- }
-
-
- /**
- * Add a positive byte button.
- * if input is lower than 0, button
- * will be empty.
- *
- * @param buttonKey the button key
- * @param timeout the timeout
- * @return this
- */
- public ObjectBuilder addPositiveByteButton(String buttonKey, long timeout) {
- return addObjectBuilderButton(ObjectBuilderButtonBuilder.POSITIVE_BYTE(buttonKey, timeout, this));
- }
-
- /**
- * Add a positive short button.
- * if input is lower than 0, button
- * will be empty.
- *
- * @param buttonKey the button key
- * @param timeout the timeout
- * @return this
- */
- public ObjectBuilder addPositiveShortButton(String buttonKey, long timeout) {
- return addObjectBuilderButton(ObjectBuilderButtonBuilder.POSITIVE_SHORT(buttonKey, timeout, this));
- }
-
- /**
- * Add a positive integer button.
- * if input is lower than 0, button
- * will be empty.
- *
- * @param buttonKey the button key
- * @param timeout the timeout
- * @return this
- */
- public ObjectBuilder addPositiveIntegerButton(String buttonKey, long timeout) {
- return addObjectBuilderButton(ObjectBuilderButtonBuilder.POSITIVE_INTEGER(buttonKey, timeout, this));
- }
-
- /**
- * Add a positive long button.
- * if input is lower than 0, button
- * will be empty.
- *
- * @param buttonKey the button key
- * @param timeout the timeout
- * @return this
- */
- public ObjectBuilder addPositiveLongButton(String buttonKey, long timeout) {
- return addObjectBuilderButton(ObjectBuilderButtonBuilder.POSITIVE_LONG(buttonKey, timeout, this));
- }
-
- /**
- * Add a positive float button.
- * if input is lower than 0, button
- * will be empty.
- *
- * @param buttonKey the button key
- * @param timeout the timeout
- * @return this
- */
- public ObjectBuilder addPositiveFloatButton(String buttonKey, long timeout) {
- return addObjectBuilderButton(ObjectBuilderButtonBuilder.POSITIVE_FLOAT(buttonKey, timeout, this));
- }
-
- /**
- * Add a positive double button.
- * if input is lower than 0, button
- * will be empty.
- *
- * @param buttonKey the button key
- * @param timeout the timeout
- * @return this
- */
- public ObjectBuilder addPositiveDoubleButton(String buttonKey, long timeout) {
- return addObjectBuilderButton(ObjectBuilderButtonBuilder.POSITIVE_DOUBLE(buttonKey, timeout, this));
- }
-
- /**
- * A quick navigator for booleans.
- * Value cannot be empty nor null.
- * By default, the value is false.
- *
- * @param buttonKey The key of the button
- * @return The button
- */
- public ObjectBuilder addBoolean(String buttonKey) {
- return addObjectBuilderButton(ObjectBuilderButtonBuilder.BOOLEAN(buttonKey, this));
- }
-
- /**
- * A quick navigator for booleans.
- * Value cannot be empty nor null.
- * By default, the value is true.
- *
- * @param buttonKey The key of the button
- * @return The button
- */
- public ObjectBuilder addBooleanDefaultTrue(String buttonKey) {
- return addObjectBuilderButton(ObjectBuilderButtonBuilder.BOOLEAN_DEFAULT_TRUE(buttonKey, this));
- }
-
- /**
- * A quick navigator for any type of array.
- * Value cannot be empty nor null.
- * By default, the value is the first element of the array.
- *
- * @param buttonKey The key of the button
- * @param enumClass The enum class
- * @return The button
- */
- public > ObjectBuilder addEnumNavigator(String buttonKey, Class enumClass) {
- return addObjectBuilderButton(ObjectBuilderButtonBuilder.ENUM_NAVIGATOR(buttonKey, enumClass, this));
- }
-
- /**
- * Set the function to be called when the build button is clicked
- *
- * @param function the function to be called
- * @return this
- */
- public ObjectBuilder setFunction(Function, T> function) {
- this.function = function;
- return this;
- }
}
diff --git a/src/main/java/us/mytheria/bloblib/entities/inventory/ObjectBuilderButtonBuilder.java b/src/main/java/us/mytheria/bloblib/entities/inventory/ObjectBuilderButtonBuilder.java
index 93502dc6..cab8bb07 100644
--- a/src/main/java/us/mytheria/bloblib/entities/inventory/ObjectBuilderButtonBuilder.java
+++ b/src/main/java/us/mytheria/bloblib/entities/inventory/ObjectBuilderButtonBuilder.java
@@ -86,7 +86,7 @@ public static ObjectBuilderButton SIMPLE_STRING(String buttonKey, long t
* @return The button
*/
public static ObjectBuilderButton QUICK_STRING(String buttonKey, long timeout,
- ObjectBuilder> objectBuilder) {
+ BlobObjectBuilder> objectBuilder) {
String placeholderRegex = NamingConventions.toCamelCase(buttonKey);
return STRING(buttonKey, timeout, "Builder." + buttonKey
+ "-Timeout", "Builder." + buttonKey,
@@ -173,7 +173,7 @@ public static ObjectBuilderButton SIMPLE_BYTE(String buttonKey, long timeo
* @return The button
*/
public static ObjectBuilderButton QUICK_BYTE(String buttonKey, long timeout,
- ObjectBuilder> objectBuilder) {
+ BlobObjectBuilder> objectBuilder) {
String placeholderRegex = NamingConventions.toCamelCase(buttonKey);
return BYTE(buttonKey, timeout, "Builder." + buttonKey
@@ -206,7 +206,7 @@ public static ObjectBuilderButton QUICK_BYTE(String buttonKey, long timeou
* @return The button
*/
public static ObjectBuilderButton POSITIVE_BYTE(String buttonKey, long timeout,
- ObjectBuilder> objectBuilder) {
+ BlobObjectBuilder> objectBuilder) {
String placeholderRegex = NamingConventions.toCamelCase(buttonKey);
Function function = value -> {
objectBuilder.updateDefaultButton(buttonKey, "%" + placeholderRegex + "%",
@@ -306,7 +306,7 @@ public static ObjectBuilderButton SIMPLE_SHORT(String buttonKey, long tim
* @return The button
*/
public static ObjectBuilderButton QUICK_SHORT(String buttonKey, long timeout,
- ObjectBuilder> objectBuilder) {
+ BlobObjectBuilder> objectBuilder) {
String placeholderRegex = NamingConventions.toCamelCase(buttonKey);
return SHORT(buttonKey, timeout, "Builder." + buttonKey
@@ -338,7 +338,7 @@ public static ObjectBuilderButton QUICK_SHORT(String buttonKey, long time
* @return The button
*/
public static ObjectBuilderButton POSITIVE_SHORT(String buttonKey, long timeout,
- ObjectBuilder> objectBuilder) {
+ BlobObjectBuilder> objectBuilder) {
String placeholderRegex = NamingConventions.toCamelCase(buttonKey);
Function function = value -> {
objectBuilder.updateDefaultButton(buttonKey, "%" + placeholderRegex + "%",
@@ -438,7 +438,7 @@ public static ObjectBuilderButton SIMPLE_INTEGER(String buttonKey, long
* @return The button
*/
public static ObjectBuilderButton QUICK_INTEGER(String buttonKey, long timeout,
- ObjectBuilder> objectBuilder) {
+ BlobObjectBuilder> objectBuilder) {
String placeholderRegex = NamingConventions.toCamelCase(buttonKey);
return INTEGER(buttonKey, timeout, "Builder." + buttonKey
@@ -470,7 +470,7 @@ public static ObjectBuilderButton QUICK_INTEGER(String buttonKey, long
* @return The button
*/
public static ObjectBuilderButton POSITIVE_INTEGER(String buttonKey, long timeout,
- ObjectBuilder> objectBuilder) {
+ BlobObjectBuilder> objectBuilder) {
String placeholderRegex = NamingConventions.toCamelCase(buttonKey);
Function function = value -> {
@@ -571,7 +571,7 @@ public static ObjectBuilderButton SIMPLE_LONG(String buttonKey, long timeo
* @return The button
*/
public static ObjectBuilderButton QUICK_LONG(String buttonKey, long timeout,
- ObjectBuilder> objectBuilder) {
+ BlobObjectBuilder> objectBuilder) {
String placeholderRegex = NamingConventions.toCamelCase(buttonKey);
return LONG(buttonKey, timeout, "Builder." + buttonKey
@@ -603,7 +603,7 @@ public static ObjectBuilderButton QUICK_LONG(String buttonKey, long timeou
* @return The button
*/
public static ObjectBuilderButton POSITIVE_LONG(String buttonKey, long timeout,
- ObjectBuilder> objectBuilder) {
+ BlobObjectBuilder> objectBuilder) {
String placeholderRegex = NamingConventions.toCamelCase(buttonKey);
Function function = value -> {
@@ -704,7 +704,7 @@ public static ObjectBuilderButton SIMPLE_FLOAT(String buttonKey, long tim
* @return The button
*/
public static ObjectBuilderButton QUICK_FLOAT(String buttonKey, long timeout,
- ObjectBuilder> objectBuilder) {
+ BlobObjectBuilder> objectBuilder) {
String placeholderRegex = NamingConventions.toCamelCase(buttonKey);
return FLOAT(buttonKey, timeout, "Builder." + buttonKey
@@ -736,7 +736,7 @@ public static ObjectBuilderButton QUICK_FLOAT(String buttonKey, long time
* @return The button
*/
public static ObjectBuilderButton POSITIVE_FLOAT(String buttonKey, long timeout,
- ObjectBuilder> objectBuilder) {
+ BlobObjectBuilder> objectBuilder) {
String placeholderRegex = NamingConventions.toCamelCase(buttonKey);
Function function = value -> {
@@ -837,7 +837,7 @@ public static ObjectBuilderButton SIMPLE_DOUBLE(String buttonKey, long t
* @return The button
*/
public static ObjectBuilderButton QUICK_DOUBLE(String buttonKey, long timeout,
- ObjectBuilder> objectBuilder) {
+ BlobObjectBuilder> objectBuilder) {
String placeholderRegex = NamingConventions.toCamelCase(buttonKey);
return DOUBLE(buttonKey, timeout, "Builder." + buttonKey
@@ -869,7 +869,7 @@ public static ObjectBuilderButton QUICK_DOUBLE(String buttonKey, long ti
* @return The button
*/
public static ObjectBuilderButton POSITIVE_DOUBLE(String buttonKey, long timeout,
- ObjectBuilder> objectBuilder) {
+ BlobObjectBuilder> objectBuilder) {
String placeholderRegex = NamingConventions.toCamelCase(buttonKey);
Function function = value -> {
objectBuilder.updateDefaultButton(buttonKey, "%" + placeholderRegex + "%",
@@ -977,7 +977,7 @@ public static ObjectBuilderButton SIMPLE_BLOCK(String buttonKey, long tim
* @return The button
*/
public static ObjectBuilderButton QUICK_BLOCK(String buttonKey, long timeout,
- ObjectBuilder> objectBuilder) {
+ BlobObjectBuilder> objectBuilder) {
String placeholderRegex = NamingConventions.toCamelCase(buttonKey);
return BLOCK(buttonKey, timeout, "Builder." + buttonKey
@@ -1011,7 +1011,7 @@ public static ObjectBuilderButton QUICK_BLOCK(String buttonKey, long time
* @return The button
*/
public static ObjectBuilderButton QUICK_ABOVE_BLOCK(String buttonKey, long timeout,
- ObjectBuilder> objectBuilder) {
+ BlobObjectBuilder> objectBuilder) {
String placeholderRegex = NamingConventions.toCamelCase(buttonKey);
return ABOVE_BLOCK(buttonKey, timeout, "Builder." + buttonKey
@@ -1036,7 +1036,7 @@ public static ObjectBuilderButton QUICK_ABOVE_BLOCK(String buttonKey, lon
*/
public static ObjectBuilderButton QUICK_ACTION_BLOCK(String buttonKey,
long timeout,
- ObjectBuilder> objectBuilder,
+ BlobObjectBuilder> objectBuilder,
Consumer consumer) {
String placeholderRegex = NamingConventions.toCamelCase(buttonKey);
return BLOCK(buttonKey, timeout, "Builder." + buttonKey
@@ -1097,7 +1097,7 @@ public static ObjectBuilderButton SIMPLE_ITEM(String buttonKey,
* @return The button
*/
public static ObjectBuilderButton QUICK_ITEM(String buttonKey,
- ObjectBuilder> objectBuilder) {
+ BlobObjectBuilder> objectBuilder) {
String placeholderRegex = NamingConventions.toCamelCase(buttonKey);
return ITEM(buttonKey, "Builder.ItemStack", itemStack -> {
objectBuilder.updateDefaultButton(buttonKey, "%" + placeholderRegex + "%",
@@ -1117,7 +1117,7 @@ public static ObjectBuilderButton QUICK_ITEM(String buttonKey,
* @return The button
*/
public static ObjectBuilderButton QUICK_ACTION_ITEM(String buttonKey,
- ObjectBuilder> objectBuilder,
+ BlobObjectBuilder> objectBuilder,
Consumer consumer) {
String placeholderRegex = NamingConventions.toCamelCase(buttonKey);
return ITEM(buttonKey, "Builder.ItemStack", itemStack -> {
@@ -1189,7 +1189,7 @@ public static