Fixed feed / heal flags

This commit is contained in:
boy0001 2015-07-10 01:31:34 +10:00
parent 3a1577469b
commit a2362882bf
3 changed files with 23 additions and 14 deletions

View File

@ -133,7 +133,7 @@ public abstract class FlagValue<T> {
@Override @Override
public String getDescription() { public String getDescription() {
return "Value(s) must be numeric. /plot set flag {flag} {amount} [seconds]"; return "Value(s) must be numeric. /plot set flag <flag> <interval> [amount]";
} }
} }

View File

@ -38,6 +38,7 @@ import com.intellectualcrafters.plot.events.PlayerEnterPlotEvent;
import com.intellectualcrafters.plot.events.PlayerLeavePlotEvent; import com.intellectualcrafters.plot.events.PlayerLeavePlotEvent;
import com.intellectualcrafters.plot.flag.Flag; import com.intellectualcrafters.plot.flag.Flag;
import com.intellectualcrafters.plot.flag.FlagManager; import com.intellectualcrafters.plot.flag.FlagManager;
import com.intellectualcrafters.plot.flag.FlagValue;
import com.intellectualcrafters.plot.object.BukkitPlayer; import com.intellectualcrafters.plot.object.BukkitPlayer;
import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotPlayer; 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); 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())); 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); final PlayerEnterPlotEvent callEvent = new PlayerEnterPlotEvent(player, plot);
Bukkit.getPluginManager().callEvent(callEvent); Bukkit.getPluginManager().callEvent(callEvent);

View File

@ -45,6 +45,7 @@ import org.bukkit.plugin.java.JavaPlugin;
import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.events.PlayerEnterPlotEvent; import com.intellectualcrafters.plot.events.PlayerEnterPlotEvent;
import com.intellectualcrafters.plot.events.PlayerLeavePlotEvent; import com.intellectualcrafters.plot.events.PlayerLeavePlotEvent;
import com.intellectualcrafters.plot.flag.Flag;
import com.intellectualcrafters.plot.flag.FlagManager; import com.intellectualcrafters.plot.flag.FlagManager;
import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotHandler; import com.intellectualcrafters.plot.object.PlotHandler;
@ -156,10 +157,21 @@ public class PlotPlusListener extends PlotListener implements Listener {
@EventHandler @EventHandler
public void onPlotEnter(final PlayerEnterPlotEvent event) { public void onPlotEnter(final PlayerEnterPlotEvent event) {
Player player = event.getPlayer();
final Plot plot = event.getPlot(); final Plot plot = event.getPlot();
if (FlagManager.getPlotFlag(plot, "greeting") != null) { if (FlagManager.getPlotFlag(plot, "greeting") != null) {
event.getPlayer().sendMessage(ChatColor.translateAlternateColorCodes('&', C.PREFIX_GREETING.s().replaceAll("%id%", plot.id + "") + FlagManager.getPlotFlag(plot, "greeting").getValueString())); 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)) { if (FlagManager.isBooleanFlag(plot, "notify-enter", false)) {
final Player trespasser = event.getPlayer(); final Player trespasser = event.getPlayer();
final PlotPlayer pt = BukkitUtil.getPlayer(trespasser); final PlotPlayer pt = BukkitUtil.getPlayer(trespasser);
@ -187,13 +199,9 @@ public class PlotPlusListener extends PlotListener implements Listener {
public void onPlayerQuit(final PlayerQuitEvent event) { public void onPlayerQuit(final PlayerQuitEvent event) {
final Player player = event.getPlayer(); final Player player = event.getPlayer();
final String name = player.getName(); final String name = player.getName();
if (feedRunnable.containsKey(name)) {
feedRunnable.remove(name); feedRunnable.remove(name);
}
if (healRunnable.containsKey(name)) {
healRunnable.remove(name); healRunnable.remove(name);
} }
}
@EventHandler @EventHandler
public void onPlotLeave(final PlayerLeavePlotEvent event) { public void onPlotLeave(final PlayerLeavePlotEvent event) {
@ -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())); event.getPlayer().sendMessage(ChatColor.translateAlternateColorCodes('&', C.PREFIX_FAREWELL.s().replaceAll("%id%", plot.id + "") + FlagManager.getPlotFlag(plot, "farewell").getValueString()));
} }
final PlotPlayer pl = BukkitUtil.getPlayer(leaver); final PlotPlayer pl = BukkitUtil.getPlayer(leaver);
pl.getName(); feedRunnable.remove(leaver.getName());
if (feedRunnable.containsKey(leaver)) { healRunnable.remove(leaver.getName());
feedRunnable.remove(leaver);
}
if (healRunnable.containsKey(leaver)) {
healRunnable.remove(leaver);
}
if (FlagManager.isBooleanFlag(plot, "notify-leave", false)) { if (FlagManager.isBooleanFlag(plot, "notify-leave", false)) {
if (Perm.hasPermission(pl, "plots.flag.notify-leave.bypass")) { if (Perm.hasPermission(pl, "plots.flag.notify-leave.bypass")) {
return; return;