From 1c915905c6b661b3b032fe6725012b83c6dc100c Mon Sep 17 00:00:00 2001 From: MattBDev <4009945+MattBDev@users.noreply.github.com> Date: Thu, 11 Apr 2019 23:27:47 -0400 Subject: [PATCH 1/2] Fixes #2275 --- .../bukkit/listeners/PlayerEvents.java | 73 ++++++++++++++----- 1 file changed, 54 insertions(+), 19 deletions(-) diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlayerEvents.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlayerEvents.java index 3833c8b8e..33e0093f8 100644 --- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlayerEvents.java +++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlayerEvents.java @@ -632,24 +632,33 @@ import java.util.regex.Pattern; EventUtil.manager.doJoinTask(pp); }, 20); - if (pp.hasPermission(Captions.PERMISSION_ADMIN_UPDATE_NOTIFICATION.s()) && - PlotSquared.get().getUpdateUtility() != null) { - final UpdateUtility updateUtility = PlotSquared.get().getUpdateUtility(); - final BukkitMain bukkitMain = BukkitMain.getPlugin(BukkitMain.class); - updateUtility.checkForUpdate(bukkitMain.getPluginVersionString(), ((updateDescription, throwable) -> { + if (pp.hasPermission(Captions.PERMISSION_ADMIN_UPDATE_NOTIFICATION.s()) + && PlotSquared.get().getUpdateUtility() != null) { + final UpdateUtility updateUtility = PlotSquared.get().getUpdateUtility(); + final BukkitMain bukkitMain = BukkitMain.getPlugin(BukkitMain.class); + updateUtility.checkForUpdate(bukkitMain.getPluginVersionString(), + ((updateDescription, throwable) -> { if (throwable != null) { - bukkitMain.getLogger().severe(String.format("Could not check for update. Reason: %s", - throwable.getMessage())); + bukkitMain.getLogger().severe(String + .format("Could not check for update. Reason: %s", + throwable.getMessage())); } else { if (updateDescription != null) { - new PlotMessage("-------- ").color("$2").text("PlotSquared Update Notification").color("$1").text(" --------").color("$2") - .send(pp); - new PlotMessage("There appears to be a PlotSquared update available!").color("$1").send(pp); + new PlotMessage("-------- ").color("$2") + .text("PlotSquared Update Notification").color("$1") + .text(" --------").color("$2").send(pp); + new PlotMessage("There appears to be a PlotSquared update available!") + .color("$1").send(pp); new PlotMessage(String.format("You are running version %s," - + " the newest available version is %s", bukkitMain.getPluginVersionString(), updateDescription.getVersion())).color("$1").send(pp); - new PlotMessage("Update URL").color("$1").text(": ").color("$2").text(updateDescription.getUrl()).tooltip("Download update").send(pp); - new PlotMessage("-------- ").color("$2").text("PlotSquared Update Notification").color("$1").text(" --------").color("$2") + + " the newest available version is %s", + bukkitMain.getPluginVersionString(), + updateDescription.getVersion())).color("$1").send(pp); + new PlotMessage("Update URL").color("$1").text(": ").color("$2") + .text(updateDescription.getUrl()).tooltip("Download update") .send(pp); + new PlotMessage("-------- ").color("$2") + .text("PlotSquared Update Notification").color("$1") + .text(" --------").color("$2").send(pp); } } })); @@ -2689,7 +2698,7 @@ import java.util.regex.Pattern; return; } Entity victim = event.getEntity(); - if (!entityDamage(damager, victim)) { + if (!entityDamage(damager, victim, event.getCause())) { if (event.isCancelled()) { if (victim instanceof Ageable) { Ageable ageable = (Ageable) victim; @@ -2703,18 +2712,37 @@ import java.util.regex.Pattern; } } - public boolean entityDamage(Entity damager, Entity victim) { + private boolean entityDamage(Entity damager, Entity victim) { + return entityDamage(damager, victim, null); + } + + private boolean entityDamage(Entity damager, Entity victim, + EntityDamageEvent.DamageCause cause) { Location dloc = BukkitUtil.getLocation(damager); Location vloc = BukkitUtil.getLocation(victim); PlotArea dArea = dloc.getPlotArea(); - PlotArea vArea = - dArea != null && dArea.contains(vloc.getX(), vloc.getZ()) ? dArea : vloc.getPlotArea(); + PlotArea vArea; + if (dArea != null && dArea.contains(vloc.getX(), vloc.getZ())) { + vArea = dArea; + } else { + vArea = vloc.getPlotArea(); + } if (dArea == null && vArea == null) { return true; } - Plot dplot = dArea != null ? dArea.getPlot(dloc) : null; - Plot vplot = vArea != null ? vArea.getPlot(vloc) : null; + Plot dplot; + if (dArea != null) { + dplot = dArea.getPlot(dloc); + } else { + dplot = null; + } + Plot vplot; + if (vArea != null) { + vplot = vArea.getPlot(vloc); + } else { + vplot = null; + } Plot plot; String stub; @@ -2860,6 +2888,13 @@ import java.util.regex.Pattern; .equals(dplot.guessOwner(), vplot.guessOwner()))) { return vplot != null && Flags.PVE.isTrue(vplot); } + //disable the firework damage. too much of a headache to support at the moment. + if (vplot != null) { + if (EntityDamageEvent.DamageCause.ENTITY_EXPLOSION == cause + && damager.getType() == EntityType.FIREWORK) { + return false; + } + } return ((vplot != null && Flags.PVE.isTrue(vplot)) || !(damager instanceof Arrow && !(victim instanceof Creature))); } From 0c46df65e62c8069adcb13fbadb5b53ec6d33e93 Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Fri, 12 Apr 2019 17:42:35 +0100 Subject: [PATCH 2/2] Not sure why that last commit was a thing locally --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 84ede9b34..7bb184b05 100644 --- a/build.gradle +++ b/build.gradle @@ -32,7 +32,7 @@ ext { date = git.head().getDate().format("yy.MM.dd") revision = "-${git.head().abbreviatedId}" parents = git.head().parentIds; - index = -2044; // Offset to match CI + index = -2039; // Offset to match CI for (; parents != null && !parents.isEmpty(); index++) { parents = git.getResolve().toCommit(parents.get(0)).getParentIds() }