mirror of
https://github.com/songoda/EpicBosses.git
synced 2024-11-15 22:35:10 +01:00
Files load, fix boss panel bug
This commit is contained in:
parent
84b24d1aae
commit
c9b15b44b1
@ -1,8 +1,6 @@
|
|||||||
package com.songoda.epicbosses.file;
|
package com.songoda.epicbosses.file;
|
||||||
|
|
||||||
import com.songoda.epicbosses.utils.Versions;
|
|
||||||
import com.songoda.epicbosses.utils.file.YmlFileHandler;
|
import com.songoda.epicbosses.utils.file.YmlFileHandler;
|
||||||
import com.songoda.epicbosses.utils.version.VersionHandler;
|
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -15,6 +13,6 @@ import java.io.File;
|
|||||||
public class ConfigFileHandler extends YmlFileHandler {
|
public class ConfigFileHandler extends YmlFileHandler {
|
||||||
|
|
||||||
public ConfigFileHandler(JavaPlugin javaPlugin) {
|
public ConfigFileHandler(JavaPlugin javaPlugin) {
|
||||||
super(javaPlugin, true, new File(javaPlugin.getDataFolder(), new VersionHandler().getVersion().isHigherThanOrEqualTo(Versions.v1_13_R1) ? "current" : "legacy" + "/config.yml"));
|
super(javaPlugin, true, new File(javaPlugin.getDataFolder(), "config.yml"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
package com.songoda.epicbosses.file;
|
package com.songoda.epicbosses.file;
|
||||||
|
|
||||||
import com.songoda.epicbosses.utils.Versions;
|
|
||||||
import com.songoda.epicbosses.utils.file.YmlFileHandler;
|
import com.songoda.epicbosses.utils.file.YmlFileHandler;
|
||||||
import com.songoda.epicbosses.utils.version.VersionHandler;
|
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -15,7 +13,7 @@ import java.io.File;
|
|||||||
public class EditorFileHandler extends YmlFileHandler {
|
public class EditorFileHandler extends YmlFileHandler {
|
||||||
|
|
||||||
public EditorFileHandler(JavaPlugin javaPlugin) {
|
public EditorFileHandler(JavaPlugin javaPlugin) {
|
||||||
super(javaPlugin, true, new File(javaPlugin.getDataFolder(), new VersionHandler().getVersion().isHigherThanOrEqualTo(Versions.v1_13_R1) ? "current" : "legacy" + "/editor.yml"));
|
super(javaPlugin, true, new File(javaPlugin.getDataFolder(), "editor.yml"));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -805,15 +805,15 @@ public class BossPanelManager implements ILoadable, IReloadable {
|
|||||||
private void loadAddItemsMenu() {
|
private void loadAddItemsMenu() {
|
||||||
PanelBuilder panelBuilder = new PanelBuilder(this.customBosses.getEditor().getConfigurationSection("AddItemsMenu"));
|
PanelBuilder panelBuilder = new PanelBuilder(this.customBosses.getEditor().getConfigurationSection("AddItemsMenu"));
|
||||||
|
|
||||||
this.addItemsBuilder = this.addItemsBuilder.cloneBuilder();
|
this.addItemsBuilder = panelBuilder.cloneBuilder();
|
||||||
this.customItemAddItemsMenu = new AddItemsPanel(this, panelBuilder, this.customBosses, new CustomItemsAddItemsParentPanelHandler(this));
|
this.customItemAddItemsMenu = new AddItemsPanel(this, panelBuilder.cloneBuilder(), this.customBosses, new CustomItemsAddItemsParentPanelHandler(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void reloadAddItemsMenu() {
|
private void reloadAddItemsMenu() {
|
||||||
PanelBuilder panelBuilder = new PanelBuilder(this.customBosses.getEditor().getConfigurationSection("AddItemsMenu"));
|
PanelBuilder panelBuilder = new PanelBuilder(this.customBosses.getEditor().getConfigurationSection("AddItemsMenu"));
|
||||||
|
|
||||||
this.addItemsBuilder = this.addItemsBuilder.cloneBuilder();
|
this.addItemsBuilder = panelBuilder.cloneBuilder();
|
||||||
this.customItemAddItemsMenu.initializePanel(panelBuilder);
|
this.customItemAddItemsMenu.initializePanel(panelBuilder.cloneBuilder());
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------
|
//---------------------------------------------
|
||||||
|
@ -6,8 +6,6 @@ import com.songoda.epicbosses.file.AutoSpawnFileHandler;
|
|||||||
import com.songoda.epicbosses.utils.ILoadable;
|
import com.songoda.epicbosses.utils.ILoadable;
|
||||||
import com.songoda.epicbosses.utils.IReloadable;
|
import com.songoda.epicbosses.utils.IReloadable;
|
||||||
import com.songoda.epicbosses.utils.ISavable;
|
import com.songoda.epicbosses.utils.ISavable;
|
||||||
import com.songoda.epicbosses.utils.Versions;
|
|
||||||
import com.songoda.epicbosses.utils.version.VersionHandler;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -24,7 +22,7 @@ public class AutoSpawnFileManager implements ILoadable, ISavable, IReloadable {
|
|||||||
private AutoSpawnFileHandler autoSpawnFileHandler;
|
private AutoSpawnFileHandler autoSpawnFileHandler;
|
||||||
|
|
||||||
public AutoSpawnFileManager(CustomBosses plugin) {
|
public AutoSpawnFileManager(CustomBosses plugin) {
|
||||||
File file = new File(plugin.getDataFolder(), new VersionHandler().getVersion().isHigherThanOrEqualTo(Versions.v1_13_R1) ? "current" : "legacy" + "/autospawns.json");
|
File file = new File(plugin.getDataFolder(), "autospawns.json");
|
||||||
|
|
||||||
this.autoSpawnFileHandler = new AutoSpawnFileHandler(plugin, true, file);
|
this.autoSpawnFileHandler = new AutoSpawnFileHandler(plugin, true, file);
|
||||||
}
|
}
|
||||||
|
@ -7,8 +7,6 @@ import com.songoda.epicbosses.file.BossesFileHandler;
|
|||||||
import com.songoda.epicbosses.utils.ILoadable;
|
import com.songoda.epicbosses.utils.ILoadable;
|
||||||
import com.songoda.epicbosses.utils.IReloadable;
|
import com.songoda.epicbosses.utils.IReloadable;
|
||||||
import com.songoda.epicbosses.utils.ISavable;
|
import com.songoda.epicbosses.utils.ISavable;
|
||||||
import com.songoda.epicbosses.utils.Versions;
|
|
||||||
import com.songoda.epicbosses.utils.version.VersionHandler;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -27,7 +25,7 @@ public class BossesFileManager implements ILoadable, ISavable, IReloadable {
|
|||||||
private BossesFileHandler bossesFileHandler;
|
private BossesFileHandler bossesFileHandler;
|
||||||
|
|
||||||
public BossesFileManager(CustomBosses customBosses) {
|
public BossesFileManager(CustomBosses customBosses) {
|
||||||
File file = new File(customBosses.getDataFolder(), new VersionHandler().getVersion().isHigherThanOrEqualTo(Versions.v1_13_R1) ? "current" : "legacy" + "/bosses.json");
|
File file = new File(customBosses.getDataFolder(), "bosses.json");
|
||||||
|
|
||||||
this.bossesFileHandler = new BossesFileHandler(customBosses, true, file);
|
this.bossesFileHandler = new BossesFileHandler(customBosses, true, file);
|
||||||
this.bossEntityContainer = customBosses.getBossEntityContainer();
|
this.bossEntityContainer = customBosses.getBossEntityContainer();
|
||||||
|
@ -5,8 +5,6 @@ import com.songoda.epicbosses.file.CommandsFileHandler;
|
|||||||
import com.songoda.epicbosses.utils.ILoadable;
|
import com.songoda.epicbosses.utils.ILoadable;
|
||||||
import com.songoda.epicbosses.utils.IReloadable;
|
import com.songoda.epicbosses.utils.IReloadable;
|
||||||
import com.songoda.epicbosses.utils.ISavable;
|
import com.songoda.epicbosses.utils.ISavable;
|
||||||
import com.songoda.epicbosses.utils.Versions;
|
|
||||||
import com.songoda.epicbosses.utils.version.VersionHandler;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -24,7 +22,7 @@ public class CommandsFileManager implements ILoadable, ISavable, IReloadable {
|
|||||||
private CommandsFileHandler commandsFileHandler;
|
private CommandsFileHandler commandsFileHandler;
|
||||||
|
|
||||||
public CommandsFileManager(CustomBosses customBosses) {
|
public CommandsFileManager(CustomBosses customBosses) {
|
||||||
File file = new File(customBosses.getDataFolder(), new VersionHandler().getVersion().isHigherThanOrEqualTo(Versions.v1_13_R1) ? "current" : "legacy" + "/commands.json");
|
File file = new File(customBosses.getDataFolder(), "commands.json");
|
||||||
|
|
||||||
this.commandsFileHandler = new CommandsFileHandler(customBosses, true, file);
|
this.commandsFileHandler = new CommandsFileHandler(customBosses, true, file);
|
||||||
}
|
}
|
||||||
|
@ -5,8 +5,6 @@ import com.songoda.epicbosses.file.DropTableFileHandler;
|
|||||||
import com.songoda.epicbosses.utils.ILoadable;
|
import com.songoda.epicbosses.utils.ILoadable;
|
||||||
import com.songoda.epicbosses.utils.IReloadable;
|
import com.songoda.epicbosses.utils.IReloadable;
|
||||||
import com.songoda.epicbosses.utils.ISavable;
|
import com.songoda.epicbosses.utils.ISavable;
|
||||||
import com.songoda.epicbosses.utils.Versions;
|
|
||||||
import com.songoda.epicbosses.utils.version.VersionHandler;
|
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -24,7 +22,7 @@ public class DropTableFileManager implements ILoadable, ISavable, IReloadable {
|
|||||||
private DropTableFileHandler dropTableFileHandler;
|
private DropTableFileHandler dropTableFileHandler;
|
||||||
|
|
||||||
public DropTableFileManager(JavaPlugin javaPlugin) {
|
public DropTableFileManager(JavaPlugin javaPlugin) {
|
||||||
File file = new File(javaPlugin.getDataFolder(), new VersionHandler().getVersion().isHigherThanOrEqualTo(Versions.v1_13_R1) ? "current" : "legacy" + "/droptables.json");
|
File file = new File(javaPlugin.getDataFolder(), "droptables.json");
|
||||||
|
|
||||||
this.dropTableFileHandler = new DropTableFileHandler(javaPlugin, true, file);
|
this.dropTableFileHandler = new DropTableFileHandler(javaPlugin, true, file);
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,12 @@
|
|||||||
package com.songoda.epicbosses.managers.files;
|
package com.songoda.epicbosses.managers.files;
|
||||||
|
|
||||||
import com.songoda.epicbosses.utils.Versions;
|
import com.songoda.epicbosses.file.ItemStackFileHandler;
|
||||||
import com.songoda.epicbosses.utils.version.VersionHandler;
|
|
||||||
import lombok.Getter;
|
|
||||||
import com.songoda.epicbosses.utils.ILoadable;
|
import com.songoda.epicbosses.utils.ILoadable;
|
||||||
import com.songoda.epicbosses.utils.IReloadable;
|
import com.songoda.epicbosses.utils.IReloadable;
|
||||||
import com.songoda.epicbosses.utils.ISavable;
|
import com.songoda.epicbosses.utils.ISavable;
|
||||||
import com.songoda.epicbosses.utils.itemstack.ItemStackConverter;
|
import com.songoda.epicbosses.utils.itemstack.ItemStackConverter;
|
||||||
import com.songoda.epicbosses.file.ItemStackFileHandler;
|
|
||||||
import com.songoda.epicbosses.utils.itemstack.holder.ItemStackHolder;
|
import com.songoda.epicbosses.utils.itemstack.holder.ItemStackHolder;
|
||||||
|
import lombok.Getter;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
@ -29,7 +27,7 @@ public class ItemsFileManager implements ILoadable, ISavable, IReloadable {
|
|||||||
private ItemStackFileHandler itemStackFileHandler;
|
private ItemStackFileHandler itemStackFileHandler;
|
||||||
|
|
||||||
public ItemsFileManager(JavaPlugin javaPlugin) {
|
public ItemsFileManager(JavaPlugin javaPlugin) {
|
||||||
File file = new File(javaPlugin.getDataFolder(), new VersionHandler().getVersion().isHigherThanOrEqualTo(Versions.v1_13_R1) ? "current" : "legacy" + "/items.json");
|
File file = new File(javaPlugin.getDataFolder(), "items.json");
|
||||||
|
|
||||||
this.itemStackFileHandler = new ItemStackFileHandler(javaPlugin, file, true);
|
this.itemStackFileHandler = new ItemStackFileHandler(javaPlugin, file, true);
|
||||||
}
|
}
|
||||||
|
@ -5,8 +5,6 @@ import com.songoda.epicbosses.file.MessagesFileHandler;
|
|||||||
import com.songoda.epicbosses.utils.ILoadable;
|
import com.songoda.epicbosses.utils.ILoadable;
|
||||||
import com.songoda.epicbosses.utils.IReloadable;
|
import com.songoda.epicbosses.utils.IReloadable;
|
||||||
import com.songoda.epicbosses.utils.ISavable;
|
import com.songoda.epicbosses.utils.ISavable;
|
||||||
import com.songoda.epicbosses.utils.Versions;
|
|
||||||
import com.songoda.epicbosses.utils.version.VersionHandler;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -24,7 +22,7 @@ public class MessagesFileManager implements ILoadable, ISavable, IReloadable {
|
|||||||
private MessagesFileHandler messagesFileHandler;
|
private MessagesFileHandler messagesFileHandler;
|
||||||
|
|
||||||
public MessagesFileManager(CustomBosses customBosses) {
|
public MessagesFileManager(CustomBosses customBosses) {
|
||||||
File file = new File(customBosses.getDataFolder(), new VersionHandler().getVersion().isHigherThanOrEqualTo(Versions.v1_13_R1) ? "current" : "legacy" + "/messages.json");
|
File file = new File(customBosses.getDataFolder(), "messages.json");
|
||||||
|
|
||||||
this.messagesFileHandler = new MessagesFileHandler(customBosses, true, file);
|
this.messagesFileHandler = new MessagesFileHandler(customBosses, true, file);
|
||||||
}
|
}
|
||||||
|
@ -7,8 +7,6 @@ import com.songoda.epicbosses.file.MinionsFileHandler;
|
|||||||
import com.songoda.epicbosses.utils.ILoadable;
|
import com.songoda.epicbosses.utils.ILoadable;
|
||||||
import com.songoda.epicbosses.utils.IReloadable;
|
import com.songoda.epicbosses.utils.IReloadable;
|
||||||
import com.songoda.epicbosses.utils.ISavable;
|
import com.songoda.epicbosses.utils.ISavable;
|
||||||
import com.songoda.epicbosses.utils.Versions;
|
|
||||||
import com.songoda.epicbosses.utils.version.VersionHandler;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -24,7 +22,7 @@ public class MinionsFileManager implements ILoadable, ISavable, IReloadable {
|
|||||||
private MinionsFileHandler minionsFileHandler;
|
private MinionsFileHandler minionsFileHandler;
|
||||||
|
|
||||||
public MinionsFileManager(CustomBosses customBosses) {
|
public MinionsFileManager(CustomBosses customBosses) {
|
||||||
File file = new File(customBosses.getDataFolder(), new VersionHandler().getVersion().isHigherThanOrEqualTo(Versions.v1_13_R1) ? "current" : "legacy" + "/minions.json");
|
File file = new File(customBosses.getDataFolder(), "minions.json");
|
||||||
|
|
||||||
this.minionsFileHandler = new MinionsFileHandler(customBosses, true, file);
|
this.minionsFileHandler = new MinionsFileHandler(customBosses, true, file);
|
||||||
this.minionEntityContainer = customBosses.getMinionEntityContainer();
|
this.minionEntityContainer = customBosses.getMinionEntityContainer();
|
||||||
|
@ -6,8 +6,6 @@ import com.songoda.epicbosses.skills.Skill;
|
|||||||
import com.songoda.epicbosses.utils.ILoadable;
|
import com.songoda.epicbosses.utils.ILoadable;
|
||||||
import com.songoda.epicbosses.utils.IReloadable;
|
import com.songoda.epicbosses.utils.IReloadable;
|
||||||
import com.songoda.epicbosses.utils.ISavable;
|
import com.songoda.epicbosses.utils.ISavable;
|
||||||
import com.songoda.epicbosses.utils.Versions;
|
|
||||||
import com.songoda.epicbosses.utils.version.VersionHandler;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -24,7 +22,7 @@ public class SkillsFileManager implements ILoadable, IReloadable, ISavable {
|
|||||||
private SkillsFileHandler skillsFileHandler;
|
private SkillsFileHandler skillsFileHandler;
|
||||||
|
|
||||||
public SkillsFileManager(CustomBosses plugin) {
|
public SkillsFileManager(CustomBosses plugin) {
|
||||||
File file = new File(plugin.getDataFolder(), new VersionHandler().getVersion().isHigherThanOrEqualTo(Versions.v1_13_R1) ? "current" : "legacy" + "/skills.json");
|
File file = new File(plugin.getDataFolder(), "skills.json");
|
||||||
|
|
||||||
this.skillsFileHandler = new SkillsFileHandler(plugin, true, file);
|
this.skillsFileHandler = new SkillsFileHandler(plugin, true, file);
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,18 @@
|
|||||||
package com.songoda.epicbosses.utils.file;
|
package com.songoda.epicbosses.utils.file;
|
||||||
|
|
||||||
|
import com.songoda.epicbosses.utils.Versions;
|
||||||
|
import com.songoda.epicbosses.utils.version.VersionHandler;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.net.URI;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Charles Cullen
|
* @author Charles Cullen
|
||||||
@ -27,11 +36,15 @@ public abstract class FileHandler<T> implements IFileHandler<T> {
|
|||||||
public void createFile() {
|
public void createFile() {
|
||||||
if(!this.file.exists()) {
|
if(!this.file.exists()) {
|
||||||
if(this.saveResource) {
|
if(this.saveResource) {
|
||||||
String path = this.file.getName();
|
String name = this.file.getName();
|
||||||
|
String folder = new VersionHandler().getVersion().isHigherThanOrEqualTo(Versions.v1_13_R1) ? "/current/" : "/legacy/";
|
||||||
|
String path = folder + name;
|
||||||
|
|
||||||
if(this.javaPlugin.getResource(path) != null) {
|
try (InputStream resourceStream = this.getClass().getResourceAsStream(path)) {
|
||||||
this.javaPlugin.saveResource(path, false);
|
Files.copy(resourceStream, new File(this.javaPlugin.getDataFolder(), name).toPath());
|
||||||
return;
|
return;
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,10 +1,15 @@
|
|||||||
package com.songoda.epicbosses.utils.file;
|
package com.songoda.epicbosses.utils.file;
|
||||||
|
|
||||||
|
import com.songoda.epicbosses.utils.Versions;
|
||||||
|
import com.songoda.epicbosses.utils.version.VersionHandler;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Charles Cullen
|
* @author Charles Cullen
|
||||||
@ -28,11 +33,15 @@ public class YmlFileHandler implements IFileHandler<FileConfiguration> {
|
|||||||
public void createFile() {
|
public void createFile() {
|
||||||
if(!this.file.exists()) {
|
if(!this.file.exists()) {
|
||||||
if(this.saveResource) {
|
if(this.saveResource) {
|
||||||
String path = this.file.getName();
|
String name = this.file.getName();
|
||||||
|
String folder = new VersionHandler().getVersion().isHigherThanOrEqualTo(Versions.v1_13_R1) ? "/current/" : "/legacy/";
|
||||||
|
String path = folder + name;
|
||||||
|
|
||||||
if(this.javaPlugin.getResource(path) != null) {
|
try (InputStream resourceStream = this.getClass().getResourceAsStream(path)) {
|
||||||
this.javaPlugin.saveResource(path, false);
|
Files.copy(resourceStream, new File(this.javaPlugin.getDataFolder(), name).toPath());
|
||||||
return;
|
return;
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user