From 8ad546df6fc60bfef91482abc65788cb27632d23 Mon Sep 17 00:00:00 2001 From: tastybento Date: Tue, 12 Mar 2019 23:52:05 -0700 Subject: [PATCH] Fixes home teleport when in some types of boat Oak and spruce boats were causing errors due to the mismatch between enums for tree species and material names. https://github.com/BentoBoxWorld/BentoBox/issues/606 --- .../bentobox/bentobox/managers/IslandsManager.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main/java/world/bentobox/bentobox/managers/IslandsManager.java b/src/main/java/world/bentobox/bentobox/managers/IslandsManager.java index 910bcc859..6c5001fad 100644 --- a/src/main/java/world/bentobox/bentobox/managers/IslandsManager.java +++ b/src/main/java/world/bentobox/bentobox/managers/IslandsManager.java @@ -15,6 +15,7 @@ import org.bukkit.Bukkit; import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.Material; +import org.bukkit.TreeSpecies; import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; @@ -29,6 +30,8 @@ import org.bukkit.util.Vector; import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jdt.annotation.Nullable; +import com.google.common.collect.ImmutableMap; + import world.bentobox.bentobox.BentoBox; import world.bentobox.bentobox.api.events.IslandBaseEvent; import world.bentobox.bentobox.api.events.island.IslandEvent; @@ -55,6 +58,15 @@ public class IslandsManager { private BentoBox plugin; + // Tree species to boat material map + private final static Map TREE_TO_BOAT = ImmutableMap.builder(). + put(TreeSpecies.ACACIA, Material.ACACIA_BOAT). + put(TreeSpecies.BIRCH, Material.BIRCH_BOAT). + put(TreeSpecies.DARK_OAK, Material.DARK_OAK_BOAT). + put(TreeSpecies.JUNGLE, Material.JUNGLE_BOAT). + put(TreeSpecies.GENERIC, Material.OAK_BOAT). + put(TreeSpecies.REDWOOD, Material.SPRUCE_BOAT).build(); + /** * One island can be spawn, this is the one - otherwise, this value is null */ @@ -594,7 +606,7 @@ public class IslandsManager { player.leaveVehicle(); // Remove the boat so they don't lie around everywhere boat.remove(); - player.getInventory().addItem(new ItemStack(Material.getMaterial(((Boat) boat).getWoodType().toString() + "_BOAT"), 1)); + player.getInventory().addItem(new ItemStack(TREE_TO_BOAT.getOrDefault(((Boat) boat).getWoodType(), Material.OAK_BOAT))); player.updateInventory(); } }