Add suppport for MVdW placeholder API

This commit is contained in:
Trent Hensler
2018-01-06 16:56:43 -08:00
parent af9fc526d7
commit c465d0c9d4
5 changed files with 41 additions and 12 deletions

View File

@@ -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() {

View File

@@ -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));
}

View File

@@ -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");
}