mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 05:06:44 +01:00
Merge branch 'v5' of github.com:IntellectualSites/PlotSquared into v5
This commit is contained in:
commit
5e44bb60c6
@ -833,7 +833,6 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain<
|
||||
case "HOGLIN":
|
||||
case "PIGLIN":
|
||||
case "ZOGLIN":
|
||||
break;
|
||||
default: {
|
||||
if (Settings.Enabled_Components.KILL_ROAD_MOBS) {
|
||||
Location location = entity.getLocation();
|
||||
|
@ -230,7 +230,6 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
public static final com.sk89q.worldedit.world.entity.EntityType FAKE_ENTITY_TYPE =
|
||||
new com.sk89q.worldedit.world.entity.EntityType("plotsquared:fake");
|
||||
|
||||
private boolean pistonBlocks = true;
|
||||
private float lastRadius;
|
||||
// To prevent recursion
|
||||
private boolean tmpTeleport = true;
|
||||
@ -822,7 +821,9 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
Player player = event.getPlayer();
|
||||
BukkitPlayer pp = BukkitUtil.getPlayer(player);
|
||||
// Cancel teleport
|
||||
TaskManager.TELEPORT_QUEUE.remove(pp.getName());
|
||||
if (TaskManager.TELEPORT_QUEUE.remove(pp.getName())) {
|
||||
MainUtil.sendMessage(pp, Captions.TELEPORT_FAILED);
|
||||
}
|
||||
// Set last location
|
||||
Location location = BukkitUtil.getLocation(to);
|
||||
pp.setMeta(PlotPlayer.META_LOCATION, location);
|
||||
@ -882,7 +883,9 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
Player player = event.getPlayer();
|
||||
BukkitPlayer pp = BukkitUtil.getPlayer(player);
|
||||
// Cancel teleport
|
||||
TaskManager.TELEPORT_QUEUE.remove(pp.getName());
|
||||
if (TaskManager.TELEPORT_QUEUE.remove(pp.getName())) {
|
||||
MainUtil.sendMessage(pp, Captions.TELEPORT_FAILED);
|
||||
}
|
||||
// Set last location
|
||||
Location location = BukkitUtil.getLocation(to);
|
||||
pp.setMeta(PlotPlayer.META_LOCATION, location);
|
||||
@ -1510,7 +1513,63 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
return;
|
||||
}
|
||||
for (Block block1 : event.getBlocks()) {
|
||||
if (BukkitUtil.getLocation(block1.getLocation().add(relative)).isPlotArea()) {
|
||||
Location bloc = BukkitUtil.getLocation(block1.getLocation());
|
||||
if (bloc.isPlotArea() || bloc.add(relative.getBlockX(),
|
||||
relative.getBlockY(), relative.getBlockZ()).isPlotArea()) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (location.add(relative.getBlockX(), relative.getBlockY(), relative.getBlockZ())
|
||||
.isPlotArea()) {
|
||||
// Prevent pistons from extending if they are: bordering a plot
|
||||
// area, facing inside plot area, and not pushing any blocks
|
||||
event.setCancelled(true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
Plot plot = area.getOwnedPlot(location);
|
||||
if (plot == null) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
for (Block block1 : event.getBlocks()) {
|
||||
Location bloc = BukkitUtil.getLocation(block1.getLocation());
|
||||
if (!area.contains(bloc.getX(), bloc.getZ()) || !area
|
||||
.contains(bloc.getX() + relative.getBlockX(), bloc.getZ() + relative.getBlockZ())) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (!plot.equals(area.getOwnedPlot(bloc)) || !plot.equals(area.getOwnedPlot(
|
||||
bloc.add(relative.getBlockX(), relative.getBlockY(), relative.getBlockZ())))) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!plot.equals(area.getOwnedPlot(location.add(
|
||||
relative.getBlockX(), relative.getBlockY(), relative.getBlockZ())))) {
|
||||
// This branch is only necessary to prevent pistons from extending
|
||||
// if they are: on a plot edge, facing outside the plot, and not
|
||||
// pushing any blocks
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onBlockPistonRetract(BlockPistonRetractEvent event) {
|
||||
Block block = event.getBlock();
|
||||
Location location = BukkitUtil.getLocation(block.getLocation());
|
||||
BlockFace face = event.getDirection();
|
||||
Vector relative = new Vector(face.getModX(), face.getModY(), face.getModZ());
|
||||
PlotArea area = location.getPlotArea();
|
||||
if (area == null) {
|
||||
if (!PlotSquared.get().hasPlotArea(location.getWorld())) {
|
||||
return;
|
||||
}
|
||||
for (Block block1 : event.getBlocks()) {
|
||||
Location bloc = BukkitUtil.getLocation(block1.getLocation());
|
||||
if (bloc.isPlotArea() || bloc.add(relative.getBlockX(),
|
||||
relative.getBlockY(), relative.getBlockZ()).isPlotArea()) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
@ -1537,87 +1596,39 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onBlockPistonRetract(BlockPistonRetractEvent event) {
|
||||
Block block = event.getBlock();
|
||||
Location location = BukkitUtil.getLocation(block.getLocation());
|
||||
PlotArea area = location.getPlotArea();
|
||||
if (area == null) {
|
||||
if (!PlotSquared.get().hasPlotArea(location.getWorld())) {
|
||||
return;
|
||||
}
|
||||
if (this.pistonBlocks) {
|
||||
try {
|
||||
for (Block pulled : event.getBlocks()) {
|
||||
location = BukkitUtil.getLocation(pulled.getLocation());
|
||||
if (location.isPlotArea()) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
} catch (Throwable ignored) {
|
||||
this.pistonBlocks = false;
|
||||
}
|
||||
}
|
||||
if (!this.pistonBlocks && !block.getType().toString().contains("PISTON")) {
|
||||
BlockFace dir = event.getDirection();
|
||||
location = BukkitUtil.getLocation(block.getLocation()
|
||||
.add(dir.getModX() * 2, dir.getModY() * 2, dir.getModZ() * 2));
|
||||
if (location.isPlotArea()) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
Plot plot = area.getOwnedPlot(location);
|
||||
BlockFace dir = event.getDirection();
|
||||
// Location head = location.add(-dir.getModX(), -dir.getModY(), -dir.getModZ());
|
||||
//
|
||||
// if (!Objects.equals(plot, area.getOwnedPlot(head))) {
|
||||
// // FIXME: cancelling the event doesn't work here. See issue #1484
|
||||
// event.setCancelled(true);
|
||||
// return;
|
||||
// }
|
||||
if (this.pistonBlocks) {
|
||||
try {
|
||||
for (Block pulled : event.getBlocks()) {
|
||||
Location from = BukkitUtil.getLocation(
|
||||
pulled.getLocation().add(dir.getModX(), dir.getModY(), dir.getModZ()));
|
||||
Location to = BukkitUtil.getLocation(pulled.getLocation());
|
||||
if (!area.contains(to.getX(), to.getZ())) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
Plot fromPlot = area.getOwnedPlot(from);
|
||||
Plot toPlot = area.getOwnedPlot(to);
|
||||
if (!Objects.equals(fromPlot, toPlot)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
} catch (Throwable ignored) {
|
||||
this.pistonBlocks = false;
|
||||
}
|
||||
}
|
||||
if (!this.pistonBlocks && !block.getType().toString().contains("PISTON")) {
|
||||
location = BukkitUtil.getLocation(
|
||||
block.getLocation().add(dir.getModX() * 2, dir.getModY() * 2, dir.getModZ() * 2));
|
||||
if (!area.contains(location)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
Plot newPlot = area.getOwnedPlot(location);
|
||||
if (!Objects.equals(plot, newPlot)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onBlockDispense(BlockDispenseEvent event) {
|
||||
Material type = event.getItem().getType();
|
||||
switch (type) {
|
||||
case SHULKER_BOX:
|
||||
case WHITE_SHULKER_BOX:
|
||||
case ORANGE_SHULKER_BOX:
|
||||
case MAGENTA_SHULKER_BOX:
|
||||
case LIGHT_BLUE_SHULKER_BOX:
|
||||
case YELLOW_SHULKER_BOX:
|
||||
case LIME_SHULKER_BOX:
|
||||
case PINK_SHULKER_BOX:
|
||||
case GRAY_SHULKER_BOX:
|
||||
case LIGHT_GRAY_SHULKER_BOX:
|
||||
case CYAN_SHULKER_BOX:
|
||||
case PURPLE_SHULKER_BOX:
|
||||
case BLUE_SHULKER_BOX:
|
||||
case BROWN_SHULKER_BOX:
|
||||
case GREEN_SHULKER_BOX:
|
||||
case RED_SHULKER_BOX:
|
||||
case BLACK_SHULKER_BOX:
|
||||
case CARVED_PUMPKIN:
|
||||
case WITHER_SKELETON_SKULL:
|
||||
case FLINT_AND_STEEL:
|
||||
case BONE_MEAL:
|
||||
case SHEARS:
|
||||
case GLASS_BOTTLE:
|
||||
case GLOWSTONE:
|
||||
case COD_BUCKET:
|
||||
case PUFFERFISH_BUCKET:
|
||||
case SALMON_BUCKET:
|
||||
case TROPICAL_FISH_BUCKET:
|
||||
case BUCKET:
|
||||
case WATER_BUCKET:
|
||||
case LAVA_BUCKET: {
|
||||
if (event.getBlock().getType() == Material.DROPPER) {
|
||||
|
@ -26,17 +26,16 @@
|
||||
package com.plotsquared.bukkit.placeholder;
|
||||
|
||||
import com.plotsquared.core.PlotSquared;
|
||||
import com.plotsquared.core.configuration.Settings;
|
||||
import com.plotsquared.core.player.PlotPlayer;
|
||||
import com.plotsquared.core.plot.Plot;
|
||||
import com.plotsquared.core.plot.flag.GlobalFlagContainer;
|
||||
import com.plotsquared.core.plot.flag.PlotFlag;
|
||||
import com.plotsquared.core.util.MainUtil;
|
||||
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
public class Placeholders extends PlaceholderExpansion {
|
||||
@ -117,23 +116,16 @@ public class Placeholders extends PlaceholderExpansion {
|
||||
return plot.getAlias();
|
||||
}
|
||||
case "currentplot_owner": {
|
||||
final Set<UUID> o = plot.getOwners();
|
||||
if (o == null || o.isEmpty()) {
|
||||
return "";
|
||||
}
|
||||
final UUID uid = (UUID) o.toArray()[0];
|
||||
if (uid == null) {
|
||||
final UUID plotOwner = plot.getOwnerAbs();
|
||||
if (plotOwner == null) {
|
||||
return "";
|
||||
}
|
||||
|
||||
String name = PlotSquared.get().getImpromptuUUIDPipeline()
|
||||
.getSingle(uid, Settings.UUID.BLOCKING_TIMEOUT);
|
||||
try {
|
||||
return MainUtil.getName(plotOwner, false);
|
||||
} catch (final Exception ignored) {}
|
||||
|
||||
if (name != null) {
|
||||
return name;
|
||||
}
|
||||
|
||||
name = Bukkit.getOfflinePlayer(uid).getName();
|
||||
final String name = Bukkit.getOfflinePlayer(plotOwner).getName();
|
||||
return name != null ? name : "unknown";
|
||||
}
|
||||
case "currentplot_members": {
|
||||
|
@ -26,6 +26,8 @@
|
||||
package com.plotsquared.bukkit.uuid;
|
||||
|
||||
import com.google.common.util.concurrent.RateLimiter;
|
||||
import com.plotsquared.core.PlotSquared;
|
||||
import com.plotsquared.core.configuration.Captions;
|
||||
import com.plotsquared.core.uuid.UUIDMapping;
|
||||
import com.plotsquared.core.uuid.UUIDService;
|
||||
import com.sk89q.squirrelid.Profile;
|
||||
@ -35,6 +37,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@ -64,10 +67,29 @@ public class SquirrelIdUUIDService implements UUIDService {
|
||||
@Override @NotNull public List<UUIDMapping> getNames(@NotNull final List<UUID> uuids) {
|
||||
final List<UUIDMapping> results = new ArrayList<>(uuids.size());
|
||||
this.rateLimiter.acquire(uuids.size());
|
||||
try {
|
||||
try {
|
||||
for (final Profile profile : this.profileService.findAllById(uuids)) {
|
||||
results.add(new UUIDMapping(profile.getUniqueId(), profile.getName()));
|
||||
}
|
||||
} catch (final IllegalArgumentException illegalArgumentException) {
|
||||
//
|
||||
// This means that the UUID was invalid for whatever reason, we'll try to
|
||||
// go through them one by one
|
||||
//
|
||||
if (uuids.size() >= 2) {
|
||||
PlotSquared.debug(Captions.PREFIX + "(UUID) Found invalid UUID in batch. Will try each UUID individually.");
|
||||
for (final UUID uuid : uuids) {
|
||||
final List<UUIDMapping> result = this.getNames(Collections.singletonList(uuid));
|
||||
if (result.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
results.add(result.get(0));
|
||||
}
|
||||
} else if (uuids.size() == 1) {
|
||||
PlotSquared.debug(Captions.PREFIX + "(UUID) Found invalid UUID: " + uuids.get(0));
|
||||
}
|
||||
}
|
||||
} catch (IOException | InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -34,6 +34,7 @@ import com.sk89q.worldedit.math.BlockVector2;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.khelekore.prtree.MBR;
|
||||
import org.khelekore.prtree.SimpleMBR;
|
||||
|
||||
@ -103,6 +104,16 @@ public class Location implements Cloneable, Comparable<Location> {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a copy of the location. This will pass {@link #equals(Object)}
|
||||
* but will have a different identity.
|
||||
*
|
||||
* @return Copy of the location
|
||||
*/
|
||||
@NotNull public Location copy() {
|
||||
return new Location(this.world, this.x, this.y, this.z, this.yaw, this.pitch);
|
||||
}
|
||||
|
||||
public PlotArea getPlotArea() {
|
||||
return PlotSquared.get().getPlotAreaAbs(this);
|
||||
}
|
||||
@ -179,6 +190,7 @@ public class Location implements Cloneable, Comparable<Location> {
|
||||
this.x += x;
|
||||
this.y += y;
|
||||
this.z += z;
|
||||
this.blockVector3 = BlockVector3.at(this.x, this.y, this.z);
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -220,6 +232,7 @@ public class Location implements Cloneable, Comparable<Location> {
|
||||
this.x -= x;
|
||||
this.y -= y;
|
||||
this.z -= z;
|
||||
this.blockVector3 = BlockVector3.at(this.x, this.y, this.z);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -367,7 +367,7 @@ public abstract class PlotPlayer<P> implements CommandCaller, OfflinePlotPlayer
|
||||
@NotNull public Location getLocation() {
|
||||
Location location = getMeta("location");
|
||||
if (location != null) {
|
||||
return location;
|
||||
return location.copy(); // Always return a copy of the location
|
||||
}
|
||||
return getLocationFull();
|
||||
}
|
||||
|
@ -3010,11 +3010,9 @@ public class Plot {
|
||||
final String name = player.getName();
|
||||
TaskManager.TELEPORT_QUEUE.add(name);
|
||||
TaskManager.runTaskLater(() -> {
|
||||
if (!TaskManager.TELEPORT_QUEUE.contains(name)) {
|
||||
MainUtil.sendMessage(player, Captions.TELEPORT_FAILED);
|
||||
if (!TaskManager.TELEPORT_QUEUE.remove(name)) {
|
||||
return;
|
||||
}
|
||||
TaskManager.TELEPORT_QUEUE.remove(name);
|
||||
if (player.isOnline()) {
|
||||
MainUtil.sendMessage(player, Captions.TELEPORTED_TO_PLOT);
|
||||
player.teleport(location, cause);
|
||||
|
@ -372,10 +372,21 @@ public class MainUtil {
|
||||
/**
|
||||
* Get the name from a UUID.
|
||||
*
|
||||
* @param owner
|
||||
* @param owner Owner UUID
|
||||
* @return The player's name, None, Everyone or Unknown
|
||||
*/
|
||||
@NotNull public static String getName(UUID owner) {
|
||||
@NotNull public static String getName(@Nullable UUID owner) {
|
||||
return getName(owner, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name from a UUID.
|
||||
*
|
||||
* @param owner Owner UUID
|
||||
* @param blocking Whether or not the operation can be blocking
|
||||
* @return The player's name, None, Everyone or Unknown
|
||||
*/
|
||||
@NotNull public static String getName(@Nullable final UUID owner, final boolean blocking) {
|
||||
if (owner == null) {
|
||||
return Captions.NONE.getTranslated();
|
||||
}
|
||||
@ -385,7 +396,17 @@ public class MainUtil {
|
||||
if (owner.equals(DBFunc.SERVER)) {
|
||||
return Captions.SERVER.getTranslated();
|
||||
}
|
||||
String name = PlotSquared.get().getImpromptuUUIDPipeline().getSingle(owner, Settings.UUID.BLOCKING_TIMEOUT);
|
||||
final String name;
|
||||
if (blocking) {
|
||||
name = PlotSquared.get().getImpromptuUUIDPipeline().getSingle(owner, Settings.UUID.BLOCKING_TIMEOUT);
|
||||
} else {
|
||||
final UUIDMapping uuidMapping = PlotSquared.get().getImpromptuUUIDPipeline().getImmediately(owner);
|
||||
if (uuidMapping != null) {
|
||||
name = uuidMapping.getUsername();
|
||||
} else {
|
||||
name = null;
|
||||
}
|
||||
}
|
||||
if (name == null) {
|
||||
return Captions.UNKNOWN.getTranslated();
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ ext {
|
||||
git = Grgit.open(dir: new File(rootDir.toString() + "/.git"))
|
||||
}
|
||||
|
||||
def ver = "5.12.4"
|
||||
def ver = "5.12.5"
|
||||
def versuffix = ""
|
||||
ext {
|
||||
if (project.hasProperty("versionsuffix")) {
|
||||
|
Loading…
Reference in New Issue
Block a user