Added support for PlaceholderAPI and MVdWPlaceholderAPI
This commit is contained in:
parent
f8a17d4fb2
commit
87dc8a9c99
|
@ -4,6 +4,7 @@
|
||||||
# {maxhealth} shows the max health of the mob or player.
|
# {maxhealth} shows the max health of the mob or player.
|
||||||
# {usestyle} will use the defined chars.
|
# {usestyle} will use the defined chars.
|
||||||
# {displayname} will use player/mob custom name.
|
# {displayname} will use player/mob custom name.
|
||||||
|
# Has support for PlaceholderAPI and MVdWPlaceholderAPI.
|
||||||
Health Message: '&7&l{name}: {usestyle}'
|
Health Message: '&7&l{name}: {usestyle}'
|
||||||
|
|
||||||
# The message the player is sent to the player if they have actionhealth disabled.
|
# The message the player is sent to the player if they have actionhealth disabled.
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,6 +1,7 @@
|
||||||
name: ActionHealth
|
name: ActionHealth
|
||||||
main: com.zeshanaslam.actionhealth.Main
|
main: com.zeshanaslam.actionhealth.Main
|
||||||
version: 3.2.1
|
version: 3.2.2
|
||||||
|
softdepend: [PlaceholderAPI, MVdWPlaceholderAPI]
|
||||||
commands:
|
commands:
|
||||||
Actionhealth:
|
Actionhealth:
|
||||||
description: Actionhealth main command.
|
description: Actionhealth main command.
|
|
@ -3,6 +3,7 @@ package com.zeshanaslam.actionhealth;
|
||||||
import be.maximvdw.placeholderapi.PlaceholderAPI;
|
import be.maximvdw.placeholderapi.PlaceholderAPI;
|
||||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
@ -103,6 +104,15 @@ public class HealthUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
output = output.replace("{displayname}", displayName);
|
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 {
|
} else {
|
||||||
output = output.replace("{displayname}", name);
|
output = output.replace("{displayname}", name);
|
||||||
}
|
}
|
||||||
|
@ -148,10 +158,6 @@ public class HealthUtil {
|
||||||
output = output.replace("{usestyle}", style.toString());
|
output = output.replace("{usestyle}", style.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.settingsManager.placeholderAPI) {
|
|
||||||
output = PlaceholderAPI.replacePlaceholders(receiver, output);
|
|
||||||
}
|
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,8 @@ public class SettingsManager {
|
||||||
public String toggleMessage;
|
public String toggleMessage;
|
||||||
public String enableMessage;
|
public String enableMessage;
|
||||||
public String disableMessage;
|
public String disableMessage;
|
||||||
public boolean placeholderAPI;
|
public boolean hasMVdWPlaceholderAPI;
|
||||||
|
public boolean hasPlaceholderAPI;
|
||||||
public int limitHealth;
|
public int limitHealth;
|
||||||
|
|
||||||
public SettingsManager(Main plugin) {
|
public SettingsManager(Main plugin) {
|
||||||
|
@ -49,7 +50,10 @@ public class SettingsManager {
|
||||||
if (plugin.taskID != -1) Bukkit.getScheduler().cancelTask(plugin.taskID);
|
if (plugin.taskID != -1) Bukkit.getScheduler().cancelTask(plugin.taskID);
|
||||||
|
|
||||||
// Check if using MVdWPlaceholderAPI
|
// 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
|
// Get settings from config
|
||||||
healthMessage = plugin.getConfig().getString("Health Message");
|
healthMessage = plugin.getConfig().getString("Health Message");
|
||||||
|
|
Loading…
Reference in New Issue