From a2362882bf6c0b4469093377573c2b1650a2aa39 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Fri, 10 Jul 2015 01:31:34 +1000 Subject: [PATCH] Fixed feed / heal flags --- .../plot/flag/FlagValue.java | 2 +- .../plot/listeners/PlotListener.java | 6 ++++ .../plot/listeners/PlotPlusListener.java | 29 ++++++++++--------- 3 files changed, 23 insertions(+), 14 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagValue.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagValue.java index 1854834fb..cd857da41 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagValue.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/flag/FlagValue.java @@ -133,7 +133,7 @@ public abstract class FlagValue { @Override public String getDescription() { - return "Value(s) must be numeric. /plot set flag {flag} {amount} [seconds]"; + return "Value(s) must be numeric. /plot set flag [amount]"; } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotListener.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotListener.java index b1f868104..5ce9fa4c3 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotListener.java @@ -38,6 +38,7 @@ import com.intellectualcrafters.plot.events.PlayerEnterPlotEvent; import com.intellectualcrafters.plot.events.PlayerLeavePlotEvent; import com.intellectualcrafters.plot.flag.Flag; import com.intellectualcrafters.plot.flag.FlagManager; +import com.intellectualcrafters.plot.flag.FlagValue; import com.intellectualcrafters.plot.object.BukkitPlayer; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotPlayer; @@ -134,6 +135,11 @@ public class PlotListener extends APlotListener { final String sTitleSub = C.TITLE_ENTERED_PLOT_SUB.s().replaceAll("%x%", plot.id.x + "").replaceAll("%z%", plot.id.y + "").replaceAll("%world%", plot.world + "").replaceAll("%greeting%", greeting).replaceAll("%s", getName(plot.owner)).replaceAll("%alias%", alias); AbstractTitle.sendTitle(pp, sTitleMain, sTitleSub, ChatColor.valueOf(C.TITLE_ENTERED_PLOT_COLOR.s()), ChatColor.valueOf(C.TITLE_ENTERED_PLOT_SUB_COLOR.s())); } + Flag feed = FlagManager.getPlotFlag(plot, "feed"); + if (feed != null) { + PlotPlusListener.manager.feed.getValue() + } + { final PlayerEnterPlotEvent callEvent = new PlayerEnterPlotEvent(player, plot); Bukkit.getPluginManager().callEvent(callEvent); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotPlusListener.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotPlusListener.java index e29a27a7a..e3143d91a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotPlusListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotPlusListener.java @@ -45,6 +45,7 @@ import org.bukkit.plugin.java.JavaPlugin; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.events.PlayerEnterPlotEvent; import com.intellectualcrafters.plot.events.PlayerLeavePlotEvent; +import com.intellectualcrafters.plot.flag.Flag; import com.intellectualcrafters.plot.flag.FlagManager; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotHandler; @@ -156,10 +157,21 @@ public class PlotPlusListener extends PlotListener implements Listener { @EventHandler public void onPlotEnter(final PlayerEnterPlotEvent event) { + Player player = event.getPlayer(); final Plot plot = event.getPlot(); if (FlagManager.getPlotFlag(plot, "greeting") != null) { event.getPlayer().sendMessage(ChatColor.translateAlternateColorCodes('&', C.PREFIX_GREETING.s().replaceAll("%id%", plot.id + "") + FlagManager.getPlotFlag(plot, "greeting").getValueString())); } + Flag feed = FlagManager.getPlotFlag(plot, "feed"); + if (feed != null) { + Integer[] value = (Integer[]) feed.getValue(); + feedRunnable.put(player.getName(), new Interval(value[0], value[1], 20)); + } + Flag heal = FlagManager.getPlotFlag(plot, "heal"); + if (heal != null) { + Integer[] value = (Integer[]) heal.getValue(); + healRunnable.put(player.getName(), new Interval(value[0], value[1], 20)); + } if (FlagManager.isBooleanFlag(plot, "notify-enter", false)) { final Player trespasser = event.getPlayer(); final PlotPlayer pt = BukkitUtil.getPlayer(trespasser); @@ -187,12 +199,8 @@ public class PlotPlusListener extends PlotListener implements Listener { public void onPlayerQuit(final PlayerQuitEvent event) { final Player player = event.getPlayer(); final String name = player.getName(); - if (feedRunnable.containsKey(name)) { - feedRunnable.remove(name); - } - if (healRunnable.containsKey(name)) { - healRunnable.remove(name); - } + feedRunnable.remove(name); + healRunnable.remove(name); } @EventHandler @@ -203,13 +211,8 @@ public class PlotPlusListener extends PlotListener implements Listener { event.getPlayer().sendMessage(ChatColor.translateAlternateColorCodes('&', C.PREFIX_FAREWELL.s().replaceAll("%id%", plot.id + "") + FlagManager.getPlotFlag(plot, "farewell").getValueString())); } final PlotPlayer pl = BukkitUtil.getPlayer(leaver); - pl.getName(); - if (feedRunnable.containsKey(leaver)) { - feedRunnable.remove(leaver); - } - if (healRunnable.containsKey(leaver)) { - healRunnable.remove(leaver); - } + feedRunnable.remove(leaver.getName()); + healRunnable.remove(leaver.getName()); if (FlagManager.isBooleanFlag(plot, "notify-leave", false)) { if (Perm.hasPermission(pl, "plots.flag.notify-leave.bypass")) { return;