From 37e4a652dd5d22a18f1e6576c7957a3fe8d28fcc Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 8 Aug 2016 22:45:08 +0200 Subject: [PATCH] Now calling the respective events when a user is removed from a plot. And switched the event calling of adding Helpers and Trusted players. (Correct me if that was wrong) --- .../bukkit/util/BukkitEventUtil.java | 29 +++---------------- .../plot/commands/Remove.java | 13 ++++++++- .../sponge/util/SpongeEventUtil.java | 4 +-- 3 files changed, 18 insertions(+), 28 deletions(-) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitEventUtil.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitEventUtil.java index c28a0a78c..dd905dbce 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitEventUtil.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitEventUtil.java @@ -1,30 +1,9 @@ package com.plotsquared.bukkit.util; import com.intellectualcrafters.plot.flag.Flag; -import com.intellectualcrafters.plot.object.Location; -import com.intellectualcrafters.plot.object.Plot; -import com.intellectualcrafters.plot.object.PlotArea; -import com.intellectualcrafters.plot.object.PlotCluster; -import com.intellectualcrafters.plot.object.PlotId; -import com.intellectualcrafters.plot.object.PlotPlayer; -import com.intellectualcrafters.plot.object.Rating; +import com.intellectualcrafters.plot.object.*; import com.intellectualcrafters.plot.util.EventUtil; -import com.plotsquared.bukkit.events.ClusterFlagRemoveEvent; -import com.plotsquared.bukkit.events.PlayerClaimPlotEvent; -import com.plotsquared.bukkit.events.PlayerEnterPlotEvent; -import com.plotsquared.bukkit.events.PlayerLeavePlotEvent; -import com.plotsquared.bukkit.events.PlayerPlotDeniedEvent; -import com.plotsquared.bukkit.events.PlayerPlotHelperEvent; -import com.plotsquared.bukkit.events.PlayerPlotTrustedEvent; -import com.plotsquared.bukkit.events.PlayerTeleportToPlotEvent; -import com.plotsquared.bukkit.events.PlotClearEvent; -import com.plotsquared.bukkit.events.PlotComponentSetEvent; -import com.plotsquared.bukkit.events.PlotDeleteEvent; -import com.plotsquared.bukkit.events.PlotFlagAddEvent; -import com.plotsquared.bukkit.events.PlotFlagRemoveEvent; -import com.plotsquared.bukkit.events.PlotMergeEvent; -import com.plotsquared.bukkit.events.PlotRateEvent; -import com.plotsquared.bukkit.events.PlotUnlinkEvent; +import com.plotsquared.bukkit.events.*; import com.plotsquared.bukkit.object.BukkitPlayer; import org.bukkit.Bukkit; import org.bukkit.entity.Player; @@ -110,12 +89,12 @@ public class BukkitEventUtil extends EventUtil { @Override public void callTrusted(PlotPlayer initiator, Plot plot, UUID player, boolean added) { - callEvent(new PlayerPlotHelperEvent(getPlayer(initiator), plot, player, added)); + callEvent(new PlayerPlotTrustedEvent(getPlayer(initiator), plot, player, added)); } @Override public void callMember(PlotPlayer initiator, Plot plot, UUID player, boolean added) { - callEvent(new PlayerPlotTrustedEvent(getPlayer(initiator), plot, player, added)); + callEvent(new PlayerPlotHelperEvent(getPlayer(initiator), plot, player, added)); } @Override diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Remove.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Remove.java index b1ad27bf3..9e311f743 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Remove.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Remove.java @@ -5,6 +5,7 @@ import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.util.EventUtil; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.UUIDHandler; @@ -71,20 +72,30 @@ public class Remove extends SubCommand { if (!uuids.isEmpty()) { for (UUID uuid : uuids) { if (uuid == DBFunc.everyone) { - if (plot.removeTrusted(uuid) | plot.removeMember(uuid) | plot.removeDenied(uuid)) { + if (plot.removeTrusted(uuid)){ + EventUtil.manager.callTrusted(player, plot, uuid, false); + count++; + }else if (plot.removeMember(uuid)) { + EventUtil.manager.callMember(player, plot, uuid, false); + count++; + }else if (plot.removeDenied(uuid)) { + EventUtil.manager.callDenied(player, plot, uuid, false); count++; } } else if (plot.getTrusted().contains(uuid)) { if (plot.removeTrusted(uuid)) { + EventUtil.manager.callTrusted(player, plot, uuid, false); count++; } } else if (plot.getMembers().contains(uuid)) { if (plot.removeMember(uuid)) { + EventUtil.manager.callMember(player, plot, uuid, false); count++; } } else if (plot.getDenied().contains(uuid)) { if (plot.removeDenied(uuid)) { + EventUtil.manager.callDenied(player, plot, uuid, false); count++; } } diff --git a/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeEventUtil.java b/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeEventUtil.java index d5f07d5d3..5dcc80c67 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeEventUtil.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeEventUtil.java @@ -106,12 +106,12 @@ public class SpongeEventUtil extends EventUtil { @Override public void callTrusted(PlotPlayer initiator, Plot plot, UUID player, boolean added) { - callEvent(new PlayerPlotHelperEvent(SpongeUtil.getPlayer(initiator), plot, player, added)); + callEvent(new PlayerPlotTrustedEvent(SpongeUtil.getPlayer(initiator), plot, player, added)); } @Override public void callMember(PlotPlayer initiator, Plot plot, UUID player, boolean added) { - callEvent(new PlayerPlotTrustedEvent(SpongeUtil.getPlayer(initiator), plot, player, added)); + callEvent(new PlayerPlotHelperEvent(SpongeUtil.getPlayer(initiator), plot, player, added)); } @Override