@@ -106,6 +106,7 @@ public final class EnderDragon extends JavaPlugin {
|
|||||||
finish = true;
|
finish = true;
|
||||||
}
|
}
|
||||||
public static void reloadAll(){
|
public static void reloadAll(){
|
||||||
|
ItemManager.getLegacy().set(false);
|
||||||
WorldManager.reload();
|
WorldManager.reload();
|
||||||
GlowManager.reload();
|
GlowManager.reload();
|
||||||
EnderDragon.getInstance().loadFiles();
|
EnderDragon.getInstance().loadFiles();
|
||||||
@@ -128,6 +129,12 @@ public final class EnderDragon extends JavaPlugin {
|
|||||||
this.cancel();
|
this.cancel();
|
||||||
DragonManager.reload();
|
DragonManager.reload();
|
||||||
GuiManager.loadGui();
|
GuiManager.loadGui();
|
||||||
|
if (ItemManager.getLegacy().get()){
|
||||||
|
Lang.error("I'm sorry that data_type 'nbt' and 'advanced' probably will be disabled in 1.20.5+");
|
||||||
|
Lang.error("It is recommended to migrate item configuration to bukkit format for compatibility.");
|
||||||
|
Lang.error("You can use /ed migrate to generate new config.");
|
||||||
|
}
|
||||||
|
|
||||||
runnable.runTaskTimer(plugin,0,1);
|
runnable.runTaskTimer(plugin,0,1);
|
||||||
}
|
}
|
||||||
}.runTaskTimer(plugin, 1, 5);
|
}.runTaskTimer(plugin, 1, 5);
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package pers.xanadu.enderdragon.config;
|
package pers.xanadu.enderdragon.config;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.configuration.InvalidConfigurationException;
|
import org.bukkit.configuration.InvalidConfigurationException;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
@@ -130,45 +131,113 @@ public class FileUpdater {
|
|||||||
// Lang.warn("Attention: Please confirm the accuracy before using new config!");
|
// Lang.warn("Attention: Please confirm the accuracy before using new config!");
|
||||||
}
|
}
|
||||||
public static void migrate(){
|
public static void migrate(){
|
||||||
File folder = new File(plugin.getDataFolder(),"reward");
|
boolean b1 = handleRewards();
|
||||||
if (folder.exists()){
|
boolean b2 = handleGuiItems();
|
||||||
File[] files = folder.listFiles(f -> f.getName().endsWith(".yml"));
|
if (b1 || b2) Lang.info("New reward configuration files are generated in plugins/EnderDragon/migrate.");
|
||||||
if (files == null || files.length == 0) {
|
|
||||||
Lang.warn("No files need to be migrated!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
for (File file : files){
|
|
||||||
FileConfiguration config = YamlConfiguration.loadConfiguration(file);
|
|
||||||
Config.copyFile(file,"new/reward/"+file.getName(),true);
|
|
||||||
File gen_file = new File(plugin.getDataFolder(),"new/reward/"+file.getName());
|
|
||||||
YamlConfiguration new_cfg = YamlConfiguration.loadConfiguration(gen_file);
|
|
||||||
if(Config.advanced_setting_backslash_split_reward) new_cfg.options().pathSeparator('\\');
|
|
||||||
List<String> gen = new ArrayList<>();
|
|
||||||
List<String> list = config.getStringList("list");
|
|
||||||
for(String str : list){
|
|
||||||
YamlConfiguration yml = new YamlConfiguration();
|
|
||||||
if(Config.advanced_setting_backslash_split_reward) yml.options().pathSeparator('\\');
|
|
||||||
try{
|
|
||||||
yml.loadFromString(str);
|
|
||||||
Reward reward = ItemManager.readAsReward(yml);
|
|
||||||
if (reward == null) continue;
|
|
||||||
gen.add(saveReward(reward));
|
|
||||||
}catch (InvalidConfigurationException e){
|
|
||||||
Lang.error(Lang.plugin_item_read_error + str);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
new_cfg.set("list",gen);
|
|
||||||
try{
|
|
||||||
new_cfg.save(gen_file);
|
|
||||||
}catch (IOException e){
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Lang.info("New reward config files are generated in plugins/EnderDragon/migrate.");
|
|
||||||
}
|
|
||||||
else Lang.warn("No files need to be migrated!");
|
else Lang.warn("No files need to be migrated!");
|
||||||
}
|
}
|
||||||
public static String saveReward(Reward reward){
|
private static boolean handleGuiItems(){
|
||||||
|
File folder = new File(plugin.getDataFolder(),"gui");
|
||||||
|
if (!folder.exists()) return false;
|
||||||
|
File[] files = folder.listFiles(f -> f.getName().endsWith(".yml"));
|
||||||
|
if (files == null || files.length == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
for (File file : files){
|
||||||
|
Config.copyFile(file,"new/gui/"+file.getName(),true);
|
||||||
|
File gen_file = new File(plugin.getDataFolder(),"new/gui/"+file.getName());
|
||||||
|
YamlConfiguration cfg = YamlConfiguration.loadConfiguration(gen_file);
|
||||||
|
cfg.getKeys(false).forEach(key->{
|
||||||
|
ConfigurationSection gui = cfg.getConfigurationSection(key);
|
||||||
|
if (gui == null) return;
|
||||||
|
ConfigurationSection Items = gui.getConfigurationSection("Items");
|
||||||
|
if (Items == null) return;
|
||||||
|
Items.getKeys(false).forEach(ch -> {
|
||||||
|
ConfigurationSection slot = Items.getConfigurationSection(ch);
|
||||||
|
if (slot == null) return;
|
||||||
|
if (!slot.contains("data")) return;
|
||||||
|
ItemStack itemStack = readItemStack(slot,"data");
|
||||||
|
ItemManager.save2section_simple(itemStack,slot,"data");
|
||||||
|
if (!slot.contains("data_disable")) return;
|
||||||
|
itemStack = readItemStack(slot,"data_disable");
|
||||||
|
ItemManager.save2section_simple(itemStack,slot,"data_disable");
|
||||||
|
});
|
||||||
|
Items.getKeys(false).forEach(ch -> {
|
||||||
|
ConfigurationSection slot = Items.getConfigurationSection(ch);
|
||||||
|
if (slot == null) return;
|
||||||
|
if (slot.contains("data_type")){
|
||||||
|
slot.set("data_type","simple");
|
||||||
|
}
|
||||||
|
else if (slot.contains("data") || slot.contains("data_disable")) {
|
||||||
|
slot.set("data_type","simple");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
try{
|
||||||
|
cfg.save(gen_file);
|
||||||
|
}catch (IOException e){
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
private static ItemStack readItemStack(ConfigurationSection section,final String path){
|
||||||
|
ItemStack itemStack;
|
||||||
|
final String type = section.getString("data_type","");
|
||||||
|
switch (type){
|
||||||
|
case "nbt":
|
||||||
|
itemStack = ItemManager.readFromNBT(section,path);
|
||||||
|
ItemManager.getLegacy().compareAndSet(false,true);
|
||||||
|
break;
|
||||||
|
case "advanced":
|
||||||
|
itemStack = ItemManager.readFromAdvData(section,path);
|
||||||
|
ItemManager.getLegacy().compareAndSet(false,true);
|
||||||
|
break;
|
||||||
|
case "simple":
|
||||||
|
itemStack = ItemManager.readFromSimple(section,path);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
itemStack = ItemManager.readFromBukkit(section,path);
|
||||||
|
}
|
||||||
|
return itemStack;
|
||||||
|
}
|
||||||
|
private static boolean handleRewards(){
|
||||||
|
File folder = new File(plugin.getDataFolder(),"reward");
|
||||||
|
if (!folder.exists()) return false;
|
||||||
|
File[] files = folder.listFiles(f -> f.getName().endsWith(".yml"));
|
||||||
|
if (files == null || files.length == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
for (File file : files){
|
||||||
|
FileConfiguration config = YamlConfiguration.loadConfiguration(file);
|
||||||
|
Config.copyFile(file,"new/reward/"+file.getName(),true);
|
||||||
|
File gen_file = new File(plugin.getDataFolder(),"new/reward/"+file.getName());
|
||||||
|
YamlConfiguration new_cfg = YamlConfiguration.loadConfiguration(gen_file);
|
||||||
|
if(Config.advanced_setting_backslash_split_reward) new_cfg.options().pathSeparator('\\');
|
||||||
|
List<String> gen = new ArrayList<>();
|
||||||
|
List<String> list = config.getStringList("list");
|
||||||
|
for(String str : list){
|
||||||
|
YamlConfiguration yml = new YamlConfiguration();
|
||||||
|
if(Config.advanced_setting_backslash_split_reward) yml.options().pathSeparator('\\');
|
||||||
|
try{
|
||||||
|
yml.loadFromString(str);
|
||||||
|
Reward reward = ItemManager.readAsReward(yml);
|
||||||
|
if (reward == null) continue;
|
||||||
|
gen.add(saveReward(reward));
|
||||||
|
}catch (InvalidConfigurationException e){
|
||||||
|
Lang.error(Lang.plugin_item_read_error + str);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
new_cfg.set("list",gen);
|
||||||
|
try{
|
||||||
|
new_cfg.save(gen_file);
|
||||||
|
}catch (IOException e){
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
private static String saveReward(Reward reward){
|
||||||
Chance chance = reward.getChance();
|
Chance chance = reward.getChance();
|
||||||
ItemStack item = reward.getItem();
|
ItemStack item = reward.getItem();
|
||||||
double value = chance.getValue();
|
double value = chance.getValue();
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ public class GUI {
|
|||||||
this.page = a;
|
this.page = a;
|
||||||
for(int i=0;i<this.slots.size();i++){
|
for(int i=0;i<this.slots.size();i++){
|
||||||
GUISlot slot = this.slots.get(i);
|
GUISlot slot = this.slots.get(i);
|
||||||
if (slot instanceof ItemSlot) {
|
if (slot instanceof ItemSlot || slot instanceof DragonSlot) {
|
||||||
this.inv.setItem(i, new ItemStack(Material.AIR));
|
this.inv.setItem(i, new ItemStack(Material.AIR));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,6 +38,23 @@ public abstract class GUISlot {
|
|||||||
return new EmptySlot();
|
return new EmptySlot();
|
||||||
}
|
}
|
||||||
protected enum DataType{
|
protected enum DataType{
|
||||||
DEFAULT,NBT,ADVANCED
|
DEFAULT,NBT,ADVANCED,SIMPLE;
|
||||||
|
public static DataType fromString(String data_type){
|
||||||
|
if (data_type == null) return DEFAULT;
|
||||||
|
switch (data_type){
|
||||||
|
case "nbt": {
|
||||||
|
return NBT;
|
||||||
|
}
|
||||||
|
case "advanced": {
|
||||||
|
return ADVANCED;
|
||||||
|
}
|
||||||
|
case "simple": {
|
||||||
|
return SIMPLE;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
return DEFAULT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,11 +6,12 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
import pers.xanadu.enderdragon.gui.GUISlot;
|
import pers.xanadu.enderdragon.gui.GUISlot;
|
||||||
import pers.xanadu.enderdragon.gui.GUISlotType;
|
import pers.xanadu.enderdragon.gui.GUISlotType;
|
||||||
|
import pers.xanadu.enderdragon.manager.ItemManager;
|
||||||
|
|
||||||
import static pers.xanadu.enderdragon.manager.ItemManager.*;
|
import static pers.xanadu.enderdragon.manager.ItemManager.*;
|
||||||
|
|
||||||
public class TipSlot extends GUISlot {
|
public class TipSlot extends GUISlot {
|
||||||
private ItemStack item;
|
private final ItemStack item;
|
||||||
protected boolean hasDisableMode;
|
protected boolean hasDisableMode;
|
||||||
protected ItemStack itemOnDisable;
|
protected ItemStack itemOnDisable;
|
||||||
|
|
||||||
@@ -18,6 +19,7 @@ public class TipSlot extends GUISlot {
|
|||||||
super(slotType);
|
super(slotType);
|
||||||
this.item = new ItemStack(material);
|
this.item = new ItemStack(material);
|
||||||
ItemMeta meta = this.item.getItemMeta();
|
ItemMeta meta = this.item.getItemMeta();
|
||||||
|
assert meta != null;
|
||||||
meta.setDisplayName(str);
|
meta.setDisplayName(str);
|
||||||
this.item.setItemMeta(meta);
|
this.item.setItemMeta(meta);
|
||||||
}
|
}
|
||||||
@@ -28,22 +30,25 @@ public class TipSlot extends GUISlot {
|
|||||||
this.hasDisableMode = true;
|
this.hasDisableMode = true;
|
||||||
}
|
}
|
||||||
else this.hasDisableMode = false;
|
else this.hasDisableMode = false;
|
||||||
if(hasDisableMode){
|
this.data_type = DataType.fromString(section.getString("data_type"));
|
||||||
if(data_type == DataType.NBT) this.itemOnDisable = readFromNBT(section,"data_disable");
|
switch (data_type) {
|
||||||
else this.itemOnDisable = readFromBukkit(section,"data_disable");
|
case NBT:
|
||||||
}
|
ItemManager.getLegacy().compareAndSet(false,true);
|
||||||
String data_type = section.getString("data_type");
|
this.item = readFromNBT(section,"data");
|
||||||
if("nbt".equals(data_type)) {
|
if(hasDisableMode) this.itemOnDisable = readFromNBT(section,"data_disable");
|
||||||
this.data_type = DataType.NBT;
|
break;
|
||||||
this.item = readFromNBT(section,"data");
|
case ADVANCED:
|
||||||
}
|
ItemManager.getLegacy().compareAndSet(false,true);
|
||||||
else if("advanced".equals(data_type)){
|
this.item = readFromAdvData(section,"data");
|
||||||
this.data_type = DataType.ADVANCED;
|
if(hasDisableMode) this.itemOnDisable = readFromAdvData(section,"data_disable");
|
||||||
this.item = readFromAdvData(section,"data");
|
break;
|
||||||
}
|
case SIMPLE:
|
||||||
else {
|
this.item = readFromSimple(section,"data");
|
||||||
this.data_type = DataType.DEFAULT;
|
if(hasDisableMode) this.itemOnDisable = readFromSimple(section,"data_disable");
|
||||||
this.item = readFromBukkit(section,"data");
|
break;
|
||||||
|
default:
|
||||||
|
this.item = readFromBukkit(section,"data");
|
||||||
|
if(hasDisableMode) this.itemOnDisable = readFromBukkit(section,"data_disable");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -54,56 +54,50 @@ public class DragonManager {
|
|||||||
private static final Pattern pattern_attacker_top = Pattern.compile("%attacker_top_(\\d+)%");
|
private static final Pattern pattern_attacker_top = Pattern.compile("%attacker_top_(\\d+)%");
|
||||||
|
|
||||||
public static void reload(){
|
public static void reload(){
|
||||||
new BukkitRunnable(){
|
dragons.clear();
|
||||||
@Override
|
mp.clear();
|
||||||
public void run(){
|
dragon_names.clear();
|
||||||
dragons.clear();
|
sum = 0;
|
||||||
mp.clear();
|
if(Config.dragon_setting_file == null){
|
||||||
dragon_names.clear();
|
Lang.error("\"dragon_setting_file\" in config.yml is empty!");
|
||||||
sum = 0;
|
Lang.warn("Plugin will use the default config...");
|
||||||
if(Config.dragon_setting_file == null){
|
Config.dragon_setting_file = new ArrayList<>();
|
||||||
Lang.error("\"dragon_setting_file\" in config.yml is empty!");
|
Config.dragon_setting_file.add("default:5");
|
||||||
Lang.warn("Plugin will use the default config...");
|
Config.dragon_setting_file.add("special:5");
|
||||||
Config.dragon_setting_file = new ArrayList<>();
|
}
|
||||||
Config.dragon_setting_file.add("default:5");
|
for(String str : Config.dragon_setting_file){
|
||||||
Config.dragon_setting_file.add("special:5");
|
String[] s = str.split(":");
|
||||||
}
|
if(s.length != 2){
|
||||||
for(String str : Config.dragon_setting_file){
|
Lang.error("\"dragon_setting_file\" in config.yml error! Key: " + str);
|
||||||
String[] s = str.split(":");
|
continue;
|
||||||
if(s.length != 2){
|
|
||||||
Lang.error("\"dragon_setting_file\" in config.yml error! Key: " + str);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
String path = "setting/" + s[0] + ".yml";
|
|
||||||
int edge = -1;
|
|
||||||
try {
|
|
||||||
edge = Integer.parseInt(s[1]);
|
|
||||||
} catch (NumberFormatException ignored){}
|
|
||||||
if(edge < 0) {
|
|
||||||
Lang.error("\"dragon_setting_file\" in config.yml error! Key: " + str);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
File file = new File(plugin.getDataFolder(),path);
|
|
||||||
if(!file.exists()) {
|
|
||||||
try{
|
|
||||||
plugin.saveResource("setting/"+file.getName(),false);
|
|
||||||
file = new File(plugin.getDataFolder(),path);
|
|
||||||
}catch (Exception ignored){
|
|
||||||
Lang.error("Not Found setting/" + s[0] + ".yml ,skipped it.");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
FileConfiguration fc = YamlConfiguration.loadConfiguration(file);
|
|
||||||
if(!Version.setting_dragon.equals(fc.getString("version"))){
|
|
||||||
Lang.warn(Lang.plugin_wrong_file_version.replace("{file_name}", file.getName()));
|
|
||||||
}
|
|
||||||
readSettingFile(fc,edge);
|
|
||||||
}
|
|
||||||
dragons.sort((o1, o2) -> o2.priority - o1.priority);
|
|
||||||
RewardManager.reload();
|
|
||||||
}
|
}
|
||||||
}.runTaskAsynchronously(plugin);
|
String path = "setting/" + s[0] + ".yml";
|
||||||
|
int edge = -1;
|
||||||
|
try {
|
||||||
|
edge = Integer.parseInt(s[1]);
|
||||||
|
} catch (NumberFormatException ignored){}
|
||||||
|
if(edge < 0) {
|
||||||
|
Lang.error("\"dragon_setting_file\" in config.yml error! Key: " + str);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
File file = new File(plugin.getDataFolder(),path);
|
||||||
|
if(!file.exists()) {
|
||||||
|
try{
|
||||||
|
plugin.saveResource("setting/"+file.getName(),false);
|
||||||
|
file = new File(plugin.getDataFolder(),path);
|
||||||
|
}catch (Exception ignored){
|
||||||
|
Lang.error("Not Found setting/" + s[0] + ".yml ,skipped it.");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
FileConfiguration fc = YamlConfiguration.loadConfiguration(file);
|
||||||
|
if(!Version.setting_dragon.equals(fc.getString("version"))){
|
||||||
|
Lang.warn(Lang.plugin_wrong_file_version.replace("{file_name}", file.getName()));
|
||||||
|
}
|
||||||
|
readSettingFile(fc,edge);
|
||||||
|
}
|
||||||
|
dragons.sort((o1, o2) -> o2.priority - o1.priority);
|
||||||
|
RewardManager.reload();
|
||||||
}
|
}
|
||||||
public static MyDragon judge(){
|
public static MyDragon judge(){
|
||||||
if(Config.special_dragon_jude_mode.equalsIgnoreCase("weight")){
|
if(Config.special_dragon_jude_mode.equalsIgnoreCase("weight")){
|
||||||
|
|||||||
@@ -17,27 +17,22 @@ import static pers.xanadu.enderdragon.EnderDragon.plugin;
|
|||||||
public class GuiManager {
|
public class GuiManager {
|
||||||
private static HashMap<String, GUIWrapper> f = new HashMap<>();
|
private static HashMap<String, GUIWrapper> f = new HashMap<>();
|
||||||
public static void loadGui(){
|
public static void loadGui(){
|
||||||
new BukkitRunnable(){
|
File folder = new File(plugin.getDataFolder(),"gui");
|
||||||
@Override
|
if(!folder.exists()) return;
|
||||||
public void run(){
|
File[] files = folder.listFiles();
|
||||||
File folder = new File(plugin.getDataFolder(),"gui");
|
if(files == null) return;
|
||||||
if(!folder.exists()) return;
|
for(File file : files){
|
||||||
File[] files = folder.listFiles();
|
if(!file.getName().endsWith(".yml")) continue;
|
||||||
if(files == null) return;
|
Lang.info(Lang.plugin_read_file + file.getName());
|
||||||
for(File file : files){
|
FileConfiguration fileConfiguration = YamlConfiguration.loadConfiguration(file);
|
||||||
if(!file.getName().endsWith(".yml")) continue;
|
Iterator it = fileConfiguration.getKeys(false).iterator();
|
||||||
Lang.info(Lang.plugin_read_file + file.getName());
|
while (it.hasNext()){
|
||||||
FileConfiguration fileConfiguration = YamlConfiguration.loadConfiguration(file);
|
String name = (String) it.next();
|
||||||
Iterator it = fileConfiguration.getKeys(false).iterator();
|
ConfigurationSection section = fileConfiguration.getConfigurationSection(name);
|
||||||
while (it.hasNext()){
|
GUIWrapper guiWrapper = new GUIWrapper(section);
|
||||||
String name = (String) it.next();
|
f.put(name, guiWrapper);
|
||||||
ConfigurationSection section = fileConfiguration.getConfigurationSection(name);
|
|
||||||
GUIWrapper guiWrapper = new GUIWrapper(section);
|
|
||||||
f.put(name, guiWrapper);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}.runTaskAsynchronously(plugin);
|
}
|
||||||
}
|
}
|
||||||
public static void disable(){
|
public static void disable(){
|
||||||
f.clear();
|
f.clear();
|
||||||
|
|||||||
@@ -20,10 +20,11 @@ import pers.xanadu.enderdragon.reward.Chance;
|
|||||||
import pers.xanadu.enderdragon.util.Version;
|
import pers.xanadu.enderdragon.util.Version;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
public class ItemManager {
|
public class ItemManager {
|
||||||
@Getter
|
@Getter
|
||||||
private static boolean legacy = false;
|
private static final AtomicBoolean legacy = new AtomicBoolean(false);
|
||||||
public static String write(Reward reward){
|
public static String write(Reward reward){
|
||||||
Chance chance = reward.getChance();
|
Chance chance = reward.getChance();
|
||||||
return write(reward.getItem(),chance.getValue(),chance.getStr(),reward.getName());
|
return write(reward.getItem(),chance.getValue(),chance.getStr(),reward.getName());
|
||||||
@@ -51,104 +52,12 @@ public class ItemManager {
|
|||||||
}
|
}
|
||||||
case "_advanced" : {
|
case "_advanced" : {
|
||||||
section.set("data_type","advanced");
|
section.set("data_type","advanced");
|
||||||
ConfigurationSection section_data = section.createSection("data");
|
save2section_adv(item,section);
|
||||||
//type
|
break;
|
||||||
String type = item.getType().name();
|
}
|
||||||
section_data.set("type",type);
|
case "simple": {
|
||||||
if("AIR".equals(type)) break;
|
section.set("data_type","simple");
|
||||||
//amount
|
save2section_simple(item,section);
|
||||||
int amount = item.getAmount();
|
|
||||||
section_data.set("amount",amount);
|
|
||||||
//damage
|
|
||||||
int damage = item.getDurability();
|
|
||||||
if(damage != 0) section_data.set("damage",damage);
|
|
||||||
ItemMeta meta = item.getItemMeta();
|
|
||||||
if(meta == null) break;
|
|
||||||
//DisplayName
|
|
||||||
String display_name = meta.getDisplayName();
|
|
||||||
if(!"".equals(display_name)) section_data.set("display_name",display_name);
|
|
||||||
//LocalizedName
|
|
||||||
if(meta.hasLocalizedName()){
|
|
||||||
section_data.set("localized_name",meta.getLocalizedName());
|
|
||||||
}
|
|
||||||
//lore
|
|
||||||
List<String> lores = meta.getLore();
|
|
||||||
if(lores != null) section_data.set("lore",lores);
|
|
||||||
//Enchantments
|
|
||||||
if(meta.hasEnchants()){
|
|
||||||
ConfigurationSection enchants = section_data.createSection("enchants");
|
|
||||||
Map<Enchantment,Integer> mp = meta.getEnchants();
|
|
||||||
mp.forEach((enchantment,level) -> enchants.set(enchantment.getName(),level));
|
|
||||||
}
|
|
||||||
if(Version.mcMainVersion>=14 || "v1_13_R2".equals(Version.getVersion())){
|
|
||||||
//AttributeModifiers
|
|
||||||
if(meta.hasAttributeModifiers()){
|
|
||||||
ConfigurationSection attributes = section_data.createSection("AttributeModifiers");
|
|
||||||
meta.getAttributeModifiers().forEach((attribute,modifier)->{
|
|
||||||
attributes.set(attribute.name(),modifier);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(Version.mcMainVersion>=14){
|
|
||||||
//CustomModelData
|
|
||||||
if(meta.hasCustomModelData()) {
|
|
||||||
section_data.set("CustomModelData",meta.getCustomModelData());//int
|
|
||||||
}
|
|
||||||
//PersistentDataContainer
|
|
||||||
PersistentDataContainer dataContainer = meta.getPersistentDataContainer();
|
|
||||||
if(!dataContainer.isEmpty()){
|
|
||||||
ConfigurationSection dataContainer_section = section_data.createSection("PersistentDataContainer");
|
|
||||||
String cpd = EnderDragon.getInstance().getNMSManager().PDCtoString(dataContainer);
|
|
||||||
dataContainer_section.set("data_type","nbt");
|
|
||||||
dataContainer_section.set("data",cpd);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//RepairCost
|
|
||||||
if(meta instanceof Repairable){
|
|
||||||
Repairable repairable = (Repairable) meta;
|
|
||||||
section_data.set("RepairCost",repairable.getRepairCost());
|
|
||||||
}
|
|
||||||
//ItemFlags
|
|
||||||
Set<ItemFlag> flags = meta.getItemFlags();
|
|
||||||
if(!flags.isEmpty()){
|
|
||||||
List<String> list = new ArrayList<>();
|
|
||||||
flags.forEach(flag ->{
|
|
||||||
list.add(flag.name());
|
|
||||||
});
|
|
||||||
section_data.set("ItemFlags",list);
|
|
||||||
}
|
|
||||||
//Unbreakable
|
|
||||||
section_data.set("unbreakable",meta.isUnbreakable());
|
|
||||||
//internal
|
|
||||||
Object cpd = EnderDragon.getInstance().getNMSManager().getCPD(item);
|
|
||||||
Map<String,Object> mp = EnderDragon.getInstance().getNMSManager().cpdToMap(cpd);
|
|
||||||
if(mp.containsKey("tag")){
|
|
||||||
cpd = mp.get("tag");
|
|
||||||
mp = EnderDragon.getInstance().getNMSManager().cpdToMap(cpd);
|
|
||||||
mp.remove("Damage");
|
|
||||||
if(mp.containsKey("display")){
|
|
||||||
Object display = mp.get("display");
|
|
||||||
Map<String,Object> display_mp = EnderDragon.getInstance().getNMSManager().cpdToMap(display);
|
|
||||||
display_mp.remove("Name");
|
|
||||||
display_mp.remove("LocName");
|
|
||||||
display_mp.remove("Lore");
|
|
||||||
Object new_display = EnderDragon.getInstance().getNMSManager().getNBTTagCompound(display_mp);
|
|
||||||
mp.put("display",new_display);
|
|
||||||
}
|
|
||||||
//mp.remove("display");//Name, LocName, Lore, color
|
|
||||||
mp.remove("Enchantments");
|
|
||||||
mp.remove("AttributeModifiers");
|
|
||||||
mp.remove("CustomModelData");
|
|
||||||
mp.remove("PublicBukkitValues");//PersistentDataContainer
|
|
||||||
mp.remove("RepairCost");
|
|
||||||
mp.remove("HideFlags");//ItemFlags
|
|
||||||
mp.remove("Unbreakable");
|
|
||||||
//CanDestroy, CanPlaceOn
|
|
||||||
Object new_cpd = EnderDragon.getInstance().getNMSManager().getNBTTagCompound(mp);
|
|
||||||
ConfigurationSection internal = section_data.createSection("internal");
|
|
||||||
internal.set("data_type","nbt");
|
|
||||||
internal.set("data",new_cpd.toString());
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "nbt":
|
case "nbt":
|
||||||
@@ -175,11 +84,11 @@ public class ItemManager {
|
|||||||
//data_type may be null
|
//data_type may be null
|
||||||
ItemStack item;
|
ItemStack item;
|
||||||
if("nbt".equals(data_type)) {
|
if("nbt".equals(data_type)) {
|
||||||
legacy = true;
|
legacy.compareAndSet(false,true);
|
||||||
item = readFromNBT(section0,"data");
|
item = readFromNBT(section0,"data");
|
||||||
}
|
}
|
||||||
else if("advanced".equals(data_type)) {
|
else if("advanced".equals(data_type)) {
|
||||||
legacy = true;
|
legacy.compareAndSet(false,true);
|
||||||
item = readFromAdvData(section0, "data");
|
item = readFromAdvData(section0, "data");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -321,12 +230,244 @@ public class ItemManager {
|
|||||||
if (nbt == null) return new ItemStack(Material.AIR);
|
if (nbt == null) return new ItemStack(Material.AIR);
|
||||||
return section.getItemStack(path);
|
return section.getItemStack(path);
|
||||||
}
|
}
|
||||||
|
public static ItemStack readFromSimple(ConfigurationSection section, String path){
|
||||||
|
if (section == null) return new ItemStack(Material.AIR);
|
||||||
|
section = section.getConfigurationSection(path);
|
||||||
|
if(section == null) return new ItemStack(Material.AIR);
|
||||||
|
//material
|
||||||
|
String type = section.getString("material");
|
||||||
|
if (type==null || "AIR".equals(type)) return new ItemStack(Material.AIR);
|
||||||
|
Material material = Material.getMaterial(type);
|
||||||
|
if (material == null) return new ItemStack(Material.AIR);
|
||||||
|
//amount
|
||||||
|
int amount = section.getInt("amount",1);
|
||||||
|
ItemStack itemStack = new ItemStack(material,amount);
|
||||||
|
ItemMeta meta = itemStack.getItemMeta();
|
||||||
|
assert meta != null;
|
||||||
|
//display_name
|
||||||
|
String display_name = section.getString("display_name");
|
||||||
|
if (display_name != null) meta.setDisplayName(display_name);
|
||||||
|
//loc_name
|
||||||
|
if(section.contains("loc_name")){
|
||||||
|
String LocalizedName = section.getString("loc_name");
|
||||||
|
if(LocalizedName != null) meta.setLocalizedName(LocalizedName);
|
||||||
|
}
|
||||||
|
//lore
|
||||||
|
if(section.contains("lore")){
|
||||||
|
List<String> lore = section.getStringList("lore");
|
||||||
|
if(!lore.isEmpty()) meta.setLore(lore);
|
||||||
|
}
|
||||||
|
//enchants
|
||||||
|
if(section.contains("enchants")){
|
||||||
|
ConfigurationSection enchants = section.getConfigurationSection("enchants");
|
||||||
|
if(enchants != null){
|
||||||
|
enchants.getKeys(false).forEach(key->{
|
||||||
|
Enchantment enchantment = Enchantment.getByName(key);
|
||||||
|
int level = enchants.getInt(key);
|
||||||
|
if(enchantment != null && level>0){
|
||||||
|
meta.addEnchant(enchantment,level,true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//CustomModelData
|
||||||
|
if(Version.mcMainVersion>=14 && section.contains("CustomModelData")){
|
||||||
|
int CustomModelData = section.getInt("CustomModelData");
|
||||||
|
meta.setCustomModelData(CustomModelData);
|
||||||
|
}
|
||||||
|
//RepairCost
|
||||||
|
if(section.contains("RepairCost")){
|
||||||
|
int cost = section.getInt("RepairCost");
|
||||||
|
if(meta instanceof Repairable){
|
||||||
|
((Repairable)meta).setRepairCost(cost);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//Unbreakable
|
||||||
|
if(section.contains("unbreakable"))
|
||||||
|
meta.setUnbreakable(section.getBoolean("unbreakable"));
|
||||||
|
//ItemFlags
|
||||||
|
if(section.contains("ItemFlags")){
|
||||||
|
List<String> names = section.getStringList("ItemFlags");
|
||||||
|
names.forEach(name->meta.addItemFlags(ItemFlag.valueOf(name)));
|
||||||
|
}
|
||||||
|
itemStack.setItemMeta(meta);
|
||||||
|
//damage
|
||||||
|
if (section.contains("damage")){
|
||||||
|
int damage = section.getInt("damage");
|
||||||
|
// 在itemStack.setItemMeta(meta)之后,直接设置到itemStack上
|
||||||
|
itemStack.setDurability((short) damage);
|
||||||
|
}
|
||||||
|
return itemStack;
|
||||||
|
}
|
||||||
public static ItemStack readFromString(String str){
|
public static ItemStack readFromString(String str){
|
||||||
YamlConfiguration yml = new YamlConfiguration();
|
YamlConfiguration yml = new YamlConfiguration();
|
||||||
if(Config.advanced_setting_backslash_split_reward) yml.options().pathSeparator('\\');
|
if(Config.advanced_setting_backslash_split_reward) yml.options().pathSeparator('\\');
|
||||||
yml.set("test",str);
|
yml.set("test",str);
|
||||||
return yml.getItemStack("test");
|
return yml.getItemStack("test");
|
||||||
}
|
}
|
||||||
|
public static void save2section_simple(ItemStack itemStack, ConfigurationSection section){
|
||||||
|
save2section_simple(itemStack,section,"data");
|
||||||
|
}
|
||||||
|
public static void save2section_simple(ItemStack itemStack, ConfigurationSection section,String path){
|
||||||
|
ConfigurationSection res = section.createSection(path);
|
||||||
|
//material
|
||||||
|
String material = itemStack.getType().name();
|
||||||
|
res.set("material",material);
|
||||||
|
if ("AIR".equals(material)) return;
|
||||||
|
//amount
|
||||||
|
int amount = itemStack.getAmount();
|
||||||
|
res.set("amount",amount);
|
||||||
|
//damage
|
||||||
|
int damage = itemStack.getDurability();
|
||||||
|
if (damage != 0) res.set("damage",damage);
|
||||||
|
ItemMeta meta = itemStack.getItemMeta();
|
||||||
|
if (meta == null) return;
|
||||||
|
//display_name
|
||||||
|
if (meta.hasDisplayName()){
|
||||||
|
String display_name = meta.getDisplayName();
|
||||||
|
res.set("display_name",display_name);
|
||||||
|
}
|
||||||
|
//loc_name
|
||||||
|
if (meta.hasLocalizedName()){
|
||||||
|
String loc_name = meta.getLocalizedName();
|
||||||
|
res.set("loc_name",loc_name);
|
||||||
|
}
|
||||||
|
//lore
|
||||||
|
if (meta.hasLore()){
|
||||||
|
List<String> lore = meta.getLore();
|
||||||
|
res.set("lore",lore);
|
||||||
|
}
|
||||||
|
//enchants
|
||||||
|
if (meta.hasEnchants()){
|
||||||
|
ConfigurationSection enchants = res.createSection("enchants");
|
||||||
|
Map<Enchantment,Integer> mp = meta.getEnchants();
|
||||||
|
mp.forEach((enchantment, level) -> enchants.set(enchantment.getName(),level));
|
||||||
|
}
|
||||||
|
//CustomModelData
|
||||||
|
if(Version.mcMainVersion>=14 && meta.hasCustomModelData()){
|
||||||
|
res.set("CustomModelData",meta.getCustomModelData());//int
|
||||||
|
}
|
||||||
|
//RepairCost
|
||||||
|
if(meta instanceof Repairable){
|
||||||
|
Repairable repairable = (Repairable) meta;
|
||||||
|
int RepairCost = repairable.getRepairCost();
|
||||||
|
if (RepairCost != 0) res.set("RepairCost",RepairCost);
|
||||||
|
}
|
||||||
|
//Unbreakable
|
||||||
|
if (meta.isUnbreakable()) {
|
||||||
|
res.set("unbreakable",true);
|
||||||
|
}
|
||||||
|
//ItemFlags
|
||||||
|
Set<ItemFlag> flags = meta.getItemFlags();
|
||||||
|
if(!flags.isEmpty()){
|
||||||
|
List<String> list = new ArrayList<>();
|
||||||
|
flags.forEach(flag ->{
|
||||||
|
list.add(flag.name());
|
||||||
|
});
|
||||||
|
res.set("ItemFlags",list);
|
||||||
|
}
|
||||||
|
//cannot handle nbt currently
|
||||||
|
}
|
||||||
|
public static void save2section_adv(ItemStack item, ConfigurationSection section){
|
||||||
|
ConfigurationSection section_data = section.createSection("data");
|
||||||
|
//type
|
||||||
|
String type = item.getType().name();
|
||||||
|
section_data.set("type",type);
|
||||||
|
if("AIR".equals(type)) return;
|
||||||
|
//amount
|
||||||
|
int amount = item.getAmount();
|
||||||
|
section_data.set("amount",amount);
|
||||||
|
//damage
|
||||||
|
int damage = item.getDurability();
|
||||||
|
if(damage != 0) section_data.set("damage",damage);
|
||||||
|
ItemMeta meta = item.getItemMeta();
|
||||||
|
if(meta == null) return;
|
||||||
|
//DisplayName
|
||||||
|
String display_name = meta.getDisplayName();
|
||||||
|
if(!"".equals(display_name)) section_data.set("display_name",display_name);
|
||||||
|
//LocalizedName
|
||||||
|
if(meta.hasLocalizedName()){
|
||||||
|
section_data.set("localized_name",meta.getLocalizedName());
|
||||||
|
}
|
||||||
|
//lore
|
||||||
|
List<String> lores = meta.getLore();
|
||||||
|
if(lores != null) section_data.set("lore",lores);
|
||||||
|
//Enchantments
|
||||||
|
if(meta.hasEnchants()){
|
||||||
|
ConfigurationSection enchants = section_data.createSection("enchants");
|
||||||
|
Map<Enchantment,Integer> mp = meta.getEnchants();
|
||||||
|
mp.forEach((enchantment,level) -> enchants.set(enchantment.getName(),level));
|
||||||
|
}
|
||||||
|
if(Version.mcMainVersion>=14 || "v1_13_R2".equals(Version.getVersion())){
|
||||||
|
//AttributeModifiers
|
||||||
|
if(meta.hasAttributeModifiers()){
|
||||||
|
ConfigurationSection attributes = section_data.createSection("AttributeModifiers");
|
||||||
|
meta.getAttributeModifiers().forEach((attribute,modifier)->{
|
||||||
|
attributes.set(attribute.name(),modifier);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(Version.mcMainVersion>=14){
|
||||||
|
//CustomModelData
|
||||||
|
if(meta.hasCustomModelData()) {
|
||||||
|
section_data.set("CustomModelData",meta.getCustomModelData());//int
|
||||||
|
}
|
||||||
|
//PersistentDataContainer
|
||||||
|
PersistentDataContainer dataContainer = meta.getPersistentDataContainer();
|
||||||
|
if(!dataContainer.isEmpty()){
|
||||||
|
ConfigurationSection dataContainer_section = section_data.createSection("PersistentDataContainer");
|
||||||
|
String cpd = EnderDragon.getInstance().getNMSManager().PDCtoString(dataContainer);
|
||||||
|
dataContainer_section.set("data_type","nbt");
|
||||||
|
dataContainer_section.set("data",cpd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//RepairCost
|
||||||
|
if(meta instanceof Repairable){
|
||||||
|
Repairable repairable = (Repairable) meta;
|
||||||
|
section_data.set("RepairCost",repairable.getRepairCost());
|
||||||
|
}
|
||||||
|
//ItemFlags
|
||||||
|
Set<ItemFlag> flags = meta.getItemFlags();
|
||||||
|
if(!flags.isEmpty()){
|
||||||
|
List<String> list = new ArrayList<>();
|
||||||
|
flags.forEach(flag ->{
|
||||||
|
list.add(flag.name());
|
||||||
|
});
|
||||||
|
section_data.set("ItemFlags",list);
|
||||||
|
}
|
||||||
|
//Unbreakable
|
||||||
|
section_data.set("unbreakable",meta.isUnbreakable());
|
||||||
|
//internal
|
||||||
|
Object cpd = EnderDragon.getInstance().getNMSManager().getCPD(item);
|
||||||
|
Map<String,Object> mp = EnderDragon.getInstance().getNMSManager().cpdToMap(cpd);
|
||||||
|
if(mp.containsKey("tag")){
|
||||||
|
cpd = mp.get("tag");
|
||||||
|
mp = EnderDragon.getInstance().getNMSManager().cpdToMap(cpd);
|
||||||
|
mp.remove("Damage");
|
||||||
|
if(mp.containsKey("display")){
|
||||||
|
Object display = mp.get("display");
|
||||||
|
Map<String,Object> display_mp = EnderDragon.getInstance().getNMSManager().cpdToMap(display);
|
||||||
|
display_mp.remove("Name");
|
||||||
|
display_mp.remove("LocName");
|
||||||
|
display_mp.remove("Lore");
|
||||||
|
Object new_display = EnderDragon.getInstance().getNMSManager().getNBTTagCompound(display_mp);
|
||||||
|
mp.put("display",new_display);
|
||||||
|
}
|
||||||
|
//mp.remove("display");//Name, LocName, Lore, color
|
||||||
|
mp.remove("Enchantments");
|
||||||
|
mp.remove("AttributeModifiers");
|
||||||
|
mp.remove("CustomModelData");
|
||||||
|
mp.remove("PublicBukkitValues");//PersistentDataContainer
|
||||||
|
mp.remove("RepairCost");
|
||||||
|
mp.remove("HideFlags");//ItemFlags
|
||||||
|
mp.remove("Unbreakable");
|
||||||
|
//CanDestroy, CanPlaceOn
|
||||||
|
Object new_cpd = EnderDragon.getInstance().getNMSManager().getNBTTagCompound(mp);
|
||||||
|
ConfigurationSection internal = section_data.createSection("internal");
|
||||||
|
internal.set("data_type","nbt");
|
||||||
|
internal.set("data",new_cpd.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
public static void addLoreFront(ItemStack item, String lore){
|
public static void addLoreFront(ItemStack item, String lore){
|
||||||
ItemMeta meta = item.getItemMeta();
|
ItemMeta meta = item.getItemMeta();
|
||||||
if(meta != null) {
|
if(meta != null) {
|
||||||
@@ -341,7 +482,7 @@ public class ItemManager {
|
|||||||
item.setItemMeta(meta);
|
item.setItemMeta(meta);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static void addLoreBack(ItemStack item, String lore){
|
public static void addLoreTail(ItemStack item, String lore){
|
||||||
ItemMeta meta = item.getItemMeta();
|
ItemMeta meta = item.getItemMeta();
|
||||||
if(meta != null) {
|
if(meta != null) {
|
||||||
List<String> lores = meta.getLore();
|
List<String> lores = meta.getLore();
|
||||||
@@ -360,81 +501,6 @@ public class ItemManager {
|
|||||||
if(item.getType() == Material.AIR) return true;
|
if(item.getType() == Material.AIR) return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
private static void saveUnhandledTags(ConfigurationSection section, Map<String,Object> mp){
|
|
||||||
mp.forEach((k,v)->{
|
|
||||||
//Bukkit.broadcastMessage(k+": "+v.getClass().toString());
|
|
||||||
if(v instanceof Map){
|
|
||||||
saveUnhandledTags(section.createSection(k), (Map<String, Object>) v);
|
|
||||||
}
|
|
||||||
else section.set(k,v.toString());
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
private static void saveUnhandledTags(ConfigurationSection section, Map<String,Object> mp){
|
|
||||||
mp.forEach((k,v)->{
|
|
||||||
Object obj = v;
|
|
||||||
//Bukkit.broadcastMessage(obj.getClass().toString());
|
|
||||||
try{
|
|
||||||
obj = EnderDragon.getInstance().getNMSItemManager().parseNBT(v);
|
|
||||||
}catch (Throwable ignored){
|
|
||||||
|
|
||||||
}
|
|
||||||
if(obj instanceof Map){
|
|
||||||
saveUnhandledTags(section.createSection(k), (Map<String, Object>) obj);
|
|
||||||
}
|
|
||||||
else section.set(k,obj);
|
|
||||||
});
|
|
||||||
}**/
|
|
||||||
private static Map<String, Object> getUnhandledTags(ConfigurationSection section){
|
|
||||||
Map<String,Object> res = new HashMap<>();
|
|
||||||
section.getKeys(false).forEach(key->{
|
|
||||||
Object obj = section.get(key);
|
|
||||||
if(obj instanceof ConfigurationSection){
|
|
||||||
ConfigurationSection subSection = section.getConfigurationSection(key);
|
|
||||||
if(subSection != null){
|
|
||||||
obj = getUnhandledTags(subSection);
|
|
||||||
// Object mp = getUnhandledTags(subSection);
|
|
||||||
// Bukkit.getLogger().info(mp.getClass().toString());
|
|
||||||
// try{
|
|
||||||
// obj = EnderDragon.getInstance().getNMSItemManager().getNBTBase(mp);
|
|
||||||
// }catch (Throwable throwable){
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else obj = EnderDragon.getInstance().getNMSManager().getCPD((String) obj);
|
|
||||||
//else obj = EnderDragon.getInstance().getNMSItemManager().readAsNBTBase((String) obj);
|
|
||||||
res.put(key,obj);
|
|
||||||
});
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
// private static Object dfs(ConfigurationSection section){
|
|
||||||
// section.getKeys(false).forEach(key->{
|
|
||||||
// Object obj = section.get(key);
|
|
||||||
// if(obj instanceof ConfigurationSection){
|
|
||||||
// ConfigurationSection subSection = section.getConfigurationSection(key);
|
|
||||||
// if(subSection != null) obj = dfs(subSection);
|
|
||||||
// }
|
|
||||||
// else obj = EnderDragon.getInstance().getNMSItemManager().readAsNBTBase((String) obj);
|
|
||||||
//
|
|
||||||
// });
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
|
|
||||||
// //internal
|
|
||||||
// Map<String,Object> mp = EnderDragon.getInstance().getNMSManager().getUnhandledTags(meta);
|
|
||||||
// if(mp != null){
|
|
||||||
// ConfigurationSection internal = section_data.createSection("internal");
|
|
||||||
// mp.forEach((k,v)->{
|
|
||||||
// Object obj = EnderDragon.getInstance().getNMSItemManager().parseNBT(v);
|
|
||||||
//
|
|
||||||
// if(obj instanceof Map) obj = obj.toString();
|
|
||||||
// else if(obj instanceof List) obj = obj.toString();
|
|
||||||
//
|
|
||||||
// internal.set(k,obj);
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -43,11 +43,6 @@ public class RewardManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ItemManager.isLegacy()){
|
|
||||||
Lang.error("I'm sorry that data_type 'nbt' and 'advanced' probably will be disabled in 1.20.5+");
|
|
||||||
Lang.error("It is recommended to migrate item configuration to bukkit format for compatibility.");
|
|
||||||
Lang.error("You can use /ed migrate to generate new config.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
public static void addItem(String key,Reward reward){
|
public static void addItem(String key,Reward reward){
|
||||||
addItem(key,reward.getItem(),reward.getChance());
|
addItem(key,reward.getItem(),reward.getChance());
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ public class NMSUtil {
|
|||||||
private Class<?> WorldClass;
|
private Class<?> WorldClass;
|
||||||
private Class<?> CraftWorldClass;
|
private Class<?> CraftWorldClass;
|
||||||
private Class<?> WorldProviderClass;
|
private Class<?> WorldProviderClass;
|
||||||
//private Class<?> WorldProviderTheEndClass;
|
|
||||||
private Class<?> CraftItemStackClass;
|
private Class<?> CraftItemStackClass;
|
||||||
private Class<?> CraftMetaItemClass;
|
private Class<?> CraftMetaItemClass;
|
||||||
private Class<?> NMSItemStackClass;
|
private Class<?> NMSItemStackClass;
|
||||||
|
|||||||
@@ -9,11 +9,11 @@ import pers.xanadu.enderdragon.nms.WorldData.IWorldDataManager;
|
|||||||
import static org.bukkit.Bukkit.getServer;
|
import static org.bukkit.Bukkit.getServer;
|
||||||
|
|
||||||
public class Version {
|
public class Version {
|
||||||
public static final String setting_dragon = "2.5.0";
|
public static final String setting_dragon = "2.4.0";
|
||||||
public static final String lang = "2.2.0";
|
public static final String lang = "2.2.0";
|
||||||
public static final String config = "2.3.0";
|
public static final String config = "2.3.0";
|
||||||
public static final String data = "2.2.0";
|
public static final String data = "2.2.0";
|
||||||
public static final String reward = "2.5.0";
|
public static final String reward = "2.1.0";
|
||||||
public static int mcMainVersion;
|
public static int mcMainVersion;
|
||||||
public static int mcPatchVersion;
|
public static int mcPatchVersion;
|
||||||
private static String version = "no version found";
|
private static String version = "no version found";
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#文件版本,请勿修改
|
#文件版本,请勿修改
|
||||||
version: 2.5.0
|
version: 2.4.0
|
||||||
|
|
||||||
#用于插件内部识别,每一种末影龙的unique_name都需要设为不同值!
|
#用于插件内部识别,每一种末影龙的unique_name都需要设为不同值!
|
||||||
unique_name: 'default'
|
unique_name: 'default'
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
version: 2.5.0
|
version: 2.4.0
|
||||||
|
|
||||||
#This is used for plugin internal identification.
|
#This is used for plugin internal identification.
|
||||||
#Please make sure the value is unique among all the types of dragons
|
#Please make sure the value is unique among all the types of dragons
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#文件版本,请勿修改
|
#文件版本,请勿修改
|
||||||
version: 2.5.0
|
version: 2.4.0
|
||||||
|
|
||||||
#用于插件内部识别,每一种末影龙的unique_name都需要设为不同值!
|
#用于插件内部识别,每一种末影龙的unique_name都需要设为不同值!
|
||||||
unique_name: 'special001'
|
unique_name: 'special001'
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
## Special thanks to Phaxius for the translation
|
## Special thanks to Phaxius for the translation
|
||||||
|
|
||||||
# File version, do not edit
|
# File version, do not edit
|
||||||
version: 2.5.0
|
version: 2.4.0
|
||||||
|
|
||||||
# Unique ID used by plugin to identify each type of dragon
|
# Unique ID used by plugin to identify each type of dragon
|
||||||
# unique_name needs to be different in each dragon settings file
|
# unique_name needs to be different in each dragon settings file
|
||||||
|
|||||||
Reference in New Issue
Block a user