diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEventListener.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEventListener.java index 4c2785200..40feaf4b0 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEventListener.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEventListener.java @@ -92,6 +92,7 @@ import org.bukkit.block.BlockFace; import org.bukkit.block.data.Waterlogged; import org.bukkit.command.PluginCommand; import org.bukkit.entity.ArmorStand; +import org.bukkit.entity.Boat; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; import org.bukkit.entity.HumanEntity; @@ -107,6 +108,7 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.block.Action; import org.bukkit.event.entity.EntityPickupItemEvent; +import org.bukkit.event.entity.EntityPlaceEvent; import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.hanging.HangingBreakByEntityEvent; import org.bukkit.event.hanging.HangingPlaceEvent; @@ -1115,6 +1117,34 @@ public class PlayerEventListener extends PlotListener implements Listener { } } + // Boats can sometimes be placed on interactable blocks such as levers, + // see PS-175. Armor stands, minecarts and end crystals (the other entities + // supported by this event) don't have this issue. + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) + public void onBoatPlace(EntityPlaceEvent event) { + Player player = event.getPlayer(); + if (player == null) { + return; + } + Entity placed = event.getEntity(); + if (!(placed instanceof Boat)) { + return; + } + BukkitPlayer pp = BukkitUtil.getPlayer(player); + PlotArea area = pp.getPlotAreaAbs(); + if (area == null) { + return; + } + PlayerBlockEventType eventType = PlayerBlockEventType.PLACE_VEHICLE; + Block block = event.getBlock(); + BlockType blockType = BukkitAdapter.asBlockType(block.getType()); + Location location = BukkitUtil.getLocation(block.getLocation()); + if (!PlotSquared.get().getEventDispatcher() + .checkPlayerBlockEvent(pp, eventType, location, blockType, true)) { + event.setCancelled(true); + } + } + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onBucketEmpty(PlayerBucketEmptyEvent event) { BlockFace bf = event.getBlockFace(); diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/managers/BukkitWorldManager.java b/Bukkit/src/main/java/com/plotsquared/bukkit/managers/BukkitWorldManager.java index eec3c2b42..a44daadc1 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/managers/BukkitWorldManager.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/managers/BukkitWorldManager.java @@ -63,7 +63,7 @@ import java.util.List; } protected void setGenerator(@Nullable final String worldName, @Nullable final String generator) { - if (generator == null) { + if (generator == null || worldName != null && worldName.contains(".")) { return; } File file = new File("bukkit.yml").getAbsoluteFile(); diff --git a/Core/src/main/java/com/plotsquared/core/command/Owner.java b/Core/src/main/java/com/plotsquared/core/command/Owner.java index ad1f6cec1..f0d5cb704 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Owner.java +++ b/Core/src/main/java/com/plotsquared/core/command/Owner.java @@ -47,7 +47,6 @@ import java.util.Collection; import java.util.Collections; import java.util.Set; import java.util.UUID; -import java.util.concurrent.TimeoutException; import java.util.function.Consumer; @CommandDeclaration(command = "setowner", @@ -176,18 +175,7 @@ public class Owner extends SetCommand { } catch (Exception ignored) { } } else { - PlotSquared.get().getImpromptuUUIDPipeline().getSingle(value, (uuid, throwable) -> { - if (throwable instanceof TimeoutException) { - player.sendMessage(TranslatableCaption.of("players.fetching_players_timeout")); - } else if (throwable != null) { - player.sendMessage( - TranslatableCaption.of("errors.invalid_player"), - Template.of("value", value) - ); - } else { - uuidConsumer.accept(uuid); - } - }); + PlotSquared.get().getImpromptuUUIDPipeline().getSingle(value, (uuid, throwable) -> uuidConsumer.accept(uuid)); } return true; }