Initial placeholderAPI support.
Give me ideas on what else to add and I'll add it.
This commit is contained in:
parent
24c7107163
commit
fe7002f674
10
pom.xml
10
pom.xml
@ -295,6 +295,12 @@
|
||||
<artifactId>PlayerVaults</artifactId>
|
||||
<version>3.6.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>me.clip</groupId>
|
||||
<artifactId>placeholderapi</artifactId>
|
||||
<version>2.8.2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<repositories>
|
||||
@ -318,5 +324,9 @@
|
||||
<id>repo.mikeprimm.com</id>
|
||||
<url>http://repo.mikeprimm.com/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>placeholderapi</id>
|
||||
<url>http://repo.extendedclip.com/content/repositories/placeholderapi/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
</project>
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user