2013-11-16 00:21:00 +01:00
|
|
|
package com.gmail.nossr50.commands.skills;
|
|
|
|
|
2019-01-13 08:54:53 +01:00
|
|
|
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
2019-01-09 04:52:52 +01:00
|
|
|
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
2013-11-16 00:21:00 +01:00
|
|
|
import com.gmail.nossr50.locale.LocaleLoader;
|
2013-12-31 00:30:58 +01:00
|
|
|
import com.gmail.nossr50.skills.alchemy.AlchemyManager;
|
2019-01-25 05:45:26 +01:00
|
|
|
import com.gmail.nossr50.util.Permissions;
|
2019-01-15 07:11:58 +01:00
|
|
|
import com.gmail.nossr50.util.TextComponentFactory;
|
2013-11-16 00:21:00 +01:00
|
|
|
import com.gmail.nossr50.util.player.UserManager;
|
2019-01-15 11:53:33 +01:00
|
|
|
import com.gmail.nossr50.util.skills.RankUtils;
|
2019-01-15 07:11:58 +01:00
|
|
|
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() {
|
2019-01-13 08:54:53 +01:00
|
|
|
super(PrimarySkillType.ALCHEMY);
|
2013-11-16 00:21:00 +01:00
|
|
|
}
|
|
|
|
|
2019-01-25 05:45:26 +01:00
|
|
|
protected String[] calculateAbilityDisplayValues(Player player) {
|
2019-04-13 00:17:05 +02:00
|
|
|
//TODO: Needed?
|
|
|
|
if(UserManager.getPlayer(player) == null)
|
|
|
|
{
|
|
|
|
player.sendMessage(LocaleLoader.getString("Profile.PendingLoad"));
|
|
|
|
return new String[] {"DATA NOT LOADED", "DATA NOT LOADED"};
|
|
|
|
}
|
|
|
|
|
2013-12-31 00:30:58 +01:00
|
|
|
AlchemyManager alchemyManager = UserManager.getPlayer(player).getAlchemyManager();
|
2013-11-16 00:21:00 +01:00
|
|
|
String[] displayValues = new String[2];
|
|
|
|
|
2019-01-25 05:45:26 +01:00
|
|
|
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
|
2019-01-25 05:45:26 +01:00
|
|
|
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) {
|
2019-01-25 05:45:26 +01:00
|
|
|
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) {
|
2013-12-31 00:30:58 +01:00
|
|
|
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) {
|
2019-01-15 12:16:21 +01:00
|
|
|
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) {
|
2020-07-13 21:31:30 +02:00
|
|
|
List<String> messages = new ArrayList<>();
|
2013-11-16 00:21:00 +01:00
|
|
|
|
|
|
|
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<>();
|
2019-01-04 16:58:39 +01:00
|
|
|
|
2019-01-13 08:54:53 +01:00
|
|
|
TextComponentFactory.getSubSkillTextComponents(player, textComponents, PrimarySkillType.ALCHEMY);
|
2019-01-04 16:58:39 +01:00
|
|
|
|
2019-01-02 17:06:18 +01:00
|
|
|
return textComponents;
|
|
|
|
}
|
2013-11-16 00:21:00 +01:00
|
|
|
}
|