2013-11-16 00:21:00 +01:00
|
|
|
package com.gmail.nossr50.commands.skills;
|
|
|
|
|
2019-01-15 07:11:58 +01:00
|
|
|
import com.gmail.nossr50.config.AdvancedConfig;
|
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;
|
|
|
|
import com.gmail.nossr50.skills.alchemy.Alchemy.Tier;
|
2013-12-31 00:30:58 +01:00
|
|
|
import com.gmail.nossr50.skills.alchemy.AlchemyManager;
|
2013-11-16 00:21:00 +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
|
|
|
}
|
|
|
|
|
2013-12-31 00:30:58 +01:00
|
|
|
protected String[] calculateAbilityDisplayValues(Player player, boolean isLucky) {
|
|
|
|
AlchemyManager alchemyManager = UserManager.getPlayer(player).getAlchemyManager();
|
2013-11-16 00:21:00 +01:00
|
|
|
String[] displayValues = new String[2];
|
|
|
|
|
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, boolean isLucky) {
|
2018-12-29 14:24:55 +01:00
|
|
|
// ALCHEMY_CATALYSIS
|
2013-11-16 00:21:00 +01:00
|
|
|
if (canCatalysis) {
|
2013-12-31 00:30:58 +01:00
|
|
|
String[] catalysisStrings = calculateAbilityDisplayValues(player, isLucky);
|
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> effectsDisplay() {
|
|
|
|
List<String> messages = new ArrayList<String>();
|
2013-12-31 00:30:58 +01:00
|
|
|
|
2013-11-16 00:21:00 +01:00
|
|
|
if (canCatalysis) {
|
|
|
|
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Alchemy.Effect.0"), LocaleLoader.getString("Alchemy.Effect.1")));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (canConcoctions) {
|
|
|
|
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Alchemy.Effect.2"), LocaleLoader.getString("Alchemy.Effect.3")));
|
|
|
|
}
|
2013-12-31 00:30:58 +01:00
|
|
|
|
2013-11-16 00:21:00 +01:00
|
|
|
return messages;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
|
|
|
|
List<String> messages = new ArrayList<String>();
|
|
|
|
|
|
|
|
if (canCatalysis) {
|
2019-01-15 12:16:21 +01:00
|
|
|
messages.add(LocaleLoader.getString("Alchemy.Catalysis.Speed", brewSpeed) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", brewSpeedLucky) : ""));
|
2013-11-16 00:21:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (canConcoctions) {
|
2019-01-15 12:16:21 +01:00
|
|
|
messages.add(LocaleLoader.getString("Alchemy.Concoctions.Rank", tier, Tier.values().length));
|
|
|
|
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
|
|
|
}
|