From c465d0c9d42468f5582a0b75101047c7a41a85ed Mon Sep 17 00:00:00 2001 From: Trent Hensler Date: Sat, 6 Jan 2018 16:56:43 -0800 Subject: [PATCH] Add suppport for MVdW placeholder API --- pom.xml | 15 +++++++++++ .../java/com/massivecraft/factions/P.java | 27 +++++++++++++------ .../scoreboards/FSidebarProvider.java | 5 +++- ...er.java => ClipPlaceholderAPIManager.java} | 4 +-- src/main/resources/plugin.yml | 2 +- 5 files changed, 41 insertions(+), 12 deletions(-) rename src/main/java/com/massivecraft/factions/util/{PlaceholderAPIManager.java => ClipPlaceholderAPIManager.java} (98%) diff --git a/pom.xml b/pom.xml index 1ea5286c..4f96d873 100644 --- a/pom.xml +++ b/pom.xml @@ -301,6 +301,17 @@ 2.8.2 provided + + be.maximvdw + MVdWPlaceholderAPI + 2.2.3-SNAPSHOT + + + org.spigotmc + spigot + + + @@ -328,5 +339,9 @@ placeholderapi http://repo.extendedclip.com/content/repositories/placeholderapi/ + + mvdw-software + http://repo.mvdw-software.be/content/groups/public/ + diff --git a/src/main/java/com/massivecraft/factions/P.java b/src/main/java/com/massivecraft/factions/P.java index f3d2e55f..9f4c5aea 100644 --- a/src/main/java/com/massivecraft/factions/P.java +++ b/src/main/java/com/massivecraft/factions/P.java @@ -61,7 +61,8 @@ public class P extends MPlugin { public CmdAutoHelp cmdAutoHelp; private boolean hookedPlayervaults; - private PlaceholderAPIManager placeholderAPIManager; + private ClipPlaceholderAPIManager clipPlaceholderAPIManager; + private boolean mvdwPlaceholderAPIManager = false; public P() { p = this; @@ -126,16 +127,26 @@ public class P extends MPlugin { } private void setupPlaceholderAPI() { - Plugin plugin = getServer().getPluginManager().getPlugin("PlaceholderAPI"); - if (plugin != null && plugin.isEnabled()) { - this.placeholderAPIManager = new PlaceholderAPIManager(); - this.placeholderAPIManager.hook(); - log(Level.INFO, "Found PlaceholderAPI. Adding hooks."); + Plugin clip = getServer().getPluginManager().getPlugin("PlaceholderAPI"); + if (clip != null && clip.isEnabled()) { + this.clipPlaceholderAPIManager = new ClipPlaceholderAPIManager(); + this.clipPlaceholderAPIManager.hook(); + log(Level.INFO, "Found Clip's PlaceholderAPI. Adding hooks."); + } + + Plugin mvdw = getServer().getPluginManager().getPlugin("MVdWPlaceholderAPI"); + if (mvdw != null && mvdw.isEnabled()) { + this.mvdwPlaceholderAPIManager = true; + log(Level.INFO, "Found MVdWPlaceholderAPI. Adding hooks."); } } - public boolean isPlaceholderAPIHooked() { - return this.placeholderAPIManager != null; + public boolean isClipPlaceholderAPIHooked() { + return this.clipPlaceholderAPIManager != null; + } + + public boolean isMVdWPlaceholderAPIHooked() { + return this.mvdwPlaceholderAPIManager; } private boolean setupPermissions() { diff --git a/src/main/java/com/massivecraft/factions/scoreboards/FSidebarProvider.java b/src/main/java/com/massivecraft/factions/scoreboards/FSidebarProvider.java index 68169058..1f29c66e 100644 --- a/src/main/java/com/massivecraft/factions/scoreboards/FSidebarProvider.java +++ b/src/main/java/com/massivecraft/factions/scoreboards/FSidebarProvider.java @@ -21,9 +21,12 @@ public abstract class FSidebarProvider { public String replaceTags(Faction faction, FPlayer fPlayer, String s) { // Run through Placeholder API first - if (P.p.isPlaceholderAPIHooked() && fPlayer.isOnline()) { + if (P.p.isClipPlaceholderAPIHooked() && fPlayer.isOnline()) { s = PlaceholderAPI.setPlaceholders(fPlayer.getPlayer(), s); } + if (P.p.isMVdWPlaceholderAPIHooked() && fPlayer.isOnline()) { + s = be.maximvdw.placeholderapi.PlaceholderAPI.replacePlaceholders(fPlayer.getPlayer(), s); + } return qualityAssure(TagUtil.parsePlain(faction, fPlayer, s)); } diff --git a/src/main/java/com/massivecraft/factions/util/PlaceholderAPIManager.java b/src/main/java/com/massivecraft/factions/util/ClipPlaceholderAPIManager.java similarity index 98% rename from src/main/java/com/massivecraft/factions/util/PlaceholderAPIManager.java rename to src/main/java/com/massivecraft/factions/util/ClipPlaceholderAPIManager.java index 21a4bfa3..2f48f738 100644 --- a/src/main/java/com/massivecraft/factions/util/PlaceholderAPIManager.java +++ b/src/main/java/com/massivecraft/factions/util/ClipPlaceholderAPIManager.java @@ -12,9 +12,9 @@ import org.bukkit.entity.Player; import java.util.UUID; -public class PlaceholderAPIManager extends EZPlaceholderHook { +public class ClipPlaceholderAPIManager extends EZPlaceholderHook { - public PlaceholderAPIManager() { + public ClipPlaceholderAPIManager() { super(P.p, "factionsuuid"); } diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 0f29173c..554248bc 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -2,7 +2,7 @@ name: Factions version: ${project.version}-b${build.number} main: com.massivecraft.factions.P authors: [Olof Larsson, Brett Flannigan, drtshock] -softdepend: [PlayerVaults, PlaceholderAPI, PermissionsEx, Permissions, Essentials, EssentialsChat, HeroChat, iChat, LocalAreaChat, LWC, nChat, ChatManager, CAPI, AuthMe, Vault, Spout, WorldEdit, WorldGuard, AuthDB, CaptureThePoints, CombatTag, dynmap] +softdepend: [PlayerVaults, PlaceholderAPI, MVdWPlaceholderAPI, PermissionsEx, Permissions, Essentials, EssentialsChat, HeroChat, iChat, LocalAreaChat, LWC, nChat, ChatManager, CAPI, AuthMe, Vault, Spout, WorldEdit, WorldGuard, AuthDB, CaptureThePoints, CombatTag, dynmap] commands: factions: description: Reference command for Factions.