Skip to content

Commit df158a3

Browse files
committed
item utils
1 parent dfb4fbf commit df158a3

File tree

3 files changed

+38
-2
lines changed

3 files changed

+38
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# SimpAPI v4.3.2
1+
# SimpAPI v4.4.0
22

33
## Table Of Contents:
44
****

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>me.kodysimpson</groupId>
88
<artifactId>SimpAPI</artifactId>
9-
<version>4.3.2</version>
9+
<version>4.4.0</version>
1010
<packaging>jar</packaging>
1111

1212
<name>SimpAPI</name>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package me.kodysimpson.simpapi.items;
2+
3+
import me.kodysimpson.simpapi.colors.ColorTranslator;
4+
import org.bukkit.Material;
5+
import org.bukkit.inventory.ItemStack;
6+
import org.bukkit.inventory.meta.ItemMeta;
7+
8+
import java.util.Arrays;
9+
import java.util.stream.Collectors;
10+
11+
/**
12+
* Class for Utilities related to Minecraft/Bukkit Items
13+
*/
14+
public class ItemUtils {
15+
16+
/**
17+
* @param material The material to base the ItemStack on
18+
* @param displayName The display name of the ItemStack
19+
* @param lore The lore of the ItemStack, with the Strings being automatically color coded with ColorTranslator
20+
* @return The constructed ItemStack object
21+
*/
22+
public static ItemStack makeItem(Material material, String displayName, String... lore) {
23+
24+
ItemStack item = new ItemStack(material);
25+
ItemMeta itemMeta = item.getItemMeta();
26+
assert itemMeta != null;
27+
itemMeta.setDisplayName(displayName);
28+
29+
//Automatically translate color codes provided
30+
itemMeta.setLore(Arrays.stream(lore).map(ColorTranslator::translateColorCodes).collect(Collectors.toList()));
31+
item.setItemMeta(itemMeta);
32+
33+
return item;
34+
}
35+
36+
}

0 commit comments

Comments
 (0)