mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-26 07:06:44 +01:00
Merge branch 'master' of https://github.com/IntellectualSites/PlotSquared
This commit is contained in:
commit
7947c3fdd7
@ -196,14 +196,9 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Optional<Boolean> flag = plot.getFlag(Flags.REDSTONE);
|
if (Flags.REDSTONE.isFalse(plot)) {
|
||||||
if (flag.isPresent()) {
|
event.setNewCurrent(0);
|
||||||
if (flag.get()) {
|
return;
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
event.setNewCurrent(0);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (Settings.REDSTONE_DISABLER) {
|
if (Settings.REDSTONE_DISABLER) {
|
||||||
if (UUIDHandler.getPlayer(plot.owner) == null) {
|
if (UUIDHandler.getPlayer(plot.owner) == null) {
|
||||||
@ -246,8 +241,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Optional<Boolean> flag = plot.getFlag(Flags.REDSTONE);
|
if (Flags.REDSTONE.isFalse(plot)) {
|
||||||
if (flag.isPresent() && !flag.get()) {
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@ -263,10 +257,12 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Plot plot = area.getOwnedPlotAbs(loc);
|
Plot plot = area.getOwnedPlotAbs(loc);
|
||||||
if (plot != null && plot.getFlag(Flags.DISABLE_PHYSICS).or(false)) {
|
if (plot == null) {
|
||||||
event.setCancelled(true);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (Flags.DISABLE_PHYSICS.isFalse(plot)) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -691,8 +687,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
}
|
}
|
||||||
Plot plot = area.getOwnedPlot(location);
|
Plot plot = area.getOwnedPlot(location);
|
||||||
if (plot != null) {
|
if (plot != null) {
|
||||||
Optional<Boolean> flag = plot.getFlag(Flags.EXPLOSION);
|
if (Flags.EXPLOSION.isTrue(plot)) {
|
||||||
if (flag.isPresent() && flag.get()) {
|
|
||||||
List<MetadataValue> meta = event.getEntity().getMetadata("plot");
|
List<MetadataValue> meta = event.getEntity().getMetadata("plot");
|
||||||
Plot origin;
|
Plot origin;
|
||||||
if (meta.isEmpty()) {
|
if (meta.isEmpty()) {
|
||||||
@ -789,20 +784,17 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
Optional<Boolean> flag;
|
Optional<Boolean> flag;
|
||||||
switch (block.getType()) {
|
switch (block.getType()) {
|
||||||
case GRASS:
|
case GRASS:
|
||||||
flag = plot.getFlag(Flags.GRASS_GROW);
|
if (Flags.GRASS_GROW.isFalse(plot)) {
|
||||||
if (flag.isPresent() && flag.get()) {
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MYCEL:
|
case MYCEL:
|
||||||
flag = plot.getFlag(Flags.MYCEL_GROW);
|
if (Flags.MYCEL_GROW.isFalse(plot)) {
|
||||||
if (flag.isPresent() && flag.get()) {
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case VINE:
|
case VINE:
|
||||||
flag = plot.getFlag(Flags.VINE_GROW);
|
if (Flags.VINE_GROW.isFalse(plot)) {
|
||||||
if (flag.isPresent() && flag.get()) {
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -872,27 +864,18 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
}
|
}
|
||||||
switch (b.getType()) {
|
switch (b.getType()) {
|
||||||
case ICE:
|
case ICE:
|
||||||
Optional<Boolean> ice_melt = plot.getFlag(Flags.ICE_MELT);
|
if (Flags.ICE_MELT.isFalse(plot)) {
|
||||||
if (ice_melt.isPresent()) {
|
event.setCancelled(true);
|
||||||
if (!ice_melt.get()) {
|
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SNOW:
|
case SNOW:
|
||||||
Optional<Boolean> snow_melt = plot.getFlag(Flags.SNOW_MELT);
|
if (Flags.SNOW_MELT.isFalse(plot)) {
|
||||||
if (snow_melt.isPresent()) {
|
event.setCancelled(true);
|
||||||
if (!snow_melt.get()) {
|
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SOIL:
|
case SOIL:
|
||||||
Optional<Boolean> soil_dry = plot.getFlag(Flags.SOIL_DRY);
|
if (Flags.SOIL_DRY.isFalse(plot)) {
|
||||||
if (soil_dry.isPresent()) {
|
event.setCancelled(true);
|
||||||
if (!soil_dry.get()) {
|
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -910,8 +893,9 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
Plot plot = area.getOwnedPlot(tLocation);
|
Plot plot = area.getOwnedPlot(tLocation);
|
||||||
Location fLocation = BukkitUtil.getLocation(from.getLocation());
|
Location fLocation = BukkitUtil.getLocation(from.getLocation());
|
||||||
if (plot != null) {
|
if (plot != null) {
|
||||||
if (plot.getFlag(Flags.DISABLE_PHYSICS).or(false) || !area.contains(fLocation.getX(), fLocation.getZ()) || !Objects
|
if (Flags.DISABLE_PHYSICS.isFalse(plot)) {
|
||||||
.equals(plot, area.getOwnedPlot(fLocation))) {
|
event.setCancelled(true);
|
||||||
|
} else if (!area.contains(fLocation.getX(), fLocation.getZ()) || !Objects.equals(plot, area.getOwnedPlot(fLocation))) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
} else if (!area.contains(fLocation.getX(), fLocation.getZ()) || !Objects.equals(plot, area.getOwnedPlot(fLocation))) {
|
} else if (!area.contains(fLocation.getX(), fLocation.getZ()) || !Objects.equals(plot, area.getOwnedPlot(fLocation))) {
|
||||||
@ -1349,7 +1333,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Plot plot = area.getOwnedPlotAbs(location);
|
Plot plot = area.getOwnedPlotAbs(location);
|
||||||
if (plot == null || plot.getFlag(Flags.DISABLE_PHYSICS).or(false)) {
|
if (plot == null || plot.getFlag(Flags.DISABLE_PHYSICS, false)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1400,14 +1384,14 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
default:
|
default:
|
||||||
i = 0;
|
i = 0;
|
||||||
}
|
}
|
||||||
Optional<Integer> plotFlag = plot.getFlag(flag);
|
int cap = plot.getFlag(flag, Integer.MAX_VALUE);
|
||||||
if (!plotFlag.isPresent()) {
|
if (cap != Integer.MAX_VALUE) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (mobs == null) {
|
if (mobs == null) {
|
||||||
mobs = plot.countEntities();
|
mobs = plot.countEntities();
|
||||||
}
|
}
|
||||||
if (mobs[i] >= plotFlag.get()) {
|
if (mobs[i] >= cap) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1535,8 +1519,9 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Plot plot = location.getOwnedPlot();
|
Plot plot = location.getOwnedPlot();
|
||||||
if (plot == null || !plot.getFlag(Flags.BLOCK_BURN).or(false)) {
|
if (plot == null || !plot.getFlag(Flags.BLOCK_BURN, false)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1584,7 +1569,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_OTHER);
|
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_OTHER);
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
} else if (!plot.getFlag(Flags.BLOCK_IGNITION).or(false)) {
|
} else if (Flags.BLOCK_IGNITION.isFalse(plot)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -1593,7 +1578,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (ignitingEntity != null) {
|
if (ignitingEntity != null) {
|
||||||
if (!plot.getFlag(Flags.BLOCK_IGNITION).or(false)) {
|
if (!plot.getFlag(Flags.BLOCK_IGNITION,false)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1617,7 +1602,7 @@ public class PlayerEvents extends PlotListener 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.getLocation(ignitingBlock.getLocation()).getPlot();
|
||||||
if (igniteCause == BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL && (!plot.getFlag(Flags.BLOCK_IGNITION).or(false)
|
if (igniteCause == BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL && (!plot.getFlag(Flags.BLOCK_IGNITION,false)
|
||||||
|| plotIgnited == null || !plotIgnited.equals(plot))
|
|| plotIgnited == null || !plotIgnited.equals(plot))
|
||||||
|| (igniteCause == BlockIgniteEvent.IgniteCause.SPREAD || igniteCause == BlockIgniteEvent.IgniteCause.LAVA) && (
|
|| (igniteCause == BlockIgniteEvent.IgniteCause.SPREAD || igniteCause == BlockIgniteEvent.IgniteCause.LAVA) && (
|
||||||
!plot.getFlag(Flags.BLOCK_IGNITION).or(false) || plotIgnited == null || !plotIgnited.equals(plot))) {
|
!plot.getFlag(Flags.BLOCK_IGNITION).or(false) || plotIgnited == null || !plotIgnited.equals(plot))) {
|
||||||
@ -1923,7 +1908,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!plot.isAdded(pp.getUUID())) {
|
if (!plot.isAdded(pp.getUUID())) {
|
||||||
if (!plot.getFlag(Flags.HANGING_PLACE).or(false)) {
|
if (!plot.getFlag(Flags.HANGING_PLACE,false)) {
|
||||||
if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_OTHER)) {
|
if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_OTHER)) {
|
||||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_OTHER);
|
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_OTHER);
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@ -1961,7 +1946,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
} else if (!plot.isAdded(pp.getUUID())) {
|
} else if (!plot.isAdded(pp.getUUID())) {
|
||||||
if (plot.getFlag(Flags.HANGING_BREAK).or(false)) {
|
if (plot.getFlag(Flags.HANGING_BREAK, false)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_DESTROY_OTHER)) {
|
if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_DESTROY_OTHER)) {
|
||||||
@ -1987,7 +1972,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
} else if (!plot.isAdded(player.getUUID())) {
|
} else if (!plot.isAdded(player.getUUID())) {
|
||||||
if (!plot.getFlag(Flags.HANGING_BREAK).or(false)) {
|
if (!plot.getFlag(Flags.HANGING_BREAK, false)) {
|
||||||
if (!Permissions.hasPermission(player, C.PERMISSION_ADMIN_DESTROY_OTHER)) {
|
if (!Permissions.hasPermission(player, C.PERMISSION_ADMIN_DESTROY_OTHER)) {
|
||||||
MainUtil.sendMessage(player, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_DESTROY_OTHER);
|
MainUtil.sendMessage(player, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_DESTROY_OTHER);
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@ -2023,19 +2008,19 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
}
|
}
|
||||||
} else if (!plot.isAdded(pp.getUUID())) {
|
} else if (!plot.isAdded(pp.getUUID())) {
|
||||||
Entity entity = event.getRightClicked();
|
Entity entity = event.getRightClicked();
|
||||||
if (entity instanceof Monster && plot.getFlag(Flags.HOSTILE_INTERACT).or(false)) {
|
if (entity instanceof Monster && plot.getFlag(Flags.HOSTILE_INTERACT, false)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (entity instanceof Animals && plot.getFlag(Flags.ANIMAL_INTERACT).or(false)) {
|
if (entity instanceof Animals && plot.getFlag(Flags.ANIMAL_INTERACT, false)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (entity instanceof Tameable && ((Tameable) entity).isTamed() && plot.getFlag(Flags.TAMED_INTERACT).or(false)) {
|
if (entity instanceof Tameable && ((Tameable) entity).isTamed() && plot.getFlag(Flags.TAMED_INTERACT, false)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (entity instanceof Vehicle && plot.getFlag(Flags.VEHICLE_USE).or(false)) {
|
if (entity instanceof Vehicle && plot.getFlag(Flags.VEHICLE_USE, false)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (entity instanceof Player && plot.getFlag(Flags.PLAYER_INTERACT).or(false)) {
|
if (entity instanceof Player && plot.getFlag(Flags.PLAYER_INTERACT, false)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER)) {
|
if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER)) {
|
||||||
@ -2072,7 +2057,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!plot.isAdded(pp.getUUID())) {
|
if (!plot.isAdded(pp.getUUID())) {
|
||||||
if (plot.getFlag(Flags.VEHICLE_BREAK).or(false)) {
|
if (plot.getFlag(Flags.VEHICLE_BREAK, false)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!Permissions.hasPermission(pp, "plots.admin.vehicle.break.other")) {
|
if (!Permissions.hasPermission(pp, "plots.admin.vehicle.break.other")) {
|
||||||
@ -2183,7 +2168,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
if (player != null) {
|
if (player != null) {
|
||||||
PlotPlayer pp = BukkitUtil.getPlayer(player);
|
PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||||
if (victim instanceof Hanging) { // hanging
|
if (victim instanceof Hanging) { // hanging
|
||||||
if (plot != null && (plot.getFlag(Flags.HANGING_BREAK).or(false) || plot.isAdded(pp.getUUID()))) {
|
if (plot != null && (plot.getFlag(Flags.HANGING_BREAK, false) || plot.isAdded(pp.getUUID()))) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!Permissions.hasPermission(pp, "plots.admin.destroy." + stub)) {
|
if (!Permissions.hasPermission(pp, "plots.admin.destroy." + stub)) {
|
||||||
@ -2191,7 +2176,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else if (victim.getEntityId() == 30) {
|
} else if (victim.getEntityId() == 30) {
|
||||||
if (plot != null && (plot.getFlag(Flags.MISC_BREAK).or(false) || plot.isAdded(pp.getUUID()))) {
|
if (plot != null && (plot.getFlag(Flags.MISC_BREAK, false) || plot.isAdded(pp.getUUID()))) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!Permissions.hasPermission(pp, "plots.admin.destroy." + stub)) {
|
if (!Permissions.hasPermission(pp, "plots.admin.destroy." + stub)) {
|
||||||
@ -2199,7 +2184,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else if (victim instanceof Monster || victim instanceof EnderDragon) { // victim is monster
|
} else if (victim instanceof Monster || victim instanceof EnderDragon) { // victim is monster
|
||||||
if (plot != null && (plot.getFlag(Flags.HOSTILE_ATTACK).or(false) || plot.getFlag(Flags.PVE).or(false) || plot
|
if (plot != null && (plot.getFlag(Flags.HOSTILE_ATTACK, false) || plot.getFlag(Flags.PVE, false) || plot
|
||||||
.isAdded(pp.getUUID()))) {
|
.isAdded(pp.getUUID()))) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -2208,7 +2193,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else if (victim instanceof Tameable) { // victim is tameable
|
} else if (victim instanceof Tameable) { // victim is tameable
|
||||||
if (plot != null && (plot.getFlag(Flags.TAMED_ATTACK).or(false) || plot.getFlag(Flags.PVE).or(false) || plot.isAdded(pp.getUUID()))) {
|
if (plot != null && (plot.getFlag(Flags.TAMED_ATTACK, false) || plot.getFlag(Flags.PVE, false) || plot.isAdded(pp.getUUID()))) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!Permissions.hasPermission(pp, "plots.admin.pve." + stub)) {
|
if (!Permissions.hasPermission(pp, "plots.admin.pve." + stub)) {
|
||||||
@ -2217,12 +2202,9 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
}
|
}
|
||||||
} else if (victim instanceof Player) {
|
} else if (victim instanceof Player) {
|
||||||
if (plot != null) {
|
if (plot != null) {
|
||||||
Optional<Boolean> pvp = plot.getFlag(Flags.PVP);
|
if (Flags.PVP.isFalse(plot) && !Permissions.hasPermission(pp, "plots.admin.pvp." + stub)) {
|
||||||
if (pvp.isPresent() && !pvp.get()) {
|
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, "plots.admin.pvp." + stub);
|
||||||
if (!Permissions.hasPermission(pp, "plots.admin.pve." + stub)) {
|
return false;
|
||||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, "plots.admin.pve." + stub);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -2232,7 +2214,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else if (victim instanceof Creature) { // victim is animal
|
} else if (victim instanceof Creature) { // victim is animal
|
||||||
if (plot != null && (plot.getFlag(Flags.ANIMAL_ATTACK).or(false) || plot.getFlag(Flags.PVE).or(false) || plot
|
if (plot != null && (plot.getFlag(Flags.ANIMAL_ATTACK, false) || plot.getFlag(Flags.PVE, false) || plot
|
||||||
.isAdded(pp.getUUID()))) {
|
.isAdded(pp.getUUID()))) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -2243,7 +2225,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
} else if (victim instanceof Vehicle) { // Vehicles are managed in vehicle destroy event
|
} else if (victim instanceof Vehicle) { // Vehicles are managed in vehicle destroy event
|
||||||
return true;
|
return true;
|
||||||
} else { // victim is something else
|
} else { // victim is something else
|
||||||
if (plot != null && (plot.getFlag(Flags.PVE).or(false) || plot.isAdded(pp.getUUID()))) {
|
if (plot != null && (plot.getFlag(Flags.PVE, false) || plot.isAdded(pp.getUUID()))) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!Permissions.hasPermission(pp, "plots.admin.pve." + stub)) {
|
if (!Permissions.hasPermission(pp, "plots.admin.pve." + stub)) {
|
||||||
@ -2303,10 +2285,14 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else if (!plot.isAdded(pp.getUUID())) {
|
} else if (!plot.isAdded(pp.getUUID())) {
|
||||||
Optional<HashSet<PlotBlock>> place = plot.getFlag(Flags.PLACE);
|
Set<PlotBlock> place = plot.getFlag(Flags.PLACE, null);
|
||||||
Block block = event.getBlock();
|
if (place != null) {
|
||||||
if ((place.isPresent() && !place.get().contains(new PlotBlock((short) block.getTypeId(), block.getData()))) && !Permissions
|
Block block = event.getBlock();
|
||||||
.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_OTHER)) {
|
if (place.contains(new PlotBlock((short) block.getTypeId(), block.getData()))) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_OTHER)) {
|
||||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_OTHER);
|
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_OTHER);
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
@ -2318,7 +2304,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (plot.getFlag(Flags.DISABLE_PHYSICS).or(false)) {
|
if (plot.getFlag(Flags.DISABLE_PHYSICS, false)) {
|
||||||
Block block = event.getBlockPlaced();
|
Block block = event.getBlockPlaced();
|
||||||
if (block.getType().hasGravity()) {
|
if (block.getType().hasGravity()) {
|
||||||
sendBlockChange(block.getLocation(), block.getType(), block.getData());
|
sendBlockChange(block.getLocation(), block.getType(), block.getData());
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package com.plotsquared.bukkit.util.block;
|
package com.plotsquared.bukkit.util.block;
|
||||||
|
|
||||||
import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass;
|
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||||
import com.intellectualcrafters.plot.object.PseudoRandom;
|
import com.intellectualcrafters.plot.object.PseudoRandom;
|
||||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||||
@ -13,23 +11,23 @@ import com.intellectualcrafters.plot.util.ReflectionUtils.RefField;
|
|||||||
import com.intellectualcrafters.plot.util.ReflectionUtils.RefMethod;
|
import com.intellectualcrafters.plot.util.ReflectionUtils.RefMethod;
|
||||||
import com.intellectualcrafters.plot.util.ReflectionUtils.RefMethod.RefExecutor;
|
import com.intellectualcrafters.plot.util.ReflectionUtils.RefMethod.RefExecutor;
|
||||||
import com.intellectualcrafters.plot.util.SetQueue.ChunkWrapper;
|
import com.intellectualcrafters.plot.util.SetQueue.ChunkWrapper;
|
||||||
import com.intellectualcrafters.plot.util.TaskManager;
|
|
||||||
import com.plotsquared.bukkit.util.BukkitUtil;
|
import com.plotsquared.bukkit.util.BukkitUtil;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
import java.util.Set;
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.World.Environment;
|
import org.bukkit.World.Environment;
|
||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass;
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public class FastQueue_1_9 extends SlowQueue {
|
public class FastQueue_1_9 extends SlowQueue {
|
||||||
|
|
||||||
@ -220,12 +218,7 @@ public class FastQueue_1_9 extends SlowQueue {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
TaskManager.runTaskLater(new Runnable() {
|
world.refreshChunk(fs.getX(), fs.getZ());
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
sendChunk(fs.getChunkWrapper().world, Collections.singletonList(new ChunkLoc(fs.getX(), fs.getZ())));
|
|
||||||
}
|
|
||||||
}, 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object newChunkSection(int i, boolean flag, char[] ids) {
|
public Object newChunkSection(int i, boolean flag, char[] ids) {
|
||||||
|
@ -483,6 +483,7 @@ public enum C {
|
|||||||
PLOT_INFO_SIZE("$1Size:$2 %size%", "Info"),
|
PLOT_INFO_SIZE("$1Size:$2 %size%", "Info"),
|
||||||
PLOT_INFO_EXPIRES("$1Expires:$2 %expires%", "Info"),
|
PLOT_INFO_EXPIRES("$1Expires:$2 %expires%", "Info"),
|
||||||
PLOT_USER_LIST(" $1%user%$2,", "Info"),
|
PLOT_USER_LIST(" $1%user%$2,", "Info"),
|
||||||
|
PLOT_FLAG_LIST("$1%s0:%s1$2", "Info"),
|
||||||
INFO_SYNTAX_CONSOLE("$2/plot info X;Y", "Info"),
|
INFO_SYNTAX_CONSOLE("$2/plot info X;Y", "Info"),
|
||||||
/*
|
/*
|
||||||
* Generating
|
* Generating
|
||||||
@ -686,6 +687,10 @@ public enum C {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String f(final Object... args) {
|
||||||
|
return format(s(), args);
|
||||||
|
}
|
||||||
|
|
||||||
public static String color(String string) {
|
public static String color(String string) {
|
||||||
return StringMan.replaceFromMap(string, replacements);
|
return StringMan.replaceFromMap(string, replacements);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package com.intellectualcrafters.plot.flag;
|
package com.intellectualcrafters.plot.flag;
|
||||||
|
|
||||||
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
|
|
||||||
public class BooleanFlag extends Flag<Boolean> {
|
public class BooleanFlag extends Flag<Boolean> {
|
||||||
|
|
||||||
public BooleanFlag(String name) {
|
public BooleanFlag(String name) {
|
||||||
@ -34,4 +36,14 @@ public class BooleanFlag extends Flag<Boolean> {
|
|||||||
@Override public String getValueDescription() {
|
@Override public String getValueDescription() {
|
||||||
return "Flag value must be a boolean (true|false)";
|
return "Flag value must be a boolean (true|false)";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isTrue(Plot plot) {
|
||||||
|
Boolean value = FlagManager.getPlotFlagRaw(plot, this);
|
||||||
|
return Boolean.TRUE == value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isFalse(Plot plot) {
|
||||||
|
Boolean value = FlagManager.getPlotFlagRaw(plot, this);
|
||||||
|
return Boolean.FALSE == value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package com.intellectualcrafters.plot.flag;
|
package com.intellectualcrafters.plot.flag;
|
||||||
|
|
||||||
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
|
|
||||||
public class Flag<V> {
|
public class Flag<V> {
|
||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
@ -35,4 +37,8 @@ public class Flag<V> {
|
|||||||
public final String getName() {
|
public final String getName() {
|
||||||
return this.name;
|
return this.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isSet(Plot plot) {
|
||||||
|
return FlagManager.getPlotFlagRaw(plot, this) != null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package com.intellectualcrafters.plot.flag;
|
package com.intellectualcrafters.plot.flag;
|
||||||
|
|
||||||
|
import com.google.common.base.Optional;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
|
import com.intellectualcrafters.plot.PS;
|
||||||
import com.intellectualcrafters.plot.database.DBFunc;
|
import com.intellectualcrafters.plot.database.DBFunc;
|
||||||
import com.intellectualcrafters.plot.object.Plot;
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
import com.intellectualcrafters.plot.object.PlotArea;
|
import com.intellectualcrafters.plot.object.PlotArea;
|
||||||
@ -9,7 +11,7 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
|
|||||||
import com.intellectualcrafters.plot.object.PlotSettings;
|
import com.intellectualcrafters.plot.object.PlotSettings;
|
||||||
import com.intellectualcrafters.plot.util.EventUtil;
|
import com.intellectualcrafters.plot.util.EventUtil;
|
||||||
import com.intellectualcrafters.plot.util.Permissions;
|
import com.intellectualcrafters.plot.util.Permissions;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -27,6 +29,35 @@ public class FlagManager {
|
|||||||
|
|
||||||
private static final HashSet<Flag<?>> reserved = Sets.newHashSet(Flags.ANALYSIS, Flags.DONE);
|
private static final HashSet<Flag<?>> reserved = Sets.newHashSet(Flags.ANALYSIS, Flags.DONE);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Some events can be called millions of times each second (e.g. physics) and reusing is a lot faster.
|
||||||
|
*/
|
||||||
|
private static Optional MUTABLE_OPTIONAL;
|
||||||
|
private static Field MUTABLE_OPTIONAL_FIELD;
|
||||||
|
static {
|
||||||
|
MUTABLE_OPTIONAL = Optional.of(new Object());
|
||||||
|
try {
|
||||||
|
MUTABLE_OPTIONAL_FIELD = MUTABLE_OPTIONAL.getClass().getDeclaredField("reference");
|
||||||
|
MUTABLE_OPTIONAL_FIELD.setAccessible(true);
|
||||||
|
} catch (NoSuchFieldException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <V> Optional<V> getPlotFlag(Plot plot, Flag<V> key) {
|
||||||
|
V value = FlagManager.getPlotFlagRaw(plot, key);
|
||||||
|
if (value != null) {
|
||||||
|
if (PS.get().isMainThread(Thread.currentThread())) {
|
||||||
|
try {
|
||||||
|
MUTABLE_OPTIONAL_FIELD.set(MUTABLE_OPTIONAL, value);
|
||||||
|
return MUTABLE_OPTIONAL;
|
||||||
|
} catch (IllegalAccessException e) {e.printStackTrace();}
|
||||||
|
}
|
||||||
|
return Optional.of(value);
|
||||||
|
}
|
||||||
|
return Optional.absent();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reserve a flag so that it cannot be set by players
|
* Reserve a flag so that it cannot be set by players
|
||||||
* @param flag
|
* @param flag
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.intellectualcrafters.plot.flag;
|
package com.intellectualcrafters.plot.flag;
|
||||||
|
|
||||||
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
public abstract class ListFlag<V extends Collection<?>> extends Flag<V> {
|
public abstract class ListFlag<V extends Collection<?>> extends Flag<V> {
|
||||||
@ -7,4 +8,9 @@ public abstract class ListFlag<V extends Collection<?>> extends Flag<V> {
|
|||||||
public ListFlag(String name) {
|
public ListFlag(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean contains(Plot plot, Object value) {
|
||||||
|
V existing = plot.getFlag(this, null);
|
||||||
|
return existing != null && existing.contains(value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -954,7 +954,7 @@ public class Plot {
|
|||||||
* @param key
|
* @param key
|
||||||
*/
|
*/
|
||||||
public <V> Optional<V> getFlag(Flag<V> key) {
|
public <V> Optional<V> getFlag(Flag<V> key) {
|
||||||
return Optional.fromNullable(FlagManager.getPlotFlagRaw(this, key));
|
return FlagManager.getPlotFlag(this, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -5,6 +5,7 @@ import com.intellectualcrafters.plot.PS;
|
|||||||
import com.intellectualcrafters.plot.config.C;
|
import com.intellectualcrafters.plot.config.C;
|
||||||
import com.intellectualcrafters.plot.config.Settings;
|
import com.intellectualcrafters.plot.config.Settings;
|
||||||
import com.intellectualcrafters.plot.database.DBFunc;
|
import com.intellectualcrafters.plot.database.DBFunc;
|
||||||
|
import com.intellectualcrafters.plot.flag.Flag;
|
||||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||||
import com.intellectualcrafters.plot.flag.Flags;
|
import com.intellectualcrafters.plot.flag.Flags;
|
||||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||||
@ -18,7 +19,6 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
|
|||||||
import com.intellectualcrafters.plot.object.PseudoRandom;
|
import com.intellectualcrafters.plot.object.PseudoRandom;
|
||||||
import com.intellectualcrafters.plot.object.RegionWrapper;
|
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
@ -39,7 +39,6 @@ import java.util.Map;
|
|||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.regex.Matcher;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* plot functions
|
* plot functions
|
||||||
@ -737,32 +736,38 @@ public class MainUtil {
|
|||||||
Optional<String> descriptionFlag = plot.getFlag(Flags.DESCRIPTION);
|
Optional<String> descriptionFlag = plot.getFlag(Flags.DESCRIPTION);
|
||||||
String description = !descriptionFlag.isPresent() ? C.NONE.s() : Flags.DESCRIPTION.valueToString(descriptionFlag.get());
|
String description = !descriptionFlag.isPresent() ? C.NONE.s() : Flags.DESCRIPTION.valueToString(descriptionFlag.get());
|
||||||
|
|
||||||
String flags;
|
StringBuilder flags = new StringBuilder();
|
||||||
if (!StringMan.join(FlagManager.getPlotFlags(plot.getArea(), plot.getSettings(), true).values(), "").isEmpty()) {
|
{
|
||||||
flags = StringMan.replaceFromMap(
|
HashMap<Flag<?>, Object> flagMap = FlagManager.getPlotFlags(plot.getArea(), plot.getSettings(), true);
|
||||||
"$2" + StringMan.join(FlagManager.getPlotFlags(plot.getArea(), plot.getSettings(), true).values(), "$1, $2"), C.replacements);
|
if (flagMap.isEmpty()) {
|
||||||
} else {
|
flags.append(C.NONE.s());
|
||||||
flags = StringMan.replaceFromMap("$2" + C.NONE.s(), C.replacements);
|
} else {
|
||||||
|
String prefix = "";
|
||||||
|
for (Entry<Flag<?>, Object> entry : flagMap.entrySet()) {
|
||||||
|
flags.append(prefix).append(C.PLOT_FLAG_LIST.f(entry.getKey().getName(), entry.getValue()));
|
||||||
|
prefix = ", ";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
boolean build = plot.isAdded(player.getUUID());
|
boolean build = plot.isAdded(player.getUUID());
|
||||||
|
|
||||||
String owner = plot.getOwners().isEmpty() ? "unowned" : getPlayerList(plot.getOwners());
|
String owner = plot.getOwners().isEmpty() ? "unowned" : getPlayerList(plot.getOwners());
|
||||||
|
|
||||||
info = info.replaceAll("%id%", plot.getId().toString());
|
info = info.replace("%id%", plot.getId().toString());
|
||||||
info = info.replaceAll("%alias%", alias);
|
info = info.replace("%alias%", alias);
|
||||||
info = info.replaceAll("%num%", num + "");
|
info = info.replace("%num%", num + "");
|
||||||
info = info.replaceAll("%desc%", description);
|
info = info.replace("%desc%", description);
|
||||||
info = info.replaceAll("%biome%", biome);
|
info = info.replace("%biome%", biome);
|
||||||
info = info.replaceAll("%owner%", owner);
|
info = info.replace("%owner%", owner);
|
||||||
info = info.replaceAll("%members%", members);
|
info = info.replace("%members%", members);
|
||||||
info = info.replaceAll("%player%", player.getName());
|
info = info.replace("%player%", player.getName());
|
||||||
info = info.replaceAll("%trusted%", trusted);
|
info = info.replace("%trusted%", trusted);
|
||||||
info = info.replaceAll("%helpers%", members);
|
info = info.replace("%helpers%", members);
|
||||||
info = info.replaceAll("%denied%", denied);
|
info = info.replace("%denied%", denied);
|
||||||
info = info.replaceAll("%expires%", expires);
|
info = info.replace("%expires%", expires);
|
||||||
info = info.replaceAll("%flags%", Matcher.quoteReplacement(flags));
|
info = info.replace("%flags%", flags);
|
||||||
info = info.replaceAll("%build%", build + "");
|
info = info.replace("%build%", build + "");
|
||||||
info = info.replaceAll("%desc%", "No description set.");
|
info = info.replace("%desc%", "No description set.");
|
||||||
if (info.contains("%rating%")) {
|
if (info.contains("%rating%")) {
|
||||||
final String newInfo = info;
|
final String newInfo = info;
|
||||||
TaskManager.runTaskAsync(new Runnable() {
|
TaskManager.runTaskAsync(new Runnable() {
|
||||||
|
Loading…
Reference in New Issue
Block a user