From d8e11a41a68f2be956b8f7f57447c62cf9fa2f23 Mon Sep 17 00:00:00 2001 From: GeorgH93 Date: Sat, 8 Jun 2019 00:25:30 +0200 Subject: [PATCH] Bugfixes [Fix] Allow players to move blocked items out of backpacks Fixes #37 [Fix] Problems when reloading the plugin while players have the backpack open on MC 1.14 [Fix] Missing messages in the language files --- pom.xml | 5 +++-- resources/lang/de.yml | 13 ++++++++++++- resources/lang/en.yml | 3 ++- .../pcgamingfreaks/Minepacks/Bukkit/Backpack.java | 5 +++-- .../Minepacks/Bukkit/Command/CommandManager.java | 7 ++++--- .../Bukkit/Database/Helper/OldFileUpdater.java | 1 - .../Minepacks/Bukkit/Database/Language.java | 2 +- .../Minepacks/Bukkit/Listener/ItemFilter.java | 2 ++ 8 files changed, 27 insertions(+), 11 deletions(-) diff --git a/pom.xml b/pom.xml index 9949a8e..13c0575 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 at.pcgamingfreaks Minepacks - 2.0 + 2.0.1 scm:git:git@github.com:GeorgH93/Minepacks.git @@ -84,7 +84,8 @@ at.pcgamingfreaks BadRabbit - 1.1.1 + 1.2.1 + Bukkit diff --git a/resources/lang/de.yml b/resources/lang/de.yml index 8caa491..e18f847 100644 --- a/resources/lang/de.yml +++ b/resources/lang/de.yml @@ -23,6 +23,16 @@ Language: Help: Header: "&6### Minepacks Commands ###" Footer: "&6#############################" + Reload: + Reloading: "&1Plugin wird neu geladen ..." + Reloaded: "&1Plugin neu geladen!" + Update: + CheckingForUpdates: "&1Suche nach Aktualisierungen ..." + Updated: "[\"\",{\"text\":\"Plugin wurde aktualisiert, Änderungen werden mit dem nächsten neustart übernommen.\",\"color\":\"yellow\"}]" + NoUpdate: "[\"\",{\"text\":\"Plugin Aktualisierung verfügbar.\",\"color\":\"gold\"}]" + UpdateFail: "[\"\",{\"text\":\"Es gab ein Problem bei der Suche nach Updates! Bitte prüfe das log für mehr details.\",\"color\":\"red\"}]" + # You can change this message if you like to, but don't cry if the link isn't linking to the plugin anymore! + UpdateAvailable: "[{\"text\":\"Es ist eine Aktualisierung verfügbar! Bitte gehe auf \\\"\",\"color\":\"green\"},{\"text\":\"https://www.spigotmc.org/resources/19286/\",\"color\":\"yellow\",\"underlined\":true,\"clickEvent\":{\"action\":\"open_url\",\"value\":\"https://www.spigotmc.org/resources/19286/\"}},{\"text\":\"\\\" um es herunter zu laden!\"}]" Admin: Reloading: "&1Reloading ..." Reloaded: "&1Reloaded!" @@ -62,6 +72,7 @@ Language: RestoreList: "Listet alle verfügbaren Sicherungskopien von Rucksäcken auf." Version: "Gibt die Versionsdetails über das Plugin und seine Abhängigkeiten aus." Help: "Zeigt die verfügbaren Befehle an." + Migrate: "Erlaubt das konvertieren der Datenbank in ein anderes Format." Command: Backpack: @@ -99,4 +110,4 @@ LanguageName: "german" Author: "GeorgH93" # Language file version. Don't touch it! -Version: 15 \ No newline at end of file +Version: 16 \ No newline at end of file diff --git a/resources/lang/en.yml b/resources/lang/en.yml index e3abcf9..903fed0 100644 --- a/resources/lang/en.yml +++ b/resources/lang/en.yml @@ -63,6 +63,7 @@ Language: Restore: "Restores a backup." RestoreList: "Lists all available backups." Help: "Shows all available commands and their description." + Migrate: "Migrates the used database from one type to another." Command: Backpack: @@ -95,4 +96,4 @@ LanguageName: "english" Author: "GeorgH93" # Language file version. Don't touch it! -Version: 15 \ No newline at end of file +Version: 16 \ No newline at end of file diff --git a/src/at/pcgamingfreaks/Minepacks/Bukkit/Backpack.java b/src/at/pcgamingfreaks/Minepacks/Bukkit/Backpack.java index 27cce6f..bb114e3 100644 --- a/src/at/pcgamingfreaks/Minepacks/Bukkit/Backpack.java +++ b/src/at/pcgamingfreaks/Minepacks/Bukkit/Backpack.java @@ -32,9 +32,10 @@ import java.lang.reflect.Field; import java.lang.reflect.Method; -import java.util.HashMap; import java.util.LinkedList; import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; public class Backpack implements at.pcgamingfreaks.Minepacks.Bukkit.API.Backpack { @@ -45,7 +46,7 @@ public class Backpack implements at.pcgamingfreaks.Minepacks.Bukkit.API.Backpack private static String titleOtherFormat, titleOther; private final OfflinePlayer owner; private final Object titleOtherOBC; - private final HashMap opened = new HashMap<>(); + private final Map opened = new ConcurrentHashMap<>(); //Thanks Minecraft 1.14 private Inventory bp; private int size, ownerID; private boolean hasChanged; diff --git a/src/at/pcgamingfreaks/Minepacks/Bukkit/Command/CommandManager.java b/src/at/pcgamingfreaks/Minepacks/Bukkit/Command/CommandManager.java index b85d9d9..8f44399 100644 --- a/src/at/pcgamingfreaks/Minepacks/Bukkit/Command/CommandManager.java +++ b/src/at/pcgamingfreaks/Minepacks/Bukkit/Command/CommandManager.java @@ -31,6 +31,7 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; import java.util.Collection; import java.util.List; @@ -41,7 +42,7 @@ public class CommandManager extends CommandExecutorWithSubCommandsGeneric onTabComplete(CommandSender sender, Command command, String alias, String[] args) + public List onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) { if(sender instanceof Player) { diff --git a/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/Helper/OldFileUpdater.java b/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/Helper/OldFileUpdater.java index 926dd43..3e80702 100644 --- a/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/Helper/OldFileUpdater.java +++ b/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/Helper/OldFileUpdater.java @@ -50,7 +50,6 @@ public static void updateConfig(YAML oldYAML, YAML newYAML) case "Misc.AutoUpdate": oldKey = "auto-update"; break; case "Misc.UseBungeeCord": oldKey = "BungeeCordMode"; break; case "Language.Language": oldKey = "Language"; break; - case "Language.UpdateMode": oldKey = "LanguageUpdateMode"; break; case "Database.UseUUIDs": if(!oldYAML.isSet("Database.UseUUIDs") && oldYAML.isSet("UseUUIDs")) oldKey = "UseUUIDs"; break; } try diff --git a/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/Language.java b/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/Language.java index f540bb9..b82394b 100644 --- a/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/Language.java +++ b/src/at/pcgamingfreaks/Minepacks/Bukkit/Database/Language.java @@ -28,7 +28,7 @@ public class Language extends at.pcgamingfreaks.Bukkit.Language { - private static final int LANG_VERSION = 15, UPGRADE_THRESHOLD = 15; + private static final int LANG_VERSION = 16, UPGRADE_THRESHOLD = 16; public Language(JavaPlugin plugin) { diff --git a/src/at/pcgamingfreaks/Minepacks/Bukkit/Listener/ItemFilter.java b/src/at/pcgamingfreaks/Minepacks/Bukkit/Listener/ItemFilter.java index 58a8d68..d7f9d3c 100644 --- a/src/at/pcgamingfreaks/Minepacks/Bukkit/Listener/ItemFilter.java +++ b/src/at/pcgamingfreaks/Minepacks/Bukkit/Listener/ItemFilter.java @@ -94,6 +94,8 @@ public void onItemMove(InventoryClickEvent event) { if(event.getInventory().getHolder() instanceof Backpack && event.getCurrentItem() != null && blockedMaterials.contains(new MinecraftMaterial(event.getCurrentItem()))) { + if(event.getClickedInventory() != null && event.getClickedInventory().getHolder() instanceof Backpack) return; // Allow user to move blacklisted items out of the backpack + messageNotAllowedInBackpack.send(event.getView().getPlayer(), itemNameResolver.getName(event.getCurrentItem())); event.setCancelled(true); }