Skip to content

Commit 490cbe4

Browse files
committed
lore provided into makeItem will now automatically be color translated
1 parent f4bafc3 commit 490cbe4

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

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.0</version>
9+
<version>4.3.1</version>
1010
<packaging>jar</packaging>
1111

1212
<name>SimpAPI</name>

src/main/java/me/kodysimpson/simpapi/config/ConfigManager.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.fasterxml.jackson.core.JsonFactory;
44
import com.fasterxml.jackson.core.JsonGenerator;
55
import com.fasterxml.jackson.core.JsonParser;
6+
import com.fasterxml.jackson.core.PrettyPrinter;
67
import com.fasterxml.jackson.core.util.DefaultPrettyPrinter;
78
import com.fasterxml.jackson.databind.DeserializationFeature;
89
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -15,6 +16,8 @@
1516

1617
public class ConfigManager {
1718

19+
private PrettyPrinter prettyPrinter = null;
20+
1821
public enum FileType{
1922
JSON, YAML
2023
}

src/main/java/me/kodysimpson/simpapi/menu/Menu.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package me.kodysimpson.simpapi.menu;
22

3+
import me.kodysimpson.simpapi.colors.ColorTranslator;
34
import me.kodysimpson.simpapi.exceptions.MenuManagerException;
45
import me.kodysimpson.simpapi.exceptions.MenuManagerNotSetupException;
56
import org.bukkit.Bukkit;
@@ -13,6 +14,7 @@
1314
import org.jetbrains.annotations.NotNull;
1415

1516
import java.util.Arrays;
17+
import java.util.stream.Collectors;
1618

1719
/*
1820
Defines the behavior and attributes of all menus in our plugin
@@ -95,7 +97,10 @@ public void setFillerGlass(){
9597
}
9698
}
9799
}
98-
100+
101+
/**
102+
* @param itemStack Placed into every empty slot when ran
103+
*/
99104
public void setFillerGlass(ItemStack itemStack) {
100105
for (int i = 0; i < getSlots(); i++) {
101106
if (inventory.getItem(i) == null){
@@ -104,14 +109,21 @@ public void setFillerGlass(ItemStack itemStack) {
104109
}
105110
}
106111

112+
/**
113+
* @param material The material to base the ItemStack on
114+
* @param displayName The display name of the ItemStack
115+
* @param lore The lore of the ItemStack, with the Strings being automatically color coded with ColorTranslator
116+
* @return The constructed ItemStack object
117+
*/
107118
public ItemStack makeItem(Material material, String displayName, String... lore) {
108119

109120
ItemStack item = new ItemStack(material);
110121
ItemMeta itemMeta = item.getItemMeta();
111122
assert itemMeta != null;
112123
itemMeta.setDisplayName(displayName);
113124

114-
itemMeta.setLore(Arrays.asList(lore));
125+
//Automatically translate color codes provided
126+
itemMeta.setLore(Arrays.stream(lore).map(ColorTranslator::translateColorCodes).collect(Collectors.toList()));
115127
item.setItemMeta(itemMeta);
116128

117129
return item;

0 commit comments

Comments
 (0)