mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 07:06:45 +01:00
Command updates - Woodcutting & Unarmed
This commit is contained in:
parent
cc60f2f308
commit
33bc2d8a6b
@ -1,5 +1,7 @@
|
|||||||
package com.gmail.nossr50.commands.skills;
|
package com.gmail.nossr50.commands.skills;
|
||||||
|
|
||||||
|
import java.text.DecimalFormat;
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -10,6 +12,7 @@ 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.Page;
|
||||||
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.Users;
|
import com.gmail.nossr50.util.Users;
|
||||||
|
|
||||||
public class UnarmedCommand implements CommandExecutor {
|
public class UnarmedCommand implements CommandExecutor {
|
||||||
@ -19,6 +22,11 @@ public class UnarmedCommand implements CommandExecutor {
|
|||||||
private String disarmChance;
|
private String disarmChance;
|
||||||
private String ironArmBonus;
|
private String ironArmBonus;
|
||||||
|
|
||||||
|
private boolean canBerserk;
|
||||||
|
private boolean canDisarm;
|
||||||
|
private boolean canBonusDamage;
|
||||||
|
private boolean canDeflect;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
if (CommandHelper.noConsoleUsage(sender)) {
|
if (CommandHelper.noConsoleUsage(sender)) {
|
||||||
@ -34,22 +42,51 @@ public class UnarmedCommand implements CommandExecutor {
|
|||||||
|
|
||||||
skillValue = (float) PP.getSkillLevel(SkillType.UNARMED);
|
skillValue = (float) PP.getSkillLevel(SkillType.UNARMED);
|
||||||
dataCalculations(skillValue);
|
dataCalculations(skillValue);
|
||||||
|
permissionsCheck(player);
|
||||||
|
|
||||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Unarmed.SkillName") }));
|
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Unarmed.SkillName") }));
|
||||||
player.sendMessage(LocaleLoader.getString("Commands.XPGain", new Object[] { LocaleLoader.getString("Commands.XPGain.Unarmed") }));
|
player.sendMessage(LocaleLoader.getString("Commands.XPGain", new Object[] { LocaleLoader.getString("Commands.XPGain.Unarmed") }));
|
||||||
player.sendMessage(LocaleLoader.getString("Effects.Level", new Object[] { PP.getSkillLevel(SkillType.UNARMED), PP.getSkillXpLevel(SkillType.UNARMED), PP.getXpToLevel(SkillType.UNARMED) }));
|
player.sendMessage(LocaleLoader.getString("Effects.Level", new Object[] { PP.getSkillLevel(SkillType.UNARMED), PP.getSkillXpLevel(SkillType.UNARMED), PP.getXpToLevel(SkillType.UNARMED) }));
|
||||||
|
|
||||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
|
if (canBerserk || canBonusDamage || canDeflect || canDisarm) {
|
||||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Unarmed.Effect.0"), LocaleLoader.getString("Unarmed.Effect.1") }));
|
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
|
||||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Unarmed.Effect.2"), LocaleLoader.getString("Unarmed.Effect.3") }));
|
}
|
||||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Unarmed.Effect.4"), LocaleLoader.getString("Unarmed.Effect.5") }));
|
|
||||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Unarmed.Effect.6"), LocaleLoader.getString("Unarmed.Effect.7") }));
|
|
||||||
|
|
||||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
|
if (canBerserk) {
|
||||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Unarmed.Ability.Bonus.0"), LocaleLoader.getString("Unarmed.Ability.Bonus.1", new Object[] {ironArmBonus}) }));
|
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Unarmed.Effect.0"), LocaleLoader.getString("Unarmed.Effect.1") }));
|
||||||
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.ArrowDeflect", new Object[] { deflectChance }));
|
}
|
||||||
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.Disarm", new Object[] { disarmChance }));
|
|
||||||
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Berserk.Length", new Object[] { berserkLength }));
|
if (canDisarm) {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Unarmed.Effect.2"), LocaleLoader.getString("Unarmed.Effect.3") }));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (canBonusDamage) {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Unarmed.Effect.4"), LocaleLoader.getString("Unarmed.Effect.5") }));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (canDeflect) {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Unarmed.Effect.6"), LocaleLoader.getString("Unarmed.Effect.7") }));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (canBerserk || canBonusDamage || canDeflect || canDisarm) {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (canBonusDamage) {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Unarmed.Ability.Bonus.0"), LocaleLoader.getString("Unarmed.Ability.Bonus.1", new Object[] {ironArmBonus}) }));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (canDeflect) {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.ArrowDeflect", new Object[] { deflectChance }));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (canDisarm) {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.Disarm", new Object[] { disarmChance }));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (canBerserk) {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Berserk.Length", new Object[] { berserkLength }));
|
||||||
|
}
|
||||||
|
|
||||||
Page.grabGuidePageForSkill(SkillType.UNARMED, player, args);
|
Page.grabGuidePageForSkill(SkillType.UNARMED, player, args);
|
||||||
|
|
||||||
@ -57,22 +94,33 @@ public class UnarmedCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void dataCalculations(float skillValue) {
|
private void dataCalculations(float skillValue) {
|
||||||
|
DecimalFormat percent = new DecimalFormat("##0.00%");
|
||||||
|
|
||||||
berserkLength = String.valueOf(2 + ((int) skillValue / 50));
|
berserkLength = String.valueOf(2 + ((int) skillValue / 50));
|
||||||
|
|
||||||
if (skillValue >= 1000) {
|
if (skillValue >= 1000) {
|
||||||
disarmChance = "33.3";
|
disarmChance = "33.33%";
|
||||||
deflectChance = "50";
|
deflectChance = "50.00%";
|
||||||
ironArmBonus = "8";
|
ironArmBonus = "8";
|
||||||
}
|
}
|
||||||
else if (skillValue >= 250) {
|
else if (skillValue >= 250) {
|
||||||
disarmChance = String.valueOf(skillValue / 30);
|
disarmChance = percent.format(skillValue / 3000);
|
||||||
deflectChance = String.valueOf(skillValue / 20);
|
deflectChance = percent.format(skillValue / 2000);
|
||||||
ironArmBonus = "8";
|
ironArmBonus = "8";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
disarmChance = String.valueOf(skillValue / 30);
|
disarmChance = percent.format(skillValue / 3000);
|
||||||
deflectChance = String.valueOf(skillValue / 20);
|
deflectChance = percent.format(skillValue / 2000);
|
||||||
ironArmBonus = String.valueOf(3 + ((int) skillValue / 50));
|
ironArmBonus = String.valueOf(3 + ((int) skillValue / 50));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void permissionsCheck(Player player) {
|
||||||
|
Permissions permInstance = Permissions.getInstance();
|
||||||
|
|
||||||
|
canBerserk = permInstance.berserk(player);
|
||||||
|
canBonusDamage = permInstance.unarmedBonus(player);
|
||||||
|
canDeflect = permInstance.deflect(player);
|
||||||
|
canDisarm = permInstance.disarm(player);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package com.gmail.nossr50.commands.skills;
|
package com.gmail.nossr50.commands.skills;
|
||||||
|
|
||||||
|
import java.text.DecimalFormat;
|
||||||
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -10,6 +12,7 @@ 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.Page;
|
||||||
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.Users;
|
import com.gmail.nossr50.util.Users;
|
||||||
|
|
||||||
public class WoodcuttingCommand implements CommandExecutor {
|
public class WoodcuttingCommand implements CommandExecutor {
|
||||||
@ -17,6 +20,10 @@ public class WoodcuttingCommand implements CommandExecutor {
|
|||||||
private String treeFellerLength;
|
private String treeFellerLength;
|
||||||
private String doubleDropChance;
|
private String doubleDropChance;
|
||||||
|
|
||||||
|
private boolean canTreeFell;
|
||||||
|
private boolean canLeafBlow;
|
||||||
|
private boolean canDoubleDrop;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
if (CommandHelper.noConsoleUsage(sender)) {
|
if (CommandHelper.noConsoleUsage(sender)) {
|
||||||
@ -32,41 +39,73 @@ public class WoodcuttingCommand implements CommandExecutor {
|
|||||||
|
|
||||||
skillValue = (float) PP.getSkillLevel(SkillType.UNARMED);
|
skillValue = (float) PP.getSkillLevel(SkillType.UNARMED);
|
||||||
dataCalculations(skillValue);
|
dataCalculations(skillValue);
|
||||||
|
permissionsCheck(player);
|
||||||
|
|
||||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("WoodCutting.SkillName") }));
|
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("WoodCutting.SkillName") }));
|
||||||
player.sendMessage(LocaleLoader.getString("Commands.XPGain", new Object[] { LocaleLoader.getString("Commands.XPGain.WoodCutting") }));
|
player.sendMessage(LocaleLoader.getString("Commands.XPGain", new Object[] { LocaleLoader.getString("Commands.XPGain.WoodCutting") }));
|
||||||
player.sendMessage(LocaleLoader.getString("Effects.Level", new Object[] { PP.getSkillLevel(SkillType.WOODCUTTING), PP.getSkillXpLevel(SkillType.WOODCUTTING), PP.getXpToLevel(SkillType.WOODCUTTING) }));
|
player.sendMessage(LocaleLoader.getString("Effects.Level", new Object[] { PP.getSkillLevel(SkillType.WOODCUTTING), PP.getSkillXpLevel(SkillType.WOODCUTTING), PP.getXpToLevel(SkillType.WOODCUTTING) }));
|
||||||
|
|
||||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
|
if (canDoubleDrop || canLeafBlow || canTreeFell) {
|
||||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Woodcutting.Effect.0"), LocaleLoader.getString("Woodcutting.Effect.1") }));
|
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
|
||||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Woodcutting.Effect.2"), LocaleLoader.getString("Woodcutting.Effect.3") }));
|
}
|
||||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Woodcutting.Effect.4"), LocaleLoader.getString("Woodcutting.Effect.5") }));
|
|
||||||
|
if (canTreeFell) {
|
||||||
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
|
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Woodcutting.Effect.0"), LocaleLoader.getString("Woodcutting.Effect.1") }));
|
||||||
|
}
|
||||||
if (PP.getSkillLevel(SkillType.WOODCUTTING) < 100) {
|
|
||||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Woodcutting.Ability.Locked.0") }));
|
if (canLeafBlow) {
|
||||||
}
|
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Woodcutting.Effect.2"), LocaleLoader.getString("Woodcutting.Effect.3") }));
|
||||||
else {
|
}
|
||||||
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Woodcutting.Ability.0"), LocaleLoader.getString("Woodcutting.Ability.1") }));
|
|
||||||
|
if (canDoubleDrop) {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Woodcutting.Effect.4"), LocaleLoader.getString("Woodcutting.Effect.5") }));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (canDoubleDrop || canLeafBlow || canTreeFell) {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO: Remove? Basically duplicates the above.
|
||||||
|
if (canLeafBlow) {
|
||||||
|
if (PP.getSkillLevel(SkillType.WOODCUTTING) < 100) {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Woodcutting.Ability.Locked.0") }));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Woodcutting.Ability.0"), LocaleLoader.getString("Woodcutting.Ability.1") }));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (canDoubleDrop) {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Chance.DDrop", new Object[] { doubleDropChance }));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (canTreeFell) {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Length", new Object[] { treeFellerLength }));
|
||||||
}
|
}
|
||||||
|
|
||||||
player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Chance.DDrop", new Object[] { doubleDropChance }));
|
|
||||||
player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Length", new Object[] { treeFellerLength }));
|
|
||||||
|
|
||||||
Page.grabGuidePageForSkill(SkillType.WOODCUTTING, player, args);
|
Page.grabGuidePageForSkill(SkillType.WOODCUTTING, player, args);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void dataCalculations(float skillValue) {
|
private void dataCalculations(float skillValue) {
|
||||||
|
DecimalFormat percent = new DecimalFormat("##0.00%");
|
||||||
|
|
||||||
treeFellerLength = String.valueOf(2 + ((int) skillValue / 50));
|
treeFellerLength = String.valueOf(2 + ((int) skillValue / 50));
|
||||||
|
|
||||||
if (skillValue >= 1000) {
|
if (skillValue >= 1000) {
|
||||||
doubleDropChance = "100";
|
doubleDropChance = "100.00%";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
doubleDropChance = String.valueOf(skillValue / 10);
|
doubleDropChance = percent.format(skillValue / 1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void permissionsCheck(Player player) {
|
||||||
|
Permissions permInstance = Permissions.getInstance();
|
||||||
|
|
||||||
|
canTreeFell = permInstance.treeFeller(player);
|
||||||
|
canDoubleDrop = permInstance.woodcuttingDoubleDrops(player);
|
||||||
|
canLeafBlow = permInstance.leafBlower(player);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user