Merge branch 'breaking' of https://github.com/IntellectualSites/PlotSquared into breaking

This commit is contained in:
matt 2019-03-08 19:26:06 -05:00
commit 578069b3c9
2 changed files with 39 additions and 14 deletions

View File

@ -10,12 +10,10 @@ import com.github.intellectualsites.plotsquared.plot.config.Settings;
import com.github.intellectualsites.plotsquared.plot.flag.Flags; import com.github.intellectualsites.plotsquared.plot.flag.Flags;
import com.github.intellectualsites.plotsquared.plot.listener.PlayerBlockEventType; import com.github.intellectualsites.plotsquared.plot.listener.PlayerBlockEventType;
import com.github.intellectualsites.plotsquared.plot.listener.PlotListener; import com.github.intellectualsites.plotsquared.plot.listener.PlotListener;
import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.*; import com.github.intellectualsites.plotsquared.plot.object.*;
import com.github.intellectualsites.plotsquared.plot.util.*; import com.github.intellectualsites.plotsquared.plot.util.*;
import org.bukkit.Bukkit; import org.bukkit.*;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState; import org.bukkit.block.BlockState;
@ -1762,7 +1760,32 @@ import java.util.regex.Pattern;
blox -> !plot.equals(area.getOwnedPlot(BukkitUtil.getLocation(blox.getLocation())))); blox -> !plot.equals(area.getOwnedPlot(BukkitUtil.getLocation(blox.getLocation()))));
} }
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) @EventHandler(priority = EventPriority.LOW)
public void onCancelledInteract(PlayerInteractEvent event) {
if (event.isCancelled() && event.getAction() == Action.RIGHT_CLICK_AIR) {
Player player = event.getPlayer();
PlotPlayer pp = BukkitUtil.getPlayer(player);
PlotArea area = pp.getPlotAreaAbs();
if (area == null) {
return;
}
Material type = player.getInventory().getItemInMainHand().getType();
if (type.toString().toLowerCase().endsWith("egg")) {
Block block = player.getTargetBlockExact(5, FluidCollisionMode.SOURCE_ONLY);
if (block != null && block.getType() != Material.AIR) {
Location location = BukkitUtil.getLocation(block.getLocation());
if (!EventUtil.manager
.checkPlayerBlockEvent(pp, PlayerBlockEventType.SPAWN_MOB, location,
new BukkitLazyBlock(PlotBlock.get(type.toString())), true)) {
event.setCancelled(true);
event.setUseItemInHand(Event.Result.DENY);
}
}
}
}
}
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = false)
public void onInteract(PlayerInteractEvent event) { public void onInteract(PlayerInteractEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
PlotPlayer pp = BukkitUtil.getPlayer(player); PlotPlayer pp = BukkitUtil.getPlayer(player);
@ -1935,25 +1958,25 @@ import java.util.regex.Pattern;
} }
ItemStack hand = player.getInventory().getItemInMainHand(); ItemStack hand = player.getInventory().getItemInMainHand();
ItemStack offHand = player.getInventory().getItemInOffHand(); ItemStack offHand = player.getInventory().getItemInOffHand();
Material type = (hand == null) ? null : hand.getType(); Material type = (hand == null) ? Material.AIR : hand.getType();
Material offType = (offHand == null) ? null : offHand.getType(); Material offType = (offHand == null) ? Material.AIR : offHand.getType();
if ((type == Material.AIR && offType != Material.AIR && !player.isSneaking() if ((type == Material.AIR && offType != Material.AIR && !player.isSneaking()
&& blockType.isInteractable()) || (type == Material.AIR && blockType.isInteractable()) || (type == Material.AIR
&& offType == Material.AIR)) { && offType == Material.AIR)) {
eventType = PlayerBlockEventType.INTERACT_BLOCK; eventType = PlayerBlockEventType.INTERACT_BLOCK;
break; break;
} }
if (!(type != null && type.equals(offType))) { if (type == Material.AIR) {
type = offType; type = offType;
} }
if (type == null || type.isBlock()) { if (type.isBlock()) {
location = BukkitUtil location = BukkitUtil
.getLocation(block.getRelative(event.getBlockFace()).getLocation()); .getLocation(block.getRelative(event.getBlockFace()).getLocation());
eventType = PlayerBlockEventType.PLACE_BLOCK; eventType = PlayerBlockEventType.PLACE_BLOCK;
break; break;
} }
lb = new BukkitLazyBlock(PlotBlock.get(type.toString())); lb = new BukkitLazyBlock(PlotBlock.get(type.toString()));
if (type.toString().endsWith("egg")) { if (type.toString().toLowerCase().endsWith("egg")) {
eventType = PlayerBlockEventType.SPAWN_MOB; eventType = PlayerBlockEventType.SPAWN_MOB;
} else { } else {
switch (type) { switch (type) {

View File

@ -10,6 +10,8 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.util.EulerAngle; import org.bukkit.util.EulerAngle;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import java.util.List;
public final class ReplicatingEntityWrapper extends EntityWrapper { public final class ReplicatingEntityWrapper extends EntityWrapper {
private final short depth; private final short depth;
@ -38,9 +40,9 @@ public final class ReplicatingEntityWrapper extends EntityWrapper {
if (depth == 0) { if (depth == 0) {
return; return;
} }
Entity passenger = entity.getPassengers().get(0); List<Entity> passengers = entity.getPassengers();
if (passenger != null) { if (passengers.size() > 0) {
this.base.passenger = new ReplicatingEntityWrapper(passenger, depth); this.base.passenger = new ReplicatingEntityWrapper(passengers.get(0), depth);
} }
this.base.fall = entity.getFallDistance(); this.base.fall = entity.getFallDistance();
this.base.fire = (short) entity.getFireTicks(); this.base.fire = (short) entity.getFireTicks();