diff --git a/.idea/libraries/spigot_1_13_2.xml b/.idea/libraries/spigot_1_13_2.xml new file mode 100644 index 0000000..52b58e2 --- /dev/null +++ b/.idea/libraries/spigot_1_13_2.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/Command Panels.iml b/Command Panels.iml index 4603bb8..ee411f3 100644 --- a/Command Panels.iml +++ b/Command Panels.iml @@ -12,7 +12,8 @@ - + + \ No newline at end of file diff --git a/resource/plugin.yml b/resource/plugin.yml index 07f3817..002c745 100644 --- a/resource/plugin.yml +++ b/resource/plugin.yml @@ -1,4 +1,4 @@ -version: 3.9.3 +version: 3.9.4 main: me.rockyhawk.commandPanels.commandpanels name: CommandPanels author: RockyHawk diff --git a/src/me/rockyhawk/commandPanels/commandpanels.java b/src/me/rockyhawk/commandPanels/commandpanels.java index 3e71df1..183158c 100644 --- a/src/me/rockyhawk/commandPanels/commandpanels.java +++ b/src/me/rockyhawk/commandPanels/commandpanels.java @@ -29,6 +29,8 @@ import me.rockyhawk.commandPanels.ingameEditor.cpIngameEditCommand; import me.rockyhawk.commandPanels.ingameEditor.cpTabCompleteIngame; import me.rockyhawk.commandPanels.ingameEditor.editorUserInput; import me.rockyhawk.commandPanels.ingameEditor.editorUtils; +import me.rockyhawk.commandPanels.ioClasses.sequence_1_13; +import me.rockyhawk.commandPanels.ioClasses.sequence_1_14; import me.rockyhawk.commandPanels.openWithItem.utilsOpenWithItem; import me.rockyhawk.commandPanels.panelBlocks.blocksTabComplete; import me.rockyhawk.commandPanels.panelBlocks.commandpanelblocks; @@ -41,8 +43,6 @@ import org.bukkit.command.CommandSender; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.YamlConfiguration; -import org.bukkit.craftbukkit.libs.org.apache.commons.io.IOUtils; -import org.bukkit.craftbukkit.libs.org.apache.commons.io.input.CharSequenceReader; import org.bukkit.enchantments.Enchantment; import org.bukkit.inventory.meta.Damageable; import org.bukkit.entity.Player; @@ -1550,8 +1550,11 @@ public class commandpanels extends JavaPlugin { public Reader getReaderFromStream(InputStream initialStream) throws IOException { //this reads the encrypted resource files in the jar file - byte[] buffer = IOUtils.toByteArray(initialStream); - return new CharSequenceReader(new String(buffer)); + if(Bukkit.getVersion().contains("1.13")){ + return new sequence_1_13().getReaderFromStream(initialStream); + }else{ + return new sequence_1_14().getReaderFromStream(initialStream); + } } public String githubNewUpdate(boolean sendMessages){ diff --git a/src/me/rockyhawk/commandPanels/ingameEditor/editorUtils.java b/src/me/rockyhawk/commandPanels/ingameEditor/editorUtils.java index 73dcaa6..bd3d7fc 100644 --- a/src/me/rockyhawk/commandPanels/ingameEditor/editorUtils.java +++ b/src/me/rockyhawk/commandPanels/ingameEditor/editorUtils.java @@ -203,9 +203,9 @@ public class editorUtils implements Listener { if(!p.getOpenInventory().getTitle().contains(ChatColor.GRAY + "Editing Panel:")){ return; } - String panelName = ""; //all panels from ALL files (panel names) - File fileName = null; //all panels from ALL files (panel names) - YamlConfiguration file = new YamlConfiguration(); //all panels from ALL files (panel yaml files) + String panelName = ""; + String fileName = ""; + YamlConfiguration file = new YamlConfiguration(); boolean found = false; try { //neew to loop through files to get file names @@ -219,7 +219,7 @@ public class editorUtils implements Listener { key = s; if (e.getView().getTitle().equals(ChatColor.GRAY + "Editing Panel: " + plugin.papi( Objects.requireNonNull(temp.getString("panels." + key + ".title"))))) { panelName = key; - fileName = new File(plugin.panelsf + File.separator + tempName); + fileName = tempName; file = temp; found = true; break; @@ -250,7 +250,7 @@ public class editorUtils implements Listener { onEditPanelClose(p,e.getInventory(),e.getView()); inventoryItemSettingsOpening.add(p.getName()); //refresh the yaml config - file = YamlConfiguration.loadConfiguration(fileName); + file = YamlConfiguration.loadConfiguration(new File(plugin.panelsf + File.separator + fileName)); plugin.openItemSettings(p,panelName,file,e.getSlot()); return; } @@ -265,7 +265,7 @@ public class editorUtils implements Listener { if(e.getAction() == InventoryAction.CLONE_STACK){ saveTempItem(e, p, file, panelName); }else if(e.getAction() == InventoryAction.PLACE_ALL){ - loadTempItem(e, p, file, fileName.getName(), panelName); + loadTempItem(e, p, file, fileName, panelName); clearTemp(p, panelName); }else if(e.getAction() == InventoryAction.COLLECT_TO_CURSOR){ //e.setCancelled(true); @@ -285,7 +285,7 @@ public class editorUtils implements Listener { }else if(e.getAction() == InventoryAction.MOVE_TO_OTHER_INVENTORY){ e.setCancelled(true); }else if(e.getAction() == InventoryAction.PLACE_SOME){ - loadTempItem(e, p, file, fileName.getName(), panelName); + loadTempItem(e, p, file, fileName, panelName); }else if(e.getAction() == InventoryAction.SWAP_WITH_CURSOR){ e.setCancelled(true); }else if(e.getAction() == InventoryAction.PICKUP_ALL){ @@ -297,7 +297,7 @@ public class editorUtils implements Listener { }else if(e.getAction() == InventoryAction.PICKUP_SOME){ saveTempItem(e, p, file, panelName); }else if(e.getAction() == InventoryAction.PLACE_ONE){ - loadTempItem(e, p, file, fileName.getName(), panelName); + loadTempItem(e, p, file, fileName, panelName); } } @EventHandler diff --git a/src/me/rockyhawk/commandPanels/ioClasses/sequence_1_13.java b/src/me/rockyhawk/commandPanels/ioClasses/sequence_1_13.java new file mode 100644 index 0000000..35c382b --- /dev/null +++ b/src/me/rockyhawk/commandPanels/ioClasses/sequence_1_13.java @@ -0,0 +1,17 @@ +package me.rockyhawk.commandPanels.ioClasses; + +//1.13 Imports +import org.apache.commons.io.IOUtils; +import org.apache.commons.io.input.CharSequenceReader; + +import java.io.IOException; +import java.io.InputStream; +import java.io.Reader; + +public class sequence_1_13{ + public Reader getReaderFromStream(InputStream initialStream) throws IOException { + //this reads the encrypted resource files in the jar file + byte[] buffer = IOUtils.toByteArray(initialStream); + return new CharSequenceReader(new String(buffer)); + } +} diff --git a/src/me/rockyhawk/commandPanels/ioClasses/sequence_1_14.java b/src/me/rockyhawk/commandPanels/ioClasses/sequence_1_14.java new file mode 100644 index 0000000..b6c9a69 --- /dev/null +++ b/src/me/rockyhawk/commandPanels/ioClasses/sequence_1_14.java @@ -0,0 +1,17 @@ +package me.rockyhawk.commandPanels.ioClasses; + +//1.14+ Imports +import org.bukkit.craftbukkit.libs.org.apache.commons.io.IOUtils; +import org.bukkit.craftbukkit.libs.org.apache.commons.io.input.CharSequenceReader; + +import java.io.IOException; +import java.io.InputStream; +import java.io.Reader; + +public class sequence_1_14{ + public Reader getReaderFromStream(InputStream initialStream) throws IOException { + //this reads the encrypted resource files in the jar file + byte[] buffer = IOUtils.toByteArray(initialStream); + return new CharSequenceReader(new String(buffer)); + } +}