mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-07-23 15:50:30 +02:00
Clean up on all of our commands. Abstracted experience commands and
hardcore commands. Moved lots of duplicated code to functions in CommandUtils.java. Split /ptp into individual commands, just like /party. Used ternary logic to simplify some of our /skillname stat displays. Fixed skill guide to not allow for negative pages. Simplified logic for many /skillname data calculations. Use permission checks to prevent calculating data that will never be displayed. Made the skill guide into its own command.
This commit is contained in:
@@ -15,7 +15,6 @@ public class WoodcuttingCommand extends SkillCommand {
|
||||
private boolean canTreeFell;
|
||||
private boolean canLeafBlow;
|
||||
private boolean canDoubleDrop;
|
||||
private boolean doubleDropsDisabled;
|
||||
|
||||
public WoodcuttingCommand() {
|
||||
super(SkillType.WOODCUTTING);
|
||||
@@ -24,27 +23,30 @@ public class WoodcuttingCommand extends SkillCommand {
|
||||
@Override
|
||||
protected void dataCalculations() {
|
||||
// TREE FELLER
|
||||
String[] treeFellerStrings = calculateLengthDisplayValues();
|
||||
treeFellerLength = treeFellerStrings[0];
|
||||
treeFellerLengthEndurance = treeFellerStrings[1];
|
||||
if (canTreeFell) {
|
||||
String[] treeFellerStrings = calculateLengthDisplayValues();
|
||||
treeFellerLength = treeFellerStrings[0];
|
||||
treeFellerLengthEndurance = treeFellerStrings[1];
|
||||
}
|
||||
|
||||
// DOUBLE DROPS
|
||||
String[] doubleDropStrings = calculateAbilityDisplayValues(Woodcutting.doubleDropsMaxLevel, Woodcutting.doubleDropsMaxChance);
|
||||
doubleDropChance = doubleDropStrings[0];
|
||||
doubleDropChanceLucky = doubleDropStrings[1];
|
||||
if (canDoubleDrop) {
|
||||
String[] doubleDropStrings = calculateAbilityDisplayValues(Woodcutting.doubleDropsMaxLevel, Woodcutting.doubleDropsMaxChance);
|
||||
doubleDropChance = doubleDropStrings[0];
|
||||
doubleDropChanceLucky = doubleDropStrings[1];
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void permissionsCheck() {
|
||||
canTreeFell = Permissions.treeFeller(player);
|
||||
canDoubleDrop = Permissions.doubleDrops(player, skill);
|
||||
canDoubleDrop = Permissions.doubleDrops(player, skill) && !skill.getDoubleDropsDisabled();
|
||||
canLeafBlow = Permissions.leafBlower(player);
|
||||
doubleDropsDisabled = skill.getDoubleDropsDisabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean effectsHeaderPermissions() {
|
||||
return (canDoubleDrop && !doubleDropsDisabled) || canLeafBlow || canTreeFell;
|
||||
return canDoubleDrop || canLeafBlow || canTreeFell;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -59,14 +61,14 @@ public class WoodcuttingCommand extends SkillCommand {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Woodcutting.Effect.2"), LocaleLoader.getString("Woodcutting.Effect.3")));
|
||||
}
|
||||
|
||||
if (canDoubleDrop && !doubleDropsDisabled) {
|
||||
if (canDoubleDrop) {
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Woodcutting.Effect.4"), LocaleLoader.getString("Woodcutting.Effect.5")));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean statsHeaderPermissions() {
|
||||
return (canDoubleDrop && !doubleDropsDisabled) || canLeafBlow || canTreeFell;
|
||||
return canDoubleDrop || canLeafBlow || canTreeFell;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -82,22 +84,12 @@ public class WoodcuttingCommand extends SkillCommand {
|
||||
}
|
||||
}
|
||||
|
||||
if (canDoubleDrop && !doubleDropsDisabled) {
|
||||
if (isLucky) {
|
||||
player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Chance.DDrop", doubleDropChance) + LocaleLoader.getString("Perks.lucky.bonus", doubleDropChanceLucky));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Chance.DDrop", doubleDropChance));
|
||||
}
|
||||
if (canDoubleDrop) {
|
||||
player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Chance.DDrop", doubleDropChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", doubleDropChanceLucky) : ""));
|
||||
}
|
||||
|
||||
if (canTreeFell) {
|
||||
if (hasEndurance) {
|
||||
player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Length", treeFellerLength) + LocaleLoader.getString("Perks.activationtime.bonus", treeFellerLengthEndurance));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Length", treeFellerLength));
|
||||
}
|
||||
player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Length", treeFellerLength) + (hasEndurance ? LocaleLoader.getString("Perks.activationtime.bonus", treeFellerLengthEndurance) : ""));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user