Merge branch 'master' into 3.3.6

This commit is contained in:
Zeshan Aslam 2019-08-08 11:49:52 -04:00 committed by GitHub
commit 705aabe419
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 39 additions and 8 deletions

View File

@ -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

View File

@ -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.

View File

@ -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());

View File

@ -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

View File

@ -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");

View File

@ -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);
}
}

View File

@ -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);