Use PlaceholderExpansion instead of EZPlaceholderHook to support relational placeholders (#1095)
This commit is contained in:
parent
a45833944b
commit
fc3473e83a
2
pom.xml
2
pom.xml
@ -299,7 +299,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>me.clip</groupId>
|
<groupId>me.clip</groupId>
|
||||||
<artifactId>placeholderapi</artifactId>
|
<artifactId>placeholderapi</artifactId>
|
||||||
<version>2.8.2</version>
|
<version>2.8.4</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -141,8 +141,9 @@ public class P extends MPlugin {
|
|||||||
Plugin clip = getServer().getPluginManager().getPlugin("PlaceholderAPI");
|
Plugin clip = getServer().getPluginManager().getPlugin("PlaceholderAPI");
|
||||||
if (clip != null && clip.isEnabled()) {
|
if (clip != null && clip.isEnabled()) {
|
||||||
this.clipPlaceholderAPIManager = new ClipPlaceholderAPIManager();
|
this.clipPlaceholderAPIManager = new ClipPlaceholderAPIManager();
|
||||||
this.clipPlaceholderAPIManager.hook();
|
if (this.clipPlaceholderAPIManager.register()) {
|
||||||
log(Level.INFO, "Found Clip's PlaceholderAPI. Adding hooks.");
|
log(Level.INFO, "Successfully registered placeholders with PlaceholderAPI.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Plugin mvdw = getServer().getPluginManager().getPlugin("MVdWPlaceholderAPI");
|
Plugin mvdw = getServer().getPluginManager().getPlugin("MVdWPlaceholderAPI");
|
||||||
|
@ -4,7 +4,8 @@ import com.massivecraft.factions.*;
|
|||||||
import com.massivecraft.factions.integration.Econ;
|
import com.massivecraft.factions.integration.Econ;
|
||||||
import com.massivecraft.factions.struct.Relation;
|
import com.massivecraft.factions.struct.Relation;
|
||||||
import com.massivecraft.factions.zcore.util.TL;
|
import com.massivecraft.factions.zcore.util.TL;
|
||||||
import me.clip.placeholderapi.external.EZPlaceholderHook;
|
import me.clip.placeholderapi.expansion.Relational;
|
||||||
|
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||||
import org.apache.commons.lang.time.DurationFormatUtils;
|
import org.apache.commons.lang.time.DurationFormatUtils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
@ -12,10 +13,48 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class ClipPlaceholderAPIManager extends EZPlaceholderHook {
|
public class ClipPlaceholderAPIManager extends PlaceholderExpansion implements Relational {
|
||||||
|
|
||||||
public ClipPlaceholderAPIManager() {
|
// Identifier for this expansion
|
||||||
super(P.p, "factionsuuid");
|
@Override
|
||||||
|
public String getIdentifier() {
|
||||||
|
return "factionsuuid";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Idk......
|
||||||
|
@Override
|
||||||
|
public String getAuthor() {
|
||||||
|
return "FactionsUUID";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Since we are registering this expansion from the dependency, this can be null
|
||||||
|
@Override
|
||||||
|
public String getPlugin() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return the plugin version since this expansion is bundled with the dependency
|
||||||
|
@Override
|
||||||
|
public String getVersion() {
|
||||||
|
return P.p.getDescription().getVersion();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Relational placeholders
|
||||||
|
@Override
|
||||||
|
public String onPlaceholderRequest(Player p1, Player p2, String placeholder) {
|
||||||
|
if (p1 == null || p2 == null || placeholder == null) return "";
|
||||||
|
FPlayer fp1 = FPlayers.getInstance().getByPlayer(p1);
|
||||||
|
FPlayer fp2 = FPlayers.getInstance().getByPlayer(p2);
|
||||||
|
if (fp1 == null || fp2 == null) return "";
|
||||||
|
switch (placeholder) {
|
||||||
|
case "relation":
|
||||||
|
String c = fp1.getRelationTo(fp2).nicename;
|
||||||
|
return c != null ? c : "";
|
||||||
|
case "relation_color":
|
||||||
|
ChatColor clr = fp1.getColorTo(fp2);
|
||||||
|
return clr != null ? clr.toString() : "";
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user