actually fix all conflicts

This commit is contained in:
dordsor21 2020-07-01 14:21:18 +01:00
parent 82a887fd3b
commit c5ec8e1931
No known key found for this signature in database
GPG Key ID: 1E53E88969FFCF0B

View File

@ -2966,262 +2966,249 @@ public class PlayerEvents extends PlotListener implements Listener {
return false; return false;
} }
} else if (EntityCategories.ANIMAL.contains(entityType)) { // victim is animal } else if (EntityCategories.ANIMAL.contains(entityType)) { // victim is animal
<<<<<<<HEAD if (isPlot) { if (isPlot) {
if (plot.getFlag(AnimalAttackFlag.class) || plot.getFlag(PveFlag.class) || plot if (plot.getFlag(AnimalAttackFlag.class) || plot.getFlag(PveFlag.class) || plot
.isAdded(plotPlayer.getUUID())) { .isAdded(plotPlayer.getUUID())) {
plot.debug(player.getName() + " could not attack " + entityType
+ " because pve = false OR animal-attack = false");
return true; return true;
} }
} else if (roadFlags && (area.getFlag(AnimalAttackFlag.class) || area } else if (roadFlags && (area.getFlag(AnimalAttackFlag.class) || area
.getFlag(PveFlag.class))) { .getFlag(PveFlag.class))) {
=======
if (plot != null && (plot.getFlag(AnimalAttackFlag.class) || plot
.getFlag(PveFlag.class) || plot.isAdded(plotPlayer.getUUID()))) {
plot.debug(player.getName() + " could not attack " + entityType
+ " because pve = false OR animal-attack = false");
>>>>>>>v5 return true;
} if (!Permissions.hasPermission(plotPlayer, "plots.admin.pve." + stub)) {
MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT,
"plots.admin.pve." + stub);
return false;
}
} else if (EntityCategories.VEHICLE
.contains(entityType)) { // Vehicles are managed in vehicle destroy event
return true;
} else { // victim is something else
if (isPlot) {
if (plot.getFlag(PveFlag.class) || plot.isAdded(plotPlayer.getUUID())) {
return true;
}
} else if (roadFlags && area.getFlag(PveFlag.class)) {
return true;
}
if (!Permissions.hasPermission(plotPlayer, "plots.admin.pve." + stub)) { if (!Permissions.hasPermission(plotPlayer, "plots.admin.pve." + stub)) {
MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT, MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT,
"plots.admin.pve." + stub); "plots.admin.pve." + stub);
if (plot != null) {
plot.debug(player.getName() + " could not attack " + entityType
+ " because pve = false");
}
return false; return false;
} }
} return true; }
} else if (dplot != null && (!dplot.equals(vplot) || Objects } else if (EntityCategories.VEHICLE
.equals(dplot.getOwnerAbs(), vplot.getOwnerAbs()))) { .contains(entityType)) { // Vehicles are managed in vehicle destroy event
return vplot != null && vplot.getFlag(PveFlag.class); return true;
} } else { // victim is something else
//disable the firework damage. too much of a headache to support at the moment. if (isPlot) {
if (vplot != null) { if (plot.getFlag(PveFlag.class) || plot.isAdded(plotPlayer.getUUID())) {
if (EntityDamageEvent.DamageCause.ENTITY_EXPLOSION == cause return true;
&& damager.getType() == EntityType.FIREWORK) { }
} else if (roadFlags && area.getFlag(PveFlag.class)) {
return true;
}
if (!Permissions.hasPermission(plotPlayer, "plots.admin.pve." + stub)) {
MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT,
"plots.admin.pve." + stub);
if (plot != null) {
plot.debug(player.getName() + " could not attack " + entityType
+ " because pve = false");
}
return false; return false;
} }
} }
if (vplot == null && roadFlags && area.getFlag(PveFlag.class)) { return true;
return true; } else if (dplot != null && (!dplot.equals(vplot) || Objects
} .equals(dplot.getOwnerAbs(), vplot.getOwnerAbs()))) {
return ((vplot != null && vplot.getFlag(PveFlag.class)) || !(damager instanceof Arrow return vplot != null && vplot.getFlag(PveFlag.class);
&& !(victim instanceof Creature)));
} }
//disable the firework damage. too much of a headache to support at the moment.
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) if (vplot != null) {
public void onPlayerEggThrow (PlayerEggThrowEvent event){ if (EntityDamageEvent.DamageCause.ENTITY_EXPLOSION == cause
Location location = BukkitUtil.getLocation(event.getEgg().getLocation()); && damager.getType() == EntityType.FIREWORK) {
PlotArea area = location.getPlotArea(); return false;
if (area == null) {
return;
}
Player player = event.getPlayer();
BukkitPlayer plotPlayer = BukkitUtil.getPlayer(player);
Plot plot = area.getPlot(location);
if (plot == null) {
if (!Permissions.hasPermission(plotPlayer, "plots.admin.projectile.road")) {
MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT,
"plots.admin.projectile.road");
event.setHatching(false);
}
} else if (!plot.hasOwner()) {
if (!Permissions.hasPermission(plotPlayer, "plots.admin.projectile.unowned")) {
MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT,
"plots.admin.projectile.unowned");
event.setHatching(false);
}
} else if (!plot.isAdded(plotPlayer.getUUID())) {
if (!Permissions.hasPermission(plotPlayer, "plots.admin.projectile.other")) {
MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT,
"plots.admin.projectile.other");
event.setHatching(false);
}
} }
} }
if (vplot == null && roadFlags && area.getFlag(PveFlag.class)) {
return true;
}
return ((vplot != null && vplot.getFlag(PveFlag.class)) || !(damager instanceof Arrow
&& !(victim instanceof Creature)));
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void blockCreate (BlockPlaceEvent event){ public void onPlayerEggThrow(PlayerEggThrowEvent event) {
Location location = BukkitUtil.getLocation(event.getBlock().getLocation()); Location location = BukkitUtil.getLocation(event.getEgg().getLocation());
PlotArea area = location.getPlotArea(); PlotArea area = location.getPlotArea();
if (area == null) { if (area == null) {
return; return;
}
Player player = event.getPlayer();
BukkitPlayer plotPlayer = BukkitUtil.getPlayer(player);
Plot plot = area.getPlot(location);
if (plot == null) {
if (!Permissions.hasPermission(plotPlayer, "plots.admin.projectile.road")) {
MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT,
"plots.admin.projectile.road");
event.setHatching(false);
} }
Player player = event.getPlayer(); } else if (!plot.hasOwner()) {
if (!Permissions.hasPermission(plotPlayer, "plots.admin.projectile.unowned")) {
MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT,
"plots.admin.projectile.unowned");
event.setHatching(false);
}
} else if (!plot.isAdded(plotPlayer.getUUID())) {
if (!Permissions.hasPermission(plotPlayer, "plots.admin.projectile.other")) {
MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT,
"plots.admin.projectile.other");
event.setHatching(false);
}
}
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void blockCreate(BlockPlaceEvent event) {
Location location = BukkitUtil.getLocation(event.getBlock().getLocation());
PlotArea area = location.getPlotArea();
if (area == null) {
return;
}
Player player = event.getPlayer();
BukkitPlayer pp = BukkitUtil.getPlayer(player);
Plot plot = area.getPlot(location);
if (plot != null) {
if ((location.getY() > area.getMaxBuildHeight() || location.getY() < area
.getMinBuildHeight()) && !Permissions
.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_HEIGHT_LIMIT)) {
event.setCancelled(true);
MainUtil.sendMessage(pp, Captions.HEIGHT_LIMIT.getTranslated()
.replace("{limit}", String.valueOf(area.getMaxBuildHeight())));
}
if (!plot.hasOwner()) {
if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_UNOWNED)) {
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT,
Captions.PERMISSION_ADMIN_BUILD_UNOWNED);
event.setCancelled(true);
return;
}
} else if (!plot.isAdded(pp.getUUID())) {
List<BlockTypeWrapper> place = plot.getFlag(PlaceFlag.class);
if (place != null) {
Block block = event.getBlock();
if (place.contains(
BlockTypeWrapper.get(BukkitAdapter.asBlockType(block.getType())))) {
return;
}
}
if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_OTHER)) {
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT,
Captions.PERMISSION_ADMIN_BUILD_OTHER);
event.setCancelled(true);
plot.debug(player.getName() + " could not place " + event.getBlock().getType()
+ " because of the place flag");
return;
}
} else if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) {
if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_OTHER)) {
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT,
Captions.PERMISSION_ADMIN_BUILD_OTHER);
event.setCancelled(true);
return;
}
}
if (plot.getFlag(DisablePhysicsFlag.class)) {
Block block = event.getBlockPlaced();
if (block.getType().hasGravity()) {
sendBlockChange(block.getLocation(), block.getBlockData());
plot.debug(event.getBlock().getType()
+ " did not fall because of disable-physics = true");
}
}
} else if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_ROAD)) {
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT,
Captions.PERMISSION_ADMIN_BUILD_ROAD);
event.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.HIGH) public void onDamage(EntityDamageEvent event) {
if (event.getEntityType() != EntityType.PLAYER) {
return;
}
Location location = BukkitUtil.getLocation(event.getEntity());
PlotArea area = location.getPlotArea();
if (area == null) {
return;
}
Plot plot = location.getOwnedPlot();
if (plot == null) {
if (area.isRoadRespectingGlobalFlags() && area.getFlag(InvincibleFlag.class)) {
event.setCancelled(true);
}
return;
}
if (plot.getFlag(InvincibleFlag.class)) {
plot.debug(
event.getEntity().getName() + " could not take damage because invincible = true");
event.setCancelled(true);
}
}
@EventHandler public void onItemDrop(PlayerDropItemEvent event) {
Player player = event.getPlayer();
BukkitPlayer pp = BukkitUtil.getPlayer(player);
Location location = pp.getLocation();
PlotArea area = location.getPlotArea();
if (area == null) {
return;
}
Plot plot = location.getOwnedPlot();
if (plot == null) {
if (area.isRoadRespectingGlobalFlags() && area.getFlag(ItemDropFlag.class)) {
event.setCancelled(true);
}
return;
}
UUID uuid = pp.getUUID();
if (!plot.isAdded(uuid)) {
if (!plot.getFlag(ItemDropFlag.class)) {
plot.debug(player.getName() + " could not drop item because of item-drop = false");
event.setCancelled(true);
}
}
}
@EventHandler public void onItemPickup(EntityPickupItemEvent event) {
LivingEntity ent = event.getEntity();
if (ent instanceof Player) {
Player player = (Player) ent;
BukkitPlayer pp = BukkitUtil.getPlayer(player); BukkitPlayer pp = BukkitUtil.getPlayer(player);
Plot plot = area.getPlot(location);
if (plot != null) {
if ((location.getY() > area.getMaxBuildHeight() || location.getY() < area
.getMinBuildHeight()) && !Permissions
.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_HEIGHT_LIMIT)) {
event.setCancelled(true);
MainUtil.sendMessage(pp, Captions.HEIGHT_LIMIT.getTranslated()
.replace("{limit}", String.valueOf(area.getMaxBuildHeight())));
}
if (!plot.hasOwner()) {
if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_UNOWNED)) {
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT,
Captions.PERMISSION_ADMIN_BUILD_UNOWNED);
event.setCancelled(true);
return;
}
} else if (!plot.isAdded(pp.getUUID())) {
List<BlockTypeWrapper> place = plot.getFlag(PlaceFlag.class);
if (place != null) {
Block block = event.getBlock();
if (place.contains(
BlockTypeWrapper.get(BukkitAdapter.asBlockType(block.getType())))) {
return;
}
}
if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_OTHER)) {
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT,
Captions.PERMISSION_ADMIN_BUILD_OTHER);
event.setCancelled(true);
plot.debug(
player.getName() + " could not place " + event.getBlock().getType()
+ " because of the place flag");
return;
}
} else if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) {
if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_OTHER)) {
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT,
Captions.PERMISSION_ADMIN_BUILD_OTHER);
event.setCancelled(true);
return;
}
}
if (plot.getFlag(DisablePhysicsFlag.class)) {
Block block = event.getBlockPlaced();
if (block.getType().hasGravity()) {
sendBlockChange(block.getLocation(), block.getBlockData());
plot.debug(event.getBlock().getType()
+ " did not fall because of disable-physics = true");
}
}
} else if (!Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_BUILD_ROAD)) {
MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT,
Captions.PERMISSION_ADMIN_BUILD_ROAD);
event.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.HIGH) public void onDamage (EntityDamageEvent event){
if (event.getEntityType() != EntityType.PLAYER) {
return;
}
Location location = BukkitUtil.getLocation(event.getEntity());
PlotArea area = location.getPlotArea();
if (area == null) {
return;
}
Plot plot = location.getOwnedPlot();
if (plot == null) {
if (area.isRoadRespectingGlobalFlags() && area.getFlag(InvincibleFlag.class)) {
event.setCancelled(true);
}
return;
}
if (plot.getFlag(InvincibleFlag.class)) {
plot.debug(event.getEntity().getName()
+ " could not take damage because invincible = true");
event.setCancelled(true);
}
}
@EventHandler public void onItemDrop (PlayerDropItemEvent event){
Player player = event.getPlayer();
<<<<<<<HEAD PlotPlayer pp = BukkitUtil.getPlayer(player);
Location location = pp.getLocation(); Location location = pp.getLocation();
PlotArea area = location.getPlotArea(); PlotArea area = location.getPlotArea();
if (area == null) { if (area == null) {
return; return;
} }
Plot plot = location.getOwnedPlot(); Plot plot = location.getOwnedPlot();
======= if (plot == null) {
BukkitPlayer pp = BukkitUtil.getPlayer(player); if (area.isRoadRespectingGlobalFlags() && area.getFlag(DropProtectionFlag.class)) {
Plot plot = BukkitUtil.getLocation(player).getOwnedPlot();
>>>>>>>v5 if (plot == null) {
if (area.isRoadRespectingGlobalFlags() && area.getFlag(ItemDropFlag.class)) {
event.setCancelled(true); event.setCancelled(true);
} }
return; return;
} }
UUID uuid = pp.getUUID(); UUID uuid = pp.getUUID();
if (!plot.isAdded(uuid)) { if (!plot.isAdded(uuid) && plot.getFlag(DropProtectionFlag.class)) {
if (!plot.getFlag(ItemDropFlag.class)) { plot.debug(
plot.debug( player.getName() + " could not pick up item because of drop-protection = true");
player.getName() + " could not drop item because of item-drop = false"); event.setCancelled(true);
event.setCancelled(true);
}
} }
} }
}
@EventHandler public void onItemPickup (EntityPickupItemEvent event){ @EventHandler public void onDeath(final PlayerDeathEvent event) {
LivingEntity ent = event.getEntity(); Location location = BukkitUtil.getLocation(event.getEntity());
if (ent instanceof Player) { PlotArea area = location.getPlotArea();
Player player = (Player) ent; if (area == null) {
<<<<<<<HEAD PlotPlayer pp = BukkitUtil.getPlayer(player); return;
Location location = pp.getLocation();
PlotArea area = location.getPlotArea();
if (area == null) {
return;
}
Plot plot = location.getOwnedPlot();
=======
BukkitPlayer pp = BukkitUtil.getPlayer(player);
Plot plot = BukkitUtil.getLocation(player).getOwnedPlot();
>>>>>>>v5 if (plot == null) {
if (area.isRoadRespectingGlobalFlags() && area
.getFlag(DropProtectionFlag.class)) {
event.setCancelled(true);
}
return;
}
UUID uuid = pp.getUUID();
if (!plot.isAdded(uuid) && plot.getFlag(DropProtectionFlag.class)) {
plot.debug(player.getName()
+ " could not pick up item because of drop-protection = true");
event.setCancelled(true);
}
}
} }
Plot plot = location.getOwnedPlot();
@EventHandler public void onDeath ( final PlayerDeathEvent event){ if (plot == null) {
<<<<<<<HEAD Location location = BukkitUtil.getLocation(event.getEntity()); if (area.isRoadRespectingGlobalFlags() && area.getFlag(KeepInventoryFlag.class)) {
PlotArea area = location.getPlotArea(); event.setCancelled(true);
if (area == null) {
return;
}
Plot plot = location.getOwnedPlot();
if (plot == null) {
if (area.isRoadRespectingGlobalFlags() && area.getFlag(KeepInventoryFlag.class)) {
event.setCancelled(true);
}
return;
} }
return;
}
if (plot.getFlag(KeepInventoryFlag.class)) {
if (plot.getFlag(KeepInventoryFlag.class)) { if (plot.getFlag(KeepInventoryFlag.class)) {
======= plot.debug(event.getEntity().getName()
final Plot plot = BukkitUtil.getPlayer(event.getEntity()).getCurrentPlot(); + " kept their inventory because of keep-inventory = true");
if (plot != null && plot.getFlag(KeepInventoryFlag.class)) { event.setKeepInventory(true);
plot.debug(event.getEntity().getName()
+ " kept their inventory because of keep-inventory = true");
>>>>>>>v5 event.setKeepInventory(true);
}
} }
} }
}
}