Initial placeholderAPI support.
Give me ideas on what else to add and I'll add it.
This commit is contained in:
@@ -58,6 +58,7 @@ public class P extends MPlugin {
|
||||
public CmdAutoHelp cmdAutoHelp;
|
||||
|
||||
private boolean hookedPlayervaults;
|
||||
private PlaceholderAPIManager placeholderAPIManager;
|
||||
|
||||
public P() {
|
||||
p = this;
|
||||
@@ -116,10 +117,20 @@ public class P extends MPlugin {
|
||||
// since some other plugins execute commands directly through this command interface, provide it
|
||||
this.getCommand(this.refCommand).setExecutor(this);
|
||||
|
||||
setupPlaceholderAPI();
|
||||
postEnable();
|
||||
this.loadSuccessful = true;
|
||||
}
|
||||
|
||||
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.");
|
||||
}
|
||||
}
|
||||
|
||||
private boolean setupPermissions() {
|
||||
try {
|
||||
RegisteredServiceProvider<Permission> rsp = getServer().getServicesManager().getRegistration(Permission.class);
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.massivecraft.factions.util;
|
||||
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.FPlayers;
|
||||
import com.massivecraft.factions.P;
|
||||
import me.clip.placeholderapi.external.EZPlaceholderHook;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class PlaceholderAPIManager extends EZPlaceholderHook {
|
||||
|
||||
public PlaceholderAPIManager() {
|
||||
super(P.p, "factionsuuid");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String onPlaceholderRequest(Player player, String placeholder) {
|
||||
if(player == null || placeholder == null) {
|
||||
return "";
|
||||
}
|
||||
|
||||
FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player);
|
||||
switch(placeholder) {
|
||||
case "faction":
|
||||
return fPlayer.getFaction().getTag();
|
||||
case "power":
|
||||
return String.valueOf(fPlayer.getPower());
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@ name: Factions
|
||||
version: ${project.version}
|
||||
main: com.massivecraft.factions.P
|
||||
authors: [Olof Larsson, Brett Flannigan, drtshock]
|
||||
softdepend: [PlayerVaults, PermissionsEx, Permissions, Essentials, EssentialsChat, HeroChat, iChat, LocalAreaChat, LWC, nChat, ChatManager, CAPI, AuthMe, Vault, Spout, WorldEdit, WorldGuard, AuthDB, CaptureThePoints, CombatTag, dynmap]
|
||||
softdepend: [PlayerVaults, PlaceholderAPI, 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.
|
||||
|
||||
Reference in New Issue
Block a user