Update JSON messages to work with 1.12 and add additional checks
This commit is contained in:
parent
6f366ae078
commit
3d1cfe7a79
|
@ -36,13 +36,14 @@ public enum JSONColor {
|
|||
|
||||
public static JSONColor fromString(String text) {
|
||||
if (text != null) {
|
||||
text = text.replace("§", "&");
|
||||
for (JSONColor b : JSONColor.values()) {
|
||||
if (text.equalsIgnoreCase(b.code)) {
|
||||
return b;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return WHITE; // no color found, return default white to prevent errors
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
|
|
|
@ -247,7 +247,7 @@ public interface JSONHoverAction<T> {
|
|||
@Override
|
||||
public String getValueString() {
|
||||
String material = value.getData().getItemType().toString().toLowerCase();
|
||||
String value2 = "{id:minecraft:" + material + ",Damage:" + value.getDurability() + ",tag:{";
|
||||
String value2 = "{id:\\\"minecraft:" + material + "\\\",Damage:" + value.getDurability() + ",Count:" + value.getAmount() + ",tag:{";
|
||||
|
||||
if (value.getItemMeta().hasEnchants()) {
|
||||
value2 += "ench:[";
|
||||
|
@ -255,9 +255,9 @@ public interface JSONHoverAction<T> {
|
|||
int size = value.getItemMeta().getEnchants().keySet().size();
|
||||
for (Enchantment ench : value.getItemMeta().getEnchants().keySet()) {
|
||||
if (i + 1 == size) {
|
||||
value2 += i + ":{lvl:" + value.getItemMeta().getEnchants().get(ench) + "s,id:" + ench.getId() + "}";
|
||||
value2 += "{lvl:" + value.getItemMeta().getEnchants().get(ench) + "s,id:" + ench.getId() + "s}";
|
||||
} else {
|
||||
value2 += i + ":{lvl:" + value.getItemMeta().getEnchants().get(ench) + "s,id:" + ench.getId() + "},";
|
||||
value2 += "{lvl:" + value.getItemMeta().getEnchants().get(ench) + "s,id:" + ench.getId() + "s},";
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
@ -274,7 +274,6 @@ public interface JSONHoverAction<T> {
|
|||
|
||||
if (value.getItemMeta().hasLore()) {
|
||||
value2 += ",Lore:[";
|
||||
int i = 0;
|
||||
for (String lore : value.getItemMeta().getLore()) {
|
||||
value2 = value2 + (value.getItemMeta().getLore().size() == 1 || value
|
||||
.getItemMeta()
|
||||
|
@ -282,8 +281,7 @@ public interface JSONHoverAction<T> {
|
|||
.get(value
|
||||
.getItemMeta()
|
||||
.getLore()
|
||||
.size() - 1) == lore ? (i + ":\\\"" + lore + "\\\"") : (i + ":\\\"" + lore + "\\\","));
|
||||
i++;
|
||||
.size() - 1) == lore ? ("\\\"" + lore + "\\\"") : ("\\\"" + lore + "\\\","));
|
||||
}
|
||||
|
||||
value2 += "]";
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
name: boosCooldowns
|
||||
main: cz.boosik.boosCooldown.BoosCoolDown
|
||||
version: 3.14.2
|
||||
version: 3.14.3
|
||||
authors: [LordBoos (boosik)]
|
||||
softdepend: [Vault, PlayerPoints]
|
||||
description: >
|
||||
|
|
2
pom.xml
2
pom.xml
|
@ -11,7 +11,7 @@
|
|||
<packaging>pom</packaging>
|
||||
<url>http://maven.apache.org</url>
|
||||
<properties>
|
||||
<boosCooldowns.version>3.14.2</boosCooldowns.version>
|
||||
<boosCooldowns.version>3.14.3</boosCooldowns.version>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<minecraft.version>1.12</minecraft.version>
|
||||
|
|
Loading…
Reference in New Issue