Update 5.14
This commit is contained in:
@@ -74,6 +74,7 @@ public class TInjectLoader implements TabooLibLoader.Loader {
|
||||
TLocaleLoader.setLocalePriority(plugin, localePriority);
|
||||
TLocaleLoader.load(plugin, true, true);
|
||||
});
|
||||
config.runListener();
|
||||
}
|
||||
if (Strings.nonEmpty(args.reload())) {
|
||||
try {
|
||||
|
||||
@@ -75,7 +75,7 @@ public class TLocaleLoader {
|
||||
}
|
||||
|
||||
public static void load(Plugin plugin, boolean isCover) {
|
||||
load(plugin, isCover, false);
|
||||
load(plugin, isCover, true);
|
||||
}
|
||||
|
||||
public static void load(Plugin plugin, boolean isCover, boolean hideMessage) {
|
||||
|
||||
@@ -74,6 +74,14 @@ public class NBTBase {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public String toJsonSimplified() {
|
||||
return toJsonSimplified(0);
|
||||
}
|
||||
|
||||
public String toJsonSimplified(int index) {
|
||||
return data instanceof String ? "\"" + data + "\"" : String.valueOf(data);
|
||||
}
|
||||
|
||||
public String asString() {
|
||||
return (String) data;
|
||||
}
|
||||
@@ -123,11 +131,14 @@ public class NBTBase {
|
||||
}
|
||||
|
||||
public static NBTBase toNBT(Object obj) {
|
||||
if (obj instanceof String) {
|
||||
if (obj instanceof NBTBase) {
|
||||
return (NBTBase) obj;
|
||||
} else if (obj instanceof String) {
|
||||
if (SHORT_PATTERN.matcher(obj.toString()).matches()) {
|
||||
return toNBT(Short.valueOf(obj.toString().substring(0, obj.toString().length() - 1)));
|
||||
} else {
|
||||
return new NBTBase((String) obj);
|
||||
}
|
||||
return new NBTBase((String) obj);
|
||||
} else if (obj instanceof Integer) {
|
||||
return new NBTBase((int) obj);
|
||||
} else if (obj instanceof Double) {
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
package io.izzel.taboolib.module.nms.nbt;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import io.izzel.taboolib.module.nms.NMS;
|
||||
import io.izzel.taboolib.util.Strings;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.Collection;
|
||||
@@ -30,6 +33,40 @@ public class NBTCompound extends NBTBase implements Map<String, NBTBase> {
|
||||
item.setItemMeta(NMS.handle().saveNBT(item, this).getItemMeta());
|
||||
}
|
||||
|
||||
public String toJson() {
|
||||
return new Gson().toJson(this);
|
||||
}
|
||||
|
||||
public String toJsonFormatted() {
|
||||
return new GsonBuilder().setPrettyPrinting().create().toJson(new Gson().toJsonTree(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toJsonSimplified() {
|
||||
return toJsonSimplified(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toJsonSimplified(int index) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("{\n");
|
||||
value.forEach((k, v) -> {
|
||||
builder.append(Strings.copy(" ", index + 1))
|
||||
.append("\"")
|
||||
.append(k)
|
||||
.append("\"")
|
||||
.append(": ")
|
||||
.append(v.toJsonSimplified(index + 1))
|
||||
.append("\n");
|
||||
});
|
||||
builder.append(Strings.copy(" ", index)).append("}");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
public static NBTCompound fromJson(String json) {
|
||||
return new Gson().fromJson(json, NBTCompound.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return value.size();
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package io.izzel.taboolib.module.nms.nbt;
|
||||
|
||||
import io.izzel.taboolib.util.Strings;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.function.Consumer;
|
||||
@@ -21,6 +23,38 @@ public class NBTList extends NBTBase implements List<NBTBase> {
|
||||
this.data = this;
|
||||
}
|
||||
|
||||
public static NBTList of(NBTBase... base) {
|
||||
NBTList list = new NBTList();
|
||||
list.addAll(Arrays.asList(base));
|
||||
return list;
|
||||
}
|
||||
|
||||
public static NBTList of(Object... base) {
|
||||
NBTList list = new NBTList();
|
||||
for (Object obj : base) {
|
||||
list.add(NBTBase.toNBT(obj));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toJsonSimplified() {
|
||||
return toJsonSimplified(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toJsonSimplified(int index) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("[\n");
|
||||
value.forEach(v -> {
|
||||
builder.append(Strings.copy(" ", index + 1))
|
||||
.append(v.toJsonSimplified(index + 1))
|
||||
.append("\n");
|
||||
});
|
||||
builder.append(Strings.copy(" ", index)).append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return value.size();
|
||||
|
||||
Reference in New Issue
Block a user