Merge branch 'v5' into v6

This commit is contained in:
dordsor21 2020-12-10 21:28:28 +00:00
commit 18f13b7d15
No known key found for this signature in database
GPG Key ID: 1E53E88969FFCF0B
3 changed files with 32 additions and 14 deletions

View File

@ -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();

View File

@ -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();

View File

@ -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;
}