Added support for MythicMobs for blacklisting option
This commit is contained in:
parent
70518492c5
commit
9193d88830
15
config.yml
15
config.yml
|
@ -49,11 +49,6 @@ Full Health Icon: "&4\u2764"
|
|||
Half Health Icon: "&c\u2764"
|
||||
Empty Health Icon: "&7\u2764"
|
||||
|
||||
# Translate names. Case sensitive!
|
||||
Name Change: false
|
||||
Name:
|
||||
- Snow Golem = New name
|
||||
|
||||
# ActionHealth will be disabled for any world names added below. Case sensitive!
|
||||
Disabled worlds:
|
||||
- randomworld
|
||||
|
@ -72,6 +67,7 @@ Limit Health: 10
|
|||
Remember Toggle: false
|
||||
|
||||
# Blacklist by entity name or entity display name.
|
||||
# Also supports MythicMobs using the internal name.
|
||||
Blacklist:
|
||||
- 'CCPD Officer'
|
||||
|
||||
|
@ -86,4 +82,11 @@ Can See: true
|
|||
Invisible Potion: true
|
||||
|
||||
# Hide if entity is in spectator mode.
|
||||
Spectator Mode: true
|
||||
Spectator Mode: true
|
||||
|
||||
# Translate names. Case sensitive!
|
||||
# I'd appreciate if servers that use custom translations share them with me, so I can share them with others!
|
||||
# For users that do, I will tag them on Spigot and display their server IP.
|
||||
Name Change: false
|
||||
Name:
|
||||
- Snow Golem = New name
|
|
@ -1,7 +1,7 @@
|
|||
name: ActionHealth
|
||||
main: com.zeshanaslam.actionhealth.Main
|
||||
version: 3.3.4
|
||||
softdepend: [PlaceholderAPI, MVdWPlaceholderAPI, WorldGuard, mcMMO]
|
||||
version: 3.3.5
|
||||
softdepend: [PlaceholderAPI, MVdWPlaceholderAPI, WorldGuard, mcMMO, MythicMobs]
|
||||
commands:
|
||||
Actionhealth:
|
||||
description: Actionhealth main commands.
|
|
@ -45,7 +45,7 @@ public class LookThread extends BukkitRunnable {
|
|||
|
||||
String name = plugin.healthUtil.getName(livingEntity);
|
||||
|
||||
if (TargetHelper.canSee(player, livingEntity.getLocation(), transparentTypeIds) && !plugin.configStore.blacklist.contains(name)) {
|
||||
if (TargetHelper.canSee(player, livingEntity.getLocation(), transparentTypeIds) && !plugin.healthUtil.isBlacklisted(livingEntity, name)) {
|
||||
plugin.healthUtil.sendHealth(player, livingEntity, livingEntity.getHealth());
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ public class Main extends JavaPlugin {
|
|||
public HealthUtil healthUtil;
|
||||
public int taskID = -1;
|
||||
public boolean mcMMOEnabled;
|
||||
public boolean mythicMobsEnabled;
|
||||
|
||||
public List<UUID> toggle = new ArrayList<>();
|
||||
|
||||
|
@ -53,6 +54,10 @@ public class Main extends JavaPlugin {
|
|||
if (Bukkit.getServer().getPluginManager().isPluginEnabled("mcMMO")) {
|
||||
mcMMOEnabled = true;
|
||||
}
|
||||
|
||||
if (Bukkit.getServer().getPluginManager().isPluginEnabled("MythicMobs")) {
|
||||
mythicMobsEnabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -19,7 +19,7 @@ public class ConfigStore {
|
|||
public boolean showMobs;
|
||||
public boolean showPlayers;
|
||||
public boolean delay;
|
||||
public long delayTick;
|
||||
public int delayTick;
|
||||
public boolean checkPvP;
|
||||
public boolean stripName;
|
||||
public boolean rememberToggle;
|
||||
|
@ -74,9 +74,9 @@ public class ConfigStore {
|
|||
showNPC = plugin.getConfig().getBoolean("Show NPC");
|
||||
delay = plugin.getConfig().getBoolean("Delay Message");
|
||||
if (plugin.getConfig().contains("Delay Tick")) {
|
||||
delayTick = plugin.getConfig().getLong("Delay Tick");
|
||||
delayTick = plugin.getConfig().getInt("Delay Tick");
|
||||
} else {
|
||||
delayTick = 1L;
|
||||
delayTick = 1;
|
||||
}
|
||||
|
||||
checkPvP = plugin.getConfig().getBoolean("Region PvP");
|
||||
|
|
|
@ -28,26 +28,19 @@ public class HealthListeners implements Listener {
|
|||
}
|
||||
|
||||
Entity damaged = event.getEntity();
|
||||
Player player = null;
|
||||
if (event.getDamager() instanceof Projectile) {
|
||||
Projectile projectile = (Projectile) event.getDamager();
|
||||
|
||||
if (projectile.getShooter() instanceof Player) {
|
||||
Player player = (Player) projectile.getShooter();
|
||||
if (!plugin.healthUtil.matchesRequirements(player, damaged)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Send health
|
||||
if (damaged instanceof LivingEntity) {
|
||||
LivingEntity livingEntity = (LivingEntity) damaged;
|
||||
plugin.healthUtil.sendHealth(player, livingEntity, livingEntity.getHealth() - event.getFinalDamage());
|
||||
}
|
||||
player = (Player) projectile.getShooter();
|
||||
}
|
||||
}
|
||||
|
||||
if (event.getDamager() instanceof Player) {
|
||||
Player player = (Player) event.getDamager();
|
||||
if (event.getDamager() instanceof Player)
|
||||
player = (Player) event.getDamager();
|
||||
|
||||
if (player != null) {
|
||||
if (!plugin.healthUtil.matchesRequirements(player, damaged)) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
package com.zeshanaslam.actionhealth.support;
|
||||
|
||||
import io.lumine.xikage.mythicmobs.MythicMobs;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
public class MythicMobsSupport {
|
||||
public String getMythicName(Entity entity) {
|
||||
if (MythicMobs.inst().getAPIHelper().isMythicMob(entity)) {
|
||||
return MythicMobs.inst().getAPIHelper().getMythicMobInstance(entity).getType().getInternalName();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -2,6 +2,7 @@ package com.zeshanaslam.actionhealth.utils;
|
|||
|
||||
import com.zeshanaslam.actionhealth.Main;
|
||||
import com.zeshanaslam.actionhealth.support.McMMOSupport;
|
||||
import com.zeshanaslam.actionhealth.support.MythicMobsSupport;
|
||||
import com.zeshanaslam.actionhealth.support.PreAction;
|
||||
import org.apache.commons.lang.WordUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
|
@ -80,7 +81,7 @@ public class HealthUtil {
|
|||
if (health < 0.0 || entity.isDead()) health = 0.0;
|
||||
|
||||
String name = getName(entity);
|
||||
if (plugin.configStore.blacklist.contains(name)) return null;
|
||||
if (plugin.healthUtil.isBlacklisted(entity, name)) return null;
|
||||
if (plugin.configStore.stripName) name = ChatColor.stripColor(name);
|
||||
|
||||
String output = plugin.configStore.healthMessage;
|
||||
|
@ -329,4 +330,15 @@ public class HealthUtil {
|
|||
plugin.healthUtil.sendActionBar(player, plugin.configStore.toggleMessage.replace("{name}", player.getName()));
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isBlacklisted(Entity entity, String name) {
|
||||
if (plugin.mythicMobsEnabled) {
|
||||
String mythicName = new MythicMobsSupport().getMythicName(entity);
|
||||
if (mythicName != null && plugin.configStore.blacklist.contains(mythicName)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return plugin.configStore.blacklist.contains(name);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue