mcMMO/src/main/java/com/gmail/nossr50/commands/skills/AlchemyCommand.java

104 lines
3.9 KiB
Java
Raw Normal View History

2013-11-16 00:21:00 +01:00
package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType;
2013-11-16 00:21:00 +01:00
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.alchemy.AlchemyManager;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.TextComponentFactory;
2013-11-16 00:21:00 +01:00
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.RankUtils;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
2013-11-16 00:21:00 +01:00
public class AlchemyCommand extends SkillCommand {
private String brewSpeed;
private String brewSpeedLucky;
private int tier;
private int ingredientCount;
private String ingredientList;
private boolean canCatalysis;
private boolean canConcoctions;
public AlchemyCommand() {
super(PrimarySkillType.ALCHEMY);
2013-11-16 00:21:00 +01:00
}
protected String[] calculateAbilityDisplayValues(Player player) {
//TODO: Needed?
if(UserManager.getPlayer(player) == null)
{
player.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
return new String[] {"DATA NOT LOADED", "DATA NOT LOADED"};
}
AlchemyManager alchemyManager = UserManager.getPlayer(player).getAlchemyManager();
2013-11-16 00:21:00 +01:00
String[] displayValues = new String[2];
boolean isLucky = Permissions.lucky(player, PrimarySkillType.ALCHEMY);
2014-02-11 22:22:57 +01:00
displayValues[0] = decimal.format(alchemyManager.calculateBrewSpeed(false)) + "x";
displayValues[1] = isLucky ? decimal.format(alchemyManager.calculateBrewSpeed(true)) + "x" : null;
2013-11-16 00:21:00 +01:00
return displayValues;
}
@Override
protected void dataCalculations(Player player, float skillValue) {
2018-12-29 14:24:55 +01:00
// ALCHEMY_CATALYSIS
2013-11-16 00:21:00 +01:00
if (canCatalysis) {
String[] catalysisStrings = calculateAbilityDisplayValues(player);
2013-11-16 00:21:00 +01:00
brewSpeed = catalysisStrings[0];
brewSpeedLucky = catalysisStrings[1];
}
2018-12-29 14:24:55 +01:00
// ALCHEMY_CONCOCTIONS
2013-11-16 00:21:00 +01:00
if (canConcoctions) {
AlchemyManager alchemyManager = UserManager.getPlayer(player).getAlchemyManager();
tier = alchemyManager.getTier();
ingredientCount = alchemyManager.getIngredients().size();
ingredientList = alchemyManager.getIngredientList();
2013-11-16 00:21:00 +01:00
}
}
@Override
protected void permissionsCheck(Player player) {
canCatalysis = canUseSubskill(player, SubSkillType.ALCHEMY_CATALYSIS);
canConcoctions = canUseSubskill(player, SubSkillType.ALCHEMY_CONCOCTIONS);
2013-11-16 00:21:00 +01:00
}
@Override
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
List<String> messages = new ArrayList<String>();
if (canCatalysis) {
2019-01-21 19:09:18 +01:00
messages.add(getStatMessage(SubSkillType.ALCHEMY_CATALYSIS, brewSpeed)
+ (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", brewSpeedLucky) : ""));
2013-11-16 00:21:00 +01:00
}
if (canConcoctions) {
2019-01-21 19:09:18 +01:00
messages.add(getStatMessage(false, true, SubSkillType.ALCHEMY_CONCOCTIONS, String.valueOf(tier), String.valueOf(RankUtils.getHighestRank(SubSkillType.ALCHEMY_CONCOCTIONS))));
messages.add(getStatMessage(true, true, SubSkillType.ALCHEMY_CONCOCTIONS, String.valueOf(ingredientCount), ingredientList));
//messages.add(LocaleLoader.getString("Alchemy.Concoctions.Rank", tier, RankUtils.getHighestRank(SubSkillType.ALCHEMY_CONCOCTIONS)));
//messages.add(LocaleLoader.getString("Alchemy.Concoctions.Ingredients", ingredientCount, ingredientList));
2013-11-16 00:21:00 +01:00
}
return messages;
}
2019-01-02 17:06:18 +01:00
@Override
protected List<TextComponent> getTextComponents(Player player) {
List<TextComponent> textComponents = new ArrayList<>();
TextComponentFactory.getSubSkillTextComponents(player, textComponents, PrimarySkillType.ALCHEMY);
2019-01-02 17:06:18 +01:00
return textComponents;
}
2013-11-16 00:21:00 +01:00
}