mirror of
https://github.com/zeshan321/ActionHealth.git
synced 2024-11-13 06:15:12 +01:00
Merge branch 'master' into 3.3.6
This commit is contained in:
commit
705aabe419
@ -94,4 +94,8 @@ ShowMiniaturePets: true
|
||||
# For users that do, I will tag them on Spigot and display their server IP.
|
||||
Name Change: false
|
||||
Name:
|
||||
- Snow Golem = New name
|
||||
- Snow Golem = New name
|
||||
|
||||
# Translate names using Client Language. Need to install LanguageUtils
|
||||
# https://www.spigotmc.org/resources/1-7-x-1-12-language-utils.8859/
|
||||
Use Client Language: false
|
@ -1,7 +1,7 @@
|
||||
name: ActionHealth
|
||||
main: com.zeshanaslam.actionhealth.Main
|
||||
version: 3.3.6
|
||||
softdepend: [PlaceholderAPI, MVdWPlaceholderAPI, WorldGuard, mcMMO, MythicMobs]
|
||||
softdepend: [PlaceholderAPI, MVdWPlaceholderAPI, WorldGuard, mcMMO, MythicMobs, LangUtils]
|
||||
commands:
|
||||
Actionhealth:
|
||||
description: Actionhealth main commands.
|
@ -43,7 +43,7 @@ public class LookThread extends BukkitRunnable {
|
||||
for (LivingEntity livingEntity : entities) {
|
||||
if (!plugin.healthUtil.matchesRequirements(player, livingEntity)) continue;
|
||||
|
||||
String name = plugin.healthUtil.getName(livingEntity);
|
||||
String name = plugin.healthUtil.getName(livingEntity, player);
|
||||
|
||||
if (TargetHelper.canSee(player, livingEntity.getLocation(), transparentTypeIds) && !plugin.healthUtil.isBlacklisted(livingEntity, name)) {
|
||||
plugin.healthUtil.sendHealth(player, livingEntity, livingEntity.getHealth());
|
||||
|
@ -23,6 +23,7 @@ public class Main extends JavaPlugin {
|
||||
public int taskID = -1;
|
||||
public boolean mcMMOEnabled;
|
||||
public boolean mythicMobsEnabled;
|
||||
public boolean langUtilsEnabled;
|
||||
|
||||
public List<UUID> toggle = new ArrayList<>();
|
||||
|
||||
@ -58,6 +59,10 @@ public class Main extends JavaPlugin {
|
||||
if (Bukkit.getServer().getPluginManager().isPluginEnabled("MythicMobs")) {
|
||||
mythicMobsEnabled = true;
|
||||
}
|
||||
|
||||
if (Bukkit.getServer().getPluginManager().isPluginEnabled("LangUtils")) {
|
||||
langUtilsEnabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -26,6 +26,7 @@ public class ConfigStore {
|
||||
public boolean canSee;
|
||||
public boolean invisiblePotion;
|
||||
public boolean spectatorMode;
|
||||
public boolean useClientLanguage;
|
||||
public String filledHeartIcon;
|
||||
public String halfHeartIcon;
|
||||
public String emptyHeartIcon;
|
||||
@ -91,6 +92,7 @@ public class ConfigStore {
|
||||
translate.put(split[0], split[1]);
|
||||
}
|
||||
}
|
||||
useClientLanguage = plugin.getConfig().getBoolean("Use Client Language");
|
||||
|
||||
// Load disabled regions
|
||||
regions = plugin.getConfig().getStringList("Disabled regions");
|
||||
|
@ -0,0 +1,17 @@
|
||||
package com.zeshanaslam.actionhealth.support;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.meowj.langutils.lang.LanguageHelper;
|
||||
|
||||
public class LangUtilsSupport {
|
||||
|
||||
public String getName(Entity entity, Player player) {
|
||||
return LanguageHelper.getEntityName(entity, player);
|
||||
}
|
||||
|
||||
public String getName(Entity entity, String locale) {
|
||||
return LanguageHelper.getEntityName(entity, locale);
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@ package com.zeshanaslam.actionhealth.utils;
|
||||
|
||||
import com.zeshanaslam.actionhealth.Main;
|
||||
import com.zeshanaslam.actionhealth.api.HealthSendEvent;
|
||||
import com.zeshanaslam.actionhealth.support.LangUtilsSupport;
|
||||
import com.zeshanaslam.actionhealth.support.McMMOSupport;
|
||||
import com.zeshanaslam.actionhealth.support.MythicMobsSupport;
|
||||
import com.zeshanaslam.actionhealth.support.PreAction;
|
||||
@ -82,7 +83,7 @@ public class HealthUtil {
|
||||
|
||||
if (health < 0.0 || entity.isDead()) health = 0.0;
|
||||
|
||||
String name = getName(entity);
|
||||
String name = getName(entity, receiver);
|
||||
if (plugin.healthUtil.isBlacklisted(entity, name)) return null;
|
||||
if (plugin.configStore.stripName) name = ChatColor.stripColor(name);
|
||||
|
||||
@ -172,7 +173,7 @@ public class HealthUtil {
|
||||
return output;
|
||||
}
|
||||
|
||||
public String getName(LivingEntity entity) {
|
||||
public String getName(LivingEntity entity, Player receiver) {
|
||||
String name;
|
||||
|
||||
// Supporting mcmmo health bar to get to display correct name.
|
||||
@ -185,10 +186,12 @@ public class HealthUtil {
|
||||
}
|
||||
|
||||
if (mcMMOName == null) {
|
||||
if (entity.getCustomName() == null) {
|
||||
name = getNameReflection(entity);
|
||||
if (entity.getCustomName() != null) {
|
||||
name = entity.getCustomName();
|
||||
} else if(plugin.langUtilsEnabled && plugin.configStore.useClientLanguage && receiver != null) {
|
||||
name = new LangUtilsSupport().getName(entity, receiver);
|
||||
} else {
|
||||
name = entity.getCustomName();
|
||||
name = getNameReflection(entity);
|
||||
}
|
||||
} else if (mcMMOName.equals("")) {
|
||||
name = getNameReflection(entity);
|
||||
|
Loading…
Reference in New Issue
Block a user