mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-08-30 23:59:53 +02:00
Fixes #1528
This commit is contained in:
parent
e9723f5be1
commit
491cc50440
|
@ -494,11 +494,58 @@ public class MainListener {
|
|||
});
|
||||
}
|
||||
|
||||
@Listener
|
||||
public void onBlockPlace(ChangeBlockEvent.Pre event) {
|
||||
Player player = SpongeUtil.getCause(event.getCause(), Player.class);
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
PlotPlayer pp = SpongeUtil.getPlayer(player);
|
||||
World world = event.getTargetWorld();
|
||||
String worldName = world.getName();
|
||||
if (!PS.get().hasPlotArea(worldName)) {
|
||||
return;
|
||||
}
|
||||
List<org.spongepowered.api.world.Location<World>> locs = event.getLocations();
|
||||
org.spongepowered.api.world.Location<World> first = locs.get(0);
|
||||
Location loc = SpongeUtil.getLocation(worldName, first);
|
||||
PlotArea area = loc.getPlotArea();
|
||||
if (area == null) {
|
||||
return;
|
||||
}
|
||||
Plot plot = area.getPlot(loc);
|
||||
if (plot == null) {
|
||||
if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_ROAD, true)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (plot.hasOwner()) {
|
||||
if (plot.isAdded(pp.getUUID()) || Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_OTHER)) {
|
||||
return;
|
||||
} else {
|
||||
com.google.common.base.Optional<HashSet<PlotBlock>> place = plot.getFlag(Flags.PLACE);
|
||||
BlockState state = first.getBlock();
|
||||
if (!place.isPresent() || !place.get().contains(SpongeUtil.getPlotBlock(state))) {
|
||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_OTHER);
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_UNOWNED)) {
|
||||
return;
|
||||
}
|
||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_UNOWNED);
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Listener
|
||||
public void onBlockPlace(ChangeBlockEvent.Place event) {
|
||||
Player player = SpongeUtil.getCause(event.getCause(), Player.class);
|
||||
if (player == null) {
|
||||
//SpongeUtil.printCause("place", event.getCause());
|
||||
return;
|
||||
}
|
||||
PlotPlayer pp = SpongeUtil.getPlayer(player);
|
||||
|
|
Loading…
Reference in New Issue
Block a user