From e518e26d1712d31ddcd9139f68781d976ba08dfb Mon Sep 17 00:00:00 2001 From: SeanOMik Date: Thu, 3 Sep 2020 11:27:43 -0500 Subject: [PATCH] Fix #8, add 1.14 support and fix esgive system cmd in console --- pom.xml | 11 ++++++----- .../energeticstorage/commands/ESGiveCommand.java | 12 +++++++++--- .../seanomik/energeticstorage/files/PlayersFile.java | 4 ++-- .../seanomik/energeticstorage/gui/ESTerminalGUI.java | 1 - src/main/resources/plugin.yml | 2 +- 5 files changed, 18 insertions(+), 12 deletions(-) diff --git a/pom.xml b/pom.xml index 3fb8c1a..cd0bbf9 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ net.seanomik energeticstorage - 0.3-SNAPSHOT + 0.4-SNAPSHOT jar EnergeticStorage @@ -47,8 +47,10 @@ - D:\Code\java\spigotPlugins\_TEST_SERVER_1.15.2_\plugins\EnergeticStorage-v${project.version}.jar + D:\Code\java\spigotPlugins\_TEST_SERVER_1.14.4_\plugins\EnergeticStorage-v${project.version}.jar + + @@ -86,14 +88,13 @@ org.spigotmc spigot - 1.15.2-R0.1-SNAPSHOT + 1.14-R0.1-SNAPSHOT provided de.tr7zw item-nbt-api - 2.4.1 - + 2.5.0 com.github.WesJD.AnvilGUI diff --git a/src/main/java/net/seanomik/energeticstorage/commands/ESGiveCommand.java b/src/main/java/net/seanomik/energeticstorage/commands/ESGiveCommand.java index 8acde64..5943564 100644 --- a/src/main/java/net/seanomik/energeticstorage/commands/ESGiveCommand.java +++ b/src/main/java/net/seanomik/energeticstorage/commands/ESGiveCommand.java @@ -76,7 +76,7 @@ public class ESGiveCommand implements TabExecutor { sender.sendMessage("Saved systems!"); break; case "system": - Player p = (Player) sender; + //Player p = (Player) sender; if (args.length == 2) { if (!PermissionChecks.canESGiveOthers(sender)) { @@ -94,7 +94,13 @@ public class ESGiveCommand implements TabExecutor { sender.sendMessage(Reference.PREFIX + ChatColor.RED + "Player does not exist or is not online!"); } } else if (args.length == 1) { - p.getInventory().addItem(ItemConstructor.createSystemBlock()); + if (sender instanceof Player) { + Player player = (Player) sender; + player.getInventory().addItem(ItemConstructor.createSystemBlock()); + } else { + sender.sendMessage(Reference.PREFIX + ChatColor.RED + "Supply a player to run this command!"); + sender.sendMessage(generateCommandUsage(args)); + } } break; case "drive": @@ -117,7 +123,7 @@ public class ESGiveCommand implements TabExecutor { if (player != null) { player.getInventory().addItem(ItemConstructor.createDrive(size, 0, 0)); - sender.sendMessage(Reference.PREFIX + ChatColor.GREEN + "Gave an ES System to " + player.getDisplayName()); + sender.sendMessage(Reference.PREFIX + ChatColor.GREEN + "Gave an ES Drive to " + player.getDisplayName()); } else { sender.sendMessage(Reference.PREFIX + ChatColor.RED + "Player does not exist or is not online!"); } diff --git a/src/main/java/net/seanomik/energeticstorage/files/PlayersFile.java b/src/main/java/net/seanomik/energeticstorage/files/PlayersFile.java index dea8fc2..3e6c423 100644 --- a/src/main/java/net/seanomik/energeticstorage/files/PlayersFile.java +++ b/src/main/java/net/seanomik/energeticstorage/files/PlayersFile.java @@ -10,7 +10,7 @@ import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.configuration.InvalidConfigurationException; import org.bukkit.configuration.file.YamlConfiguration; -import org.bukkit.craftbukkit.libs.org.apache.commons.lang3.StringEscapeUtils; +//import org.bukkit.craftbukkit.libs.org.apache.commons.lang3.StringEscapeUtils; import org.bukkit.inventory.ItemStack; import org.json.simple.JSONArray; import org.json.simple.JSONObject; @@ -245,7 +245,7 @@ public class PlayersFile extends YamlConfiguration { JSONArray itemsJson = new JSONArray(); for (Map.Entry entry : drive.getItems().entrySet()) { try { - String object = "{\"itemYAML\":\"" + StringEscapeUtils.escapeJson(ItemSerialization.serializeItem(entry.getKey(), entry.getValue())) + "\"}"; + String object = "{\"itemYAML\":\"" + ItemSerialization.serializeItem(entry.getKey(), entry.getValue()).replace("\"", "\\\"") + "\"}"; JSONObject itemJSON = (JSONObject) new JSONParser().parse(object); itemsJson.add(itemJSON); diff --git a/src/main/java/net/seanomik/energeticstorage/gui/ESTerminalGUI.java b/src/main/java/net/seanomik/energeticstorage/gui/ESTerminalGUI.java index 06ef37f..82e5993 100644 --- a/src/main/java/net/seanomik/energeticstorage/gui/ESTerminalGUI.java +++ b/src/main/java/net/seanomik/energeticstorage/gui/ESTerminalGUI.java @@ -10,7 +10,6 @@ import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.OfflinePlayer; -import org.bukkit.craftbukkit.libs.it.unimi.dsi.fastutil.Hash; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 4a56145..bf9b9f8 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,7 +1,7 @@ name: EnergeticStorage version: ${project.version} main: net.seanomik.energeticstorage.EnergeticStorage -api-version: 1.15 +api-version: 1.14 authors: [SeanOMik] softdepend: [Multiverse-Core] commands: