mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-06-25 02:04:44 +02:00
Mobhealth bars are no longer a per-player setting.
Removed the mobhealthbar command. Removed the mobhealthbar permissions.
This commit is contained in:
@ -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;
|
||||
|
@ -371,15 +371,6 @@ public final class CommandRegistrationManager {
|
||||
command.setUsage(LocaleLoader.getString("Commands.Usage.0", "mcnotify"));
|
||||
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");
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user