mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-12-28 11:37:39 +01:00
Herbalism to SkillCommand
This commit is contained in:
parent
a16d5435de
commit
8cdecf80c7
@ -1,23 +1,11 @@
|
|||||||
package com.gmail.nossr50.commands.skills;
|
package com.gmail.nossr50.commands.skills;
|
||||||
|
|
||||||
import java.text.DecimalFormat;
|
import com.gmail.nossr50.commands.SkillCommand;
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import com.gmail.nossr50.commands.CommandHelper;
|
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
|
||||||
import com.gmail.nossr50.datatypes.SkillType;
|
import com.gmail.nossr50.datatypes.SkillType;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.util.Page;
|
|
||||||
import com.gmail.nossr50.util.Permissions;
|
|
||||||
import com.gmail.nossr50.util.Users;
|
|
||||||
|
|
||||||
public class HerbalismCommand implements CommandExecutor {
|
public class HerbalismCommand extends SkillCommand {
|
||||||
private float skillValue;
|
|
||||||
private String greenTerraLength;
|
private String greenTerraLength;
|
||||||
private String greenThumbChance;
|
private String greenThumbChance;
|
||||||
private String greenThumbStage;
|
private String greenThumbStage;
|
||||||
@ -31,83 +19,12 @@ public class HerbalismCommand implements CommandExecutor {
|
|||||||
private boolean canDoubleDrop;
|
private boolean canDoubleDrop;
|
||||||
private boolean doubleDropsDisabled;
|
private boolean doubleDropsDisabled;
|
||||||
|
|
||||||
@Override
|
public HerbalismCommand() {
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
super(SkillType.HERBALISM);
|
||||||
if (CommandHelper.noConsoleUsage(sender)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.skills.herbalism")) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
Player player = (Player) sender;
|
|
||||||
PlayerProfile PP = Users.getProfile(player);
|
|
||||||
|
|
||||||
skillValue = (float) PP.getSkillLevel(SkillType.HERBALISM);
|
|
||||||
dataCalculations(skillValue);
|
|
||||||
permissionsCheck(player);
|
|
||||||
|
|
||||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Herbalism.SkillName") }));
|
|
||||||
player.sendMessage(LocaleLoader.getString("Commands.XPGain", new Object[] { LocaleLoader.getString("Commands.XPGain.Herbalism") }));
|
|
||||||
player.sendMessage(LocaleLoader.getString("Effects.Level", new Object[] { PP.getSkillLevel(SkillType.HERBALISM), PP.getSkillXpLevel(SkillType.HERBALISM), PP.getXpToLevel(SkillType.HERBALISM) }));
|
|
||||||
|
|
||||||
if (canGreenTerra || (canDoubleDrop && !doubleDropsDisabled )|| canFarmersDiet || canGreenThumbBlocks || canGreenThumbWheat) {
|
|
||||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (canGreenTerra) {
|
|
||||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Herbalism.Effect.0"), LocaleLoader.getString("Herbalism.Effect.1") }));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (canGreenThumbWheat) {
|
|
||||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Herbalism.Effect.2"), LocaleLoader.getString("Herbalism.Effect.3") }));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (canGreenThumbBlocks) {
|
|
||||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Herbalism.Effect.4"), LocaleLoader.getString("Herbalism.Effect.5") }));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (canFarmersDiet) {
|
|
||||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Herbalism.Effect.6"), LocaleLoader.getString("Herbalism.Effect.7") }));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (canDoubleDrop && !doubleDropsDisabled) {
|
|
||||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Herbalism.Effect.8"), LocaleLoader.getString("Herbalism.Effect.9") }));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (canGreenTerra || (canDoubleDrop && !doubleDropsDisabled ) || canFarmersDiet || canGreenThumbBlocks || canGreenThumbWheat) {
|
|
||||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (canGreenTerra) {
|
|
||||||
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTe.Length", new Object[] { greenTerraLength }));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (canGreenThumbBlocks || canGreenThumbWheat) {
|
|
||||||
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTh.Chance", new Object[] { greenThumbChance }));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (canGreenThumbWheat) {
|
|
||||||
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTh.Stage", new Object[] { greenThumbStage }));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (canFarmersDiet) {
|
|
||||||
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.FD", new Object[] { farmersDietRank } ));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (canDoubleDrop && !doubleDropsDisabled) {
|
|
||||||
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.DoubleDropChance", new Object[] { doubleDropChance }));
|
|
||||||
}
|
|
||||||
|
|
||||||
Page.grabGuidePageForSkill(SkillType.HERBALISM, player, args);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void dataCalculations(float skillValue) {
|
@Override
|
||||||
DecimalFormat percent = new DecimalFormat("##0.00%");
|
protected void dataCalculations() {
|
||||||
|
|
||||||
greenTerraLength = String.valueOf(2 + ((int) skillValue / 50));
|
greenTerraLength = String.valueOf(2 + ((int) skillValue / 50));
|
||||||
|
|
||||||
if (skillValue >= 1500) {
|
if (skillValue >= 1500) {
|
||||||
@ -154,8 +71,8 @@ public class HerbalismCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void permissionsCheck(Player player) {
|
@Override
|
||||||
Permissions permInstance = Permissions.getInstance();
|
protected void permissionsCheck() {
|
||||||
Config configInstance = Config.getInstance();
|
Config configInstance = Config.getInstance();
|
||||||
|
|
||||||
canGreenTerra = permInstance.greenTerra(player);
|
canGreenTerra = permInstance.greenTerra(player);
|
||||||
@ -165,4 +82,60 @@ public class HerbalismCommand implements CommandExecutor {
|
|||||||
canDoubleDrop = permInstance.herbalismDoubleDrops(player);
|
canDoubleDrop = permInstance.herbalismDoubleDrops(player);
|
||||||
doubleDropsDisabled = configInstance.herbalismDoubleDropsDisabled();
|
doubleDropsDisabled = configInstance.herbalismDoubleDropsDisabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean effectsHeaderPermissions() {
|
||||||
|
return canGreenTerra || (canDoubleDrop && !doubleDropsDisabled) || canFarmersDiet || canGreenThumbBlocks || canGreenThumbWheat;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void effectsDisplay() {
|
||||||
|
if (canGreenTerra) {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Herbalism.Effect.0"), LocaleLoader.getString("Herbalism.Effect.1") }));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (canGreenThumbWheat) {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Herbalism.Effect.2"), LocaleLoader.getString("Herbalism.Effect.3") }));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (canGreenThumbBlocks) {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Herbalism.Effect.4"), LocaleLoader.getString("Herbalism.Effect.5") }));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (canFarmersDiet) {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Herbalism.Effect.6"), LocaleLoader.getString("Herbalism.Effect.7") }));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (canDoubleDrop && !doubleDropsDisabled) {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Herbalism.Effect.8"), LocaleLoader.getString("Herbalism.Effect.9") }));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean statsHeaderPermissions() {
|
||||||
|
return canGreenTerra || (canDoubleDrop && !doubleDropsDisabled) || canFarmersDiet || canGreenThumbBlocks || canGreenThumbWheat;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void statsDisplay() {
|
||||||
|
if (canGreenTerra) {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTe.Length", new Object[] { greenTerraLength }));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (canGreenThumbBlocks || canGreenThumbWheat) {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTh.Chance", new Object[] { greenThumbChance }));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (canGreenThumbWheat) {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTh.Stage", new Object[] { greenThumbStage }));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (canFarmersDiet) {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.FD", new Object[] { farmersDietRank } ));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (canDoubleDrop && !doubleDropsDisabled) {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.DoubleDropChance", new Object[] { doubleDropChance }));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user