From 7aebd7da8ebb8a2e395837f746a706845abfc37b Mon Sep 17 00:00:00 2001 From: boy0001 Date: Fri, 5 Jun 2015 22:47:23 +1000 Subject: [PATCH] Work on making titles toggleable --- .../intellectualcrafters/plot/listeners/PlotListener.java | 4 +--- .../plot/object/comment/CommentManager.java | 2 +- .../com/intellectualcrafters/plot/titles/AbstractTitle.java | 6 ++++++ 3 files changed, 8 insertions(+), 4 deletions(-) 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 a8a97ba9f..16711f2b0 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotListener.java @@ -128,9 +128,7 @@ public class PlotListener extends APlotListener { } final String sTitleMain = C.TITLE_ENTERED_PLOT.s().replaceAll("%x%", plot.id.x + "").replaceAll("%z%", plot.id.y + "").replaceAll("%world%", plot.world + "").replaceAll("%greeting%", greeting).replaceFirst("%s", getName(plot.owner)); 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).replaceFirst("%s", getName(plot.owner)); - if (AbstractTitle.TITLE_CLASS != null) { - AbstractTitle.TITLE_CLASS.sendTitle(pp, sTitleMain, sTitleSub, ChatColor.valueOf(C.TITLE_ENTERED_PLOT_COLOR.s()), ChatColor.valueOf(C.TITLE_ENTERED_PLOT_SUB_COLOR.s()), 1, 2, 1); - } + AbstractTitle.sendTitle(pp, sTitleMain, sTitleSub, ChatColor.valueOf(C.TITLE_ENTERED_PLOT_COLOR.s()), ChatColor.valueOf(C.TITLE_ENTERED_PLOT_SUB_COLOR.s())); } { final PlayerEnterPlotEvent callEvent = new PlayerEnterPlotEvent(player, plot); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/comment/CommentManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/comment/CommentManager.java index 5f4d64681..65f81d551 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/comment/CommentManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/comment/CommentManager.java @@ -50,7 +50,7 @@ public class CommentManager { total = count.get(); } if (size.decrementAndGet() == 0 && total > 0) { - AbstractTitle.TITLE_CLASS.sendTitle(player, "", C.INBOX_NOTIFICATION.s().replaceAll("%s", "" + total), ChatColor.GOLD, ChatColor.valueOf(C.TITLE_ENTERED_PLOT_SUB_COLOR.s()), 1, 2, 1); + AbstractTitle.sendTitle(player, "", C.INBOX_NOTIFICATION.s().replaceAll("%s", "" + total), ChatColor.GOLD, ChatColor.valueOf(C.TITLE_ENTERED_PLOT_SUB_COLOR.s())); } } }); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/titles/AbstractTitle.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/titles/AbstractTitle.java index 66569a20b..0020083f7 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/titles/AbstractTitle.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/titles/AbstractTitle.java @@ -6,6 +6,12 @@ import com.intellectualcrafters.plot.object.PlotPlayer; public abstract class AbstractTitle { public static AbstractTitle TITLE_CLASS; + + public static void sendTitle(PlotPlayer player, String head, String sub, ChatColor head_color, ChatColor sub_color) { + if (TITLE_CLASS != null && !player.getAttribute("disabletitles")) { + TITLE_CLASS.sendTitle(player, head, sub, head_color, sub_color, 1, 2, 1); + } + } public abstract void sendTitle(PlotPlayer player, String head, String sub, ChatColor head_color, ChatColor sub_color, int in, int delay, int out); }