mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-25 22:56:45 +01:00
Mobhealth bars are no longer a per-player setting.
Removed the mobhealthbar command. Removed the mobhealthbar permissions.
This commit is contained in:
parent
c51be84b50
commit
6ff13077be
@ -123,6 +123,8 @@ Version 2.1.0
|
||||
! (Permissions) Counter Attack permission node renamed to mcmmo.ability.swords.counterattack
|
||||
! (Permissions) Arrow Deflect permission node renamed to mcmmo.ability.unarmed.arrowdeflect
|
||||
! (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) 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
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
@ -4,10 +4,8 @@ import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.MobHealthbarType;
|
||||
import com.gmail.nossr50.datatypes.meta.OldName;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.runnables.MobHealthDisplayUpdaterTask;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -34,13 +32,11 @@ public final class MobHealthbarUtils {
|
||||
|
||||
/**
|
||||
* Handle the creation of mob healthbars.
|
||||
*
|
||||
* @param player the attacking player
|
||||
* @param target the targetted entity
|
||||
* @param target the targetted entity
|
||||
* @param damage damage done by the attack triggering this
|
||||
*/
|
||||
public static void handleMobHealthbars(Player player, LivingEntity target, double damage, mcMMO plugin) {
|
||||
if (mcMMO.isHealthBarPluginEnabled() || !Permissions.mobHealthDisplay(player) || !Config.getInstance().getMobHealthbarEnabled()) {
|
||||
public static void handleMobHealthbars(LivingEntity target, double damage, mcMMO plugin) {
|
||||
if (mcMMO.isHealthBarPluginEnabled() || !Config.getInstance().getMobHealthbarEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -48,20 +44,9 @@ public final class MobHealthbarUtils {
|
||||
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 oldName = target.getCustomName();
|
||||
|
||||
|
||||
/*
|
||||
* Store the name in metadata
|
||||
*/
|
||||
@ -76,7 +61,7 @@ public final class MobHealthbarUtils {
|
||||
}
|
||||
|
||||
boolean oldNameVisible = target.isCustomNameVisible();
|
||||
String newName = createHealthDisplay(profile, target, damage);
|
||||
String newName = createHealthDisplay(Config.getInstance().getMobHealthbarDefault(), target, damage);
|
||||
|
||||
target.setCustomName(newName);
|
||||
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 currentHealth = Math.max(entity.getHealth() - damage, 0);
|
||||
double healthPercentage = (currentHealth / maxHealth) * 100.0D;
|
||||
@ -108,7 +93,7 @@ public final class MobHealthbarUtils {
|
||||
ChatColor color = ChatColor.BLACK;
|
||||
String symbol;
|
||||
|
||||
switch (profile.getMobHealthbarType()) {
|
||||
switch (mobHealthbarType) {
|
||||
case HEARTS:
|
||||
fullDisplay = Math.min((int) (maxHealth / 2), 10);
|
||||
color = ChatColor.DARK_RED;
|
||||
|
@ -372,15 +372,6 @@ public final class CommandRegistrationManager {
|
||||
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() {
|
||||
PluginCommand command = mcMMO.p.getCommand("mhd");
|
||||
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();
|
||||
registerMcrefreshCommand();
|
||||
registerMcscoreboardCommand();
|
||||
registerMobhealthCommand();
|
||||
registerMHDCommand();
|
||||
registerXprateCommand();
|
||||
|
||||
|
@ -15,7 +15,6 @@ import com.gmail.nossr50.runnables.skills.BleedTimerTask;
|
||||
import com.gmail.nossr50.skills.acrobatics.AcrobaticsManager;
|
||||
import com.gmail.nossr50.skills.archery.ArcheryManager;
|
||||
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.taming.TamingManager;
|
||||
import com.gmail.nossr50.skills.unarmed.UnarmedManager;
|
||||
@ -731,6 +730,6 @@ public final class CombatUtils {
|
||||
return;
|
||||
}
|
||||
|
||||
MobHealthbarUtils.handleMobHealthbars(player, target, damage, plugin);
|
||||
MobHealthbarUtils.handleMobHealthbars(target, damage, plugin);
|
||||
}
|
||||
}
|
||||
|
@ -157,10 +157,6 @@ commands:
|
||||
aliases: [notify]
|
||||
description: Toggle mcMMO abilities chat display notifications on/off
|
||||
permission: mcmmo.commands.mcnotify
|
||||
mobhealth:
|
||||
aliases: [mcmobhealth]
|
||||
description: Change the style of the mob healthbar
|
||||
permission: mcmmo.commands.mobhealth
|
||||
mhd:
|
||||
description: Sets all players mob health settings to default
|
||||
permission: mcmmo.commands.mhd
|
||||
@ -771,7 +767,6 @@ permissions:
|
||||
mcmmo.commands.mcstats: true
|
||||
mcmmo.commands.mctop.all: true
|
||||
mcmmo.commands.mining: true
|
||||
mcmmo.commands.mobhealth: true
|
||||
mcmmo.commands.party.all: true
|
||||
mcmmo.commands.ptp.all: true
|
||||
mcmmo.commands.repair: true
|
||||
@ -1019,8 +1014,6 @@ permissions:
|
||||
description: Allows access to the mmoedit command for other players
|
||||
mcmmo.commands.mmoshowdb:
|
||||
description: Allows access to the mmoshowdb command
|
||||
mcmmo.commands.mobhealth:
|
||||
description: Allows access to the mobhealth command
|
||||
mcmmo.commands.mhd:
|
||||
default: false
|
||||
description: Allows access to the mhd command
|
||||
@ -1295,7 +1288,6 @@ permissions:
|
||||
children:
|
||||
mcmmo.chat.partychat: true
|
||||
mcmmo.commands.defaults: true
|
||||
mcmmo.mobhealthdisplay: true
|
||||
mcmmo.motd: true
|
||||
mcmmo.skills.all: true
|
||||
mcmmo.defaultsop:
|
||||
@ -1317,8 +1309,6 @@ permissions:
|
||||
mcmmo.item.chimaerawing: true
|
||||
mcmmo.item.chimaerawing:
|
||||
description: Allows use of Chimaera Wing item
|
||||
mcmmo.mobhealthdisplay:
|
||||
description: Allows viewing of mob health display during combat
|
||||
mcmmo.party.*:
|
||||
default: false
|
||||
description: Implies access to all mcmmo party permissions
|
||||
|
Loading…
Reference in New Issue
Block a user