mirror of
https://github.com/Xiao-MoMi/Custom-Fishing.git
synced 2025-12-19 15:09:24 +00:00
1.0
This commit is contained in:
@@ -215,59 +215,44 @@ public class ConfigReader{
|
||||
YamlConfiguration config = getConfig("loots.yml");
|
||||
Set<String> keys = Objects.requireNonNull(config.getConfigurationSection("items")).getKeys(false);
|
||||
keys.forEach(key -> {
|
||||
/*
|
||||
必设置的内容,为构造所需
|
||||
*/
|
||||
String name;
|
||||
if (config.contains("items." + key + ".display.name")) {
|
||||
name = config.getString("items." + key + ".display.name");
|
||||
} else {
|
||||
AdventureManager.consoleMessage("<red>[CustomFishing] 错误! 未设置 " + key + " 的物品名称!</red>");
|
||||
return;
|
||||
}
|
||||
|
||||
Difficulty difficulty;
|
||||
if (config.contains("items." + key + ".difficulty")) {
|
||||
String[] split = StringUtils.split(config.getString("items." + key + ".difficulty"), "-");
|
||||
assert split != null;
|
||||
if (Integer.parseInt(split[1]) <= 0 || Integer.parseInt(split[0]) <= 0){
|
||||
AdventureManager.consoleMessage("<red>[CustomFishing] 错误! " + key + " 的捕获难度必须为正整数与正整数的组合!</red>");
|
||||
AdventureManager.consoleMessage("<red>[CustomFishing] Error! " + key + " has wrong difficulty format!</red>");
|
||||
return;
|
||||
}else {
|
||||
difficulty = new Difficulty(Integer.parseInt(split[0]), Integer.parseInt(split[1]));
|
||||
}
|
||||
} else {
|
||||
AdventureManager.consoleMessage("<red>[CustomFishing] 错误! 未设置 " + key + " 的捕获难度!</red>");
|
||||
return;
|
||||
difficulty = new Difficulty(1, 1);
|
||||
}
|
||||
int weight;
|
||||
if (config.contains("items." + key + ".weight")) {
|
||||
weight = config.getInt("items." + key + ".weight");
|
||||
} else {
|
||||
AdventureManager.consoleMessage("<red>[CustomFishing] 错误! 未设置 " + key + " 的捕获权重!</red>");
|
||||
AdventureManager.consoleMessage("<red>[CustomFishing] Error! No weight set for " + key + " !</red>");
|
||||
return;
|
||||
}
|
||||
int time;
|
||||
if (config.contains("items." + key + ".time")) {
|
||||
time = config.getInt("items." + key + ".time");
|
||||
if (time <= 0){
|
||||
AdventureManager.consoleMessage("<red>[CustomFishing] 错误! " + key + " 的捕捉时间必须为正整数!</red>");
|
||||
AdventureManager.consoleMessage("<red>[CustomFishing] Error! " + key + " time must be positive!</red>");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
AdventureManager.consoleMessage("<red>[CustomFishing] 错误! 未设置 " + key + " 的捕捉时间!</red>");
|
||||
return;
|
||||
time = 10000;
|
||||
}
|
||||
|
||||
//新建单例
|
||||
Loot loot = new Loot(key, name, difficulty, weight, time);
|
||||
Loot loot = new Loot(key, difficulty, weight, time);
|
||||
|
||||
/*
|
||||
必须设置的内容,但并非构造所需
|
||||
*/
|
||||
if (config.contains("items." + key + ".material")) {
|
||||
loot.setMaterial(config.getString("items." + key + ".material"));
|
||||
} else {
|
||||
AdventureManager.consoleMessage("<red>[CustomFishing] 错误! 未设置 " + key + " 的物品材质!</red>");
|
||||
AdventureManager.consoleMessage("<red>[CustomFishing] Error! No material set for " + key + " !</red>");
|
||||
return;
|
||||
}
|
||||
/*
|
||||
@@ -275,6 +260,8 @@ public class ConfigReader{
|
||||
*/
|
||||
if (config.contains("items." + key + ".display.lore"))
|
||||
loot.setLore(config.getStringList("items." + key + ".display.lore"));
|
||||
if (config.contains("items." + key + ".display.name"))
|
||||
loot.setName(config.getString("items." + key + ".display.name"));
|
||||
if (config.contains("items." + key + ".enchantments")) {
|
||||
ArrayList<Enchantment> arrayList = new ArrayList<>();
|
||||
config.getStringList("items." + key + ".enchantments").forEach(enchant -> {
|
||||
@@ -292,13 +279,15 @@ public class ConfigReader{
|
||||
loot.setItemFlags(arrayList);
|
||||
}
|
||||
if (config.contains("items." + key + ".nbt"))
|
||||
loot.setNbt(config.getMapList("items." + key + ".nbt").get(0));
|
||||
|
||||
loot.setNbt((Map<String, Object>) config.getMapList("items." + key + ".nbt").get(0));
|
||||
if (config.contains("items." + key + ".custom-model-data"))
|
||||
loot.setCustommodeldata(config.getInt("items." + key + ".custom-model-data"));
|
||||
if (config.contains("items."+ key +".nick")){
|
||||
loot.setNick(config.getString("items."+key+".nick"));
|
||||
}else {
|
||||
loot.setNick(loot.getName());
|
||||
}
|
||||
loot.setUnbreakable(config.getBoolean("items." + key + ".unbreakable",false));
|
||||
|
||||
if (config.contains("items." + key + ".action.message"))
|
||||
loot.setMsg(config.getString("items." + key + ".action.message"));
|
||||
@@ -328,7 +317,7 @@ public class ConfigReader{
|
||||
if (Config.season){
|
||||
requirements.add(new Season(config.getStringList("items." + key + ".requirements.season")));
|
||||
}else {
|
||||
AdventureManager.consoleMessage("<red>[CustomFishing] 使用季节特性请先在 config.yml 中启用季节特性!</red>");
|
||||
AdventureManager.consoleMessage("<red>[CustomFishing] Plz enable season in config.yml!</red>");
|
||||
}
|
||||
}
|
||||
case "world" -> requirements.add(new World(config.getStringList("items." + key + ".requirements.world")));
|
||||
@@ -338,7 +327,7 @@ public class ConfigReader{
|
||||
if (Config.wg){
|
||||
requirements.add(new Region(config.getStringList("items." + key + ".requirements.regions")));
|
||||
}else {
|
||||
AdventureManager.consoleMessage("<red>[CustomFishing] 指定钓鱼区域需要启用 WorldGuard 兼容!</red>");
|
||||
AdventureManager.consoleMessage("<red>[CustomFishing] Plz enable WorldGuard Integration!</red>");
|
||||
}
|
||||
}
|
||||
case "time" -> requirements.add(new Time(config.getStringList("items." + key + ".requirements.time")));
|
||||
@@ -361,7 +350,7 @@ public class ConfigReader{
|
||||
if (config.contains("mobs." + key + ".name")) {
|
||||
name = config.getString("mobs." + key + ".name");
|
||||
} else {
|
||||
AdventureManager.consoleMessage("<red>[CustomFishing] 错误! 未设置 " + key + " 的怪物名称!</red>");
|
||||
AdventureManager.consoleMessage("<red>[CustomFishing] Error! No name set for mob " + key + " !</red>");
|
||||
return;
|
||||
}
|
||||
Difficulty difficulty;
|
||||
@@ -369,42 +358,40 @@ public class ConfigReader{
|
||||
String[] split = StringUtils.split(config.getString("mobs." + key + ".difficulty"), "-");
|
||||
assert split != null;
|
||||
if (Integer.parseInt(split[1]) <= 0 || Integer.parseInt(split[0]) <= 0){
|
||||
AdventureManager.consoleMessage("<red>[CustomFishing] 错误! " + key + " 的捕获难度必须为正整数与正整数的组合!</red>");
|
||||
AdventureManager.consoleMessage("<red>[CustomFishing] Error! " + key + " has wrong difficulty format!</red>");
|
||||
return;
|
||||
}else {
|
||||
difficulty = new Difficulty(Integer.parseInt(split[0]), Integer.parseInt(split[1]));
|
||||
}
|
||||
} else {
|
||||
AdventureManager.consoleMessage("<red>[CustomFishing] 错误! 未设置 " + key + " 的捕获难度!</red>");
|
||||
return;
|
||||
difficulty = new Difficulty(1, 1);
|
||||
}
|
||||
int weight;
|
||||
if (config.contains("mobs." + key + ".weight")) {
|
||||
weight = config.getInt("mobs." + key + ".weight");
|
||||
} else {
|
||||
AdventureManager.consoleMessage("<red>[CustomFishing] 错误! 未设置 " + key + " 的捕获权重!</red>");
|
||||
AdventureManager.consoleMessage("<red>[CustomFishing] Error! No weight set for " + key + " !</red>");
|
||||
return;
|
||||
}
|
||||
int time;
|
||||
if (config.contains("mobs." + key + ".time")) {
|
||||
time = config.getInt("mobs." + key + ".time");
|
||||
if (time <= 0){
|
||||
AdventureManager.consoleMessage("<red>[CustomFishing] 错误! " + key + " 的捕捉时间必须为正整数!</red>");
|
||||
AdventureManager.consoleMessage("<red>[CustomFishing] Error! " + key + " time must be positive!</red>");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
AdventureManager.consoleMessage("<red>[CustomFishing] 错误! 未设置 " + key + " 的捕捉时间!</red>");
|
||||
return;
|
||||
time = 10000;
|
||||
}
|
||||
//新建单例
|
||||
Loot loot = new Loot(key, name, difficulty, weight, time);
|
||||
Loot loot = new Loot(key, difficulty, weight, time);
|
||||
//设置昵称
|
||||
loot.setNick(name);
|
||||
//设置MM怪ID
|
||||
if (config.contains("mobs." + key + ".mythicmobsID")) {
|
||||
loot.setMm(config.getString("mobs." + key + ".mythicmobsID"));
|
||||
} else {
|
||||
AdventureManager.consoleMessage("<red>[CustomFishing] 错误! 未设置 " + key + " 的MM怪ID!</red>");
|
||||
AdventureManager.consoleMessage("<red>[CustomFishing] Error! No MythicMobs id set for " + key + " !</red>");
|
||||
return;
|
||||
}
|
||||
//设置MM怪位移
|
||||
@@ -444,7 +431,7 @@ public class ConfigReader{
|
||||
if (Config.season){
|
||||
requirements.add(new Season(config.getStringList("mobs." + key + ".requirements.season")));
|
||||
}else {
|
||||
AdventureManager.consoleMessage("<red>[CustomFishing] 使用季节特性请先在 config.yml 中启用季节特性!</red>");
|
||||
AdventureManager.consoleMessage("<red>[CustomFishing] Plz enable season in config.yml!</red>");
|
||||
}
|
||||
}
|
||||
case "world" -> requirements.add(new World(config.getStringList("mobs." + key + ".requirements.world")));
|
||||
@@ -454,7 +441,7 @@ public class ConfigReader{
|
||||
if (Config.wg){
|
||||
requirements.add(new Region(config.getStringList("mobs." + key + ".requirements.regions")));
|
||||
}else {
|
||||
AdventureManager.consoleMessage("<red>[CustomFishing] 指定钓鱼区域需要启用 WorldGuard 兼容!</red>");
|
||||
AdventureManager.consoleMessage("<red>[CustomFishing] Plz enable WorldGuard Integration!</red>");
|
||||
}
|
||||
}
|
||||
case "time" -> requirements.add(new Time(config.getStringList("mobs." + key + ".requirements.time")));
|
||||
@@ -466,7 +453,7 @@ public class ConfigReader{
|
||||
LOOT.put(key, loot);
|
||||
});
|
||||
if (keys.size() != LOOTITEM.size() || mobs.size() != LOOT.size()- LOOTITEM.size()) {
|
||||
AdventureManager.consoleMessage("<red>[CustomFishing] loots.yml 文件存在配置错误!</red>");
|
||||
AdventureManager.consoleMessage("<red>[CustomFishing] loots.yml exists error!</red>");
|
||||
} else {
|
||||
AdventureManager.consoleMessage("<gradient:#0070B3:#A0EACF>[CustomFishing] </gradient><white>" + keys.size() + " <color:#E1FFFF>loots loaded!");
|
||||
AdventureManager.consoleMessage("<gradient:#0070B3:#A0EACF>[CustomFishing] </gradient><white>" + mobs.size() + " <color:#E1FFFF>mobs loaded!");
|
||||
@@ -494,13 +481,7 @@ public class ConfigReader{
|
||||
/*
|
||||
必设置的内容,为构造所需
|
||||
*/
|
||||
String name;
|
||||
if (config.contains("utils." + key + ".display.name")) {
|
||||
name = config.getString("utils." + key + ".display.name");
|
||||
} else {
|
||||
AdventureManager.consoleMessage("<red>[CustomFishing] Error! No name set for " + key + " !</red>");
|
||||
return;
|
||||
}
|
||||
|
||||
String material;
|
||||
if (config.contains("utils." + key + ".material")) {
|
||||
material = config.getString("utils." + key + ".material");
|
||||
@@ -509,12 +490,16 @@ public class ConfigReader{
|
||||
return;
|
||||
}
|
||||
|
||||
Util utilInstance = new Util(key, name, material);
|
||||
|
||||
Util utilInstance = new Util(material);
|
||||
if (config.contains("utils." + key + ".custom-model-data"))
|
||||
utilInstance.setCustommodeldata(config.getInt("utils." + key + ".custom-model-data"));
|
||||
if (config.contains("utils." + key + ".display.name"))
|
||||
utilInstance.setName(config.getString("utils." + key + ".display.name"));
|
||||
if (config.contains("utils." + key + ".display.lore"))
|
||||
utilInstance.setLore(config.getStringList("utils." + key + ".display.lore"));
|
||||
if (config.contains("utils." + key + ".nbt"))
|
||||
utilInstance.setNbt(config.getMapList("utils." + key + ".nbt").get(0));
|
||||
utilInstance.setNbt((Map<String, Object>) config.getMapList("utils." + key + ".nbt").get(0));
|
||||
utilInstance.setUnbreakable(config.getBoolean("utils." + key + ".unbreakable",false));
|
||||
if (config.contains("utils." + key + ".enchantments")) {
|
||||
ArrayList<Enchantment> arrayList = new ArrayList<>();
|
||||
config.getStringList("utils." + key + ".enchantments").forEach(enchant -> {
|
||||
@@ -531,6 +516,7 @@ public class ConfigReader{
|
||||
});
|
||||
utilInstance.setItemFlags(arrayList);
|
||||
}
|
||||
|
||||
UTIL.put(key, utilInstance);
|
||||
UTILITEM.put(key, NBTUtil.addIdentifier(ItemStackGenerator.fromItem(utilInstance), "util", key));
|
||||
});
|
||||
@@ -553,20 +539,16 @@ public class ConfigReader{
|
||||
Set<String> keys = Objects.requireNonNull(config.getConfigurationSection("rods")).getKeys(false);
|
||||
|
||||
keys.forEach(key -> {
|
||||
String name;
|
||||
if (config.contains("rods." + key + ".display.name")) {
|
||||
name = config.getString("rods." + key + ".display.name");
|
||||
} else {
|
||||
AdventureManager.consoleMessage("<red>[CustomFishing] 错误! 未设置 " + key + " 的物品名称!</red>");
|
||||
return;
|
||||
}
|
||||
Rod rodInstance = new Rod(name);
|
||||
if (config.contains("rods." + key + ".display.lore")) {
|
||||
Rod rodInstance = new Rod();
|
||||
if (config.contains("rods." + key + ".display.name"))
|
||||
rodInstance.setName(config.getString("rods." + key + ".display.name"));
|
||||
if (config.contains("rods." + key + ".display.lore"))
|
||||
rodInstance.setLore(config.getStringList("rods." + key + ".display.lore"));
|
||||
}
|
||||
if (config.contains("rods." + key + ".nbt")) {
|
||||
rodInstance.setNbt(config.getMapList("rods." + key + ".nbt").get(0));
|
||||
}
|
||||
if (config.contains("rods." + key + ".nbt"))
|
||||
rodInstance.setNbt((Map<String, Object>)(config.getMapList("rods." + key + ".nbt").get(0)));
|
||||
if (config.contains("rods." + key + ".custom-model-data"))
|
||||
rodInstance.setCustommodeldata(config.getInt("rods." + key + ".custom-model-data"));
|
||||
rodInstance.setUnbreakable(config.getBoolean("rods." + key + ".unbreakable",false));
|
||||
if (config.contains("rods." + key + ".enchantments")) {
|
||||
ArrayList<Enchantment> arrayList = new ArrayList<>();
|
||||
config.getStringList("rods." + key + ".enchantments").forEach(enchant -> {
|
||||
@@ -626,13 +608,6 @@ public class ConfigReader{
|
||||
Set<String> keys = config.getConfigurationSection("baits").getKeys(false);
|
||||
|
||||
keys.forEach(key -> {
|
||||
String name;
|
||||
if (config.contains("baits." + key + ".display.name")) {
|
||||
name = config.getString("baits." + key + ".display.name");
|
||||
} else {
|
||||
AdventureManager.consoleMessage("<red>[CustomFishing] Error! No name set for " + key + " !</red>");
|
||||
return;
|
||||
}
|
||||
String material;
|
||||
if (config.contains("baits." + key + ".material")) {
|
||||
material = config.getString("baits." + key + ".material");
|
||||
@@ -640,13 +615,17 @@ public class ConfigReader{
|
||||
AdventureManager.consoleMessage("<red>[CustomFishing] Error! No material set for " + key + " !</red>");
|
||||
return;
|
||||
}
|
||||
Bait baitInstance = new Bait(name, material);
|
||||
if (config.contains("baits." + key + ".display.lore")) {
|
||||
Bait baitInstance = new Bait(material);
|
||||
if (config.contains("baits." + key + ".display.lore"))
|
||||
baitInstance.setLore(config.getStringList("baits." + key + ".display.lore"));
|
||||
}
|
||||
if (config.contains("baits." + key + ".display.name"))
|
||||
baitInstance.setName(config.getString("baits." + key + ".display.name"));
|
||||
if (config.contains("baits." + key + ".custom-model-data"))
|
||||
baitInstance.setCustommodeldata(config.getInt("baits." + key + ".custom-model-data"));
|
||||
if (config.contains("baits." + key + ".nbt")) {
|
||||
baitInstance.setNbt(config.getMapList("baits." + key + ".nbt").get(0));
|
||||
baitInstance.setNbt((Map<String, Object>) config.getMapList("baits." + key + ".nbt").get(0));
|
||||
}
|
||||
baitInstance.setUnbreakable(config.getBoolean("baits." + key + ".unbreakable",false));
|
||||
if (config.contains("baits." + key + ".enchantments")) {
|
||||
ArrayList<Enchantment> arrayList = new ArrayList<>();
|
||||
config.getStringList("baits." + key + ".enchantments").forEach(enchant -> {
|
||||
|
||||
@@ -30,7 +30,6 @@ public class Layout {
|
||||
public void setStart(String start) {this.start = start;}
|
||||
public void setTitle(String title) {this.title = title;}
|
||||
|
||||
public String getKey(){return this.key;}
|
||||
public int getRange(){return this.range;}
|
||||
public double[] getSuccessRate(){return this.successRate;}
|
||||
public int getSize(){return this.size;}
|
||||
|
||||
@@ -6,6 +6,7 @@ import net.momirealms.customfishing.item.Bait;
|
||||
import net.momirealms.customfishing.item.Loot;
|
||||
import net.momirealms.customfishing.item.Rod;
|
||||
import net.momirealms.customfishing.item.Util;
|
||||
import net.momirealms.customfishing.utils.SaveItem;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
@@ -18,17 +19,17 @@ public class Execute implements CommandExecutor {
|
||||
@Override
|
||||
@ParametersAreNonnullByDefault
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
//没有权限的快走啦
|
||||
|
||||
if (!(sender.hasPermission("customfishing.admin") || sender.isOp())) {
|
||||
AdventureManager.playerMessage((Player) sender,ConfigReader.Message.prefix + ConfigReader.Message.noPerm);
|
||||
return true;
|
||||
}
|
||||
//参数打不全的赶紧走开
|
||||
|
||||
if (args.length < 1){
|
||||
lackArgs(sender);
|
||||
return true;
|
||||
}
|
||||
//重载命令
|
||||
|
||||
if (args[0].equalsIgnoreCase("reload")) {
|
||||
ConfigReader.Reload();
|
||||
if (sender instanceof Player){
|
||||
@@ -38,7 +39,18 @@ public class Execute implements CommandExecutor {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
//获取物品命令
|
||||
|
||||
if (args[0].equalsIgnoreCase("export")) {
|
||||
if (args.length < 2){
|
||||
lackArgs(sender);
|
||||
return true;
|
||||
}
|
||||
if (sender instanceof Player player){
|
||||
SaveItem.saveToFile(player.getInventory().getItemInMainHand(), args[1]);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("items")) {
|
||||
if (args.length < 4){
|
||||
lackArgs(sender);
|
||||
|
||||
@@ -15,17 +15,20 @@ public class TabComplete implements TabCompleter {
|
||||
@Override
|
||||
@ParametersAreNonnullByDefault
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
//没有权限还想补全?
|
||||
|
||||
if (!(sender.hasPermission("customfishing.admin") || sender.isOp())) {
|
||||
return null;
|
||||
}
|
||||
if (args.length == 1){
|
||||
return Arrays.asList("reload","items");
|
||||
return Arrays.asList("reload","items","export");
|
||||
}
|
||||
if (args.length == 2){
|
||||
if (args[0].equalsIgnoreCase("items")){
|
||||
return Arrays.asList("loot","bait","rod","util");
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("export")){
|
||||
return List.of("FileName");
|
||||
}
|
||||
}
|
||||
if (args.length == 3){
|
||||
if (args[0].equalsIgnoreCase("items")){
|
||||
|
||||
@@ -79,9 +79,7 @@ public final class LibraryLoader {
|
||||
}
|
||||
|
||||
public static void load(Dependency d) {
|
||||
//Log.info(String.format("Loading dependency %s:%s:%s from %s", d.getGroupId(), d.getArtifactId(), d.getVersion(), d.getRepoUrl()));
|
||||
String name = d.getArtifactId() + "-" + d.getVersion();
|
||||
|
||||
File saveLocation = new File(getLibFolder(d), name + ".jar");
|
||||
if (!saveLocation.exists()) {
|
||||
|
||||
@@ -100,13 +98,13 @@ public final class LibraryLoader {
|
||||
}
|
||||
|
||||
if (!saveLocation.exists()) {
|
||||
throw new RuntimeException("Unable to download dependency: " + d.toString());
|
||||
throw new RuntimeException("Unable to download dependency: " + d);
|
||||
}
|
||||
|
||||
try {
|
||||
URL_INJECTOR.get().addURL(saveLocation.toURI().toURL());
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Unable to load dependency: " + saveLocation.toString(), e);
|
||||
throw new RuntimeException("Unable to load dependency: " + saveLocation, e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,9 +11,9 @@ import java.util.Map;
|
||||
|
||||
public class Bait implements Item{
|
||||
|
||||
private final String name;
|
||||
private String name;
|
||||
private List<String> lore;
|
||||
private Map<?, ?> nbt;
|
||||
private Map<String,Object> nbt;
|
||||
private HashMap<String, Double> weightMQ;
|
||||
private HashMap<String, Integer> weightPM;
|
||||
private double time;
|
||||
@@ -22,9 +22,10 @@ public class Bait implements Item{
|
||||
private final String material;
|
||||
private List<net.momirealms.customfishing.utils.Enchantment> enchantment;
|
||||
private List<ItemFlag> itemFlags;
|
||||
private int custommodeldata;
|
||||
private boolean unbreakable;
|
||||
|
||||
public Bait(String name, String material) {
|
||||
this.name = name;
|
||||
public Bait(String material) {
|
||||
this.material = material;
|
||||
}
|
||||
|
||||
@@ -35,15 +36,18 @@ public class Bait implements Item{
|
||||
player.getInventory().addItem(itemStack);
|
||||
}
|
||||
|
||||
public void setName(String name) {this.name = name;}
|
||||
public void setItemFlags(List<ItemFlag> itemFlags) {this.itemFlags = itemFlags;}
|
||||
public void setDifficulty(int difficulty) {this.difficulty = difficulty;}
|
||||
public void setNbt(Map<?, ?> nbt) {this.nbt = nbt;}
|
||||
public void setNbt(Map<String,Object> nbt) {this.nbt = nbt;}
|
||||
public void setLore(List<String> lore) {this.lore = lore;}
|
||||
public void setTime(double time) {this.time = time;}
|
||||
public void setWeightMQ(HashMap<String, Double> weightMQ) {this.weightMQ = weightMQ;}
|
||||
public void setWeightPM(HashMap<String, Integer> weightPM) {this.weightPM = weightPM;}
|
||||
public void setDoubleLoot(double doubleLoot) {this.doubleLoot = doubleLoot;}
|
||||
public void setEnchantment(List<net.momirealms.customfishing.utils.Enchantment> enchantment) {this.enchantment = enchantment;}
|
||||
public void setCustommodeldata(int custommodeldata){this.custommodeldata = custommodeldata;}
|
||||
public void setUnbreakable(boolean unbreakable){this.unbreakable = unbreakable;}
|
||||
|
||||
public double getDoubleLoot() {return this.doubleLoot;}
|
||||
public int getDifficulty() {return difficulty;}
|
||||
@@ -51,10 +55,14 @@ public class Bait implements Item{
|
||||
public HashMap<String, Double> getWeightMQ() {return weightMQ;}
|
||||
public HashMap<String, Integer> getWeightPM() {return weightPM;}
|
||||
|
||||
@Override
|
||||
public boolean isUnbreakable() {return this.unbreakable;}
|
||||
@Override
|
||||
public int getCustomModelData() {return this.custommodeldata;}
|
||||
@Override
|
||||
public List<String> getLore() {return lore;}
|
||||
@Override
|
||||
public Map<?, ?> getNbt() {return nbt;}
|
||||
public Map<String,Object> getNbt() {return nbt;}
|
||||
@Override
|
||||
public String getMaterial() {return this.material;}
|
||||
@Override
|
||||
|
||||
@@ -2,7 +2,6 @@ package net.momirealms.customfishing.item;
|
||||
|
||||
import net.momirealms.customfishing.utils.Enchantment;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -13,5 +12,7 @@ public interface Item {
|
||||
List<ItemFlag> getItemFlags();
|
||||
String getName();
|
||||
List<String> getLore();
|
||||
Map<?, ?> getNbt();
|
||||
Map<String,Object> getNbt();
|
||||
int getCustomModelData();
|
||||
boolean isUnbreakable();
|
||||
}
|
||||
|
||||
@@ -13,10 +13,10 @@ import java.util.*;
|
||||
public class Loot implements Item {
|
||||
|
||||
private final String key;
|
||||
private final String name;
|
||||
private String name;
|
||||
private String nick;
|
||||
private List<String> lore;
|
||||
private Map<?, ?> nbt;
|
||||
private Map<String,Object> nbt;
|
||||
private String material;
|
||||
private String msg;
|
||||
private String mm;
|
||||
@@ -33,10 +33,11 @@ public class Loot implements Item {
|
||||
private List<net.momirealms.customfishing.utils.Enchantment> enchantment;
|
||||
private List<ItemFlag> itemFlags;
|
||||
private boolean showInFinder;
|
||||
private int custommodeldata;
|
||||
private boolean unbreakable;
|
||||
|
||||
public Loot(String key, String name, Difficulty difficulty, int weight, int time){
|
||||
public Loot(String key, Difficulty difficulty, int weight, int time){
|
||||
this.key = key;
|
||||
this.name = name;
|
||||
this.difficulty = difficulty;
|
||||
this.weight = weight;
|
||||
this.time = time;
|
||||
@@ -69,11 +70,16 @@ public class Loot implements Item {
|
||||
@Override
|
||||
public List<ItemFlag> getItemFlags() {return this.itemFlags;}
|
||||
@Override
|
||||
public Map<?, ?> getNbt(){return this.nbt;}
|
||||
public Map<String,Object> getNbt(){return this.nbt;}
|
||||
@Override
|
||||
public int getCustomModelData() {return this.custommodeldata;}
|
||||
@Override
|
||||
public boolean isUnbreakable() {return this.unbreakable;}
|
||||
|
||||
public void setName(String name) {this.name = name;}
|
||||
public void setShowInFinder(boolean showInFinder) {this.showInFinder = showInFinder;}
|
||||
public void setLore(List<String> lore){this.lore = lore;}
|
||||
public void setNbt(Map<?, ?> nbt){this.nbt = nbt;}
|
||||
public void setNbt(Map<String,Object> nbt){this.nbt = nbt;}
|
||||
public void setRequirements(List<Requirement> requirements) {this.requirements = requirements;}
|
||||
public void setMaterial(String material){this.material = material;}
|
||||
public void setNick(String nick){this.nick = nick;}
|
||||
@@ -87,6 +93,8 @@ public class Loot implements Item {
|
||||
public void setExp(int exp) {this.exp = exp;}
|
||||
public void setItemFlags(List<ItemFlag> itemFlags) {this.itemFlags = itemFlags;}
|
||||
public void setEnchantment(List<net.momirealms.customfishing.utils.Enchantment> enchantment) {this.enchantment = enchantment;}
|
||||
public void setCustommodeldata(int custommodeldata){this.custommodeldata = custommodeldata;}
|
||||
public void setUnbreakable(boolean unbreakable){this.unbreakable = unbreakable;}
|
||||
|
||||
public static void givePlayerLoot(Player player, String lootKey, int amount){
|
||||
ItemStack itemStack = ConfigReader.LOOTITEM.get(lootKey);
|
||||
|
||||
@@ -12,9 +12,9 @@ import java.util.Map;
|
||||
|
||||
public class Rod implements Item{
|
||||
|
||||
private final String name;
|
||||
private String name;
|
||||
private List<String> lore;
|
||||
private Map<?, ?> nbt;
|
||||
private Map<String,Object> nbt;
|
||||
private HashMap<String, Double> weightMQ;
|
||||
private HashMap<String, Integer> weightPM;
|
||||
private double time;
|
||||
@@ -22,10 +22,8 @@ public class Rod implements Item{
|
||||
private double doubleLoot;
|
||||
private List<net.momirealms.customfishing.utils.Enchantment> enchantment;
|
||||
private List<ItemFlag> itemFlags;
|
||||
|
||||
public Rod(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
private int custommodeldata;
|
||||
private boolean unbreakable;
|
||||
|
||||
public static void givePlayerRod(Player player, String rodKey, int amount){
|
||||
ItemStack itemStack = ConfigReader.RODITEM.get(rodKey);
|
||||
@@ -35,18 +33,29 @@ public class Rod implements Item{
|
||||
|
||||
public void setDifficulty(int difficulty) {this.difficulty = difficulty;}
|
||||
public void setDoubleLoot(double doubleLoot) {this.doubleLoot = doubleLoot;}
|
||||
public void setNbt(Map<?, ?> nbt) {this.nbt = nbt;}
|
||||
public void setNbt(Map<String,Object> nbt) {this.nbt = nbt;}
|
||||
public void setLore(List<String> lore) {this.lore = lore;}
|
||||
public void setEnchantment(List<net.momirealms.customfishing.utils.Enchantment> enchantment) {this.enchantment = enchantment;}
|
||||
public void setItemFlags(List<ItemFlag> itemFlags) {this.itemFlags = itemFlags;}
|
||||
public void setTime(double time) {this.time = time;}
|
||||
public void setWeightMQ(HashMap<String, Double> weightMQ) {this.weightMQ = weightMQ;}
|
||||
public void setWeightPM(HashMap<String, Integer> weightPM) {this.weightPM = weightPM;}
|
||||
public void setCustommodeldata(int custommodeldata){this.custommodeldata = custommodeldata;}
|
||||
public void setUnbreakable(boolean unbreakable){this.unbreakable = unbreakable;}
|
||||
public void setName(String name) {this.name = name;}
|
||||
|
||||
public double getTime() {return time;}
|
||||
public HashMap<String, Double> getWeightMQ() {return weightMQ;}
|
||||
public HashMap<String, Integer> getWeightPM() {return weightPM;}
|
||||
public int getDifficulty() {return difficulty;}
|
||||
public double getDoubleLoot() {return this.doubleLoot;}
|
||||
|
||||
@Override
|
||||
public Map<?, ?> getNbt() {return nbt;}
|
||||
public boolean isUnbreakable() {return this.unbreakable;}
|
||||
@Override
|
||||
public Map<String,Object> getNbt() {return nbt;}
|
||||
@Override
|
||||
public int getCustomModelData() {return this.custommodeldata;}
|
||||
@Override
|
||||
public String getMaterial() {return "fishing_rod";}
|
||||
@Override
|
||||
@@ -57,8 +66,4 @@ public class Rod implements Item{
|
||||
public String getName() {return this.name;}
|
||||
@Override
|
||||
public List<String> getLore() {return this.lore;}
|
||||
|
||||
public double getTime() {return time;}
|
||||
public HashMap<String, Double> getWeightMQ() {return weightMQ;}
|
||||
public HashMap<String, Integer> getWeightPM() {return weightPM;}
|
||||
}
|
||||
|
||||
@@ -11,24 +11,40 @@ import java.util.Map;
|
||||
|
||||
public class Util implements Item{
|
||||
|
||||
private final String key;
|
||||
private final String name;
|
||||
private String name;
|
||||
private List<String> lore;
|
||||
private Map<?, ?> nbt;
|
||||
private Map<String,Object> nbt;
|
||||
private final String material;
|
||||
private List<net.momirealms.customfishing.utils.Enchantment> enchantment;
|
||||
private List<ItemFlag> itemFlags;
|
||||
private int custommodeldata;
|
||||
private boolean unbreakable;
|
||||
|
||||
public Util(String key, String name, String material){
|
||||
this.key = key;
|
||||
this.name = name;
|
||||
public Util(String material){
|
||||
this.material = material;
|
||||
}
|
||||
|
||||
public String getKey(){return this.key;}
|
||||
public List<String> getLore(){return this.lore;}
|
||||
public String getMaterial(){return this.material;}
|
||||
public static void givePlayerUtil(Player player, String utilKey, int amount){
|
||||
ItemStack itemStack = ConfigReader.UTILITEM.get(utilKey);
|
||||
if (itemStack == null) return;
|
||||
itemStack.setAmount(amount);
|
||||
player.getInventory().addItem(itemStack);
|
||||
}
|
||||
|
||||
public void setLore(List<String> lore){this.lore = lore;}
|
||||
public void setNbt(Map<String,Object> nbt){this.nbt = nbt;}
|
||||
public void setEnchantment(List<net.momirealms.customfishing.utils.Enchantment> enchantment) {this.enchantment = enchantment;}
|
||||
public void setItemFlags(List<ItemFlag> itemFlags) {this.itemFlags = itemFlags;}
|
||||
public void setCustommodeldata(int custommodeldata){this.custommodeldata = custommodeldata;}
|
||||
public void setUnbreakable(boolean unbreakable){this.unbreakable = unbreakable;}
|
||||
public void setName(String name) {this.name = name;}
|
||||
|
||||
@Override
|
||||
public boolean isUnbreakable() {return this.unbreakable;}
|
||||
@Override
|
||||
public List<String> getLore(){return this.lore;}
|
||||
@Override
|
||||
public String getMaterial(){return this.material;}
|
||||
@Override
|
||||
public String getName(){return this.name;}
|
||||
@Override
|
||||
@@ -36,16 +52,7 @@ public class Util implements Item{
|
||||
@Override
|
||||
public List<ItemFlag> getItemFlags() {return this.itemFlags;}
|
||||
@Override
|
||||
public Map<?, ?> getNbt(){return this.nbt;}
|
||||
|
||||
public void setLore(List<String> lore){this.lore = lore;}
|
||||
public void setNbt(Map<?, ?> nbt){this.nbt = nbt;}
|
||||
public void setEnchantment(List<net.momirealms.customfishing.utils.Enchantment> enchantment) {this.enchantment = enchantment;}
|
||||
public void setItemFlags(List<ItemFlag> itemFlags) {this.itemFlags = itemFlags;}
|
||||
|
||||
public static void givePlayerUtil(Player player, String utilKey, int amount){
|
||||
ItemStack itemStack = ConfigReader.UTILITEM.get(utilKey);
|
||||
itemStack.setAmount(amount);
|
||||
player.getInventory().addItem(itemStack);
|
||||
}
|
||||
public Map<String,Object> getNbt(){return this.nbt;}
|
||||
@Override
|
||||
public int getCustomModelData() {return this.custommodeldata;}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,12 @@ public class ItemStackGenerator {
|
||||
|
||||
ItemStack itemStack = new ItemStack(Material.valueOf(item.getMaterial().toUpperCase()));
|
||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||
if (item.getCustomModelData() != 0){
|
||||
itemMeta.setCustomModelData(item.getCustomModelData());
|
||||
}
|
||||
if (item.isUnbreakable()){
|
||||
itemMeta.setUnbreakable(true);
|
||||
}
|
||||
if (item.getItemFlags() != null){
|
||||
item.getItemFlags().forEach(itemMeta::addItemFlags);
|
||||
}
|
||||
@@ -41,8 +47,8 @@ public class ItemStackGenerator {
|
||||
}
|
||||
|
||||
NBTItem nbtItem = new NBTItem(itemStack);
|
||||
|
||||
NBTCompound display = nbtItem.addCompound("display");
|
||||
if (item.getName() != null){
|
||||
String name = item.getName();
|
||||
if (name.contains("&") || name.contains("§")){
|
||||
name = name.replaceAll("&","§");
|
||||
@@ -50,7 +56,7 @@ public class ItemStackGenerator {
|
||||
}else {
|
||||
display.setString("Name", GsonComponentSerializer.gson().serialize(MiniMessage.miniMessage().deserialize("<italic:false>" + name)));
|
||||
}
|
||||
|
||||
}
|
||||
if(item.getLore() != null){
|
||||
List<String> lore = display.getStringList("Lore");
|
||||
item.getLore().forEach(line -> {
|
||||
@@ -62,7 +68,6 @@ public class ItemStackGenerator {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (item.getNbt() != null){
|
||||
NBTUtil nbtUtil = new NBTUtil(item.getNbt(), nbtItem.getItem());
|
||||
return nbtUtil.getNBTItem().getItem();
|
||||
|
||||
@@ -2,17 +2,18 @@ package net.momirealms.customfishing.utils;
|
||||
|
||||
import de.tr7zw.changeme.nbtapi.NBTCompound;
|
||||
import de.tr7zw.changeme.nbtapi.NBTItem;
|
||||
import net.momirealms.customfishing.AdventureManager;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
|
||||
public class NBTUtil {
|
||||
|
||||
private final Map<?,?> nbt;
|
||||
private final Map<String,Object> nbt;
|
||||
private final NBTItem nbtItem;
|
||||
|
||||
public NBTUtil(Map<?,?> nbt, ItemStack itemStack){
|
||||
public NBTUtil(Map<String,Object> nbt, ItemStack itemStack){
|
||||
this.nbt = nbt;
|
||||
this.nbtItem = new NBTItem(itemStack);
|
||||
}
|
||||
@@ -26,30 +27,43 @@ public class NBTUtil {
|
||||
}
|
||||
|
||||
public NBTItem getNBTItem(){
|
||||
nbt.keySet().forEach(key -> {
|
||||
if (nbt.get(key) instanceof Map<?,?> map){
|
||||
nbtItem.addCompound((String) key);
|
||||
setTags(map, nbtItem.getCompound((String) key));
|
||||
}else {
|
||||
setNbt(nbtItem, (String) key, nbt.get(key));
|
||||
}
|
||||
});
|
||||
setTags(nbt, nbtItem);
|
||||
return this.nbtItem;
|
||||
}
|
||||
|
||||
private void setTags(Map<?,?> map, NBTCompound nbtCompound){
|
||||
private NBTCompound setTags(Map<String,Object> map, NBTCompound nbtCompound){
|
||||
map.keySet().forEach(key -> {
|
||||
if (map.get(key) instanceof Map map2){
|
||||
nbtCompound.addCompound((String) key);
|
||||
setTags(map2, nbtCompound.getCompound((String) key));
|
||||
}else {
|
||||
setNbt(nbtCompound, (String) key, map.get(key));
|
||||
nbtCompound.addCompound(key);
|
||||
setTags(map2, nbtCompound.getCompound(key));
|
||||
}
|
||||
});
|
||||
else if(map.get(key) instanceof List list){
|
||||
for (Object o : list) {
|
||||
if (o instanceof String s) {
|
||||
if (s.startsWith("(String) ")) {
|
||||
nbtCompound.getStringList(key).add(s.substring(9));
|
||||
} else if (s.startsWith("(UUID) ")) {
|
||||
nbtCompound.getUUIDList(key).add(UUID.fromString(s.substring(7)));
|
||||
} else if (s.startsWith("(Double) ")) {
|
||||
nbtCompound.getDoubleList(key).add(Double.valueOf(s.substring(9)));
|
||||
} else if (s.startsWith("(Long) ")) {
|
||||
nbtCompound.getLongList(key).add(Long.valueOf(s.substring(7)));
|
||||
} else if (s.startsWith("(Float) ")) {
|
||||
nbtCompound.getFloatList(key).add(Float.valueOf(s.substring(8)));
|
||||
} else if (s.startsWith("(Int) ")) {
|
||||
nbtCompound.getIntegerList(key).add(Integer.valueOf(s.substring(6)));
|
||||
} else if (s.startsWith("(IntArray) ")){
|
||||
String[] split = s.substring(11).replace("[","").replace("]","").replaceAll("\\s", "").split(",");
|
||||
int[] array = Arrays.asList(split).stream().mapToInt(Integer::parseInt).toArray();
|
||||
nbtCompound.getIntArrayList(key).add(array);
|
||||
}
|
||||
|
||||
private void setNbt(NBTCompound nbtCompound, String key, Object value){
|
||||
if (value instanceof String string){
|
||||
} else if (o instanceof Map map1) {
|
||||
setTags(map1, nbtCompound.getCompoundList(key).addCompound());
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (map.get(key) instanceof String string){
|
||||
if (string.startsWith("(Int) ")){
|
||||
nbtCompound.setInteger(key, Integer.valueOf(string.substring(6)));
|
||||
}else if (string.startsWith("(String) ")){
|
||||
@@ -68,16 +82,21 @@ public class NBTUtil {
|
||||
nbtCompound.setUUID(key, UUID.fromString(string.substring(7)));
|
||||
}else if (string.startsWith("(Byte) ")){
|
||||
nbtCompound.setByte(key, Byte.valueOf(string.substring(7)));
|
||||
}else {
|
||||
nbtCompound.setString(key, string);
|
||||
}else if (string.startsWith("(ByteArray) ")){
|
||||
String[] split = string.substring(12).replace("[","").replace("]","").replaceAll("\\s", "").split(",");
|
||||
byte[] bytes = new byte[split.length];
|
||||
for (int i = 0; i < split.length; i++){
|
||||
bytes[i] = Byte.parseByte(split[i]);
|
||||
}
|
||||
}else {
|
||||
try {
|
||||
nbtCompound.setInteger(key, (Integer) value);
|
||||
}catch (ClassCastException e){
|
||||
e.printStackTrace();
|
||||
AdventureManager.consoleMessage("<red>[CustomFishing] 非Int类型数字必须加上强制转换标识!</red>");
|
||||
nbtCompound.setByteArray(key, bytes);
|
||||
}else if (string.startsWith("(IntArray) ")){
|
||||
String[] split = string.substring(11).replace("[","").replace("]","").replaceAll("\\s", "").split(",");
|
||||
int[] array = Arrays.asList(split).stream().mapToInt(Integer::parseInt).toArray();
|
||||
nbtCompound.setIntArray(key, array);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
return nbtCompound;
|
||||
}
|
||||
}
|
||||
130
src/main/java/net/momirealms/customfishing/utils/SaveItem.java
Normal file
130
src/main/java/net/momirealms/customfishing/utils/SaveItem.java
Normal file
@@ -0,0 +1,130 @@
|
||||
package net.momirealms.customfishing.utils;
|
||||
|
||||
import de.tr7zw.changeme.nbtapi.NBTCompound;
|
||||
import de.tr7zw.changeme.nbtapi.NBTItem;
|
||||
import net.momirealms.customfishing.CustomFishing;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
public class SaveItem {
|
||||
|
||||
public static void saveToFile(ItemStack itemStack, String fileName){
|
||||
|
||||
if (itemStack == null || itemStack.getType() == Material.AIR) return;
|
||||
|
||||
YamlConfiguration yamlConfiguration = new YamlConfiguration();
|
||||
|
||||
yamlConfiguration.set(fileName + ".material", itemStack.getType().toString());
|
||||
|
||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||
if (itemMeta.hasDisplayName()){
|
||||
yamlConfiguration.set(fileName + ".display.name", itemMeta.getDisplayName());
|
||||
}
|
||||
if (itemMeta.hasLore()){
|
||||
yamlConfiguration.set(fileName + ".display.lore", itemMeta.getLore());
|
||||
}
|
||||
if (itemMeta.hasCustomModelData()) {
|
||||
yamlConfiguration.set(fileName + ".custom-model-data", itemMeta.getCustomModelData());
|
||||
}
|
||||
if (itemMeta.isUnbreakable()) {
|
||||
yamlConfiguration.set(fileName + ".unbreakable", itemMeta.isUnbreakable());
|
||||
}
|
||||
if (itemMeta.hasEnchants()) {
|
||||
ArrayList<String> enchants = new ArrayList<>();
|
||||
itemMeta.getEnchants().forEach((enchantment, level) -> {
|
||||
enchants.add(enchantment.getKey() + "/" + level);
|
||||
});
|
||||
yamlConfiguration.set(fileName + ".enchantments", enchants);
|
||||
}
|
||||
if (itemMeta.getItemFlags().size() > 0){
|
||||
ArrayList<String> itemFlags = new ArrayList<>();
|
||||
itemStack.getItemFlags().forEach(itemFlag -> {
|
||||
itemFlags.add(itemFlag.name());
|
||||
});
|
||||
yamlConfiguration.set(fileName + ".item_flags", itemFlags);
|
||||
}
|
||||
|
||||
NBTItem nbtItem = new NBTItem(itemStack);
|
||||
|
||||
Map<String, Object> map0 = compoundToMap(nbtItem);
|
||||
if (map0.size() != 0){
|
||||
ArrayList<Map<String, Object>> mapArrayList = new ArrayList<>();
|
||||
mapArrayList.add(map0);
|
||||
yamlConfiguration.set(fileName + ".nbt", mapArrayList);
|
||||
}
|
||||
|
||||
File file = new File(CustomFishing.instance.getDataFolder(), File.separator + "export" + File.separator + fileName + ".yml");
|
||||
|
||||
try {
|
||||
yamlConfiguration.save(file);
|
||||
}catch (IOException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static Map<String, Object> compoundToMap(NBTCompound nbtCompound){
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
nbtCompound.getKeys().forEach(key -> {
|
||||
if (key.equals("Enchantments")) return;
|
||||
if (key.equals("Name")) return;
|
||||
if (key.equals("Lore")) return;
|
||||
if (key.equals("HideFlags")) return;
|
||||
if (key.equals("CustomModelData")) return;
|
||||
if (key.equals("Unbreakable")) return;
|
||||
switch (nbtCompound.getType(key)){
|
||||
case NBTTagByte -> map.put(key, "(Byte) " + nbtCompound.getByte(key));
|
||||
case NBTTagInt -> map.put(key, "(Int) " + nbtCompound.getInteger(key));
|
||||
case NBTTagDouble -> map.put(key, "(Double) " + nbtCompound.getDouble(key));
|
||||
case NBTTagLong -> map.put(key, "(Long) " + nbtCompound.getLong(key));
|
||||
case NBTTagFloat -> map.put(key, "(Float) " + nbtCompound.getFloat(key));
|
||||
case NBTTagShort -> map.put(key, "(Short) " + nbtCompound.getShort(key));
|
||||
case NBTTagString -> map.put(key, "(String) " + nbtCompound.getString(key));
|
||||
case NBTTagByteArray -> map.put(key, "(ByteArray) " + Arrays.toString(nbtCompound.getByteArray(key)));
|
||||
case NBTTagIntArray -> map.put(key, "(IntArray) " + Arrays.toString(nbtCompound.getIntArray(key)));
|
||||
case NBTTagCompound -> {
|
||||
Map<String, Object> map1 = compoundToMap(nbtCompound.getCompound(key));
|
||||
if (map1.size() != 0){
|
||||
map.put(key, map1);
|
||||
}
|
||||
}
|
||||
case NBTTagList -> {
|
||||
List<Object> list = new ArrayList<>();
|
||||
switch (nbtCompound.getListType(key)){
|
||||
case NBTTagInt -> nbtCompound.getIntegerList(key).forEach(a -> {
|
||||
list.add("(Int) " + a);
|
||||
});
|
||||
case NBTTagDouble -> nbtCompound.getDoubleList(key).forEach(a -> {
|
||||
list.add("(Double) " + a);
|
||||
});
|
||||
case NBTTagString -> nbtCompound.getStringList(key).forEach(a -> {
|
||||
list.add("(String) " + a);
|
||||
});
|
||||
case NBTTagCompound -> nbtCompound.getCompoundList(key).forEach(a -> {
|
||||
list.add(compoundToMap(a));
|
||||
});
|
||||
case NBTTagFloat -> nbtCompound.getFloatList(key).forEach(a -> {
|
||||
list.add("(Float) " + a);
|
||||
});
|
||||
case NBTTagLong -> nbtCompound.getLongList(key).forEach(a -> {
|
||||
list.add("(Long) " + a);
|
||||
});
|
||||
case NBTTagIntArray -> nbtCompound.getIntArrayList(key).forEach(a -> {
|
||||
list.add("(IntArray) " + Arrays.toString(a));
|
||||
});
|
||||
default -> nbtCompound.getUUIDList(key).forEach(a -> {
|
||||
list.add("(UUID) " + a);
|
||||
});
|
||||
}
|
||||
map.put(key, list);
|
||||
}
|
||||
}
|
||||
});
|
||||
return map;
|
||||
}
|
||||
}
|
||||
@@ -6,8 +6,7 @@ baits:
|
||||
lore:
|
||||
- '<white>减少捕鱼的时间'
|
||||
- '<white>但是加大捕鱼的难度'
|
||||
nbt:
|
||||
- CustomModelData: '(Int) 1'
|
||||
custom-model-data: 1
|
||||
#钓饵增益
|
||||
modifier:
|
||||
#改变指定组的loot权重
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
#https://docs.adventure.kyori.net/minimessage/format.html
|
||||
|
||||
items:
|
||||
#最基本的物品需要填写如下项目
|
||||
rubbish:
|
||||
material: paper
|
||||
display:
|
||||
@@ -24,13 +23,14 @@ items:
|
||||
lore:
|
||||
- '<gray>This is a <font:uniform>rainbow fish!'
|
||||
- '<gray> 这是一条七色彩虹鱼'
|
||||
|
||||
custom-model-data: 1
|
||||
#自定义NBT
|
||||
#可类型(Int) (Byte) (String) (Float) (String) (Double) (Short) (Long) (UUID) (Boolean)
|
||||
nbt:
|
||||
- itemsadder:
|
||||
namespace: '(String) momirealms'
|
||||
id: '(String) rainbow_fish'
|
||||
CustomModelData: '(Int) 1'
|
||||
SomeNBT:
|
||||
NBTS:
|
||||
byte: '(Byte) 127'
|
||||
|
||||
@@ -4,8 +4,7 @@ rods:
|
||||
name: '普通的木鱼竿'
|
||||
lore:
|
||||
- '就是一把普通的鱼竿而已啦'
|
||||
nbt:
|
||||
- CustomModelData: '(Int) 1'
|
||||
custom-model-data: 1
|
||||
#鱼竿增益
|
||||
modifier:
|
||||
#改变指定组的loot权重
|
||||
|
||||
@@ -5,5 +5,4 @@ utils:
|
||||
name: '找鱼器'
|
||||
lore:
|
||||
- '右键查看这个地方能钓到什么鱼吧!'
|
||||
nbt:
|
||||
- CustomModelData: '(Int) 1'
|
||||
custom-model-data: 1
|
||||
Reference in New Issue
Block a user