Added support for PlaceholderAPI and MVdWPlaceholderAPI

This commit is contained in:
Zeshan Aslam 2018-07-12 19:46:42 -04:00
parent f8a17d4fb2
commit 87dc8a9c99
7 changed files with 19 additions and 7 deletions

View File

@ -4,6 +4,7 @@
# {maxhealth} shows the max health of the mob or player.
# {usestyle} will use the defined chars.
# {displayname} will use player/mob custom name.
# Has support for PlaceholderAPI and MVdWPlaceholderAPI.
Health Message: '&7&l{name}: {usestyle}'
# The message the player is sent to the player if they have actionhealth disabled.

View File

@ -1,6 +1,7 @@
name: ActionHealth
main: com.zeshanaslam.actionhealth.Main
version: 3.2.1
version: 3.2.2
softdepend: [PlaceholderAPI, MVdWPlaceholderAPI]
commands:
Actionhealth:
description: Actionhealth main command.

View File

@ -3,6 +3,7 @@ package com.zeshanaslam.actionhealth;
import be.maximvdw.placeholderapi.PlaceholderAPI;
import com.sk89q.worldguard.protection.ApplicableRegionSet;
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.entity.LivingEntity;
@ -103,6 +104,15 @@ public class HealthUtil {
}
output = output.replace("{displayname}", displayName);
// Placeholder apis
if (plugin.settingsManager.hasMVdWPlaceholderAPI) {
output = be.maximvdw.placeholderapi.PlaceholderAPI.replacePlaceholders(player, output);
}
if (plugin.settingsManager.hasPlaceholderAPI) {
output = me.clip.placeholderapi.PlaceholderAPI.setPlaceholders(player, output);
}
} else {
output = output.replace("{displayname}", name);
}
@ -148,10 +158,6 @@ public class HealthUtil {
output = output.replace("{usestyle}", style.toString());
}
if (plugin.settingsManager.placeholderAPI) {
output = PlaceholderAPI.replacePlaceholders(receiver, output);
}
return output;
}

View File

@ -36,7 +36,8 @@ public class SettingsManager {
public String toggleMessage;
public String enableMessage;
public String disableMessage;
public boolean placeholderAPI;
public boolean hasMVdWPlaceholderAPI;
public boolean hasPlaceholderAPI;
public int limitHealth;
public SettingsManager(Main plugin) {
@ -49,7 +50,10 @@ public class SettingsManager {
if (plugin.taskID != -1) Bukkit.getScheduler().cancelTask(plugin.taskID);
// Check if using MVdWPlaceholderAPI
placeholderAPI = Bukkit.getPluginManager().isPluginEnabled("MVdWPlaceholderAPI");
hasMVdWPlaceholderAPI = Bukkit.getPluginManager().isPluginEnabled("MVdWPlaceholderAPI");
// Check if using placeholderAPI
hasPlaceholderAPI = Bukkit.getPluginManager().isPluginEnabled("PlaceholderAPI");
// Get settings from config
healthMessage = plugin.getConfig().getString("Health Message");