Skip to content

Commit

Permalink
Updated Upstream (Purpur)
Browse files Browse the repository at this point in the history
  • Loading branch information
SoSeDiK committed Sep 20, 2024
1 parent 7bf37e0 commit 7ce0fb6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = 1.21.1-R0.1-SNAPSHOT
mcVersion = 1.21.1

# Upstream commit
purpurCommit = 8af4ea6f4637c5aaeeaf10791f2715324b5ccf38
purpurCommit = 8332fa45d9886aed8cf0c114e08c6671a06794c8

# Gradle
org.gradle.caching = true
Expand Down
27 changes: 22 additions & 5 deletions patches/api/0013-Item-Modifiers-API.patch
Original file line number Diff line number Diff line change
Expand Up @@ -67,23 +67,27 @@ index 0000000000000000000000000000000000000000..3d596bbfaa0015a5d2e34207f4065d9a
+}
diff --git a/src/main/java/me/sosedik/kiterino/modifier/item/ItemContextBox.java b/src/main/java/me/sosedik/kiterino/modifier/item/ItemContextBox.java
new file mode 100644
index 0000000000000000000000000000000000000000..9499c5f24702e5c1ff0fa1b688fc0d5d1c5f59a4
index 0000000000000000000000000000000000000000..1c6e912c28a3d69995b24a5713f6ad14a5ce00af
--- /dev/null
+++ b/src/main/java/me/sosedik/kiterino/modifier/item/ItemContextBox.java
@@ -0,0 +1,223 @@
@@ -0,0 +1,240 @@
+package me.sosedik.kiterino.modifier.item;
+
+import com.google.common.base.Preconditions;
+import me.sosedik.kiterino.modifier.item.context.ItemModifierContext;
+import me.sosedik.kiterino.modifier.item.context.ItemModifierContextType;
+import net.kyori.adventure.text.Component;
+import org.bukkit.Material;
+import org.bukkit.entity.Player;
+import org.bukkit.inventory.ItemStack;
+import org.bukkit.inventory.meta.ItemMeta;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Locale;
+import java.util.Objects;
+import java.util.function.Consumer;
+
+/**
Expand Down Expand Up @@ -232,14 +236,25 @@ index 0000000000000000000000000000000000000000..9499c5f24702e5c1ff0fa1b688fc0d5d
+ */
+ @SuppressWarnings("unchecked")
+ public <M extends ItemMeta> boolean editMeta(@NotNull Class<M> metaClass, @NotNull Consumer<? super M> consumer) {
+ if (metaClass.isInstance(meta)) {
+ consumer.accept((M) meta);
+ ItemMeta itemMeta = getMeta();
+ if (metaClass.isInstance(itemMeta)) {
+ consumer.accept((M) itemMeta);
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Gets the item's lore if exists, or a new array list otherwise
+ *
+ * @return item's lore or empty list
+ */
+ public @NotNull List<Component> getLore() {
+ ItemMeta itemMeta = getMeta();
+ return itemMeta.hasLore() ? Objects.requireNonNull(itemMeta.lore()) : new ArrayList<>();
+ }
+
+ /**
+ * Gets the resulting type of the item.
+ * This will return either {@link #getNewMaterial()} or current item's type.
+ * If you are interested only in the original item type,
Expand Down Expand Up @@ -289,7 +304,9 @@ index 0000000000000000000000000000000000000000..9499c5f24702e5c1ff0fa1b688fc0d5d
+ if (type == null) return;
+
+ var tempItem = new ItemStack(type);
+ tempItem.setItemMeta(this.meta);
+ if (this.meta != null || this.item.getType() != Material.AIR) {
+ tempItem.setItemMeta(getMeta());
+ }
+ this.meta = tempItem.getItemMeta();
+ }
+
Expand Down

0 comments on commit 7ce0fb6

Please sign in to comment.