From 308d3a9661b036ef1e6966501bb80106755cde16 Mon Sep 17 00:00:00 2001 From: Brianna Date: Tue, 31 Mar 2020 08:25:36 -0400 Subject: [PATCH 1/6] Use CompatibleSound for ChallangeInventory. --- .../skyblock/challenge/inventory/inv/ChallengeInventory.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/songoda/skyblock/challenge/inventory/inv/ChallengeInventory.java b/src/main/java/com/songoda/skyblock/challenge/inventory/inv/ChallengeInventory.java index 68ce3598..c1043c13 100644 --- a/src/main/java/com/songoda/skyblock/challenge/inventory/inv/ChallengeInventory.java +++ b/src/main/java/com/songoda/skyblock/challenge/inventory/inv/ChallengeInventory.java @@ -4,6 +4,7 @@ import java.util.HashMap; import java.util.function.Consumer; import java.util.logging.Level; +import com.songoda.core.compatibility.CompatibleSound; import org.bukkit.Bukkit; import org.bukkit.Sound; import org.bukkit.enchantments.Enchantment; @@ -90,7 +91,7 @@ public class ChallengeInventory implements InventoryProvider { // Update count count2 = done.getOrDefault(c, 0); // Play sound - p.playSound(p.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1, 1); + p.playSound(p.getLocation(), CompatibleSound.ENTITY_PLAYER_LEVELUP.getSound(), 1, 1); // Update item ItemStack is2 = ic.createItem(inv.getPlayer().getUniqueId(), count2); // If challenge is done, add enchantment to show to player that it's done From 32f5383f3e801f803eb72b6ef78e6855a29dd78f Mon Sep 17 00:00:00 2001 From: 0ddlyoko <0ddlyokoOfficial@gmail.com> Date: Tue, 31 Mar 2020 15:46:40 +0200 Subject: [PATCH 2/6] Try to fix NullPointerException for challenges --- .../challenge/challenge/ChallengeCategory.java | 6 ++++-- src/main/resources/challenges.yml | 10 +++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/challenge/challenge/ChallengeCategory.java b/src/main/java/com/songoda/skyblock/challenge/challenge/ChallengeCategory.java index d9ea2086..7da312e4 100644 --- a/src/main/java/com/songoda/skyblock/challenge/challenge/ChallengeCategory.java +++ b/src/main/java/com/songoda/skyblock/challenge/challenge/ChallengeCategory.java @@ -54,8 +54,10 @@ public class ChallengeCategory { lore = new ArrayList<>(); try { // If an Exception occurs, we don't handle it here but in parent class - System.out.println(strItem); - Material item = CompatibleMaterial.getMaterial(strItem).getMaterial(); + CompatibleMaterial compatibleMaterial = CompatibleMaterial.getMaterial(strItem); + if (compatibleMaterial == null) + throw new IllegalArgumentException("Item " + strItem + " isn't a correct material"); + Material item = compatibleMaterial.getMaterial(); if (item == null) throw new IllegalArgumentException("Item " + strItem + " isn't a correct material"); ItemChallenge ic = new ItemChallenge(show, row, col, item, amount, lore); diff --git a/src/main/resources/challenges.yml b/src/main/resources/challenges.yml index b9f2b07a..658227eb 100644 --- a/src/main/resources/challenges.yml +++ b/src/main/resources/challenges.yml @@ -388,7 +388,7 @@ challenges: id: 3 name: '&2A Prickly Affair' require: - - 'ITEM:cactus_green 48' + - 'ITEM:green_dye 48' reward: - 'CMD:eco give {player} 200' - 'ITEM:sand 24' @@ -398,7 +398,7 @@ challenges: show: true row: 1 col: 5 - item: cactus_green + item: green_dye amount: 1 lore: - '&c&lFor this challenge, you''ll need:' @@ -1368,8 +1368,8 @@ challenges: id: 2 name: '&2Artist' require: - - 'ITEM:rose_red 64' - - 'ITEM:cactus_green 64' + - 'ITEM:red_dye 64' + - 'ITEM:green_dye 64' - 'ITEM:purple_dye 64' - 'ITEM:cyan_dye 64' - 'ITEM:light_gray_dye 64' @@ -1393,7 +1393,7 @@ challenges: show: true row: 1 col: 4 - item: dandelion_yellow + item: YELLOW_DYE amount: 1 lore: - '&c&lFor this challenge, you''ll need:' From 4aafc87b551297d5ba0e72b78aaaa58dc0c13416 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wert=C3=ADk?= Date: Tue, 31 Mar 2020 17:39:27 +0200 Subject: [PATCH 3/6] Fixed parsing incorrect weather. --- .../com/songoda/skyblock/island/Island.java | 38 ++++++++++--------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/island/Island.java b/src/main/java/com/songoda/skyblock/island/Island.java index 16c6c9ae..e266a0a1 100644 --- a/src/main/java/com/songoda/skyblock/island/Island.java +++ b/src/main/java/com/songoda/skyblock/island/Island.java @@ -134,14 +134,14 @@ public class Island { Config settingsDataConfig = null; File settingDataFile = new File(skyblock.getDataFolder().toString() + "/setting-data", getOwnerUUID().toString() + ".yml"); - + if (fileManager.isFileExist(settingDataFile)) { settingsDataConfig = fileManager.getConfig(settingDataFile); } for (IslandRole roleList : IslandRole.getRoles()) { List settings = new ArrayList<>(); - + for (String settingList : defaultSettingsConfig.getFileConfiguration().getConfigurationSection("Settings." + roleList.name()).getKeys(false)) { if (settingsDataConfig == null || settingsDataConfig.getFileConfiguration().getString("Settings." + roleList.name() + "." + settingList) == null) { settings.add( @@ -353,17 +353,17 @@ public class Island { public boolean isInBorder(Location blockLocation) { WorldManager worldManager = skyblock.getWorldManager(); - if(!isBorder()) { + if (!isBorder()) { return true; } Location islandLocation = getLocation(worldManager.getIslandWorld(blockLocation.getWorld()), IslandEnvironment.Island); double halfSize = Math.floor(getRadius()); - if(blockLocation.getBlockX() > (islandLocation.getBlockX()+halfSize) - || blockLocation.getBlockX() < (islandLocation.getBlockX()-halfSize-1) - || blockLocation.getBlockZ() > (islandLocation.getBlockZ()+halfSize) - || blockLocation.getBlockZ() < (islandLocation.getBlockZ()-halfSize-1)) { + if (blockLocation.getBlockX() > (islandLocation.getBlockX() + halfSize) + || blockLocation.getBlockX() < (islandLocation.getBlockX() - halfSize - 1) + || blockLocation.getBlockZ() > (islandLocation.getBlockZ() + halfSize) + || blockLocation.getBlockZ() < (islandLocation.getBlockZ() - halfSize - 1)) { return false; } @@ -413,10 +413,14 @@ public class Island { WeatherType weatherType; - if (weatherTypeName == null || weatherTypeName.isEmpty() || WeatherType.valueOf(weatherTypeName) == null) { + if (weatherTypeName == null || weatherTypeName.isEmpty()) { weatherType = WeatherType.CLEAR; } else { - weatherType = WeatherType.valueOf(weatherTypeName); + try { + weatherType = WeatherType.valueOf(weatherTypeName); + } catch (IllegalArgumentException e) { + weatherType = WeatherType.CLEAR; + } } return weatherType; @@ -615,10 +619,10 @@ public class Island { } public boolean hasUpgrade(Upgrade.Type type) { - return skyblock.getFileManager().getConfig( - new File(new File(skyblock.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")) - .getFileConfiguration().getString("Upgrade." + type.name()) != null; - } + return skyblock.getFileManager().getConfig( + new File(new File(skyblock.getDataFolder().toString() + "/island-data"), ownerUUID.toString() + ".yml")) + .getFileConfiguration().getString("Upgrade." + type.name()) != null; + } public boolean isUpgrade(Upgrade.Type type) { return skyblock.getFileManager().getConfig( @@ -735,8 +739,8 @@ public class Island { } public boolean hasStructure() { - return getStructure() != null; - } + return getStructure() != null; + } public String getStructure() { return skyblock.getFileManager().getConfig( @@ -775,13 +779,13 @@ public class Island { Config config = fileManager .getConfig(new File(skyblock.getDataFolder().toString() + "/island-data", ownerUUID.toString() + ".yml")); - + try { config.getFileConfiguration().save(config.getFile()); } catch (IOException e) { e.printStackTrace(); } - + config = fileManager .getConfig(new File(skyblock.getDataFolder().toString() + "/setting-data", ownerUUID.toString() + ".yml")); FileConfiguration configLoad = config.getFileConfiguration(); From 2c86e6e89b681f2cd5323a9e58f2729594bb6c9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wert=C3=ADk?= Date: Tue, 31 Mar 2020 18:15:41 +0200 Subject: [PATCH 4/6] Added check for material loading in Levelling.java --- src/main/java/com/songoda/skyblock/menus/Levelling.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/com/songoda/skyblock/menus/Levelling.java b/src/main/java/com/songoda/skyblock/menus/Levelling.java index c801b47f..8cbf3c63 100644 --- a/src/main/java/com/songoda/skyblock/menus/Levelling.java +++ b/src/main/java/com/songoda/skyblock/menus/Levelling.java @@ -190,6 +190,9 @@ public class Levelling { long value = testIslandMaterials.get(materialName); CompatibleMaterial materials = CompatibleMaterial.getMaterial(materialName); + + if (materials == null) continue; + ItemStack is = materials.getItem(); if (is == null || is.getItemMeta() == null) continue; From eb5e7f3399f920104f0413130289dee8ec5e21e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wert=C3=ADk?= Date: Tue, 31 Mar 2020 22:54:21 +0200 Subject: [PATCH 5/6] Fixed teleportation bug. --- .../songoda/skyblock/listeners/Teleport.java | 34 ++++++++++--------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/listeners/Teleport.java b/src/main/java/com/songoda/skyblock/listeners/Teleport.java index c6b13305..f2841f4d 100644 --- a/src/main/java/com/songoda/skyblock/listeners/Teleport.java +++ b/src/main/java/com/songoda/skyblock/listeners/Teleport.java @@ -74,7 +74,7 @@ public class Teleport implements Listener { event.setCancelled(true); messageManager.sendMessage(player, configLoad.getString("Island.Settings.Permission.Message")); - soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F); + soundManager.playSound(player, CompatibleSound.ENTITY_VILLAGER_NO.getSound(), 1.0F, 1.0F); return; } @@ -176,20 +176,22 @@ public class Teleport implements Listener { } } } - - @EventHandler - public void onEntityTeleport(EntityPortalEvent e) { - WorldManager worldManager = skyblock.getWorldManager(); - // Do not handle player - if (e.getEntityType() == EntityType.PLAYER) - return; - Location from = e.getFrom(); - Location to = e.getTo(); - // Test which world the event is from - if (from.getWorld() == to.getWorld()) - return; - if (worldManager.getIslandWorld(e.getFrom().getWorld()) != null) - e.setCancelled(true); - } + @EventHandler + public void onEntityTeleport(EntityPortalEvent e) { + WorldManager worldManager = skyblock.getWorldManager(); + + // Do not handle player + if (e.getEntityType() == EntityType.PLAYER) + return; + + Location from = e.getFrom(); + Location to = e.getTo(); + + if (to == null || from.getWorld() == to.getWorld()) + return; + + if (worldManager.getIslandWorld(e.getFrom().getWorld()) != null) + e.setCancelled(true); + } } From 1df7eb416a7827a8b19a44faebd29266c39f5d19 Mon Sep 17 00:00:00 2001 From: Brianna Date: Wed, 1 Apr 2020 10:54:22 -0400 Subject: [PATCH 6/6] version 2.2.1 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index a73e39a1..f5f8a505 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 com.songoda skyblock - 2.2 + 2.2.1 clean install FabledSkyblock-${project.version}