Mobhealth bars are no longer a per-player setting.

Removed the mobhealthbar command.
Removed the mobhealthbar permissions.
This commit is contained in:
nossr50 2019-01-23 15:39:04 -08:00
parent c51be84b50
commit 6ff13077be
6 changed files with 9 additions and 112 deletions

View File

@ -123,6 +123,8 @@ Version 2.1.0
! (Permissions) Counter Attack permission node renamed to mcmmo.ability.swords.counterattack ! (Permissions) Counter Attack permission node renamed to mcmmo.ability.swords.counterattack
! (Permissions) Arrow Deflect permission node renamed to mcmmo.ability.unarmed.arrowdeflect ! (Permissions) Arrow Deflect permission node renamed to mcmmo.ability.unarmed.arrowdeflect
! (Permissions) Iron Arm Style permission node renamed to mcmmo.ability.unarmed.ironarmstyle ! (Permissions) Iron Arm Style permission node renamed to mcmmo.ability.unarmed.ironarmstyle
! (Permissions) Remove all mob health bar permissions, this is no longer a per-player setting.
! (Commands) Removed the mobhealthbar command, this is no longer a per-player setting.
! (Locale) The descriptions of a few skills have changed ! (Locale) The descriptions of a few skills have changed
! (Locale) Removed redundant information from some skill names and descriptions en_US (other locales will need to be updated) ! (Locale) Removed redundant information from some skill names and descriptions en_US (other locales will need to be updated)
! (Locale) SubSkill locale keys are now located at {ParentSkill}.SubSkill.SubSkillName ! (Locale) SubSkill locale keys are now located at {ParentSkill}.SubSkill.SubSkillName

View File

@ -1,69 +0,0 @@
package com.gmail.nossr50.commands;
import com.gmail.nossr50.datatypes.MobHealthbarType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player;
import org.bukkit.util.StringUtil;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class MobhealthCommand implements TabExecutor {
private static final List<String> MOB_HEALTHBAR_TYPES;
static {
ArrayList<String> types = new ArrayList<String>();
for (MobHealthbarType type : MobHealthbarType.values()) {
types.add(type.toString());
}
Collections.sort(types);
MOB_HEALTHBAR_TYPES = ImmutableList.copyOf(types);
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (CommandUtils.noConsoleUsage(sender)) {
return true;
}
if (!CommandUtils.hasPlayerDataKey(sender)) {
return true;
}
switch (args.length) {
case 1:
try {
MobHealthbarType type = MobHealthbarType.valueOf(args[0].toUpperCase().trim());
UserManager.getPlayer((Player) sender).getProfile().setMobHealthbarType(type);
sender.sendMessage(LocaleLoader.getString("Commands.Healthbars.Changed." + type.name()));
return true;
}
catch (IllegalArgumentException ex) {
sender.sendMessage(LocaleLoader.getString("Commands.Healthbars.Invalid"));
return true;
}
default:
return false;
}
}
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
switch (args.length) {
case 1:
return StringUtil.copyPartialMatches(args[0], MOB_HEALTHBAR_TYPES, new ArrayList<String>(MOB_HEALTHBAR_TYPES.size()));
default:
return ImmutableList.of();
}
}
}

View File

@ -4,10 +4,8 @@ import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config; import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.MobHealthbarType; import com.gmail.nossr50.datatypes.MobHealthbarType;
import com.gmail.nossr50.datatypes.meta.OldName; import com.gmail.nossr50.datatypes.meta.OldName;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.runnables.MobHealthDisplayUpdaterTask; import com.gmail.nossr50.runnables.MobHealthDisplayUpdaterTask;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -34,13 +32,11 @@ public final class MobHealthbarUtils {
/** /**
* Handle the creation of mob healthbars. * Handle the creation of mob healthbars.
* * @param target the targetted entity
* @param player the attacking player
* @param target the targetted entity
* @param damage damage done by the attack triggering this * @param damage damage done by the attack triggering this
*/ */
public static void handleMobHealthbars(Player player, LivingEntity target, double damage, mcMMO plugin) { public static void handleMobHealthbars(LivingEntity target, double damage, mcMMO plugin) {
if (mcMMO.isHealthBarPluginEnabled() || !Permissions.mobHealthDisplay(player) || !Config.getInstance().getMobHealthbarEnabled()) { if (mcMMO.isHealthBarPluginEnabled() || !Config.getInstance().getMobHealthbarEnabled()) {
return; return;
} }
@ -48,20 +44,9 @@ public final class MobHealthbarUtils {
return; return;
} }
PlayerProfile profile = UserManager.getPlayer(player).getProfile();
if (profile.getMobHealthbarType() == null) {
profile.setMobHealthbarType(Config.getInstance().getMobHealthbarDefault());
}
if (profile.getMobHealthbarType() == MobHealthbarType.DISABLED) {
return;
}
String originalName = target.getName(); String originalName = target.getName();
String oldName = target.getCustomName(); String oldName = target.getCustomName();
/* /*
* Store the name in metadata * Store the name in metadata
*/ */
@ -76,7 +61,7 @@ public final class MobHealthbarUtils {
} }
boolean oldNameVisible = target.isCustomNameVisible(); boolean oldNameVisible = target.isCustomNameVisible();
String newName = createHealthDisplay(profile, target, damage); String newName = createHealthDisplay(Config.getInstance().getMobHealthbarDefault(), target, damage);
target.setCustomName(newName); target.setCustomName(newName);
target.setCustomNameVisible(true); target.setCustomNameVisible(true);
@ -99,7 +84,7 @@ public final class MobHealthbarUtils {
} }
} }
private static String createHealthDisplay(PlayerProfile profile, LivingEntity entity, double damage) { private static String createHealthDisplay(MobHealthbarType mobHealthbarType, LivingEntity entity, double damage) {
double maxHealth = entity.getMaxHealth(); double maxHealth = entity.getMaxHealth();
double currentHealth = Math.max(entity.getHealth() - damage, 0); double currentHealth = Math.max(entity.getHealth() - damage, 0);
double healthPercentage = (currentHealth / maxHealth) * 100.0D; double healthPercentage = (currentHealth / maxHealth) * 100.0D;
@ -108,7 +93,7 @@ public final class MobHealthbarUtils {
ChatColor color = ChatColor.BLACK; ChatColor color = ChatColor.BLACK;
String symbol; String symbol;
switch (profile.getMobHealthbarType()) { switch (mobHealthbarType) {
case HEARTS: case HEARTS:
fullDisplay = Math.min((int) (maxHealth / 2), 10); fullDisplay = Math.min((int) (maxHealth / 2), 10);
color = ChatColor.DARK_RED; color = ChatColor.DARK_RED;

View File

@ -372,15 +372,6 @@ public final class CommandRegistrationManager {
command.setExecutor(new McnotifyCommand()); command.setExecutor(new McnotifyCommand());
} }
private static void registerMobhealthCommand() {
PluginCommand command = mcMMO.p.getCommand("mobhealth");
command.setDescription("Change the style of the mob healthbar"); //TODO: Localize
command.setPermission("mcmmo.commands.mobhealth");
command.setPermissionMessage(permissionsMessage);
command.setUsage(LocaleLoader.getString("Commands.Usage.1", "mobhealth", "<DISABLED | HEARTS | BAR>"));
command.setExecutor(new MobhealthCommand());
}
private static void registerMHDCommand() { private static void registerMHDCommand() {
PluginCommand command = mcMMO.p.getCommand("mhd"); PluginCommand command = mcMMO.p.getCommand("mhd");
command.setDescription("Resets all mob health bar settings for all players to the default"); //TODO: Localize command.setDescription("Resets all mob health bar settings for all players to the default"); //TODO: Localize
@ -430,7 +421,6 @@ public final class CommandRegistrationManager {
registerMcnotifyCommand(); registerMcnotifyCommand();
registerMcrefreshCommand(); registerMcrefreshCommand();
registerMcscoreboardCommand(); registerMcscoreboardCommand();
registerMobhealthCommand();
registerMHDCommand(); registerMHDCommand();
registerXprateCommand(); registerXprateCommand();

View File

@ -15,7 +15,6 @@ import com.gmail.nossr50.runnables.skills.BleedTimerTask;
import com.gmail.nossr50.skills.acrobatics.AcrobaticsManager; import com.gmail.nossr50.skills.acrobatics.AcrobaticsManager;
import com.gmail.nossr50.skills.archery.ArcheryManager; import com.gmail.nossr50.skills.archery.ArcheryManager;
import com.gmail.nossr50.skills.axes.AxesManager; import com.gmail.nossr50.skills.axes.AxesManager;
import com.gmail.nossr50.skills.swords.Swords;
import com.gmail.nossr50.skills.swords.SwordsManager; import com.gmail.nossr50.skills.swords.SwordsManager;
import com.gmail.nossr50.skills.taming.TamingManager; import com.gmail.nossr50.skills.taming.TamingManager;
import com.gmail.nossr50.skills.unarmed.UnarmedManager; import com.gmail.nossr50.skills.unarmed.UnarmedManager;
@ -731,6 +730,6 @@ public final class CombatUtils {
return; return;
} }
MobHealthbarUtils.handleMobHealthbars(player, target, damage, plugin); MobHealthbarUtils.handleMobHealthbars(target, damage, plugin);
} }
} }

View File

@ -157,10 +157,6 @@ commands:
aliases: [notify] aliases: [notify]
description: Toggle mcMMO abilities chat display notifications on/off description: Toggle mcMMO abilities chat display notifications on/off
permission: mcmmo.commands.mcnotify permission: mcmmo.commands.mcnotify
mobhealth:
aliases: [mcmobhealth]
description: Change the style of the mob healthbar
permission: mcmmo.commands.mobhealth
mhd: mhd:
description: Sets all players mob health settings to default description: Sets all players mob health settings to default
permission: mcmmo.commands.mhd permission: mcmmo.commands.mhd
@ -771,7 +767,6 @@ permissions:
mcmmo.commands.mcstats: true mcmmo.commands.mcstats: true
mcmmo.commands.mctop.all: true mcmmo.commands.mctop.all: true
mcmmo.commands.mining: true mcmmo.commands.mining: true
mcmmo.commands.mobhealth: true
mcmmo.commands.party.all: true mcmmo.commands.party.all: true
mcmmo.commands.ptp.all: true mcmmo.commands.ptp.all: true
mcmmo.commands.repair: true mcmmo.commands.repair: true
@ -1019,8 +1014,6 @@ permissions:
description: Allows access to the mmoedit command for other players description: Allows access to the mmoedit command for other players
mcmmo.commands.mmoshowdb: mcmmo.commands.mmoshowdb:
description: Allows access to the mmoshowdb command description: Allows access to the mmoshowdb command
mcmmo.commands.mobhealth:
description: Allows access to the mobhealth command
mcmmo.commands.mhd: mcmmo.commands.mhd:
default: false default: false
description: Allows access to the mhd command description: Allows access to the mhd command
@ -1295,7 +1288,6 @@ permissions:
children: children:
mcmmo.chat.partychat: true mcmmo.chat.partychat: true
mcmmo.commands.defaults: true mcmmo.commands.defaults: true
mcmmo.mobhealthdisplay: true
mcmmo.motd: true mcmmo.motd: true
mcmmo.skills.all: true mcmmo.skills.all: true
mcmmo.defaultsop: mcmmo.defaultsop:
@ -1317,8 +1309,6 @@ permissions:
mcmmo.item.chimaerawing: true mcmmo.item.chimaerawing: true
mcmmo.item.chimaerawing: mcmmo.item.chimaerawing:
description: Allows use of Chimaera Wing item description: Allows use of Chimaera Wing item
mcmmo.mobhealthdisplay:
description: Allows viewing of mob health display during combat
mcmmo.party.*: mcmmo.party.*:
default: false default: false
description: Implies access to all mcmmo party permissions description: Implies access to all mcmmo party permissions