From e6ea62ad1e712fa1277aae321872a4c822c87211 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Tue, 21 Jul 2015 13:56:49 +1000 Subject: [PATCH] Fixes #430 --- .../plot/commands/Deny.java | 3 --- .../plot/commands/FlagCmd.java | 3 --- .../plot/commands/MusicSubcommand.java | 7 ------ .../plot/flag/FlagManager.java | 4 ++++ .../plot/util/MainUtil.java | 24 +++++++++++++++++++ 5 files changed, 28 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Deny.java b/src/main/java/com/intellectualcrafters/plot/commands/Deny.java index 0d16aeac4..b0b3ebd79 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/Deny.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/Deny.java @@ -84,9 +84,6 @@ public class Deny extends SubCommand { plot.addDenied(uuid); EventUtil.manager.callDenied(plr, plot, uuid, true); MainUtil.sendMessage(plr, C.DENIED_ADDED); - // if (!uuid.equals(DBFunc.everyone)) { - // PS.get().IMP.handleKick(uuid, C.YOU_GOT_DENIED); - //} if (!uuid.equals(DBFunc.everyone)) { handleKick(uuid, plot); } diff --git a/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java b/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java index 0a2c21549..9e35bb161 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java @@ -130,7 +130,6 @@ public class FlagCmd extends SubCommand { return false; } MainUtil.sendMessage(player, C.FLAG_ADDED); - APlotListener.manager.plotEntry(player, plot); return true; } case "remove": { @@ -168,7 +167,6 @@ public class FlagCmd extends SubCommand { } } MainUtil.sendMessage(player, C.FLAG_REMOVED); - APlotListener.manager.plotEntry(player, plot); return true; } case "add": { @@ -208,7 +206,6 @@ public class FlagCmd extends SubCommand { } DBFunc.setFlags(plot, plot.settings.flags.values()); MainUtil.sendMessage(player, C.FLAG_ADDED); - APlotListener.manager.plotEntry(player, plot); return true; } case "list": { diff --git a/src/main/java/com/intellectualcrafters/plot/commands/MusicSubcommand.java b/src/main/java/com/intellectualcrafters/plot/commands/MusicSubcommand.java index 2dae6f83a..c457d10bb 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/MusicSubcommand.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/MusicSubcommand.java @@ -60,13 +60,6 @@ PlotInventory inv = new PlotInventory(player, 2, "Plot Jukebox") { else { FlagManager.addPlotFlag(plot, new Flag(FlagManager.getFlag("music"), id)); } - TaskManager.runTaskLater(new Runnable() { - @Override - public void run() { - PlotListener.manager.plotEntry(player, plot); - } - }, 1); - close(); return false; } }; diff --git a/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java b/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java index 677b72d10..e8b53b78e 100644 --- a/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java +++ b/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java @@ -31,6 +31,7 @@ import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotSettings; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.util.EventUtil; +import com.intellectualcrafters.plot.util.MainUtil; /** * Flag Manager Utility @@ -203,6 +204,7 @@ public class FlagManager { return false; } plot.settings.flags.put(flag.getKey(), flag); + MainUtil.reEnterPlot(plot); DBFunc.setFlags(plot, plot.settings.flags.values()); return true; } @@ -267,6 +269,7 @@ public class FlagManager { plot.settings.flags.put(id, flag); return false; } + MainUtil.reEnterPlot(plot); DBFunc.setFlags(plot, plot.settings.flags.values()); return true; } @@ -298,6 +301,7 @@ public class FlagManager { else { plot.settings.flags.clear(); } + MainUtil.reEnterPlot(plot); DBFunc.setFlags(plot, plot.settings.flags.values()); } diff --git a/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java b/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java index 0960a8ebb..db7bf8540 100644 --- a/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java +++ b/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java @@ -23,6 +23,7 @@ package com.intellectualcrafters.plot.util; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; +import java.util.List; import java.util.Map.Entry; import java.util.UUID; @@ -30,6 +31,7 @@ import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.database.DBFunc; +import com.intellectualcrafters.plot.listeners.PlotListener; import com.intellectualcrafters.plot.object.BlockLoc; import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.Location; @@ -68,6 +70,28 @@ public class MainUtil { return true; } + public static List getPlayersInPlot(Plot plot) { + ArrayList players = new ArrayList<>(); + for (PlotPlayer pp : UUIDHandler.players.values()) { + if (plot.equals(MainUtil.getPlot(pp.getLocation()))) { + players.add(pp); + } + } + return players; + } + + public static void reEnterPlot(final Plot plot) { + TaskManager.runTaskLater(new Runnable() { + @Override + public void run() { + for (PlotPlayer pp : getPlayersInPlot(plot)) { + PlotListener.manager.plotExit(pp, plot); + PlotListener.manager.plotEntry(pp, plot); + } + } + }, 1); + } + public static Location getPlotCenter(Plot plot) { Location bot = getPlotBottomLoc(plot.world, plot.id); Location top = getPlotBottomLoc(plot.world, plot.id).add(1, 0, 1);