mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-23 05:36:46 +01:00
Update Woodcutting command.
This commit is contained in:
parent
cac5f15a37
commit
397dd96383
@ -2,11 +2,10 @@ package com.gmail.nossr50.commands.skills;
|
|||||||
|
|
||||||
import com.gmail.nossr50.commands.SkillCommand;
|
import com.gmail.nossr50.commands.SkillCommand;
|
||||||
import com.gmail.nossr50.config.AdvancedConfig;
|
import com.gmail.nossr50.config.AdvancedConfig;
|
||||||
import com.gmail.nossr50.config.Config;
|
|
||||||
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.skills.gathering.WoodCutting;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.Skills;
|
|
||||||
|
|
||||||
public class WoodcuttingCommand extends SkillCommand {
|
public class WoodcuttingCommand extends SkillCommand {
|
||||||
AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
|
AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
|
||||||
@ -15,17 +14,10 @@ public class WoodcuttingCommand extends SkillCommand {
|
|||||||
private String doubleDropChance;
|
private String doubleDropChance;
|
||||||
private String doubleDropChanceLucky;
|
private String doubleDropChanceLucky;
|
||||||
|
|
||||||
private int abilityLengthIncreaseLevel = advancedConfig.getAbilityLength();
|
|
||||||
private double doubleDropsMaxBonus = advancedConfig.getWoodcuttingDoubleDropChance();
|
|
||||||
private int doubleDropsMaxLevel = advancedConfig.getWoodcuttingDoubleDropMaxLevel();
|
|
||||||
private int leafBlowUnlock = advancedConfig.getLeafBlowUnlockLevel();
|
|
||||||
|
|
||||||
private boolean canTreeFell;
|
private boolean canTreeFell;
|
||||||
private boolean canLeafBlow;
|
private boolean canLeafBlow;
|
||||||
private boolean canDoubleDrop;
|
private boolean canDoubleDrop;
|
||||||
private boolean doubleDropsDisabled;
|
private boolean doubleDropsDisabled;
|
||||||
private boolean lucky;
|
|
||||||
private boolean endurance;
|
|
||||||
|
|
||||||
public WoodcuttingCommand() {
|
public WoodcuttingCommand() {
|
||||||
super(SkillType.WOODCUTTING);
|
super(SkillType.WOODCUTTING);
|
||||||
@ -33,45 +25,23 @@ public class WoodcuttingCommand extends SkillCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void dataCalculations() {
|
protected void dataCalculations() {
|
||||||
float doubleDropChanceF;
|
//TREE FELLER
|
||||||
|
String[] treeFellerStrings = calculateLengthDisplayValues();
|
||||||
|
treeFellerLength = treeFellerStrings[0];
|
||||||
|
treeFellerLengthEndurance = treeFellerStrings[1];
|
||||||
|
|
||||||
//Tree Feller
|
//DOUBLE DROPS
|
||||||
int length = 2 + (int) ((double) skillValue / (double) abilityLengthIncreaseLevel);
|
String[] doubleDropStrings = calculateAbilityDisplayValues(WoodCutting.doubleDropsMaxLevel, WoodCutting.doubleDropsMaxChance);
|
||||||
treeFellerLength = String.valueOf(length);
|
doubleDropChance = doubleDropStrings[0];
|
||||||
|
doubleDropChanceLucky = doubleDropStrings[1];
|
||||||
if (Permissions.activationTwelve(player)) {
|
|
||||||
length = length + 12;
|
|
||||||
}
|
|
||||||
else if (Permissions.activationEight(player)) {
|
|
||||||
length = length + 8;
|
|
||||||
}
|
|
||||||
else if (Permissions.activationFour(player)) {
|
|
||||||
length = length + 4;
|
|
||||||
}
|
|
||||||
int maxLength = SkillType.WOODCUTTING.getAbility().getMaxTicks();
|
|
||||||
if (maxLength != 0 && length > maxLength) {
|
|
||||||
length = maxLength;
|
|
||||||
}
|
|
||||||
treeFellerLengthEndurance = String.valueOf(length);
|
|
||||||
|
|
||||||
//Double Drops
|
|
||||||
if (skillValue >= doubleDropsMaxLevel) doubleDropChanceF = (float) (doubleDropsMaxBonus);
|
|
||||||
else doubleDropChanceF = (float) ((doubleDropsMaxBonus / doubleDropsMaxLevel) * skillValue);
|
|
||||||
doubleDropChance = percent.format(doubleDropChanceF / 100D);
|
|
||||||
if (doubleDropChanceF * 1.3333D >= 100D) doubleDropChanceLucky = percent.format(1D);
|
|
||||||
else doubleDropChanceLucky = percent.format(doubleDropChanceF * 1.3333D / 100D);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void permissionsCheck() {
|
protected void permissionsCheck() {
|
||||||
Config configInstance = Config.getInstance();
|
|
||||||
|
|
||||||
canTreeFell = Permissions.treeFeller(player);
|
canTreeFell = Permissions.treeFeller(player);
|
||||||
canDoubleDrop = Permissions.woodcuttingDoubleDrops(player);
|
canDoubleDrop = Permissions.woodcuttingDoubleDrops(player);
|
||||||
canLeafBlow = Permissions.leafBlower(player);
|
canLeafBlow = Permissions.leafBlower(player);
|
||||||
doubleDropsDisabled = configInstance.woodcuttingDoubleDropsDisabled();
|
doubleDropsDisabled = WoodCutting.doubleDropsDisabled;
|
||||||
lucky = Permissions.luckyWoodcutting(player);
|
|
||||||
endurance = Permissions.activationTwelve(player) || Permissions.activationEight(player) || Permissions.activationFour(player);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -81,10 +51,7 @@ public class WoodcuttingCommand extends SkillCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void effectsDisplay() {
|
protected void effectsDisplay() {
|
||||||
if (lucky) {
|
luckyEffectsDisplay();
|
||||||
String perkPrefix = LocaleLoader.getString("MOTD.PerksPrefix");
|
|
||||||
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.lucky.name"), LocaleLoader.getString("Perks.lucky.desc", new Object[] { Skills.localizeSkillName(SkillType.WOODCUTTING) }) }));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (canTreeFell) {
|
if (canTreeFell) {
|
||||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Woodcutting.Effect.0"), LocaleLoader.getString("Woodcutting.Effect.1") }));
|
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Woodcutting.Effect.0"), LocaleLoader.getString("Woodcutting.Effect.1") }));
|
||||||
@ -106,10 +73,9 @@ public class WoodcuttingCommand extends SkillCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void statsDisplay() {
|
protected void statsDisplay() {
|
||||||
//TODO: Remove? Basically duplicates the above.
|
|
||||||
if (canLeafBlow) {
|
if (canLeafBlow) {
|
||||||
if (skillValue < leafBlowUnlock) {
|
if (skillValue < WoodCutting.leafBlowerUnlockLevel) {
|
||||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Woodcutting.Ability.Locked.0", new Object[] { leafBlowUnlock }) }));
|
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Woodcutting.Ability.Locked.0", new Object[] { WoodCutting.leafBlowerUnlockLevel }) }));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Woodcutting.Ability.0"), LocaleLoader.getString("Woodcutting.Ability.1") }));
|
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Woodcutting.Ability.0"), LocaleLoader.getString("Woodcutting.Ability.1") }));
|
||||||
@ -117,17 +83,21 @@ public class WoodcuttingCommand extends SkillCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (canDoubleDrop && !doubleDropsDisabled) {
|
if (canDoubleDrop && !doubleDropsDisabled) {
|
||||||
if (lucky)
|
if (isLucky) {
|
||||||
player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Chance.DDrop", new Object[] { doubleDropChance }) + LocaleLoader.getString("Perks.lucky.bonus", new Object[] { doubleDropChanceLucky }));
|
player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Chance.DDrop", new Object[] { doubleDropChance }) + LocaleLoader.getString("Perks.lucky.bonus", new Object[] { doubleDropChanceLucky }));
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Chance.DDrop", new Object[] { doubleDropChance }));
|
player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Chance.DDrop", new Object[] { doubleDropChance }));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (canTreeFell) {
|
if (canTreeFell) {
|
||||||
if (endurance)
|
if (hasEndurance) {
|
||||||
player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Length", new Object[] { treeFellerLength }) + LocaleLoader.getString("Perks.activationtime.bonus", new Object[] { treeFellerLengthEndurance }));
|
player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Length", new Object[] { treeFellerLength }) + LocaleLoader.getString("Perks.activationtime.bonus", new Object[] { treeFellerLengthEndurance }));
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Length", new Object[] { treeFellerLength }));
|
player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Length", new Object[] { treeFellerLength }));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -183,7 +183,8 @@ public class AdvancedConfig extends ConfigLoader {
|
|||||||
|
|
||||||
/* WOODCUTTING */
|
/* WOODCUTTING */
|
||||||
public int getLeafBlowUnlockLevel() { return config.getInt("Skills.Woodcutting.LeafBlower_UnlockLevel", 100); }
|
public int getLeafBlowUnlockLevel() { return config.getInt("Skills.Woodcutting.LeafBlower_UnlockLevel", 100); }
|
||||||
public int getWoodcuttingDoubleDropChance() { return config.getInt("Skills.Woodcutting.DoubleDrops_ChanceMax", 100); }
|
|
||||||
|
public double getWoodcuttingDoubleDropChance() { return config.getDouble("Skills.Woodcutting.DoubleDrops_ChanceMax", 100.0D); }
|
||||||
public int getWoodcuttingDoubleDropMaxLevel() { return config.getInt("Skills.Woodcutting.DoubleDrops_MaxBonusLevel", 1000); }
|
public int getWoodcuttingDoubleDropMaxLevel() { return config.getInt("Skills.Woodcutting.DoubleDrops_MaxBonusLevel", 1000); }
|
||||||
|
|
||||||
/* SPOUT STUFF*/
|
/* SPOUT STUFF*/
|
||||||
|
@ -36,6 +36,12 @@ public class WoodCutting {
|
|||||||
private static final AdvancedConfig ADVANCED_CONFIG = AdvancedConfig.getInstance();
|
private static final AdvancedConfig ADVANCED_CONFIG = AdvancedConfig.getInstance();
|
||||||
private static boolean treeFellerReachedThreshold = false;
|
private static boolean treeFellerReachedThreshold = false;
|
||||||
|
|
||||||
|
public static int doubleDropsMaxLevel = ADVANCED_CONFIG.getMiningDoubleDropMaxLevel();
|
||||||
|
public static double doubleDropsMaxChance = ADVANCED_CONFIG.getMiningDoubleDropChance();
|
||||||
|
public static boolean doubleDropsDisabled = Config.getInstance().woodcuttingDoubleDropsDisabled();
|
||||||
|
|
||||||
|
public static int leafBlowerUnlockLevel = ADVANCED_CONFIG.getLeafBlowUnlockLevel();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle the Tree Feller ability.
|
* Handle the Tree Feller ability.
|
||||||
*
|
*
|
||||||
@ -242,7 +248,7 @@ public class WoodCutting {
|
|||||||
* @param block Block being broken
|
* @param block Block being broken
|
||||||
*/
|
*/
|
||||||
private static void woodCuttingProcCheck(Player player, Block block) {
|
private static void woodCuttingProcCheck(Player player, Block block) {
|
||||||
final int MAX_CHANCE = ADVANCED_CONFIG.getWoodcuttingDoubleDropChance();
|
final double MAX_CHANCE = ADVANCED_CONFIG.getWoodcuttingDoubleDropChance();
|
||||||
final int MAX_BONUS_LEVEL = ADVANCED_CONFIG.getWoodcuttingDoubleDropMaxLevel();
|
final int MAX_BONUS_LEVEL = ADVANCED_CONFIG.getWoodcuttingDoubleDropMaxLevel();
|
||||||
byte type = block.getData();
|
byte type = block.getData();
|
||||||
|
|
||||||
@ -253,10 +259,10 @@ public class WoodCutting {
|
|||||||
type ^= 0x8;
|
type ^= 0x8;
|
||||||
|
|
||||||
Material blockMaterial = block.getType();
|
Material blockMaterial = block.getType();
|
||||||
int chance = (int) (((double) MAX_CHANCE / (double) MAX_BONUS_LEVEL) * Users.getProfile(player).getSkillLevel(SkillType.WOODCUTTING));
|
int chance = (int) ((MAX_CHANCE / MAX_BONUS_LEVEL) * Users.getProfile(player).getSkillLevel(SkillType.WOODCUTTING));
|
||||||
|
|
||||||
if (chance > MAX_CHANCE) {
|
if (chance > MAX_CHANCE) {
|
||||||
chance = MAX_CHANCE;
|
chance = (int) MAX_CHANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
int activationChance = Misc.calculateActivationChance(Permissions.luckyWoodcutting(player));
|
int activationChance = Misc.calculateActivationChance(Permissions.luckyWoodcutting(player));
|
||||||
|
@ -286,7 +286,7 @@ Skills:
|
|||||||
|
|
||||||
# DoubleDrops_ChanceMax: Maximum chance of receiving double drops
|
# DoubleDrops_ChanceMax: Maximum chance of receiving double drops
|
||||||
# DoubleDrops_MaxBonusLevel: Level when the maximum chance of receiving double drops is reached
|
# DoubleDrops_MaxBonusLevel: Level when the maximum chance of receiving double drops is reached
|
||||||
DoubleDrops_ChanceMax: 100
|
DoubleDrops_ChanceMax: 100.0
|
||||||
DoubleDrops_MaxBonusLevel: 1000
|
DoubleDrops_MaxBonusLevel: 1000
|
||||||
Spout:
|
Spout:
|
||||||
#
|
#
|
||||||
|
Loading…
Reference in New Issue
Block a user