From 7e34d9e20a6f4d8b09014851a835bf338b745b19 Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Wed, 30 Nov 2016 21:26:52 +1100 Subject: [PATCH] Fix title logic --- .../bukkit/titles/DefaultTitle_111.java | 24 +++++++++++++------ ...ltTitle_110.java => DefaultTitle_180.java} | 2 +- 2 files changed, 18 insertions(+), 8 deletions(-) rename Bukkit/src/main/java/com/plotsquared/bukkit/titles/{DefaultTitle_110.java => DefaultTitle_180.java} (92%) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/titles/DefaultTitle_111.java b/Bukkit/src/main/java/com/plotsquared/bukkit/titles/DefaultTitle_111.java index 6afb3341e..be6cfc568 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/titles/DefaultTitle_111.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/titles/DefaultTitle_111.java @@ -1,22 +1,32 @@ package com.plotsquared.bukkit.titles; +import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.AbstractTitle; import com.plotsquared.bukkit.object.BukkitPlayer; +import com.plotsquared.bukkit.util.BukkitVersion; import org.bukkit.entity.Player; @SuppressWarnings("deprecation") public class DefaultTitle_111 extends AbstractTitle { + private final boolean valid; + + public DefaultTitle_111() { + this.valid = PS.get().checkVersion(PS.get().IMP.getServerVersion(), BukkitVersion.v1_11_0); + } + @Override public void sendTitle(PlotPlayer player, String head, String sub, int in, int delay, int out) { - try { - final Player playerObj = ((BukkitPlayer) player).player; - TitleManager_1_11 title = new TitleManager_1_11(head, sub, in, delay, out); - title.send(playerObj); - } catch (Throwable ignored) { - AbstractTitle.TITLE_CLASS = new DefaultTitle_110(); - AbstractTitle.TITLE_CLASS.sendTitle(player, head, sub, in, delay, out); + if (valid) { + try { + final Player playerObj = ((BukkitPlayer) player).player; + TitleManager_1_11 title = new TitleManager_1_11(head, sub, in, delay, out); + title.send(playerObj); + return; + } catch (Throwable ignored) {} } + AbstractTitle.TITLE_CLASS = new DefaultTitle_180(); + AbstractTitle.TITLE_CLASS.sendTitle(player, head, sub, in, delay, out); } } diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/titles/DefaultTitle_110.java b/Bukkit/src/main/java/com/plotsquared/bukkit/titles/DefaultTitle_180.java similarity index 92% rename from Bukkit/src/main/java/com/plotsquared/bukkit/titles/DefaultTitle_110.java rename to Bukkit/src/main/java/com/plotsquared/bukkit/titles/DefaultTitle_180.java index 324c6bd32..5f7836b13 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/titles/DefaultTitle_110.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/titles/DefaultTitle_180.java @@ -4,7 +4,7 @@ import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.AbstractTitle; import com.plotsquared.bukkit.object.BukkitPlayer; -public class DefaultTitle_110 extends AbstractTitle { +public class DefaultTitle_180 extends AbstractTitle { @Override public void sendTitle(PlotPlayer player, String head, String sub, int in, int delay, int out) {