mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-25 14:46:45 +01:00
Fix a few remaining merge issues (+1 squashed commits)
Squashed commits: [8c6b55dd4] Fix a few remaining merge issues
This commit is contained in:
parent
3180d2ddf2
commit
221d299052
@ -42,6 +42,7 @@ dependencies {
|
|||||||
implementation("net.alpenblock:BungeePerms:4.0-dev-106")
|
implementation("net.alpenblock:BungeePerms:4.0-dev-106")
|
||||||
compile("se.hyperver.hyperverse:Core:0.6.0-SNAPSHOT"){ transitive = false }
|
compile("se.hyperver.hyperverse:Core:0.6.0-SNAPSHOT"){ transitive = false }
|
||||||
compile('com.sk89q:squirrelid:1.0.0-SNAPSHOT'){ transitive = false }
|
compile('com.sk89q:squirrelid:1.0.0-SNAPSHOT'){ transitive = false }
|
||||||
|
compile('be.maximvdw:MVdWPlaceholderAPI:2.1.1-SNAPSHOT'){ transitive = false }
|
||||||
// logging
|
// logging
|
||||||
implementation('org.apache.logging.log4j:log4j-slf4j-impl:2.8.1')
|
implementation('org.apache.logging.log4j:log4j-slf4j-impl:2.8.1')
|
||||||
compile('be.maximvdw:MVdWPlaceholderAPI:3.1.1-SNAPSHOT'){ transitive = false }
|
compile('be.maximvdw:MVdWPlaceholderAPI:3.1.1-SNAPSHOT'){ transitive = false }
|
||||||
|
@ -56,9 +56,12 @@ import com.plotsquared.core.plot.flag.implementations.SnowMeltFlag;
|
|||||||
import com.plotsquared.core.plot.flag.implementations.SoilDryFlag;
|
import com.plotsquared.core.plot.flag.implementations.SoilDryFlag;
|
||||||
import com.plotsquared.core.plot.flag.implementations.VineGrowFlag;
|
import com.plotsquared.core.plot.flag.implementations.VineGrowFlag;
|
||||||
import com.plotsquared.core.plot.flag.types.BlockTypeWrapper;
|
import com.plotsquared.core.plot.flag.types.BlockTypeWrapper;
|
||||||
|
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||||
import com.plotsquared.core.util.MainUtil;
|
import com.plotsquared.core.util.MainUtil;
|
||||||
import com.plotsquared.core.util.Permissions;
|
import com.plotsquared.core.util.Permissions;
|
||||||
import com.plotsquared.core.util.task.TaskManager;
|
import com.plotsquared.core.util.task.TaskManager;
|
||||||
|
import com.plotsquared.core.util.task.TaskTime;
|
||||||
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||||
import com.sk89q.worldedit.world.block.BlockType;
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -96,6 +99,8 @@ import org.bukkit.material.Directional;
|
|||||||
import org.bukkit.projectiles.BlockProjectileSource;
|
import org.bukkit.projectiles.BlockProjectileSource;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
import javax.inject.Inject;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
@ -104,6 +109,14 @@ import java.util.UUID;
|
|||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public class BlockEventListener implements Listener {
|
public class BlockEventListener implements Listener {
|
||||||
|
|
||||||
|
private final PlotAreaManager plotAreaManager;
|
||||||
|
private final WorldEdit worldEdit;
|
||||||
|
|
||||||
|
@Inject public BlockEventListener(@Nonnull final PlotAreaManager plotAreaManager, @Nonnull final WorldEdit worldEdit) {
|
||||||
|
this.plotAreaManager = plotAreaManager;
|
||||||
|
this.worldEdit = worldEdit;
|
||||||
|
}
|
||||||
|
|
||||||
public static void sendBlockChange(final org.bukkit.Location bloc, final BlockData data) {
|
public static void sendBlockChange(final org.bukkit.Location bloc, final BlockData data) {
|
||||||
TaskManager.runTaskLater(() -> {
|
TaskManager.runTaskLater(() -> {
|
||||||
String world = bloc.getWorld().getName();
|
String world = bloc.getWorld().getName();
|
||||||
@ -111,22 +124,21 @@ public class BlockEventListener implements Listener {
|
|||||||
int z = bloc.getBlockZ();
|
int z = bloc.getBlockZ();
|
||||||
int distance = Bukkit.getViewDistance() * 16;
|
int distance = Bukkit.getViewDistance() * 16;
|
||||||
|
|
||||||
for (final PlotPlayer<?> player : PlotSquared.imp().getPlayerManager().getPlayers()) {
|
for (final PlotPlayer<?> player : PlotSquared.platform().getPlayerManager().getPlayers()) {
|
||||||
Location location = player.getLocation();
|
Location location = player.getLocation();
|
||||||
if (location.getWorld().equals(world)) {
|
if (location.getWorldName().equals(world)) {
|
||||||
if (16 * Math.abs(location.getX() - x) / 16 > distance
|
if (16 * Math.abs(location.getX() - x) / 16 > distance || 16 * Math.abs(location.getZ() - z) / 16 > distance) {
|
||||||
|| 16 * Math.abs(location.getZ() - z) / 16 > distance) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
((BukkitPlayer) player).player.sendBlockChange(bloc, data);
|
((BukkitPlayer) player).player.sendBlockChange(bloc, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, 3);
|
}, TaskTime.ticks(3L));
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler public void onRedstoneEvent(BlockRedstoneEvent event) {
|
@EventHandler public void onRedstoneEvent(BlockRedstoneEvent event) {
|
||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
Location location = BukkitUtil.getLocation(block.getLocation());
|
Location location = BukkitUtil.adapt(block.getLocation());
|
||||||
PlotArea area = location.getPlotArea();
|
PlotArea area = location.getPlotArea();
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
return;
|
return;
|
||||||
@ -149,34 +161,31 @@ public class BlockEventListener implements Listener {
|
|||||||
if (plot.isMerged()) {
|
if (plot.isMerged()) {
|
||||||
disable = true;
|
disable = true;
|
||||||
for (UUID owner : plot.getOwners()) {
|
for (UUID owner : plot.getOwners()) {
|
||||||
if (PlotSquared.imp().getPlayerManager().getPlayerIfExists(owner) != null) {
|
if (PlotSquared.platform().getPlayerManager().getPlayerIfExists(owner) != null) {
|
||||||
disable = false;
|
disable = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
disable =
|
disable = PlotSquared.platform().getPlayerManager().getPlayerIfExists(plot.getOwnerAbs()) == null;
|
||||||
PlotSquared.imp().getPlayerManager().getPlayerIfExists(plot.getOwnerAbs())
|
|
||||||
== null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (disable) {
|
if (disable) {
|
||||||
for (UUID trusted : plot.getTrusted()) {
|
for (UUID trusted : plot.getTrusted()) {
|
||||||
if (PlotSquared.imp().getPlayerManager().getPlayerIfExists(trusted) != null) {
|
if (PlotSquared.platform().getPlayerManager().getPlayerIfExists(trusted) != null) {
|
||||||
disable = false;
|
disable = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (disable) {
|
if (disable) {
|
||||||
event.setNewCurrent(0);
|
event.setNewCurrent(0);
|
||||||
plot.debug(
|
plot.debug("Redstone event was cancelled because no trusted player was in the plot");
|
||||||
"Redstone event was cancelled because no trusted player was in the plot");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Settings.Redstone.DISABLE_UNOCCUPIED) {
|
if (Settings.Redstone.DISABLE_UNOCCUPIED) {
|
||||||
for (final PlotPlayer<?> player : PlotSquared.imp().getPlayerManager().getPlayers()) {
|
for (final PlotPlayer<?> player : PlotSquared.platform().getPlayerManager().getPlayers()) {
|
||||||
if (plot.equals(player.getCurrentPlot())) {
|
if (plot.equals(player.getCurrentPlot())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -185,12 +194,11 @@ public class BlockEventListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
|
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST) public void onPhysicsEvent(BlockPhysicsEvent event) {
|
||||||
public void onPhysicsEvent(BlockPhysicsEvent event) {
|
|
||||||
switch (event.getChangedType()) {
|
switch (event.getChangedType()) {
|
||||||
case COMPARATOR: {
|
case COMPARATOR: {
|
||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
Location location = BukkitUtil.getLocation(block.getLocation());
|
Location location = BukkitUtil.adapt(block.getLocation());
|
||||||
if (location.isPlotArea()) {
|
if (location.isPlotArea()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -212,7 +220,7 @@ public class BlockEventListener implements Listener {
|
|||||||
case TURTLE_HELMET:
|
case TURTLE_HELMET:
|
||||||
case TURTLE_SPAWN_EGG: {
|
case TURTLE_SPAWN_EGG: {
|
||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
Location location = BukkitUtil.getLocation(block.getLocation());
|
Location location = BukkitUtil.adapt(block.getLocation());
|
||||||
PlotArea area = location.getPlotArea();
|
PlotArea area = location.getPlotArea();
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
return;
|
return;
|
||||||
@ -233,9 +241,8 @@ public class BlockEventListener implements Listener {
|
|||||||
switch (block.getType()) {
|
switch (block.getType()) {
|
||||||
case PISTON:
|
case PISTON:
|
||||||
case STICKY_PISTON:
|
case STICKY_PISTON:
|
||||||
org.bukkit.block.data.Directional piston =
|
org.bukkit.block.data.Directional piston = (org.bukkit.block.data.Directional) block.getBlockData();
|
||||||
(org.bukkit.block.data.Directional) block.getBlockData();
|
Location location = BukkitUtil.adapt(block.getLocation());
|
||||||
Location location = BukkitUtil.getLocation(block.getLocation());
|
|
||||||
PlotArea area = location.getPlotArea();
|
PlotArea area = location.getPlotArea();
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
return;
|
return;
|
||||||
@ -246,23 +253,22 @@ public class BlockEventListener implements Listener {
|
|||||||
}
|
}
|
||||||
switch (piston.getFacing()) {
|
switch (piston.getFacing()) {
|
||||||
case EAST:
|
case EAST:
|
||||||
location.setX(location.getX() + 1);
|
location = location.add(1, 0, 0);
|
||||||
break;
|
break;
|
||||||
case SOUTH:
|
case SOUTH:
|
||||||
location.setX(location.getX() - 1);
|
location = location.add(-1, 0, 0);
|
||||||
break;
|
break;
|
||||||
case WEST:
|
case WEST:
|
||||||
location.setZ(location.getZ() + 1);
|
location = location.add(0, 0, 1);
|
||||||
break;
|
break;
|
||||||
case NORTH:
|
case NORTH:
|
||||||
location.setZ(location.getZ() - 1);
|
location = location.add(0, 0, -1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Plot newPlot = area.getOwnedPlotAbs(location);
|
Plot newPlot = area.getOwnedPlotAbs(location);
|
||||||
if (!plot.equals(newPlot)) {
|
if (!plot.equals(newPlot)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
plot.debug(
|
plot.debug("Prevented piston update because of invalid edge piston detection");
|
||||||
"Prevented piston update because of invalid edge piston detection");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -271,28 +277,24 @@ public class BlockEventListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void blockCreate(BlockPlaceEvent event) {
|
||||||
public void blockCreate(BlockPlaceEvent event) {
|
Location location = BukkitUtil.adapt(event.getBlock().getLocation());
|
||||||
Location location = BukkitUtil.getLocation(event.getBlock().getLocation());
|
|
||||||
PlotArea area = location.getPlotArea();
|
PlotArea area = location.getPlotArea();
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
BukkitPlayer pp = BukkitUtil.getPlayer(player);
|
BukkitPlayer pp = BukkitUtil.adapt(player);
|
||||||
Plot plot = area.getPlot(location);
|
Plot plot = area.getPlot(location);
|
||||||
if (plot != null) {
|
if (plot != null) {
|
||||||
if ((location.getY() > area.getMaxBuildHeight() || location.getY() < area
|
if ((location.getY() > area.getMaxBuildHeight() || location.getY() < area.getMinBuildHeight()) && !Permissions
|
||||||
.getMinBuildHeight()) && !Permissions
|
|
||||||
.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_HEIGHT_LIMIT)) {
|
.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_HEIGHT_LIMIT)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
MainUtil.sendMessage(pp, Captions.HEIGHT_LIMIT.getTranslated()
|
MainUtil.sendMessage(pp, Captions.HEIGHT_LIMIT.getTranslated().replace("{limit}", String.valueOf(area.getMaxBuildHeight())));
|
||||||
.replace("{limit}", String.valueOf(area.getMaxBuildHeight())));
|
|
||||||
}
|
}
|
||||||
if (!plot.hasOwner()) {
|
if (!plot.hasOwner()) {
|
||||||
if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_UNOWNED)) {
|
if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_UNOWNED)) {
|
||||||
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT,
|
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT, Captions.PERMISSION_ADMIN_BUILD_UNOWNED);
|
||||||
Captions.PERMISSION_ADMIN_BUILD_UNOWNED);
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -300,23 +302,19 @@ public class BlockEventListener implements Listener {
|
|||||||
List<BlockTypeWrapper> place = plot.getFlag(PlaceFlag.class);
|
List<BlockTypeWrapper> place = plot.getFlag(PlaceFlag.class);
|
||||||
if (place != null) {
|
if (place != null) {
|
||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
if (place.contains(
|
if (place.contains(BlockTypeWrapper.get(BukkitAdapter.asBlockType(block.getType())))) {
|
||||||
BlockTypeWrapper.get(BukkitAdapter.asBlockType(block.getType())))) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_OTHER)) {
|
if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_OTHER)) {
|
||||||
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT,
|
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT, Captions.PERMISSION_ADMIN_BUILD_OTHER);
|
||||||
Captions.PERMISSION_ADMIN_BUILD_OTHER);
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
plot.debug(player.getName() + " could not place " + event.getBlock().getType()
|
plot.debug(player.getName() + " could not place " + event.getBlock().getType() + " because of the place flag");
|
||||||
+ " because of the place flag");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) {
|
} else if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) {
|
||||||
if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_OTHER)) {
|
if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_OTHER)) {
|
||||||
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT,
|
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT, Captions.PERMISSION_ADMIN_BUILD_OTHER);
|
||||||
Captions.PERMISSION_ADMIN_BUILD_OTHER);
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -325,45 +323,38 @@ public class BlockEventListener implements Listener {
|
|||||||
Block block = event.getBlockPlaced();
|
Block block = event.getBlockPlaced();
|
||||||
if (block.getType().hasGravity()) {
|
if (block.getType().hasGravity()) {
|
||||||
sendBlockChange(block.getLocation(), block.getBlockData());
|
sendBlockChange(block.getLocation(), block.getBlockData());
|
||||||
plot.debug(event.getBlock().getType()
|
plot.debug(event.getBlock().getType() + " did not fall because of disable-physics = true");
|
||||||
+ " did not fall because of disable-physics = true");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_ROAD)) {
|
} else if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_ROAD)) {
|
||||||
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT,
|
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT, Captions.PERMISSION_ADMIN_BUILD_ROAD);
|
||||||
Captions.PERMISSION_ADMIN_BUILD_ROAD);
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST) public void blockDestroy(BlockBreakEvent event) {
|
@EventHandler(priority = EventPriority.LOWEST) public void blockDestroy(BlockBreakEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
Location location = BukkitUtil.getLocation(event.getBlock().getLocation());
|
Location location = BukkitUtil.adapt(event.getBlock().getLocation());
|
||||||
PlotArea area = location.getPlotArea();
|
PlotArea area = location.getPlotArea();
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Plot plot = area.getPlot(location);
|
Plot plot = area.getPlot(location);
|
||||||
if (plot != null) {
|
if (plot != null) {
|
||||||
BukkitPlayer plotPlayer = BukkitUtil.getPlayer(player);
|
BukkitPlayer plotPlayer = BukkitUtil.adapt(player);
|
||||||
if (event.getBlock().getY() == 0) {
|
if (event.getBlock().getY() == 0) {
|
||||||
if (!Permissions
|
if (!Permissions.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_DESTROY_GROUNDLEVEL)) {
|
||||||
.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_DESTROY_GROUNDLEVEL)) {
|
MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT, Captions.PERMISSION_ADMIN_DESTROY_GROUNDLEVEL);
|
||||||
MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT,
|
|
||||||
Captions.PERMISSION_ADMIN_DESTROY_GROUNDLEVEL);
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else if ((location.getY() > area.getMaxBuildHeight() || location.getY() < area
|
} else if ((location.getY() > area.getMaxBuildHeight() || location.getY() < area.getMinBuildHeight()) && !Permissions
|
||||||
.getMinBuildHeight()) && !Permissions
|
|
||||||
.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_BUILD_HEIGHT_LIMIT)) {
|
.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_BUILD_HEIGHT_LIMIT)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
MainUtil.sendMessage(plotPlayer, Captions.HEIGHT_LIMIT.getTranslated()
|
MainUtil.sendMessage(plotPlayer, Captions.HEIGHT_LIMIT.getTranslated().replace("{limit}", String.valueOf(area.getMaxBuildHeight())));
|
||||||
.replace("{limit}", String.valueOf(area.getMaxBuildHeight())));
|
|
||||||
}
|
}
|
||||||
if (!plot.hasOwner()) {
|
if (!plot.hasOwner()) {
|
||||||
if (!Permissions
|
if (!Permissions.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_DESTROY_UNOWNED, true)) {
|
||||||
.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_DESTROY_UNOWNED, true)) {
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@ -377,42 +368,36 @@ public class BlockEventListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Permissions
|
if (Permissions.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_DESTROY_OTHER)) {
|
||||||
.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_DESTROY_OTHER)) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT,
|
MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT, Captions.PERMISSION_ADMIN_DESTROY_OTHER);
|
||||||
Captions.PERMISSION_ADMIN_DESTROY_OTHER);
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
} else if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) {
|
} else if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) {
|
||||||
if (!Permissions.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_BUILD_OTHER)) {
|
if (!Permissions.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_BUILD_OTHER)) {
|
||||||
MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT,
|
MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT, Captions.PERMISSION_ADMIN_BUILD_OTHER);
|
||||||
Captions.PERMISSION_ADMIN_BUILD_OTHER);
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
BukkitPlayer pp = BukkitUtil.getPlayer(player);
|
BukkitPlayer pp = BukkitUtil.adapt(player);
|
||||||
if (Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_DESTROY_ROAD)) {
|
if (Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_DESTROY_ROAD)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (PlotSquared.get().worldedit != null && pp.getAttribute("worldedit")) {
|
if (this.worldEdit != null && pp.getAttribute("worldedit")) {
|
||||||
if (player.getInventory().getItemInMainHand().getType() == Material
|
if (player.getInventory().getItemInMainHand().getType() == Material.getMaterial(this.worldEdit.getConfiguration().wandItem)) {
|
||||||
.getMaterial(PlotSquared.get().worldedit.getConfiguration().wandItem)) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MainUtil
|
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT, Captions.PERMISSION_ADMIN_DESTROY_ROAD);
|
||||||
.sendMessage(pp, Captions.NO_PERMISSION_EVENT, Captions.PERMISSION_ADMIN_DESTROY_ROAD);
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onBlockSpread(BlockSpreadEvent event) {
|
||||||
public void onBlockSpread(BlockSpreadEvent event) {
|
|
||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
Location location = BukkitUtil.getLocation(block.getLocation());
|
Location location = BukkitUtil.adapt(block.getLocation());
|
||||||
if (location.isPlotRoad()) {
|
if (location.isPlotRoad()) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
@ -453,10 +438,9 @@ public class BlockEventListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onBlockForm(BlockFormEvent event) {
|
||||||
public void onBlockForm(BlockFormEvent event) {
|
|
||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
Location location = BukkitUtil.getLocation(block.getLocation());
|
Location location = BukkitUtil.adapt(block.getLocation());
|
||||||
if (location.isPlotRoad()) {
|
if (location.isPlotRoad()) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
@ -487,13 +471,12 @@ public class BlockEventListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onEntityBlockForm(EntityBlockFormEvent event) {
|
||||||
public void onEntityBlockForm(EntityBlockFormEvent event) {
|
|
||||||
String world = event.getBlock().getWorld().getName();
|
String world = event.getBlock().getWorld().getName();
|
||||||
if (!PlotSquared.get().hasPlotArea(world)) {
|
if (!this.plotAreaManager.hasPlotArea(world)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Location location = BukkitUtil.getLocation(event.getBlock().getLocation());
|
Location location = BukkitUtil.adapt(event.getBlock().getLocation());
|
||||||
PlotArea area = location.getPlotArea();
|
PlotArea area = location.getPlotArea();
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
return;
|
return;
|
||||||
@ -507,7 +490,7 @@ public class BlockEventListener implements Listener {
|
|||||||
if (entity instanceof Player) {
|
if (entity instanceof Player) {
|
||||||
Player player = (Player) entity;
|
Player player = (Player) entity;
|
||||||
if (!plot.hasOwner()) {
|
if (!plot.hasOwner()) {
|
||||||
BukkitPlayer plotPlayer = BukkitUtil.getPlayer(player);
|
BukkitPlayer plotPlayer = BukkitUtil.adapt(player);
|
||||||
if (plot.getFlag(IceFormFlag.class)) {
|
if (plot.getFlag(IceFormFlag.class)) {
|
||||||
plot.debug("Ice could not be formed because ice-form = false");
|
plot.debug("Ice could not be formed because ice-form = false");
|
||||||
return;
|
return;
|
||||||
@ -515,7 +498,7 @@ public class BlockEventListener implements Listener {
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
BukkitPlayer plotPlayer = BukkitUtil.getPlayer(player);
|
BukkitPlayer plotPlayer = BukkitUtil.adapt(player);
|
||||||
if (!plot.isAdded(plotPlayer.getUUID())) {
|
if (!plot.isAdded(plotPlayer.getUUID())) {
|
||||||
if (plot.getFlag(IceFormFlag.class)) {
|
if (plot.getFlag(IceFormFlag.class)) {
|
||||||
plot.debug("Ice could not be formed because ice-form = false");
|
plot.debug("Ice could not be formed because ice-form = false");
|
||||||
@ -531,10 +514,9 @@ public class BlockEventListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onBlockDamage(BlockDamageEvent event) {
|
||||||
public void onBlockDamage(BlockDamageEvent event) {
|
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
Location location = BukkitUtil.getLocation(event.getBlock().getLocation());
|
Location location = BukkitUtil.adapt(event.getBlock().getLocation());
|
||||||
PlotArea area = location.getPlotArea();
|
PlotArea area = location.getPlotArea();
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
return;
|
return;
|
||||||
@ -557,42 +539,37 @@ public class BlockEventListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!plot.hasOwner()) {
|
if (!plot.hasOwner()) {
|
||||||
BukkitPlayer plotPlayer = BukkitUtil.getPlayer(player);
|
BukkitPlayer plotPlayer = BukkitUtil.adapt(player);
|
||||||
if (Permissions
|
if (Permissions.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_DESTROY_UNOWNED)) {
|
||||||
.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_DESTROY_UNOWNED)) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
BukkitPlayer plotPlayer = BukkitUtil.getPlayer(player);
|
BukkitPlayer plotPlayer = BukkitUtil.adapt(player);
|
||||||
if (!plot.isAdded(plotPlayer.getUUID())) {
|
if (!plot.isAdded(plotPlayer.getUUID())) {
|
||||||
List<BlockTypeWrapper> destroy = plot.getFlag(BreakFlag.class);
|
List<BlockTypeWrapper> destroy = plot.getFlag(BreakFlag.class);
|
||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
if (destroy
|
if (destroy.contains(BlockTypeWrapper.get(BukkitAdapter.asBlockType(block.getType()))) || Permissions
|
||||||
.contains(BlockTypeWrapper.get(BukkitAdapter.asBlockType(block.getType())))
|
|
||||||
|| Permissions
|
|
||||||
.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_DESTROY_OTHER)) {
|
.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_DESTROY_OTHER)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
plot.debug(player.getName() + " could not break " + block.getType()
|
plot.debug(player.getName() + " could not break " + block.getType() + " because it was not in the break flag");
|
||||||
+ " because it was not in the break flag");
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
BukkitPlayer plotPlayer = BukkitUtil.getPlayer(player);
|
BukkitPlayer plotPlayer = BukkitUtil.adapt(player);
|
||||||
if (Permissions.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_DESTROY_ROAD)) {
|
if (Permissions.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_DESTROY_ROAD)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onFade(BlockFadeEvent event) {
|
||||||
public void onFade(BlockFadeEvent event) {
|
|
||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
Location location = BukkitUtil.getLocation(block.getLocation());
|
Location location = BukkitUtil.adapt(block.getLocation());
|
||||||
PlotArea area = location.getPlotArea();
|
PlotArea area = location.getPlotArea();
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
return;
|
return;
|
||||||
@ -649,54 +626,46 @@ public class BlockEventListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onChange(BlockFromToEvent event) {
|
||||||
public void onChange(BlockFromToEvent event) {
|
|
||||||
Block from = event.getBlock();
|
Block from = event.getBlock();
|
||||||
|
|
||||||
// Check liquid flow flag inside of origin plot too
|
// Check liquid flow flag inside of origin plot too
|
||||||
final Location fLocation = BukkitUtil.getLocation(from.getLocation());
|
final Location fLocation = BukkitUtil.adapt(from.getLocation());
|
||||||
final PlotArea fromArea = fLocation.getPlotArea();
|
final PlotArea fromArea = fLocation.getPlotArea();
|
||||||
if (fromArea != null) {
|
if (fromArea != null) {
|
||||||
final Plot plot = fromArea.getOwnedPlot(fLocation);
|
final Plot plot = fromArea.getOwnedPlot(fLocation);
|
||||||
if (plot != null
|
if (plot != null && plot.getFlag(LiquidFlowFlag.class) == LiquidFlowFlag.FlowStatus.DISABLED && event.getBlock().isLiquid()) {
|
||||||
&& plot.getFlag(LiquidFlowFlag.class) == LiquidFlowFlag.FlowStatus.DISABLED && event
|
plot.debug("Liquid could now flow because liquid-flow = disabled");
|
||||||
.getBlock().isLiquid()) {
|
|
||||||
plot.debug("Liquid could not flow because liquid-flow = disabled");
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Block to = event.getToBlock();
|
Block to = event.getToBlock();
|
||||||
Location tLocation = BukkitUtil.getLocation(to.getLocation());
|
Location tLocation = BukkitUtil.adapt(to.getLocation());
|
||||||
PlotArea area = tLocation.getPlotArea();
|
PlotArea area = tLocation.getPlotArea();
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Plot plot = area.getOwnedPlot(tLocation);
|
Plot plot = area.getOwnedPlot(tLocation);
|
||||||
if (plot != null) {
|
if (plot != null) {
|
||||||
if (!area.contains(fLocation.getX(), fLocation.getZ()) || !Objects
|
if (!area.contains(fLocation.getX(), fLocation.getZ()) || !Objects.equals(plot, area.getOwnedPlot(fLocation))) {
|
||||||
.equals(plot, area.getOwnedPlot(fLocation))) {
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (plot.getFlag(LiquidFlowFlag.class) == LiquidFlowFlag.FlowStatus.ENABLED && event
|
if (plot.getFlag(LiquidFlowFlag.class) == LiquidFlowFlag.FlowStatus.ENABLED && event.getBlock().isLiquid()) {
|
||||||
.getBlock().isLiquid()) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (plot.getFlag(DisablePhysicsFlag.class)) {
|
if (plot.getFlag(DisablePhysicsFlag.class)) {
|
||||||
plot.debug(event.getBlock().getType()
|
plot.debug(event.getBlock().getType() + " could not update because disable-physics = true");
|
||||||
+ " could not update because disable-physics = true");
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (plot.getFlag(LiquidFlowFlag.class) == LiquidFlowFlag.FlowStatus.DISABLED && event
|
if (plot.getFlag(LiquidFlowFlag.class) == LiquidFlowFlag.FlowStatus.DISABLED && event.getBlock().isLiquid()) {
|
||||||
.getBlock().isLiquid()) {
|
|
||||||
plot.debug("Liquid could not flow because liquid-flow = disabled");
|
plot.debug("Liquid could not flow because liquid-flow = disabled");
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
} else if (!area.contains(fLocation.getX(), fLocation.getZ()) || !Objects
|
} else if (!area.contains(fLocation.getX(), fLocation.getZ()) || !Objects.equals(null, area.getOwnedPlot(fLocation))) {
|
||||||
.equals(null, area.getOwnedPlot(fLocation))) {
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
} else if (event.getBlock().isLiquid()) {
|
} else if (event.getBlock().isLiquid()) {
|
||||||
final org.bukkit.Location location = event.getBlock().getLocation();
|
final org.bukkit.Location location = event.getBlock().getLocation();
|
||||||
@ -704,7 +673,6 @@ public class BlockEventListener implements Listener {
|
|||||||
/*
|
/*
|
||||||
X = block location
|
X = block location
|
||||||
A-H = potential plot locations
|
A-H = potential plot locations
|
||||||
|
|
||||||
Z
|
Z
|
||||||
^
|
^
|
||||||
| A B C
|
| A B C
|
||||||
@ -713,50 +681,46 @@ public class BlockEventListener implements Listener {
|
|||||||
v
|
v
|
||||||
<-----O-----> x
|
<-----O-----> x
|
||||||
*/
|
*/
|
||||||
if (BukkitUtil.getPlot(location.clone().add(-1, 0, 1) /* A */) != null
|
if (BukkitUtil.adapt(location.clone().add(-1, 0, 1) /* A */).getPlot() != null
|
||||||
|| BukkitUtil.getPlot(location.clone().add(1, 0, 0) /* B */) != null
|
|| BukkitUtil.adapt(location.clone().add(1, 0, 0) /* B */).getPlot() != null
|
||||||
|| BukkitUtil.getPlot(location.clone().add(1, 0, 1) /* C */) != null
|
|| BukkitUtil.adapt(location.clone().add(1, 0, 1) /* C */).getPlot() != null
|
||||||
|| BukkitUtil.getPlot(location.clone().add(-1, 0, 0) /* D */) != null
|
|| BukkitUtil.adapt(location.clone().add(-1, 0, 0) /* D */).getPlot() != null
|
||||||
|| BukkitUtil.getPlot(location.clone().add(1, 0, 0) /* E */) != null
|
|| BukkitUtil.adapt(location.clone().add(1, 0, 0) /* E */).getPlot() != null
|
||||||
|| BukkitUtil.getPlot(location.clone().add(-1, 0, -1) /* F */) != null
|
|| BukkitUtil.adapt(location.clone().add(-1, 0, -1) /* F */).getPlot() != null
|
||||||
|| BukkitUtil.getPlot(location.clone().add(0, 0, -1) /* G */) != null
|
|| BukkitUtil.adapt(location.clone().add(0, 0, -1) /* G */).getPlot() != null
|
||||||
|| BukkitUtil.getPlot(location.clone().add(1, 0, 1) /* H */) != null) {
|
|| BukkitUtil.adapt(location.clone().add(1, 0, 1) /* H */).getPlot() != null) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
|
||||||
public void onGrow(BlockGrowEvent event) {
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onGrow(BlockGrowEvent event) {
|
||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
Location location = BukkitUtil.getLocation(block.getLocation());
|
Location location = BukkitUtil.adapt(block.getLocation());
|
||||||
if (location.isUnownedPlotArea()) {
|
if (location.isUnownedPlotArea()) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onBlockPistonExtend(BlockPistonExtendEvent event) {
|
||||||
public void onBlockPistonExtend(BlockPistonExtendEvent event) {
|
|
||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
Location location = BukkitUtil.getLocation(block.getLocation());
|
Location location = BukkitUtil.adapt(block.getLocation());
|
||||||
BlockFace face = event.getDirection();
|
BlockFace face = event.getDirection();
|
||||||
Vector relative = new Vector(face.getModX(), face.getModY(), face.getModZ());
|
Vector relative = new Vector(face.getModX(), face.getModY(), face.getModZ());
|
||||||
PlotArea area = location.getPlotArea();
|
PlotArea area = location.getPlotArea();
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
if (!PlotSquared.get().hasPlotArea(location.getWorld())) {
|
if (!this.plotAreaManager.hasPlotArea(location.getWorldName())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (Block block1 : event.getBlocks()) {
|
for (Block block1 : event.getBlocks()) {
|
||||||
Location bloc = BukkitUtil.getLocation(block1.getLocation());
|
Location bloc = BukkitUtil.adapt(block1.getLocation());
|
||||||
if (bloc.isPlotArea() || bloc
|
if (bloc.isPlotArea() || bloc.add(relative.getBlockX(), relative.getBlockY(), relative.getBlockZ()).isPlotArea()) {
|
||||||
.add(relative.getBlockX(), relative.getBlockY(), relative.getBlockZ())
|
|
||||||
.isPlotArea()) {
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (location.add(relative.getBlockX(), relative.getBlockY(), relative.getBlockZ())
|
if (location.add(relative.getBlockX(), relative.getBlockY(), relative.getBlockZ()).isPlotArea()) {
|
||||||
.isPlotArea()) {
|
|
||||||
// Prevent pistons from extending if they are: bordering a plot
|
// Prevent pistons from extending if they are: bordering a plot
|
||||||
// area, facing inside plot area, and not pushing any blocks
|
// area, facing inside plot area, and not pushing any blocks
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@ -769,20 +733,18 @@ public class BlockEventListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (Block block1 : event.getBlocks()) {
|
for (Block block1 : event.getBlocks()) {
|
||||||
Location bloc = BukkitUtil.getLocation(block1.getLocation());
|
Location bloc = BukkitUtil.adapt(block1.getLocation());
|
||||||
if (!area.contains(bloc.getX(), bloc.getZ()) || !area
|
if (!area.contains(bloc.getX(), bloc.getZ()) || !area.contains(bloc.getX() + relative.getBlockX(), bloc.getZ() + relative.getBlockZ())) {
|
||||||
.contains(bloc.getX() + relative.getBlockX(), bloc.getZ() + relative.getBlockZ())) {
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!plot.equals(area.getOwnedPlot(bloc)) || !plot.equals(area.getOwnedPlot(
|
if (!plot.equals(area.getOwnedPlot(bloc)) || !plot
|
||||||
bloc.add(relative.getBlockX(), relative.getBlockY(), relative.getBlockZ())))) {
|
.equals(area.getOwnedPlot(bloc.add(relative.getBlockX(), relative.getBlockY(), relative.getBlockZ())))) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!plot.equals(area.getOwnedPlot(
|
if (!plot.equals(area.getOwnedPlot(location.add(relative.getBlockX(), relative.getBlockY(), relative.getBlockZ())))) {
|
||||||
location.add(relative.getBlockX(), relative.getBlockY(), relative.getBlockZ())))) {
|
|
||||||
// This branch is only necessary to prevent pistons from extending
|
// This branch is only necessary to prevent pistons from extending
|
||||||
// if they are: on a plot edge, facing outside the plot, and not
|
// if they are: on a plot edge, facing outside the plot, and not
|
||||||
// pushing any blocks
|
// pushing any blocks
|
||||||
@ -790,22 +752,19 @@ public class BlockEventListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onBlockPistonRetract(BlockPistonRetractEvent event) {
|
||||||
public void onBlockPistonRetract(BlockPistonRetractEvent event) {
|
|
||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
Location location = BukkitUtil.getLocation(block.getLocation());
|
Location location = BukkitUtil.adapt(block.getLocation());
|
||||||
BlockFace face = event.getDirection();
|
BlockFace face = event.getDirection();
|
||||||
Vector relative = new Vector(face.getModX(), face.getModY(), face.getModZ());
|
Vector relative = new Vector(face.getModX(), face.getModY(), face.getModZ());
|
||||||
PlotArea area = location.getPlotArea();
|
PlotArea area = location.getPlotArea();
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
if (!PlotSquared.get().hasPlotArea(location.getWorld())) {
|
if (!this.plotAreaManager.hasPlotArea(location.getWorldName())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (Block block1 : event.getBlocks()) {
|
for (Block block1 : event.getBlocks()) {
|
||||||
Location bloc = BukkitUtil.getLocation(block1.getLocation());
|
Location bloc = BukkitUtil.adapt(block1.getLocation());
|
||||||
if (bloc.isPlotArea() || bloc
|
if (bloc.isPlotArea() || bloc.add(relative.getBlockX(), relative.getBlockY(), relative.getBlockZ()).isPlotArea()) {
|
||||||
.add(relative.getBlockX(), relative.getBlockY(), relative.getBlockZ())
|
|
||||||
.isPlotArea()) {
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -818,22 +777,20 @@ public class BlockEventListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (Block block1 : event.getBlocks()) {
|
for (Block block1 : event.getBlocks()) {
|
||||||
Location bloc = BukkitUtil.getLocation(block1.getLocation());
|
Location bloc = BukkitUtil.adapt(block1.getLocation());
|
||||||
if (!area.contains(bloc.getX(), bloc.getZ()) || !area
|
if (!area.contains(bloc.getX(), bloc.getZ()) || !area.contains(bloc.getX() + relative.getBlockX(), bloc.getZ() + relative.getBlockZ())) {
|
||||||
.contains(bloc.getX() + relative.getBlockX(), bloc.getZ() + relative.getBlockZ())) {
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!plot.equals(area.getOwnedPlot(bloc)) || !plot.equals(area.getOwnedPlot(
|
if (!plot.equals(area.getOwnedPlot(bloc)) || !plot
|
||||||
bloc.add(relative.getBlockX(), relative.getBlockY(), relative.getBlockZ())))) {
|
.equals(area.getOwnedPlot(bloc.add(relative.getBlockX(), relative.getBlockY(), relative.getBlockZ())))) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onBlockDispense(BlockDispenseEvent event) {
|
||||||
public void onBlockDispense(BlockDispenseEvent event) {
|
|
||||||
Material type = event.getItem().getType();
|
Material type = event.getItem().getType();
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case SHULKER_BOX:
|
case SHULKER_BOX:
|
||||||
@ -870,10 +827,8 @@ public class BlockEventListener implements Listener {
|
|||||||
if (event.getBlock().getType() == Material.DROPPER) {
|
if (event.getBlock().getType() == Material.DROPPER) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
BlockFace targetFace =
|
BlockFace targetFace = ((Directional) event.getBlock().getState().getData()).getFacing();
|
||||||
((Directional) event.getBlock().getState().getData()).getFacing();
|
Location location = BukkitUtil.adapt(event.getBlock().getRelative(targetFace).getLocation());
|
||||||
Location location =
|
|
||||||
BukkitUtil.getLocation(event.getBlock().getRelative(targetFace).getLocation());
|
|
||||||
if (location.isPlotRoad()) {
|
if (location.isPlotRoad()) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
@ -881,20 +836,19 @@ public class BlockEventListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onStructureGrow(StructureGrowEvent event) {
|
||||||
public void onStructureGrow(StructureGrowEvent event) {
|
if (!this.plotAreaManager.hasPlotArea(event.getWorld().getName())) {
|
||||||
if (!PlotSquared.get().hasPlotArea(event.getWorld().getName())) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
List<org.bukkit.block.BlockState> blocks = event.getBlocks();
|
List<org.bukkit.block.BlockState> blocks = event.getBlocks();
|
||||||
if (blocks.isEmpty()) {
|
if (blocks.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Location location = BukkitUtil.getLocation(blocks.get(0).getLocation());
|
Location location = BukkitUtil.adapt(blocks.get(0).getLocation());
|
||||||
PlotArea area = location.getPlotArea();
|
PlotArea area = location.getPlotArea();
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
for (int i = blocks.size() - 1; i >= 0; i--) {
|
for (int i = blocks.size() - 1; i >= 0; i--) {
|
||||||
location = BukkitUtil.getLocation(blocks.get(i).getLocation());
|
location = BukkitUtil.adapt(blocks.get(i).getLocation());
|
||||||
if (location.isPlotArea()) {
|
if (location.isPlotArea()) {
|
||||||
blocks.remove(i);
|
blocks.remove(i);
|
||||||
}
|
}
|
||||||
@ -907,7 +861,7 @@ public class BlockEventListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (int i = blocks.size() - 1; i >= 0; i--) {
|
for (int i = blocks.size() - 1; i >= 0; i--) {
|
||||||
location = BukkitUtil.getLocation(blocks.get(i).getLocation());
|
location = BukkitUtil.adapt(blocks.get(i).getLocation());
|
||||||
if (!area.contains(location.getX(), location.getZ())) {
|
if (!area.contains(location.getX(), location.getZ())) {
|
||||||
blocks.remove(i);
|
blocks.remove(i);
|
||||||
continue;
|
continue;
|
||||||
@ -924,7 +878,7 @@ public class BlockEventListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (int i = blocks.size() - 1; i >= 0; i--) {
|
for (int i = blocks.size() - 1; i >= 0; i--) {
|
||||||
location = BukkitUtil.getLocation(blocks.get(i).getLocation());
|
location = BukkitUtil.adapt(blocks.get(i).getLocation());
|
||||||
Plot plot = area.getOwnedPlot(location);
|
Plot plot = area.getOwnedPlot(location);
|
||||||
/*
|
/*
|
||||||
* plot → the base plot of the merged area
|
* plot → the base plot of the merged area
|
||||||
@ -932,26 +886,24 @@ public class BlockEventListener implements Listener {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// Are plot and origin different AND are both plots merged
|
// Are plot and origin different AND are both plots merged
|
||||||
if (plot != null && !Objects.equals(plot, origin) && (!plot.isMerged() && !origin
|
if (!Objects.equals(plot, origin) && (!plot.isMerged() && !origin.isMerged())) {
|
||||||
.isMerged())) {
|
|
||||||
event.getBlocks().remove(i);
|
event.getBlocks().remove(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onBigBoom(BlockExplodeEvent event) {
|
||||||
public void onBigBoom(BlockExplodeEvent event) {
|
|
||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
Location location = BukkitUtil.getLocation(block.getLocation());
|
Location location = BukkitUtil.adapt(block.getLocation());
|
||||||
String world = location.getWorld();
|
String world = location.getWorldName();
|
||||||
if (!PlotSquared.get().hasPlotArea(world)) {
|
if (!this.plotAreaManager.hasPlotArea(world)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
PlotArea area = location.getPlotArea();
|
PlotArea area = location.getPlotArea();
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
Iterator<Block> iterator = event.blockList().iterator();
|
Iterator<Block> iterator = event.blockList().iterator();
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
location = BukkitUtil.getLocation(iterator.next().getLocation());
|
location = BukkitUtil.adapt(iterator.next().getLocation());
|
||||||
if (location.isPlotArea()) {
|
if (location.isPlotArea()) {
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
}
|
}
|
||||||
@ -965,14 +917,12 @@ public class BlockEventListener implements Listener {
|
|||||||
plot.debug("Explosion was cancelled because explosion = false");
|
plot.debug("Explosion was cancelled because explosion = false");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
event.blockList().removeIf(blox -> plot != null && !plot
|
event.blockList().removeIf(blox -> !plot.equals(area.getOwnedPlot(BukkitUtil.adapt(blox.getLocation()))));
|
||||||
.equals(area.getOwnedPlot(BukkitUtil.getLocation(blox.getLocation()))));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onBlockBurn(BlockBurnEvent event) {
|
||||||
public void onBlockBurn(BlockBurnEvent event) {
|
|
||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
Location location = BukkitUtil.getLocation(block.getLocation());
|
Location location = BukkitUtil.adapt(block.getLocation());
|
||||||
|
|
||||||
PlotArea area = location.getPlotArea();
|
PlotArea area = location.getPlotArea();
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
@ -989,13 +939,12 @@ public class BlockEventListener implements Listener {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onBlockIgnite(BlockIgniteEvent event) {
|
||||||
public void onBlockIgnite(BlockIgniteEvent event) {
|
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
Entity ignitingEntity = event.getIgnitingEntity();
|
Entity ignitingEntity = event.getIgnitingEntity();
|
||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
BlockIgniteEvent.IgniteCause igniteCause = event.getCause();
|
BlockIgniteEvent.IgniteCause igniteCause = event.getCause();
|
||||||
Location location1 = BukkitUtil.getLocation(block.getLocation());
|
Location location1 = BukkitUtil.adapt(block.getLocation());
|
||||||
PlotArea area = location1.getPlotArea();
|
PlotArea area = location1.getPlotArea();
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
return;
|
return;
|
||||||
@ -1007,23 +956,20 @@ public class BlockEventListener implements Listener {
|
|||||||
|
|
||||||
Plot plot = area.getOwnedPlot(location1);
|
Plot plot = area.getOwnedPlot(location1);
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
BukkitPlayer pp = BukkitUtil.getPlayer(player);
|
BukkitPlayer pp = BukkitUtil.adapt(player);
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_ROAD)) {
|
if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_ROAD)) {
|
||||||
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT,
|
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT, Captions.PERMISSION_ADMIN_BUILD_ROAD);
|
||||||
Captions.PERMISSION_ADMIN_BUILD_ROAD);
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
} else if (!plot.hasOwner()) {
|
} else if (!plot.hasOwner()) {
|
||||||
if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_UNOWNED)) {
|
if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_UNOWNED)) {
|
||||||
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT,
|
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT, Captions.PERMISSION_ADMIN_BUILD_UNOWNED);
|
||||||
Captions.PERMISSION_ADMIN_BUILD_UNOWNED);
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
} else if (!plot.isAdded(pp.getUUID())) {
|
} else if (!plot.isAdded(pp.getUUID())) {
|
||||||
if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_OTHER)) {
|
if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_OTHER)) {
|
||||||
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT,
|
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT, Captions.PERMISSION_ADMIN_BUILD_OTHER);
|
||||||
Captions.PERMISSION_ADMIN_BUILD_OTHER);
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
} else if (!plot.getFlag(BlockIgnitionFlag.class)) {
|
} else if (!plot.getFlag(BlockIgnitionFlag.class)) {
|
||||||
@ -1046,11 +992,10 @@ public class BlockEventListener implements Listener {
|
|||||||
Location location = null;
|
Location location = null;
|
||||||
if (fireball.getShooter() instanceof Entity) {
|
if (fireball.getShooter() instanceof Entity) {
|
||||||
Entity shooter = (Entity) fireball.getShooter();
|
Entity shooter = (Entity) fireball.getShooter();
|
||||||
location = BukkitUtil.getLocation(shooter.getLocation());
|
location = BukkitUtil.adapt(shooter.getLocation());
|
||||||
} else if (fireball.getShooter() instanceof BlockProjectileSource) {
|
} else if (fireball.getShooter() instanceof BlockProjectileSource) {
|
||||||
Block shooter =
|
Block shooter = ((BlockProjectileSource) fireball.getShooter()).getBlock();
|
||||||
((BlockProjectileSource) fireball.getShooter()).getBlock();
|
location = BukkitUtil.adapt(shooter.getLocation());
|
||||||
location = BukkitUtil.getLocation(shooter.getLocation());
|
|
||||||
}
|
}
|
||||||
if (location != null && !plot.equals(location.getPlot())) {
|
if (location != null && !plot.equals(location.getPlot())) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@ -1060,13 +1005,11 @@ public class BlockEventListener implements Listener {
|
|||||||
|
|
||||||
} else if (event.getIgnitingBlock() != null) {
|
} else if (event.getIgnitingBlock() != null) {
|
||||||
Block ignitingBlock = event.getIgnitingBlock();
|
Block ignitingBlock = event.getIgnitingBlock();
|
||||||
Plot plotIgnited = BukkitUtil.getLocation(ignitingBlock.getLocation()).getPlot();
|
Plot plotIgnited = BukkitUtil.adapt(ignitingBlock.getLocation()).getPlot();
|
||||||
if (igniteCause == BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL && (
|
if (igniteCause == BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL && (!plot.getFlag(BlockIgnitionFlag.class) || plotIgnited == null
|
||||||
!plot.getFlag(BlockIgnitionFlag.class) || plotIgnited == null || !plotIgnited
|
|| !plotIgnited.equals(plot))
|
||||||
.equals(plot)) || (igniteCause == BlockIgniteEvent.IgniteCause.SPREAD
|
|| (igniteCause == BlockIgniteEvent.IgniteCause.SPREAD || igniteCause == BlockIgniteEvent.IgniteCause.LAVA) && (
|
||||||
|| igniteCause == BlockIgniteEvent.IgniteCause.LAVA) && (
|
!plot.getFlag(BlockIgnitionFlag.class) || plotIgnited == null || !plotIgnited.equals(plot))) {
|
||||||
!plot.getFlag(BlockIgnitionFlag.class) || plotIgnited == null || !plotIgnited
|
|
||||||
.equals(plot))) {
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,6 +36,7 @@ import com.plotsquared.core.plot.flag.implementations.DisablePhysicsFlag;
|
|||||||
import com.plotsquared.core.plot.flag.implementations.ExplosionFlag;
|
import com.plotsquared.core.plot.flag.implementations.ExplosionFlag;
|
||||||
import com.plotsquared.core.plot.flag.implementations.InvincibleFlag;
|
import com.plotsquared.core.plot.flag.implementations.InvincibleFlag;
|
||||||
import com.plotsquared.core.plot.flag.implementations.MobPlaceFlag;
|
import com.plotsquared.core.plot.flag.implementations.MobPlaceFlag;
|
||||||
|
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
@ -60,30 +61,34 @@ import org.bukkit.metadata.FixedMetadataValue;
|
|||||||
import org.bukkit.metadata.MetadataValue;
|
import org.bukkit.metadata.MetadataValue;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
import javax.inject.Inject;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public class EntityEventListener implements Listener {
|
public class EntityEventListener implements Listener {
|
||||||
|
|
||||||
|
private final PlotAreaManager plotAreaManager;
|
||||||
private float lastRadius;
|
private float lastRadius;
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@Inject public EntityEventListener(@Nonnull final PlotAreaManager plotAreaManager) {
|
||||||
public void onEntityCombustByEntity(EntityCombustByEntityEvent event) {
|
this.plotAreaManager = plotAreaManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGHEST) public void onEntityCombustByEntity(EntityCombustByEntityEvent event) {
|
||||||
EntityDamageByEntityEvent eventChange =
|
EntityDamageByEntityEvent eventChange =
|
||||||
new EntityDamageByEntityEvent(event.getCombuster(), event.getEntity(),
|
new EntityDamageByEntityEvent(event.getCombuster(), event.getEntity(), EntityDamageEvent.DamageCause.FIRE_TICK, event.getDuration());
|
||||||
EntityDamageEvent.DamageCause.FIRE_TICK, event.getDuration());
|
|
||||||
onEntityDamageByEntityEvent(eventChange);
|
onEntityDamageByEntityEvent(eventChange);
|
||||||
if (eventChange.isCancelled()) {
|
if (eventChange.isCancelled()) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST) public void onEntityDamageByEntityEvent(EntityDamageByEntityEvent event) {
|
||||||
public void onEntityDamageByEntityEvent(EntityDamageByEntityEvent event) {
|
|
||||||
Entity damager = event.getDamager();
|
Entity damager = event.getDamager();
|
||||||
Location location = BukkitUtil.getLocation(damager);
|
Location location = BukkitUtil.adapt(damager.getLocation());
|
||||||
if (!PlotSquared.get().hasPlotArea(location.getWorld())) {
|
if (!this.plotAreaManager.hasPlotArea(location.getWorldName())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Entity victim = event.getEntity();
|
Entity victim = event.getEntity();
|
||||||
@ -110,10 +115,9 @@ public class EntityEventListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void creatureSpawnEvent(CreatureSpawnEvent event) {
|
||||||
public void creatureSpawnEvent(CreatureSpawnEvent event) {
|
|
||||||
Entity entity = event.getEntity();
|
Entity entity = event.getEntity();
|
||||||
Location location = BukkitUtil.getLocation(entity.getLocation());
|
Location location = BukkitUtil.adapt(entity.getLocation());
|
||||||
PlotArea area = location.getPlotArea();
|
PlotArea area = location.getPlotArea();
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
return;
|
return;
|
||||||
@ -180,18 +184,17 @@ public class EntityEventListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
|
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST) public void onEntityFall(EntityChangeBlockEvent event) {
|
||||||
public void onEntityFall(EntityChangeBlockEvent event) {
|
|
||||||
if (event.getEntityType() != EntityType.FALLING_BLOCK) {
|
if (event.getEntityType() != EntityType.FALLING_BLOCK) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
World world = block.getWorld();
|
World world = block.getWorld();
|
||||||
String worldName = world.getName();
|
String worldName = world.getName();
|
||||||
if (!PlotSquared.get().hasPlotArea(worldName)) {
|
if (!this.plotAreaManager.hasPlotArea(worldName)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Location location = BukkitUtil.getLocation(block.getLocation());
|
Location location = BukkitUtil.adapt(block.getLocation());
|
||||||
PlotArea area = location.getPlotArea();
|
PlotArea area = location.getPlotArea();
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
return;
|
return;
|
||||||
@ -199,9 +202,7 @@ public class EntityEventListener implements Listener {
|
|||||||
Plot plot = area.getOwnedPlotAbs(location);
|
Plot plot = area.getOwnedPlotAbs(location);
|
||||||
if (plot == null || plot.getFlag(DisablePhysicsFlag.class)) {
|
if (plot == null || plot.getFlag(DisablePhysicsFlag.class)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
if (plot != null) {
|
|
||||||
plot.debug("Falling block event was cancelled because disable-physics = true");
|
plot.debug("Falling block event was cancelled because disable-physics = true");
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (event.getTo().hasGravity()) {
|
if (event.getTo().hasGravity()) {
|
||||||
@ -216,8 +217,7 @@ public class EntityEventListener implements Listener {
|
|||||||
entity.remove();
|
entity.remove();
|
||||||
}
|
}
|
||||||
} else if (event.getTo() == Material.AIR) {
|
} else if (event.getTo() == Material.AIR) {
|
||||||
event.getEntity()
|
event.getEntity().setMetadata("plot", new FixedMetadataValue((Plugin) PlotSquared.platform(), plot));
|
||||||
.setMetadata("plot", new FixedMetadataValue((Plugin) PlotSquared.get().IMP, plot));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -225,7 +225,7 @@ public class EntityEventListener implements Listener {
|
|||||||
if (event.getEntityType() != EntityType.PLAYER) {
|
if (event.getEntityType() != EntityType.PLAYER) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Location location = BukkitUtil.getLocation(event.getEntity());
|
Location location = BukkitUtil.adapt(event.getEntity().getLocation());
|
||||||
PlotArea area = location.getPlotArea();
|
PlotArea area = location.getPlotArea();
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
return;
|
return;
|
||||||
@ -238,19 +238,17 @@ public class EntityEventListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (plot.getFlag(InvincibleFlag.class)) {
|
if (plot.getFlag(InvincibleFlag.class)) {
|
||||||
plot.debug(
|
plot.debug(event.getEntity().getName() + " could not take damage because invincible = true");
|
||||||
event.getEntity().getName() + " could not take damage because invincible = true");
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onBigBoom(EntityExplodeEvent event) {
|
||||||
public void onBigBoom(EntityExplodeEvent event) {
|
Location location = BukkitUtil.adapt(event.getLocation());
|
||||||
Location location = BukkitUtil.getLocation(event.getLocation());
|
|
||||||
PlotArea area = location.getPlotArea();
|
PlotArea area = location.getPlotArea();
|
||||||
boolean plotArea = location.isPlotArea();
|
boolean plotArea = location.isPlotArea();
|
||||||
if (!plotArea) {
|
if (!plotArea) {
|
||||||
if (!PlotSquared.get().hasPlotArea(location.getWorld())) {
|
if (!this.plotAreaManager.hasPlotArea(location.getWorldName())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@ -266,14 +264,11 @@ public class EntityEventListener implements Listener {
|
|||||||
origin = (Plot) meta.get(0).value();
|
origin = (Plot) meta.get(0).value();
|
||||||
}
|
}
|
||||||
if (this.lastRadius != 0) {
|
if (this.lastRadius != 0) {
|
||||||
List<Entity> nearby = event.getEntity()
|
List<Entity> nearby = event.getEntity().getNearbyEntities(this.lastRadius, this.lastRadius, this.lastRadius);
|
||||||
.getNearbyEntities(this.lastRadius, this.lastRadius, this.lastRadius);
|
|
||||||
for (Entity near : nearby) {
|
for (Entity near : nearby) {
|
||||||
if (near instanceof TNTPrimed || near.getType()
|
if (near instanceof TNTPrimed || near.getType().equals(EntityType.MINECART_TNT)) {
|
||||||
.equals(EntityType.MINECART_TNT)) {
|
|
||||||
if (!near.hasMetadata("plot")) {
|
if (!near.hasMetadata("plot")) {
|
||||||
near.setMetadata("plot",
|
near.setMetadata("plot", new FixedMetadataValue((Plugin) PlotSquared.platform(), plot));
|
||||||
new FixedMetadataValue((Plugin) PlotSquared.get().IMP, plot));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -282,9 +277,8 @@ public class EntityEventListener implements Listener {
|
|||||||
Iterator<Block> iterator = event.blockList().iterator();
|
Iterator<Block> iterator = event.blockList().iterator();
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
Block block = iterator.next();
|
Block block = iterator.next();
|
||||||
location = BukkitUtil.getLocation(block.getLocation());
|
location = BukkitUtil.adapt(block.getLocation());
|
||||||
if (!area.contains(location.getX(), location.getZ()) || (origin != null
|
if (!area.contains(location.getX(), location.getZ()) || !origin.equals(area.getOwnedPlot(location))) {
|
||||||
&& !origin.equals(area.getOwnedPlot(location)))) {
|
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -300,15 +294,13 @@ public class EntityEventListener implements Listener {
|
|||||||
public void onPeskyMobsChangeTheWorldLikeWTFEvent(EntityChangeBlockEvent event) {
|
public void onPeskyMobsChangeTheWorldLikeWTFEvent(EntityChangeBlockEvent event) {
|
||||||
Entity e = event.getEntity();
|
Entity e = event.getEntity();
|
||||||
if (!(e instanceof FallingBlock)) {
|
if (!(e instanceof FallingBlock)) {
|
||||||
Location location = BukkitUtil.getLocation(event.getBlock().getLocation());
|
Location location = BukkitUtil.adapt(event.getBlock().getLocation());
|
||||||
PlotArea area = location.getPlotArea();
|
PlotArea area = location.getPlotArea();
|
||||||
if (area != null) {
|
if (area != null) {
|
||||||
Plot plot = area.getOwnedPlot(location);
|
Plot plot = area.getOwnedPlot(location);
|
||||||
if (plot != null && plot.getFlag(MobPlaceFlag.class)) {
|
if (plot != null && plot.getFlag(MobPlaceFlag.class)) {
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (plot != null) {
|
|
||||||
plot.debug(e.getType() + " could not change block because mob-place = false");
|
plot.debug(e.getType() + " could not change block because mob-place = false");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
@ -319,10 +311,9 @@ public class EntityEventListener implements Listener {
|
|||||||
this.lastRadius = event.getRadius() + 1;
|
this.lastRadius = event.getRadius() + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onVehicleCreate(VehicleCreateEvent event) {
|
||||||
public void onVehicleCreate(VehicleCreateEvent event) {
|
|
||||||
Vehicle entity = event.getVehicle();
|
Vehicle entity = event.getVehicle();
|
||||||
Location location = BukkitUtil.getLocation(entity);
|
Location location = BukkitUtil.adapt(entity.getLocation());
|
||||||
PlotArea area = location.getPlotArea();
|
PlotArea area = location.getPlotArea();
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
return;
|
return;
|
||||||
@ -333,8 +324,7 @@ public class EntityEventListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (Settings.Enabled_Components.KILL_ROAD_VEHICLES) {
|
if (Settings.Enabled_Components.KILL_ROAD_VEHICLES) {
|
||||||
entity
|
entity.setMetadata("plot", new FixedMetadataValue((Plugin) PlotSquared.platform(), plot));
|
||||||
.setMetadata("plot", new FixedMetadataValue((Plugin) PlotSquared.get().IMP, plot));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -54,8 +54,8 @@ import org.bukkit.event.world.ChunkLoadEvent;
|
|||||||
import org.bukkit.metadata.FixedMetadataValue;
|
import org.bukkit.metadata.FixedMetadataValue;
|
||||||
import org.bukkit.metadata.MetadataValue;
|
import org.bukkit.metadata.MetadataValue;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class EntitySpawnListener implements Listener {
|
public class EntitySpawnListener implements Listener {
|
||||||
@ -67,8 +67,7 @@ public class EntitySpawnListener implements Listener {
|
|||||||
|
|
||||||
public static void testNether(final Entity entity) {
|
public static void testNether(final Entity entity) {
|
||||||
@Nonnull World world = entity.getWorld();
|
@Nonnull World world = entity.getWorld();
|
||||||
if (world.getEnvironment() != World.Environment.NETHER
|
if (world.getEnvironment() != World.Environment.NETHER && world.getEnvironment() != World.Environment.THE_END) {
|
||||||
&& world.getEnvironment() != World.Environment.THE_END) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
test(entity);
|
test(entity);
|
||||||
@ -92,8 +91,7 @@ public class EntitySpawnListener implements Listener {
|
|||||||
List<MetadataValue> meta = entity.getMetadata(KEY);
|
List<MetadataValue> meta = entity.getMetadata(KEY);
|
||||||
if (meta.isEmpty()) {
|
if (meta.isEmpty()) {
|
||||||
if (PlotSquared.get().getPlotAreaManager().hasPlotArea(world.getName())) {
|
if (PlotSquared.get().getPlotAreaManager().hasPlotArea(world.getName())) {
|
||||||
entity.setMetadata(KEY,
|
entity.setMetadata(KEY, new FixedMetadataValue((Plugin) PlotSquared.platform(), entity.getLocation()));
|
||||||
new FixedMetadataValue((Plugin) PlotSquared.platform(), entity.getLocation()));
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
org.bukkit.Location origin = (org.bukkit.Location) meta.get(0).value();
|
org.bukkit.Location origin = (org.bukkit.Location) meta.get(0).value();
|
||||||
@ -124,8 +122,7 @@ public class EntitySpawnListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void creatureSpawnEvent(EntitySpawnEvent event) {
|
||||||
public void creatureSpawnEvent(EntitySpawnEvent event) {
|
|
||||||
Entity entity = event.getEntity();
|
Entity entity = event.getEntity();
|
||||||
Location location = BukkitUtil.adapt(entity.getLocation());
|
Location location = BukkitUtil.adapt(entity.getLocation());
|
||||||
PlotArea area = location.getPlotArea();
|
PlotArea area = location.getPlotArea();
|
||||||
@ -161,8 +158,7 @@ public class EntitySpawnListener implements Listener {
|
|||||||
}
|
}
|
||||||
case SHULKER:
|
case SHULKER:
|
||||||
if (!entity.hasMetadata("shulkerPlot")) {
|
if (!entity.hasMetadata("shulkerPlot")) {
|
||||||
entity.setMetadata("shulkerPlot",
|
entity.setMetadata("shulkerPlot", new FixedMetadataValue((Plugin) PlotSquared.platform(), plot.getId()));
|
||||||
new FixedMetadataValue((Plugin) PlotSquared.platform(), plot.getId()));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -193,8 +189,7 @@ public class EntitySpawnListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void vehicleMove(VehicleMoveEvent event) {
|
||||||
public void vehicleMove(VehicleMoveEvent event) {
|
|
||||||
testNether(event.getVehicle());
|
testNether(event.getVehicle());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -27,13 +27,13 @@ package com.plotsquared.bukkit.listener;
|
|||||||
|
|
||||||
import com.plotsquared.bukkit.util.BukkitEntityUtil;
|
import com.plotsquared.bukkit.util.BukkitEntityUtil;
|
||||||
import com.plotsquared.bukkit.util.BukkitUtil;
|
import com.plotsquared.bukkit.util.BukkitUtil;
|
||||||
import com.plotsquared.core.PlotSquared;
|
|
||||||
import com.plotsquared.core.configuration.Captions;
|
import com.plotsquared.core.configuration.Captions;
|
||||||
import com.plotsquared.core.location.Location;
|
import com.plotsquared.core.location.Location;
|
||||||
import com.plotsquared.core.player.PlotPlayer;
|
import com.plotsquared.core.player.PlotPlayer;
|
||||||
import com.plotsquared.core.plot.Plot;
|
import com.plotsquared.core.plot.Plot;
|
||||||
import com.plotsquared.core.plot.PlotArea;
|
import com.plotsquared.core.plot.PlotArea;
|
||||||
import com.plotsquared.core.plot.PlotHandler;
|
import com.plotsquared.core.plot.PlotHandler;
|
||||||
|
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||||
import com.plotsquared.core.util.Permissions;
|
import com.plotsquared.core.util.Permissions;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
@ -50,14 +50,22 @@ import org.bukkit.event.entity.ProjectileLaunchEvent;
|
|||||||
import org.bukkit.projectiles.BlockProjectileSource;
|
import org.bukkit.projectiles.BlockProjectileSource;
|
||||||
import org.bukkit.projectiles.ProjectileSource;
|
import org.bukkit.projectiles.ProjectileSource;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public class ProjectileEventListener implements Listener {
|
public class ProjectileEventListener implements Listener {
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
private final PlotAreaManager plotAreaManager;
|
||||||
public void onPotionSplash(LingeringPotionSplashEvent event) {
|
|
||||||
|
@Inject public ProjectileEventListener(@Nonnull final PlotAreaManager plotAreaManager) {
|
||||||
|
this.plotAreaManager = plotAreaManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onPotionSplash(LingeringPotionSplashEvent event) {
|
||||||
Projectile entity = event.getEntity();
|
Projectile entity = event.getEntity();
|
||||||
Location location = BukkitUtil.getLocation(entity);
|
Location location = BukkitUtil.adapt(entity.getLocation());
|
||||||
if (!PlotSquared.get().hasPlotArea(location.getWorld())) {
|
if (!this.plotAreaManager.hasPlotArea(location.getWorldName())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!this.onProjectileHit(event)) {
|
if (!this.onProjectileHit(event)) {
|
||||||
@ -65,11 +73,10 @@ public class ProjectileEventListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onPotionSplash(PotionSplashEvent event) {
|
||||||
public void onPotionSplash(PotionSplashEvent event) {
|
|
||||||
ThrownPotion damager = event.getPotion();
|
ThrownPotion damager = event.getPotion();
|
||||||
Location location = BukkitUtil.getLocation(damager);
|
Location location = BukkitUtil.adapt(damager.getLocation());
|
||||||
if (!PlotSquared.get().hasPlotArea(location.getWorld())) {
|
if (!this.plotAreaManager.hasPlotArea(location.getWorldName())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int count = 0;
|
int count = 0;
|
||||||
@ -93,11 +100,11 @@ public class ProjectileEventListener implements Listener {
|
|||||||
if (!(shooter instanceof Player)) {
|
if (!(shooter instanceof Player)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Location location = BukkitUtil.getLocation(entity);
|
Location location = BukkitUtil.adapt(entity.getLocation());
|
||||||
if (!PlotSquared.get().hasPlotArea(location.getWorld())) {
|
if (!this.plotAreaManager.hasPlotArea(location.getWorldName())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
PlotPlayer<Player> pp = BukkitUtil.getPlayer((Player) shooter);
|
PlotPlayer<Player> pp = BukkitUtil.adapt((Player) shooter);
|
||||||
Plot plot = location.getOwnedPlot();
|
Plot plot = location.getOwnedPlot();
|
||||||
if (plot != null && !plot.isAdded(pp.getUUID())) {
|
if (plot != null && !plot.isAdded(pp.getUUID())) {
|
||||||
entity.remove();
|
entity.remove();
|
||||||
@ -108,8 +115,8 @@ public class ProjectileEventListener implements Listener {
|
|||||||
@SuppressWarnings({"BooleanMethodIsAlwaysInverted", "cos it's not... dum IntelliJ"}) @EventHandler
|
@SuppressWarnings({"BooleanMethodIsAlwaysInverted", "cos it's not... dum IntelliJ"}) @EventHandler
|
||||||
public boolean onProjectileHit(ProjectileHitEvent event) {
|
public boolean onProjectileHit(ProjectileHitEvent event) {
|
||||||
Projectile entity = event.getEntity();
|
Projectile entity = event.getEntity();
|
||||||
Location location = BukkitUtil.getLocation(entity);
|
Location location = BukkitUtil.adapt(entity.getLocation());
|
||||||
if (!PlotSquared.get().hasPlotArea(location.getWorld())) {
|
if (!this.plotAreaManager.hasPlotArea(location.getWorldName())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
PlotArea area = location.getPlotArea();
|
PlotArea area = location.getPlotArea();
|
||||||
@ -119,7 +126,7 @@ public class ProjectileEventListener implements Listener {
|
|||||||
Plot plot = area.getPlot(location);
|
Plot plot = area.getPlot(location);
|
||||||
ProjectileSource shooter = entity.getShooter();
|
ProjectileSource shooter = entity.getShooter();
|
||||||
if (shooter instanceof Player) {
|
if (shooter instanceof Player) {
|
||||||
PlotPlayer<?> pp = BukkitUtil.getPlayer((Player) shooter);
|
PlotPlayer<?> pp = BukkitUtil.adapt((Player) shooter);
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
if (!Permissions.hasPermission(pp, Captions.PERMISSION_PROJECTILE_UNOWNED)) {
|
if (!Permissions.hasPermission(pp, Captions.PERMISSION_PROJECTILE_UNOWNED)) {
|
||||||
entity.remove();
|
entity.remove();
|
||||||
@ -127,8 +134,7 @@ public class ProjectileEventListener implements Listener {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (plot.isAdded(pp.getUUID()) || Permissions
|
if (plot.isAdded(pp.getUUID()) || Permissions.hasPermission(pp, Captions.PERMISSION_PROJECTILE_OTHER)) {
|
||||||
.hasPermission(pp, Captions.PERMISSION_PROJECTILE_OTHER)) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
entity.remove();
|
entity.remove();
|
||||||
@ -139,8 +145,7 @@ public class ProjectileEventListener implements Listener {
|
|||||||
entity.remove();
|
entity.remove();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Location sLoc =
|
Location sLoc = BukkitUtil.adapt(((BlockProjectileSource) shooter).getBlock().getLocation());
|
||||||
BukkitUtil.getLocation(((BlockProjectileSource) shooter).getBlock().getLocation());
|
|
||||||
if (!area.contains(sLoc.getX(), sLoc.getZ())) {
|
if (!area.contains(sLoc.getX(), sLoc.getZ())) {
|
||||||
entity.remove();
|
entity.remove();
|
||||||
return false;
|
return false;
|
||||||
|
@ -45,8 +45,7 @@ public class MVdWPlaceholders {
|
|||||||
private final Plugin plugin;
|
private final Plugin plugin;
|
||||||
private final PlaceholderRegistry registry;
|
private final PlaceholderRegistry registry;
|
||||||
|
|
||||||
public MVdWPlaceholders(@NotNull final Plugin plugin,
|
public MVdWPlaceholders(@NotNull final Plugin plugin, @NotNull final PlaceholderRegistry registry) {
|
||||||
@NotNull final PlaceholderRegistry registry) {
|
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.registry = registry;
|
this.registry = registry;
|
||||||
for (final Placeholder placeholder : registry.getPlaceholders()) {
|
for (final Placeholder placeholder : registry.getPlaceholders()) {
|
||||||
@ -55,21 +54,16 @@ public class MVdWPlaceholders {
|
|||||||
PlotSquared.get().getEventDispatcher().registerListener(this);
|
PlotSquared.get().getEventDispatcher().registerListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe public void onNewPlaceholder(@NotNull final
|
@Subscribe public void onNewPlaceholder(@NotNull final PlaceholderRegistry.PlaceholderAddedEvent event) {
|
||||||
PlaceholderRegistry.PlaceholderAddedEvent event) {
|
|
||||||
this.addPlaceholder(event.getPlaceholder());
|
this.addPlaceholder(event.getPlaceholder());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addPlaceholder(@NotNull final Placeholder placeholder) {
|
private void addPlaceholder(@NotNull final Placeholder placeholder) {
|
||||||
PlaceholderAPI.registerPlaceholder(plugin, PREFIX + String.format("%s", placeholder.getKey()),
|
PlaceholderAPI.registerPlaceholder(plugin, PREFIX + String.format("%s", placeholder.getKey()), placeholderReplaceEvent -> {
|
||||||
placeholderReplaceEvent -> {
|
|
||||||
if (!placeholderReplaceEvent.isOnline() || placeholderReplaceEvent.getPlayer() == null) {
|
if (!placeholderReplaceEvent.isOnline() || placeholderReplaceEvent.getPlayer() == null) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
final PlotPlayer<Player> player = BukkitUtil.getPlayer(placeholderReplaceEvent.getPlayer());
|
final PlotPlayer<Player> player = BukkitUtil.adapt(placeholderReplaceEvent.getPlayer());
|
||||||
if (player == null) {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
String key = placeholderReplaceEvent.getPlaceholder().substring(PREFIX.length());
|
String key = placeholderReplaceEvent.getPlaceholder().substring(PREFIX.length());
|
||||||
return registry.getPlaceholderValue(key, player);
|
return registry.getPlaceholderValue(key, player);
|
||||||
});
|
});
|
||||||
|
@ -57,7 +57,7 @@ public class PAPIPlaceholders extends PlaceholderExpansion {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override public String onPlaceholderRequest(Player p, String identifier) {
|
@Override public String onPlaceholderRequest(Player p, String identifier) {
|
||||||
final PlotPlayer<?> pl = PlotSquared.imp().getPlayerManager().getPlayerIfExists(p.getUniqueId());
|
final PlotPlayer<?> pl = PlotSquared.platform().getPlayerManager().getPlayerIfExists(p.getUniqueId());
|
||||||
|
|
||||||
if (pl == null) {
|
if (pl == null) {
|
||||||
return "";
|
return "";
|
||||||
|
@ -73,8 +73,8 @@ public class BukkitEntityUtil {
|
|||||||
|
|
||||||
public static boolean entityDamage(Entity damager, Entity victim,
|
public static boolean entityDamage(Entity damager, Entity victim,
|
||||||
EntityDamageEvent.DamageCause cause) {
|
EntityDamageEvent.DamageCause cause) {
|
||||||
Location dloc = BukkitUtil.getLocation(damager);
|
Location dloc = BukkitUtil.adapt(damager.getLocation());
|
||||||
Location vloc = BukkitUtil.getLocation(victim);
|
Location vloc = BukkitUtil.adapt(victim.getLocation());
|
||||||
PlotArea dArea = dloc.getPlotArea();
|
PlotArea dArea = dloc.getPlotArea();
|
||||||
PlotArea vArea;
|
PlotArea vArea;
|
||||||
if (dArea != null && dArea.contains(vloc.getX(), vloc.getZ())) {
|
if (dArea != null && dArea.contains(vloc.getX(), vloc.getZ())) {
|
||||||
@ -152,7 +152,7 @@ public class BukkitEntityUtil {
|
|||||||
} else { // shooter is not player
|
} else { // shooter is not player
|
||||||
if (shooter instanceof BlockProjectileSource) {
|
if (shooter instanceof BlockProjectileSource) {
|
||||||
Location sLoc = BukkitUtil
|
Location sLoc = BukkitUtil
|
||||||
.getLocation(((BlockProjectileSource) shooter).getBlock().getLocation());
|
.adapt(((BlockProjectileSource) shooter).getBlock().getLocation());
|
||||||
dplot = dArea.getPlot(sLoc);
|
dplot = dArea.getPlot(sLoc);
|
||||||
}
|
}
|
||||||
player = null;
|
player = null;
|
||||||
@ -161,7 +161,7 @@ public class BukkitEntityUtil {
|
|||||||
player = null;
|
player = null;
|
||||||
}
|
}
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
BukkitPlayer plotPlayer = BukkitUtil.getPlayer(player);
|
BukkitPlayer plotPlayer = BukkitUtil.adapt(player);
|
||||||
|
|
||||||
final com.sk89q.worldedit.world.entity.EntityType entityType;
|
final com.sk89q.worldedit.world.entity.EntityType entityType;
|
||||||
|
|
||||||
|
@ -2351,7 +2351,7 @@ public class Plot {
|
|||||||
*
|
*
|
||||||
* @return The plot alias
|
* @return The plot alias
|
||||||
*/
|
*/
|
||||||
@NotNull public String getAlias() {
|
@Nonnull public String getAlias() {
|
||||||
if (this.settings == null) {
|
if (this.settings == null) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
@ -104,6 +104,9 @@ public class EventDispatcher {
|
|||||||
eventBus.unregister(listener);
|
eventBus.unregister(listener);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public void callGenericEvent(@Nonnull final Object event) {
|
||||||
|
eventBus.post(event);
|
||||||
|
}
|
||||||
|
|
||||||
public void callEvent(@Nonnull final PlotEvent event) {
|
public void callEvent(@Nonnull final PlotEvent event) {
|
||||||
eventBus.post(event);
|
eventBus.post(event);
|
||||||
|
@ -34,6 +34,7 @@ import com.plotsquared.core.plot.flag.GlobalFlagContainer;
|
|||||||
import com.plotsquared.core.plot.flag.PlotFlag;
|
import com.plotsquared.core.plot.flag.PlotFlag;
|
||||||
import com.plotsquared.core.util.EventDispatcher;
|
import com.plotsquared.core.util.EventDispatcher;
|
||||||
import com.plotsquared.core.util.MainUtil;
|
import com.plotsquared.core.util.MainUtil;
|
||||||
|
import com.plotsquared.core.util.PlayerManager;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@ -70,7 +71,7 @@ public final class PlaceholderRegistry {
|
|||||||
this.registerPlaceholder(new PlotFlagPlaceholder(flag, true));
|
this.registerPlaceholder(new PlotFlagPlaceholder(flag, true));
|
||||||
this.registerPlaceholder(new PlotFlagPlaceholder(flag, false));
|
this.registerPlaceholder(new PlotFlagPlaceholder(flag, false));
|
||||||
});
|
});
|
||||||
this.createPlaceholder("currentplot_world", player -> player.getLocation().getWorld());
|
this.createPlaceholder("currentplot_world", player -> player.getLocation().getWorldName());
|
||||||
this.createPlaceholder("has_plot", player -> player.getPlotCount() > 0 ? "true" : "false");
|
this.createPlaceholder("has_plot", player -> player.getPlotCount() > 0 ? "true" : "false");
|
||||||
this.createPlaceholder("allowed_plot_count", player -> Integer.toString(player.getAllowedPlots()));
|
this.createPlaceholder("allowed_plot_count", player -> Integer.toString(player.getAllowedPlots()));
|
||||||
this.createPlaceholder("plot_count", player -> Integer.toString(player.getPlotCount()));
|
this.createPlaceholder("plot_count", player -> Integer.toString(player.getPlotCount()));
|
||||||
@ -82,7 +83,7 @@ public final class PlaceholderRegistry {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return MainUtil.getName(plotOwner, false);
|
return PlayerManager.getName(plotOwner, false);
|
||||||
} catch (final Exception ignored) {}
|
} catch (final Exception ignored) {}
|
||||||
|
|
||||||
return "unknown";
|
return "unknown";
|
||||||
|
Loading…
Reference in New Issue
Block a user