Squashed commit of the following:

commit cb3e057dee1f2b29838ab654a526baac1baab7d6
Author: NuclearW <incongruency@gmail.com>
Date:   Fri Mar 1 00:43:57 2013 -0500

    1.4.00 release

commit 4f9628d2e4cde31c8946e9a911ee6f10e1fb6b35
Author: NuclearW <incongruency@gmail.com>
Date:   Fri Mar 1 00:07:30 2013 -0500

    \r -> \n

commit b2ca22e0477c747143b0f08a28a096967ee6ffd7
Author: GJ <gjmcferrin@gmail.com>
Date:   Thu Feb 28 23:53:56 2013 -0500

    Commented-out code shouldn't be done like that.

commit 92f131712cc671e3e616c14a22e22769ef6d6d0b
Author: GJ <gjmcferrin@gmail.com>
Date:   Thu Feb 28 23:45:36 2013 -0500

    More things we missed.

commit 408b03766f6261a03a862a1ab7f5835772feda4a
Author: NuclearW <incongruency@gmail.com>
Date:   Thu Feb 28 23:20:13 2013 -0500

    Format: util through spout and backup lib

commit d6bd2c29bbb51bee3607247468cfe145d4f38c9e
Author: GJ <gjmcferrin@gmail.com>
Date:   Thu Feb 28 22:50:08 2013 -0500

    The things we missed the first time through...

commit 393f0b889aa1b7011ee81ee7b15413d8824b8cfb
Author: GJ <gjmcferrin@gmail.com>
Date:   Thu Feb 28 22:05:29 2013 -0500

    Formatting: Skills

commit c097a6e188a7b760dd1b4389ed81dca417146b16
Author: GJ <gjmcferrin@gmail.com>
Date:   Thu Feb 28 19:30:12 2013 -0500

    Organize imports.

commit 34c3e74be7eb5f983f21d969e30155c5d82c01c1
Author: GJ <gjmcferrin@gmail.com>
Date:   Thu Feb 28 19:09:45 2013 -0500

    Fixed a missing fallthrough comment from ChatCommand

commit b4a76c9f022a2fd98bdd8f083accfea03becfd71
Author: GJ <gjmcferrin@gmail.com>
Date:   Thu Feb 28 19:09:36 2013 -0500

    Formatting: datatypes.* through events.*

commit 3e57dd41d3265a7c8106c7eb026df926770a4d15
Author: NuclearW <incongruency@gmail.com>
Date:   Thu Feb 28 17:56:15 2013 -0500

    Fix issue with bad rebase

commit e8c8e06b2971555b7334e49128257e3af6f36892
Author: GJ <gjmcferrin@gmail.com>
Date:   Thu Feb 28 17:35:32 2013 -0500

    Formatting: DatabaseManager, LeaderboardManager, DatabaseUpdateType, and
    PlayerStat

commit 13ecf1cc41f377a12991e357ac10abdcda24d6de
Author: NuclearW <incongruency@gmail.com>
Date:   Thu Feb 28 17:31:43 2013 -0500

    Format: listeners.* through runnables.*

commit 71686e3c0d96c2dcf25442b91703fadda1ea3bb0
Author: NuclearW <incongruency@gmail.com>
Date:   Thu Feb 28 17:13:57 2013 -0500

    Format PartyLockCommand

commit d50abed10bf94e1a88df3dc5cc07c259aea920ea
Author: NuclearW <incongruency@gmail.com>
Date:   Thu Feb 28 16:54:08 2013 -0500

    Format: base through config.*

commit 7004823eeebbae5be7728bf9cafc3b04e57b64cf
Author: NuclearW <incongruency@gmail.com>
Date:   Thu Feb 28 15:21:40 2013 -0500

    Example of using spaces to align like things

commit 534190cfe2481e466fe459d65628550458cc2993
Author: NuclearW <incongruency@gmail.com>
Date:   Thu Feb 28 15:12:19 2013 -0500

    Capitalization

commit 5b61d3ba4c8d81e6f358b0cf4f460abfe9798414
Author: NuclearW <incongruency@gmail.com>
Date:   Thu Feb 28 15:07:43 2013 -0500

    Updated readme, added standards.md

commit 5ec0df70fb82c527420a2f437f27f31bd758f884
Author: NuclearW <incongruency@gmail.com>
Date:   Thu Feb 28 14:42:16 2013 -0500

    Markdown was here, Creole is a loser

commit 70d557c59d086b6a5fb5e0e63c0c1d8eb4c8d19c
Author: NuclearW <incongruency@gmail.com>
Date:   Thu Feb 28 13:46:24 2013 -0500

    Move MCStats shading to .metrics.mcstats

commit eb9d67e66b1659d6abd2397ecf403343cfeffdda
Author: GJ <gjmcferrin@gmail.com>
Date:   Thu Feb 28 13:37:37 2013 -0500

    Move ALL the packages!

commit 8ffa9e7b75417b6c7f158613d4b4ffb783dcf2d0
Author: NuclearW <incongruency@gmail.com>
Date:   Thu Feb 28 12:37:12 2013 -0500

    /r/n -> /n
This commit is contained in:
NuclearW
2013-03-01 00:52:01 -05:00
parent 13111a8d1b
commit a542d6cf3e
263 changed files with 24364 additions and 23982 deletions

View File

@ -1,159 +0,0 @@
package com.gmail.nossr50.skills;
import java.text.DecimalFormat;
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.AdvancedConfig;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.utilities.PerksUtils;
import com.gmail.nossr50.skills.utilities.SkillTools;
import com.gmail.nossr50.skills.utilities.SkillType;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.Users;
public abstract class SkillCommand implements CommandExecutor {
protected SkillType skill;
private String skillString;
protected Player player;
protected PlayerProfile profile;
protected float skillValue;
protected boolean isLucky;
protected boolean hasEndurance;
protected DecimalFormat percent = new DecimalFormat("##0.00%");
protected DecimalFormat decimal = new DecimalFormat("##0.00");
public SkillCommand(SkillType skill) {
this.skill = skill;
this.skillString = StringUtils.getCapitalized(skill.toString());
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (CommandHelper.noConsoleUsage(sender)) {
return true;
}
player = (Player) sender;
profile = Users.getPlayer(player).getProfile();
if (profile == null) {
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
return true;
}
skillValue = profile.getSkillLevel(skill);
isLucky = Permissions.lucky(sender, skill);
hasEndurance = (Permissions.twelveSecondActivationBoost(sender) || Permissions.eightSecondActivationBoost(sender) || Permissions.fourSecondActivationBoost(sender));
dataCalculations();
permissionsCheck();
player.sendMessage(LocaleLoader.getString("Skills.Header", LocaleLoader.getString(skillString + ".SkillName")));
if (!skill.isChildSkill()) {
player.sendMessage(LocaleLoader.getString("Commands.XPGain", LocaleLoader.getString("Commands.XPGain." + skillString)));
player.sendMessage(LocaleLoader.getString("Effects.Level", profile.getSkillLevel(skill), profile.getSkillXpLevel(skill), profile.getXpToLevel(skill)));
}
if (effectsHeaderPermissions()) {
player.sendMessage(LocaleLoader.getString("Skills.Header", LocaleLoader.getString("Effects.Effects")));
}
effectsDisplay();
if (statsHeaderPermissions()) {
player.sendMessage(LocaleLoader.getString("Skills.Header", LocaleLoader.getString("Commands.Stats.Self")));
}
statsDisplay();
return SkillGuide.grabGuidePageForSkill(skill, player, args);
}
protected String calculateRank(int maxLevel, int rankChangeLevel) {
if (skillValue >= maxLevel) {
return String.valueOf(maxLevel / rankChangeLevel);
}
return String.valueOf((int) (skillValue / rankChangeLevel));
}
protected String[] calculateAbilityDisplayValues(double chance) {
if (isLucky) {
double luckyChance = chance * 1.3333D;
if (luckyChance >= 100D) {
return new String[] { percent.format(chance / 100.0D), percent.format(1.0D) };
}
return new String[] { percent.format(chance / 100.0D), percent.format(luckyChance / 100.0D) };
}
return new String[] { percent.format(chance / 100.0D), null };
}
protected String[] calculateAbilityDisplayValues(int maxBonusLevel, double maxChance) {
double abilityChance;
if (skillValue >= maxBonusLevel) {
abilityChance = maxChance;
}
else {
abilityChance = (maxChance / maxBonusLevel) * skillValue;
}
if (isLucky) {
double luckyChance = abilityChance * 1.3333D;
if (luckyChance >= 100D) {
return new String[] { percent.format(abilityChance / 100.0D), percent.format(1.0D) };
}
return new String[] { percent.format(abilityChance / 100.0D), percent.format(luckyChance / 100.0D) };
}
return new String[] { percent.format(abilityChance / 100.0D), null };
}
protected String[] calculateLengthDisplayValues() {
int maxLength = skill.getAbility().getMaxTicks();
int length = 2 + (int) (skillValue / AdvancedConfig.getInstance().getAbilityLength());
int enduranceLength = PerksUtils.handleActivationPerks(player, length, maxLength);
if (maxLength != 0) {
if (length > maxLength) {
length = maxLength;
}
}
return new String[] { String.valueOf(length), String.valueOf(enduranceLength) };
}
protected void luckyEffectsDisplay() {
if (isLucky) {
String perkPrefix = LocaleLoader.getString("MOTD.PerksPrefix");
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Perks.lucky.name"), LocaleLoader.getString("Perks.lucky.desc", SkillTools.getSkillName(skill))));
}
}
protected abstract void dataCalculations();
protected abstract void permissionsCheck();
protected abstract boolean effectsHeaderPermissions();
protected abstract void effectsDisplay();
protected abstract boolean statsHeaderPermissions();
protected abstract void statsDisplay();
}

View File

@ -1,107 +0,0 @@
package com.gmail.nossr50.skills;
import java.util.ArrayList;
import org.bukkit.entity.Player;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.utilities.SkillTools;
import com.gmail.nossr50.skills.utilities.SkillType;
import com.gmail.nossr50.util.StringUtils;
public final class SkillGuide {
private SkillGuide() {}
public static int getTotalPageNumber(String address) {
String[] addressSplit = LocaleLoader.getString(address).split("\n");
if (addressSplit.length <= 8) {
return 1;
}
return (addressSplit.length/8)+1;
}
public static ArrayList<String> grabPageContents(String header, String address, int pagenum) {
int pageIndexStart = 0;
//Determine what string to start at
if (pagenum > 1) {
pageIndexStart = 8*(pagenum-1);
}
ArrayList<String> allStrings = new ArrayList<String>();
String split[] = LocaleLoader.getString(address).split("\n");
allStrings.add(LocaleLoader.getString("Guides.Header", header));
//Add targeted strings
while (allStrings.size() < 9) {
if (pageIndexStart+allStrings.size() > split.length) {
allStrings.add("");
}
else {
allStrings.add(split[pageIndexStart+allStrings.size()-1]);
}
}
allStrings.add("Page "+pagenum+" of "+getTotalPageNumber(address));
return allStrings;
}
public static void clearChat(Player player) {
player.sendMessage("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
}
public static boolean grabGuidePageForSkill(SkillType skilltype, Player player, String[] args) {
String skillName = skilltype.toString();
String capitalized = StringUtils.getCapitalized(skillName);
String localized = SkillTools.getSkillName(skilltype);
player.sendMessage(LocaleLoader.getString("Guides.Available", localized, localized.toLowerCase()));
String address = "Guides." + capitalized;
switch (args.length) {
case 0:
// We have to specify this, otherwise we get the usage string every time we call /skillname...
return true;
case 1:
if (!args[0].equals("?")) {
return false;
}
SkillGuide.clearChat(player);
for (String target : SkillGuide.grabPageContents(localized, address, 1)) {
player.sendMessage(target);
}
return true;
case 2:
int totalPages = SkillGuide.getTotalPageNumber(address);
if (!StringUtils.isInt(args[1])) {
player.sendMessage(LocaleLoader.getString("Guides.Page.Invalid"));
return true;
}
if (Integer.parseInt(args[1]) > totalPages) {
player.sendMessage(LocaleLoader.getString("Guides.Page.OutOfRange", totalPages));
return true;
}
SkillGuide.clearChat(player);
for (String target : SkillGuide.grabPageContents(localized, address, Integer.parseInt(args[1]))) {
player.sendMessage(target);
}
return true;
default:
return false;
}
}
}

View File

@ -1,44 +1,44 @@
package com.gmail.nossr50.skills;
import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.McMMOPlayer;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.skills.utilities.PerksUtils;
import com.gmail.nossr50.skills.utilities.SkillType;
public abstract class SkillManager {
protected McMMOPlayer mcMMOPlayer;
protected int activationChance;
protected SkillType skill;
public SkillManager(McMMOPlayer mcMMOPlayer, SkillType skill) {
this.mcMMOPlayer = mcMMOPlayer;
this.activationChance = PerksUtils.handleLuckyPerks(mcMMOPlayer.getPlayer(), skill);
this.skill = skill;
}
public McMMOPlayer getMcMMOPlayer() {
return mcMMOPlayer;
}
public Player getPlayer() {
return mcMMOPlayer.getPlayer();
}
public PlayerProfile getProfile() {
return mcMMOPlayer.getProfile();
}
public int getSkillLevel() {
return mcMMOPlayer.getProfile().getSkillLevel(skill);
}
public int getActivationChance() {
return activationChance;
}
public void applyXpGain(int xp) {
mcMMOPlayer.beginXpGain(skill, xp);
}
}
package com.gmail.nossr50.skills;
import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.util.skills.PerksUtils;
public abstract class SkillManager {
protected McMMOPlayer mcMMOPlayer;
protected int activationChance;
protected SkillType skill;
public SkillManager(McMMOPlayer mcMMOPlayer, SkillType skill) {
this.mcMMOPlayer = mcMMOPlayer;
this.activationChance = PerksUtils.handleLuckyPerks(mcMMOPlayer.getPlayer(), skill);
this.skill = skill;
}
public McMMOPlayer getMcMMOPlayer() {
return mcMMOPlayer;
}
public Player getPlayer() {
return mcMMOPlayer.getPlayer();
}
public PlayerProfile getProfile() {
return mcMMOPlayer.getProfile();
}
public int getSkillLevel() {
return mcMMOPlayer.getProfile().getSkillLevel(skill);
}
public int getActivationChance() {
return activationChance;
}
public void applyXpGain(int xp) {
mcMMOPlayer.beginXpGain(skill, xp);
}
}

View File

@ -1,128 +1,128 @@
package com.gmail.nossr50.skills;
import java.util.HashMap;
import com.gmail.nossr50.skills.acrobatics.AcrobaticsManager;
import com.gmail.nossr50.skills.archery.ArcheryManager;
import com.gmail.nossr50.skills.axes.AxeManager;
import com.gmail.nossr50.skills.excavation.ExcavationManager;
import com.gmail.nossr50.skills.fishing.FishingManager;
import com.gmail.nossr50.skills.herbalism.HerbalismManager;
import com.gmail.nossr50.skills.mining.MiningManager;
import com.gmail.nossr50.skills.smelting.SmeltingManager;
import com.gmail.nossr50.skills.swords.SwordsManager;
import com.gmail.nossr50.skills.taming.TamingManager;
import com.gmail.nossr50.skills.unarmed.UnarmedManager;
import com.gmail.nossr50.util.Users;
public class SkillManagerStore {
private static SkillManagerStore instance;
private HashMap<String, AcrobaticsManager> acrobaticsManagers = new HashMap<String, AcrobaticsManager>();
private HashMap<String, ArcheryManager> archeryManagers = new HashMap<String, ArcheryManager>();
private HashMap<String, AxeManager> axeManagers = new HashMap<String, AxeManager>();
private HashMap<String, ExcavationManager> excavationManagers = new HashMap<String, ExcavationManager>();
private HashMap<String, FishingManager> fishingManagers = new HashMap<String, FishingManager>();
private HashMap<String, HerbalismManager> herbalismManagers = new HashMap<String, HerbalismManager>();
private HashMap<String, MiningManager> miningManagers = new HashMap<String, MiningManager>();
private HashMap<String, SmeltingManager> smeltingManagers = new HashMap<String, SmeltingManager>();
private HashMap<String, SwordsManager> swordsManagers = new HashMap<String, SwordsManager>();
private HashMap<String, TamingManager> tamingManagers = new HashMap<String, TamingManager>();
private HashMap<String, UnarmedManager> unarmedManagers = new HashMap<String, UnarmedManager>();
public static SkillManagerStore getInstance() {
if (instance == null) {
instance = new SkillManagerStore();
}
return instance;
}
public AcrobaticsManager getAcrobaticsManager(String playerName) {
if (!acrobaticsManagers.containsKey(playerName)) {
acrobaticsManagers.put(playerName, new AcrobaticsManager(Users.getPlayer(playerName)));
}
return acrobaticsManagers.get(playerName);
}
public ArcheryManager getArcheryManager(String playerName) {
if (!archeryManagers.containsKey(playerName)) {
archeryManagers.put(playerName, new ArcheryManager(Users.getPlayer(playerName)));
}
return archeryManagers.get(playerName);
}
public AxeManager getAxeManager(String playerName) {
if (!axeManagers.containsKey(playerName)) {
axeManagers.put(playerName, new AxeManager(Users.getPlayer(playerName)));
}
return axeManagers.get(playerName);
}
public ExcavationManager getExcavationManager(String playerName) {
if (!excavationManagers.containsKey(playerName)) {
excavationManagers.put(playerName, new ExcavationManager(Users.getPlayer(playerName)));
}
return excavationManagers.get(playerName);
}
public FishingManager getFishingManager(String playerName) {
if (!fishingManagers.containsKey(playerName)) {
fishingManagers.put(playerName, new FishingManager(Users.getPlayer(playerName)));
}
return fishingManagers.get(playerName);
}
public HerbalismManager getHerbalismManager(String playerName) {
if (!herbalismManagers.containsKey(playerName)) {
herbalismManagers.put(playerName, new HerbalismManager(Users.getPlayer(playerName)));
}
return herbalismManagers.get(playerName);
}
public MiningManager getMiningManager(String playerName) {
if (!miningManagers.containsKey(playerName)) {
miningManagers.put(playerName, new MiningManager(Users.getPlayer(playerName)));
}
return miningManagers.get(playerName);
}
public SmeltingManager getSmeltingManager(String playerName) {
if (!smeltingManagers.containsKey(playerName)) {
smeltingManagers.put(playerName, new SmeltingManager(Users.getPlayer(playerName)));
}
return smeltingManagers.get(playerName);
}
public SwordsManager getSwordsManager(String playerName) {
if (!swordsManagers.containsKey(playerName)) {
swordsManagers.put(playerName, new SwordsManager(Users.getPlayer(playerName)));
}
return swordsManagers.get(playerName);
}
public TamingManager getTamingManager(String playerName) {
if (!tamingManagers.containsKey(playerName)) {
tamingManagers.put(playerName, new TamingManager(Users.getPlayer(playerName)));
}
return tamingManagers.get(playerName);
}
public UnarmedManager getUnarmedManager(String playerName) {
if (!unarmedManagers.containsKey(playerName)) {
unarmedManagers.put(playerName, new UnarmedManager(Users.getPlayer(playerName)));
}
return unarmedManagers.get(playerName);
}
}
package com.gmail.nossr50.skills;
import java.util.HashMap;
import com.gmail.nossr50.skills.acrobatics.AcrobaticsManager;
import com.gmail.nossr50.skills.archery.ArcheryManager;
import com.gmail.nossr50.skills.axes.AxeManager;
import com.gmail.nossr50.skills.excavation.ExcavationManager;
import com.gmail.nossr50.skills.fishing.FishingManager;
import com.gmail.nossr50.skills.herbalism.HerbalismManager;
import com.gmail.nossr50.skills.mining.MiningManager;
import com.gmail.nossr50.skills.smelting.SmeltingManager;
import com.gmail.nossr50.skills.swords.SwordsManager;
import com.gmail.nossr50.skills.taming.TamingManager;
import com.gmail.nossr50.skills.unarmed.UnarmedManager;
import com.gmail.nossr50.util.player.UserManager;
public class SkillManagerStore {
private static SkillManagerStore instance;
private HashMap<String, AcrobaticsManager> acrobaticsManagers = new HashMap<String, AcrobaticsManager>();
private HashMap<String, ArcheryManager> archeryManagers = new HashMap<String, ArcheryManager>();
private HashMap<String, AxeManager> axeManagers = new HashMap<String, AxeManager>();
private HashMap<String, ExcavationManager> excavationManagers = new HashMap<String, ExcavationManager>();
private HashMap<String, FishingManager> fishingManagers = new HashMap<String, FishingManager>();
private HashMap<String, HerbalismManager> herbalismManagers = new HashMap<String, HerbalismManager>();
private HashMap<String, MiningManager> miningManagers = new HashMap<String, MiningManager>();
private HashMap<String, SmeltingManager> smeltingManagers = new HashMap<String, SmeltingManager>();
private HashMap<String, SwordsManager> swordsManagers = new HashMap<String, SwordsManager>();
private HashMap<String, TamingManager> tamingManagers = new HashMap<String, TamingManager>();
private HashMap<String, UnarmedManager> unarmedManagers = new HashMap<String, UnarmedManager>();
public static SkillManagerStore getInstance() {
if (instance == null) {
instance = new SkillManagerStore();
}
return instance;
}
public AcrobaticsManager getAcrobaticsManager(String playerName) {
if (!acrobaticsManagers.containsKey(playerName)) {
acrobaticsManagers.put(playerName, new AcrobaticsManager(UserManager.getPlayer(playerName)));
}
return acrobaticsManagers.get(playerName);
}
public ArcheryManager getArcheryManager(String playerName) {
if (!archeryManagers.containsKey(playerName)) {
archeryManagers.put(playerName, new ArcheryManager(UserManager.getPlayer(playerName)));
}
return archeryManagers.get(playerName);
}
public AxeManager getAxeManager(String playerName) {
if (!axeManagers.containsKey(playerName)) {
axeManagers.put(playerName, new AxeManager(UserManager.getPlayer(playerName)));
}
return axeManagers.get(playerName);
}
public ExcavationManager getExcavationManager(String playerName) {
if (!excavationManagers.containsKey(playerName)) {
excavationManagers.put(playerName, new ExcavationManager(UserManager.getPlayer(playerName)));
}
return excavationManagers.get(playerName);
}
public FishingManager getFishingManager(String playerName) {
if (!fishingManagers.containsKey(playerName)) {
fishingManagers.put(playerName, new FishingManager(UserManager.getPlayer(playerName)));
}
return fishingManagers.get(playerName);
}
public HerbalismManager getHerbalismManager(String playerName) {
if (!herbalismManagers.containsKey(playerName)) {
herbalismManagers.put(playerName, new HerbalismManager(UserManager.getPlayer(playerName)));
}
return herbalismManagers.get(playerName);
}
public MiningManager getMiningManager(String playerName) {
if (!miningManagers.containsKey(playerName)) {
miningManagers.put(playerName, new MiningManager(UserManager.getPlayer(playerName)));
}
return miningManagers.get(playerName);
}
public SmeltingManager getSmeltingManager(String playerName) {
if (!smeltingManagers.containsKey(playerName)) {
smeltingManagers.put(playerName, new SmeltingManager(UserManager.getPlayer(playerName)));
}
return smeltingManagers.get(playerName);
}
public SwordsManager getSwordsManager(String playerName) {
if (!swordsManagers.containsKey(playerName)) {
swordsManagers.put(playerName, new SwordsManager(UserManager.getPlayer(playerName)));
}
return swordsManagers.get(playerName);
}
public TamingManager getTamingManager(String playerName) {
if (!tamingManagers.containsKey(playerName)) {
tamingManagers.put(playerName, new TamingManager(UserManager.getPlayer(playerName)));
}
return tamingManagers.get(playerName);
}
public UnarmedManager getUnarmedManager(String playerName) {
if (!unarmedManagers.containsKey(playerName)) {
unarmedManagers.put(playerName, new UnarmedManager(UserManager.getPlayer(playerName)));
}
return unarmedManagers.get(playerName);
}
}

View File

@ -1,36 +1,36 @@
package com.gmail.nossr50.skills.acrobatics;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config;
public final class Acrobatics {
public static double dodgeMaxChance = AdvancedConfig.getInstance().getDodgeChanceMax();
public static int dodgeMaxBonusLevel = AdvancedConfig.getInstance().getDodgeMaxBonusLevel();
public static int dodgeXpModifier = AdvancedConfig.getInstance().getDodgeXPModifier();
public static int dodgeDamageModifier = AdvancedConfig.getInstance().getDodgeDamageModifier();
public static double rollMaxChance = AdvancedConfig.getInstance().getRollChanceMax();
public static int rollMaxBonusLevel = AdvancedConfig.getInstance().getRollMaxBonusLevel();
public static int rollThreshold = AdvancedConfig.getInstance().getRollDamageThreshold();
public static double gracefulRollMaxChance = AdvancedConfig.getInstance().getGracefulRollChanceMax();
public static int gracefulRollMaxBonusLevel = AdvancedConfig.getInstance().getGracefulRollMaxBonusLevel();
public static int gracefulRollThreshold = AdvancedConfig.getInstance().getGracefulRollDamageThreshold();
public static int gracefulRollSuccessModifier = AdvancedConfig.getInstance().getGracefulRollSuccessModifer();
public static int rollXpModifier = AdvancedConfig.getInstance().getRollXPModifier();
public static int fallXpModifier = AdvancedConfig.getInstance().getFallXPModifier();
public static boolean afkLevelingDisabled = Config.getInstance().getAcrobaticsAFKDisabled();
public static boolean dodgeLightningDisabled = Config.getInstance().getDodgeLightningDisabled();
private Acrobatics() {};
protected static int calculateModifiedDodgeDamage(int damage, int damageModifier) {
return Math.max(damage / damageModifier, 1);
}
protected static int calculateModifiedRollDamage(int damage, int damageThreshold) {
return Math.max(damage - damageThreshold, 0);
}
}
package com.gmail.nossr50.skills.acrobatics;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config;
public final class Acrobatics {
public static int dodgeMaxBonusLevel = AdvancedConfig.getInstance().getDodgeMaxBonusLevel();
public static int dodgeDamageModifier = AdvancedConfig.getInstance().getDodgeDamageModifier();
public static double dodgeMaxChance = AdvancedConfig.getInstance().getDodgeChanceMax();
public static int rollMaxBonusLevel = AdvancedConfig.getInstance().getRollMaxBonusLevel();
public static int rollThreshold = AdvancedConfig.getInstance().getRollDamageThreshold();
public static double rollMaxChance = AdvancedConfig.getInstance().getRollChanceMax();
public static int gracefulRollMaxBonusLevel = AdvancedConfig.getInstance().getGracefulRollMaxBonusLevel();
public static int gracefulRollThreshold = AdvancedConfig.getInstance().getGracefulRollDamageThreshold();
public static int gracefulRollSuccessModifier = AdvancedConfig.getInstance().getGracefulRollSuccessModifer();
public static double gracefulRollMaxChance = AdvancedConfig.getInstance().getGracefulRollChanceMax();
public static int dodgeXpModifier = AdvancedConfig.getInstance().getDodgeXPModifier();
public static int rollXpModifier = AdvancedConfig.getInstance().getRollXPModifier();
public static int fallXpModifier = AdvancedConfig.getInstance().getFallXPModifier();
public static boolean afkLevelingDisabled = Config.getInstance().getAcrobaticsAFKDisabled();
public static boolean dodgeLightningDisabled = Config.getInstance().getDodgeLightningDisabled();
private Acrobatics() {};
protected static int calculateModifiedDodgeDamage(int damage, int damageModifier) {
return Math.max(damage / damageModifier, 1);
}
protected static int calculateModifiedRollDamage(int damage, int damageThreshold) {
return Math.max(damage - damageThreshold, 0);
}
}

View File

@ -1,105 +0,0 @@
package com.gmail.nossr50.skills.acrobatics;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.SkillCommand;
import com.gmail.nossr50.skills.utilities.SkillType;
import com.gmail.nossr50.util.Permissions;
public class AcrobaticsCommand extends SkillCommand {
private String dodgeChance;
private String dodgeChanceLucky;
private String rollChance;
private String rollChanceLucky;
private String gracefulRollChance;
private String gracefulRollChanceLucky;
private boolean canDodge;
private boolean canRoll;
private boolean canGracefulRoll;
public AcrobaticsCommand() {
super(SkillType.ACROBATICS);
}
@Override
protected void dataCalculations() {
//DODGE
String[] dodgeStrings = calculateAbilityDisplayValues(Acrobatics.dodgeMaxBonusLevel, Acrobatics.dodgeMaxChance);
dodgeChance = dodgeStrings[0];
dodgeChanceLucky = dodgeStrings[1];
//ROLL
String[] rollStrings = calculateAbilityDisplayValues(Acrobatics.rollMaxBonusLevel, Acrobatics.rollMaxChance);
rollChance = rollStrings[0];
rollChanceLucky = rollStrings[1];
//GRACEFUL ROLL
String[] gracefulRollStrings = calculateAbilityDisplayValues(Acrobatics.gracefulRollMaxBonusLevel, Acrobatics.gracefulRollMaxChance);
gracefulRollChance = gracefulRollStrings[0];
gracefulRollChanceLucky = gracefulRollStrings[1];
}
@Override
protected void permissionsCheck() {
canDodge = Permissions.dodge(player);
canRoll = Permissions.roll(player);
canGracefulRoll = Permissions.gracefulRoll(player);
}
@Override
protected boolean effectsHeaderPermissions() {
return canDodge || canGracefulRoll || canRoll;
}
@Override
protected void effectsDisplay() {
luckyEffectsDisplay();
if (canRoll) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Acrobatics.Effect.0"), LocaleLoader.getString("Acrobatics.Effect.1")));
}
if (canGracefulRoll) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Acrobatics.Effect.2"), LocaleLoader.getString("Acrobatics.Effect.3")));
}
if (canDodge) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Acrobatics.Effect.4"), LocaleLoader.getString("Acrobatics.Effect.5")));
}
}
@Override
protected boolean statsHeaderPermissions() {
return canDodge || canGracefulRoll || canRoll;
}
@Override
protected void statsDisplay() {
if (canRoll) {
if (isLucky) {
player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.Chance", new Object[] { rollChance }) + LocaleLoader.getString("Perks.lucky.bonus", new Object[] { rollChanceLucky }));
}
else {
player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.Chance", new Object[] { rollChance }));
}
}
if (canGracefulRoll) {
if (isLucky) {
player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.GraceChance", new Object[] { gracefulRollChance }) + LocaleLoader.getString("Perks.lucky.bonus", new Object[] { gracefulRollChanceLucky }));
}
else {
player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.GraceChance", new Object[] { gracefulRollChance }));
}
}
if (canDodge) {
if (isLucky) {
player.sendMessage(LocaleLoader.getString("Acrobatics.DodgeChance", new Object[] { dodgeChance }) + LocaleLoader.getString("Perks.lucky.bonus", new Object[] { dodgeChanceLucky }));
}
else {
player.sendMessage(LocaleLoader.getString("Acrobatics.DodgeChance", new Object[] { dodgeChance }));
}
}
}
}

View File

@ -1,129 +1,129 @@
package com.gmail.nossr50.skills.acrobatics;
import org.bukkit.Material;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LightningStrike;
import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.McMMOPlayer;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.skills.utilities.SkillTools;
import com.gmail.nossr50.skills.utilities.SkillType;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.ParticleEffectUtils;
import com.gmail.nossr50.util.Permissions;
public class AcrobaticsManager extends SkillManager {
public AcrobaticsManager (McMMOPlayer mcMMOPlayer) {
super(mcMMOPlayer, SkillType.ACROBATICS);
}
public boolean canRoll() {
Player player = getPlayer();
return (player.getItemInHand().getType() != Material.ENDER_PEARL) && !(Acrobatics.afkLevelingDisabled && player.isInsideVehicle()) && Permissions.roll(player);
}
public boolean canDodge(Entity damager) {
if (Permissions.dodge(getPlayer())) {
if (damager instanceof Player && SkillType.ACROBATICS.getPVPEnabled()) {
return true;
}
else if (!(damager instanceof Player) && SkillType.ACROBATICS.getPVEEnabled() && !(damager instanceof LightningStrike && Acrobatics.dodgeLightningDisabled)) {
return true;
}
}
return false;
}
/**
* Handle the damage reduction and XP gain from the Dodge ability
*
* @param damage The amount of damage initially dealt by the event
* @return the modified event damage if the ability was successful, the original event damage otherwise
*/
public int dodgeCheck(int damage) {
int modifiedDamage = Acrobatics.calculateModifiedDodgeDamage(damage, Acrobatics.dodgeDamageModifier);
Player player = getPlayer();
if (!isFatal(modifiedDamage) && SkillTools.activationSuccessful(player, skill, Acrobatics.dodgeMaxChance, Acrobatics.dodgeMaxBonusLevel)) {
ParticleEffectUtils.playDodgeEffect(player);
PlayerProfile playerProfile = getProfile();
if (playerProfile.useChatNotifications()) {
player.sendMessage(LocaleLoader.getString("Acrobatics.Combat.Proc"));
}
// Why do we check respawn cooldown here?
if (System.currentTimeMillis() >= playerProfile.getRespawnATS() + Misc.PLAYER_RESPAWN_COOLDOWN_SECONDS) {
applyXpGain(damage * Acrobatics.dodgeXpModifier);
}
return modifiedDamage;
}
return damage;
}
/**
* Handle the damage reduction and XP gain from the Roll ability
*
* @param damage The amount of damage initially dealt by the event
* @return the modified event damage if the ability was successful, the original event damage otherwise
*/
public int rollCheck(int damage) {
Player player = getPlayer();
if (player.isSneaking() && Permissions.gracefulRoll(player)) {
return gracefulRollCheck(damage);
}
int modifiedDamage = Acrobatics.calculateModifiedRollDamage(damage, Acrobatics.rollThreshold);
if (!isFatal(modifiedDamage) && isSuccessfulRoll(Acrobatics.rollMaxChance, Acrobatics.rollMaxBonusLevel, 1)) {
player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.Text"));
applyXpGain(damage * Acrobatics.rollXpModifier);
return modifiedDamage;
}
else if (!isFatal(damage)) {
applyXpGain(damage * Acrobatics.fallXpModifier);
}
return damage;
}
/**
* Handle the damage reduction and XP gain from the Graceful Roll ability
*
* @param damage The amount of damage initially dealt by the event
* @return the modified event damage if the ability was successful, the original event damage otherwise
*/
private int gracefulRollCheck(int damage) {
int modifiedDamage = Acrobatics.calculateModifiedRollDamage(damage, Acrobatics.gracefulRollThreshold);
if (!isFatal(modifiedDamage) && isSuccessfulRoll(Acrobatics.gracefulRollMaxChance, Acrobatics.gracefulRollMaxBonusLevel, Acrobatics.gracefulRollSuccessModifier)) {
getPlayer().sendMessage(LocaleLoader.getString("Acrobatics.Ability.Proc"));
applyXpGain(damage * Acrobatics.rollXpModifier);
return modifiedDamage;
}
else if (!isFatal(damage)) {
applyXpGain(damage * Acrobatics.fallXpModifier);
}
return damage;
}
private boolean isSuccessfulRoll(double maxChance, int maxLevel, int successModifier) {
return ((maxChance / maxLevel) * Math.min(getSkillLevel(), maxLevel) * successModifier) > Misc.getRandom().nextInt(activationChance);
}
private boolean isFatal(int damage) {
return getPlayer().getHealth() - damage < 1;
}
}
package com.gmail.nossr50.skills.acrobatics;
import org.bukkit.Material;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LightningStrike;
import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.skills.ParticleEffectUtils;
import com.gmail.nossr50.util.skills.SkillUtils;
public class AcrobaticsManager extends SkillManager {
public AcrobaticsManager(McMMOPlayer mcMMOPlayer) {
super(mcMMOPlayer, SkillType.ACROBATICS);
}
public boolean canRoll() {
Player player = getPlayer();
return (player.getItemInHand().getType() != Material.ENDER_PEARL) && !(Acrobatics.afkLevelingDisabled && player.isInsideVehicle()) && Permissions.roll(player);
}
public boolean canDodge(Entity damager) {
if (Permissions.dodge(getPlayer())) {
if (damager instanceof Player && SkillType.ACROBATICS.getPVPEnabled()) {
return true;
}
else if (!(damager instanceof Player) && SkillType.ACROBATICS.getPVEEnabled() && !(damager instanceof LightningStrike && Acrobatics.dodgeLightningDisabled)) {
return true;
}
}
return false;
}
/**
* Handle the damage reduction and XP gain from the Dodge ability
*
* @param damage The amount of damage initially dealt by the event
* @return the modified event damage if the ability was successful, the original event damage otherwise
*/
public int dodgeCheck(int damage) {
int modifiedDamage = Acrobatics.calculateModifiedDodgeDamage(damage, Acrobatics.dodgeDamageModifier);
Player player = getPlayer();
if (!isFatal(modifiedDamage) && SkillUtils.activationSuccessful(player, skill, Acrobatics.dodgeMaxChance, Acrobatics.dodgeMaxBonusLevel)) {
ParticleEffectUtils.playDodgeEffect(player);
PlayerProfile playerProfile = getProfile();
if (playerProfile.useChatNotifications()) {
player.sendMessage(LocaleLoader.getString("Acrobatics.Combat.Proc"));
}
// Why do we check respawn cooldown here?
if (System.currentTimeMillis() >= playerProfile.getRespawnATS() + Misc.PLAYER_RESPAWN_COOLDOWN_SECONDS) {
applyXpGain(damage * Acrobatics.dodgeXpModifier);
}
return modifiedDamage;
}
return damage;
}
/**
* Handle the damage reduction and XP gain from the Roll ability
*
* @param damage The amount of damage initially dealt by the event
* @return the modified event damage if the ability was successful, the original event damage otherwise
*/
public int rollCheck(int damage) {
Player player = getPlayer();
if (player.isSneaking() && Permissions.gracefulRoll(player)) {
return gracefulRollCheck(damage);
}
int modifiedDamage = Acrobatics.calculateModifiedRollDamage(damage, Acrobatics.rollThreshold);
if (!isFatal(modifiedDamage) && isSuccessfulRoll(Acrobatics.rollMaxChance, Acrobatics.rollMaxBonusLevel, 1)) {
player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.Text"));
applyXpGain(damage * Acrobatics.rollXpModifier);
return modifiedDamage;
}
else if (!isFatal(damage)) {
applyXpGain(damage * Acrobatics.fallXpModifier);
}
return damage;
}
/**
* Handle the damage reduction and XP gain from the Graceful Roll ability
*
* @param damage The amount of damage initially dealt by the event
* @return the modified event damage if the ability was successful, the original event damage otherwise
*/
private int gracefulRollCheck(int damage) {
int modifiedDamage = Acrobatics.calculateModifiedRollDamage(damage, Acrobatics.gracefulRollThreshold);
if (!isFatal(modifiedDamage) && isSuccessfulRoll(Acrobatics.gracefulRollMaxChance, Acrobatics.gracefulRollMaxBonusLevel, Acrobatics.gracefulRollSuccessModifier)) {
getPlayer().sendMessage(LocaleLoader.getString("Acrobatics.Ability.Proc"));
applyXpGain(damage * Acrobatics.rollXpModifier);
return modifiedDamage;
}
else if (!isFatal(damage)) {
applyXpGain(damage * Acrobatics.fallXpModifier);
}
return damage;
}
private boolean isSuccessfulRoll(double maxChance, int maxLevel, int successModifier) {
return ((maxChance / maxLevel) * Math.min(getSkillLevel(), maxLevel) * successModifier) > Misc.getRandom().nextInt(activationChance);
}
private boolean isFatal(int damage) {
return getPlayer().getHealth() - damage < 1;
}
}

View File

@ -1,68 +1,68 @@
package com.gmail.nossr50.skills.archery;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.bukkit.Material;
import org.bukkit.entity.LivingEntity;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.util.Misc;
public class Archery {
private static List<TrackedEntity> trackedEntities = new ArrayList<TrackedEntity>();
public static int retrieveMaxBonusLevel = AdvancedConfig.getInstance().getRetrieveMaxBonusLevel();
public static double retrieveMaxChance = AdvancedConfig.getInstance().getRetrieveChanceMax();
public static int skillShotIncreaseLevel = AdvancedConfig.getInstance().getSkillShotIncreaseLevel();
public static double skillShotIncreasePercentage = AdvancedConfig.getInstance().getSkillShotIncreasePercentage();
public static double skillShotMaxBonusPercentage = AdvancedConfig.getInstance().getSkillShotBonusMax();
public static int dazeMaxBonusLevel = AdvancedConfig.getInstance().getDazeMaxBonusLevel();
public static double dazeMaxBonus = AdvancedConfig.getInstance().getDazeBonusMax();
public static int dazeModifier = AdvancedConfig.getInstance().getDazeModifier();
public static double distanceXpModifer = 0.025;
protected static void incrementTrackerValue(LivingEntity livingEntity) {
for (TrackedEntity trackedEntity : trackedEntities) {
if (trackedEntity.getLivingEntity().getEntityId() == livingEntity.getEntityId()) {
trackedEntity.incrementArrowCount();
return;
}
}
addToTracker(livingEntity); //If the entity isn't tracked yet
}
protected static void addToTracker(LivingEntity livingEntity) {
TrackedEntity trackedEntity = new TrackedEntity(livingEntity);
trackedEntity.incrementArrowCount();
trackedEntities.add(trackedEntity);
}
protected static void removeFromTracker(TrackedEntity trackedEntity) {
trackedEntities.remove(trackedEntity);
}
/**
* Check for arrow retrieval.
*
* @param livingEntity The entity hit by the arrows
*/
public static void arrowRetrievalCheck(LivingEntity livingEntity) {
for (Iterator<TrackedEntity> entityIterator = trackedEntities.iterator(); entityIterator.hasNext(); ) {
TrackedEntity trackedEntity = entityIterator.next();
if (trackedEntity.getID() == livingEntity.getUniqueId()) {
Misc.dropItems(livingEntity.getLocation(), new ItemStack(Material.ARROW), trackedEntity.getArrowCount());
entityIterator.remove();
return;
}
}
}
}
package com.gmail.nossr50.skills.archery;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.bukkit.Material;
import org.bukkit.entity.LivingEntity;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.util.Misc;
public class Archery {
private static List<TrackedEntity> trackedEntities = new ArrayList<TrackedEntity>();
public static int retrieveMaxBonusLevel = AdvancedConfig.getInstance().getRetrieveMaxBonusLevel();
public static double retrieveMaxChance = AdvancedConfig.getInstance().getRetrieveChanceMax();
public static int skillShotIncreaseLevel = AdvancedConfig.getInstance().getSkillShotIncreaseLevel();
public static double skillShotIncreasePercentage = AdvancedConfig.getInstance().getSkillShotIncreasePercentage();
public static double skillShotMaxBonusPercentage = AdvancedConfig.getInstance().getSkillShotBonusMax();
public static int dazeMaxBonusLevel = AdvancedConfig.getInstance().getDazeMaxBonusLevel();
public static int dazeModifier = AdvancedConfig.getInstance().getDazeModifier();
public static double dazeMaxBonus = AdvancedConfig.getInstance().getDazeBonusMax();
public static final double DISTANCE_XP_MULTIPLIER = 0.025;
protected static void incrementTrackerValue(LivingEntity livingEntity) {
for (TrackedEntity trackedEntity : trackedEntities) {
if (trackedEntity.getLivingEntity().getEntityId() == livingEntity.getEntityId()) {
trackedEntity.incrementArrowCount();
return;
}
}
addToTracker(livingEntity); // If the entity isn't tracked yet
}
protected static void addToTracker(LivingEntity livingEntity) {
TrackedEntity trackedEntity = new TrackedEntity(livingEntity);
trackedEntity.incrementArrowCount();
trackedEntities.add(trackedEntity);
}
protected static void removeFromTracker(TrackedEntity trackedEntity) {
trackedEntities.remove(trackedEntity);
}
/**
* Check for arrow retrieval.
*
* @param livingEntity The entity hit by the arrows
*/
public static void arrowRetrievalCheck(LivingEntity livingEntity) {
for (Iterator<TrackedEntity> entityIterator = trackedEntities.iterator(); entityIterator.hasNext();) {
TrackedEntity trackedEntity = entityIterator.next();
if (trackedEntity.getID() == livingEntity.getUniqueId()) {
Misc.dropItems(livingEntity.getLocation(), new ItemStack(Material.ARROW), trackedEntity.getArrowCount());
entityIterator.remove();
return;
}
}
}
}

View File

@ -1,104 +0,0 @@
package com.gmail.nossr50.skills.archery;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.SkillCommand;
import com.gmail.nossr50.skills.utilities.SkillType;
import com.gmail.nossr50.util.Permissions;
public class ArcheryCommand extends SkillCommand {
private String skillShotBonus;
private String dazeChance;
private String dazeChanceLucky;
private String retrieveChance;
private String retrieveChanceLucky;
private boolean canSkillShot;
private boolean canDaze;
private boolean canRetrieve;
public ArcheryCommand() {
super(SkillType.ARCHERY);
}
@Override
protected void dataCalculations() {
//SKILL SHOT
double bonus = (skillValue / Archery.skillShotIncreaseLevel) * Archery.skillShotIncreasePercentage;
if (bonus > Archery.skillShotMaxBonusPercentage) {
skillShotBonus = percent.format(Archery.skillShotMaxBonusPercentage);
}
else {
skillShotBonus = percent.format(bonus);
}
//DAZE
String[] dazeStrings = calculateAbilityDisplayValues(Archery.dazeMaxBonusLevel, Archery.dazeMaxBonus);
dazeChance = dazeStrings[0];
dazeChanceLucky = dazeStrings[1];
//RETRIEVE
String[] retrieveStrings = calculateAbilityDisplayValues(Archery.retrieveMaxBonusLevel, Archery.retrieveMaxChance);
retrieveChance = retrieveStrings[0];
retrieveChanceLucky = retrieveStrings[1];
}
@Override
protected void permissionsCheck() {
canSkillShot = Permissions.bonusDamage(player, skill);
canDaze = Permissions.daze(player);
canRetrieve = Permissions.arrowRetrieval(player);
}
@Override
protected boolean effectsHeaderPermissions() {
return canSkillShot || canDaze || canRetrieve;
}
@Override
protected void effectsDisplay() {
luckyEffectsDisplay();
if (canSkillShot) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Archery.Effect.0"), LocaleLoader.getString("Archery.Effect.1")));
}
if (canDaze) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Archery.Effect.2"), LocaleLoader.getString("Archery.Effect.3", Archery.dazeModifier)));
}
if (canRetrieve) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Archery.Effect.4"), LocaleLoader.getString("Archery.Effect.5")));
}
}
@Override
protected boolean statsHeaderPermissions() {
return canSkillShot || canDaze || canRetrieve;
}
@Override
protected void statsDisplay() {
if (canSkillShot) {
player.sendMessage(LocaleLoader.getString("Archery.Combat.SkillshotBonus", skillShotBonus));
}
if (canDaze) {
if (isLucky) {
player.sendMessage(LocaleLoader.getString("Archery.Combat.DazeChance", dazeChance) + LocaleLoader.getString("Perks.lucky.bonus", dazeChanceLucky));
}
else {
player.sendMessage(LocaleLoader.getString("Archery.Combat.DazeChance", dazeChance));
}
}
if (canRetrieve) {
if (isLucky) {
player.sendMessage(LocaleLoader.getString("Archery.Combat.RetrieveChance", retrieveChance) + LocaleLoader.getString("Perks.lucky.bonus", retrieveChanceLucky));
}
else {
player.sendMessage(LocaleLoader.getString("Archery.Combat.RetrieveChance", retrieveChance));
}
}
}
}

View File

@ -1,115 +1,115 @@
package com.gmail.nossr50.skills.archery;
import org.bukkit.Location;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import com.gmail.nossr50.datatypes.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.skills.utilities.SkillTools;
import com.gmail.nossr50.skills.utilities.SkillType;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Users;
public class ArcheryManager extends SkillManager {
public ArcheryManager (McMMOPlayer mcMMOPlayer) {
super(mcMMOPlayer, SkillType.ARCHERY);
}
public boolean canDaze(LivingEntity target) {
return target instanceof Player && Permissions.daze(getPlayer());
}
public boolean canSkillShot() {
Player player = getPlayer();
return SkillTools.unlockLevelReached(player, skill, Archery.skillShotIncreaseLevel) && Permissions.bonusDamage(player, skill);
}
public boolean canTrackArrows() {
Player player = getPlayer();
return !(player.getItemInHand().containsEnchantment(Enchantment.ARROW_INFINITE)) && Permissions.arrowRetrieval(player);
}
/**
* Calculate bonus XP awarded for Archery when hitting a far-away target.
*
* @param target The {@link LivingEntity} damaged by the arrow
*/
public void distanceXpBonus(LivingEntity target) {
Player player = getPlayer();
Location shooterLocation = player.getLocation();
Location targetLocation = target.getLocation();
if (!shooterLocation.getWorld().equals(targetLocation.getWorld())) {
return;
}
// Cap distance at 100^2 to prevent teleport exploit.
// TODO: Better way to handle this would be great...
double squaredDistance = Math.min(shooterLocation.distanceSquared(targetLocation), 10000);
applyXpGain((int) (squaredDistance * Archery.distanceXpModifer));
}
/**
* Track arrows fired for later retrieval.
*
* @param target The {@link LivingEntity} damaged by the arrow
*/
public void trackArrows(LivingEntity target) {
if (SkillTools.activationSuccessful(getPlayer(), skill, Archery.retrieveMaxChance, Archery.retrieveMaxBonusLevel)) {
Archery.incrementTrackerValue(target);
}
}
/**
* Handle the effects of the Daze ability
*
* @param defender The player being affected by the ability
* @param damage The amount of damage initially dealt by the event
* @return the modified event damage if the ability was successful, the original event damage otherwise
*/
public int dazeCheck(Player defender, int damage) {
Player attacker = getPlayer();
if (SkillTools.activationSuccessful(attacker, skill, Archery.dazeMaxBonus, Archery.dazeMaxBonusLevel)) {
Location dazedLocation = defender.getLocation();
dazedLocation.setPitch(90 - Misc.getRandom().nextInt(181));
defender.teleport(dazedLocation);
defender.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 20 * 10, 10));
if (Users.getPlayer(defender).getProfile().useChatNotifications()) {
defender.sendMessage(LocaleLoader.getString("Combat.TouchedFuzzy"));
}
if (getProfile().useChatNotifications()) {
attacker.sendMessage(LocaleLoader.getString("Combat.TargetDazed"));
}
return damage + Archery.dazeModifier;
}
return damage;
}
/**
* Handle the effects of the Skill Shot ability
*
* @param damage The amount of damage initially dealt by the event
* @return the modified event damage
*/
public int skillShotCheck(int damage) {
double damageBonusPercent = Math.min(((getSkillLevel() / Archery.skillShotIncreaseLevel) * Archery.skillShotIncreasePercentage), Archery.skillShotMaxBonusPercentage);
int archeryBonus = (int) (damage * damageBonusPercent);
return damage + archeryBonus;
}
}
package com.gmail.nossr50.skills.archery;
import org.bukkit.Location;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.SkillUtils;
public class ArcheryManager extends SkillManager {
public ArcheryManager(McMMOPlayer mcMMOPlayer) {
super(mcMMOPlayer, SkillType.ARCHERY);
}
public boolean canDaze(LivingEntity target) {
return target instanceof Player && Permissions.daze(getPlayer());
}
public boolean canSkillShot() {
Player player = getPlayer();
return SkillUtils.unlockLevelReached(player, skill, Archery.skillShotIncreaseLevel) && Permissions.bonusDamage(player, skill);
}
public boolean canTrackArrows() {
Player player = getPlayer();
return !(player.getItemInHand().containsEnchantment(Enchantment.ARROW_INFINITE)) && Permissions.arrowRetrieval(player);
}
/**
* Calculate bonus XP awarded for Archery when hitting a far-away target.
*
* @param target The {@link LivingEntity} damaged by the arrow
*/
public void distanceXpBonus(LivingEntity target) {
Player player = getPlayer();
Location shooterLocation = player.getLocation();
Location targetLocation = target.getLocation();
if (!shooterLocation.getWorld().equals(targetLocation.getWorld())) {
return;
}
// Cap distance at 100^2 to prevent teleport exploit.
// TODO: Better way to handle this would be great...
double squaredDistance = Math.min(shooterLocation.distanceSquared(targetLocation), 10000);
applyXpGain((int) (squaredDistance * Archery.DISTANCE_XP_MULTIPLIER));
}
/**
* Track arrows fired for later retrieval.
*
* @param target The {@link LivingEntity} damaged by the arrow
*/
public void trackArrows(LivingEntity target) {
if (SkillUtils.activationSuccessful(getPlayer(), skill, Archery.retrieveMaxChance, Archery.retrieveMaxBonusLevel)) {
Archery.incrementTrackerValue(target);
}
}
/**
* Handle the effects of the Daze ability
*
* @param defender The player being affected by the ability
* @param damage The amount of damage initially dealt by the event
* @return the modified event damage if the ability was successful, the original event damage otherwise
*/
public int dazeCheck(Player defender, int damage) {
Player attacker = getPlayer();
if (SkillUtils.activationSuccessful(attacker, skill, Archery.dazeMaxBonus, Archery.dazeMaxBonusLevel)) {
Location dazedLocation = defender.getLocation();
dazedLocation.setPitch(90 - Misc.getRandom().nextInt(181));
defender.teleport(dazedLocation);
defender.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 20 * 10, 10));
if (UserManager.getPlayer(defender).getProfile().useChatNotifications()) {
defender.sendMessage(LocaleLoader.getString("Combat.TouchedFuzzy"));
}
if (getProfile().useChatNotifications()) {
attacker.sendMessage(LocaleLoader.getString("Combat.TargetDazed"));
}
return damage + Archery.dazeModifier;
}
return damage;
}
/**
* Handle the effects of the Skill Shot ability
*
* @param damage The amount of damage initially dealt by the event
* @return the modified event damage
*/
public int skillShotCheck(int damage) {
double damageBonusPercent = Math.min(((getSkillLevel() / Archery.skillShotIncreaseLevel) * Archery.skillShotIncreasePercentage), Archery.skillShotMaxBonusPercentage);
int archeryBonus = (int) (damage * damageBonusPercent);
return damage + archeryBonus;
}
}

View File

@ -21,6 +21,14 @@ public class TrackedEntity implements Runnable {
this.taskId = scheduler.scheduleSyncRepeatingTask(mcMMO.p, this, 12000, 12000);
}
@Override
public void run() {
if (!livingEntity.isValid()) {
Archery.removeFromTracker(this);
scheduler.cancelTask(taskId);
}
}
protected LivingEntity getLivingEntity() {
return livingEntity;
}
@ -36,12 +44,4 @@ public class TrackedEntity implements Runnable {
protected void incrementArrowCount() {
arrowCount++;
}
@Override
public void run() {
if (!livingEntity.isValid()) {
Archery.removeFromTracker(this);
scheduler.cancelTask(taskId);
}
}
}

View File

@ -1,148 +1,148 @@
package com.gmail.nossr50.skills.axes;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.datatypes.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mods.ModChecks;
import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.skills.utilities.AbilityType;
import com.gmail.nossr50.skills.utilities.CombatTools;
import com.gmail.nossr50.skills.utilities.SkillTools;
import com.gmail.nossr50.skills.utilities.SkillType;
import com.gmail.nossr50.skills.utilities.ToolType;
import com.gmail.nossr50.util.ItemChecks;
import com.gmail.nossr50.util.ParticleEffectUtils;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Users;
public class AxeManager extends SkillManager {
public AxeManager(McMMOPlayer mcMMOPlayer) {
super(mcMMOPlayer, SkillType.AXES);
}
public boolean canUseAxeMastery() {
return Permissions.bonusDamage(getPlayer(), skill);
}
public boolean canCriticalHit(LivingEntity target) {
return target.isValid() && Permissions.criticalStrikes(getPlayer());
}
public boolean canImpact(LivingEntity target) {
return target.isValid() && Permissions.armorImpact(getPlayer()) && Axes.hasArmor(target);
}
public boolean canGreaterImpact(LivingEntity target) {
return target.isValid() && Permissions.greaterImpact(getPlayer()) && !Axes.hasArmor(target);
}
public boolean canUseSkullSplitter(LivingEntity target) {
return target.isValid() && getProfile().getAbilityMode(AbilityType.SKULL_SPLITTER) && Permissions.skullSplitter(getPlayer());
}
public boolean canActivateAbility() {
return getProfile().getToolPreparationMode(ToolType.AXE) && Permissions.skullSplitter(getPlayer());
}
/**
* Handle the effects of the Axe Mastery ability
*
* @param damage The amount of damage initially dealt by the event
* @return the modified event damage
*/
public int axeMasteryCheck(int damage) {
int axeBonus = Math.min(getSkillLevel() / (Axes.bonusDamageMaxBonusLevel / Axes.bonusDamageMaxBonus), Axes.bonusDamageMaxBonus);
return damage + axeBonus;
}
/**
* Handle the effects of the Critical Hit ability
*
* @param target The {@link LivingEntity} being affected by the ability
* @param damage The amount of damage initially dealt by the event
* @return the modified event damage if the ability was successful, the original event damage otherwise
*/
public int criticalHitCheck(LivingEntity target, int damage) {
Player player = getPlayer();
if (SkillTools.activationSuccessful(player, skill, Axes.criticalHitMaxChance, Axes.criticalHitMaxBonusLevel)) {
player.sendMessage(LocaleLoader.getString("Axes.Combat.CriticalHit"));
if (target instanceof Player) {
((Player) target).sendMessage(LocaleLoader.getString("Axes.Combat.CritStruck"));
return (int) (damage * Axes.criticalHitPVPModifier);
}
return (int) (damage * Axes.criticalHitPVEModifier);
}
return damage;
}
/**
* Handle the effects of the Impact ability
*
* @param target The {@link LivingEntity} being affected by Impact
*/
public void impactCheck(LivingEntity target) {
int durabilityDamage = 1 + (getSkillLevel() / Axes.impactIncreaseLevel);
for (ItemStack armor : target.getEquipment().getArmorContents()) {
if (ItemChecks.isArmor(armor) && SkillTools.activationSuccessful(getPlayer(), skill, Axes.impactChance)) {
double durabilityModifier = 1 / (armor.getEnchantmentLevel(Enchantment.DURABILITY) + 1); // Modifier to simulate the durability enchantment behavior
double modifiedDurabilityDamage = durabilityDamage * durabilityModifier;
double maxDurabilityDamage = (ModChecks.isCustomArmor(armor) ? ModChecks.getArmorFromItemStack(armor).getDurability() : armor.getType().getMaxDurability()) * Axes.impactMaxDurabilityDamageModifier;
armor.setDurability((short) (Math.min(modifiedDurabilityDamage, maxDurabilityDamage) + armor.getDurability()));
}
}
}
/**
* Handle the effects of the Greater Impact ability
*
* @param target The {@link LivingEntity} being affected by the ability
* @param damage The amount of damage initially dealt by the event
* @return the modified event damage if the ability was successful, the original event damage otherwise
*/
public int greaterImpactCheck(LivingEntity target, int damage) {
Player player = getPlayer();
if (SkillTools.activationSuccessful(player, skill, Axes.greaterImpactChance)) {
ParticleEffectUtils.playGreaterImpactEffect(target);
target.setVelocity(player.getLocation().getDirection().normalize().multiply(Axes.greaterImpactKnockbackMultiplier));
if (getProfile().useChatNotifications()) {
player.sendMessage(LocaleLoader.getString("Axes.Combat.GI.Proc"));
}
if (target instanceof Player) {
Player defender = (Player) target;
if (Users.getPlayer(defender).getProfile().useChatNotifications()) {
defender.sendMessage(LocaleLoader.getString("Axes.Combat.GI.Struck"));
}
}
return damage + Axes.greaterImpactBonusDamage;
}
return damage;
}
/**
* Handle the effects of the Skull Splitter ability
*
* @param target The {@link LivingEntity} being affected by the ability
* @param damage The amount of damage initially dealt by the event
*/
public void skullSplitterCheck(LivingEntity target, int damage) {
CombatTools.applyAbilityAoE(getPlayer(), target, damage / Axes.skullSplitterModifier, skill);
}
}
package com.gmail.nossr50.skills.axes;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.AbilityType;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.datatypes.skills.ToolType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.util.ItemUtils;
import com.gmail.nossr50.util.ModUtils;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.CombatUtils;
import com.gmail.nossr50.util.skills.ParticleEffectUtils;
import com.gmail.nossr50.util.skills.SkillUtils;
public class AxeManager extends SkillManager {
public AxeManager(McMMOPlayer mcMMOPlayer) {
super(mcMMOPlayer, SkillType.AXES);
}
public boolean canUseAxeMastery() {
return Permissions.bonusDamage(getPlayer(), skill);
}
public boolean canCriticalHit(LivingEntity target) {
return target.isValid() && Permissions.criticalStrikes(getPlayer());
}
public boolean canImpact(LivingEntity target) {
return target.isValid() && Permissions.armorImpact(getPlayer()) && Axes.hasArmor(target);
}
public boolean canGreaterImpact(LivingEntity target) {
return target.isValid() && Permissions.greaterImpact(getPlayer()) && !Axes.hasArmor(target);
}
public boolean canUseSkullSplitter(LivingEntity target) {
return target.isValid() && getProfile().getAbilityMode(AbilityType.SKULL_SPLITTER) && Permissions.skullSplitter(getPlayer());
}
public boolean canActivateAbility() {
return getProfile().getToolPreparationMode(ToolType.AXE) && Permissions.skullSplitter(getPlayer());
}
/**
* Handle the effects of the Axe Mastery ability
*
* @param damage The amount of damage initially dealt by the event
* @return the modified event damage
*/
public int axeMasteryCheck(int damage) {
int axeBonus = Math.min(getSkillLevel() / (Axes.bonusDamageMaxBonusLevel / Axes.bonusDamageMaxBonus), Axes.bonusDamageMaxBonus);
return damage + axeBonus;
}
/**
* Handle the effects of the Critical Hit ability
*
* @param target The {@link LivingEntity} being affected by the ability
* @param damage The amount of damage initially dealt by the event
* @return the modified event damage if the ability was successful, the original event damage otherwise
*/
public int criticalHitCheck(LivingEntity target, int damage) {
Player player = getPlayer();
if (SkillUtils.activationSuccessful(player, skill, Axes.criticalHitMaxChance, Axes.criticalHitMaxBonusLevel)) {
player.sendMessage(LocaleLoader.getString("Axes.Combat.CriticalHit"));
if (target instanceof Player) {
((Player) target).sendMessage(LocaleLoader.getString("Axes.Combat.CritStruck"));
return (int) (damage * Axes.criticalHitPVPModifier);
}
return (int) (damage * Axes.criticalHitPVEModifier);
}
return damage;
}
/**
* Handle the effects of the Impact ability
*
* @param target The {@link LivingEntity} being affected by Impact
*/
public void impactCheck(LivingEntity target) {
int durabilityDamage = 1 + (getSkillLevel() / Axes.impactIncreaseLevel);
for (ItemStack armor : target.getEquipment().getArmorContents()) {
if (ItemUtils.isArmor(armor) && SkillUtils.activationSuccessful(getPlayer(), skill, Axes.impactChance)) {
double durabilityModifier = 1 / (armor.getEnchantmentLevel(Enchantment.DURABILITY) + 1); // Modifier to simulate the durability enchantment behavior
double modifiedDurabilityDamage = durabilityDamage * durabilityModifier;
double maxDurabilityDamage = (ModUtils.isCustomArmor(armor) ? ModUtils.getArmorFromItemStack(armor).getDurability() : armor.getType().getMaxDurability()) * Axes.impactMaxDurabilityModifier;
armor.setDurability((short) (Math.min(modifiedDurabilityDamage, maxDurabilityDamage) + armor.getDurability()));
}
}
}
/**
* Handle the effects of the Greater Impact ability
*
* @param target The {@link LivingEntity} being affected by the ability
* @param damage The amount of damage initially dealt by the event
* @return the modified event damage if the ability was successful, the original event damage otherwise
*/
public int greaterImpactCheck(LivingEntity target, int damage) {
Player player = getPlayer();
if (SkillUtils.activationSuccessful(player, skill, Axes.greaterImpactChance)) {
ParticleEffectUtils.playGreaterImpactEffect(target);
target.setVelocity(player.getLocation().getDirection().normalize().multiply(Axes.greaterImpactKnockbackMultiplier));
if (getProfile().useChatNotifications()) {
player.sendMessage(LocaleLoader.getString("Axes.Combat.GI.Proc"));
}
if (target instanceof Player) {
Player defender = (Player) target;
if (UserManager.getPlayer(defender).getProfile().useChatNotifications()) {
defender.sendMessage(LocaleLoader.getString("Axes.Combat.GI.Struck"));
}
}
return damage + Axes.greaterImpactBonusDamage;
}
return damage;
}
/**
* Handle the effects of the Skull Splitter ability
*
* @param target The {@link LivingEntity} being affected by the ability
* @param damage The amount of damage initially dealt by the event
*/
public void skullSplitterCheck(LivingEntity target, int damage) {
CombatUtils.applyAbilityAoE(getPlayer(), target, damage / Axes.skullSplitterModifier, skill);
}
}

View File

@ -1,37 +1,37 @@
package com.gmail.nossr50.skills.axes;
import org.bukkit.entity.LivingEntity;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.util.ItemChecks;
public class Axes {
public static int bonusDamageMaxBonus = AdvancedConfig.getInstance().getBonusDamageAxesBonusMax();
public static int bonusDamageMaxBonusLevel = AdvancedConfig.getInstance().getBonusDamageAxesMaxBonusLevel();
public static int criticalHitMaxBonusLevel = AdvancedConfig.getInstance().getAxesCriticalMaxBonusLevel();
public static double criticalHitMaxChance = AdvancedConfig.getInstance().getAxesCriticalChance();
public static double criticalHitPVPModifier = AdvancedConfig.getInstance().getAxesCriticalPVPModifier();
public static double criticalHitPVEModifier = AdvancedConfig.getInstance().getAxesCriticalPVEModifier();
public static int impactIncreaseLevel = AdvancedConfig.getInstance().getArmorImpactIncreaseLevel();
public static double impactChance = AdvancedConfig.getInstance().getImpactChance();
public static double impactMaxDurabilityDamageModifier = AdvancedConfig.getInstance().getArmorImpactMaxDurabilityDamage() / 100D;
public static double greaterImpactChance = AdvancedConfig.getInstance().getGreaterImpactChance();
public static double greaterImpactKnockbackMultiplier = AdvancedConfig.getInstance().getGreaterImpactModifier();
public static int greaterImpactBonusDamage = AdvancedConfig.getInstance().getGreaterImpactBonusDamage();
public static int skullSplitterModifier = AdvancedConfig.getInstance().getSkullSplitterModifier();
protected static boolean hasArmor(LivingEntity target) {
for (ItemStack itemStack : target.getEquipment().getArmorContents()) {
if (ItemChecks.isArmor(itemStack)) {
return true;
}
}
return false;
}
}
package com.gmail.nossr50.skills.axes;
import org.bukkit.entity.LivingEntity;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.util.ItemUtils;
public class Axes {
public static int bonusDamageMaxBonus = AdvancedConfig.getInstance().getBonusDamageAxesBonusMax();
public static int bonusDamageMaxBonusLevel = AdvancedConfig.getInstance().getBonusDamageAxesMaxBonusLevel();
public static int criticalHitMaxBonusLevel = AdvancedConfig.getInstance().getAxesCriticalMaxBonusLevel();
public static double criticalHitMaxChance = AdvancedConfig.getInstance().getAxesCriticalChance();
public static double criticalHitPVPModifier = AdvancedConfig.getInstance().getAxesCriticalPVPModifier();
public static double criticalHitPVEModifier = AdvancedConfig.getInstance().getAxesCriticalPVEModifier();
public static int impactIncreaseLevel = AdvancedConfig.getInstance().getArmorImpactIncreaseLevel();
public static double impactChance = AdvancedConfig.getInstance().getImpactChance();
public static double impactMaxDurabilityModifier = AdvancedConfig.getInstance().getArmorImpactMaxDurabilityDamage() / 100D;
public static int greaterImpactBonusDamage = AdvancedConfig.getInstance().getGreaterImpactBonusDamage();
public static double greaterImpactChance = AdvancedConfig.getInstance().getGreaterImpactChance();
public static double greaterImpactKnockbackMultiplier = AdvancedConfig.getInstance().getGreaterImpactModifier();
public static int skullSplitterModifier = AdvancedConfig.getInstance().getSkullSplitterModifier();
protected static boolean hasArmor(LivingEntity target) {
for (ItemStack itemStack : target.getEquipment().getArmorContents()) {
if (ItemUtils.isArmor(itemStack)) {
return true;
}
}
return false;
}
}

View File

@ -1,128 +0,0 @@
package com.gmail.nossr50.skills.axes;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.SkillCommand;
import com.gmail.nossr50.skills.utilities.SkillType;
import com.gmail.nossr50.util.Permissions;
public class AxesCommand extends SkillCommand {
private String critChance;
private String critChanceLucky;
private String bonusDamage;
private String impactDamage;
private String greaterImpactDamage;
private String skullSplitterLength;
private String skullSplitterLengthEndurance;
private boolean canSkullSplitter;
private boolean canCritical;
private boolean canBonusDamage;
private boolean canImpact;
private boolean canGreaterImpact;
public AxesCommand() {
super(SkillType.AXES);
}
@Override
protected void dataCalculations() {
//IMPACT
impactDamage = String.valueOf(1 + (skillValue / Axes.impactIncreaseLevel));
greaterImpactDamage = String.valueOf(Axes.greaterImpactBonusDamage);
//SKULL SPLITTER
String[] skullSplitterStrings = calculateLengthDisplayValues();
skullSplitterLength = skullSplitterStrings[0];
skullSplitterLengthEndurance = skullSplitterStrings[1];
//CRITICAL STRIKES
String[] criticalStrikeStrings = calculateAbilityDisplayValues(Axes.criticalHitMaxBonusLevel, Axes.criticalHitMaxChance);
critChance = criticalStrikeStrings[0];
critChanceLucky = criticalStrikeStrings[1];
//AXE MASTERY
if (skillValue >= Axes.bonusDamageMaxBonusLevel) {
bonusDamage = String.valueOf(Axes.bonusDamageMaxBonus);
}
else {
bonusDamage = String.valueOf(skillValue / (Axes.bonusDamageMaxBonusLevel / Axes.bonusDamageMaxBonus));
}
}
@Override
protected void permissionsCheck() {
canSkullSplitter = Permissions.skullSplitter(player);
canCritical = Permissions.criticalStrikes(player);
canBonusDamage = Permissions.bonusDamage(player, skill);
canImpact = Permissions.armorImpact(player);
canGreaterImpact = Permissions.greaterImpact(player);
}
@Override
protected boolean effectsHeaderPermissions() {
return canSkullSplitter || canCritical || canBonusDamage || canImpact || canGreaterImpact;
}
@Override
protected void effectsDisplay() {
luckyEffectsDisplay();
if (canSkullSplitter) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Axes.Effect.0"), LocaleLoader.getString("Axes.Effect.1")));
}
if (canCritical) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Axes.Effect.2"), LocaleLoader.getString("Axes.Effect.3")));
}
if (canBonusDamage) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Axes.Effect.4"), LocaleLoader.getString("Axes.Effect.5")));
}
if (canImpact) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Axes.Effect.6"), LocaleLoader.getString("Axes.Effect.7")));
}
if (canGreaterImpact) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Axes.Effect.8"), LocaleLoader.getString("Axes.Effect.9")));
}
}
@Override
protected boolean statsHeaderPermissions() {
return canSkullSplitter || canCritical || canBonusDamage || canImpact || canGreaterImpact;
}
@Override
protected void statsDisplay() {
if (canBonusDamage) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Axes.Ability.Bonus.0"), LocaleLoader.getString("Axes.Ability.Bonus.1", bonusDamage)));
}
if (canImpact) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Axes.Ability.Bonus.2"), LocaleLoader.getString("Axes.Ability.Bonus.3", impactDamage)));
}
if (canGreaterImpact) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Axes.Ability.Bonus.4"), LocaleLoader.getString("Axes.Ability.Bonus.5", greaterImpactDamage)));
}
if (canCritical) {
if (isLucky) {
player.sendMessage(LocaleLoader.getString("Axes.Combat.CritChance", critChance) + LocaleLoader.getString("Perks.lucky.bonus", critChanceLucky));
}
else {
player.sendMessage(LocaleLoader.getString("Axes.Combat.CritChance", critChance));
}
}
if (canSkullSplitter) {
if (hasEndurance) {
player.sendMessage(LocaleLoader.getString("Axes.Combat.SS.Length", skullSplitterLength) + LocaleLoader.getString("Perks.activationtime.bonus", skullSplitterLengthEndurance));
}
else {
player.sendMessage(LocaleLoader.getString("Axes.Combat.SS.Length", skullSplitterLength));
}
}
}
}

View File

@ -6,7 +6,7 @@ import java.util.List;
import org.bukkit.configuration.file.YamlConfiguration;
import com.gmail.nossr50.config.AutoUpdateConfigLoader;
import com.gmail.nossr50.skills.utilities.SkillType;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.util.StringUtils;
public class ChildConfig extends AutoUpdateConfigLoader {
@ -22,15 +22,18 @@ public class ChildConfig extends AutoUpdateConfigLoader {
for (SkillType skill : SkillType.values()) {
if (skill.isChildSkill()) {
plugin.debug("Finding parents of " + skill.name());
List<String> parentNames = config.getStringList(StringUtils.getCapitalized(skill.name()));
EnumSet<SkillType> parentSkills = EnumSet.noneOf(SkillType.class);
boolean useDefaults = false; // If we had an error we back out and use defaults
for (String name : parentNames) {
try {
SkillType parentSkill = Enum.valueOf(SkillType.class, name.toUpperCase());
FamilyTree.enforceNotChildSkill(parentSkill);
parentSkills.add(parentSkill);
} catch (IllegalArgumentException ex) {
}
catch (IllegalArgumentException ex) {
plugin.getLogger().warning(name + " is not a valid skill type, or is a child skill!");
useDefaults = true;
break;
@ -55,6 +58,7 @@ public class ChildConfig extends AutoUpdateConfigLoader {
}
}
}
FamilyTree.closeRegistration();
}
}

View File

@ -5,7 +5,7 @@ import java.util.EnumSet;
import java.util.HashMap;
import java.util.Set;
import com.gmail.nossr50.skills.utilities.SkillType;
import com.gmail.nossr50.datatypes.skills.SkillType;
public class FamilyTree {
private static HashMap<SkillType, Set<SkillType>> tree = new HashMap<SkillType, Set<SkillType>>();

View File

@ -1,59 +1,58 @@
package com.gmail.nossr50.skills.excavation;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.block.BlockState;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.TreasuresConfig;
import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure;
import com.gmail.nossr50.mods.ModChecks;
import com.gmail.nossr50.skills.utilities.SkillType;
public class Excavation {
/**
* Get the list of possible {@link ExcavationTreasure|ExcavationTreasures} obtained from a given block.
*
* @param blockState The {@link BlockState} of the block to check.
* @return the list of treasures that could be found
*/
protected static List<ExcavationTreasure> getTreasures(BlockState blockState) {
switch (blockState.getType()) {
case DIRT:
return TreasuresConfig.getInstance().excavationFromDirt;
case GRASS:
return TreasuresConfig.getInstance().excavationFromGrass;
case SAND:
return TreasuresConfig.getInstance().excavationFromSand;
case GRAVEL:
return TreasuresConfig.getInstance().excavationFromGravel;
case CLAY:
return TreasuresConfig.getInstance().excavationFromClay;
case MYCEL:
return TreasuresConfig.getInstance().excavationFromMycel;
case SOUL_SAND:
return TreasuresConfig.getInstance().excavationFromSoulSand;
default:
return new ArrayList<ExcavationTreasure>();
}
}
protected static int getBlockXP(BlockState blockState) {
int xp = Config.getInstance().getXp(SkillType.EXCAVATION, blockState.getType());
if (xp == 0 && ModChecks.isCustomExcavationBlock(blockState)) {
xp = ModChecks.getCustomBlock(blockState).getXpGain();
}
return xp;
}
}
package com.gmail.nossr50.skills.excavation;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.block.BlockState;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.treasure.TreasureConfig;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure;
import com.gmail.nossr50.util.ModUtils;
public class Excavation {
/**
* Get the list of possible {@link ExcavationTreasure|ExcavationTreasures} obtained from a given block.
*
* @param blockState The {@link BlockState} of the block to check.
* @return the list of treasures that could be found
*/
protected static List<ExcavationTreasure> getTreasures(BlockState blockState) {
switch (blockState.getType()) {
case DIRT:
return TreasureConfig.getInstance().excavationFromDirt;
case GRASS:
return TreasureConfig.getInstance().excavationFromGrass;
case SAND:
return TreasureConfig.getInstance().excavationFromSand;
case GRAVEL:
return TreasureConfig.getInstance().excavationFromGravel;
case CLAY:
return TreasureConfig.getInstance().excavationFromClay;
case MYCEL:
return TreasureConfig.getInstance().excavationFromMycel;
case SOUL_SAND:
return TreasureConfig.getInstance().excavationFromSoulSand;
default:
return new ArrayList<ExcavationTreasure>();
}
}
protected static int getBlockXP(BlockState blockState) {
int xp = Config.getInstance().getXp(SkillType.EXCAVATION, blockState.getType());
if (xp == 0 && ModUtils.isCustomExcavationBlock(blockState)) {
xp = ModUtils.getCustomBlock(blockState).getXpGain();
}
return xp;
}
}

View File

@ -1,67 +0,0 @@
package com.gmail.nossr50.skills.excavation;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.SkillCommand;
import com.gmail.nossr50.skills.utilities.SkillType;
import com.gmail.nossr50.util.Permissions;
public class ExcavationCommand extends SkillCommand {
private String gigaDrillBreakerLength;
private String gigaDrillBreakerLengthEndurance;
private boolean canGigaDrill;
private boolean canTreasureHunt;
public ExcavationCommand() {
super(SkillType.EXCAVATION);
}
@Override
protected void dataCalculations() {
//GIGA DRILL BREAKER
String gigaDrillStrings[] = calculateLengthDisplayValues();
gigaDrillBreakerLength = gigaDrillStrings[0];
gigaDrillBreakerLengthEndurance = gigaDrillStrings[1];
}
@Override
protected void permissionsCheck() {
canGigaDrill = Permissions.gigaDrillBreaker(player);
canTreasureHunt = Permissions.excavationTreasureHunter(player);
}
@Override
protected boolean effectsHeaderPermissions() {
return canGigaDrill || canTreasureHunt;
}
@Override
protected void effectsDisplay() {
luckyEffectsDisplay();
if (canGigaDrill) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Excavation.Effect.0"), LocaleLoader.getString("Excavation.Effect.1")));
}
if (canTreasureHunt) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Excavation.Effect.2"), LocaleLoader.getString("Excavation.Effect.3")));
}
}
@Override
protected boolean statsHeaderPermissions() {
return canGigaDrill;
}
@Override
protected void statsDisplay() {
if (canGigaDrill) {
if (hasEndurance) {
player.sendMessage(LocaleLoader.getString("Excavation.Effect.Length", gigaDrillBreakerLength) + LocaleLoader.getString("Perks.activationtime.bonus", gigaDrillBreakerLengthEndurance));
}
else {
player.sendMessage(LocaleLoader.getString("Excavation.Effect.Length", gigaDrillBreakerLength));
}
}
}
}

View File

@ -1,57 +1,57 @@
package com.gmail.nossr50.skills.excavation;
import java.util.List;
import org.bukkit.Location;
import org.bukkit.block.BlockState;
import com.gmail.nossr50.datatypes.McMMOPlayer;
import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure;
import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.skills.utilities.SkillTools;
import com.gmail.nossr50.skills.utilities.SkillType;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
public class ExcavationManager extends SkillManager {
public ExcavationManager(McMMOPlayer mcMMOPlayer) {
super(mcMMOPlayer, SkillType.EXCAVATION);
}
/**
* Process treasure drops & XP gain for Excavation.
*
* @param blockState The {@link BlockState} to check ability activation for
*/
public void excavationBlockCheck(BlockState blockState) {
int xp = Excavation.getBlockXP(blockState);
if (Permissions.excavationTreasureHunter(getPlayer())) {
List<ExcavationTreasure> treasures = Excavation.getTreasures(blockState);
if (!treasures.isEmpty()) {
int skillLevel = getSkillLevel();
Location location = blockState.getLocation();
for (ExcavationTreasure treasure : treasures) {
if (skillLevel >= treasure.getDropLevel() && SkillTools.treasureDropSuccessful(treasure.getDropChance(), activationChance)) {
xp += treasure.getXp();
Misc.dropItem(location, treasure.getDrop());
}
}
}
}
applyXpGain(xp);
}
/**
* Process the Giga Drill Breaker ability.
*
* @param blockState The {@link BlockState} to check ability activation for
*/
public void gigaDrillBreaker(BlockState blockState) {
excavationBlockCheck(blockState);
excavationBlockCheck(blockState);
}
}
package com.gmail.nossr50.skills.excavation;
import java.util.List;
import org.bukkit.Location;
import org.bukkit.block.BlockState;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure;
import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.skills.SkillUtils;
public class ExcavationManager extends SkillManager {
public ExcavationManager(McMMOPlayer mcMMOPlayer) {
super(mcMMOPlayer, SkillType.EXCAVATION);
}
/**
* Process treasure drops & XP gain for Excavation.
*
* @param blockState The {@link BlockState} to check ability activation for
*/
public void excavationBlockCheck(BlockState blockState) {
int xp = Excavation.getBlockXP(blockState);
if (Permissions.excavationTreasureHunter(getPlayer())) {
List<ExcavationTreasure> treasures = Excavation.getTreasures(blockState);
if (!treasures.isEmpty()) {
int skillLevel = getSkillLevel();
Location location = blockState.getLocation();
for (ExcavationTreasure treasure : treasures) {
if (skillLevel >= treasure.getDropLevel() && SkillUtils.treasureDropSuccessful(treasure.getDropChance(), activationChance)) {
xp += treasure.getXp();
Misc.dropItem(location, treasure.getDrop());
}
}
}
}
applyXpGain(xp);
}
/**
* Process the Giga Drill Breaker ability.
*
* @param blockState The {@link BlockState} to check ability activation for
*/
public void gigaDrillBreaker(BlockState blockState) {
excavationBlockCheck(blockState);
excavationBlockCheck(blockState);
}
}

View File

@ -1,201 +1,201 @@
package com.gmail.nossr50.skills.fishing;
import java.util.Map;
import java.util.Map.Entry;
import org.bukkit.DyeColor;
import org.bukkit.Material;
import org.bukkit.entity.LivingEntity;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.Potion;
import org.bukkit.potion.PotionType;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.util.Misc;
public final class Fishing {
// The order of the values is extremely important, a few methods depend on it to work properly
protected enum Tier {
FIVE(5) {
@Override public int getLevel() {return AdvancedConfig.getInstance().getFishingTierLevelsTier5();}
@Override public int getShakeChance() {return AdvancedConfig.getInstance().getShakeChanceRank5();}
@Override public int getVanillaXPBoostModifier() {return AdvancedConfig.getInstance().getFishingVanillaXPModifierRank5();}},
FOUR(4) {
@Override public int getLevel() {return AdvancedConfig.getInstance().getFishingTierLevelsTier4();}
@Override public int getShakeChance() {return AdvancedConfig.getInstance().getShakeChanceRank4();}
@Override public int getVanillaXPBoostModifier() {return AdvancedConfig.getInstance().getFishingVanillaXPModifierRank4();}},
THREE(3) {
@Override public int getLevel() {return AdvancedConfig.getInstance().getFishingTierLevelsTier3();}
@Override public int getShakeChance() {return AdvancedConfig.getInstance().getShakeChanceRank3();}
@Override public int getVanillaXPBoostModifier() {return AdvancedConfig.getInstance().getFishingVanillaXPModifierRank3();}},
TWO(2) {
@Override public int getLevel() {return AdvancedConfig.getInstance().getFishingTierLevelsTier2();}
@Override public int getShakeChance() {return AdvancedConfig.getInstance().getShakeChanceRank2();}
@Override public int getVanillaXPBoostModifier() {return AdvancedConfig.getInstance().getFishingVanillaXPModifierRank2();}},
ONE(1) {
@Override public int getLevel() {return AdvancedConfig.getInstance().getFishingTierLevelsTier1();}
@Override public int getShakeChance() {return AdvancedConfig.getInstance().getShakeChanceRank1();}
@Override public int getVanillaXPBoostModifier() {return AdvancedConfig.getInstance().getFishingVanillaXPModifierRank1();}};
int numerical;
private Tier(int numerical) {
this.numerical = numerical;
}
public int toNumerical() {
return numerical;
}
abstract protected int getLevel();
abstract protected int getShakeChance();
abstract protected int getVanillaXPBoostModifier();
}
// TODO: Get rid of that
public static int fishermansDietRankLevel1 = AdvancedConfig.getInstance().getFishermanDietRankChange();
public static int fishermansDietRankLevel2 = fishermansDietRankLevel1 * 2;
public static int fishermansDietMaxLevel = fishermansDietRankLevel1 * 5;
public static final double STORM_MODIFIER = 0.909;
private Fishing() {}
/**
* Finds the possible drops of an entity
*
* @param target Targeted entity
* @param possibleDrops List of ItemStack that can be dropped
*/
protected static void findPossibleDrops(LivingEntity target, Map<ItemStack, Integer> possibleDrops) {
switch (target.getType()) {
case BLAZE:
possibleDrops.put(new ItemStack(Material.BLAZE_ROD), 100);
break;
case CAVE_SPIDER:
case SPIDER:
possibleDrops.put(new ItemStack(Material.SPIDER_EYE), 50);
possibleDrops.put(new ItemStack(Material.STRING), 50);
break;
case CHICKEN:
possibleDrops.put(new ItemStack(Material.FEATHER), 34);
possibleDrops.put(new ItemStack(Material.RAW_CHICKEN), 33);
possibleDrops.put(new ItemStack(Material.EGG), 33);
break;
case COW:
possibleDrops.put(new ItemStack(Material.MILK_BUCKET), 2);
possibleDrops.put(new ItemStack(Material.LEATHER), 49);
possibleDrops.put(new ItemStack(Material.RAW_BEEF), 49);
break;
case CREEPER:
possibleDrops.put(new ItemStack(Material.SKULL_ITEM, 1, (short) 4), 1);
possibleDrops.put(new ItemStack(Material.SULPHUR), 99);
break;
case ENDERMAN:
possibleDrops.put(new ItemStack(Material.ENDER_PEARL), 100);
break;
case GHAST:
possibleDrops.put(new ItemStack(Material.SULPHUR), 50);
possibleDrops.put(new ItemStack(Material.GHAST_TEAR), 50);
break;
case IRON_GOLEM:
possibleDrops.put(new ItemStack(Material.PUMPKIN), 3);
possibleDrops.put(new ItemStack(Material.IRON_INGOT), 12);
possibleDrops.put(new ItemStack(Material.RED_ROSE), 85);
break;
case MAGMA_CUBE:
possibleDrops.put(new ItemStack(Material.MAGMA_CREAM), 100);
break;
case MUSHROOM_COW:
possibleDrops.put(new ItemStack(Material.MILK_BUCKET), 5);
possibleDrops.put(new ItemStack(Material.MUSHROOM_SOUP), 5);
possibleDrops.put(new ItemStack(Material.LEATHER), 30);
possibleDrops.put(new ItemStack(Material.RAW_BEEF), 30);
possibleDrops.put(new ItemStack(Material.RED_MUSHROOM, Misc.getRandom().nextInt(3) + 1), 30);
break;
case PIG:
possibleDrops.put(new ItemStack(Material.PORK), 100);
break;
case PIG_ZOMBIE:
possibleDrops.put(new ItemStack(Material.ROTTEN_FLESH), 50);
possibleDrops.put(new ItemStack(Material.GOLD_NUGGET), 50);
break;
case SHEEP:
possibleDrops.put(new ItemStack(Material.WOOL, Misc.getRandom().nextInt(6) + 1), 100);
break;
case SKELETON:
possibleDrops.put(new ItemStack(Material.SKULL_ITEM, 1, (short) 0), 2);
possibleDrops.put(new ItemStack(Material.BONE), 49);
possibleDrops.put(new ItemStack(Material.ARROW, Misc.getRandom().nextInt(3) + 1), 49);
break;
case SLIME:
possibleDrops.put(new ItemStack(Material.SLIME_BALL), 100);
break;
case SNOWMAN:
possibleDrops.put(new ItemStack(Material.PUMPKIN), 3);
possibleDrops.put(new ItemStack(Material.SNOW_BALL, Misc.getRandom().nextInt(4) + 1), 97);
break;
case SQUID:
possibleDrops.put(new ItemStack(Material.INK_SACK, 1, DyeColor.BLACK.getDyeData()), 100);
break;
case WITCH:
possibleDrops.put(new Potion(PotionType.INSTANT_HEAL).toItemStack(1), 1);
possibleDrops.put(new Potion(PotionType.FIRE_RESISTANCE).toItemStack(1), 1);
possibleDrops.put(new Potion(PotionType.SPEED).toItemStack(1), 1);
possibleDrops.put(new ItemStack(Material.GLASS_BOTTLE), 9);
possibleDrops.put(new ItemStack(Material.GLOWSTONE_DUST), 13);
possibleDrops.put(new ItemStack(Material.SULPHUR), 12);
possibleDrops.put(new ItemStack(Material.REDSTONE), 13);
possibleDrops.put(new ItemStack(Material.SPIDER_EYE), 12);
possibleDrops.put(new ItemStack(Material.STICK), 13);
possibleDrops.put(new ItemStack(Material.SUGAR), 12);
possibleDrops.put(new ItemStack(Material.POTION), 13);
break;
case ZOMBIE:
possibleDrops.put(new ItemStack(Material.SKULL_ITEM, 1, (short) 2), 2);
possibleDrops.put(new ItemStack(Material.ROTTEN_FLESH), 98);
break;
default:
return;
}
}
/**
* Randomly chooses a drop among the list
*
* @param possibleDrops List of ItemStack that can be dropped
* @return Chosen ItemStack
*/
protected static ItemStack chooseDrop(Map<ItemStack, Integer> possibleDrops) {
int dropProbability = Misc.getRandom().nextInt(100);
int cumulatedProbability = 0;
for (Entry<ItemStack, Integer> entry : possibleDrops.entrySet()) {
cumulatedProbability += entry.getValue();
if (dropProbability < cumulatedProbability) {
return entry.getKey();
}
}
return null;
}
}
package com.gmail.nossr50.skills.fishing;
import java.util.Map;
import java.util.Map.Entry;
import org.bukkit.DyeColor;
import org.bukkit.Material;
import org.bukkit.entity.LivingEntity;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.Potion;
import org.bukkit.potion.PotionType;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.util.Misc;
public final class Fishing {
// The order of the values is extremely important, a few methods depend on it to work properly
protected enum Tier {
FIVE(5) {
@Override public int getLevel() { return AdvancedConfig.getInstance().getFishingTierLevelsTier5(); }
@Override public int getShakeChance() { return AdvancedConfig.getInstance().getShakeChanceRank5(); }
@Override public int getVanillaXPBoostModifier() { return AdvancedConfig.getInstance().getFishingVanillaXPModifierRank5(); }},
FOUR(4) {
@Override public int getLevel() { return AdvancedConfig.getInstance().getFishingTierLevelsTier4(); }
@Override public int getShakeChance() { return AdvancedConfig.getInstance().getShakeChanceRank4(); }
@Override public int getVanillaXPBoostModifier() { return AdvancedConfig.getInstance().getFishingVanillaXPModifierRank4(); }},
THREE(3) {
@Override public int getLevel() { return AdvancedConfig.getInstance().getFishingTierLevelsTier3(); }
@Override public int getShakeChance() { return AdvancedConfig.getInstance().getShakeChanceRank3(); }
@Override public int getVanillaXPBoostModifier() { return AdvancedConfig.getInstance().getFishingVanillaXPModifierRank3(); }},
TWO(2) {
@Override public int getLevel() { return AdvancedConfig.getInstance().getFishingTierLevelsTier2(); }
@Override public int getShakeChance() { return AdvancedConfig.getInstance().getShakeChanceRank2(); }
@Override public int getVanillaXPBoostModifier() { return AdvancedConfig.getInstance().getFishingVanillaXPModifierRank2(); }},
ONE(1) {
@Override public int getLevel() { return AdvancedConfig.getInstance().getFishingTierLevelsTier1(); }
@Override public int getShakeChance() { return AdvancedConfig.getInstance().getShakeChanceRank1(); }
@Override public int getVanillaXPBoostModifier() { return AdvancedConfig.getInstance().getFishingVanillaXPModifierRank1(); }};
int numerical;
private Tier(int numerical) {
this.numerical = numerical;
}
public int toNumerical() {
return numerical;
}
abstract protected int getLevel();
abstract protected int getShakeChance();
abstract protected int getVanillaXPBoostModifier();
}
public static int fishermansDietRankLevel1 = AdvancedConfig.getInstance().getFishermanDietRankChange();
public static int fishermansDietRankLevel2 = fishermansDietRankLevel1 * 2;
public static int fishermansDietMaxLevel = fishermansDietRankLevel1 * 5;
public static final double STORM_MODIFIER = 0.909;
private Fishing() {}
/**
* Finds the possible drops of an entity
*
* @param target Targeted entity
* @param possibleDrops List of ItemStack that can be dropped
*/
protected static void findPossibleDrops(LivingEntity target, Map<ItemStack, Integer> possibleDrops) {
switch (target.getType()) {
case BLAZE:
possibleDrops.put(new ItemStack(Material.BLAZE_ROD), 100);
break;
case CAVE_SPIDER:
case SPIDER:
possibleDrops.put(new ItemStack(Material.SPIDER_EYE), 50);
possibleDrops.put(new ItemStack(Material.STRING), 50);
break;
case CHICKEN:
possibleDrops.put(new ItemStack(Material.FEATHER), 34);
possibleDrops.put(new ItemStack(Material.RAW_CHICKEN), 33);
possibleDrops.put(new ItemStack(Material.EGG), 33);
break;
case COW:
possibleDrops.put(new ItemStack(Material.MILK_BUCKET), 2);
possibleDrops.put(new ItemStack(Material.LEATHER), 49);
possibleDrops.put(new ItemStack(Material.RAW_BEEF), 49);
break;
case CREEPER:
possibleDrops.put(new ItemStack(Material.SKULL_ITEM, 1, (short) 4), 1);
possibleDrops.put(new ItemStack(Material.SULPHUR), 99);
break;
case ENDERMAN:
possibleDrops.put(new ItemStack(Material.ENDER_PEARL), 100);
break;
case GHAST:
possibleDrops.put(new ItemStack(Material.SULPHUR), 50);
possibleDrops.put(new ItemStack(Material.GHAST_TEAR), 50);
break;
case IRON_GOLEM:
possibleDrops.put(new ItemStack(Material.PUMPKIN), 3);
possibleDrops.put(new ItemStack(Material.IRON_INGOT), 12);
possibleDrops.put(new ItemStack(Material.RED_ROSE), 85);
break;
case MAGMA_CUBE:
possibleDrops.put(new ItemStack(Material.MAGMA_CREAM), 100);
break;
case MUSHROOM_COW:
possibleDrops.put(new ItemStack(Material.MILK_BUCKET), 5);
possibleDrops.put(new ItemStack(Material.MUSHROOM_SOUP), 5);
possibleDrops.put(new ItemStack(Material.LEATHER), 30);
possibleDrops.put(new ItemStack(Material.RAW_BEEF), 30);
possibleDrops.put(new ItemStack(Material.RED_MUSHROOM, Misc.getRandom().nextInt(3) + 1), 30);
break;
case PIG:
possibleDrops.put(new ItemStack(Material.PORK), 100);
break;
case PIG_ZOMBIE:
possibleDrops.put(new ItemStack(Material.ROTTEN_FLESH), 50);
possibleDrops.put(new ItemStack(Material.GOLD_NUGGET), 50);
break;
case SHEEP:
possibleDrops.put(new ItemStack(Material.WOOL, Misc.getRandom().nextInt(6) + 1), 100);
break;
case SKELETON:
possibleDrops.put(new ItemStack(Material.SKULL_ITEM, 1, (short) 0), 2);
possibleDrops.put(new ItemStack(Material.BONE), 49);
possibleDrops.put(new ItemStack(Material.ARROW, Misc.getRandom().nextInt(3) + 1), 49);
break;
case SLIME:
possibleDrops.put(new ItemStack(Material.SLIME_BALL), 100);
break;
case SNOWMAN:
possibleDrops.put(new ItemStack(Material.PUMPKIN), 3);
possibleDrops.put(new ItemStack(Material.SNOW_BALL, Misc.getRandom().nextInt(4) + 1), 97);
break;
case SQUID:
possibleDrops.put(new ItemStack(Material.INK_SACK, 1, DyeColor.BLACK.getDyeData()), 100);
break;
case WITCH:
possibleDrops.put(new Potion(PotionType.INSTANT_HEAL).toItemStack(1), 1);
possibleDrops.put(new Potion(PotionType.FIRE_RESISTANCE).toItemStack(1), 1);
possibleDrops.put(new Potion(PotionType.SPEED).toItemStack(1), 1);
possibleDrops.put(new ItemStack(Material.GLASS_BOTTLE), 9);
possibleDrops.put(new ItemStack(Material.GLOWSTONE_DUST), 13);
possibleDrops.put(new ItemStack(Material.SULPHUR), 12);
possibleDrops.put(new ItemStack(Material.REDSTONE), 13);
possibleDrops.put(new ItemStack(Material.SPIDER_EYE), 12);
possibleDrops.put(new ItemStack(Material.STICK), 13);
possibleDrops.put(new ItemStack(Material.SUGAR), 12);
possibleDrops.put(new ItemStack(Material.POTION), 13);
break;
case ZOMBIE:
possibleDrops.put(new ItemStack(Material.SKULL_ITEM, 1, (short) 2), 2);
possibleDrops.put(new ItemStack(Material.ROTTEN_FLESH), 98);
break;
default:
return;
}
}
/**
* Randomly chooses a drop among the list
*
* @param possibleDrops List of ItemStack that can be dropped
* @return Chosen ItemStack
*/
protected static ItemStack chooseDrop(Map<ItemStack, Integer> possibleDrops) {
int dropProbability = Misc.getRandom().nextInt(100);
int cumulatedProbability = 0;
for (Entry<ItemStack, Integer> entry : possibleDrops.entrySet()) {
cumulatedProbability += entry.getValue();
if (dropProbability < cumulatedProbability) {
return entry.getKey();
}
}
return null;
}
}

View File

@ -1,125 +0,0 @@
package com.gmail.nossr50.skills.fishing;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.SkillCommand;
import com.gmail.nossr50.skills.SkillManagerStore;
import com.gmail.nossr50.skills.utilities.SkillType;
import com.gmail.nossr50.util.Permissions;
public class FishingCommand extends SkillCommand {
private int lootTier;
private String magicChance;
private String magicChanceLucky;
private String chanceRaining = "";
private String shakeChance;
private String shakeChanceLucky;
private String fishermansDietRank;
private boolean canTreasureHunt;
private boolean canMagicHunt;
private boolean canShake;
private boolean canFishermansDiet;
public FishingCommand() {
super(SkillType.FISHING);
}
@Override
protected void dataCalculations() {
lootTier = SkillManagerStore.getInstance().getFishingManager(player.getName()).getLootTier();
//TREASURE HUNTER
double enchantChance = lootTier * AdvancedConfig.getInstance().getFishingMagicMultiplier();
if (player.getWorld().hasStorm()) {
chanceRaining = LocaleLoader.getString("Fishing.Chance.Raining");
enchantChance = enchantChance * 1.1D;
}
String[] treasureHunterStrings = calculateAbilityDisplayValues(enchantChance);
magicChance = treasureHunterStrings[0];
magicChanceLucky = treasureHunterStrings[1];
//SHAKE
String[] shakeStrings = calculateAbilityDisplayValues(SkillManagerStore.getInstance().getFishingManager(player.getName()).getShakeProbability());
shakeChance = shakeStrings[0];
shakeChanceLucky = shakeStrings[1];
//FISHERMAN'S DIET
fishermansDietRank = calculateRank(Fishing.fishermansDietMaxLevel, Fishing.fishermansDietRankLevel1);
}
@Override
protected void permissionsCheck() {
canTreasureHunt = Permissions.fishingTreasureHunter(player);
canMagicHunt = Permissions.magicHunter(player);
canShake = Permissions.shake(player);
canFishermansDiet = Permissions.fishermansDiet(player);
}
@Override
protected boolean effectsHeaderPermissions() {
return canTreasureHunt || canMagicHunt || canShake;
}
@Override
protected void effectsDisplay() {
luckyEffectsDisplay();
if (canTreasureHunt) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.0"), LocaleLoader.getString("Fishing.Effect.1")));
}
if (canMagicHunt) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.2"), LocaleLoader.getString("Fishing.Effect.3")));
}
if (canShake) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.4"), LocaleLoader.getString("Fishing.Effect.5")));
}
if (canFishermansDiet) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.6"), LocaleLoader.getString("Fishing.Effect.7")));
}
}
@Override
protected boolean statsHeaderPermissions() {
return canTreasureHunt || canMagicHunt || canShake;
}
@Override
protected void statsDisplay() {
if (canTreasureHunt) {
player.sendMessage(LocaleLoader.getString("Fishing.Ability.Rank", lootTier));
}
if (canMagicHunt) {
if (isLucky) {
player.sendMessage(LocaleLoader.getString("Fishing.Enchant.Chance", magicChance) + chanceRaining + LocaleLoader.getString("Perks.lucky.bonus", magicChanceLucky));
}
else {
player.sendMessage(LocaleLoader.getString("Fishing.Enchant.Chance", magicChance) + chanceRaining);
}
}
if (canShake) {
if (skillValue < AdvancedConfig.getInstance().getShakeUnlockLevel()) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Fishing.Ability.Locked.0", AdvancedConfig.getInstance().getShakeUnlockLevel())));
}
else {
if (isLucky) {
player.sendMessage(LocaleLoader.getString("Fishing.Ability.Shake", shakeChance) + LocaleLoader.getString("Perks.lucky.bonus", shakeChanceLucky));
}
else {
player.sendMessage(LocaleLoader.getString("Fishing.Ability.Shake", shakeChance));
}
}
}
if (canFishermansDiet) {
player.sendMessage(LocaleLoader.getString("Fishing.Ability.FD", fishermansDietRank));
}
}
}

View File

@ -1,305 +1,305 @@
package com.gmail.nossr50.skills.fishing;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Item;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Sheep;
import org.bukkit.entity.Skeleton;
import org.bukkit.entity.Skeleton.SkeletonType;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.TreasuresConfig;
import com.gmail.nossr50.datatypes.McMMOPlayer;
import com.gmail.nossr50.datatypes.treasure.FishingTreasure;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.skills.fishing.Fishing.Tier;
import com.gmail.nossr50.skills.utilities.CombatTools;
import com.gmail.nossr50.skills.utilities.SkillTools;
import com.gmail.nossr50.skills.utilities.SkillType;
import com.gmail.nossr50.util.ItemChecks;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
public class FishingManager extends SkillManager {
public FishingManager(McMMOPlayer mcMMOPlayer) {
super(mcMMOPlayer, SkillType.FISHING);
}
public boolean canShake(Entity target) {
Player player = getPlayer();
return target instanceof LivingEntity && SkillTools.unlockLevelReached(player, skill, AdvancedConfig.getInstance().getShakeUnlockLevel()) && Permissions.shake(player);
}
/**
* Handle the Fisherman's Diet ability
*
* @param rankChange The # of levels to change rank for the food
* @param eventFoodLevel The initial change in hunger from the event
* @return the modified change in hunger for the event
*/
public int handleFishermanDiet(int rankChange, int eventFoodLevel) {
return SkillTools.handleFoodSkills(getPlayer(), skill, eventFoodLevel, Fishing.fishermansDietRankLevel1, Fishing.fishermansDietMaxLevel, rankChange);
}
/**
* Process the results from a successful fishing trip
*
* @param fishingCatch The {@link Item} initially caught
*/
public void handleFishing(Item fishingCatch) {
int treasureXp = 0;
Player player = getPlayer();
FishingTreasure treasure = null;
if (Config.getInstance().getFishingDropsEnabled() && Permissions.fishingTreasureHunter(player)) {
treasure = getFishingTreasure();
}
if (treasure != null) {
player.sendMessage(LocaleLoader.getString("Fishing.ItemFound"));
treasureXp = treasure.getXp();
ItemStack treasureDrop = treasure.getDrop();
if (Permissions.magicHunter(player) && ItemChecks.isEnchantable(treasureDrop) && handleMagicHunter(treasureDrop)) {
player.sendMessage(LocaleLoader.getString("Fishing.MagicFound"));
}
// Drop the original catch at the feet of the player and set the treasure as the real catch
Misc.dropItem(player.getEyeLocation(), fishingCatch.getItemStack());
fishingCatch.setItemStack(treasureDrop);
}
applyXpGain(Config.getInstance().getFishingBaseXP() + treasureXp);
}
/**
* Handle the vanilla XP boost for Fishing
*
* @param experience The amount of experience initially awarded by the event
* @return the modified event damage
*/
public int handleVanillaXpBoost(int experience) {
return experience * getVanillaXpMultiplier();
}
/**
* Handle the Shake ability
*
* @param mob The {@link LivingEntity} affected by the ability
*/
public void shakeCheck(LivingEntity target) {
if (SkillTools.activationSuccessful(getPlayer(), skill, getShakeProbability())) {
Map<ItemStack, Integer> possibleDrops = new HashMap<ItemStack, Integer>();
Fishing.findPossibleDrops(target, possibleDrops);
if (possibleDrops.isEmpty()) {
return;
}
ItemStack drop = Fishing.chooseDrop(possibleDrops);
// It's possible that chooseDrop returns null if the sum of probability in possibleDrops is inferior than 100
if (drop == null) {
return;
}
// Extra processing depending on the mob and drop type
switch (target.getType()) {
case SHEEP:
Sheep sheep = (Sheep) target;
if (drop.getType() == Material.WOOL) {
if (sheep.isSheared()) {
return;
}
drop.setDurability(sheep.getColor().getWoolData());
sheep.setSheared(true);
}
break;
case SKELETON:
Skeleton skeleton = (Skeleton) target;
if (skeleton.getSkeletonType() == SkeletonType.WITHER) {
switch (drop.getType()) {
case SKULL_ITEM:
drop.setDurability((short) 1);
break;
case ARROW:
drop.setType(Material.COAL);
break;
default:
break;
}
}
break;
default:
break;
}
Misc.dropItem(target.getLocation(), drop);
CombatTools.dealDamage(target, target.getMaxHealth() / 4); // Make it so you can shake a mob no more than 4 times.
}
}
/**
* Process the Treasure Hunter ability for Fishing
*
* @return The {@link FishingTreasure} found, or null if no treasure was found.
*/
private FishingTreasure getFishingTreasure() {
List<FishingTreasure> rewards = new ArrayList<FishingTreasure>();
int skillLevel = getSkillLevel();
for (FishingTreasure treasure : TreasuresConfig.getInstance().fishingRewards) {
int maxLevel = treasure.getMaxLevel();
if (treasure.getDropLevel() <= skillLevel && (maxLevel >= skillLevel || maxLevel <= 0)) {
rewards.add(treasure);
}
}
if (rewards.isEmpty()) {
return null;
}
FishingTreasure treasure = rewards.get(Misc.getRandom().nextInt(rewards.size()));
ItemStack treasureDrop = treasure.getDrop();
if (!SkillTools.treasureDropSuccessful(treasure.getDropChance(), skillLevel)) {
return null;
}
short maxDurability = treasureDrop.getType().getMaxDurability();
if (maxDurability > 0) {
treasureDrop.setDurability((short) (Misc.getRandom().nextInt(maxDurability)));
}
return treasure;
}
/**
* Process the Magic Hunter ability
*
* @param treasureDrop The {@link ItemStack} to enchant
* @return true if the item has been enchanted
*/
private boolean handleMagicHunter(ItemStack treasureDrop) {
Player player = getPlayer();
int activationChance = this.activationChance;
if (player.getWorld().hasStorm()) {
activationChance *= Fishing.STORM_MODIFIER;
}
if (Misc.getRandom().nextInt(activationChance) > getLootTier() * AdvancedConfig.getInstance().getFishingMagicMultiplier()) {
return false;
}
List<Enchantment> possibleEnchantments = new ArrayList<Enchantment>();
for (Enchantment enchantment : Enchantment.values()) {
if (enchantment.canEnchantItem(treasureDrop)) {
possibleEnchantments.add(enchantment);
}
}
// This make sure that the order isn't always the same, for example previously Unbreaking had a lot more chance to be used than any other enchant
Collections.shuffle(possibleEnchantments, Misc.getRandom());
boolean enchanted = false;
int specificChance = 1;
for (Enchantment possibleEnchantment : possibleEnchantments) {
boolean conflicts = false;
for (Enchantment currentEnchantment : treasureDrop.getEnchantments().keySet()) {
conflicts = currentEnchantment.conflictsWith(possibleEnchantment);
if (conflicts) {
break;
}
}
if (!conflicts && Misc.getRandom().nextInt(specificChance) == 0) {
treasureDrop.addEnchantment(possibleEnchantment, Misc.getRandom().nextInt(possibleEnchantment.getMaxLevel()) + 1);
specificChance++;
enchanted = true;
}
}
return enchanted;
}
/**
* Gets the loot tier
*
* @return the loot tier
*/
public int getLootTier() {
int skillLevel = getSkillLevel();
for (Tier tier : Tier.values()) {
if (skillLevel >= tier.getLevel()) {
return tier.toNumerical();
}
}
return 0;
}
/**
* Gets the Shake Mob probability
*
* @return Shake Mob probability
*/
public int getShakeProbability() {
int skillLevel = getSkillLevel();
for (Tier tier : Tier.values()) {
if (skillLevel >= tier.getLevel()) {
return tier.getShakeChance();
}
}
return 0;
}
/**
* Gets the vanilla XP multiplier
*
* @return the vanilla XP multiplier
*/
private int getVanillaXpMultiplier() {
int skillLevel = getSkillLevel();
for (Tier tier : Tier.values()) {
if (skillLevel >= tier.getLevel()) {
return tier.getVanillaXPBoostModifier();
}
}
return 0;
}
}
package com.gmail.nossr50.skills.fishing;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Item;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Sheep;
import org.bukkit.entity.Skeleton;
import org.bukkit.entity.Skeleton.SkeletonType;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.treasure.TreasureConfig;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.datatypes.treasure.FishingTreasure;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.skills.fishing.Fishing.Tier;
import com.gmail.nossr50.util.ItemUtils;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.skills.CombatUtils;
import com.gmail.nossr50.util.skills.SkillUtils;
public class FishingManager extends SkillManager {
public FishingManager(McMMOPlayer mcMMOPlayer) {
super(mcMMOPlayer, SkillType.FISHING);
}
public boolean canShake(Entity target) {
Player player = getPlayer();
return target instanceof LivingEntity && SkillUtils.unlockLevelReached(player, skill, AdvancedConfig.getInstance().getShakeUnlockLevel()) && Permissions.shake(player);
}
/**
* Gets the loot tier
*
* @return the loot tier
*/
public int getLootTier() {
int skillLevel = getSkillLevel();
for (Tier tier : Tier.values()) {
if (skillLevel >= tier.getLevel()) {
return tier.toNumerical();
}
}
return 0;
}
/**
* Gets the Shake Mob probability
*
* @return Shake Mob probability
*/
public int getShakeProbability() {
int skillLevel = getSkillLevel();
for (Tier tier : Tier.values()) {
if (skillLevel >= tier.getLevel()) {
return tier.getShakeChance();
}
}
return 0;
}
/**
* Handle the Fisherman's Diet ability
*
* @param rankChange The # of levels to change rank for the food
* @param eventFoodLevel The initial change in hunger from the event
* @return the modified change in hunger for the event
*/
public int handleFishermanDiet(int rankChange, int eventFoodLevel) {
return SkillUtils.handleFoodSkills(getPlayer(), skill, eventFoodLevel, Fishing.fishermansDietRankLevel1, Fishing.fishermansDietMaxLevel, rankChange);
}
/**
* Process the results from a successful fishing trip
*
* @param fishingCatch The {@link Item} initially caught
*/
public void handleFishing(Item fishingCatch) {
int treasureXp = 0;
Player player = getPlayer();
FishingTreasure treasure = null;
if (Config.getInstance().getFishingDropsEnabled() && Permissions.fishingTreasureHunter(player)) {
treasure = getFishingTreasure();
}
if (treasure != null) {
player.sendMessage(LocaleLoader.getString("Fishing.ItemFound"));
treasureXp = treasure.getXp();
ItemStack treasureDrop = treasure.getDrop();
if (Permissions.magicHunter(player) && ItemUtils.isEnchantable(treasureDrop) && handleMagicHunter(treasureDrop)) {
player.sendMessage(LocaleLoader.getString("Fishing.MagicFound"));
}
// Drop the original catch at the feet of the player and set the treasure as the real catch
Misc.dropItem(player.getEyeLocation(), fishingCatch.getItemStack());
fishingCatch.setItemStack(treasureDrop);
}
applyXpGain(Config.getInstance().getFishingBaseXP() + treasureXp);
}
/**
* Handle the vanilla XP boost for Fishing
*
* @param experience The amount of experience initially awarded by the event
* @return the modified event damage
*/
public int handleVanillaXpBoost(int experience) {
return experience * getVanillaXpMultiplier();
}
/**
* Handle the Shake ability
*
* @param mob The {@link LivingEntity} affected by the ability
*/
public void shakeCheck(LivingEntity target) {
if (SkillUtils.activationSuccessful(getPlayer(), skill, getShakeProbability())) {
Map<ItemStack, Integer> possibleDrops = new HashMap<ItemStack, Integer>();
Fishing.findPossibleDrops(target, possibleDrops);
if (possibleDrops.isEmpty()) {
return;
}
ItemStack drop = Fishing.chooseDrop(possibleDrops);
// It's possible that chooseDrop returns null if the sum of probability in possibleDrops is inferior than 100
if (drop == null) {
return;
}
// Extra processing depending on the mob and drop type
switch (target.getType()) {
case SHEEP:
Sheep sheep = (Sheep) target;
if (drop.getType() == Material.WOOL) {
if (sheep.isSheared()) {
return;
}
drop.setDurability(sheep.getColor().getWoolData());
sheep.setSheared(true);
}
break;
case SKELETON:
Skeleton skeleton = (Skeleton) target;
if (skeleton.getSkeletonType() == SkeletonType.WITHER) {
switch (drop.getType()) {
case SKULL_ITEM:
drop.setDurability((short) 1);
break;
case ARROW:
drop.setType(Material.COAL);
break;
default:
break;
}
}
break;
default:
break;
}
Misc.dropItem(target.getLocation(), drop);
CombatUtils.dealDamage(target, target.getMaxHealth() / 4); // Make it so you can shake a mob no more than 4 times.
}
}
/**
* Process the Treasure Hunter ability for Fishing
*
* @return The {@link FishingTreasure} found, or null if no treasure was found.
*/
private FishingTreasure getFishingTreasure() {
List<FishingTreasure> rewards = new ArrayList<FishingTreasure>();
int skillLevel = getSkillLevel();
for (FishingTreasure treasure : TreasureConfig.getInstance().fishingRewards) {
int maxLevel = treasure.getMaxLevel();
if (treasure.getDropLevel() <= skillLevel && (maxLevel >= skillLevel || maxLevel <= 0)) {
rewards.add(treasure);
}
}
if (rewards.isEmpty()) {
return null;
}
FishingTreasure treasure = rewards.get(Misc.getRandom().nextInt(rewards.size()));
ItemStack treasureDrop = treasure.getDrop();
if (!SkillUtils.treasureDropSuccessful(treasure.getDropChance(), skillLevel)) {
return null;
}
short maxDurability = treasureDrop.getType().getMaxDurability();
if (maxDurability > 0) {
treasureDrop.setDurability((short) (Misc.getRandom().nextInt(maxDurability)));
}
return treasure;
}
/**
* Process the Magic Hunter ability
*
* @param treasureDrop The {@link ItemStack} to enchant
* @return true if the item has been enchanted
*/
private boolean handleMagicHunter(ItemStack treasureDrop) {
Player player = getPlayer();
int activationChance = this.activationChance;
if (player.getWorld().hasStorm()) {
activationChance *= Fishing.STORM_MODIFIER;
}
if (Misc.getRandom().nextInt(activationChance) > getLootTier() * AdvancedConfig.getInstance().getFishingMagicMultiplier()) {
return false;
}
List<Enchantment> possibleEnchantments = new ArrayList<Enchantment>();
for (Enchantment enchantment : Enchantment.values()) {
if (enchantment.canEnchantItem(treasureDrop)) {
possibleEnchantments.add(enchantment);
}
}
// This make sure that the order isn't always the same, for example previously Unbreaking had a lot more chance to be used than any other enchant
Collections.shuffle(possibleEnchantments, Misc.getRandom());
boolean enchanted = false;
int specificChance = 1;
for (Enchantment possibleEnchantment : possibleEnchantments) {
boolean conflicts = false;
for (Enchantment currentEnchantment : treasureDrop.getEnchantments().keySet()) {
conflicts = currentEnchantment.conflictsWith(possibleEnchantment);
if (conflicts) {
break;
}
}
if (!conflicts && Misc.getRandom().nextInt(specificChance) == 0) {
treasureDrop.addEnchantment(possibleEnchantment, Misc.getRandom().nextInt(possibleEnchantment.getMaxLevel()) + 1);
specificChance++;
enchanted = true;
}
}
return enchanted;
}
/**
* Gets the vanilla XP multiplier
*
* @return the vanilla XP multiplier
*/
private int getVanillaXpMultiplier() {
int skillLevel = getSkillLevel();
for (Tier tier : Tier.values()) {
if (skillLevel >= tier.getLevel()) {
return tier.getVanillaXPBoostModifier();
}
}
return 0;
}
}

View File

@ -1,46 +0,0 @@
package com.gmail.nossr50.skills.herbalism;
import org.bukkit.CropState;
import org.bukkit.block.BlockState;
import org.bukkit.material.CocoaPlant;
import org.bukkit.material.CocoaPlant.CocoaPlantSize;
/**
* Convert plants affected by the Green Terra ability.
*
* @param blockState The {@link BlockState} to check ability activation for
*/
public class GreenTerraTimer implements Runnable {
private BlockState blockState;
public GreenTerraTimer(BlockState blockState) {
this.blockState = blockState;
}
@Override
public void run() {
switch (blockState.getType()) {
case CROPS:
case CARROT:
case POTATO:
blockState.setRawData(CropState.MEDIUM.getData());
blockState.update(true);
return;
case NETHER_WARTS:
blockState.setRawData((byte) 0x2);
blockState.update(true);
return;
case COCOA:
CocoaPlant plant = (CocoaPlant) blockState.getData();
plant.setSize(CocoaPlantSize.MEDIUM);
blockState.setData(plant);
blockState.update(true);
return;
default:
return;
}
}
}

View File

@ -1,64 +0,0 @@
package com.gmail.nossr50.skills.herbalism;
import org.bukkit.block.BlockState;
import org.bukkit.material.CocoaPlant;
import org.bukkit.material.CocoaPlant.CocoaPlantSize;
/**
* Convert plants affected by the Green Thumb ability.
*
* @param blockState The {@link BlockState} to check ability activation for
* @param skillLevel The player's Herbalism skill level
*/
public class GreenThumbTimer implements Runnable {
private BlockState blockState;
private int skillLevel;
public GreenThumbTimer(BlockState blockState, int skillLevel) {
this.blockState = blockState;
this.skillLevel = skillLevel;
}
@Override
public void run() {
int greenThumbStage = Math.min(Math.min(skillLevel, Herbalism.greenThumbStageMaxLevel) / Herbalism.greenThumbStageChangeLevel, 4);
switch(blockState.getType()) {
case CROPS:
case CARROT:
case POTATO:
blockState.setRawData((byte) greenThumbStage);
blockState.update(true);
return;
case NETHER_WARTS:
if (greenThumbStage > 2) {
blockState.setRawData((byte) 0x2);
}
else if (greenThumbStage == 2) {
blockState.setRawData((byte) 0x1);
}
else {
blockState.setRawData((byte) 0x0);
}
blockState.update(true);
return;
case COCOA:
CocoaPlant plant = (CocoaPlant) blockState.getData();
if (greenThumbStage > 1) {
plant.setSize(CocoaPlantSize.MEDIUM);
}
else {
plant.setSize(CocoaPlantSize.SMALL);
}
blockState.setData(plant);
blockState.update(true);
return;
default:
return;
}
}
}

View File

@ -1,108 +1,108 @@
package com.gmail.nossr50.skills.herbalism;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.AdvancedConfig;
public class Herbalism {
public static int farmersDietRankLevel1 = AdvancedConfig.getInstance().getFarmerDietRankChange();
public static int farmersDietRankLevel2 = farmersDietRankLevel1 * 2;
public static int farmersDietMaxLevel = farmersDietRankLevel1 * 5;
public static int greenThumbStageChangeLevel = AdvancedConfig.getInstance().getGreenThumbStageChange();
public static int greenThumbStageMaxLevel = greenThumbStageChangeLevel * 4;
public static double greenThumbMaxChance = AdvancedConfig.getInstance().getGreenThumbChanceMax();
public static int greenThumbMaxLevel = AdvancedConfig.getInstance().getGreenThumbMaxLevel();
public static double doubleDropsMaxChance = AdvancedConfig.getInstance().getHerbalismDoubleDropsChanceMax();
public static int doubleDropsMaxLevel = AdvancedConfig.getInstance().getHerbalismDoubleDropsMaxLevel();
public static double hylianLuckMaxChance = AdvancedConfig.getInstance().getHylianLuckChanceMax();
public static int hylianLuckMaxLevel = AdvancedConfig.getInstance().getHylianLuckMaxLevel();
public static double shroomThumbMaxChance = AdvancedConfig.getInstance().getShroomThumbChanceMax();
public static int shroomThumbMaxLevel = AdvancedConfig.getInstance().getShroomThumbMaxLevel();
/**
* Convert blocks affected by the Green Thumb & Green Terra abilities.
*
* @param blockState The {@link BlockState} to check ability activation for
* @return true if the ability was successful, false otherwise
*/
protected static boolean convertGreenTerraBlocks(BlockState blockState) {
switch (blockState.getType()) {
case COBBLE_WALL:
case SMOOTH_BRICK:
blockState.setRawData((byte) 0x1);
return true;
case DIRT:
blockState.setType(Material.GRASS);
return true;
case COBBLESTONE:
blockState.setType(Material.MOSSY_COBBLESTONE);
return true;
default:
return false;
}
}
/**
* Calculate the drop amounts for cacti & sugar cane based on the blocks above them.
*
* @param blockState The {@link BlockState} of the bottom block of the plant
* @return the number of bonus drops to award from the blocks in this plant
*/
protected static int calculateCatciAndSugarDrops(BlockState blockState) {
Block block = blockState.getBlock();
Material blockType = blockState.getType();
int dropAmount = 0;
// Handle the original block
if (!mcMMO.placeStore.isTrue(blockState)) {
dropAmount++;
}
// Handle the two blocks above it - cacti & sugar cane can only grow 3 high naturally
for (int y = 1; y < 3; y++) {
Block relativeBlock = block.getRelative(BlockFace.UP, y);
Material relativeBlockType = relativeBlock.getType();
// If the first one is air, so is the next one
if (relativeBlockType == Material.AIR) {
break;
}
if (relativeBlockType == blockType && !mcMMO.placeStore.isTrue(relativeBlock)) {
dropAmount++;
}
}
return dropAmount;
}
/**
* Convert blocks affected by the Green Thumb & Green Terra abilities.
*
* @param blockState The {@link BlockState} to check ability activation for
* @return true if the ability was successful, false otherwise
*/
protected static boolean convertShroomThumb(BlockState blockState) {
switch (blockState.getType()){
case DIRT:
case GRASS:
blockState.setType(Material.MYCEL);
return true;
default:
return false;
}
}
}
package com.gmail.nossr50.skills.herbalism;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.AdvancedConfig;
public class Herbalism {
public static int farmersDietRankLevel1 = AdvancedConfig.getInstance().getFarmerDietRankChange();
public static int farmersDietRankLevel2 = farmersDietRankLevel1 * 2;
public static int farmersDietMaxLevel = farmersDietRankLevel1 * 5;
public static int greenThumbStageChangeLevel = AdvancedConfig.getInstance().getGreenThumbStageChange();
public static int greenThumbStageMaxLevel = greenThumbStageChangeLevel * 4;
public static int greenThumbMaxLevel = AdvancedConfig.getInstance().getGreenThumbMaxLevel();
public static double greenThumbMaxChance = AdvancedConfig.getInstance().getGreenThumbChanceMax();
public static int doubleDropsMaxLevel = AdvancedConfig.getInstance().getHerbalismDoubleDropsMaxLevel();
public static double doubleDropsMaxChance = AdvancedConfig.getInstance().getHerbalismDoubleDropsChanceMax();
public static int hylianLuckMaxLevel = AdvancedConfig.getInstance().getHylianLuckMaxLevel();
public static double hylianLuckMaxChance = AdvancedConfig.getInstance().getHylianLuckChanceMax();
public static int shroomThumbMaxLevel = AdvancedConfig.getInstance().getShroomThumbMaxLevel();
public static double shroomThumbMaxChance = AdvancedConfig.getInstance().getShroomThumbChanceMax();
/**
* Convert blocks affected by the Green Thumb & Green Terra abilities.
*
* @param blockState The {@link BlockState} to check ability activation for
* @return true if the ability was successful, false otherwise
*/
protected static boolean convertGreenTerraBlocks(BlockState blockState) {
switch (blockState.getType()) {
case COBBLE_WALL:
case SMOOTH_BRICK:
blockState.setRawData((byte) 0x1);
return true;
case DIRT:
blockState.setType(Material.GRASS);
return true;
case COBBLESTONE:
blockState.setType(Material.MOSSY_COBBLESTONE);
return true;
default:
return false;
}
}
/**
* Calculate the drop amounts for cacti & sugar cane based on the blocks above them.
*
* @param blockState The {@link BlockState} of the bottom block of the plant
* @return the number of bonus drops to award from the blocks in this plant
*/
protected static int calculateCatciAndSugarDrops(BlockState blockState) {
Block block = blockState.getBlock();
Material blockType = blockState.getType();
int dropAmount = 0;
// Handle the original block
if (!mcMMO.placeStore.isTrue(blockState)) {
dropAmount++;
}
// Handle the two blocks above it - cacti & sugar cane can only grow 3 high naturally
for (int y = 1; y < 3; y++) {
Block relativeBlock = block.getRelative(BlockFace.UP, y);
Material relativeBlockType = relativeBlock.getType();
// If the first one is air, so is the next one
if (relativeBlockType == Material.AIR) {
break;
}
if (relativeBlockType == blockType && !mcMMO.placeStore.isTrue(relativeBlock)) {
dropAmount++;
}
}
return dropAmount;
}
/**
* Convert blocks affected by the Green Thumb & Green Terra abilities.
*
* @param blockState The {@link BlockState} to check ability activation for
* @return true if the ability was successful, false otherwise
*/
protected static boolean convertShroomThumb(BlockState blockState) {
switch (blockState.getType()) {
case DIRT:
case GRASS:
blockState.setType(Material.MYCEL);
return true;
default:
return false;
}
}
}

View File

@ -1,75 +1,75 @@
package com.gmail.nossr50.skills.herbalism;
import java.util.Map;
import org.bukkit.DyeColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.skills.utilities.SkillType;
import com.gmail.nossr50.util.Permissions;
import com.google.common.collect.Maps;
public enum HerbalismBlock {
BROWN_MUSHROOM(Material.BROWN_MUSHROOM),
CACTUS(Material.CACTUS),
CARROT(Material.CARROT, Material.CARROT_ITEM),
COCOA(Material.COCOA, new ItemStack(Material.INK_SACK, 1, DyeColor.BROWN.getDyeData())),
CROPS(Material.CROPS, Material.WHEAT),
MELON_BLOCK(Material.MELON_BLOCK, Material.MELON),
NETHER_WARTS(Material.NETHER_WARTS, Material.NETHER_STALK),
POTATO(Material.POTATO, Material.POTATO_ITEM),
PUMPKIN(Material.PUMPKIN),
RED_MUSHROOM(Material.RED_MUSHROOM),
RED_ROSE(Material.RED_ROSE),
SUGAR_CANE_BLOCK(Material.SUGAR_CANE_BLOCK, Material.SUGAR_CANE),
VINE(Material.VINE),
WATER_LILY(Material.WATER_LILY),
YELLOW_FLOWER(Material.YELLOW_FLOWER);
private Material blockType;
private ItemStack dropItem;
private final static Map<Material, HerbalismBlock> BY_MATERIAL = Maps.newHashMap();
private HerbalismBlock(Material blockType) {
this(blockType, new ItemStack(blockType));
}
private HerbalismBlock(Material blockType, Material dropType) {
this(blockType, new ItemStack(dropType));
}
private HerbalismBlock(Material blockType, ItemStack dropItem) {
this.blockType = blockType;
this.dropItem = dropItem;
}
static {
for (HerbalismBlock herbalismBlock : values()) {
BY_MATERIAL.put(herbalismBlock.blockType, herbalismBlock);
}
}
public ItemStack getDropItem() {
return dropItem;
}
public int getXpGain() {
return Config.getInstance().getXp(SkillType.HERBALISM, blockType);
}
public boolean canDoubleDrop() {
return Config.getInstance().getDoubleDropsEnabled(SkillType.HERBALISM, blockType);
}
public boolean hasGreenThumbPermission(Player player) {
return Permissions.greenThumbPlant(player, blockType);
}
public static HerbalismBlock getHerbalismBlock(Material blockType) {
return BY_MATERIAL.get(blockType);
}
}
package com.gmail.nossr50.skills.herbalism;
import java.util.Map;
import org.bukkit.DyeColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.util.Permissions;
import com.google.common.collect.Maps;
public enum HerbalismBlock {
BROWN_MUSHROOM(Material.BROWN_MUSHROOM),
CACTUS(Material.CACTUS),
CARROT(Material.CARROT, Material.CARROT_ITEM),
COCOA(Material.COCOA, new ItemStack(Material.INK_SACK, 1, DyeColor.BROWN.getDyeData())),
CROPS(Material.CROPS, Material.WHEAT),
MELON_BLOCK(Material.MELON_BLOCK, Material.MELON),
NETHER_WARTS(Material.NETHER_WARTS, Material.NETHER_STALK),
POTATO(Material.POTATO, Material.POTATO_ITEM),
PUMPKIN(Material.PUMPKIN),
RED_MUSHROOM(Material.RED_MUSHROOM),
RED_ROSE(Material.RED_ROSE),
SUGAR_CANE_BLOCK(Material.SUGAR_CANE_BLOCK, Material.SUGAR_CANE),
VINE(Material.VINE),
WATER_LILY(Material.WATER_LILY),
YELLOW_FLOWER(Material.YELLOW_FLOWER);
private Material blockType;
private ItemStack dropItem;
private final static Map<Material, HerbalismBlock> BY_MATERIAL = Maps.newHashMap();
private HerbalismBlock(Material blockType) {
this(blockType, new ItemStack(blockType));
}
private HerbalismBlock(Material blockType, Material dropType) {
this(blockType, new ItemStack(dropType));
}
private HerbalismBlock(Material blockType, ItemStack dropItem) {
this.blockType = blockType;
this.dropItem = dropItem;
}
static {
for (HerbalismBlock herbalismBlock : values()) {
BY_MATERIAL.put(herbalismBlock.blockType, herbalismBlock);
}
}
public ItemStack getDropItem() {
return dropItem;
}
public int getXpGain() {
return Config.getInstance().getXp(SkillType.HERBALISM, blockType);
}
public boolean canDoubleDrop() {
return Config.getInstance().getDoubleDropsEnabled(SkillType.HERBALISM, blockType);
}
public boolean hasGreenThumbPermission(Player player) {
return Permissions.greenThumbPlant(player, blockType);
}
public static HerbalismBlock getHerbalismBlock(Material blockType) {
return BY_MATERIAL.get(blockType);
}
}

View File

@ -1,180 +0,0 @@
package com.gmail.nossr50.skills.herbalism;
import org.bukkit.Material;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.SkillCommand;
import com.gmail.nossr50.skills.utilities.SkillType;
import com.gmail.nossr50.util.Permissions;
public class HerbalismCommand extends SkillCommand {
private String greenTerraLength;
private String greenTerraLengthEndurance;
private String greenThumbChance;
private String greenThumbChanceLucky;
private String greenThumbStage;
private String farmersDietRank;
private String doubleDropChance;
private String doubleDropChanceLucky;
private String hylianLuckChance;
private String hylianLuckChanceLucky;
private String shroomThumbChance;
private String shroomThumbChanceLucky;
private boolean hasHylianLuck;
private boolean canGreenTerra;
private boolean canGreenThumbWheat;
private boolean canGreenThumbBlocks;
private boolean canFarmersDiet;
private boolean canDoubleDrop;
private boolean canShroomThumb;
private boolean doubleDropsDisabled;
public HerbalismCommand() {
super(SkillType.HERBALISM);
}
@Override
protected void dataCalculations() {
//GREEN TERRA
String[] greenTerraStrings = calculateLengthDisplayValues();
greenTerraLength = greenTerraStrings[0];
greenTerraLengthEndurance = greenTerraStrings[1];
//FARMERS DIET
farmersDietRank = calculateRank(Herbalism.farmersDietMaxLevel, Herbalism.farmersDietRankLevel1);
//GREEN THUMB
greenThumbStage = calculateRank(Herbalism.greenThumbStageMaxLevel, Herbalism.greenThumbStageChangeLevel);
String[] greenThumbStrings = calculateAbilityDisplayValues(Herbalism.greenThumbMaxLevel, Herbalism.greenThumbMaxChance);
greenThumbChance = greenThumbStrings[0];
greenThumbChanceLucky = greenThumbStrings[1];
//DOUBLE DROPS
String[] doubleDropStrings = calculateAbilityDisplayValues(Herbalism.doubleDropsMaxLevel, Herbalism.doubleDropsMaxChance);
doubleDropChance = doubleDropStrings[0];
doubleDropChanceLucky = doubleDropStrings[1];
//HYLIAN LUCK
String[] hylianLuckStrings = calculateAbilityDisplayValues(Herbalism.hylianLuckMaxLevel, Herbalism.hylianLuckMaxChance);
hylianLuckChance = hylianLuckStrings[0];
hylianLuckChanceLucky = hylianLuckStrings[1];
//SHROOM THUMB
String[] shroomThumbStrings = calculateAbilityDisplayValues(Herbalism.shroomThumbMaxLevel, Herbalism.shroomThumbMaxChance);
shroomThumbChance = shroomThumbStrings[0];
shroomThumbChanceLucky = shroomThumbStrings[1];
}
@Override
protected void permissionsCheck() {
hasHylianLuck = Permissions.hylianLuck(player);
canGreenTerra = Permissions.greenTerra(player);
canGreenThumbWheat = Permissions.greenThumbPlant(player, Material.CROPS); //TODO: This isn't really accurate - they could have perms for other crops but not wheat.
canGreenThumbBlocks = (Permissions.greenThumbBlock(player, Material.DIRT) || Permissions.greenThumbBlock(player, Material.COBBLESTONE) || Permissions.greenThumbBlock(player, Material.COBBLE_WALL) || Permissions.greenThumbBlock(player, Material.SMOOTH_BRICK));
canFarmersDiet = Permissions.farmersDiet(player);
canDoubleDrop = Permissions.doubleDrops(player, skill);
doubleDropsDisabled = skill.getDoubleDropsDisabled();
canShroomThumb = Permissions.shroomThumb(player);
}
@Override
protected boolean effectsHeaderPermissions() {
return canGreenTerra || (canDoubleDrop && !doubleDropsDisabled) || canFarmersDiet || canGreenThumbBlocks || canGreenThumbWheat || canShroomThumb;
}
@Override
protected void effectsDisplay() {
luckyEffectsDisplay();
if (canGreenTerra) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.0"), LocaleLoader.getString("Herbalism.Effect.1")));
}
if (canGreenThumbWheat) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.2"), LocaleLoader.getString("Herbalism.Effect.3")));
}
if (canGreenThumbBlocks) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.4"), LocaleLoader.getString("Herbalism.Effect.5")));
}
if (canFarmersDiet) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.6"), LocaleLoader.getString("Herbalism.Effect.7")));
}
if (hasHylianLuck) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.10"), LocaleLoader.getString("Herbalism.Effect.11")));
}
if (canShroomThumb) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.12"), LocaleLoader.getString("Herbalism.Effect.13")));
}
if (canDoubleDrop && !doubleDropsDisabled) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Herbalism.Effect.8"), LocaleLoader.getString("Herbalism.Effect.9")));
}
}
@Override
protected boolean statsHeaderPermissions() {
return canGreenTerra || (canDoubleDrop && !doubleDropsDisabled) || canFarmersDiet || canGreenThumbBlocks || canGreenThumbWheat || canShroomThumb;
}
@Override
protected void statsDisplay() {
if (canGreenTerra) {
if (hasEndurance) {
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTe.Length", greenTerraLength) + LocaleLoader.getString("Perks.activationtime.bonus", greenTerraLengthEndurance));
}
else {
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTe.Length", greenTerraLength));
}
}
if (canGreenThumbBlocks || canGreenThumbWheat) {
if (isLucky) {
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTh.Chance", greenThumbChance) + LocaleLoader.getString("Perks.lucky.bonus", greenThumbChanceLucky));
}
else {
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTh.Chance", greenThumbChance));
}
}
if (canGreenThumbWheat) {
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTh.Stage", greenThumbStage));
}
if (canFarmersDiet) {
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.FD", farmersDietRank));
}
if (hasHylianLuck) {
if (isLucky) {
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.HylianLuck", hylianLuckChance) + LocaleLoader.getString("Perks.lucky.bonus", hylianLuckChanceLucky));
}
else {
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.HylianLuck", hylianLuckChance));
}
}
if (canShroomThumb) {
if (isLucky) {
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.ShroomThumb.Chance", shroomThumbChance) + LocaleLoader.getString("Perks.lucky.bonus", shroomThumbChanceLucky));
}
else {
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.ShroomThumb.Chance", shroomThumbChance));
}
}
if (canDoubleDrop && !doubleDropsDisabled) {
if (isLucky) {
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.DoubleDropChance", doubleDropChance) + LocaleLoader.getString("Perks.lucky.bonus", doubleDropChanceLucky));
}
else {
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.DoubleDropChance", doubleDropChance));
}
}
}
}

View File

@ -1,306 +1,308 @@
package com.gmail.nossr50.skills.herbalism;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.BlockState;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.TreasuresConfig;
import com.gmail.nossr50.datatypes.McMMOPlayer;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.treasure.HylianTreasure;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mods.ModChecks;
import com.gmail.nossr50.mods.datatypes.CustomBlock;
import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.skills.utilities.AbilityType;
import com.gmail.nossr50.skills.utilities.SkillTools;
import com.gmail.nossr50.skills.utilities.SkillType;
import com.gmail.nossr50.skills.utilities.ToolType;
import com.gmail.nossr50.util.BlockChecks;
import com.gmail.nossr50.util.ItemChecks;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.Users;
public class HerbalismManager extends SkillManager {
public HerbalismManager(McMMOPlayer mcMMOPlayer) {
super(mcMMOPlayer, SkillType.HERBALISM);
}
public boolean canBlockCheck() {
return !(Config.getInstance().getHerbalismAFKDisabled() && getPlayer().isInsideVehicle());
}
public boolean canGreenThumbBlock(BlockState blockState) {
Player player = getPlayer();
return player.getItemInHand().getType() == Material.SEEDS && BlockChecks.canMakeMossy(blockState) && Permissions.greenThumbBlock(player, blockState.getType());
}
public boolean canUseShroomThumb(BlockState blockState) {
Player player = getPlayer();
Material itemType = player.getItemInHand().getType();
return (itemType == Material.RED_MUSHROOM || itemType == Material.BROWN_MUSHROOM) && BlockChecks.canMakeShroomy(blockState) && Permissions.shroomThumb(player);
}
public boolean canUseHylianLuck() {
Player player = getPlayer();
return ItemChecks.isSword(player.getItemInHand()) && Permissions.hylianLuck(player);
}
public boolean canGreenTerraBlock(BlockState blockState) {
return getProfile().getAbilityMode(AbilityType.GREEN_TERRA) && BlockChecks.canMakeMossy(blockState);
}
public boolean canActivateAbility() {
return getProfile().getToolPreparationMode(ToolType.HOE) && Permissions.greenTerra(getPlayer());
}
public boolean canGreenTerraPlant() {
return getProfile().getAbilityMode(AbilityType.GREEN_TERRA);
}
/**
* Handle the Farmer's Diet ability
*
* @param rankChange The # of levels to change rank for the food
* @param eventFoodLevel The initial change in hunger from the event
* @return the modified change in hunger for the event
*/
public int farmersDiet(int rankChange, int eventFoodLevel) {
return SkillTools.handleFoodSkills(getPlayer(), SkillType.HERBALISM, eventFoodLevel, Herbalism.farmersDietRankLevel1, Herbalism.farmersDietMaxLevel, rankChange);
}
/**
* Process the Green Terra ability.
*
* @param blockState The {@link BlockState} to check ability activation for
* @return true if the ability was successful, false otherwise
*/
public boolean processGreenTerra(BlockState blockState) {
Player player = getPlayer();
if (!Permissions.greenThumbBlock(player, blockState.getType())) {
return false;
}
PlayerInventory playerInventory = player.getInventory();
ItemStack seed = new ItemStack(Material.SEEDS);
if (!playerInventory.containsAtLeast(seed, 1)) {
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTe.NeedMore"));
return false;
}
playerInventory.removeItem(seed);
player.updateInventory(); // Needed until replacement available
return Herbalism.convertGreenTerraBlocks(blockState);
}
/**
* Process double drops & XP gain for Herbalism.
*
* @param blockState The {@link BlockState} to check ability activation for
* @return true if the ability was successful, false otherwise
*/
public void herbalismBlockCheck(BlockState blockState) {
Player player = getPlayer();
Material blockType = blockState.getType();
HerbalismBlock herbalismBlock = HerbalismBlock.getHerbalismBlock(blockType);
CustomBlock customBlock = null;
int xp = 0;
int dropAmount = 1;
ItemStack dropItem = null;
if (herbalismBlock != null) {
if (blockType == Material.CACTUS || blockType == Material.SUGAR_CANE_BLOCK) {
dropItem = herbalismBlock.getDropItem();
dropAmount = Herbalism.calculateCatciAndSugarDrops(blockState);
xp = herbalismBlock.getXpGain() * dropAmount;
}
else if (herbalismBlock.hasGreenThumbPermission(player)){
dropItem = herbalismBlock.getDropItem();
xp = herbalismBlock.getXpGain();
processGreenThumbPlants(blockState);
}
else {
if (!mcMMO.placeStore.isTrue(blockState)) {
dropItem = herbalismBlock.getDropItem();
xp = herbalismBlock.getXpGain();
}
}
}
else {
customBlock = ModChecks.getCustomBlock(blockState);
dropItem = customBlock.getItemDrop();
xp = customBlock.getXpGain();
}
if (Permissions.doubleDrops(player, skill) && SkillTools.activationSuccessful(player, skill, Herbalism.doubleDropsMaxChance, Herbalism.doubleDropsMaxLevel)) {
Location location = blockState.getLocation();
if (dropItem != null && herbalismBlock != null && herbalismBlock.canDoubleDrop()) {
Misc.dropItems(location, dropItem, dropAmount);
}
else if (customBlock != null){
int minimumDropAmount = customBlock.getMinimumDropAmount();
int maximumDropAmount = customBlock.getMaximumDropAmount();
if (minimumDropAmount != maximumDropAmount) {
Misc.randomDropItems(location, dropItem, maximumDropAmount - minimumDropAmount);
}
Misc.dropItems(location, dropItem, minimumDropAmount);
}
}
applyXpGain(xp);
}
/**
* Process the Green Thumb ability for blocks.
*
* @param blockState The {@link BlockState} to check ability activation for
* @return true if the ability was successful, false otherwise
*/
public boolean processGreenThumbBlocks(BlockState blockState) {
Player player = getPlayer();
if (!SkillTools.activationSuccessful(player, skill, Herbalism.greenThumbMaxChance, Herbalism.greenThumbMaxLevel)) {
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTh.Fail"));
return false;
}
return Herbalism.convertGreenTerraBlocks(blockState);
}
/**
* Process the Hylian Luck ability.
*
* @param blockState The {@link BlockState} to check ability activation for
* @return true if the ability was successful, false otherwise
*/
public boolean processHylianLuck(BlockState blockState) {
Player player = getPlayer();
if (!SkillTools.activationSuccessful(player, skill, Herbalism.hylianLuckMaxChance, Herbalism.hylianLuckMaxLevel)) {
return false;
}
List<HylianTreasure> treasures = new ArrayList<HylianTreasure>();
switch (blockState.getType()) {
case DEAD_BUSH:
case LONG_GRASS:
case SAPLING:
treasures = TreasuresConfig.getInstance().hylianFromBushes;
break;
case RED_ROSE:
case YELLOW_FLOWER:
if (mcMMO.placeStore.isTrue(blockState)) {
mcMMO.placeStore.setFalse(blockState);
return false;
}
treasures = TreasuresConfig.getInstance().hylianFromFlowers;
break;
case FLOWER_POT:
treasures = TreasuresConfig.getInstance().hylianFromPots;
break;
default:
return false;
}
if (treasures.isEmpty()) {
return false;
}
blockState.setRawData((byte) 0x0);
blockState.setType(Material.AIR);
Misc.dropItem(blockState.getLocation(), treasures.get(Misc.getRandom().nextInt(treasures.size())).getDrop());
player.sendMessage(LocaleLoader.getString("Herbalism.HylianLuck"));
return true;
}
/**
* Process the Shroom Thumb ability.
*
* @param blockState The {@link BlockState} to check ability activation for
* @return true if the ability was successful, false otherwise
*/
public boolean processShroomThumb(BlockState blockState) {
Player player = getPlayer();
PlayerInventory playerInventory = player.getInventory();
if (!playerInventory.contains(Material.BROWN_MUSHROOM)) {
player.sendMessage(LocaleLoader.getString("Skills.NeedMore", StringUtils.getPrettyItemString(Material.BROWN_MUSHROOM)));
return false;
}
if (!playerInventory.contains(Material.RED_MUSHROOM)) {
player.sendMessage(LocaleLoader.getString("Skills.NeedMore", StringUtils.getPrettyItemString(Material.RED_MUSHROOM)));
return false;
}
playerInventory.removeItem(new ItemStack(Material.BROWN_MUSHROOM));
playerInventory.removeItem(new ItemStack(Material.RED_MUSHROOM));
player.updateInventory();
if (!SkillTools.activationSuccessful(player, skill, Herbalism.shroomThumbMaxChance, Herbalism.shroomThumbMaxLevel)) {
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.ShroomThumb.Fail"));
return false;
}
return Herbalism.convertShroomThumb(blockState);
}
/**
* Process the Green Thumb ability for plants.
*
* @param blockState The {@link BlockState} to check ability activation for
*/
private void processGreenThumbPlants(BlockState blockState) {
Player player = getPlayer();
PlayerInventory playerInventory = player.getInventory();
ItemStack seed = HerbalismBlock.getHerbalismBlock(blockState.getType()).getDropItem();
if (!playerInventory.containsAtLeast(seed, 1)) {
return;
}
PlayerProfile playerProfile = Users.getPlayer(player).getProfile();
if (playerProfile.getAbilityMode(AbilityType.GREEN_TERRA)) {
playerInventory.removeItem(seed);
player.updateInventory(); // Needed until replacement available
mcMMO.p.getServer().getScheduler().scheduleSyncDelayedTask(mcMMO.p, new GreenTerraTimer(blockState), 0);
return;
}
else if (SkillTools.activationSuccessful(player, skill, Herbalism.greenThumbMaxChance, Herbalism.greenThumbMaxLevel)) {
playerInventory.removeItem(seed);
player.updateInventory(); // Needed until replacement available
mcMMO.p.getServer().getScheduler().scheduleSyncDelayedTask(mcMMO.p, new GreenThumbTimer(blockState, getSkillLevel()), 0);
return;
}
}
}
package com.gmail.nossr50.skills.herbalism;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.BlockState;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.treasure.TreasureConfig;
import com.gmail.nossr50.datatypes.mods.CustomBlock;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.AbilityType;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.datatypes.skills.ToolType;
import com.gmail.nossr50.datatypes.treasure.HylianTreasure;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.runnables.skills.herbalism.GreenTerraTimerTask;
import com.gmail.nossr50.runnables.skills.herbalism.GreenThumbTimerTask;
import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.util.BlockUtils;
import com.gmail.nossr50.util.ItemUtils;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.ModUtils;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.SkillUtils;
public class HerbalismManager extends SkillManager {
public HerbalismManager(McMMOPlayer mcMMOPlayer) {
super(mcMMOPlayer, SkillType.HERBALISM);
}
public boolean canBlockCheck() {
return !(Config.getInstance().getHerbalismAFKDisabled() && getPlayer().isInsideVehicle());
}
public boolean canGreenThumbBlock(BlockState blockState) {
Player player = getPlayer();
return player.getItemInHand().getType() == Material.SEEDS && BlockUtils.canMakeMossy(blockState) && Permissions.greenThumbBlock(player, blockState.getType());
}
public boolean canUseShroomThumb(BlockState blockState) {
Player player = getPlayer();
Material itemType = player.getItemInHand().getType();
return (itemType == Material.RED_MUSHROOM || itemType == Material.BROWN_MUSHROOM) && BlockUtils.canMakeShroomy(blockState) && Permissions.shroomThumb(player);
}
public boolean canUseHylianLuck() {
Player player = getPlayer();
return ItemUtils.isSword(player.getItemInHand()) && Permissions.hylianLuck(player);
}
public boolean canGreenTerraBlock(BlockState blockState) {
return getProfile().getAbilityMode(AbilityType.GREEN_TERRA) && BlockUtils.canMakeMossy(blockState);
}
public boolean canActivateAbility() {
return getProfile().getToolPreparationMode(ToolType.HOE) && Permissions.greenTerra(getPlayer());
}
public boolean canGreenTerraPlant() {
return getProfile().getAbilityMode(AbilityType.GREEN_TERRA);
}
/**
* Handle the Farmer's Diet ability
*
* @param rankChange The # of levels to change rank for the food
* @param eventFoodLevel The initial change in hunger from the event
* @return the modified change in hunger for the event
*/
public int farmersDiet(int rankChange, int eventFoodLevel) {
return SkillUtils.handleFoodSkills(getPlayer(), SkillType.HERBALISM, eventFoodLevel, Herbalism.farmersDietRankLevel1, Herbalism.farmersDietMaxLevel, rankChange);
}
/**
* Process the Green Terra ability.
*
* @param blockState The {@link BlockState} to check ability activation for
* @return true if the ability was successful, false otherwise
*/
public boolean processGreenTerra(BlockState blockState) {
Player player = getPlayer();
if (!Permissions.greenThumbBlock(player, blockState.getType())) {
return false;
}
PlayerInventory playerInventory = player.getInventory();
ItemStack seed = new ItemStack(Material.SEEDS);
if (!playerInventory.containsAtLeast(seed, 1)) {
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTe.NeedMore"));
return false;
}
playerInventory.removeItem(seed);
player.updateInventory(); // Needed until replacement available
return Herbalism.convertGreenTerraBlocks(blockState);
}
/**
* Process double drops & XP gain for Herbalism.
*
* @param blockState The {@link BlockState} to check ability activation for
* @return true if the ability was successful, false otherwise
*/
public void herbalismBlockCheck(BlockState blockState) {
Player player = getPlayer();
Material blockType = blockState.getType();
HerbalismBlock herbalismBlock = HerbalismBlock.getHerbalismBlock(blockType);
CustomBlock customBlock = null;
int xp = 0;
int dropAmount = 1;
ItemStack dropItem = null;
if (herbalismBlock != null) {
if (blockType == Material.CACTUS || blockType == Material.SUGAR_CANE_BLOCK) {
dropItem = herbalismBlock.getDropItem();
dropAmount = Herbalism.calculateCatciAndSugarDrops(blockState);
xp = herbalismBlock.getXpGain() * dropAmount;
}
else if (herbalismBlock.hasGreenThumbPermission(player)) {
dropItem = herbalismBlock.getDropItem();
xp = herbalismBlock.getXpGain();
processGreenThumbPlants(blockState);
}
else {
if (!mcMMO.placeStore.isTrue(blockState)) {
dropItem = herbalismBlock.getDropItem();
xp = herbalismBlock.getXpGain();
}
}
}
else {
customBlock = ModUtils.getCustomBlock(blockState);
dropItem = customBlock.getItemDrop();
xp = customBlock.getXpGain();
}
if (Permissions.doubleDrops(player, skill) && SkillUtils.activationSuccessful(player, skill, Herbalism.doubleDropsMaxChance, Herbalism.doubleDropsMaxLevel)) {
Location location = blockState.getLocation();
if (dropItem != null && herbalismBlock != null && herbalismBlock.canDoubleDrop()) {
Misc.dropItems(location, dropItem, dropAmount);
}
else if (customBlock != null) {
int minimumDropAmount = customBlock.getMinimumDropAmount();
int maximumDropAmount = customBlock.getMaximumDropAmount();
if (minimumDropAmount != maximumDropAmount) {
Misc.randomDropItems(location, dropItem, maximumDropAmount - minimumDropAmount);
}
Misc.dropItems(location, dropItem, minimumDropAmount);
}
}
applyXpGain(xp);
}
/**
* Process the Green Thumb ability for blocks.
*
* @param blockState The {@link BlockState} to check ability activation for
* @return true if the ability was successful, false otherwise
*/
public boolean processGreenThumbBlocks(BlockState blockState) {
Player player = getPlayer();
if (!SkillUtils.activationSuccessful(player, skill, Herbalism.greenThumbMaxChance, Herbalism.greenThumbMaxLevel)) {
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTh.Fail"));
return false;
}
return Herbalism.convertGreenTerraBlocks(blockState);
}
/**
* Process the Hylian Luck ability.
*
* @param blockState The {@link BlockState} to check ability activation for
* @return true if the ability was successful, false otherwise
*/
public boolean processHylianLuck(BlockState blockState) {
Player player = getPlayer();
if (!SkillUtils.activationSuccessful(player, skill, Herbalism.hylianLuckMaxChance, Herbalism.hylianLuckMaxLevel)) {
return false;
}
List<HylianTreasure> treasures = new ArrayList<HylianTreasure>();
switch (blockState.getType()) {
case DEAD_BUSH:
case LONG_GRASS:
case SAPLING:
treasures = TreasureConfig.getInstance().hylianFromBushes;
break;
case RED_ROSE:
case YELLOW_FLOWER:
if (mcMMO.placeStore.isTrue(blockState)) {
mcMMO.placeStore.setFalse(blockState);
return false;
}
treasures = TreasureConfig.getInstance().hylianFromFlowers;
break;
case FLOWER_POT:
treasures = TreasureConfig.getInstance().hylianFromPots;
break;
default:
return false;
}
if (treasures.isEmpty()) {
return false;
}
blockState.setRawData((byte) 0x0);
blockState.setType(Material.AIR);
Misc.dropItem(blockState.getLocation(), treasures.get(Misc.getRandom().nextInt(treasures.size())).getDrop());
player.sendMessage(LocaleLoader.getString("Herbalism.HylianLuck"));
return true;
}
/**
* Process the Shroom Thumb ability.
*
* @param blockState The {@link BlockState} to check ability activation for
* @return true if the ability was successful, false otherwise
*/
public boolean processShroomThumb(BlockState blockState) {
Player player = getPlayer();
PlayerInventory playerInventory = player.getInventory();
if (!playerInventory.contains(Material.BROWN_MUSHROOM)) {
player.sendMessage(LocaleLoader.getString("Skills.NeedMore", StringUtils.getPrettyItemString(Material.BROWN_MUSHROOM)));
return false;
}
if (!playerInventory.contains(Material.RED_MUSHROOM)) {
player.sendMessage(LocaleLoader.getString("Skills.NeedMore", StringUtils.getPrettyItemString(Material.RED_MUSHROOM)));
return false;
}
playerInventory.removeItem(new ItemStack(Material.BROWN_MUSHROOM));
playerInventory.removeItem(new ItemStack(Material.RED_MUSHROOM));
player.updateInventory();
if (!SkillUtils.activationSuccessful(player, skill, Herbalism.shroomThumbMaxChance, Herbalism.shroomThumbMaxLevel)) {
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.ShroomThumb.Fail"));
return false;
}
return Herbalism.convertShroomThumb(blockState);
}
/**
* Process the Green Thumb ability for plants.
*
* @param blockState The {@link BlockState} to check ability activation for
*/
private void processGreenThumbPlants(BlockState blockState) {
Player player = getPlayer();
PlayerInventory playerInventory = player.getInventory();
ItemStack seed = HerbalismBlock.getHerbalismBlock(blockState.getType()).getDropItem();
if (!playerInventory.containsAtLeast(seed, 1)) {
return;
}
PlayerProfile playerProfile = UserManager.getPlayer(player).getProfile();
if (playerProfile.getAbilityMode(AbilityType.GREEN_TERRA)) {
playerInventory.removeItem(seed);
player.updateInventory(); // Needed until replacement available
mcMMO.p.getServer().getScheduler().scheduleSyncDelayedTask(mcMMO.p, new GreenTerraTimerTask(blockState), 0);
return;
}
else if (SkillUtils.activationSuccessful(player, skill, Herbalism.greenThumbMaxChance, Herbalism.greenThumbMaxLevel)) {
playerInventory.removeItem(seed);
player.updateInventory(); // Needed until replacement available
mcMMO.p.getServer().getScheduler().scheduleSyncDelayedTask(mcMMO.p, new GreenThumbTimerTask(blockState, getSkillLevel()), 0);
return;
}
}
}

View File

@ -1,103 +1,103 @@
package com.gmail.nossr50.skills.mining;
import java.util.HashSet;
import org.bukkit.Material;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config;
public class BlastMining {
// The order of the values is extremely important, a few methods depend on it to work properly
protected enum Tier {
EIGHT(8) {
@Override public int getLevel() {return AdvancedConfig.getInstance().getBlastMiningRank8();}
@Override public double getBlastRadiusModifier() {return AdvancedConfig.getInstance().getBlastRadiusModifierRank8();}
@Override public double getOreBonus() {return AdvancedConfig.getInstance().getOreBonusRank8();}
@Override public double getDebrisReduction() {return AdvancedConfig.getInstance().getDebrisReductionRank8();}
@Override public double getBlastDamageDecrease() {return AdvancedConfig.getInstance().getBlastDamageDecreaseRank8();}
@Override public int getDropMultiplier() {return AdvancedConfig.getInstance().getDropMultiplierRank8();}},
SEVEN(7) {
@Override public int getLevel() {return AdvancedConfig.getInstance().getBlastMiningRank7();}
@Override public double getBlastRadiusModifier() {return AdvancedConfig.getInstance().getBlastRadiusModifierRank7();}
@Override public double getOreBonus() {return AdvancedConfig.getInstance().getOreBonusRank7();}
@Override public double getDebrisReduction() {return AdvancedConfig.getInstance().getDebrisReductionRank7();}
@Override public double getBlastDamageDecrease() {return AdvancedConfig.getInstance().getBlastDamageDecreaseRank7();}
@Override public int getDropMultiplier() {return AdvancedConfig.getInstance().getDropMultiplierRank7();}},
SIX(6) {
@Override public int getLevel() {return AdvancedConfig.getInstance().getBlastMiningRank6();}
@Override public double getBlastRadiusModifier() {return AdvancedConfig.getInstance().getBlastRadiusModifierRank6();}
@Override public double getOreBonus() {return AdvancedConfig.getInstance().getOreBonusRank6();}
@Override public double getDebrisReduction() {return AdvancedConfig.getInstance().getDebrisReductionRank6();}
@Override public double getBlastDamageDecrease() {return AdvancedConfig.getInstance().getBlastDamageDecreaseRank6();}
@Override public int getDropMultiplier() {return AdvancedConfig.getInstance().getDropMultiplierRank6();}},
FIVE(5) {
@Override public int getLevel() {return AdvancedConfig.getInstance().getBlastMiningRank5();}
@Override public double getBlastRadiusModifier() {return AdvancedConfig.getInstance().getBlastRadiusModifierRank5();}
@Override public double getOreBonus() {return AdvancedConfig.getInstance().getOreBonusRank5();}
@Override public double getDebrisReduction() {return AdvancedConfig.getInstance().getDebrisReductionRank5();}
@Override public double getBlastDamageDecrease() {return AdvancedConfig.getInstance().getBlastDamageDecreaseRank5();}
@Override public int getDropMultiplier() {return AdvancedConfig.getInstance().getDropMultiplierRank5();}},
FOUR(4) {
@Override public int getLevel() {return AdvancedConfig.getInstance().getBlastMiningRank4();}
@Override public double getBlastRadiusModifier() {return AdvancedConfig.getInstance().getBlastRadiusModifierRank4();}
@Override public double getOreBonus() {return AdvancedConfig.getInstance().getOreBonusRank4();}
@Override public double getDebrisReduction() {return AdvancedConfig.getInstance().getDebrisReductionRank4();}
@Override public double getBlastDamageDecrease() {return AdvancedConfig.getInstance().getBlastDamageDecreaseRank4();}
@Override public int getDropMultiplier() {return AdvancedConfig.getInstance().getDropMultiplierRank4();}},
THREE(3) {
@Override public int getLevel() {return AdvancedConfig.getInstance().getBlastMiningRank3();}
@Override public double getBlastRadiusModifier() {return AdvancedConfig.getInstance().getBlastRadiusModifierRank3();}
@Override public double getOreBonus() {return AdvancedConfig.getInstance().getOreBonusRank3();}
@Override public double getDebrisReduction() {return AdvancedConfig.getInstance().getDebrisReductionRank3();}
@Override public double getBlastDamageDecrease() {return AdvancedConfig.getInstance().getBlastDamageDecreaseRank3();}
@Override public int getDropMultiplier() {return AdvancedConfig.getInstance().getDropMultiplierRank3();}},
TWO(2) {
@Override public int getLevel() {return AdvancedConfig.getInstance().getBlastMiningRank2();}
@Override public double getBlastRadiusModifier() {return AdvancedConfig.getInstance().getBlastRadiusModifierRank2();}
@Override public double getOreBonus() {return AdvancedConfig.getInstance().getOreBonusRank2();}
@Override public double getDebrisReduction() {return AdvancedConfig.getInstance().getDebrisReductionRank2();}
@Override public double getBlastDamageDecrease() {return AdvancedConfig.getInstance().getBlastDamageDecreaseRank2();}
@Override public int getDropMultiplier() {return AdvancedConfig.getInstance().getDropMultiplierRank2();}},
ONE(1) {
@Override public int getLevel() {return AdvancedConfig.getInstance().getBlastMiningRank1();}
@Override public double getBlastRadiusModifier() {return AdvancedConfig.getInstance().getBlastRadiusModifierRank1();}
@Override public double getOreBonus() {return AdvancedConfig.getInstance().getOreBonusRank1();}
@Override public double getDebrisReduction() {return AdvancedConfig.getInstance().getDebrisReductionRank1();}
@Override public double getBlastDamageDecrease() {return AdvancedConfig.getInstance().getBlastDamageDecreaseRank1();}
@Override public int getDropMultiplier() {return AdvancedConfig.getInstance().getDropMultiplierRank1();}};
int numerical;
private Tier(int numerical) {
this.numerical = numerical;
}
public int toNumerical() {
return numerical;
}
abstract protected int getLevel();
abstract protected double getBlastRadiusModifier();
abstract protected double getOreBonus();
abstract protected double getDebrisReduction();
abstract protected double getBlastDamageDecrease();
abstract protected int getDropMultiplier();
}
public static int detonatorID = Config.getInstance().getDetonatorItemID();
public final static int MAXIMUM_REMOTE_DETONATION_DISTANCE = 100;
protected static HashSet<Byte> generateTransparentBlockList() {
HashSet<Byte> transparentBlocks = new HashSet<Byte>();
for (Material material : Material.values()) {
if (material.isTransparent()) {
transparentBlocks.add((byte) material.getId());
}
}
return transparentBlocks;
}
}
package com.gmail.nossr50.skills.mining;
import java.util.HashSet;
import org.bukkit.Material;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config;
public class BlastMining {
// The order of the values is extremely important, a few methods depend on it to work properly
protected enum Tier {
EIGHT(8) {
@Override public int getLevel() { return AdvancedConfig.getInstance().getBlastMiningRank8(); }
@Override public double getBlastRadiusModifier() { return AdvancedConfig.getInstance().getBlastRadiusModifierRank8(); }
@Override public double getOreBonus() { return AdvancedConfig.getInstance().getOreBonusRank8(); }
@Override public double getDebrisReduction() { return AdvancedConfig.getInstance().getDebrisReductionRank8(); }
@Override public double getBlastDamageDecrease() { return AdvancedConfig.getInstance().getBlastDamageDecreaseRank8(); }
@Override public int getDropMultiplier() { return AdvancedConfig.getInstance().getDropMultiplierRank8(); }},
SEVEN(7) {
@Override public int getLevel() { return AdvancedConfig.getInstance().getBlastMiningRank7(); }
@Override public double getBlastRadiusModifier() { return AdvancedConfig.getInstance().getBlastRadiusModifierRank7(); }
@Override public double getOreBonus() { return AdvancedConfig.getInstance().getOreBonusRank7(); }
@Override public double getDebrisReduction() { return AdvancedConfig.getInstance().getDebrisReductionRank7(); }
@Override public double getBlastDamageDecrease() { return AdvancedConfig.getInstance().getBlastDamageDecreaseRank7(); }
@Override public int getDropMultiplier() { return AdvancedConfig.getInstance().getDropMultiplierRank7(); }},
SIX(6) {
@Override public int getLevel() { return AdvancedConfig.getInstance().getBlastMiningRank6(); }
@Override public double getBlastRadiusModifier() { return AdvancedConfig.getInstance().getBlastRadiusModifierRank6(); }
@Override public double getOreBonus() { return AdvancedConfig.getInstance().getOreBonusRank6(); }
@Override public double getDebrisReduction() { return AdvancedConfig.getInstance().getDebrisReductionRank6(); }
@Override public double getBlastDamageDecrease() { return AdvancedConfig.getInstance().getBlastDamageDecreaseRank6(); }
@Override public int getDropMultiplier() { return AdvancedConfig.getInstance().getDropMultiplierRank6(); }},
FIVE(5) {
@Override public int getLevel() { return AdvancedConfig.getInstance().getBlastMiningRank5(); }
@Override public double getBlastRadiusModifier() { return AdvancedConfig.getInstance().getBlastRadiusModifierRank5(); }
@Override public double getOreBonus() { return AdvancedConfig.getInstance().getOreBonusRank5(); }
@Override public double getDebrisReduction() { return AdvancedConfig.getInstance().getDebrisReductionRank5(); }
@Override public double getBlastDamageDecrease() { return AdvancedConfig.getInstance().getBlastDamageDecreaseRank5(); }
@Override public int getDropMultiplier() { return AdvancedConfig.getInstance().getDropMultiplierRank5(); }},
FOUR(4) {
@Override public int getLevel() { return AdvancedConfig.getInstance().getBlastMiningRank4(); }
@Override public double getBlastRadiusModifier() { return AdvancedConfig.getInstance().getBlastRadiusModifierRank4(); }
@Override public double getOreBonus() { return AdvancedConfig.getInstance().getOreBonusRank4(); }
@Override public double getDebrisReduction() { return AdvancedConfig.getInstance().getDebrisReductionRank4(); }
@Override public double getBlastDamageDecrease() { return AdvancedConfig.getInstance().getBlastDamageDecreaseRank4(); }
@Override public int getDropMultiplier() { return AdvancedConfig.getInstance().getDropMultiplierRank4(); }},
THREE(3) {
@Override public int getLevel() { return AdvancedConfig.getInstance().getBlastMiningRank3(); }
@Override public double getBlastRadiusModifier() { return AdvancedConfig.getInstance().getBlastRadiusModifierRank3(); }
@Override public double getOreBonus() { return AdvancedConfig.getInstance().getOreBonusRank3(); }
@Override public double getDebrisReduction() { return AdvancedConfig.getInstance().getDebrisReductionRank3(); }
@Override public double getBlastDamageDecrease() { return AdvancedConfig.getInstance().getBlastDamageDecreaseRank3(); }
@Override public int getDropMultiplier() { return AdvancedConfig.getInstance().getDropMultiplierRank3(); }},
TWO(2) {
@Override public int getLevel() { return AdvancedConfig.getInstance().getBlastMiningRank2(); }
@Override public double getBlastRadiusModifier() { return AdvancedConfig.getInstance().getBlastRadiusModifierRank2(); }
@Override public double getOreBonus() { return AdvancedConfig.getInstance().getOreBonusRank2(); }
@Override public double getDebrisReduction() { return AdvancedConfig.getInstance().getDebrisReductionRank2(); }
@Override public double getBlastDamageDecrease() { return AdvancedConfig.getInstance().getBlastDamageDecreaseRank2(); }
@Override public int getDropMultiplier() { return AdvancedConfig.getInstance().getDropMultiplierRank2(); }},
ONE(1) {
@Override public int getLevel() { return AdvancedConfig.getInstance().getBlastMiningRank1(); }
@Override public double getBlastRadiusModifier() { return AdvancedConfig.getInstance().getBlastRadiusModifierRank1(); }
@Override public double getOreBonus() { return AdvancedConfig.getInstance().getOreBonusRank1(); }
@Override public double getDebrisReduction() { return AdvancedConfig.getInstance().getDebrisReductionRank1(); }
@Override public double getBlastDamageDecrease() { return AdvancedConfig.getInstance().getBlastDamageDecreaseRank1(); }
@Override public int getDropMultiplier() { return AdvancedConfig.getInstance().getDropMultiplierRank1(); }};
int numerical;
private Tier(int numerical) {
this.numerical = numerical;
}
public int toNumerical() {
return numerical;
}
abstract protected int getLevel();
abstract protected double getBlastRadiusModifier();
abstract protected double getOreBonus();
abstract protected double getDebrisReduction();
abstract protected double getBlastDamageDecrease();
abstract protected int getDropMultiplier();
}
public static int detonatorID = Config.getInstance().getDetonatorItemID();
public final static int MAXIMUM_REMOTE_DETONATION_DISTANCE = 100;
protected static HashSet<Byte> generateTransparentBlockList() {
HashSet<Byte> transparentBlocks = new HashSet<Byte>();
for (Material material : Material.values()) {
if (material.isTransparent()) {
transparentBlocks.add((byte) material.getId());
}
}
return transparentBlocks;
}
}

View File

@ -1,148 +1,146 @@
package com.gmail.nossr50.skills.mining;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.BlockState;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.mods.ModChecks;
import com.gmail.nossr50.mods.datatypes.CustomBlock;
import com.gmail.nossr50.skills.utilities.SkillType;
import com.gmail.nossr50.util.Misc;
public class Mining {
private static AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
public static int doubleDropsMaxLevel = advancedConfig.getMiningDoubleDropMaxLevel();
public static double doubleDropsMaxChance = advancedConfig.getMiningDoubleDropChance();
/**
* Calculate XP gain for Mining.
*
* @param blockState The {@link BlockState} to check ability activation for
*/
protected static int getBlockXp(BlockState blockState) {
Material blockType = blockState.getType();
int xp = Config.getInstance().getXp(SkillType.MINING, blockType);
if (blockType == Material.GLOWING_REDSTONE_ORE) {
xp = Config.getInstance().getXp(SkillType.MINING, Material.REDSTONE_ORE);
}
else if (xp == 0 && ModChecks.isCustomMiningBlock(blockState)) {
xp = ModChecks.getCustomBlock(blockState).getXpGain();
}
return xp;
}
/**
* Handle double drops when using Silk Touch.
*
* @param blockState The {@link BlockState} to check ability activation for
*/
protected static void handleSilkTouchDrops(BlockState blockState) {
Material blockType = blockState.getType();
if (blockType != Material.GLOWING_REDSTONE_ORE && !Config.getInstance().getDoubleDropsEnabled(SkillType.MINING, blockType)) {
return;
}
switch (blockType) {
case ENDER_STONE:
case GOLD_ORE:
case IRON_ORE:
case MOSSY_COBBLESTONE:
case NETHERRACK:
case OBSIDIAN:
case SANDSTONE:
handleMiningDrops(blockState);
return;
case GLOWING_REDSTONE_ORE:
if (Config.getInstance().getDoubleDropsEnabled(SkillType.MINING, Material.REDSTONE_ORE)) {
Misc.dropItem(blockState.getLocation(), new ItemStack(Material.REDSTONE_ORE));
}
return;
case COAL_ORE:
case DIAMOND_ORE:
case REDSTONE_ORE:
case GLOWSTONE:
case LAPIS_ORE:
case STONE:
case EMERALD_ORE:
Misc.dropItem(blockState.getLocation(), new ItemStack(blockType));
return;
default:
if (ModChecks.isCustomMiningBlock(blockState)) {
Misc.dropItem(blockState.getLocation(), blockState.getData().toItemStack());
}
return;
}
}
/**
* Handle double drops from Mining & Blast Mining.
*
* @param blockState The {@link BlockState} to check ability activation for
*/
protected static void handleMiningDrops(BlockState blockState) {
Material blockType = blockState.getType();
if (blockType != Material.GLOWING_REDSTONE_ORE && !Config.getInstance().getDoubleDropsEnabled(SkillType.MINING, blockType)) {
return;
}
Location location = blockState.getLocation();
ItemStack dropItem;
switch (blockType) {
case COAL_ORE:
case DIAMOND_ORE:
case EMERALD_ORE:
case GLOWSTONE:
case LAPIS_ORE:
case STONE:
case ENDER_STONE:
case GOLD_ORE:
case IRON_ORE:
case MOSSY_COBBLESTONE:
case NETHERRACK:
case OBSIDIAN:
case SANDSTONE:
for (ItemStack drop : blockState.getBlock().getDrops()) {
Misc.dropItem(location, drop);
}
return;
case GLOWING_REDSTONE_ORE:
case REDSTONE_ORE:
if (Config.getInstance().getDoubleDropsEnabled(SkillType.MINING, Material.REDSTONE_ORE)) {
for (ItemStack drop : blockState.getBlock().getDrops()) {
Misc.dropItem(location, drop);
}
}
return;
default:
if (ModChecks.isCustomMiningBlock(blockState)) {
CustomBlock customBlock = ModChecks.getCustomBlock(blockState);
int minimumDropAmount = customBlock.getMinimumDropAmount();
int maximumDropAmount = customBlock.getMaximumDropAmount();
dropItem = customBlock.getItemDrop();
if (minimumDropAmount != maximumDropAmount) {
Misc.dropItems(location, dropItem, minimumDropAmount);
Misc.randomDropItems(location, dropItem, maximumDropAmount - minimumDropAmount);
}
else {
Misc.dropItems(location, dropItem, minimumDropAmount);
}
}
return;
}
}
}
package com.gmail.nossr50.skills.mining;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.BlockState;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.mods.CustomBlock;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.ModUtils;
public class Mining {
public static int doubleDropsMaxLevel = AdvancedConfig.getInstance().getMiningDoubleDropMaxLevel();
public static double doubleDropsMaxChance = AdvancedConfig.getInstance().getMiningDoubleDropChance();
/**
* Calculate XP gain for Mining.
*
* @param blockState The {@link BlockState} to check ability activation for
*/
protected static int getBlockXp(BlockState blockState) {
Material blockType = blockState.getType();
int xp = Config.getInstance().getXp(SkillType.MINING, blockType);
if (blockType == Material.GLOWING_REDSTONE_ORE) {
xp = Config.getInstance().getXp(SkillType.MINING, Material.REDSTONE_ORE);
}
else if (xp == 0 && ModUtils.isCustomMiningBlock(blockState)) {
xp = ModUtils.getCustomBlock(blockState).getXpGain();
}
return xp;
}
/**
* Handle double drops when using Silk Touch.
*
* @param blockState The {@link BlockState} to check ability activation for
*/
protected static void handleSilkTouchDrops(BlockState blockState) {
Material blockType = blockState.getType();
if (blockType != Material.GLOWING_REDSTONE_ORE && !Config.getInstance().getDoubleDropsEnabled(SkillType.MINING, blockType)) {
return;
}
switch (blockType) {
case ENDER_STONE:
case GOLD_ORE:
case IRON_ORE:
case MOSSY_COBBLESTONE:
case NETHERRACK:
case OBSIDIAN:
case SANDSTONE:
handleMiningDrops(blockState);
return;
case GLOWING_REDSTONE_ORE:
if (Config.getInstance().getDoubleDropsEnabled(SkillType.MINING, Material.REDSTONE_ORE)) {
Misc.dropItem(blockState.getLocation(), new ItemStack(Material.REDSTONE_ORE));
}
return;
case COAL_ORE:
case DIAMOND_ORE:
case REDSTONE_ORE:
case GLOWSTONE:
case LAPIS_ORE:
case STONE:
case EMERALD_ORE:
Misc.dropItem(blockState.getLocation(), new ItemStack(blockType));
return;
default:
if (ModUtils.isCustomMiningBlock(blockState)) {
Misc.dropItem(blockState.getLocation(), blockState.getData().toItemStack());
}
return;
}
}
/**
* Handle double drops from Mining & Blast Mining.
*
* @param blockState The {@link BlockState} to check ability activation for
*/
protected static void handleMiningDrops(BlockState blockState) {
Material blockType = blockState.getType();
if (blockType != Material.GLOWING_REDSTONE_ORE && !Config.getInstance().getDoubleDropsEnabled(SkillType.MINING, blockType)) {
return;
}
Location location = blockState.getLocation();
ItemStack dropItem;
switch (blockType) {
case COAL_ORE:
case DIAMOND_ORE:
case EMERALD_ORE:
case GLOWSTONE:
case LAPIS_ORE:
case STONE:
case ENDER_STONE:
case GOLD_ORE:
case IRON_ORE:
case MOSSY_COBBLESTONE:
case NETHERRACK:
case OBSIDIAN:
case SANDSTONE:
for (ItemStack drop : blockState.getBlock().getDrops()) {
Misc.dropItem(location, drop);
}
return;
case GLOWING_REDSTONE_ORE:
case REDSTONE_ORE:
if (Config.getInstance().getDoubleDropsEnabled(SkillType.MINING, Material.REDSTONE_ORE)) {
for (ItemStack drop : blockState.getBlock().getDrops()) {
Misc.dropItem(location, drop);
}
}
return;
default:
if (ModUtils.isCustomMiningBlock(blockState)) {
CustomBlock customBlock = ModUtils.getCustomBlock(blockState);
int minimumDropAmount = customBlock.getMinimumDropAmount();
int maximumDropAmount = customBlock.getMaximumDropAmount();
dropItem = customBlock.getItemDrop();
if (minimumDropAmount != maximumDropAmount) {
Misc.dropItems(location, dropItem, minimumDropAmount);
Misc.randomDropItems(location, dropItem, maximumDropAmount - minimumDropAmount);
}
else {
Misc.dropItems(location, dropItem, minimumDropAmount);
}
}
return;
}
}
}

View File

@ -1,148 +0,0 @@
package com.gmail.nossr50.skills.mining;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.SkillCommand;
import com.gmail.nossr50.skills.SkillManagerStore;
import com.gmail.nossr50.skills.utilities.SkillType;
import com.gmail.nossr50.util.Permissions;
public class MiningCommand extends SkillCommand {
private String doubleDropChance;
private String doubleDropChanceLucky;
private String superBreakerLength;
private String superBreakerLengthEndurance;
private int blastMiningRank;
private int bonusTNTDrops;
private double blastRadiusIncrease;
private String oreBonus;
private String debrisReduction;
private String blastDamageDecrease;
private boolean canSuperBreaker;
private boolean canDoubleDrop;
private boolean canBlast;
private boolean canBiggerBombs;
private boolean canDemoExpert;
private boolean doubleDropsDisabled;
public MiningCommand() {
super(SkillType.MINING);
}
@Override
protected void dataCalculations() {
//SUPER BREAKER
String[] superBreakerStrings = calculateLengthDisplayValues();
superBreakerLength = superBreakerStrings[0];
superBreakerLengthEndurance = superBreakerStrings[1];
//DOUBLE DROPS
String[] doubleDropStrings = calculateAbilityDisplayValues(Mining.doubleDropsMaxLevel, Mining.doubleDropsMaxChance);
doubleDropChance = doubleDropStrings[0];
doubleDropChanceLucky = doubleDropStrings[1];
//BLAST MINING
MiningManager miningManager = SkillManagerStore.getInstance().getMiningManager(player.getName());
blastMiningRank = miningManager.getBlastMiningTier();
bonusTNTDrops = miningManager.getDropMultiplier();
oreBonus = percent.format(miningManager.getOreBonus() / 30.0D); // Base received in TNT is 30%
debrisReduction = percent.format(miningManager.getDebrisReduction() / 30.0D); // Base received in TNT is 30%
blastDamageDecrease = percent.format(miningManager.getBlastDamageModifier() / 100.0D);
blastRadiusIncrease = miningManager.getBlastRadiusModifier();
}
@Override
protected void permissionsCheck() {
canBiggerBombs = Permissions.biggerBombs(player);
canBlast = Permissions.remoteDetonation(player);
canDemoExpert = Permissions.demolitionsExpertise(player);
canDoubleDrop = Permissions.doubleDrops(player, skill);
canSuperBreaker = Permissions.superBreaker(player);
doubleDropsDisabled = skill.getDoubleDropsDisabled();
}
@Override
protected boolean effectsHeaderPermissions() {
return canBiggerBombs || canBlast || canDemoExpert || (canDoubleDrop && !doubleDropsDisabled) || canSuperBreaker;
}
@Override
protected void effectsDisplay() {
luckyEffectsDisplay();
if (canSuperBreaker) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Mining.Effect.0"), LocaleLoader.getString("Mining.Effect.1")));
}
if (canDoubleDrop && !doubleDropsDisabled) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Mining.Effect.2"), LocaleLoader.getString("Mining.Effect.3")));
}
if (canBlast) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Mining.Effect.4"), LocaleLoader.getString("Mining.Effect.5")));
}
if (canBiggerBombs) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Mining.Effect.6"), LocaleLoader.getString("Mining.Effect.7")));
}
if (canDemoExpert) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Mining.Effect.8"), LocaleLoader.getString("Mining.Effect.9")));
}
}
@Override
protected boolean statsHeaderPermissions() {
return canBiggerBombs || canBlast || canDemoExpert || (canDoubleDrop && !doubleDropsDisabled) || canSuperBreaker;
}
@Override
protected void statsDisplay() {
if (canDoubleDrop && !doubleDropsDisabled) {
if (isLucky) {
player.sendMessage(LocaleLoader.getString("Mining.Effect.DropChance", doubleDropChance) + LocaleLoader.getString("Perks.lucky.bonus", doubleDropChanceLucky));
}
else {
player.sendMessage(LocaleLoader.getString("Mining.Effect.DropChance", doubleDropChance));
}
}
if (canSuperBreaker) {
if (hasEndurance) {
player.sendMessage(LocaleLoader.getString("Mining.Ability.Length", superBreakerLength) + LocaleLoader.getString("Perks.activationtime.bonus", superBreakerLengthEndurance));
}
else {
player.sendMessage(LocaleLoader.getString("Mining.Ability.Length", superBreakerLength));
}
}
if (canBlast) {
if (skillValue < AdvancedConfig.getInstance().getBlastMiningRank1()) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Mining.Ability.Locked.0", AdvancedConfig.getInstance().getBlastMiningRank1())));
}
else {
player.sendMessage(LocaleLoader.getString("Mining.Blast.Rank", blastMiningRank, LocaleLoader.getString("Mining.Blast.Effect", oreBonus, debrisReduction, bonusTNTDrops)));
}
}
if (canBiggerBombs) {
if (skillValue < AdvancedConfig.getInstance().getBlastMiningRank2()) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Mining.Ability.Locked.1", AdvancedConfig.getInstance().getBlastMiningRank2())));
}
else {
player.sendMessage(LocaleLoader.getString("Mining.Blast.Radius.Increase", blastRadiusIncrease));
}
}
if (canDemoExpert) {
if (skillValue < AdvancedConfig.getInstance().getBlastMiningRank4()) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Mining.Ability.Locked.2", AdvancedConfig.getInstance().getBlastMiningRank4())));
}
else {
player.sendMessage(LocaleLoader.getString("Mining.Effect.Decrease", blastDamageDecrease));
}
}
}
}

View File

@ -1,288 +1,288 @@
package com.gmail.nossr50.skills.mining;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.entity.TNTPrimed;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.McMMOPlayer;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.skills.mining.BlastMining.Tier;
import com.gmail.nossr50.skills.utilities.AbilityType;
import com.gmail.nossr50.skills.utilities.SkillTools;
import com.gmail.nossr50.skills.utilities.SkillType;
import com.gmail.nossr50.util.BlockChecks;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
public class MiningManager extends SkillManager{
public MiningManager (McMMOPlayer mcMMOPlayer) {
super(mcMMOPlayer, SkillType.MINING);
}
public boolean canUseDemolitionsExpertise() {
Player player = getPlayer();
return SkillTools.unlockLevelReached(player, skill, BlastMining.Tier.FOUR.getLevel()) && Permissions.demolitionsExpertise(player);
}
public boolean canDetonate() {
Player player = getPlayer();
return player.isSneaking() && player.getItemInHand().getTypeId() == BlastMining.detonatorID && Permissions.remoteDetonation(player) && SkillTools.unlockLevelReached(player, skill, BlastMining.Tier.ONE.getLevel());
}
public boolean canUseBlastMining() {
return SkillTools.unlockLevelReached(getPlayer(), skill, BlastMining.Tier.ONE.getLevel());
}
public boolean canUseBiggerBombs() {
Player player = getPlayer();
return Permissions.biggerBombs(player) && SkillTools.unlockLevelReached(getPlayer(), skill, BlastMining.Tier.TWO.getLevel());
}
/**
* Process double drops & XP gain for Mining.
*
* @param blockState The {@link BlockState} to check ability activation for
* @param player The {@link Player} using this ability
*/
public void miningBlockCheck(BlockState blockState) {
Player player = getPlayer();
int xp = Mining.getBlockXp(blockState);
if (Permissions.doubleDrops(player, skill) && SkillTools.activationSuccessful(player, skill, Mining.doubleDropsMaxChance, Mining.doubleDropsMaxLevel)) {
if (player.getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH)) {
Mining.handleSilkTouchDrops(blockState);
}
else {
Mining.handleMiningDrops(blockState);
}
}
applyXpGain(xp);
}
/**
* Detonate TNT for Blast Mining
*/
public void remoteDetonation() {
Player player = getPlayer();
HashSet<Byte> transparentBlocks = BlastMining.generateTransparentBlockList();
Block targetBlock = player.getTargetBlock(transparentBlocks, BlastMining.MAXIMUM_REMOTE_DETONATION_DISTANCE);
if (targetBlock.getType() != Material.TNT || !SkillTools.blockBreakSimulate(targetBlock, player, true) || !blastMiningCooldownOver()) {
return;
}
PlayerProfile profile = getProfile();
TNTPrimed tnt = player.getWorld().spawn(targetBlock.getLocation(), TNTPrimed.class);
SkillTools.sendSkillMessage(player, AbilityType.BLAST_MINING.getAbilityPlayer(player));
player.sendMessage(LocaleLoader.getString("Mining.Blast.Boom"));
mcMMO.p.addToTNTTracker(tnt.getEntityId(), player.getName());
tnt.setFuseTicks(0);
targetBlock.setData((byte) 0x0);
targetBlock.setType(Material.AIR);
profile.setSkillDATS(AbilityType.BLAST_MINING, System.currentTimeMillis());
profile.setAbilityInformed(AbilityType.BLAST_MINING, false);
}
/**
* Handler for explosion drops and XP gain.
*
* @param event Event whose explosion is being processed
*/
public void blastMiningDropProcessing(float yield, List<Block> blockList) {
List<BlockState> ores = new ArrayList<BlockState>();
List<BlockState> debris = new ArrayList<BlockState>();
int xp = 0;
float oreBonus = (float) (getOreBonus() / 100);
float debrisReduction = (float) (getDebrisReduction() / 100);
int dropMultiplier = getDropMultiplier();
float debrisYield = yield - debrisReduction;
for (Block block : blockList) {
BlockState blockState = block.getState();
if (BlockChecks.isOre(blockState)) {
ores.add(blockState);
}
else {
debris.add(blockState);
}
}
for (BlockState blockState : ores) {
if (Misc.getRandom().nextFloat() < (yield + oreBonus)) {
if (!mcMMO.placeStore.isTrue(blockState)) {
xp += Mining.getBlockXp(blockState);
}
Misc.dropItem(blockState.getLocation(), blockState.getData().toItemStack()); // Initial block that would have been dropped
if (!mcMMO.placeStore.isTrue(blockState)) {
for (int i = 1 ; i < dropMultiplier ; i++) {
xp += Mining.getBlockXp(blockState);
Mining.handleSilkTouchDrops(blockState); // Bonus drops - should drop the block & not the items
}
}
}
}
if (debrisYield > 0) {
for (BlockState blockState : debris) {
if (Misc.getRandom().nextFloat() < debrisYield) {
Misc.dropItem(blockState.getLocation(), blockState.getData().toItemStack());
}
}
}
applyXpGain(xp);
}
/**
* Increases the blast radius of the explosion.
*
* @param event Event whose explosion radius is being changed
*/
public float biggerBombs(float radius) {
return (float) (radius + getBlastRadiusModifier());
}
public int processDemolitionsExpertise(int damage) {
return (int) (damage * (100.0 - getBlastDamageModifier()));
}
private boolean blastMiningCooldownOver() {
Player player = getPlayer();
PlayerProfile profile = getProfile();
long oldTime = profile.getSkillDATS(AbilityType.BLAST_MINING) * Misc.TIME_CONVERSION_FACTOR;
int cooldown = AbilityType.BLAST_MINING.getCooldown();
if (!SkillTools.cooldownOver(oldTime, cooldown, player)) {
player.sendMessage(LocaleLoader.getString("Skills.TooTired", SkillTools.calculateTimeLeft(oldTime, cooldown, player)));
return false;
}
return true;
}
/**
* Gets the Blast Mining tier
*
* @return the Blast Mining tier
*/
public int getBlastMiningTier() {
int skillLevel = getSkillLevel();
for (Tier tier : Tier.values()) {
if (skillLevel >= tier.getLevel()) {
return tier.toNumerical();
}
}
return 0;
}
/**
* Gets the Blast Mining tier
*
* @return the Blast Mining tier
*/
public double getOreBonus() {
int skillLevel = getSkillLevel();
for (Tier tier : Tier.values()) {
if (skillLevel >= tier.getLevel()) {
return tier.getOreBonus();
}
}
return 0;
}
/**
* Gets the Blast Mining tier
*
* @return the Blast Mining tier
*/
public double getDebrisReduction() {
int skillLevel = getSkillLevel();
for (Tier tier : Tier.values()) {
if (skillLevel >= tier.getLevel()) {
return tier.getDebrisReduction();
}
}
return 0;
}
/**
* Gets the Blast Mining tier
*
* @return the Blast Mining tier
*/
public int getDropMultiplier() {
int skillLevel = getSkillLevel();
for (Tier tier : Tier.values()) {
if (skillLevel >= tier.getLevel()) {
return tier.getDropMultiplier();
}
}
return 0;
}
/**
* Gets the Blast Mining tier
*
* @return the Blast Mining tier
*/
public double getBlastRadiusModifier() {
int skillLevel = getSkillLevel();
for (Tier tier : Tier.values()) {
if (skillLevel >= tier.getLevel()) {
return tier.getBlastRadiusModifier();
}
}
return 0;
}
/**
* Gets the Blast Mining tier
*
* @return the Blast Mining tier
*/
public double getBlastDamageModifier() {
int skillLevel = getSkillLevel();
for (Tier tier : Tier.values()) {
if (skillLevel >= tier.getLevel()) {
return tier.getBlastDamageDecrease();
}
}
return 0;
}
}
package com.gmail.nossr50.skills.mining;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.entity.TNTPrimed;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.AbilityType;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.skills.mining.BlastMining.Tier;
import com.gmail.nossr50.util.BlockUtils;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.skills.SkillUtils;
public class MiningManager extends SkillManager{
public MiningManager(McMMOPlayer mcMMOPlayer) {
super(mcMMOPlayer, SkillType.MINING);
}
public boolean canUseDemolitionsExpertise() {
Player player = getPlayer();
return SkillUtils.unlockLevelReached(player, skill, BlastMining.Tier.FOUR.getLevel()) && Permissions.demolitionsExpertise(player);
}
public boolean canDetonate() {
Player player = getPlayer();
return player.isSneaking() && player.getItemInHand().getTypeId() == BlastMining.detonatorID && Permissions.remoteDetonation(player) && SkillUtils.unlockLevelReached(player, skill, BlastMining.Tier.ONE.getLevel());
}
public boolean canUseBlastMining() {
return SkillUtils.unlockLevelReached(getPlayer(), skill, BlastMining.Tier.ONE.getLevel());
}
public boolean canUseBiggerBombs() {
Player player = getPlayer();
return Permissions.biggerBombs(player) && SkillUtils.unlockLevelReached(getPlayer(), skill, BlastMining.Tier.TWO.getLevel());
}
/**
* Process double drops & XP gain for Mining.
*
* @param blockState The {@link BlockState} to check ability activation for
* @param player The {@link Player} using this ability
*/
public void miningBlockCheck(BlockState blockState) {
Player player = getPlayer();
int xp = Mining.getBlockXp(blockState);
if (Permissions.doubleDrops(player, skill) && SkillUtils.activationSuccessful(player, skill, Mining.doubleDropsMaxChance, Mining.doubleDropsMaxLevel)) {
if (player.getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH)) {
Mining.handleSilkTouchDrops(blockState);
}
else {
Mining.handleMiningDrops(blockState);
}
}
applyXpGain(xp);
}
/**
* Detonate TNT for Blast Mining
*/
public void remoteDetonation() {
Player player = getPlayer();
HashSet<Byte> transparentBlocks = BlastMining.generateTransparentBlockList();
Block targetBlock = player.getTargetBlock(transparentBlocks, BlastMining.MAXIMUM_REMOTE_DETONATION_DISTANCE);
if (targetBlock.getType() != Material.TNT || !SkillUtils.blockBreakSimulate(targetBlock, player, true) || !blastMiningCooldownOver()) {
return;
}
PlayerProfile profile = getProfile();
TNTPrimed tnt = player.getWorld().spawn(targetBlock.getLocation(), TNTPrimed.class);
SkillUtils.sendSkillMessage(player, AbilityType.BLAST_MINING.getAbilityPlayer(player));
player.sendMessage(LocaleLoader.getString("Mining.Blast.Boom"));
mcMMO.p.addToTNTTracker(tnt.getEntityId(), player.getName());
tnt.setFuseTicks(0);
targetBlock.setData((byte) 0x0);
targetBlock.setType(Material.AIR);
profile.setSkillDATS(AbilityType.BLAST_MINING, System.currentTimeMillis());
profile.setAbilityInformed(AbilityType.BLAST_MINING, false);
}
/**
* Handler for explosion drops and XP gain.
*
* @param event Event whose explosion is being processed
*/
public void blastMiningDropProcessing(float yield, List<Block> blockList) {
List<BlockState> ores = new ArrayList<BlockState>();
List<BlockState> debris = new ArrayList<BlockState>();
int xp = 0;
float oreBonus = (float) (getOreBonus() / 100);
float debrisReduction = (float) (getDebrisReduction() / 100);
int dropMultiplier = getDropMultiplier();
float debrisYield = yield - debrisReduction;
for (Block block : blockList) {
BlockState blockState = block.getState();
if (BlockUtils.isOre(blockState)) {
ores.add(blockState);
}
else {
debris.add(blockState);
}
}
for (BlockState blockState : ores) {
if (Misc.getRandom().nextFloat() < (yield + oreBonus)) {
if (!mcMMO.placeStore.isTrue(blockState)) {
xp += Mining.getBlockXp(blockState);
}
Misc.dropItem(blockState.getLocation(), blockState.getData().toItemStack()); // Initial block that would have been dropped
if (!mcMMO.placeStore.isTrue(blockState)) {
for (int i = 1; i < dropMultiplier; i++) {
xp += Mining.getBlockXp(blockState);
Mining.handleSilkTouchDrops(blockState); // Bonus drops - should drop the block & not the items
}
}
}
}
if (debrisYield > 0) {
for (BlockState blockState : debris) {
if (Misc.getRandom().nextFloat() < debrisYield) {
Misc.dropItem(blockState.getLocation(), blockState.getData().toItemStack());
}
}
}
applyXpGain(xp);
}
/**
* Increases the blast radius of the explosion.
*
* @param event Event whose explosion radius is being changed
*/
public float biggerBombs(float radius) {
return (float) (radius + getBlastRadiusModifier());
}
public int processDemolitionsExpertise(int damage) {
return (int) (damage * (100.0 - getBlastDamageModifier()));
}
/**
* Gets the Blast Mining tier
*
* @return the Blast Mining tier
*/
public int getBlastMiningTier() {
int skillLevel = getSkillLevel();
for (Tier tier : Tier.values()) {
if (skillLevel >= tier.getLevel()) {
return tier.toNumerical();
}
}
return 0;
}
/**
* Gets the Blast Mining tier
*
* @return the Blast Mining tier
*/
public double getOreBonus() {
int skillLevel = getSkillLevel();
for (Tier tier : Tier.values()) {
if (skillLevel >= tier.getLevel()) {
return tier.getOreBonus();
}
}
return 0;
}
/**
* Gets the Blast Mining tier
*
* @return the Blast Mining tier
*/
public double getDebrisReduction() {
int skillLevel = getSkillLevel();
for (Tier tier : Tier.values()) {
if (skillLevel >= tier.getLevel()) {
return tier.getDebrisReduction();
}
}
return 0;
}
/**
* Gets the Blast Mining tier
*
* @return the Blast Mining tier
*/
public int getDropMultiplier() {
int skillLevel = getSkillLevel();
for (Tier tier : Tier.values()) {
if (skillLevel >= tier.getLevel()) {
return tier.getDropMultiplier();
}
}
return 0;
}
/**
* Gets the Blast Mining tier
*
* @return the Blast Mining tier
*/
public double getBlastRadiusModifier() {
int skillLevel = getSkillLevel();
for (Tier tier : Tier.values()) {
if (skillLevel >= tier.getLevel()) {
return tier.getBlastRadiusModifier();
}
}
return 0;
}
/**
* Gets the Blast Mining tier
*
* @return the Blast Mining tier
*/
public double getBlastDamageModifier() {
int skillLevel = getSkillLevel();
for (Tier tier : Tier.values()) {
if (skillLevel >= tier.getLevel()) {
return tier.getBlastDamageDecrease();
}
}
return 0;
}
private boolean blastMiningCooldownOver() {
Player player = getPlayer();
PlayerProfile profile = getProfile();
long oldTime = profile.getSkillDATS(AbilityType.BLAST_MINING) * Misc.TIME_CONVERSION_FACTOR;
int cooldown = AbilityType.BLAST_MINING.getCooldown();
if (!SkillUtils.cooldownOver(oldTime, cooldown, player)) {
player.sendMessage(LocaleLoader.getString("Skills.TooTired", SkillUtils.calculateTimeLeft(oldTime, cooldown, player)));
return false;
}
return true;
}
}

View File

@ -14,43 +14,27 @@ import org.getspout.spoutapi.player.SpoutPlayer;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.McMMOPlayer;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.utilities.PerksUtils;
import com.gmail.nossr50.skills.utilities.SkillType;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Users;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.PerksUtils;
public class Repair {
private static final AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
public static int repairMasteryMaxBonusLevel = AdvancedConfig.getInstance().getRepairMasteryMaxLevel();
public static double repairMasteryMaxBonus = AdvancedConfig.getInstance().getRepairMasteryMaxBonus();
public static final double REPAIR_MASTERY_CHANCE_MAX = advancedConfig.getRepairMasteryMaxBonus();
public static final int REPAIR_MASTERY_MAX_BONUS_LEVEL = advancedConfig.getRepairMasteryMaxLevel();
public static final double SUPER_REPAIR_CHANCE_MAX = advancedConfig.getSuperRepairChanceMax();
public static final int SUPER_REPAIR_MAX_BONUS_LEVEL = advancedConfig.getSuperRepairMaxLevel();
public static int superRepairMaxBonusLevel = AdvancedConfig.getInstance().getSuperRepairMaxLevel();
public static double superRepairMaxChance = AdvancedConfig.getInstance().getSuperRepairChanceMax();
public static boolean arcaneForgingDowngrades = advancedConfig.getArcaneForgingDowngradeEnabled();
public static boolean arcaneForgingEnchantLoss = advancedConfig.getArcaneForgingEnchantLossEnabled();
public static boolean arcaneForgingDowngrades = AdvancedConfig.getInstance().getArcaneForgingDowngradeEnabled();
public static boolean arcaneForgingEnchantLoss = AdvancedConfig.getInstance().getArcaneForgingEnchantLossEnabled();
public static boolean anvilMessagesEnabled = Config.getInstance().getRepairAnvilMessagesEnabled();
public static int anvilID = Config.getInstance().getRepairAnvilId();
/**
* Handle the Xp gain for repair events.
*
* @param mcMMOPlayer Player repairing the item
* @param durabilityBefore Durability of the item before repair
* @param modify Amount to modify the durability by
*/
protected static void xpHandler(McMMOPlayer mcMMOPlayer, short durabilityBefore, short durabilityAfter, double modify) {
short dif = (short) ((durabilityBefore - durabilityAfter) * modify);
Player player = mcMMOPlayer.getPlayer();
player.playSound(player.getLocation(), Sound.ANVIL_USE, Misc.ANVIL_USE_VOLUME, Misc.ANVIL_USE_PITCH);
mcMMOPlayer.beginXpGain(SkillType.REPAIR, dif * 10);
}
public static boolean anvilMessagesEnabled = Config.getInstance().getRepairAnvilMessagesEnabled();
/**
* Get current Arcane Forging rank.
@ -61,16 +45,16 @@ public class Repair {
public static int getArcaneForgingRank(PlayerProfile profile) {
int skillLevel = profile.getSkillLevel(SkillType.REPAIR);
if (skillLevel >= advancedConfig.getArcaneForgingRankLevels4()) {
if (skillLevel >= AdvancedConfig.getInstance().getArcaneForgingRankLevels4()) {
return 4;
}
else if (skillLevel >= advancedConfig.getArcaneForgingRankLevels3()) {
else if (skillLevel >= AdvancedConfig.getInstance().getArcaneForgingRankLevels3()) {
return 3;
}
else if (skillLevel >= advancedConfig.getArcaneForgingRankLevels2()) {
else if (skillLevel >= AdvancedConfig.getInstance().getArcaneForgingRankLevels2()) {
return 2;
}
else if (skillLevel >= advancedConfig.getArcaneForgingRankLevels1()) {
else if (skillLevel >= AdvancedConfig.getInstance().getArcaneForgingRankLevels1()) {
return 1;
}
else {
@ -95,7 +79,7 @@ public class Repair {
return;
}
int rank = getArcaneForgingRank(Users.getPlayer(player).getProfile());
int rank = getArcaneForgingRank(UserManager.getPlayer(player).getProfile());
if (rank == 0 || !Permissions.arcaneForging(player)) {
for (Enchantment x : enchants.keySet()) {
@ -115,7 +99,7 @@ public class Repair {
if (Misc.getRandom().nextInt(activationChance) <= getEnchantChance(rank)) {
int enchantLevel = enchant.getValue();
if (advancedConfig.getArcaneForgingDowngradeEnabled() && enchantLevel > 1) {
if (arcaneForgingDowngrades && enchantLevel > 1) {
if (Misc.getRandom().nextInt(activationChance) < getDowngradeChance(rank)) {
is.addEnchantment(enchantment, --enchantLevel);
downgraded = true;
@ -148,20 +132,20 @@ public class Repair {
*/
public static int getEnchantChance(int rank) {
switch (rank) {
case 4:
return advancedConfig.getArcaneForgingKeepEnchantsChanceRank4();
case 4:
return AdvancedConfig.getInstance().getArcaneForgingKeepEnchantsChanceRank4();
case 3:
return advancedConfig.getArcaneForgingKeepEnchantsChanceRank3();
case 3:
return AdvancedConfig.getInstance().getArcaneForgingKeepEnchantsChanceRank3();
case 2:
return advancedConfig.getArcaneForgingKeepEnchantsChanceRank2();
case 2:
return AdvancedConfig.getInstance().getArcaneForgingKeepEnchantsChanceRank2();
case 1:
return advancedConfig.getArcaneForgingKeepEnchantsChanceRank1();
case 1:
return AdvancedConfig.getInstance().getArcaneForgingKeepEnchantsChanceRank1();
default:
return 0;
default:
return 0;
}
}
@ -173,58 +157,23 @@ public class Repair {
*/
public static int getDowngradeChance(int rank) {
switch (rank) {
case 4:
return advancedConfig.getArcaneForgingDowngradeChanceRank4();
case 4:
return AdvancedConfig.getInstance().getArcaneForgingDowngradeChanceRank4();
case 3:
return advancedConfig.getArcaneForgingDowngradeChanceRank3();
case 3:
return AdvancedConfig.getInstance().getArcaneForgingDowngradeChanceRank3();
case 2:
return advancedConfig.getArcaneForgingDowngradeChanceRank2();
case 2:
return AdvancedConfig.getInstance().getArcaneForgingDowngradeChanceRank2();
case 1:
return advancedConfig.getArcaneForgingDowngradeChanceRank1();
case 1:
return AdvancedConfig.getInstance().getArcaneForgingDowngradeChanceRank1();
default:
return 100;
default:
return 100;
}
}
/**
* Computes repair bonuses.
*
* @param player The player repairing an item
* @param skillLevel the skillLevel of the player in Repair
* @param durability The durability of the item being repaired
* @param repairAmount The base amount of durability repaired to the item
* @return The final amount of durability repaired to the item
*/
protected static short repairCalculate(Player player, int skillLevel, short durability, int repairAmount) {
float bonus;
if (skillLevel >= REPAIR_MASTERY_MAX_BONUS_LEVEL) bonus = (float) (REPAIR_MASTERY_CHANCE_MAX / 100F);
else bonus = (((float) skillLevel) / ((float) REPAIR_MASTERY_MAX_BONUS_LEVEL)) * (float) ((REPAIR_MASTERY_CHANCE_MAX) / 100F);
if (Permissions.repairMastery(player)) {
bonus = repairAmount * bonus;
repairAmount += (int) bonus;
}
if (checkPlayerProcRepair(player)) {
repairAmount = (int) (repairAmount * 2D);
}
if (repairAmount <= 0 || repairAmount > 32767)
repairAmount = 32767;
durability -= repairAmount;
if (durability < 0) {
durability = 0;
}
return durability;
}
/**
* Checks for Super Repair bonus.
*
@ -232,10 +181,12 @@ public class Repair {
* @return true if bonus granted, false otherwise
*/
public static boolean checkPlayerProcRepair(Player player) {
int skillLevel = Users.getPlayer(player).getProfile().getSkillLevel(SkillType.REPAIR);
int skillLevel = UserManager.getPlayer(player).getProfile().getSkillLevel(SkillType.REPAIR);
int chance = (int) ((SUPER_REPAIR_CHANCE_MAX / SUPER_REPAIR_MAX_BONUS_LEVEL) * skillLevel);
if (skillLevel >= SUPER_REPAIR_MAX_BONUS_LEVEL) chance = (int) SUPER_REPAIR_CHANCE_MAX;
int chance = (int) ((superRepairMaxChance / superRepairMaxBonusLevel) * skillLevel);
if (skillLevel >= superRepairMaxBonusLevel) {
chance = (int) superRepairMaxChance;
}
int activationChance = PerksUtils.handleLuckyPerks(player, SkillType.REPAIR);
@ -253,7 +204,7 @@ public class Repair {
* @param anvilID The item ID of the anvil block
*/
public static void placedAnvilCheck(Player player, int anvilID) {
PlayerProfile profile = Users.getPlayer(player).getProfile();
PlayerProfile profile = UserManager.getPlayer(player).getProfile();
if (!profile.getPlacedAnvil()) {
if (mcMMO.spoutEnabled) {
@ -271,4 +222,59 @@ public class Repair {
profile.togglePlacedAnvil();
}
}
/**
* Handle the Xp gain for repair events.
*
* @param mcMMOPlayer Player repairing the item
* @param durabilityBefore Durability of the item before repair
* @param modify Amount to modify the durability by
*/
protected static void xpHandler(McMMOPlayer mcMMOPlayer, short durabilityBefore, short durabilityAfter, double modify) {
short dif = (short) ((durabilityBefore - durabilityAfter) * modify);
Player player = mcMMOPlayer.getPlayer();
player.playSound(player.getLocation(), Sound.ANVIL_USE, Misc.ANVIL_USE_VOLUME, Misc.ANVIL_USE_PITCH);
mcMMOPlayer.beginXpGain(SkillType.REPAIR, dif * 10);
}
/**
* Computes repair bonuses.
*
* @param player The player repairing an item
* @param skillLevel the skillLevel of the player in Repair
* @param durability The durability of the item being repaired
* @param repairAmount The base amount of durability repaired to the item
* @return The final amount of durability repaired to the item
*/
protected static short repairCalculate(Player player, int skillLevel, short durability, int repairAmount) {
float bonus;
if (skillLevel >= repairMasteryMaxBonusLevel) {
bonus = (float) (repairMasteryMaxBonus / 100F);
}
else {
bonus = (((float) skillLevel) / ((float) repairMasteryMaxBonusLevel)) * (float) ((repairMasteryMaxBonus) / 100F);
}
if (Permissions.repairMastery(player)) {
bonus = repairAmount * bonus;
repairAmount += (int) bonus;
}
if (checkPlayerProcRepair(player)) {
repairAmount = (int) (repairAmount * 2D);
}
if (repairAmount <= 0 || repairAmount > 32767) {
repairAmount = 32767;
}
durability -= repairAmount;
if (durability < 0) {
durability = 0;
}
return durability;
}
}

View File

@ -1,164 +0,0 @@
package com.gmail.nossr50.skills.repair;
import org.bukkit.Material;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.SkillCommand;
import com.gmail.nossr50.skills.utilities.SkillType;
import com.gmail.nossr50.util.Permissions;
public class RepairCommand extends SkillCommand {
private int arcaneForgingRank;
private String repairMasteryBonus;
private String superRepairChance;
private String superRepairChanceLucky;
private boolean canSuperRepair;
private boolean canMasterRepair;
private boolean canArcaneForge;
private boolean canSalvage;
private boolean canRepairStone;
private boolean canRepairIron;
private boolean canRepairGold;
private boolean canRepairDiamond;
private boolean canRepairString;
private boolean canRepairLeather;
private boolean canRepairWood;
private boolean arcaneBypass;
private int diamondLevel;
private int goldLevel;
private int ironLevel;
private int stoneLevel;
public RepairCommand() {
super(SkillType.REPAIR);
}
@Override
protected void dataCalculations() {
// We're using pickaxes here, not the best but it works
Repairable diamondRepairable = mcMMO.repairManager.getRepairable(Material.DIAMOND_PICKAXE.getId());
Repairable goldRepairable = mcMMO.repairManager.getRepairable(Material.GOLD_PICKAXE.getId());
Repairable ironRepairable = mcMMO.repairManager.getRepairable(Material.IRON_PICKAXE.getId());
Repairable stoneRepairable = mcMMO.repairManager.getRepairable(Material.STONE_PICKAXE.getId());
//TODO: This isn't really accurate - if they don't have pickaxes loaded it doesn't always mean the repair level is 0
diamondLevel = (diamondRepairable == null) ? 0 : diamondRepairable.getMinimumLevel();
goldLevel = (goldRepairable == null) ? 0 : goldRepairable.getMinimumLevel();
ironLevel = (ironRepairable == null) ? 0 : ironRepairable.getMinimumLevel();
stoneLevel = (stoneRepairable == null) ? 0 : stoneRepairable.getMinimumLevel();
//REPAIR MASTERY
if (skillValue >= Repair.REPAIR_MASTERY_MAX_BONUS_LEVEL) {
repairMasteryBonus = percent.format(Repair.REPAIR_MASTERY_CHANCE_MAX / 100D);
}
else {
repairMasteryBonus = percent.format((( Repair.REPAIR_MASTERY_CHANCE_MAX / Repair.REPAIR_MASTERY_MAX_BONUS_LEVEL) * skillValue) / 100D);
}
//SUPER REPAIR
String[] superRepairStrings = calculateAbilityDisplayValues(Repair.SUPER_REPAIR_MAX_BONUS_LEVEL, Repair.SUPER_REPAIR_CHANCE_MAX);
superRepairChance = superRepairStrings[0];
superRepairChanceLucky = superRepairStrings[1];
//ARCANE FORGING
arcaneForgingRank = Repair.getArcaneForgingRank(profile);
}
@Override
protected void permissionsCheck() {
canSuperRepair = Permissions.superRepair(player);
canMasterRepair = Permissions.repairMastery(player);
canArcaneForge = Permissions.arcaneForging(player);
canSalvage = Permissions.salvage(player);
canRepairDiamond = Permissions.repairDiamond(player);
canRepairGold = Permissions.repairGold(player);
canRepairIron = Permissions.repairIron(player);
canRepairStone = Permissions.repairStone(player);
canRepairString = Permissions.repairString(player);
canRepairLeather = Permissions.repairLeather(player);
canRepairWood = Permissions.repairWood(player);
arcaneBypass = Permissions.arcaneBypass(player);
}
@Override
protected boolean effectsHeaderPermissions() {
return canArcaneForge || canSalvage || canRepairDiamond || canRepairGold || canRepairIron || canMasterRepair || canRepairStone || canSuperRepair || canRepairString || canRepairWood || canRepairLeather;
}
@Override
protected void effectsDisplay() {
luckyEffectsDisplay();
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.0"), LocaleLoader.getString("Repair.Effect.1")));
if (canMasterRepair) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.2"), LocaleLoader.getString("Repair.Effect.3")));
}
if (canSuperRepair) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.4"), LocaleLoader.getString("Repair.Effect.5")));
}
/* Repair Level Requirements */
if (canRepairStone && stoneLevel > 0) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.14", stoneLevel), LocaleLoader.getString("Repair.Effect.15")));
}
if (canRepairIron && ironLevel > 0) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.12", ironLevel), LocaleLoader.getString("Repair.Effect.13")));
}
if (canRepairGold && goldLevel > 0) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.10", goldLevel), LocaleLoader.getString("Repair.Effect.11")));
}
if (canRepairDiamond && diamondLevel > 0) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.6", diamondLevel), LocaleLoader.getString("Repair.Effect.7")));
}
if (canSalvage && Salvage.salvageUnlockLevel > 0) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.16", Salvage.salvageUnlockLevel), LocaleLoader.getString("Repair.Effect.17")));
}
if (canArcaneForge) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.8"), LocaleLoader.getString("Repair.Effect.9")));
}
}
@Override
protected boolean statsHeaderPermissions() {
return canArcaneForge || canMasterRepair || canSuperRepair;
}
@Override
protected void statsDisplay() {
if (canMasterRepair) {
player.sendMessage(LocaleLoader.getString("Repair.Skills.Mastery", repairMasteryBonus));
}
if (canSuperRepair) {
if (isLucky) {
player.sendMessage(LocaleLoader.getString("Repair.Skills.Super.Chance", superRepairChance) + LocaleLoader.getString("Perks.lucky.bonus", superRepairChanceLucky));
}
else {
player.sendMessage(LocaleLoader.getString("Repair.Skills.Super.Chance", superRepairChance));
}
}
if (canArcaneForge) {
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Rank", arcaneForgingRank));
if (Repair.arcaneForgingEnchantLoss) {
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Chance.Success", (arcaneBypass ? 100 : Repair.getEnchantChance(arcaneForgingRank))));
}
if (Repair.arcaneForgingDowngrades) {
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Chance.Downgrade", (arcaneBypass ? 0 : Repair.getDowngradeChance(arcaneForgingRank))));
}
}
}
}

View File

@ -17,17 +17,17 @@ public enum RepairItemType {
*/
public boolean getPermissions(Player player) {
switch (this) {
case ARMOR:
return Permissions.repairArmor(player);
case ARMOR:
return Permissions.repairArmor(player);
case TOOL:
return Permissions.repairTools(player);
case TOOL:
return Permissions.repairTools(player);
case OTHER:
return Permissions.repairOtherItems(player);
case OTHER:
return Permissions.repairOtherItems(player);
default:
return false;
default:
return false;
}
}
}

View File

@ -4,7 +4,7 @@ import java.util.List;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.datatypes.McMMOPlayer;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
public interface RepairManager {
/**

View File

@ -22,32 +22,32 @@ public enum RepairMaterialType {
*/
public boolean getPermissions(Player player) {
switch (this) {
case STRING:
return Permissions.repairString(player);
case STRING:
return Permissions.repairString(player);
case LEATHER:
return Permissions.repairLeather(player);
case LEATHER:
return Permissions.repairLeather(player);
case WOOD:
return Permissions.repairWood(player);
case WOOD:
return Permissions.repairWood(player);
case STONE:
return Permissions.repairStone(player);
case STONE:
return Permissions.repairStone(player);
case IRON:
return Permissions.repairIron(player);
case IRON:
return Permissions.repairIron(player);
case GOLD:
return Permissions.repairGold(player);
case GOLD:
return Permissions.repairGold(player);
case DIAMOND:
return Permissions.repairDiamond(player);
case DIAMOND:
return Permissions.repairDiamond(player);
case OTHER:
return Permissions.repairOtherMaterials(player);
case OTHER:
return Permissions.repairOtherMaterials(player);
default:
return false;
default:
return false;
}
}
}

View File

@ -11,28 +11,26 @@ import org.getspout.spoutapi.player.SpoutPlayer;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.utilities.SkillType;
import com.gmail.nossr50.util.ItemChecks;
import com.gmail.nossr50.util.ItemUtils;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Users;
import com.gmail.nossr50.util.player.UserManager;
public class Salvage {
private static Config configInstance = Config.getInstance();
public static int salvageUnlockLevel = Config.getInstance().getSalvageUnlockLevel();
public static int anvilID = Config.getInstance().getSalvageAnvilId();
public static void handleSalvage(final Player player, final Location location, final ItemStack item) {
if (!configInstance.getSalvageEnabled()) {
if (!Config.getInstance().getSalvageEnabled()) {
return;
}
if (player.getGameMode() == GameMode.SURVIVAL) {
final int skillLevel = Users.getPlayer(player).getProfile().getSkillLevel(SkillType.REPAIR);
final int unlockLevel = configInstance.getSalvageUnlockLevel();
final int skillLevel = UserManager.getPlayer(player).getProfile().getSkillLevel(SkillType.REPAIR);
if (skillLevel < unlockLevel) {
if (skillLevel < salvageUnlockLevel) {
player.sendMessage(LocaleLoader.getString("Repair.Skills.AdeptSalvage"));
return;
}
@ -52,17 +50,16 @@ public class Salvage {
player.sendMessage(LocaleLoader.getString("Repair.Skills.NotFullDurability"));
}
}
}
/**
* Handles notifications for placing an anvil.
*
*
* @param player The player placing the anvil
* @param anvilID The item ID of the anvil block
*/
public static void placedAnvilCheck(final Player player, final int anvilID) {
final PlayerProfile profile = Users.getPlayer(player).getProfile();
final PlayerProfile profile = UserManager.getPlayer(player).getProfile();
if (!profile.getPlacedSalvageAnvil()) {
if (mcMMO.spoutEnabled) {
@ -81,26 +78,44 @@ public class Salvage {
}
}
/**
* Checks if the item is salvageable.
*
* @param is Item to check
* @return true if the item is salvageable, false otherwise
*/
public static boolean isSalvageable(final ItemStack is) {
if (Config.getInstance().getSalvageTools() && (ItemUtils.isMinecraftTool(is) || ItemUtils.isStringTool(is) || is.getType() == Material.BUCKET)) {
return true;
}
if (Config.getInstance().getSalvageArmor() && ItemUtils.isMinecraftArmor(is)) {
return true;
}
return false;
}
private static Material getSalvagedItem(final ItemStack inHand) {
if (ItemChecks.isDiamondTool(inHand) || ItemChecks.isDiamondArmor(inHand)) {
if (ItemUtils.isDiamondTool(inHand) || ItemUtils.isDiamondArmor(inHand)) {
return Material.DIAMOND;
}
else if (ItemChecks.isGoldTool(inHand) || ItemChecks.isGoldArmor(inHand)) {
else if (ItemUtils.isGoldTool(inHand) || ItemUtils.isGoldArmor(inHand)) {
return Material.GOLD_INGOT;
}
else if (ItemChecks.isIronTool(inHand) || ItemChecks.isIronArmor(inHand)) {
else if (ItemUtils.isIronTool(inHand) || ItemUtils.isIronArmor(inHand)) {
return Material.IRON_INGOT;
}
else if (ItemChecks.isStoneTool(inHand)) {
else if (ItemUtils.isStoneTool(inHand)) {
return Material.COBBLESTONE;
}
else if (ItemChecks.isWoodTool(inHand)) {
else if (ItemUtils.isWoodTool(inHand)) {
return Material.WOOD;
}
else if (ItemChecks.isLeatherArmor(inHand)) {
else if (ItemUtils.isLeatherArmor(inHand)) {
return Material.LEATHER;
}
else if (ItemChecks.isStringTool(inHand)) {
else if (ItemUtils.isStringTool(inHand)) {
return Material.STRING;
}
else {
@ -109,44 +124,29 @@ public class Salvage {
}
private static int getSalvagedAmount(final ItemStack inHand) {
if (ItemChecks.isPickaxe(inHand) || ItemChecks.isAxe(inHand) || inHand.getType() == Material.BOW || inHand.getType() == Material.BUCKET) {
if (ItemUtils.isPickaxe(inHand) || ItemUtils.isAxe(inHand) || inHand.getType() == Material.BOW || inHand.getType() == Material.BUCKET) {
return 3;
}
else if (ItemChecks.isShovel(inHand) || inHand.getType() == Material.FLINT_AND_STEEL) {
else if (ItemUtils.isShovel(inHand) || inHand.getType() == Material.FLINT_AND_STEEL) {
return 1;
}
else if (ItemChecks.isSword(inHand) || ItemChecks.isHoe(inHand) || inHand.getType() == Material.CARROT_STICK || inHand.getType() == Material.FISHING_ROD || inHand.getType() == Material.SHEARS) {
else if (ItemUtils.isSword(inHand) || ItemUtils.isHoe(inHand) || inHand.getType() == Material.CARROT_STICK || inHand.getType() == Material.FISHING_ROD || inHand.getType() == Material.SHEARS) {
return 2;
}
else if (ItemChecks.isHelmet(inHand)) {
else if (ItemUtils.isHelmet(inHand)) {
return 5;
}
else if (ItemChecks.isChestplate(inHand)) {
else if (ItemUtils.isChestplate(inHand)) {
return 8;
}
else if (ItemChecks.isLeggings(inHand)) {
else if (ItemUtils.isLeggings(inHand)) {
return 7;
}
else if (ItemChecks.isBoots(inHand)) {
else if (ItemUtils.isBoots(inHand)) {
return 4;
}
else {
return 0;
}
}
/**
* Checks if the item is salvageable.
*
* @param is Item to check
* @return true if the item is salvageable, false otherwise
*/
public static boolean isSalvageable(final ItemStack is) {
if (configInstance.getSalvageTools() && (ItemChecks.isMinecraftTool(is) || ItemChecks.isStringTool(is) || is.getType() == Material.BUCKET)) {
return true;
}
if (configInstance.getSalvageArmor() && ItemChecks.isMinecraftArmor(is)) {
return true;
}
return false;
}
}

View File

@ -9,10 +9,10 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.datatypes.McMMOPlayer;
import com.gmail.nossr50.events.skills.McMMOPlayerRepairCheckEvent;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.events.skills.repair.McMMOPlayerRepairCheckEvent;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.utilities.SkillType;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.StringUtils;
@ -194,11 +194,8 @@ public class SimpleRepairManager implements RepairManager {
*/
private int findInInventory(PlayerInventory inventory, int itemId, byte metadata) {
int location = -1;
ItemStack[] contents = inventory.getContents();
for (int i = 0; i < contents.length; i++) {
ItemStack item = contents[i];
for (ItemStack item : inventory.getContents()) {
if (item == null) {
continue;
}

View File

@ -1,109 +0,0 @@
package com.gmail.nossr50.skills.runnables;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.utilities.CombatTools;
import com.gmail.nossr50.util.ParticleEffectUtils;
public class BleedTimer implements Runnable {
private final static int MAX_BLEED_TICKS = 10;
private static Map<LivingEntity, Integer> bleedList = new HashMap<LivingEntity, Integer>();
@Override
public void run() {
for (Iterator<Entry<LivingEntity, Integer>> bleedIterator = bleedList.entrySet().iterator(); bleedIterator.hasNext();) {
Entry<LivingEntity, Integer> entry = bleedIterator.next();
LivingEntity entity = entry.getKey();
if (entry.getValue() <= 0 || !entity.isValid()) {
bleedIterator.remove();
continue;
}
int damage = 0;
if (entity instanceof Player) {
damage = 1;
Player player = (Player) entity;
if (!player.isOnline()) {
continue;
}
// Never kill with Bleeding
if (player.getHealth() - damage > 0) {
CombatTools.dealDamage(player, damage);
ParticleEffectUtils.playBleedEffect(entity);
}
entry.setValue(entry.getValue() - damage);
if (entry.getValue() <= 0) {
player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleeding.Stopped"));
}
}
else {
damage = 2;
// Anticipate the entity's death to prevent CME because of our EntityDeathEvent listener
if (entity.getHealth() - damage > 0) {
entry.setValue(entry.getValue() - 1);
}
else {
bleedIterator.remove();
}
CombatTools.dealDamage(entity, damage);
ParticleEffectUtils.playBleedEffect(entity);
}
}
}
/**
* Instantly Bleed out a LivingEntity
*
* @param entity LivingEntity to bleed out
*/
public static void bleedOut(LivingEntity entity) {
if (bleedList.containsKey(entity)) {
CombatTools.dealDamage(entity, bleedList.get(entity) * 2);
bleedList.remove(entity);
}
}
/**
* Remove a LivingEntity from the bleedList if it is in it
*
* @param entity LivingEntity to remove
*/
public static void remove(LivingEntity entity) {
if (bleedList.containsKey(entity)) {
bleedList.remove(entity);
}
}
/**
* Add a LivingEntity to the bleedList if it is not in it.
*
* @param entity LivingEntity to add
* @param ticks Number of bleeding ticks
*/
public static void add(LivingEntity entity, int ticks) {
int newTicks = ticks;
if (bleedList.containsKey(entity)) {
newTicks += bleedList.get(entity);
bleedList.put(entity, Math.min(newTicks, MAX_BLEED_TICKS));
}
else {
bleedList.put(entity, Math.min(newTicks, MAX_BLEED_TICKS));
}
}
}

View File

@ -1,40 +0,0 @@
package com.gmail.nossr50.skills.runnables;
import org.bukkit.entity.LivingEntity;
import com.gmail.nossr50.datatypes.McMMOPlayer;
import com.gmail.nossr50.skills.utilities.SkillType;
public class CombatXpGiver implements Runnable {
private McMMOPlayer mcMMOPlayer;
private double baseXp;
private SkillType skillType;
private LivingEntity target;
private int baseHealth;
public CombatXpGiver(McMMOPlayer mcMMOPlayer, SkillType skillType, double baseXp, LivingEntity target) {
this.mcMMOPlayer = mcMMOPlayer;
this.skillType = skillType;
this.baseXp = baseXp;
this.target = target;
baseHealth = target.getHealth();
}
@Override
public void run() {
int health = target.getHealth();
int damage = baseHealth - health;
//May avoid negative xp, we don't know what other plugins do with the entity health
if (damage <= 0) {
return;
}
//Don't reward the player for overkills
if (health < 0) {
damage += health;
}
mcMMOPlayer.beginXpGain(skillType, (int) (damage * baseXp));
}
}

View File

@ -1,44 +0,0 @@
package com.gmail.nossr50.skills.runnables;
import org.bukkit.entity.Player;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.skills.utilities.AbilityType;
import com.gmail.nossr50.skills.utilities.SkillTools;
import com.gmail.nossr50.skills.utilities.SkillType;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Users;
public class SkillMonitor implements Runnable {
@Override
public void run() {
long curTime = System.currentTimeMillis();
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
if (Misc.isNPCEntity(player)) {
continue;
}
PlayerProfile profile = Users.getPlayer(player).getProfile();
/*
* MONITOR SKILLS
*/
for (SkillType skill : SkillType.values()) {
if (skill.getTool() != null && skill.getAbility() != null) {
SkillTools.monitorSkill(player, profile, curTime, skill);
}
}
/*
* COOLDOWN MONITORING
*/
for (AbilityType ability : AbilityType.values()) {
if (ability.getCooldown() > 0) {
SkillTools.watchCooldown(player, profile, ability);
}
}
}
}
}

View File

@ -1,60 +1,60 @@
package com.gmail.nossr50.skills.smelting;
import org.bukkit.Material;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.skills.utilities.SkillType;
public class Smelting {
// The order of the values is extremely important, a few methods depend on it to work properly
protected enum Tier {
FIVE(5) {
@Override public int getLevel() {return AdvancedConfig.getInstance().getSmeltingVanillaXPBoostRank5Level();}
@Override public int getVanillaXPBoostModifier() {return AdvancedConfig.getInstance().getSmeltingVanillaXPBoostRank5Multiplier();}},
FOUR(4) {
@Override public int getLevel() {return AdvancedConfig.getInstance().getSmeltingVanillaXPBoostRank4Level();}
@Override public int getVanillaXPBoostModifier() {return AdvancedConfig.getInstance().getSmeltingVanillaXPBoostRank4Multiplier();}},
THREE(3) {
@Override public int getLevel() {return AdvancedConfig.getInstance().getSmeltingVanillaXPBoostRank3Level();}
@Override public int getVanillaXPBoostModifier() {return AdvancedConfig.getInstance().getSmeltingVanillaXPBoostRank3Multiplier();}},
TWO(2) {
@Override public int getLevel() {return AdvancedConfig.getInstance().getSmeltingVanillaXPBoostRank2Level();}
@Override public int getVanillaXPBoostModifier() {return AdvancedConfig.getInstance().getSmeltingVanillaXPBoostRank2Multiplier();}},
ONE(1) {
@Override public int getLevel() {return AdvancedConfig.getInstance().getSmeltingVanillaXPBoostRank1Level();}
@Override public int getVanillaXPBoostModifier() {return AdvancedConfig.getInstance().getSmeltingVanillaXPBoostRank1Multiplier();}};
int numerical;
private Tier(int numerical) {
this.numerical = numerical;
}
public int toNumerical() {
return numerical;
}
abstract protected int getLevel();
abstract protected int getVanillaXPBoostModifier();
}
public static int burnModifierMaxLevel = AdvancedConfig.getInstance().getBurnModifierMaxLevel();
public static double burnTimeMultiplier = AdvancedConfig.getInstance().getBurnTimeMultiplier();
public static double secondSmeltMaxChance = AdvancedConfig.getInstance().getSecondSmeltMaxChance();
public static int secondSmeltMaxLevel = AdvancedConfig.getInstance().getSecondSmeltMaxLevel();
public static int fluxMiningUnlockLevel = AdvancedConfig.getInstance().getFluxMiningUnlockLevel();
public static double fluxMiningChance = AdvancedConfig.getInstance().getFluxMiningChance();
protected static int getResourceXp(Material resourceType) {
int xp = Config.getInstance().getXp(SkillType.SMELTING, resourceType);
if (resourceType == Material.GLOWING_REDSTONE_ORE) {
xp = Config.getInstance().getXp(SkillType.SMELTING, Material.REDSTONE_ORE);
}
return xp;
}
}
package com.gmail.nossr50.skills.smelting;
import org.bukkit.Material;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.skills.SkillType;
public class Smelting {
// The order of the values is extremely important, a few methods depend on it to work properly
protected enum Tier {
FIVE(5) {
@Override public int getLevel() { return AdvancedConfig.getInstance().getSmeltingVanillaXPBoostRank5Level(); }
@Override public int getVanillaXPBoostModifier() { return AdvancedConfig.getInstance().getSmeltingVanillaXPBoostRank5Multiplier(); }},
FOUR(4) {
@Override public int getLevel() { return AdvancedConfig.getInstance().getSmeltingVanillaXPBoostRank4Level(); }
@Override public int getVanillaXPBoostModifier() { return AdvancedConfig.getInstance().getSmeltingVanillaXPBoostRank4Multiplier(); }},
THREE(3) {
@Override public int getLevel() { return AdvancedConfig.getInstance().getSmeltingVanillaXPBoostRank3Level(); }
@Override public int getVanillaXPBoostModifier() { return AdvancedConfig.getInstance().getSmeltingVanillaXPBoostRank3Multiplier(); }},
TWO(2) {
@Override public int getLevel() { return AdvancedConfig.getInstance().getSmeltingVanillaXPBoostRank2Level(); }
@Override public int getVanillaXPBoostModifier() { return AdvancedConfig.getInstance().getSmeltingVanillaXPBoostRank2Multiplier(); }},
ONE(1) {
@Override public int getLevel() { return AdvancedConfig.getInstance().getSmeltingVanillaXPBoostRank1Level(); }
@Override public int getVanillaXPBoostModifier() { return AdvancedConfig.getInstance().getSmeltingVanillaXPBoostRank1Multiplier(); }};
int numerical;
private Tier(int numerical) {
this.numerical = numerical;
}
public int toNumerical() {
return numerical;
}
abstract protected int getLevel();
abstract protected int getVanillaXPBoostModifier();
}
public static int burnModifierMaxLevel = AdvancedConfig.getInstance().getBurnModifierMaxLevel();
public static double burnTimeMultiplier = AdvancedConfig.getInstance().getBurnTimeMultiplier();
public static int secondSmeltMaxLevel = AdvancedConfig.getInstance().getSecondSmeltMaxLevel();
public static double secondSmeltMaxChance = AdvancedConfig.getInstance().getSecondSmeltMaxChance();
public static int fluxMiningUnlockLevel = AdvancedConfig.getInstance().getFluxMiningUnlockLevel();
public static double fluxMiningChance = AdvancedConfig.getInstance().getFluxMiningChance();
protected static int getResourceXp(Material resourceType) {
int xp = Config.getInstance().getXp(SkillType.SMELTING, resourceType);
if (resourceType == Material.GLOWING_REDSTONE_ORE) {
xp = Config.getInstance().getXp(SkillType.SMELTING, Material.REDSTONE_ORE);
}
return xp;
}
}

View File

@ -1,121 +0,0 @@
package com.gmail.nossr50.skills.smelting;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.SkillCommand;
import com.gmail.nossr50.skills.SkillManagerStore;
import com.gmail.nossr50.skills.utilities.SkillType;
import com.gmail.nossr50.util.Permissions;
public class SmeltingCommand extends SkillCommand {
private String burnTimeModifier;
private String secondSmeltChance;
private String secondSmeltChanceLucky;
private String fluxMiningChance;
private String fluxMiningChanceLucky;
private int vanillaXPModifier;
private boolean canFuelEfficiency;
private boolean canSecondSmelt;
private boolean canFluxMine;
private boolean canVanillaXPBoost;
public SmeltingCommand() {
super(SkillType.SMELTING);
}
@Override
protected void dataCalculations() {
//FUEL EFFICIENCY
burnTimeModifier = decimal.format(1 + ((skillValue / Smelting.burnModifierMaxLevel) * Smelting.burnTimeMultiplier));
//SECOND SMELT
String[] secondSmeltStrings = calculateAbilityDisplayValues(Smelting.secondSmeltMaxLevel, Smelting.secondSmeltMaxChance);
secondSmeltChance = secondSmeltStrings[0];
secondSmeltChanceLucky = secondSmeltStrings[1];
//FLUX MINING
String[] fluxMiningStrings = calculateAbilityDisplayValues(Smelting.fluxMiningChance);
fluxMiningChance = fluxMiningStrings[0];
fluxMiningChanceLucky = fluxMiningStrings[1];
//VANILLA XP BOOST
vanillaXPModifier = SkillManagerStore.getInstance().getSmeltingManager(player.getName()).getVanillaXpMultiplier();
}
@Override
protected void permissionsCheck() {
canFuelEfficiency = Permissions.fuelEfficiency(player);
canSecondSmelt = Permissions.doubleDrops(player, skill);
canFluxMine = Permissions.fluxMining(player);
canVanillaXPBoost = Permissions.vanillaXpBoost(player, skill);
}
@Override
protected boolean effectsHeaderPermissions() {
return canFluxMine || canFuelEfficiency || canSecondSmelt || canVanillaXPBoost;
}
@Override
protected void effectsDisplay() {
luckyEffectsDisplay();
if (canFuelEfficiency) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Smelting.Effect.0"), LocaleLoader.getString("Smelting.Effect.1")));
}
if (canSecondSmelt) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Smelting.Effect.2"), LocaleLoader.getString("Smelting.Effect.3")));
}
if (canVanillaXPBoost) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Smelting.Effect.4"), LocaleLoader.getString("Smelting.Effect.5")));
}
if (canFluxMine) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Smelting.Effect.6"), LocaleLoader.getString("Smelting.Effect.7")));
}
}
@Override
protected boolean statsHeaderPermissions() {
return canFluxMine || canFuelEfficiency || canSecondSmelt || canVanillaXPBoost;
}
@Override
protected void statsDisplay() {
if (canFuelEfficiency) {
player.sendMessage(LocaleLoader.getString("Smelting.Ability.FuelEfficiency", burnTimeModifier));
}
if (canSecondSmelt) {
if (isLucky) {
player.sendMessage(LocaleLoader.getString("Smelting.Ability.SecondSmelt", secondSmeltChance) + LocaleLoader.getString("Perks.lucky.bonus", secondSmeltChanceLucky));
}
else {
player.sendMessage(LocaleLoader.getString("Smelting.Ability.SecondSmelt", secondSmeltChance));
}
}
if (canVanillaXPBoost) {
if (skillValue < AdvancedConfig.getInstance().getSmeltingVanillaXPBoostRank1Level()) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Smelting.Ability.Locked.0", AdvancedConfig.getInstance().getSmeltingVanillaXPBoostRank1Level())));
}
else {
player.sendMessage(LocaleLoader.getString("Smelting.Ability.VanillaXPBoost", vanillaXPModifier));
}
}
if (canFluxMine) {
if (skillValue < Smelting.fluxMiningUnlockLevel) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Smelting.Ability.Locked.1", Smelting.fluxMiningUnlockLevel)));
}
else if (isLucky) {
player.sendMessage(LocaleLoader.getString("Smelting.Ability.FluxMining", fluxMiningChance) + LocaleLoader.getString("Perks.lucky.bonus", fluxMiningChanceLucky));
}
else {
player.sendMessage(LocaleLoader.getString("Smelting.Ability.FluxMining", fluxMiningChance));
}
}
}
}

View File

@ -1,132 +1,132 @@
package com.gmail.nossr50.skills.smelting;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.BlockState;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.FurnaceBurnEvent;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.skills.mining.Mining;
import com.gmail.nossr50.skills.smelting.Smelting.Tier;
import com.gmail.nossr50.skills.utilities.SkillTools;
import com.gmail.nossr50.skills.utilities.SkillType;
import com.gmail.nossr50.util.BlockChecks;
import com.gmail.nossr50.util.ItemChecks;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
public class SmeltingManager extends SkillManager {
public SmeltingManager(McMMOPlayer mcMMOPlayer) {
super(mcMMOPlayer, SkillType.SMELTING);
}
public boolean canUseFluxMining(BlockState blockState) {
Player player = getPlayer();
ItemStack heldItem = player.getItemInHand();
return BlockChecks.affectedByFluxMining(blockState) && ItemChecks.isPickaxe(heldItem) && !heldItem.containsEnchantment(Enchantment.SILK_TOUCH) && Permissions.fluxMining(player) && !mcMMO.placeStore.isTrue(blockState);
}
public boolean canUseVanillaXpBoost() {
Player player = getPlayer();
return SkillTools.unlockLevelReached(player, skill, Smelting.Tier.ONE.getLevel()) && Permissions.vanillaXpBoost(player, skill);
}
/**
* Process the Flux Mining ability.
*
* @param blockState The {@link BlockState} to check ability activation for
* @return true if the ability was successful, false otherwise
*/
public boolean processFluxMining(BlockState blockState) {
Player player = getPlayer();
if (SkillTools.unlockLevelReached(player, skill, Smelting.fluxMiningUnlockLevel) && SkillTools.activationSuccessful(player, skill, Smelting.fluxMiningChance)) {
ItemStack item = null;
switch (blockState.getType()) {
case IRON_ORE:
item = new ItemStack(Material.IRON_INGOT);
break;
case GOLD_ORE:
item = new ItemStack(Material.GOLD_INGOT);
break;
default:
break;
}
if (item == null) {
return false;
}
Location location = blockState.getLocation();
Misc.dropItem(location, item);
if (Permissions.doubleDrops(player, skill) && SkillTools.activationSuccessful(player, skill, Mining.doubleDropsMaxChance, Mining.doubleDropsMaxLevel)) {
Misc.dropItem(location, item);
}
blockState.setRawData((byte) 0x0);
blockState.setType(Material.AIR);
player.sendMessage(LocaleLoader.getString("Smelting.FluxMining.Success"));
return true;
}
return false;
}
/**
* Increases burn time for furnace fuel.
*
* @param burnTime The initial burn time from the {@link FurnaceBurnEvent}
*/
public int fuelEfficiency(int burnTime) {
double burnModifier = 1 + (((double) getSkillLevel() / Smelting.burnModifierMaxLevel) * Smelting.burnTimeMultiplier);
return (int) (burnTime * burnModifier);
}
public ItemStack smeltProcessing(Material resourceType, ItemStack result) {
Player player = getPlayer();
applyXpGain(Smelting.getResourceXp(resourceType));
if (Permissions.doubleDrops(player, skill) && SkillTools.activationSuccessful(player, skill, Smelting.secondSmeltMaxChance, Smelting.secondSmeltMaxLevel)) {
ItemStack newResult = new ItemStack(result.getType(), result.getAmount() + 1);
return newResult;
}
return result;
}
public int vanillaXPBoost(int experience) {
return experience * getVanillaXpMultiplier();
}
/**
* Gets the vanilla XP multiplier
*
* @return the vanilla XP multiplier
*/
protected int getVanillaXpMultiplier() {
int skillLevel = getSkillLevel();
for (Tier tier : Tier.values()) {
if (skillLevel >= tier.getLevel()) {
return tier.getVanillaXPBoostModifier();
}
}
return 0;
}
}
package com.gmail.nossr50.skills.smelting;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.BlockState;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.FurnaceBurnEvent;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.skills.mining.Mining;
import com.gmail.nossr50.skills.smelting.Smelting.Tier;
import com.gmail.nossr50.util.BlockUtils;
import com.gmail.nossr50.util.ItemUtils;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.skills.SkillUtils;
public class SmeltingManager extends SkillManager {
public SmeltingManager(McMMOPlayer mcMMOPlayer) {
super(mcMMOPlayer, SkillType.SMELTING);
}
public boolean canUseFluxMining(BlockState blockState) {
Player player = getPlayer();
ItemStack heldItem = player.getItemInHand();
return BlockUtils.affectedByFluxMining(blockState) && ItemUtils.isPickaxe(heldItem) && !heldItem.containsEnchantment(Enchantment.SILK_TOUCH) && Permissions.fluxMining(player) && !mcMMO.placeStore.isTrue(blockState);
}
public boolean canUseVanillaXpBoost() {
Player player = getPlayer();
return SkillUtils.unlockLevelReached(player, skill, Smelting.Tier.ONE.getLevel()) && Permissions.vanillaXpBoost(player, skill);
}
/**
* Process the Flux Mining ability.
*
* @param blockState The {@link BlockState} to check ability activation for
* @return true if the ability was successful, false otherwise
*/
public boolean processFluxMining(BlockState blockState) {
Player player = getPlayer();
if (SkillUtils.unlockLevelReached(player, skill, Smelting.fluxMiningUnlockLevel) && SkillUtils.activationSuccessful(player, skill, Smelting.fluxMiningChance)) {
ItemStack item = null;
switch (blockState.getType()) {
case IRON_ORE:
item = new ItemStack(Material.IRON_INGOT);
break;
case GOLD_ORE:
item = new ItemStack(Material.GOLD_INGOT);
break;
default:
break;
}
if (item == null) {
return false;
}
Location location = blockState.getLocation();
Misc.dropItem(location, item);
if (Permissions.doubleDrops(player, skill) && SkillUtils.activationSuccessful(player, skill, Mining.doubleDropsMaxChance, Mining.doubleDropsMaxLevel)) {
Misc.dropItem(location, item);
}
blockState.setRawData((byte) 0x0);
blockState.setType(Material.AIR);
player.sendMessage(LocaleLoader.getString("Smelting.FluxMining.Success"));
return true;
}
return false;
}
/**
* Increases burn time for furnace fuel.
*
* @param burnTime The initial burn time from the {@link FurnaceBurnEvent}
*/
public int fuelEfficiency(int burnTime) {
double burnModifier = 1 + (((double) getSkillLevel() / Smelting.burnModifierMaxLevel) * Smelting.burnTimeMultiplier);
return (int) (burnTime * burnModifier);
}
public ItemStack smeltProcessing(Material resourceType, ItemStack result) {
Player player = getPlayer();
applyXpGain(Smelting.getResourceXp(resourceType));
if (Permissions.doubleDrops(player, skill) && SkillUtils.activationSuccessful(player, skill, Smelting.secondSmeltMaxChance, Smelting.secondSmeltMaxLevel)) {
ItemStack newResult = new ItemStack(result.getType(), result.getAmount() + 1);
return newResult;
}
return result;
}
public int vanillaXPBoost(int experience) {
return experience * getVanillaXpMultiplier();
}
/**
* Gets the vanilla XP multiplier
*
* @return the vanilla XP multiplier
*/
public int getVanillaXpMultiplier() {
int skillLevel = getSkillLevel();
for (Tier tier : Tier.values()) {
if (skillLevel >= tier.getLevel()) {
return tier.getVanillaXPBoostModifier();
}
}
return 0;
}
}

View File

@ -1,18 +1,17 @@
package com.gmail.nossr50.skills.swords;
import com.gmail.nossr50.config.AdvancedConfig;
public class Swords {
public static double bleedMaxChance = AdvancedConfig.getInstance().getBleedChanceMax();
public static int bleedMaxBonusLevel = AdvancedConfig.getInstance().getBleedMaxBonusLevel();
public static int bleedMaxTicks = AdvancedConfig.getInstance().getBleedMaxTicks();
public static int bleedBaseTicks = AdvancedConfig.getInstance().getBleedBaseTicks();
public static double counterAttackMaxChance = AdvancedConfig.getInstance().getCounterChanceMax();
public static int counterAttackMaxBonusLevel = AdvancedConfig.getInstance().getCounterMaxBonusLevel();
public static int counterAttackModifier = AdvancedConfig.getInstance().getCounterModifier();
public static int serratedStrikesModifier = AdvancedConfig.getInstance().getSerratedStrikesModifier();
public static int serratedStrikesBleedTicks = AdvancedConfig.getInstance().getSerratedStrikesTicks();
}
package com.gmail.nossr50.skills.swords;
import com.gmail.nossr50.config.AdvancedConfig;
public class Swords {
public static int bleedMaxBonusLevel = AdvancedConfig.getInstance().getBleedMaxBonusLevel();
public static int bleedMaxTicks = AdvancedConfig.getInstance().getBleedMaxTicks();
public static int bleedBaseTicks = AdvancedConfig.getInstance().getBleedBaseTicks();
public static double bleedMaxChance = AdvancedConfig.getInstance().getBleedChanceMax();
public static int counterAttackMaxBonusLevel = AdvancedConfig.getInstance().getCounterMaxBonusLevel();
public static int counterAttackModifier = AdvancedConfig.getInstance().getCounterModifier();
public static double counterAttackMaxChance = AdvancedConfig.getInstance().getCounterChanceMax();
public static int serratedStrikesModifier = AdvancedConfig.getInstance().getSerratedStrikesModifier();
public static int serratedStrikesBleedTicks = AdvancedConfig.getInstance().getSerratedStrikesTicks();
}

View File

@ -1,117 +0,0 @@
package com.gmail.nossr50.skills.swords;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.SkillCommand;
import com.gmail.nossr50.skills.utilities.SkillType;
import com.gmail.nossr50.util.Permissions;
public class SwordsCommand extends SkillCommand {
private String counterAttackChance;
private String counterAttackChanceLucky;
private String bleedLength;
private String bleedChance;
private String bleedChanceLucky;
private String serratedStrikesLength;
private String serratedStrikesLengthEndurance;
private boolean canCounter;
private boolean canSerratedStrike;
private boolean canBleed;
public SwordsCommand() {
super(SkillType.SWORDS);
}
@Override
protected void dataCalculations() {
//SERRATED STRIKES
String[] serratedStrikesStrings = calculateLengthDisplayValues();
serratedStrikesLength = serratedStrikesStrings[0];
serratedStrikesLengthEndurance = serratedStrikesStrings[1];
//BLEED
if (skillValue >= Swords.bleedMaxBonusLevel) {
bleedLength = String.valueOf(Swords.bleedMaxTicks);
}
else {
bleedLength = String.valueOf(Swords.bleedBaseTicks);
}
String[] bleedStrings = calculateAbilityDisplayValues(Swords.bleedMaxBonusLevel, Swords.bleedMaxChance);
bleedChance = bleedStrings[0];
bleedChanceLucky = bleedStrings[1];
//COUNTER ATTACK
String[] counterAttackStrings = calculateAbilityDisplayValues(Swords.counterAttackMaxBonusLevel, Swords.counterAttackMaxChance);
counterAttackChance = counterAttackStrings[0];
counterAttackChanceLucky = counterAttackStrings[1];
}
@Override
protected void permissionsCheck() {
canBleed = Permissions.bleed(player);
canCounter = Permissions.counterAttack(player);
canSerratedStrike = Permissions.serratedStrikes(player);
}
@Override
protected boolean effectsHeaderPermissions() {
return canBleed || canCounter || canSerratedStrike;
}
@Override
protected void effectsDisplay() {
luckyEffectsDisplay();
if (canCounter) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Swords.Effect.0"), LocaleLoader.getString("Swords.Effect.1", percent.format(1.0D / Swords.counterAttackModifier))));
}
if (canSerratedStrike) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Swords.Effect.2"), LocaleLoader.getString("Swords.Effect.3", percent.format(1.0D / Swords.serratedStrikesModifier))));
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Swords.Effect.4"), LocaleLoader.getString("Swords.Effect.5", Swords.serratedStrikesBleedTicks)));
}
if (canBleed) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Swords.Effect.6"), LocaleLoader.getString("Swords.Effect.7")));
}
}
@Override
protected boolean statsHeaderPermissions() {
return canBleed || canCounter || canSerratedStrike;
}
@Override
protected void statsDisplay() {
if (canCounter) {
if (isLucky) {
player.sendMessage(LocaleLoader.getString("Swords.Combat.Counter.Chance", counterAttackChance) + LocaleLoader.getString("Perks.lucky.bonus", counterAttackChanceLucky));
}
else {
player.sendMessage(LocaleLoader.getString("Swords.Combat.Counter.Chance", counterAttackChance));
}
}
if (canBleed) {
player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleed.Length", bleedLength));
player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleed.Note"));
if (isLucky) {
player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleed.Chance", bleedChance) + LocaleLoader.getString("Perks.lucky.bonus", bleedChanceLucky));
}
else {
player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleed.Chance", bleedChance));
}
}
if (canSerratedStrike) {
if (hasEndurance) {
player.sendMessage(LocaleLoader.getString("Swords.SS.Length", serratedStrikesLength) + LocaleLoader.getString("Perks.activationtime.bonus", serratedStrikesLengthEndurance));
}
else {
player.sendMessage(LocaleLoader.getString("Swords.SS.Length", serratedStrikesLength));
}
}
}
}

View File

@ -1,67 +1,67 @@
package com.gmail.nossr50.skills.swords;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.skills.runnables.BleedTimer;
import com.gmail.nossr50.skills.utilities.CombatTools;
import com.gmail.nossr50.skills.utilities.SkillTools;
import com.gmail.nossr50.skills.utilities.SkillType;
import com.gmail.nossr50.util.Users;
public class SwordsManager extends SkillManager {
public SwordsManager(McMMOPlayer mcMMOPlayer) {
super(mcMMOPlayer, SkillType.SWORDS);
}
/**
* Check for Bleed effect.
*
* @param target The defending entity
*/
public void bleedCheck(LivingEntity target) {
Player player = getPlayer();
if (SkillTools.activationSuccessful(player, skill, Swords.bleedMaxChance, Swords.bleedMaxBonusLevel)) {
if (getSkillLevel() >= Swords.bleedMaxBonusLevel) {
BleedTimer.add(target, Swords.bleedMaxTicks);
}
else {
BleedTimer.add(target, Swords.bleedBaseTicks);
}
if (getProfile().useChatNotifications()) {
player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleeding"));
}
if (target instanceof Player) {
Player defender = (Player) target;
if (Users.getPlayer(defender).getProfile().useChatNotifications()) {
defender.sendMessage(LocaleLoader.getString("Swords.Combat.Bleeding.Started"));
}
}
}
}
public void counterAttackChecks(LivingEntity attacker, int damage) {
if (SkillTools.activationSuccessful(getPlayer(), skill, Swords.counterAttackMaxChance, Swords.counterAttackMaxBonusLevel)) {
CombatTools.dealDamage(attacker, damage / Swords.counterAttackModifier);
getPlayer().sendMessage(LocaleLoader.getString("Swords.Combat.Countered"));
if (attacker instanceof Player) {
((Player) attacker).sendMessage(LocaleLoader.getString("Swords.Combat.Counter.Hit"));
}
}
}
public void serratedStrikes(LivingEntity target, int damage) {
CombatTools.applyAbilityAoE(getPlayer(), target, damage / Swords.serratedStrikesModifier, skill);
BleedTimer.add(target, Swords.serratedStrikesBleedTicks);
}
}
package com.gmail.nossr50.skills.swords;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.runnables.skills.BleedTimerTask;
import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.CombatUtils;
import com.gmail.nossr50.util.skills.SkillUtils;
public class SwordsManager extends SkillManager {
public SwordsManager(McMMOPlayer mcMMOPlayer) {
super(mcMMOPlayer, SkillType.SWORDS);
}
/**
* Check for Bleed effect.
*
* @param target The defending entity
*/
public void bleedCheck(LivingEntity target) {
Player player = getPlayer();
if (SkillUtils.activationSuccessful(player, skill, Swords.bleedMaxChance, Swords.bleedMaxBonusLevel)) {
if (getSkillLevel() >= Swords.bleedMaxBonusLevel) {
BleedTimerTask.add(target, Swords.bleedMaxTicks);
}
else {
BleedTimerTask.add(target, Swords.bleedBaseTicks);
}
if (getProfile().useChatNotifications()) {
player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleeding"));
}
if (target instanceof Player) {
Player defender = (Player) target;
if (UserManager.getPlayer(defender).getProfile().useChatNotifications()) {
defender.sendMessage(LocaleLoader.getString("Swords.Combat.Bleeding.Started"));
}
}
}
}
public void counterAttackChecks(LivingEntity attacker, int damage) {
if (SkillUtils.activationSuccessful(getPlayer(), skill, Swords.counterAttackMaxChance, Swords.counterAttackMaxBonusLevel)) {
CombatUtils.dealDamage(attacker, damage / Swords.counterAttackModifier);
getPlayer().sendMessage(LocaleLoader.getString("Swords.Combat.Countered"));
if (attacker instanceof Player) {
((Player) attacker).sendMessage(LocaleLoader.getString("Swords.Combat.Counter.Hit"));
}
}
}
public void serratedStrikes(LivingEntity target, int damage) {
CombatUtils.applyAbilityAoE(getPlayer(), target, damage / Swords.serratedStrikesModifier, skill);
BleedTimerTask.add(target, Swords.serratedStrikesBleedTicks);
}
}

View File

@ -1,53 +1,54 @@
package com.gmail.nossr50.skills.taming;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.AnimalTamer;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Tameable;
import com.gmail.nossr50.locale.LocaleLoader;
public class BeastLoreEventHandler {
private Player player;
private LivingEntity livingEntity;
private Tameable beast;
protected BeastLoreEventHandler(Player player, LivingEntity livingEntity) {
this.player = player;
this.livingEntity = livingEntity;
this.beast = (Tameable) livingEntity;
}
protected void sendInspectMessage() {
if (player == null)
return;
String message = LocaleLoader.getString("Combat.BeastLore") + " ";
if (beast.isTamed()) {
message = message.concat(LocaleLoader.getString("Combat.BeastLoreOwner", getOwnerName()) + " ");
}
message = message.concat(LocaleLoader.getString("Combat.BeastLoreHealth", livingEntity.getHealth(), livingEntity.getMaxHealth()));
player.sendMessage(message);
}
/**
* Get the name of a tameable animal's owner.
*
* @return the name of the animal's owner
*/
private String getOwnerName() {
AnimalTamer tamer = beast.getOwner();
if (tamer instanceof Player) {
return ((Player) tamer).getName();
}
else if (tamer instanceof OfflinePlayer) {
return ((OfflinePlayer) tamer).getName();
}
return "Unknown Master";
}
}
package com.gmail.nossr50.skills.taming;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.AnimalTamer;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Tameable;
import com.gmail.nossr50.locale.LocaleLoader;
public class BeastLoreEventHandler {
private Player player;
private LivingEntity livingEntity;
private Tameable beast;
protected BeastLoreEventHandler(Player player, LivingEntity livingEntity) {
this.player = player;
this.livingEntity = livingEntity;
this.beast = (Tameable) livingEntity;
}
protected void sendInspectMessage() {
if (player == null) {
return;
}
String message = LocaleLoader.getString("Combat.BeastLore") + " ";
if (beast.isTamed()) {
message = message.concat(LocaleLoader.getString("Combat.BeastLoreOwner", getOwnerName()) + " ");
}
message = message.concat(LocaleLoader.getString("Combat.BeastLoreHealth", livingEntity.getHealth(), livingEntity.getMaxHealth()));
player.sendMessage(message);
}
/**
* Get the name of a tameable animal's owner.
*
* @return the name of the animal's owner
*/
private String getOwnerName() {
AnimalTamer tamer = beast.getOwner();
if (tamer instanceof Player) {
return ((Player) tamer).getName();
}
else if (tamer instanceof OfflinePlayer) {
return ((OfflinePlayer) tamer).getName();
}
return "Unknown Master";
}
}

View File

@ -1,102 +1,108 @@
package com.gmail.nossr50.skills.taming;
import org.bukkit.Material;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Ocelot;
import org.bukkit.entity.Player;
import org.bukkit.entity.Tameable;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.StringUtils;
public class CallOfTheWildEventHandler {
protected Player player;
protected ItemStack inHand;
protected EntityType type;
protected int summonAmount;
protected CallOfTheWildEventHandler(Player player, EntityType type, int summonAmount) {
this.player = player;
this.inHand = player.getItemInHand();
this.type = type;
this.summonAmount = summonAmount;
}
protected void sendInsufficientAmountMessage() {
if (player == null)
return;
player.sendMessage(LocaleLoader.getString("Skills.NeedMore", StringUtils.getPrettyItemString(inHand.getTypeId())));
}
protected boolean nearbyEntityExists() {
if (player == null)
return false;
boolean entityExists = false;
for (Entity entity : player.getNearbyEntities(40, 40, 40)) {
if (entity.getType() == type) {
entityExists = true;
break;
}
}
return entityExists;
}
protected void sendFailureMessage() {
if (player == null)
return;
if (type == EntityType.OCELOT) {
player.sendMessage(LocaleLoader.getString("Taming.Summon.Fail.Ocelot"));
}
else {
player.sendMessage(LocaleLoader.getString("Taming.Summon.Fail.Wolf"));
}
}
protected void spawnCreature() {
if (player == null)
return;
LivingEntity entity = (LivingEntity) player.getWorld().spawnEntity(player.getLocation(), type);
entity.setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue);
((Tameable) entity).setOwner(player);
if (type == EntityType.OCELOT) {
((Ocelot) entity).setCatType(Ocelot.Type.getType(1 + Misc.getRandom().nextInt(3)));
}
else {
entity.setHealth(entity.getMaxHealth());
}
}
protected void processResourceCost() {
if (player == null)
return;
int newAmount = inHand.getAmount() - summonAmount;
if (newAmount == 0) {
player.setItemInHand(new ItemStack(Material.AIR));
}
else {
player.getItemInHand().setAmount(inHand.getAmount() - summonAmount);
}
}
protected void sendSuccessMessage() {
if (player == null)
return;
player.sendMessage(LocaleLoader.getString("Taming.Summon.Complete"));
}
}
package com.gmail.nossr50.skills.taming;
import org.bukkit.Material;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Ocelot;
import org.bukkit.entity.Player;
import org.bukkit.entity.Tameable;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.StringUtils;
public class CallOfTheWildEventHandler {
protected Player player;
protected ItemStack inHand;
protected EntityType type;
protected int summonAmount;
protected CallOfTheWildEventHandler(Player player, EntityType type, int summonAmount) {
this.player = player;
this.inHand = player.getItemInHand();
this.type = type;
this.summonAmount = summonAmount;
}
protected void sendInsufficientAmountMessage() {
if (player == null) {
return;
}
player.sendMessage(LocaleLoader.getString("Skills.NeedMore", StringUtils.getPrettyItemString(inHand.getTypeId())));
}
protected boolean nearbyEntityExists() {
if (player == null) {
return false;
}
boolean entityExists = false;
for (Entity entity : player.getNearbyEntities(40, 40, 40)) {
if (entity.getType() == type) {
entityExists = true;
break;
}
}
return entityExists;
}
protected void sendFailureMessage() {
if (player == null) {
return;
}
if (type == EntityType.OCELOT) {
player.sendMessage(LocaleLoader.getString("Taming.Summon.Fail.Ocelot"));
}
else {
player.sendMessage(LocaleLoader.getString("Taming.Summon.Fail.Wolf"));
}
}
protected void spawnCreature() {
if (player == null) {
return;
}
LivingEntity entity = (LivingEntity) player.getWorld().spawnEntity(player.getLocation(), type);
entity.setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue);
((Tameable) entity).setOwner(player);
if (type == EntityType.OCELOT) {
((Ocelot) entity).setCatType(Ocelot.Type.getType(1 + Misc.getRandom().nextInt(3)));
}
else {
entity.setHealth(entity.getMaxHealth());
}
}
protected void processResourceCost() {
if (player == null) {
return;
}
int newAmount = inHand.getAmount() - summonAmount;
if (newAmount == 0) {
player.setItemInHand(new ItemStack(Material.AIR));
}
else {
player.getItemInHand().setAmount(inHand.getAmount() - summonAmount);
}
}
protected void sendSuccessMessage() {
if (player == null) {
return;
}
player.sendMessage(LocaleLoader.getString("Taming.Summon.Complete"));
}
}

View File

@ -1,27 +1,27 @@
package com.gmail.nossr50.skills.taming;
import org.bukkit.entity.Wolf;
public class FastFoodServiceEventHandler {
private Wolf wolf;
public FastFoodServiceEventHandler (Wolf wolf) {
this.wolf = wolf;
}
protected void modifyHealth(int damage) {
int health = wolf.getHealth();
int maxHealth = wolf.getMaxHealth();
if (health < maxHealth) {
int newHealth = health + damage;
if (newHealth <= maxHealth) {
wolf.setHealth(newHealth);
}
else {
wolf.setHealth(maxHealth);
}
}
}
}
package com.gmail.nossr50.skills.taming;
import org.bukkit.entity.Wolf;
public class FastFoodServiceEventHandler {
private Wolf wolf;
public FastFoodServiceEventHandler(Wolf wolf) {
this.wolf = wolf;
}
protected void modifyHealth(int damage) {
int health = wolf.getHealth();
int maxHealth = wolf.getMaxHealth();
if (health < maxHealth) {
int newHealth = health + damage;
if (newHealth <= maxHealth) {
wolf.setHealth(newHealth);
}
else {
wolf.setHealth(maxHealth);
}
}
}
}

View File

@ -1,44 +1,44 @@
package com.gmail.nossr50.skills.taming;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageEvent;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.runnables.BleedTimer;
import com.gmail.nossr50.skills.utilities.SkillTools;
public class GoreEventHandler {
private TamingManager manager;
private EntityDamageEvent event;
private Entity entity;
protected int skillModifier;
protected GoreEventHandler(TamingManager manager, EntityDamageEvent event) {
this.manager = manager;
this.event = event;
this.entity = event.getEntity();
calculateSkillModifier();
}
protected void calculateSkillModifier() {
this.skillModifier = SkillTools.skillCheck(manager.getSkillLevel(), Taming.goreMaxBonusLevel);
}
protected void modifyEventDamage() {
event.setDamage(event.getDamage() * Taming.goreModifier);
}
protected void sendAbilityMessage() {
if (entity instanceof Player) {
((Player) entity).sendMessage(LocaleLoader.getString("Combat.StruckByGore"));
}
manager.getMcMMOPlayer().getPlayer().sendMessage(LocaleLoader.getString("Combat.Gore"));
}
protected void applyBleed() {
BleedTimer.add((LivingEntity) entity, Taming.goreBleedTicks);
}
}
package com.gmail.nossr50.skills.taming;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageEvent;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.runnables.skills.BleedTimerTask;
import com.gmail.nossr50.util.skills.SkillUtils;
public class GoreEventHandler {
private TamingManager manager;
private EntityDamageEvent event;
private Entity entity;
protected int skillModifier;
protected GoreEventHandler(TamingManager manager, EntityDamageEvent event) {
this.manager = manager;
this.event = event;
this.entity = event.getEntity();
calculateSkillModifier();
}
protected void calculateSkillModifier() {
this.skillModifier = SkillUtils.skillCheck(manager.getSkillLevel(), Taming.goreMaxBonusLevel);
}
protected void modifyEventDamage() {
event.setDamage(event.getDamage() * Taming.goreModifier);
}
protected void sendAbilityMessage() {
if (entity instanceof Player) {
((Player) entity).sendMessage(LocaleLoader.getString("Combat.StruckByGore"));
}
manager.getMcMMOPlayer().getPlayer().sendMessage(LocaleLoader.getString("Combat.Gore"));
}
protected void applyBleed() {
BleedTimerTask.add((LivingEntity) entity, Taming.goreBleedTicks);
}
}

View File

@ -1,15 +1,15 @@
package com.gmail.nossr50.skills.taming;
import org.bukkit.event.entity.EntityDamageEvent;
public class SharpenedClawsEventHandler {
private EntityDamageEvent event;
public SharpenedClawsEventHandler (EntityDamageEvent event) {
this.event = event;
}
protected void modifyEventDamage() {
event.setDamage(event.getDamage() + Taming.sharpenedClawsBonusDamage);
}
}
package com.gmail.nossr50.skills.taming;
import org.bukkit.event.entity.EntityDamageEvent;
public class SharpenedClawsEventHandler {
private EntityDamageEvent event;
public SharpenedClawsEventHandler(EntityDamageEvent event) {
this.event = event;
}
protected void modifyEventDamage() {
event.setDamage(event.getDamage() + Taming.sharpenedClawsBonusDamage);
}
}

View File

@ -8,33 +8,33 @@ import org.bukkit.entity.Wolf;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.utilities.SkillTools;
import com.gmail.nossr50.skills.utilities.SkillType;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.skills.SkillUtils;
public class Taming {
public static int environmentallyAwareUnlockLevel = AdvancedConfig.getInstance().getEnviromentallyAwareUnlock();
public static int holyHoundUnlockLevel = AdvancedConfig.getInstance().getHolyHoundUnlock();
public static int holyHoundUnlockLevel = AdvancedConfig.getInstance().getHolyHoundUnlock();
public static int fastFoodServiceUnlockLevel = AdvancedConfig.getInstance().getFastFoodUnlock();
public static double fastFoodServiceActivationChance = AdvancedConfig.getInstance().getFastFoodChance();
public static int fastFoodServiceUnlockLevel = AdvancedConfig.getInstance().getFastFoodUnlock();
public static int goreBleedTicks = AdvancedConfig.getInstance().getGoreBleedTicks();
public static int goreMaxBonusLevel = AdvancedConfig.getInstance().getGoreMaxBonusLevel();
public static int goreModifier = AdvancedConfig.getInstance().getGoreModifier();
public static double goreMaxChance = AdvancedConfig.getInstance().getGoreChanceMax();
public static int goreBleedTicks = AdvancedConfig.getInstance().getGoreBleedTicks();
public static int goreMaxBonusLevel = AdvancedConfig.getInstance().getGoreMaxBonusLevel();
public static int goreModifier = AdvancedConfig.getInstance().getGoreModifier();
public static int sharpenedClawsUnlockLevel = AdvancedConfig.getInstance().getSharpenedClawsUnlock();
public static int sharpenedClawsBonusDamage = AdvancedConfig.getInstance().getSharpenedClawsBonus();
public static int shockProofUnlockLevel = AdvancedConfig.getInstance().getShockProofUnlock();
public static int shockProofModifier = AdvancedConfig.getInstance().getShockProofModifier();
public static int shockProofModifier = AdvancedConfig.getInstance().getShockProofModifier();
public static int thickFurUnlockLevel = AdvancedConfig.getInstance().getThickFurUnlock();
public static int thickFurModifier = AdvancedConfig.getInstance().getThickFurModifier();
public static int thickFurModifier = AdvancedConfig.getInstance().getThickFurModifier();
public static int wolfXp = Config.getInstance().getTamingXPWolf();
public static int wolfXp = Config.getInstance().getTamingXPWolf();
public static int ocelotXp = Config.getInstance().getTamingXPOcelot();
public static boolean canPreventDamage(Tameable pet, AnimalTamer owner) {
@ -42,19 +42,19 @@ public class Taming {
}
public static boolean canUseThickFur(Player player) {
return SkillTools.unlockLevelReached(player, SkillType.TAMING, thickFurUnlockLevel) && Permissions.thickFur(player);
return SkillUtils.unlockLevelReached(player, SkillType.TAMING, thickFurUnlockLevel) && Permissions.thickFur(player);
}
public static boolean canUseEnvironmentallyAware(Player player) {
return SkillTools.unlockLevelReached(player, SkillType.TAMING, environmentallyAwareUnlockLevel) && Permissions.environmentallyAware(player);
return SkillUtils.unlockLevelReached(player, SkillType.TAMING, environmentallyAwareUnlockLevel) && Permissions.environmentallyAware(player);
}
public static boolean canUseShockProof(Player player) {
return SkillTools.unlockLevelReached(player, SkillType.TAMING, shockProofUnlockLevel) && Permissions.shockProof(player);
return SkillUtils.unlockLevelReached(player, SkillType.TAMING, shockProofUnlockLevel) && Permissions.shockProof(player);
}
public static boolean canUseHolyHound(Player player) {
return SkillTools.unlockLevelReached(player, SkillType.TAMING, holyHoundUnlockLevel) && Permissions.holyHound(player);
return SkillUtils.unlockLevelReached(player, SkillType.TAMING, holyHoundUnlockLevel) && Permissions.holyHound(player);
}
public static int processThickFur(Wolf wolf, int damage) {

View File

@ -1,165 +0,0 @@
package com.gmail.nossr50.skills.taming;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.SkillCommand;
import com.gmail.nossr50.skills.utilities.SkillType;
import com.gmail.nossr50.util.Permissions;
public class TamingCommand extends SkillCommand {
private String goreChance;
private String goreChanceLucky;
private boolean canBeastLore;
private boolean canGore;
private boolean canSharpenedClaws;
private boolean canEnvironmentallyAware;
private boolean canThickFur;
private boolean canShockProof;
private boolean canCallWild;
private boolean canFastFood;
private boolean canHolyHound;
public TamingCommand() {
super(SkillType.TAMING);
}
@Override
protected void dataCalculations() {
String[] goreStrings = calculateAbilityDisplayValues(Taming.goreMaxBonusLevel, Taming.goreMaxChance);
goreChance = goreStrings[0];
goreChanceLucky = goreStrings[1];
}
@Override
protected void permissionsCheck() {
canBeastLore = Permissions.beastLore(player);
canCallWild = Permissions.callOfTheWild(player);
canEnvironmentallyAware = Permissions.environmentallyAware(player);
canFastFood = Permissions.fastFoodService(player);
canGore = Permissions.gore(player);
canSharpenedClaws = Permissions.sharpenedClaws(player);
canShockProof = Permissions.shockProof(player);
canThickFur = Permissions.thickFur(player);
canHolyHound = Permissions.holyHound(player);
}
@Override
protected boolean effectsHeaderPermissions() {
return canBeastLore || canCallWild || canEnvironmentallyAware || canFastFood || canGore || canSharpenedClaws || canShockProof || canThickFur || canHolyHound;
}
@Override
protected void effectsDisplay() {
luckyEffectsDisplay();
if (canBeastLore) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.0"), LocaleLoader.getString("Taming.Effect.1")));
}
if (canGore) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.2"), LocaleLoader.getString("Taming.Effect.3")));
}
if (canSharpenedClaws) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.4"), LocaleLoader.getString("Taming.Effect.5")));
}
if (canEnvironmentallyAware) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.6"), LocaleLoader.getString("Taming.Effect.7")));
}
if (canThickFur) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.8"), LocaleLoader.getString("Taming.Effect.9")));
}
if (canShockProof) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.10"), LocaleLoader.getString("Taming.Effect.11")));
}
if (canFastFood) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.16"), LocaleLoader.getString("Taming.Effect.17")));
}
if (canHolyHound) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.18"), LocaleLoader.getString("Taming.Effect.19")));
}
if (canCallWild) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.12"), LocaleLoader.getString("Taming.Effect.13")));
player.sendMessage(LocaleLoader.getString("Taming.Effect.14", Config.getInstance().getTamingCOTWOcelotCost()));
player.sendMessage(LocaleLoader.getString("Taming.Effect.15", Config.getInstance().getTamingCOTWWolfCost()));
}
}
@Override
protected boolean statsHeaderPermissions() {
return canEnvironmentallyAware || canFastFood || canGore || canSharpenedClaws || canShockProof || canThickFur || canHolyHound;
}
@Override
protected void statsDisplay() {
if (canFastFood) {
if (skillValue < Taming.fastFoodServiceUnlockLevel) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Taming.Ability.Locked.4", Taming.fastFoodServiceUnlockLevel)));
}
else {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Taming.Ability.Bonus.8"), LocaleLoader.getString("Taming.Ability.Bonus.9", percent.format(Taming.fastFoodServiceActivationChance / 100D))));
}
}
if (canEnvironmentallyAware) {
if (skillValue < Taming.environmentallyAwareUnlockLevel) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Taming.Ability.Locked.0", Taming.environmentallyAwareUnlockLevel)));
}
else {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Taming.Ability.Bonus.0"), LocaleLoader.getString("Taming.Ability.Bonus.1")));
}
}
if (canThickFur) {
if (skillValue < Taming.thickFurUnlockLevel) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Taming.Ability.Locked.1", Taming.thickFurUnlockLevel)));
}
else {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Taming.Ability.Bonus.2"), LocaleLoader.getString("Taming.Ability.Bonus.3", Taming.thickFurModifier)));
}
}
if (canHolyHound) {
if (skillValue < Taming.holyHoundUnlockLevel) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Taming.Ability.Locked.5", Taming.holyHoundUnlockLevel)));
}
else {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Taming.Ability.Bonus.10"), LocaleLoader.getString("Taming.Ability.Bonus.11")));
}
}
if (canShockProof) {
if (skillValue < Taming.shockProofUnlockLevel) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Taming.Ability.Locked.2", Taming.shockProofUnlockLevel)));
}
else {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Taming.Ability.Bonus.4"), LocaleLoader.getString("Taming.Ability.Bonus.5", Taming.shockProofModifier)));
}
}
if (canSharpenedClaws) {
if (skillValue < Taming.sharpenedClawsUnlockLevel) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Taming.Ability.Locked.3", Taming.sharpenedClawsUnlockLevel)));
}
else {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Taming.Ability.Bonus.6"), LocaleLoader.getString("Taming.Ability.Bonus.7", Taming.sharpenedClawsBonusDamage)));
}
}
if (canGore) {
if (isLucky) {
player.sendMessage(LocaleLoader.getString("Taming.Combat.Chance.Gore", goreChance) + LocaleLoader.getString("Perks.lucky.bonus", goreChanceLucky));
}
else {
player.sendMessage(LocaleLoader.getString("Taming.Combat.Chance.Gore", goreChance));
}
}
}
}

View File

@ -1,145 +1,145 @@
package com.gmail.nossr50.skills.taming;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Wolf;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityTameEvent;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.McMMOPlayer;
import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.skills.utilities.SkillTools;
import com.gmail.nossr50.skills.utilities.SkillType;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
public class TamingManager extends SkillManager {
public TamingManager(McMMOPlayer mcMMOPlayer) {
super(mcMMOPlayer, SkillType.TAMING);
}
/**
* Award XP for taming.
*
* @param event The event to award XP for
*/
public void awardTamingXP(LivingEntity entity) {
switch (entity.getType()) {
case WOLF:
applyXpGain(Taming.wolfXp);
return;
case OCELOT:
applyXpGain(Taming.ocelotXp);
return;
default:
return;
}
}
/**
* Apply the Fast Food Service ability.
*
* @param wolf The wolf using the ability
* @param damage The damage being absorbed by the wolf
*/
public void fastFoodService(Wolf wolf, int damage) {
if (SkillTools.activationSuccessful(getPlayer(), skill, Taming.fastFoodServiceActivationChance)) {
int health = wolf.getHealth();
int maxHealth = wolf.getMaxHealth();
if (health < maxHealth) {
int newHealth = health + damage;
wolf.setHealth(Math.min(newHealth, maxHealth));
}
}
}
/**
* Apply the Sharpened Claws ability.
*
* @param event The event to modify
*/
public void sharpenedClaws(EntityDamageEvent event) {
SharpenedClawsEventHandler eventHandler = new SharpenedClawsEventHandler(event);
eventHandler.modifyEventDamage();
}
/**
* Apply the Gore ability.
*
* @param event The event to modify
*/
public void gore(EntityDamageEvent event) {
GoreEventHandler eventHandler = new GoreEventHandler(this, event);
float chance = (float) ((Taming.goreMaxChance / Taming.goreMaxBonusLevel) * getSkillLevel());
if (chance > Taming.goreMaxChance) chance = (float) Taming.goreMaxChance;
if (chance > Misc.getRandom().nextInt(activationChance)) {
eventHandler.modifyEventDamage();
eventHandler.applyBleed();
eventHandler.sendAbilityMessage();
}
}
/**
* Summon an ocelot to your side.
*/
public void summonOcelot() {
callOfTheWild(EntityType.OCELOT, Config.getInstance().getTamingCOTWOcelotCost());
}
/**
* Summon a wolf to your side.
*/
public void summonWolf() {
callOfTheWild(EntityType.WOLF, Config.getInstance().getTamingCOTWWolfCost());
}
/**
* Handle the Beast Lore ability.
*
* @param livingEntity The entity to examine
*/
public void beastLore(LivingEntity livingEntity) {
BeastLoreEventHandler eventHandler = new BeastLoreEventHandler(mcMMOPlayer.getPlayer(), livingEntity);
eventHandler.sendInspectMessage();
}
/**
* Handle the Call of the Wild ability.
*
* @param type The type of entity to summon.
* @param summonAmount The amount of material needed to summon the entity
*/
private void callOfTheWild(EntityType type, int summonAmount) {
if (!Permissions.callOfTheWild(mcMMOPlayer.getPlayer())) {
return;
}
CallOfTheWildEventHandler eventHandler = new CallOfTheWildEventHandler(mcMMOPlayer.getPlayer(), type, summonAmount);
ItemStack inHand = eventHandler.inHand;
int inHandAmount = inHand.getAmount();
if (inHandAmount < summonAmount) {
eventHandler.sendInsufficientAmountMessage();
return;
}
if (eventHandler.nearbyEntityExists()) {
eventHandler.sendFailureMessage();
}
else {
eventHandler.spawnCreature();
eventHandler.processResourceCost();
eventHandler.sendSuccessMessage();
}
}
}
package com.gmail.nossr50.skills.taming;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Wolf;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.skills.SkillUtils;
public class TamingManager extends SkillManager {
public TamingManager(McMMOPlayer mcMMOPlayer) {
super(mcMMOPlayer, SkillType.TAMING);
}
/**
* Award XP for taming.
*
* @param event The event to award XP for
*/
public void awardTamingXP(LivingEntity entity) {
switch (entity.getType()) {
case WOLF:
applyXpGain(Taming.wolfXp);
return;
case OCELOT:
applyXpGain(Taming.ocelotXp);
return;
default:
return;
}
}
/**
* Apply the Fast Food Service ability.
*
* @param wolf The wolf using the ability
* @param damage The damage being absorbed by the wolf
*/
public void fastFoodService(Wolf wolf, int damage) {
if (SkillUtils.activationSuccessful(getPlayer(), skill, Taming.fastFoodServiceActivationChance)) {
int health = wolf.getHealth();
int maxHealth = wolf.getMaxHealth();
if (health < maxHealth) {
int newHealth = health + damage;
wolf.setHealth(Math.min(newHealth, maxHealth));
}
}
}
/**
* Apply the Sharpened Claws ability.
*
* @param event The event to modify
*/
public void sharpenedClaws(EntityDamageEvent event) {
SharpenedClawsEventHandler eventHandler = new SharpenedClawsEventHandler(event);
eventHandler.modifyEventDamage();
}
/**
* Apply the Gore ability.
*
* @param event The event to modify
*/
public void gore(EntityDamageEvent event) {
GoreEventHandler eventHandler = new GoreEventHandler(this, event);
float chance = (float) ((Taming.goreMaxChance / Taming.goreMaxBonusLevel) * getSkillLevel());
if (chance > Taming.goreMaxChance) {
chance = (float) Taming.goreMaxChance;
}
if (chance > Misc.getRandom().nextInt(activationChance)) {
eventHandler.modifyEventDamage();
eventHandler.applyBleed();
eventHandler.sendAbilityMessage();
}
}
/**
* Summon an ocelot to your side.
*/
public void summonOcelot() {
callOfTheWild(EntityType.OCELOT, Config.getInstance().getTamingCOTWOcelotCost());
}
/**
* Summon a wolf to your side.
*/
public void summonWolf() {
callOfTheWild(EntityType.WOLF, Config.getInstance().getTamingCOTWWolfCost());
}
/**
* Handle the Beast Lore ability.
*
* @param livingEntity The entity to examine
*/
public void beastLore(LivingEntity livingEntity) {
BeastLoreEventHandler eventHandler = new BeastLoreEventHandler(mcMMOPlayer.getPlayer(), livingEntity);
eventHandler.sendInspectMessage();
}
/**
* Handle the Call of the Wild ability.
*
* @param type The type of entity to summon.
* @param summonAmount The amount of material needed to summon the entity
*/
private void callOfTheWild(EntityType type, int summonAmount) {
if (!Permissions.callOfTheWild(mcMMOPlayer.getPlayer())) {
return;
}
CallOfTheWildEventHandler eventHandler = new CallOfTheWildEventHandler(mcMMOPlayer.getPlayer(), type, summonAmount);
ItemStack inHand = eventHandler.inHand;
int inHandAmount = inHand.getAmount();
if (inHandAmount < summonAmount) {
eventHandler.sendInsufficientAmountMessage();
return;
}
if (eventHandler.nearbyEntityExists()) {
eventHandler.sendFailureMessage();
}
else {
eventHandler.spawnCreature();
eventHandler.processResourceCost();
eventHandler.sendSuccessMessage();
}
}
}

View File

@ -1,46 +1,46 @@
package com.gmail.nossr50.skills.unarmed;
import org.bukkit.Material;
import org.bukkit.block.BlockState;
import org.bukkit.entity.Player;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.skills.utilities.SkillTools;
public class Unarmed {
public static int ironArmMaxBonusDamage = AdvancedConfig.getInstance().getIronArmMaxBonus();
public static int ironArmIncreaseLevel = AdvancedConfig.getInstance().getIronArmIncreaseLevel();
public static double disarmMaxChance = AdvancedConfig.getInstance().getDisarmChanceMax() ;
public static int disarmMaxBonusLevel = AdvancedConfig.getInstance().getDisarmMaxBonusLevel();
public static double deflectMaxChance = AdvancedConfig.getInstance().getDeflectChanceMax();
public static int deflectMaxBonusLevel = AdvancedConfig.getInstance().getDeflectMaxBonusLevel();
public static double ironGripMaxChance = AdvancedConfig.getInstance().getIronGripChanceMax();
public static int ironGripMaxBonusLevel = AdvancedConfig.getInstance().getIronGripMaxBonusLevel();
public static boolean blockCrackerSmoothBrick = Config.getInstance().getUnarmedBlockCrackerSmoothbrickToCracked();
public static double berserkDamageModifier = 1.5;
public static boolean blockCracker(Player player, BlockState blockState) {
if (SkillTools.blockBreakSimulate(blockState.getBlock(), player, false)) {
Material type = blockState.getType();
switch (type) {
case SMOOTH_BRICK:
if (blockCrackerSmoothBrick && blockState.getRawData() == (byte) 0x0) {
blockState.setRawData((byte) 0x2);
}
return true;
default:
return false;
}
}
return false;
}
}
package com.gmail.nossr50.skills.unarmed;
import org.bukkit.Material;
import org.bukkit.block.BlockState;
import org.bukkit.entity.Player;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.util.skills.SkillUtils;
public class Unarmed {
public static int ironArmMaxBonusDamage = AdvancedConfig.getInstance().getIronArmMaxBonus();
public static int ironArmIncreaseLevel = AdvancedConfig.getInstance().getIronArmIncreaseLevel();
public static int disarmMaxBonusLevel = AdvancedConfig.getInstance().getDisarmMaxBonusLevel();
public static double disarmMaxChance = AdvancedConfig.getInstance().getDisarmChanceMax();
public static int deflectMaxBonusLevel = AdvancedConfig.getInstance().getDeflectMaxBonusLevel();
public static double deflectMaxChance = AdvancedConfig.getInstance().getDeflectChanceMax();
public static int ironGripMaxBonusLevel = AdvancedConfig.getInstance().getIronGripMaxBonusLevel();
public static double ironGripMaxChance = AdvancedConfig.getInstance().getIronGripChanceMax();
public static boolean blockCrackerSmoothBrick = Config.getInstance().getUnarmedBlockCrackerSmoothbrickToCracked();
public static double berserkDamageModifier = 1.5;
public static boolean blockCracker(Player player, BlockState blockState) {
if (SkillUtils.blockBreakSimulate(blockState.getBlock(), player, false)) {
Material type = blockState.getType();
switch (type) {
case SMOOTH_BRICK:
if (blockCrackerSmoothBrick && blockState.getRawData() == (byte) 0x0) {
blockState.setRawData((byte) 0x2);
}
return true;
default:
return false;
}
}
return false;
}
}

View File

@ -1,146 +0,0 @@
package com.gmail.nossr50.skills.unarmed;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.SkillCommand;
import com.gmail.nossr50.skills.utilities.SkillType;
import com.gmail.nossr50.util.Permissions;
public class UnarmedCommand extends SkillCommand {
private String berserkLength;
private String berserkLengthEndurance;
private String deflectChance;
private String deflectChanceLucky;
private String disarmChance;
private String disarmChanceLucky;
private String ironGripChance;
private String ironGripChanceLucky;
private String ironArmBonus;
private boolean canBerserk;
private boolean canDisarm;
private boolean canBonusDamage;
private boolean canDeflect;
private boolean canIronGrip;
public UnarmedCommand() {
super(SkillType.UNARMED);
}
@Override
protected void dataCalculations() {
//BERSERK
String[] berserkStrings = calculateLengthDisplayValues();
berserkLength = berserkStrings[0];
berserkLengthEndurance = berserkStrings[1];
//DISARM
String[] disarmStrings = calculateAbilityDisplayValues(Unarmed.disarmMaxBonusLevel, Unarmed.disarmMaxChance);
disarmChance = disarmStrings[0];
disarmChanceLucky = disarmStrings[1];
//DEFLECT
String[] deflectStrings = calculateAbilityDisplayValues(Unarmed.deflectMaxBonusLevel, Unarmed.deflectMaxChance);
deflectChance = deflectStrings[0];
deflectChanceLucky = deflectStrings[1];
//IRON ARM
if (skillValue >= ((Unarmed.ironArmMaxBonusDamage - 3) * Unarmed.ironArmIncreaseLevel)) {
ironArmBonus = String.valueOf(Unarmed.ironArmMaxBonusDamage);
}
else {
ironArmBonus = String.valueOf(3 + (skillValue / Unarmed.ironArmIncreaseLevel));
}
//IRON GRIP
String[] ironGripStrings = calculateAbilityDisplayValues(Unarmed.ironGripMaxBonusLevel, Unarmed.ironGripMaxChance);
ironGripChance = ironGripStrings[0];
ironGripChanceLucky = ironGripStrings[1];
}
@Override
protected void permissionsCheck() {
canBerserk = Permissions.berserk(player);
canBonusDamage = Permissions.bonusDamage(player, skill);
canDeflect = Permissions.arrowDeflect(player);
canDisarm = Permissions.disarm(player);
canIronGrip = Permissions.ironGrip(player);
}
@Override
protected boolean effectsHeaderPermissions() {
return canBerserk || canBonusDamage || canDeflect || canDisarm || canIronGrip;
}
@Override
protected void effectsDisplay() {
luckyEffectsDisplay();
if (canBerserk) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Unarmed.Effect.0"), LocaleLoader.getString("Unarmed.Effect.1")));
}
if (canDisarm) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Unarmed.Effect.2"), LocaleLoader.getString("Unarmed.Effect.3")));
}
if (canBonusDamage) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Unarmed.Effect.4"), LocaleLoader.getString("Unarmed.Effect.5")));
}
if (canDeflect) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Unarmed.Effect.6"), LocaleLoader.getString("Unarmed.Effect.7")));
}
if (canIronGrip) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Unarmed.Effect.8"), LocaleLoader.getString("Unarmed.Effect.9")));
}
}
@Override
protected boolean statsHeaderPermissions() {
return canBerserk || canBonusDamage || canDeflect || canDisarm || canIronGrip;
}
@Override
protected void statsDisplay() {
if (canBonusDamage) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Unarmed.Ability.Bonus.0"), LocaleLoader.getString("Unarmed.Ability.Bonus.1", ironArmBonus)));
}
if (canDeflect) {
if (isLucky) {
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.ArrowDeflect", deflectChance) + LocaleLoader.getString("Perks.lucky.bonus", deflectChanceLucky));
}
else {
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.ArrowDeflect", deflectChance));
}
}
if (canDisarm) {
if (isLucky) {
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.Disarm", disarmChance) + LocaleLoader.getString("Perks.lucky.bonus", disarmChanceLucky));
}
else {
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.Disarm", disarmChance));
}
}
if (canIronGrip) {
if (isLucky) {
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.IronGrip", ironGripChance) + LocaleLoader.getString("Perks.lucky.bonus", ironGripChanceLucky));
}
else {
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.IronGrip", ironGripChance));
}
}
if (canBerserk) {
if (hasEndurance) {
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Berserk.Length", berserkLength) + LocaleLoader.getString("Perks.activationtime.bonus", berserkLengthEndurance));
}
else {
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Berserk.Length", berserkLength));
}
}
}
}

View File

@ -1,87 +1,87 @@
package com.gmail.nossr50.skills.unarmed;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.McMMOPlayer;
import com.gmail.nossr50.events.skills.McMMOPlayerDisarmEvent;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.skills.utilities.SkillTools;
import com.gmail.nossr50.skills.utilities.SkillType;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
public class UnarmedManager extends SkillManager {
public UnarmedManager(McMMOPlayer mcMMOPlayer) {
super(mcMMOPlayer, SkillType.UNARMED);
}
/**
* Check for disarm.
*
* @param defender The defending player
*/
public void disarmCheck(Player defender) {
if (SkillTools.activationSuccessful(getPlayer(), skill, Unarmed.disarmMaxChance, Unarmed.disarmMaxBonusLevel) && !hasIronGrip(defender)) {
McMMOPlayerDisarmEvent disarmEvent = new McMMOPlayerDisarmEvent(defender);
mcMMO.p.getServer().getPluginManager().callEvent(disarmEvent);
if (!disarmEvent.isCancelled()) {
Misc.dropItem(defender.getLocation(), defender.getItemInHand());
defender.setItemInHand(new ItemStack(Material.AIR));
defender.sendMessage(LocaleLoader.getString("Skills.Disarmed"));
}
}
}
/**
* Check for arrow deflection.
*/
public boolean deflectCheck() {
Player player = getPlayer();
if (SkillTools.activationSuccessful(player, skill, Unarmed.deflectMaxChance, Unarmed.deflectMaxBonusLevel)) {
player.sendMessage(LocaleLoader.getString("Combat.ArrowDeflect"));
return true;
}
return false;
}
public int berserkDamage(int damage) {
return (int) (damage * Unarmed.berserkDamageModifier);
}
/**
* Handle the effects of the Iron Arm ability
*
* @param damage The amount of damage initially dealt by the event
* @return the modified event damage
*/
public int ironArmCheck(int damage) {
int unarmedBonus = Math.min(3 + (getSkillLevel() / Unarmed.ironArmIncreaseLevel), Unarmed.ironArmMaxBonusDamage);
return damage + unarmedBonus;
}
/**
* Check Iron Grip ability success
*
* @param defender The defending player
* @return true if the defender was not disarmed, false otherwise
*/
private boolean hasIronGrip(Player defender) {
if (!Misc.isNPCEntity(defender) && Permissions.ironGrip(defender) && SkillTools.activationSuccessful(defender, skill, Unarmed.ironGripMaxChance, Unarmed.ironGripMaxBonusLevel)) {
defender.sendMessage(LocaleLoader.getString("Unarmed.Ability.IronGrip.Defender"));
getPlayer().sendMessage(LocaleLoader.getString("Unarmed.Ability.IronGrip.Attacker"));
return true;
}
return false;
}
}
package com.gmail.nossr50.skills.unarmed;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.events.skills.unarmed.McMMOPlayerDisarmEvent;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.skills.SkillUtils;
public class UnarmedManager extends SkillManager {
public UnarmedManager(McMMOPlayer mcMMOPlayer) {
super(mcMMOPlayer, SkillType.UNARMED);
}
/**
* Check for disarm.
*
* @param defender The defending player
*/
public void disarmCheck(Player defender) {
if (SkillUtils.activationSuccessful(getPlayer(), skill, Unarmed.disarmMaxChance, Unarmed.disarmMaxBonusLevel) && !hasIronGrip(defender)) {
McMMOPlayerDisarmEvent disarmEvent = new McMMOPlayerDisarmEvent(defender);
mcMMO.p.getServer().getPluginManager().callEvent(disarmEvent);
if (!disarmEvent.isCancelled()) {
Misc.dropItem(defender.getLocation(), defender.getItemInHand());
defender.setItemInHand(new ItemStack(Material.AIR));
defender.sendMessage(LocaleLoader.getString("Skills.Disarmed"));
}
}
}
/**
* Check for arrow deflection.
*/
public boolean deflectCheck() {
Player player = getPlayer();
if (SkillUtils.activationSuccessful(player, skill, Unarmed.deflectMaxChance, Unarmed.deflectMaxBonusLevel)) {
player.sendMessage(LocaleLoader.getString("Combat.ArrowDeflect"));
return true;
}
return false;
}
public int berserkDamage(int damage) {
return (int) (damage * Unarmed.berserkDamageModifier);
}
/**
* Handle the effects of the Iron Arm ability
*
* @param damage The amount of damage initially dealt by the event
* @return the modified event damage
*/
public int ironArmCheck(int damage) {
int unarmedBonus = Math.min(3 + (getSkillLevel() / Unarmed.ironArmIncreaseLevel), Unarmed.ironArmMaxBonusDamage);
return damage + unarmedBonus;
}
/**
* Check Iron Grip ability success
*
* @param defender The defending player
* @return true if the defender was not disarmed, false otherwise
*/
private boolean hasIronGrip(Player defender) {
if (!Misc.isNPCEntity(defender) && Permissions.ironGrip(defender) && SkillUtils.activationSuccessful(defender, skill, Unarmed.ironGripMaxChance, Unarmed.ironGripMaxBonusLevel)) {
defender.sendMessage(LocaleLoader.getString("Unarmed.Ability.IronGrip.Defender"));
getPlayer().sendMessage(LocaleLoader.getString("Unarmed.Ability.IronGrip.Attacker"));
return true;
}
return false;
}
}

View File

@ -1,211 +0,0 @@
package com.gmail.nossr50.skills.utilities;
import org.bukkit.Material;
import org.bukkit.block.BlockState;
import org.bukkit.entity.Player;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.BlockChecks;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.StringUtils;
public enum AbilityType {
BERSERK(
"Unarmed.Skills.Berserk.On",
"Unarmed.Skills.Berserk.Off",
"Unarmed.Skills.Berserk.Other.On",
"Unarmed.Skills.Berserk.Refresh",
"Unarmed.Skills.Berserk.Other.Off"),
SUPER_BREAKER(
"Mining.Skills.SuperBreaker.On",
"Mining.Skills.SuperBreaker.Off",
"Mining.Skills.SuperBreaker.Other.On",
"Mining.Skills.SuperBreaker.Refresh",
"Mining.Skills.SuperBreaker.Other.Off"),
GIGA_DRILL_BREAKER(
"Excavation.Skills.GigaDrillBreaker.On",
"Excavation.Skills.GigaDrillBreaker.Off",
"Excavation.Skills.GigaDrillBreaker.Other.On",
"Excavation.Skills.GigaDrillBreaker.Refresh",
"Excavation.Skills.GigaDrillBreaker.Other.Off"),
GREEN_TERRA(
"Herbalism.Skills.GTe.On",
"Herbalism.Skills.GTe.Off",
"Herbalism.Skills.GTe.Other.On",
"Herbalism.Skills.GTe.Refresh",
"Herbalism.Skills.GTe.Other.Off"),
SKULL_SPLITTER(
"Axes.Skills.SS.On",
"Axes.Skills.SS.Off",
"Axes.Skills.SS.Other.On",
"Axes.Skills.SS.Refresh",
"Axes.Skills.SS.Other.Off"),
TREE_FELLER(
"Woodcutting.Skills.TreeFeller.On",
"Woodcutting.Skills.TreeFeller.Off",
"Woodcutting.Skills.TreeFeller.Other.On",
"Woodcutting.Skills.TreeFeller.Refresh",
"Woodcutting.Skills.TreeFeller.Other.Off"),
SERRATED_STRIKES(
"Swords.Skills.SS.On",
"Swords.Skills.SS.Off",
"Swords.Skills.SS.Other.On",
"Swords.Skills.SS.Refresh",
"Swords.Skills.SS.Other.Off"),
BLAST_MINING(
null,
null,
"Mining.Blast.Other.On",
"Mining.Blast.Refresh",
null),
LEAF_BLOWER(
null,
null,
null,
null,
null);
private String abilityOn;
private String abilityOff;
private String abilityPlayer;
private String abilityRefresh;
private String abilityPlayerOff;
private AbilityType(String abilityOn, String abilityOff, String abilityPlayer, String abilityRefresh, String abilityPlayerOff) {
this.abilityOn = abilityOn;
this.abilityOff = abilityOff;
this.abilityPlayer = abilityPlayer;
this.abilityRefresh = abilityRefresh;
this.abilityPlayerOff = abilityPlayerOff;
}
public int getCooldown() {
return Config.getInstance().getCooldown(this);
}
public int getMaxTicks() {
return Config.getInstance().getMaxTicks(this);
}
public String getAbilityOn() {
return LocaleLoader.getString(this.abilityOn);
}
public String getAbilityOff() {
return LocaleLoader.getString(this.abilityOff);
}
public String getAbilityPlayer(Player player) {
return LocaleLoader.getString(this.abilityPlayer, player.getName());
}
public String getAbilityPlayerOff(Player player) {
return LocaleLoader.getString(this.abilityPlayerOff, player.getName());
}
public String getAbilityRefresh() {
return LocaleLoader.getString(this.abilityRefresh);
}
@Override
public String toString() {
String baseString = name();
String[] substrings = baseString.split("_");
String formattedString = "";
int size = 1;
for (String string : substrings) {
formattedString = formattedString.concat(StringUtils.getCapitalized(string));
if (size < substrings.length) {
formattedString = formattedString.concat("_");
}
size++;
}
return formattedString;
}
/**
* Get the permissions for this ability.
*
* @param player Player to check permissions for
* @return true if the player has permissions, false otherwise
*/
public boolean getPermissions(Player player) {
switch (this) {
case BERSERK:
return Permissions.berserk(player);
case BLAST_MINING:
return Permissions.remoteDetonation(player);
case GIGA_DRILL_BREAKER:
return Permissions.gigaDrillBreaker(player);
case GREEN_TERRA:
return Permissions.greenTerra(player);
case LEAF_BLOWER:
return Permissions.leafBlower(player);
case SERRATED_STRIKES:
return Permissions.serratedStrikes(player);
case SKULL_SPLITTER:
return Permissions.skullSplitter(player);
case SUPER_BREAKER:
return Permissions.superBreaker(player);
case TREE_FELLER:
return Permissions.treeFeller(player);
default:
return false;
}
}
/**
* Check if a block is affected by this ability.
*
* @param blockState the block to check
* @return true if the block is affected by this ability, false otherwise
*/
public boolean blockCheck(BlockState blockState) {
switch (this) {
case BERSERK:
return (BlockChecks.affectedByGigaDrillBreaker(blockState) || blockState.getType() == Material.SNOW);
case GIGA_DRILL_BREAKER:
return BlockChecks.affectedByGigaDrillBreaker(blockState);
case GREEN_TERRA:
return BlockChecks.canMakeMossy(blockState);
case LEAF_BLOWER:
return BlockChecks.isLeaves(blockState);
case SUPER_BREAKER:
return BlockChecks.affectedBySuperBreaker(blockState);
case TREE_FELLER:
return BlockChecks.isLog(blockState);
default:
return false;
}
}
}

View File

@ -1,597 +0,0 @@
package com.gmail.nossr50.skills.utilities;
import org.bukkit.Material;
import org.bukkit.entity.AnimalTamer;
import org.bukkit.entity.Animals;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.IronGolem;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Skeleton;
import org.bukkit.entity.Tameable;
import org.bukkit.entity.Wolf;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.player.PlayerAnimationEvent;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.McMMOPlayer;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.events.fake.FakeEntityDamageByEntityEvent;
import com.gmail.nossr50.events.fake.FakeEntityDamageEvent;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mods.ModChecks;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.skills.SkillManagerStore;
import com.gmail.nossr50.skills.axes.AxeManager;
import com.gmail.nossr50.skills.runnables.BleedTimer;
import com.gmail.nossr50.skills.runnables.CombatXpGiver;
import com.gmail.nossr50.skills.swords.Swords;
import com.gmail.nossr50.skills.taming.Taming;
import com.gmail.nossr50.util.ItemChecks;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Users;
public final class CombatTools {
private CombatTools() {}
/**
* Apply combat modifiers and process and XP gain.
*
* @param event The event to run the combat checks on.
*/
public static void combatChecks(EntityDamageByEntityEvent event, Entity attacker, LivingEntity target) {
boolean targetIsPlayer = (target.getType() == EntityType.PLAYER);
boolean targetIsTamedPet = (target instanceof Tameable) ? ((Tameable) target).isTamed() : false;
Entity damager = event.getDamager();
if (attacker instanceof Player && damager.getType() == EntityType.PLAYER) {
Player player = (Player) attacker;
if (Misc.isNPCEntity(player)) {
return;
}
if (target instanceof Tameable && isFriendlyPet(player, (Tameable) target)) {
return;
}
ItemStack heldItem = player.getItemInHand();
Material heldItemType = heldItem.getType();
if (ItemChecks.isSword(heldItem)) {
if (targetIsPlayer || targetIsTamedPet) {
if (!SkillType.SWORDS.getPVPEnabled()) {
return;
}
}
else if (!SkillType.SWORDS.getPVEEnabled()) {
return;
}
if (Permissions.skillEnabled(player, SkillType.SWORDS)) {
McMMOPlayer mcMMOPlayer = Users.getPlayer(player);
PlayerProfile profile = mcMMOPlayer.getProfile();
String playerName = player.getName();
boolean canSerratedStrike = Permissions.serratedStrikes(player); //So we don't have to check the same permission twice
if (profile.getToolPreparationMode(ToolType.SWORD) && canSerratedStrike) {
SkillTools.abilityCheck(player, SkillType.SWORDS);
}
if (Permissions.bleed(player)) {
SkillManagerStore.getInstance().getSwordsManager(playerName).bleedCheck(target);
}
if (profile.getAbilityMode(AbilityType.SERRATED_STRIKES) && canSerratedStrike) {
SkillManagerStore.getInstance().getSwordsManager(playerName).serratedStrikes(target, event.getDamage());
}
startGainXp(mcMMOPlayer, target, SkillType.SWORDS);
}
}
else if (ItemChecks.isAxe(heldItem)) {
if (((targetIsPlayer || targetIsTamedPet) && !SkillType.AXES.getPVPEnabled()) || (!targetIsPlayer && !targetIsTamedPet && !SkillType.AXES.getPVEEnabled())) {
return;
}
if (Permissions.skillEnabled(player, SkillType.AXES)) {
AxeManager axeManager = SkillManagerStore.getInstance().getAxeManager(player.getName());
if (axeManager.canActivateAbility()) {
SkillTools.abilityCheck(player, SkillType.AXES);
}
if (axeManager.canUseAxeMastery()) {
event.setDamage(axeManager.axeMasteryCheck(event.getDamage()));
}
if (axeManager.canCriticalHit(target)) {
event.setDamage(axeManager.criticalHitCheck(target, event.getDamage()));
}
if (axeManager.canImpact(target)) {
axeManager.impactCheck(target);
}
else if (axeManager.canGreaterImpact(target)){
event.setDamage(axeManager.greaterImpactCheck(target, event.getDamage()));
}
if (axeManager.canUseSkullSplitter(target)) {
axeManager.skullSplitterCheck(target, event.getDamage());
}
startGainXp(axeManager.getMcMMOPlayer(), target, SkillType.AXES);
}
}
else if (heldItemType == Material.AIR) {
if (targetIsPlayer || targetIsTamedPet) {
if (!SkillType.UNARMED.getPVPEnabled()) {
return;
}
}
else if (!SkillType.UNARMED.getPVEEnabled()) {
return;
}
if (Permissions.skillEnabled(player, SkillType.UNARMED)) {
McMMOPlayer mcMMOPlayer = Users.getPlayer(player);
PlayerProfile profile = mcMMOPlayer.getProfile();
String playerName = player.getName();
boolean canBerserk = Permissions.berserk(player); //So we don't have to check the same permission twice
if (profile.getToolPreparationMode(ToolType.FISTS) && canBerserk) {
SkillTools.abilityCheck(player, SkillType.UNARMED);
}
if (Permissions.bonusDamage(player, SkillType.UNARMED)) {
event.setDamage(SkillManagerStore.getInstance().getUnarmedManager(playerName).ironArmCheck(event.getDamage()));
}
if (profile.getAbilityMode(AbilityType.BERSERK) && canBerserk) {
event.setDamage(SkillManagerStore.getInstance().getUnarmedManager(playerName).berserkDamage(event.getDamage()));
}
if (target instanceof Player && Permissions.disarm(player)) {
Player defender = (Player) target;
if (defender.getItemInHand().getType() != Material.AIR) {
SkillManagerStore.getInstance().getUnarmedManager(playerName).disarmCheck((Player) target);
}
}
startGainXp(mcMMOPlayer, target, SkillType.UNARMED);
}
}
else if (heldItemType == Material.BONE && target instanceof Tameable && Permissions.beastLore(player)) {
SkillManagerStore.getInstance().getTamingManager(player.getName()).beastLore(target);
}
}
switch (damager.getType()) {
case WOLF:
Wolf wolf = (Wolf) damager;
if (wolf.isTamed() && wolf.getOwner() instanceof Player) {
Player master = (Player) wolf.getOwner();
if (Misc.isNPCEntity(master)) {
return;
}
if (targetIsPlayer || targetIsTamedPet) {
if (!SkillType.TAMING.getPVPEnabled()) {
return;
}
}
else if (!SkillType.TAMING.getPVEEnabled()) {
return;
}
if (Permissions.skillEnabled(master, SkillType.TAMING)) {
McMMOPlayer mcMMOPlayer = Users.getPlayer(master);
int skillLevel = SkillManagerStore.getInstance().getTamingManager(master.getName()).getSkillLevel();
if (skillLevel >= Taming.fastFoodServiceUnlockLevel && Permissions.fastFoodService(master)) {
SkillManagerStore.getInstance().getTamingManager(master.getName()).fastFoodService(wolf, event.getDamage());
}
if (skillLevel >= Taming.sharpenedClawsUnlockLevel && Permissions.sharpenedClaws(master)) {
SkillManagerStore.getInstance().getTamingManager(master.getName()).sharpenedClaws(event);
}
if (Permissions.gore(master)) {
SkillManagerStore.getInstance().getTamingManager(master.getName()).gore(event);
}
startGainXp(mcMMOPlayer, target, SkillType.TAMING);
}
}
break;
case ARROW:
LivingEntity shooter = ((Arrow) damager).getShooter();
/* Break instead of return due to Dodge/Counter/Deflect abilities */
if (shooter == null || !(shooter instanceof Player)) {
break;
}
if (targetIsPlayer || targetIsTamedPet) {
if (!SkillType.ARCHERY.getPVPEnabled()) {
return;
}
}
else if (!SkillType.ARCHERY.getPVEEnabled()) {
return;
}
archeryCheck((Player) shooter, target, event);
break;
default:
break;
}
if (targetIsPlayer) {
Player player = (Player) target;
if (Misc.isNPCEntity(player)) {
return;
}
ItemStack heldItem = player.getItemInHand();
if (SkillManagerStore.getInstance().getAcrobaticsManager(player.getName()).canDodge(damager)) {
event.setDamage(SkillManagerStore.getInstance().getAcrobaticsManager(player.getName()).dodgeCheck(event.getDamage()));
}
if (damager instanceof Player) {
if (SkillType.SWORDS.getPVPEnabled() && ItemChecks.isSword(heldItem) && Permissions.counterAttack(player)) {
SkillManagerStore.getInstance().getSwordsManager(player.getName()).counterAttackChecks((LivingEntity) damager, event.getDamage());
}
}
else {
if (SkillType.SWORDS.getPVEEnabled() && damager instanceof LivingEntity && ItemChecks.isSword(heldItem) && Permissions.counterAttack(player)) {
SkillManagerStore.getInstance().getSwordsManager(player.getName()).counterAttackChecks((LivingEntity) damager, event.getDamage());
}
}
}
}
/**
* Process archery abilities.
*
* @param shooter The player shooting
* @param target The defending entity
* @param event The event to run the archery checks on.
*/
private static void archeryCheck(Player shooter, LivingEntity target, EntityDamageByEntityEvent event) {
if (Misc.isNPCEntity(shooter)) {
return;
}
if (Permissions.skillEnabled(shooter, SkillType.ARCHERY)) {
String playerName = shooter.getName();
if (SkillManagerStore.getInstance().getArcheryManager(playerName).canSkillShot()) {
event.setDamage(SkillManagerStore.getInstance().getArcheryManager(playerName).skillShotCheck(event.getDamage()));
}
if (target instanceof Player && SkillType.UNARMED.getPVPEnabled() && ((Player) target).getItemInHand().getType() == Material.AIR && Permissions.arrowDeflect((Player) target)) {
event.setCancelled(SkillManagerStore.getInstance().getUnarmedManager(((Player) target).getName()).deflectCheck());
if (event.isCancelled()) {
return;
}
}
if (SkillManagerStore.getInstance().getArcheryManager(playerName).canDaze(target)) {
event.setDamage(SkillManagerStore.getInstance().getArcheryManager(playerName).dazeCheck((Player) target, event.getDamage()));
}
if (SkillManagerStore.getInstance().getArcheryManager(playerName).canTrackArrows()) {
SkillManagerStore.getInstance().getArcheryManager(playerName).trackArrows(target);
}
SkillManagerStore.getInstance().getArcheryManager(playerName).distanceXpBonus(target);
startGainXp(Users.getPlayer(shooter), target, SkillType.ARCHERY);
}
}
/**
* Attempt to damage target for value dmg with reason CUSTOM
*
* @param target LivingEntity which to attempt to damage
* @param dmg Amount of damage to attempt to do
*/
public static void dealDamage(LivingEntity target, int dmg) {
dealDamage(target, dmg, EntityDamageEvent.DamageCause.CUSTOM);
}
/**
* Attempt to damage target for value dmg with reason cause
*
* @param target LivingEntity which to attempt to damage
* @param dmg Amount of damage to attempt to do
* @param cause DamageCause to pass to damage event
*/
private static void dealDamage(LivingEntity target, int dmg, DamageCause cause) {
if (Config.getInstance().getEventCallbackEnabled()) {
EntityDamageEvent ede = new FakeEntityDamageEvent(target, cause, dmg);
mcMMO.p.getServer().getPluginManager().callEvent(ede);
if (ede.isCancelled()) {
return;
}
target.damage(ede.getDamage());
}
else {
target.damage(dmg);
}
}
/**
* Attempt to damage target for value dmg with reason ENTITY_ATTACK with damager attacker
*
* @param target LivingEntity which to attempt to damage
* @param dmg Amount of damage to attempt to do
* @param attacker Player to pass to event as damager
*/
private static void dealDamage(LivingEntity target, int dmg, Player attacker) {
if (Config.getInstance().getEventCallbackEnabled()) {
EntityDamageEvent ede = new FakeEntityDamageByEntityEvent(attacker, target, EntityDamageEvent.DamageCause.ENTITY_ATTACK, dmg);
mcMMO.p.getServer().getPluginManager().callEvent(ede);
if (ede.isCancelled()) {
return;
}
target.damage(ede.getDamage());
}
else {
target.damage(dmg);
}
}
/**
* Apply Area-of-Effect ability actions.
*
* @param attacker The attacking player
* @param target The defending entity
* @param damage The initial damage amount
* @param type The type of skill being used
*/
public static void applyAbilityAoE(Player attacker, LivingEntity target, int damage, SkillType type) {
int numberOfTargets = Misc.getTier(attacker.getItemInHand()); //The higher the weapon tier, the more targets you hit
int damageAmount = damage;
if (damageAmount < 1) {
damageAmount = 1;
}
for (Entity entity : target.getNearbyEntities(2.5, 2.5, 2.5)) {
if (Misc.isNPCEntity(entity) || !(entity instanceof LivingEntity) || !shouldBeAffected(attacker, entity)) {
continue;
}
if (numberOfTargets <= 0) {
break;
}
PlayerAnimationEvent armswing = new PlayerAnimationEvent(attacker);
mcMMO.p.getServer().getPluginManager().callEvent(armswing);
switch (type) {
case SWORDS:
if (entity instanceof Player) {
((Player) entity).sendMessage(LocaleLoader.getString("Swords.Combat.SS.Struck"));
}
BleedTimer.add((LivingEntity) entity, Swords.serratedStrikesBleedTicks);
break;
case AXES:
if (entity instanceof Player) {
((Player) entity).sendMessage(LocaleLoader.getString("Axes.Combat.Cleave.Struck"));
}
break;
default:
break;
}
dealDamage((LivingEntity) entity, damageAmount, attacker);
numberOfTargets--;
}
}
/**
* Start the task that gives combat XP.
*
* @param mcMMOPlayer The attacking player
* @param target The defending entity
* @param skillType The skill being used
*/
public static void startGainXp(McMMOPlayer mcMMOPlayer, LivingEntity target, SkillType skillType) {
double baseXP = 0;
if (target instanceof Player) {
if (!Config.getInstance().getExperienceGainsPlayerVersusPlayerEnabled()) {
return;
}
Player defender = (Player) target;
if (System.currentTimeMillis() >= Users.getPlayer(defender).getProfile().getRespawnATS() + 5) {
baseXP = 20 * Config.getInstance().getPlayerVersusPlayerXP();
}
}
else if (!target.hasMetadata(mcMMO.entityMetadataKey)) {
if (target instanceof Animals) {
if (ModChecks.isCustomEntity(target)) {
baseXP = ModChecks.getCustomEntity(target).getXpMultiplier();
}
else {
baseXP = Config.getInstance().getAnimalsXP();
}
}
else {
EntityType type = target.getType();
switch (type) {
case BAT:
baseXP = Config.getInstance().getAnimalsXP();
break;
case BLAZE:
case CAVE_SPIDER:
case CREEPER:
case ENDER_DRAGON:
case ENDERMAN:
case GHAST:
case GIANT:
case MAGMA_CUBE:
case PIG_ZOMBIE:
case SILVERFISH:
case SLIME:
case SPIDER:
case WITCH:
case WITHER:
case ZOMBIE:
baseXP = Config.getInstance().getCombatXP(type);
break;
// Temporary workaround for custom entities
case UNKNOWN:
baseXP = 1.0;
break;
case SKELETON:
switch(((Skeleton) target).getSkeletonType()) {
case WITHER:
baseXP = Config.getInstance().getWitherSkeletonXP();
break;
default:
baseXP = Config.getInstance().getCombatXP(type);
break;
}
break;
case IRON_GOLEM:
if (!((IronGolem) target).isPlayerCreated()) {
baseXP = Config.getInstance().getCombatXP(type);
}
break;
default:
if (ModChecks.isCustomEntity(target)) {
baseXP = ModChecks.getCustomEntity(target).getXpMultiplier();
}
break;
}
}
baseXP *= 10;
}
if (baseXP != 0) {
mcMMO.p.getServer().getScheduler().scheduleSyncDelayedTask(mcMMO.p, new CombatXpGiver(mcMMOPlayer, skillType, baseXP, target), 0);
}
}
/**
* Check to see if the given LivingEntity should be affected by a combat ability.
*
* @param player The attacking Player
* @param entity The defending Entity
* @return true if the Entity should be damaged, false otherwise.
*/
public static boolean shouldBeAffected(Player player, Entity entity) {
if (entity instanceof Player) {
Player defender = (Player) entity;
if (!defender.getWorld().getPVP() || defender == player || Users.getPlayer(defender).getProfile().getGodMode()) {
return false;
}
if (PartyManager.inSameParty(player, defender) && !(Permissions.friendlyFire(player) && Permissions.friendlyFire(defender))) {
return false;
}
//It may seem a bit redundant but we need a check here to prevent bleed from being applied in applyAbilityAoE()
EntityDamageEvent ede = new FakeEntityDamageByEntityEvent(player, entity, EntityDamageEvent.DamageCause.ENTITY_ATTACK, 1);
mcMMO.p.getServer().getPluginManager().callEvent(ede);
if (ede.isCancelled()) {
return false;
}
}
else if (entity instanceof Tameable) {
if (isFriendlyPet(player, (Tameable) entity)) {
// isFriendlyPet ensures that the Tameable is: Tamed, owned by a player, and the owner is in the same party
// So we can make some assumptions here, about our casting and our check
Player owner = (Player) ((Tameable) entity).getOwner();
if (!(Permissions.friendlyFire(player) && Permissions.friendlyFire(owner))) {
return false;
}
}
}
return true;
}
/**
* Checks to see if an entity is currently invincible.
*
* @param entity The {@link LivingEntity} to check
* @param eventDamage The damage from the event the entity is involved in
* @return true if the entity is invincible, false otherwise
*/
public static boolean isInvincible(LivingEntity entity, int eventDamage) {
/*
* So apparently if you do more damage to a LivingEntity than its last damage int you bypass the invincibility.
* So yeah, this is for that.
*/
if ((entity.getNoDamageTicks() > entity.getMaximumNoDamageTicks() / 2.0F) && (eventDamage <= entity.getLastDamage())) {
return true;
}
return false;
}
/**
* Checks to see if an entity is currently friendly toward a given player.
*
* @param attacker The player to check.
* @param pet The entity to check.
* @return true if the entity is friendly, false otherwise
*/
public static boolean isFriendlyPet(Player attacker, Tameable pet) {
if (pet.isTamed()) {
AnimalTamer tamer = pet.getOwner();
if (tamer instanceof Player) {
Player owner = (Player) tamer;
if (owner == attacker || PartyManager.inSameParty(attacker, owner)) {
return true;
}
}
}
return false;
}
}

View File

@ -1,78 +0,0 @@
package com.gmail.nossr50.skills.utilities;
import org.bukkit.entity.Player;
import com.gmail.nossr50.util.Permissions;
public final class PerksUtils {
private static final int LUCKY_SKILL_ACTIVATION_CHANCE = 75;
private static final int NORMAL_SKILL_ACTIVATION_CHANCE = 100;
private PerksUtils() {};
public static int handleCooldownPerks(Player player, int cooldown) {
if (Permissions.halvedCooldowns(player)) {
cooldown *= 0.5;
}
else if (Permissions.thirdedCooldowns(player)) {
cooldown *= (1.0 / 3.0);
}
else if (Permissions.quarteredCooldowns(player)) {
cooldown *= 0.75;
}
return cooldown;
}
public static int handleActivationPerks(Player player, int ticks, int maxTicks) {
if (Permissions.twelveSecondActivationBoost(player)) {
ticks += 12;
}
else if (Permissions.eightSecondActivationBoost(player)) {
ticks += 8;
}
else if (Permissions.fourSecondActivationBoost(player)) {
ticks += 4;
}
if (maxTicks != 0 && ticks > maxTicks) {
ticks = maxTicks;
}
return ticks;
}
public static int handleXpPerks(Player player, int xp) {
if (Permissions.quadrupleXp(player)) {
xp *= 4;
}
else if (Permissions.tripleXp(player)) {
xp *= 3;
}
else if (Permissions.doubleAndOneHalfXp(player)) {
xp *= 2.5;
}
else if (Permissions.doubleXp(player)) {
xp *= 2;
}
else if (Permissions.oneAndOneHalfXp(player)) {
xp *= 1.5;
}
return xp;
}
/**
* Calculate activation chance for a skill.
*
* @param isLucky true if the player has the appropriate "lucky" perk, false otherwise
* @return the activation chance
*/
public static int handleLuckyPerks(Player player, SkillType skill) {
if (Permissions.lucky(player, skill)) {
return LUCKY_SKILL_ACTIVATION_CHANCE;
}
return NORMAL_SKILL_ACTIVATION_CHANCE;
}
}

View File

@ -1,623 +0,0 @@
package com.gmail.nossr50.skills.utilities;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.plugin.PluginManager;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.getspout.spoutapi.SpoutManager;
import org.getspout.spoutapi.player.SpoutPlayer;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.HiddenConfig;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.events.experience.McMMOPlayerLevelUpEvent;
import com.gmail.nossr50.events.fake.FakeBlockBreakEvent;
import com.gmail.nossr50.events.fake.FakeBlockDamageEvent;
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mods.ModChecks;
import com.gmail.nossr50.spout.SpoutConfig;
import com.gmail.nossr50.spout.SpoutTools;
import com.gmail.nossr50.util.ItemChecks;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.ParticleEffectUtils;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.Users;
public class SkillTools {
public static int handleFoodSkills(Player player, SkillType skill, int eventFoodLevel, int baseLevel, int maxLevel, int rankChange) {
int skillLevel = Users.getPlayer(player).getProfile().getSkillLevel(skill);
int currentFoodLevel = player.getFoodLevel();
int foodChange = eventFoodLevel - currentFoodLevel;
for (int i = baseLevel; i <= maxLevel; i+= rankChange) {
if (skillLevel >= i) {
foodChange++;
}
}
return currentFoodLevel + foodChange;
}
/**
* Checks to see if the cooldown for an item or ability is expired.
*
* @param oldTime The time the ability or item was last used
* @param cooldown The amount of time that must pass between uses
* @param player The player whose cooldown is being checked
* @return true if the cooldown is over, false otherwise
*/
public static boolean cooldownOver(long oldTime, int cooldown, Player player) {
long currentTime = System.currentTimeMillis();
int adjustedCooldown = PerksUtils.handleCooldownPerks(player, cooldown);
if (currentTime - oldTime >= (adjustedCooldown * Misc.TIME_CONVERSION_FACTOR)) {
return true;
}
return false;
}
/**
* Calculate the time remaining until the cooldown expires.
*
* @param deactivatedTimeStamp Time of deactivation
* @param cooldown The length of the cooldown
* @return the number of seconds remaining before the cooldown expires
*/
public static int calculateTimeLeft(long deactivatedTimeStamp, int cooldown, Player player) {
return (int) (((deactivatedTimeStamp + (PerksUtils.handleCooldownPerks(player, cooldown) * Misc.TIME_CONVERSION_FACTOR)) - System.currentTimeMillis()) / Misc.TIME_CONVERSION_FACTOR);
}
/**
* Sends a message to the player when the cooldown expires.
*
* @param player The player to send a message to
* @param profile The profile of the player
* @param ability The ability to watch cooldowns for
*/
public static void watchCooldown(Player player, PlayerProfile profile, AbilityType ability) {
if (player == null || profile == null || ability == null)
return;
if (!profile.getAbilityInformed(ability) && cooldownOver(profile.getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR, ability.getCooldown(), player)) {
profile.setAbilityInformed(ability, true);
player.sendMessage(ability.getAbilityRefresh());
}
}
/**
* Process activating abilities & readying the tool.
*
* @param player The player using the ability
* @param skill The skill the ability is tied to
*/
public static void activationCheck(Player player, SkillType skill) {
if (Config.getInstance().getAbilitiesOnlyActivateWhenSneaking() && !player.isSneaking()) {
return;
}
PlayerProfile profile = Users.getPlayer(player).getProfile();
AbilityType ability = skill.getAbility();
ToolType tool = skill.getTool();
ItemStack inHand = player.getItemInHand();
if (ModChecks.isCustomTool(inHand) && !ModChecks.getToolFromItemStack(inHand).isAbilityEnabled()) {
return;
}
/* Check if any abilities are active */
if (profile == null) {
return;
}
if (!profile.getAbilityUse()) {
return;
}
for (AbilityType x : AbilityType.values()) {
if (profile.getAbilityMode(x)) {
return;
}
}
/* Woodcutting & Axes need to be treated differently.
* Basically the tool always needs to ready and we check to see if the cooldown is over when the user takes action
*/
if (ability.getPermissions(player) && tool.inHand(inHand) && !profile.getToolPreparationMode(tool)) {
if (skill != SkillType.WOODCUTTING && skill != SkillType.AXES) {
if (!profile.getAbilityMode(ability) && !cooldownOver(profile.getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR, ability.getCooldown(), player)) {
player.sendMessage(LocaleLoader.getString("Skills.TooTired", calculateTimeLeft(profile.getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR, ability.getCooldown(), player)));
return;
}
}
if (Config.getInstance().getAbilityMessagesEnabled()) {
player.sendMessage(tool.getRaiseTool());
}
profile.setToolPreparationATS(tool, System.currentTimeMillis());
profile.setToolPreparationMode(tool, true);
}
}
/**
* Monitors various things relating to skill abilities.
*
* @param player The player using the skill
* @param profile The profile of the player
* @param curTime The current system time
* @param skill The skill being monitored
*/
public static void monitorSkill(Player player, PlayerProfile profile, long curTime, SkillType skill) {
final int FOUR_SECONDS = 4000;
ToolType tool = skill.getTool();
AbilityType ability = skill.getAbility();
if (profile == null) {
return;
}
if (profile.getToolPreparationMode(tool) && curTime - (profile.getToolPreparationATS(tool) * Misc.TIME_CONVERSION_FACTOR) >= FOUR_SECONDS) {
profile.setToolPreparationMode(tool, false);
if (Config.getInstance().getAbilityMessagesEnabled()) {
player.sendMessage(tool.getLowerTool());
}
}
if (ability.getPermissions(player)) {
if (profile.getAbilityMode(ability) && (profile.getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR) <= curTime) {
if (ability == AbilityType.BERSERK) {
player.setCanPickupItems(true);
}
else if (ability == AbilityType.SUPER_BREAKER || ability == AbilityType.GIGA_DRILL_BREAKER) {
handleAbilitySpeedDecrease(player);
}
profile.setAbilityMode(ability, false);
profile.setAbilityInformed(ability, false);
ParticleEffectUtils.playAbilityDisabledEffect(player);
if (profile.useChatNotifications()) {
player.sendMessage(ability.getAbilityOff());
}
sendSkillMessage(player, ability.getAbilityPlayerOff(player));
}
}
}
/**
* Check the XP of a skill.
*
* @param skillType The skill to check
* @param player The player whose skill to check
* @param profile The profile of the player whose skill to check
*/
public static void xpCheckSkill(SkillType skillType, Player player, PlayerProfile profile) {
int skillups = 0;
int xpRemoved = 0;
if (profile.getSkillXpLevel(skillType) >= profile.getXpToLevel(skillType)) {
while (profile.getSkillXpLevel(skillType) >= profile.getXpToLevel(skillType)) {
if ((skillType.getMaxLevel() >= profile.getSkillLevel(skillType) + 1) && (Config.getInstance().getPowerLevelCap() >= Users.getPlayer(player).getPowerLevel() + 1)) {
int xp = profile.getXpToLevel(skillType);
xpRemoved += xp;
profile.removeXp(skillType, xp);
skillups++;
profile.skillUp(skillType, 1);
}
else {
profile.addLevels(skillType, 0);
}
}
McMMOPlayerLevelUpEvent eventToFire = new McMMOPlayerLevelUpEvent(player, skillType, skillups);
mcMMO.p.getServer().getPluginManager().callEvent(eventToFire);
if (eventToFire.isCancelled()) {
profile.modifySkill(skillType, profile.getSkillLevel(skillType) - skillups);
profile.setSkillXpLevel(skillType, profile.getSkillXpLevel(skillType) + xpRemoved);
return;
}
String capitalized = StringUtils.getCapitalized(skillType.toString());
/* Spout Stuff */
if (mcMMO.spoutEnabled) {
SpoutPlayer spoutPlayer = SpoutManager.getPlayer(player);
if (spoutPlayer != null && spoutPlayer.isSpoutCraftEnabled()) {
SpoutTools.levelUpNotification(skillType, spoutPlayer);
/* Update custom titles */
if (SpoutConfig.getInstance().getShowPowerLevel()) {
spoutPlayer.setTitle(LocaleLoader.getString("Spout.Title", spoutPlayer.getName(), Users.getPlayer(player).getPowerLevel()));
}
}
else {
player.sendMessage(LocaleLoader.getString(capitalized + ".Skillup", skillups, profile.getSkillLevel(skillType)));
}
}
else {
player.sendMessage(LocaleLoader.getString(capitalized + ".Skillup", skillups, profile.getSkillLevel(skillType)));
}
}
if (mcMMO.spoutEnabled) {
SpoutPlayer spoutPlayer = SpoutManager.getPlayer(player);
if (spoutPlayer != null && spoutPlayer.isSpoutCraftEnabled()) {
if (SpoutConfig.getInstance().getXPBarEnabled()) {
profile.getSpoutHud().updateXpBar();
}
}
}
}
/**
* Checks if the given string represents a valid skill
*
* @param skillName The name of the skill to check
* @return true if this is a valid skill, false otherwise
*/
public static boolean isSkill(String skillName) {
if (!Config.getInstance().getLocale().equalsIgnoreCase("en_US")) {
return isLocalizedSkill(skillName);
}
if (SkillType.getSkill(skillName) != null) {
return true;
}
return false;
}
private static boolean isLocalizedSkill(String skillName) {
for (SkillType skill : SkillType.values()) {
if (skillName.equalsIgnoreCase(LocaleLoader.getString(StringUtils.getCapitalized(skill.toString()) + ".SkillName"))) {
return true;
}
}
return false;
}
public static String getSkillName(SkillType skill) {
if (!Config.getInstance().getLocale().equalsIgnoreCase("en_US")) {
return StringUtils.getCapitalized(LocaleLoader.getString(StringUtils.getCapitalized(skill.toString()) + ".SkillName"));
}
return StringUtils.getCapitalized(skill.toString());
}
/**
* Check if the player has any combat skill permissions.
*
* @param player The player to check permissions for
* @return true if the player has combat skills, false otherwise
*/
public static boolean hasCombatSkills(Player player) {
if (Permissions.skillEnabled(player, SkillType.AXES)
|| Permissions.skillEnabled(player, SkillType.ARCHERY)
|| Permissions.skillEnabled(player, SkillType.SWORDS)
|| Permissions.skillEnabled(player, SkillType.TAMING)
|| Permissions.skillEnabled(player, SkillType.UNARMED)) {
return true;
}
return false;
}
/**
* Check if the player has any gathering skill permissions.
*
* @param player The player to check permissions for
* @return true if the player has gathering skills, false otherwise
*/
public static boolean hasGatheringSkills(Player player) {
if (Permissions.skillEnabled(player, SkillType.EXCAVATION)
|| Permissions.skillEnabled(player, SkillType.FISHING)
|| Permissions.skillEnabled(player, SkillType.HERBALISM)
|| Permissions.skillEnabled(player, SkillType.MINING)
|| Permissions.skillEnabled(player, SkillType.WOODCUTTING)) {
return true;
}
return false;
}
/**
* Check if the player has any misc skill permissions.
*
* @param player The player to check permissions for
* @return true if the player has misc skills, false otherwise
*/
public static boolean hasMiscSkills(Player player) {
if (Permissions.skillEnabled(player, SkillType.ACROBATICS)
|| Permissions.skillEnabled(player, SkillType.SMELTING)
|| Permissions.skillEnabled(player, SkillType.REPAIR)) {
return true;
}
return false;
}
/**
* Check to see if an ability can be activated.
*
* @param player The player activating the ability
* @param type The skill the ability is based on
*/
public static void abilityCheck(Player player, SkillType type) {
PlayerProfile profile = Users.getPlayer(player).getProfile();
ToolType tool = type.getTool();
AbilityType ability = type.getAbility();
profile.setToolPreparationMode(tool, false);
/* Axes and Woodcutting are odd because they share the same tool.
* We show them the too tired message when they take action.
*/
if (type == SkillType.WOODCUTTING || type == SkillType.AXES) {
if (!profile.getAbilityMode(ability) && !cooldownOver(profile.getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR, ability.getCooldown(), player)) {
player.sendMessage(LocaleLoader.getString("Skills.TooTired", calculateTimeLeft(profile.getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR, ability.getCooldown(), player)));
return;
}
}
if (!profile.getAbilityMode(ability) && cooldownOver(profile.getSkillDATS(ability), ability.getCooldown(), player)) {
int ticks = PerksUtils.handleActivationPerks(player, 2 + (profile.getSkillLevel(type) / AdvancedConfig.getInstance().getAbilityLength()), ability.getMaxTicks());
ParticleEffectUtils.playAbilityEnabledEffect(player);
if (profile.useChatNotifications()) {
player.sendMessage(ability.getAbilityOn());
}
SkillTools.sendSkillMessage(player, ability.getAbilityPlayer(player));
profile.setSkillDATS(ability, System.currentTimeMillis() + (ticks * Misc.TIME_CONVERSION_FACTOR));
profile.setAbilityMode(ability, true);
if (ability == AbilityType.BERSERK) {
player.setCanPickupItems(false);
}
else if (ability == AbilityType.SUPER_BREAKER || ability == AbilityType.GIGA_DRILL_BREAKER) {
handleAbilitySpeedIncrease(player);
}
}
}
/**
* Check to see if ability should be triggered.
*
* @param player The player using the ability
* @param block The block modified by the ability
* @param ability The ability to check
* @return true if the ability should activate, false otherwise
*/
public static boolean triggerCheck(Player player, Block block, AbilityType ability) {
boolean activate = true;
switch (ability) {
case BERSERK:
case LEAF_BLOWER:
if (!ability.blockCheck(block.getState())) {
activate = false;
break;
}
if (!blockBreakSimulate(block, player, true)) {
activate = false;
break;
}
break;
case GIGA_DRILL_BREAKER:
case SUPER_BREAKER:
case GREEN_TERRA:
if (!ability.blockCheck(block.getState())) {
activate = false;
break;
}
break;
default:
activate = false;
break;
}
return activate;
}
public static void sendSkillMessage(Player player, String message) {
for (Player otherPlayer : player.getWorld().getPlayers()) {
if (otherPlayer != player && Misc.isNear(player.getLocation(), otherPlayer.getLocation(), Misc.SKILL_MESSAGE_MAX_SENDING_DISTANCE)) {
otherPlayer.sendMessage(message);
}
}
}
/**
* Check if a skill level is higher than the max bonus level of the ability.
*
* @param skillLevel Skill level to check
* @param maxLevel Max level of the ability
* @return whichever value is lower
*/
public static int skillCheck(int skillLevel, int maxLevel) {
//TODO: Could we just use Math.min(skillLevel, maxLevel) here?
if (skillLevel > maxLevel) {
return maxLevel;
}
return skillLevel;
}
public static void handleAbilitySpeedIncrease(Player player) {
if (HiddenConfig.getInstance().useEnchantmentBuffs()) {
ItemStack heldItem = player.getItemInHand();
if (heldItem == null || heldItem.getType() == Material.AIR ) {
return;
}
int efficiencyLevel = heldItem.getEnchantmentLevel(Enchantment.DIG_SPEED);
ItemMeta itemMeta = heldItem.getItemMeta();
List<String> itemLore = new ArrayList<String>();
if (itemMeta.hasLore()) {
itemLore = itemMeta.getLore();
}
itemLore.add("mcMMO Ability Tool");
itemMeta.addEnchant(Enchantment.DIG_SPEED, efficiencyLevel + 5, true);
itemMeta.setLore(itemLore);
heldItem.setItemMeta(itemMeta);
}
else {
int duration = 0;
int amplifier = 0;
if (player.hasPotionEffect(PotionEffectType.FAST_DIGGING)) {
for (PotionEffect effect : player.getActivePotionEffects()) {
if (effect.getType() == PotionEffectType.FAST_DIGGING) {
duration = effect.getDuration();
amplifier = effect.getAmplifier();
break;
}
}
}
PlayerProfile profile = Users.getPlayer(player).getProfile();
int ticks = 0;
if (profile.getAbilityMode(AbilityType.SUPER_BREAKER)) {
ticks = ((int) (profile.getSkillDATS(AbilityType.SUPER_BREAKER) - System.currentTimeMillis())) / Misc.TIME_CONVERSION_FACTOR;
}
else if (profile.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER)) {
ticks = ((int) (profile.getSkillDATS(AbilityType.GIGA_DRILL_BREAKER) - System.currentTimeMillis())) / Misc.TIME_CONVERSION_FACTOR;
}
PotionEffect abilityBuff = new PotionEffect(PotionEffectType.FAST_DIGGING, duration + ticks, amplifier + 10);
player.addPotionEffect(abilityBuff, true);
}
}
public static void handleAbilitySpeedDecrease(Player player) {
if (HiddenConfig.getInstance().useEnchantmentBuffs()) {
PlayerInventory playerInventory = player.getInventory();
for (int i = 0; i < playerInventory.getContents().length; i++) {
ItemStack item = playerInventory.getItem(i);
playerInventory.setItem(i, removeAbilityBuff(item));
}
}
else {
player.removePotionEffect(PotionEffectType.FAST_DIGGING);
}
}
public static ItemStack removeAbilityBuff(ItemStack item) {
if (item == null || item.getType() == Material.AIR ) {
return item;
}
if (!ItemChecks.isPickaxe(item) && !ItemChecks.isShovel(item)) {
return item;
}
if (item.containsEnchantment(Enchantment.DIG_SPEED)) {
ItemMeta itemMeta = item.getItemMeta();
if (itemMeta.hasLore()) {
List<String> itemLore = itemMeta.getLore();
if (itemLore.remove("mcMMO Ability Tool")) {
int efficiencyLevel = item.getEnchantmentLevel(Enchantment.DIG_SPEED);
if (efficiencyLevel <= 5) {
itemMeta.removeEnchant(Enchantment.DIG_SPEED);
}
else {
itemMeta.addEnchant(Enchantment.DIG_SPEED, efficiencyLevel - 5, true);
}
itemMeta.setLore(itemLore);
item.setItemMeta(itemMeta);
}
}
}
return item;
}
/**
* Simulate a block break event.
*
* @param block The block to break
* @param player The player breaking the block
* @param shouldArmSwing true if an armswing event should be fired, false otherwise
* @return true if the event wasn't cancelled, false otherwise
*/
public static boolean blockBreakSimulate(Block block, Player player, Boolean shouldArmSwing) {
PluginManager pluginManger = mcMMO.p.getServer().getPluginManager();
//Support for NoCheat
if (shouldArmSwing) {
pluginManger.callEvent(new FakePlayerAnimationEvent(player));
}
FakeBlockDamageEvent damageEvent = new FakeBlockDamageEvent(player, block, player.getItemInHand(), true);
pluginManger.callEvent(damageEvent);
FakeBlockBreakEvent breakEvent = new FakeBlockBreakEvent(block, player);
pluginManger.callEvent(breakEvent);
if (!damageEvent.isCancelled() && !breakEvent.isCancelled()) {
return true;
}
return false;
}
public static boolean activationSuccessful(Player player, SkillType skill, double maxChance, int maxLevel) {
int skillLevel = Users.getPlayer(player).getProfile().getSkillLevel(skill);
int activationChance = PerksUtils.handleLuckyPerks(player, skill);
double chance = (maxChance / maxLevel) * Math.min(skillLevel, maxLevel);
return chance > Misc.getRandom().nextInt(activationChance);
}
public static boolean activationSuccessful(Player player, SkillType skill, double chance) {
return chance > Misc.getRandom().nextInt(PerksUtils.handleLuckyPerks(player, skill));
}
public static boolean unlockLevelReached(Player player, SkillType skill, int unlockLevel) {
return Users.getPlayer(player).getProfile().getSkillLevel(skill) > unlockLevel;
}
public static boolean treasureDropSuccessful(double dropChance, int activationChance) {
return dropChance > Misc.getRandom().nextDouble() * activationChance;
}
}

View File

@ -1,98 +0,0 @@
package com.gmail.nossr50.skills.utilities;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.StringUtils;
public enum SkillType {
ACROBATICS,
ARCHERY,
AXES(AbilityType.SKULL_SPLITTER, ToolType.AXE),
EXCAVATION(AbilityType.GIGA_DRILL_BREAKER, ToolType.SHOVEL),
FISHING,
HERBALISM(AbilityType.GREEN_TERRA, ToolType.HOE),
MINING(AbilityType.SUPER_BREAKER, ToolType.PICKAXE),
REPAIR,
SMELTING,
SWORDS(AbilityType.SERRATED_STRIKES, ToolType.SWORD),
TAMING,
UNARMED(AbilityType.BERSERK, ToolType.FISTS),
WOODCUTTING(AbilityType.TREE_FELLER, ToolType.AXE);
private AbilityType ability;
private ToolType tool;
private SkillType() {
this.ability = null;
this.tool = null;
}
private SkillType(AbilityType ability, ToolType tool) {
this.ability = ability;
this.tool = tool;
}
public AbilityType getAbility() {
return ability;
}
/**
* Get the max level of this skill.
*
* @return the max level of this skill
*/
public int getMaxLevel() {
return Config.getInstance().getLevelCap(this);
}
public boolean getPVPEnabled() {
return Config.getInstance().getPVPEnabled(this);
}
public boolean getPVEEnabled() {
return Config.getInstance().getPVEEnabled(this);
}
public boolean getDoubleDropsDisabled() {
return Config.getInstance().getDoubleDropsDisabled(this);
}
public ToolType getTool() {
return tool;
}
public double getXpModifier() {
return Config.getInstance().getForumulaMultiplier(this);
}
public static SkillType getSkill(String skillName) {
if (!Config.getInstance().getLocale().equalsIgnoreCase("en_US")) {
for (SkillType type : values()) {
if (skillName.equalsIgnoreCase(LocaleLoader.getString(StringUtils.getCapitalized(type.name()) + ".SkillName"))) {
return type;
}
}
}
for (SkillType type : values()) {
if (type.name().equalsIgnoreCase(skillName)) {
return type;
}
}
mcMMO.p.getLogger().warning("[Debug] Invalid mcMMO skill (" + skillName + ")");
return null;
}
// TODO: This is a little "hacky", we probably need to add something to distinguish child skills in the enum, or to use another enum for them
public boolean isChildSkill() {
switch (this) {
case SMELTING:
return true;
default:
return false;
}
}
}

View File

@ -1,63 +0,0 @@
package com.gmail.nossr50.skills.utilities;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.ItemChecks;
public enum ToolType {
AXE(LocaleLoader.getString("Axes.Ability.Lower"), LocaleLoader.getString("Axes.Ability.Ready")),
FISTS(LocaleLoader.getString("Unarmed.Ability.Lower"), LocaleLoader.getString("Unarmed.Ability.Ready")),
HOE(LocaleLoader.getString("Herbalism.Ability.Lower"), LocaleLoader.getString("Herbalism.Ability.Ready")),
PICKAXE(LocaleLoader.getString("Mining.Ability.Lower"), LocaleLoader.getString("Mining.Ability.Ready")),
SHOVEL(LocaleLoader.getString("Excavation.Ability.Lower"), LocaleLoader.getString("Excavation.Ability.Ready")),
SWORD(LocaleLoader.getString("Swords.Ability.Lower"), LocaleLoader.getString("Swords.Ability.Ready"));
private String lowerTool;
private String raiseTool;
private ToolType(String lowerTool, String raiseTool) {
this.lowerTool = lowerTool;
this.raiseTool = raiseTool;
}
public String getLowerTool() {
return lowerTool;
}
public String getRaiseTool() {
return raiseTool;
}
/**
* Check to see if the item is of the appropriate type.
*
* @param is The item to check
* @return true if the item is the right type, false otherwise
*/
public boolean inHand(ItemStack is) {
switch (this) {
case AXE:
return ItemChecks.isAxe(is);
case FISTS:
return is.getType() == Material.AIR;
case HOE:
return ItemChecks.isHoe(is);
case PICKAXE:
return ItemChecks.isPickaxe(is);
case SHOVEL:
return ItemChecks.isShovel(is);
case SWORD:
return ItemChecks.isSword(is);
default:
return false;
}
}
}

View File

@ -1,275 +1,276 @@
package com.gmail.nossr50.skills.woodcutting;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.BlockState;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.material.Tree;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mods.ModChecks;
import com.gmail.nossr50.mods.datatypes.CustomBlock;
import com.gmail.nossr50.skills.utilities.CombatTools;
import com.gmail.nossr50.skills.utilities.SkillTools;
import com.gmail.nossr50.skills.utilities.SkillType;
import com.gmail.nossr50.skills.woodcutting.Woodcutting.ExperienceGainMethod;
import com.gmail.nossr50.util.BlockChecks;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Users;
public final class TreeFeller {
private static boolean treeFellerReachedThreshold = false;
private TreeFeller() {}
/**
* Begins Tree Feller
*
* @param mcMMOPlayer Player using Tree Feller
* @param blockState Block being broken
*/
protected static void processTreeFeller(BlockState blockState, Player player) {
List<BlockState> treeFellerBlocks = new ArrayList<BlockState>();
if(blockState.getTypeId() == 17 || blockState.getTypeId() == 99)
processRegularTrees(blockState, treeFellerBlocks);
else
processRedMushroomTrees(blockState, treeFellerBlocks);
// If the player is trying to break too many blocks
if (treeFellerReachedThreshold) {
treeFellerReachedThreshold = false;
player.sendMessage(LocaleLoader.getString("Woodcutting.Skills.TreeFellerThreshold"));
return;
}
// If the tool can't sustain the durability loss
if (!handleDurabilityLoss(treeFellerBlocks, player.getItemInHand())) {
player.sendMessage(LocaleLoader.getString("Woodcutting.Skills.TreeFeller.Splinter"));
int health = player.getHealth();
if (health > 1) {
CombatTools.dealDamage(player, Misc.getRandom().nextInt(health - 1));
}
return;
}
dropBlocks(treeFellerBlocks, player);
}
/**
* Processes Tree Feller for generic Trees
*
* @param blockState Block being checked
* @param treeFellerBlocks List of blocks to be removed
*/
private static void processRegularTrees(BlockState blockState, List<BlockState> treeFellerBlocks) {
if (!BlockChecks.isLog(blockState)) {
return;
}
List<BlockState> futureCenterBlocks = new ArrayList<BlockState>();
World world = blockState.getWorld();
// Handle the blocks around 'block'
for (int y = 0; y <= 1; y++) {
for (int x = -1; x <= 1; x++) {
for (int z = -1; z <= 1; z++) {
BlockState nextBlock = world.getBlockAt(blockState.getLocation().add(x, y, z)).getState();
handleBlock(nextBlock, futureCenterBlocks, treeFellerBlocks);
if (treeFellerReachedThreshold) {
return;
}
}
}
}
// Recursive call for each log found
for (BlockState futureCenterBlock : futureCenterBlocks) {
if (treeFellerReachedThreshold) {
return;
}
processRegularTrees(futureCenterBlock, treeFellerBlocks);
}
}
/**
* Processes Tree Feller for Red Mushrooms (Dome Shaped)
*
* @param blockState Block being checked
* @param treeFellerBlocks List of blocks to be removed
*/
private static void processRedMushroomTrees(BlockState blockState, List<BlockState> treeFellerBlocks) {
if (!BlockChecks.isLog(blockState)) {
return;
}
List<BlockState> futureCenterBlocks = new ArrayList<BlockState>();
World world = blockState.getWorld();
// Handle the blocks around 'block'
for (int y = 0; y <= 1; y++) {
for (int x = -1; x <= 1; x++) {
for (int z = -1; z <= 1; z++) {
BlockState nextBlock = world.getBlockAt(blockState.getLocation().add(x, y, z)).getState();
BlockState otherNextBlock = world.getBlockAt(blockState.getLocation().add(x, y-(y*2), z)).getState();
handleBlock(nextBlock, futureCenterBlocks, treeFellerBlocks);
handleBlock(otherNextBlock, futureCenterBlocks, treeFellerBlocks);
if (treeFellerReachedThreshold) {
return;
}
}
}
}
// Recursive call for each log found
for (BlockState futureCenterBlock : futureCenterBlocks) {
if (treeFellerReachedThreshold) {
return;
}
processRedMushroomTrees(futureCenterBlock, treeFellerBlocks);
}
}
/**
* Handle a block addition to the list of blocks to be removed
* and to the list of blocks used for future recursive calls of 'processRecursively()'
*
* @param blockState Block to be added
* @param futureCenterBlocks List of blocks that will be used to call 'processRecursively()'
* @param treeFellerBlocks List of blocks to be removed
*/
private static void handleBlock(BlockState blockState, List<BlockState> futureCenterBlocks, List<BlockState> treeFellerBlocks) {
if (!BlockChecks.affectedByTreeFeller(blockState) || mcMMO.placeStore.isTrue(blockState) || treeFellerBlocks.contains(blockState)) {
return;
}
treeFellerBlocks.add(blockState);
if (treeFellerBlocks.size() > Config.getInstance().getTreeFellerThreshold()) {
treeFellerReachedThreshold = true;
return;
}
futureCenterBlocks.add(blockState);
}
/**
* Handles the durability loss
*
* @param treeFellerBlocks List of blocks to be removed
* @param inHand tool being used
* @return True if the tool can sustain the durability loss
*/
private static boolean handleDurabilityLoss(List<BlockState> treeFellerBlocks, ItemStack inHand) {
Material inHandMaterial = inHand.getType();
if (inHandMaterial != Material.AIR) {
short durabilityLoss = 0;
int unbreakingLevel = inHand.getEnchantmentLevel(Enchantment.DURABILITY);
for (BlockState blockState : treeFellerBlocks) {
if (BlockChecks.isLog(blockState) && Misc.getRandom().nextInt(unbreakingLevel + 1) == 0) {
durabilityLoss += Config.getInstance().getAbilityToolDamage();
}
}
short finalDurability = (short) (inHand.getDurability() + durabilityLoss);
short maxDurability = ModChecks.isCustomTool(inHand) ? ModChecks.getToolFromItemStack(inHand).getDurability() : inHandMaterial.getMaxDurability();
if (finalDurability >= maxDurability) {
inHand.setDurability(maxDurability);
return false;
}
inHand.setDurability(finalDurability);
}
return true;
}
/**
* Handles the dropping of blocks
*
* @param treeFellerBlocks List of blocks to be dropped
* @param player Player using the ability
*/
private static void dropBlocks(List<BlockState> treeFellerBlocks, Player player) {
int xp = 0;
for (BlockState blockState : treeFellerBlocks) {
if (!SkillTools.blockBreakSimulate(blockState.getBlock(), player, true)) {
break; // TODO: Shouldn't we use continue instead?
}
Material material = blockState.getType();
if (material == Material.HUGE_MUSHROOM_1 || material == Material.HUGE_MUSHROOM_2) {
xp += Woodcutting.getExperienceFromLog(blockState, ExperienceGainMethod.TREE_FELLER);
for (ItemStack drop : blockState.getBlock().getDrops()) {
Misc.dropItem(blockState.getLocation(), drop);
}
}
else if (ModChecks.isCustomLogBlock(blockState)) {
Woodcutting.checkForDoubleDrop(player, blockState);
CustomBlock customBlock = ModChecks.getCustomBlock(blockState);
xp = customBlock.getXpGain();
int minimumDropAmount = customBlock.getMinimumDropAmount();
int maximumDropAmount = customBlock.getMaximumDropAmount();
Location location = blockState.getLocation();
ItemStack item = customBlock.getItemDrop();;
Misc.dropItems(location, item, minimumDropAmount);
if (minimumDropAmount < maximumDropAmount) {
Misc.randomDropItems(location, item, maximumDropAmount - minimumDropAmount);
}
}
else if (ModChecks.isCustomLeafBlock(blockState)) {
Misc.randomDropItem(blockState.getLocation(), ModChecks.getCustomBlock(blockState).getItemDrop(), 10);
}
else {
Tree tree = (Tree) blockState.getData();
switch (material) {
case LOG:
Woodcutting.checkForDoubleDrop(player, blockState);
xp += Woodcutting.getExperienceFromLog(blockState, ExperienceGainMethod.TREE_FELLER);
Misc.dropItem(blockState.getLocation(), new ItemStack(Material.LOG, 1, tree.getSpecies().getData()));
break;
case LEAVES:
Misc.randomDropItem(blockState.getLocation(), new ItemStack(Material.SAPLING, 1, tree.getSpecies().getData()), 10);
break;
default:
break;
}
}
blockState.setRawData((byte) 0x0);
blockState.setType(Material.AIR);
blockState.update(true);
}
Users.getPlayer(player).beginXpGain(SkillType.WOODCUTTING, xp);
}
}
package com.gmail.nossr50.skills.woodcutting;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.BlockState;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.material.Tree;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.mods.CustomBlock;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.woodcutting.Woodcutting.ExperienceGainMethod;
import com.gmail.nossr50.util.BlockUtils;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.ModUtils;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.CombatUtils;
import com.gmail.nossr50.util.skills.SkillUtils;
public final class TreeFeller {
private static boolean treeFellerReachedThreshold = false;
private TreeFeller() {}
/**
* Begins Tree Feller
*
* @param mcMMOPlayer Player using Tree Feller
* @param blockState Block being broken
*/
protected static void processTreeFeller(BlockState blockState, Player player) {
List<BlockState> treeFellerBlocks = new ArrayList<BlockState>();
if (blockState.getTypeId() == 17 || blockState.getTypeId() == 99) {
processRegularTrees(blockState, treeFellerBlocks);
}
else {
processRedMushroomTrees(blockState, treeFellerBlocks);
}
// If the player is trying to break too many blocks
if (treeFellerReachedThreshold) {
treeFellerReachedThreshold = false;
player.sendMessage(LocaleLoader.getString("Woodcutting.Skills.TreeFellerThreshold"));
return;
}
// If the tool can't sustain the durability loss
if (!handleDurabilityLoss(treeFellerBlocks, player.getItemInHand())) {
player.sendMessage(LocaleLoader.getString("Woodcutting.Skills.TreeFeller.Splinter"));
int health = player.getHealth();
if (health > 1) {
CombatUtils.dealDamage(player, Misc.getRandom().nextInt(health - 1));
}
return;
}
dropBlocks(treeFellerBlocks, player);
}
/**
* Processes Tree Feller for generic Trees
*
* @param blockState Block being checked
* @param treeFellerBlocks List of blocks to be removed
*/
private static void processRegularTrees(BlockState blockState, List<BlockState> treeFellerBlocks) {
if (!BlockUtils.isLog(blockState)) {
return;
}
List<BlockState> futureCenterBlocks = new ArrayList<BlockState>();
World world = blockState.getWorld();
// Handle the blocks around 'block'
for (int y = 0; y <= 1; y++) {
for (int x = -1; x <= 1; x++) {
for (int z = -1; z <= 1; z++) {
BlockState nextBlock = world.getBlockAt(blockState.getLocation().add(x, y, z)).getState();
handleBlock(nextBlock, futureCenterBlocks, treeFellerBlocks);
if (treeFellerReachedThreshold) {
return;
}
}
}
}
// Recursive call for each log found
for (BlockState futureCenterBlock : futureCenterBlocks) {
if (treeFellerReachedThreshold) {
return;
}
processRegularTrees(futureCenterBlock, treeFellerBlocks);
}
}
/**
* Processes Tree Feller for Red Mushrooms (Dome Shaped)
*
* @param blockState Block being checked
* @param treeFellerBlocks List of blocks to be removed
*/
private static void processRedMushroomTrees(BlockState blockState, List<BlockState> treeFellerBlocks) {
if (!BlockUtils.isLog(blockState)) {
return;
}
List<BlockState> futureCenterBlocks = new ArrayList<BlockState>();
World world = blockState.getWorld();
// Handle the blocks around 'block'
for (int y = 0; y <= 1; y++) {
for (int x = -1; x <= 1; x++) {
for (int z = -1; z <= 1; z++) {
BlockState nextBlock = world.getBlockAt(blockState.getLocation().add(x, y, z)).getState();
BlockState otherNextBlock = world.getBlockAt(blockState.getLocation().add(x, y - (y * 2), z)).getState();
handleBlock(nextBlock, futureCenterBlocks, treeFellerBlocks);
handleBlock(otherNextBlock, futureCenterBlocks, treeFellerBlocks);
if (treeFellerReachedThreshold) {
return;
}
}
}
}
// Recursive call for each log found
for (BlockState futureCenterBlock : futureCenterBlocks) {
if (treeFellerReachedThreshold) {
return;
}
processRedMushroomTrees(futureCenterBlock, treeFellerBlocks);
}
}
/**
* Handle a block addition to the list of blocks to be removed and to the list of blocks used for future recursive calls of 'processRecursively()'
*
* @param blockState Block to be added
* @param futureCenterBlocks List of blocks that will be used to call 'processRecursively()'
* @param treeFellerBlocks List of blocks to be removed
*/
private static void handleBlock(BlockState blockState, List<BlockState> futureCenterBlocks, List<BlockState> treeFellerBlocks) {
if (!BlockUtils.affectedByTreeFeller(blockState) || mcMMO.placeStore.isTrue(blockState) || treeFellerBlocks.contains(blockState)) {
return;
}
treeFellerBlocks.add(blockState);
if (treeFellerBlocks.size() > Config.getInstance().getTreeFellerThreshold()) {
treeFellerReachedThreshold = true;
return;
}
futureCenterBlocks.add(blockState);
}
/**
* Handles the durability loss
*
* @param treeFellerBlocks List of blocks to be removed
* @param inHand tool being used
* @return True if the tool can sustain the durability loss
*/
private static boolean handleDurabilityLoss(List<BlockState> treeFellerBlocks, ItemStack inHand) {
Material inHandMaterial = inHand.getType();
if (inHandMaterial != Material.AIR) {
short durabilityLoss = 0;
int unbreakingLevel = inHand.getEnchantmentLevel(Enchantment.DURABILITY);
for (BlockState blockState : treeFellerBlocks) {
if (BlockUtils.isLog(blockState) && Misc.getRandom().nextInt(unbreakingLevel + 1) == 0) {
durabilityLoss += Config.getInstance().getAbilityToolDamage();
}
}
short finalDurability = (short) (inHand.getDurability() + durabilityLoss);
short maxDurability = ModUtils.isCustomTool(inHand) ? ModUtils.getToolFromItemStack(inHand).getDurability() : inHandMaterial.getMaxDurability();
if (finalDurability >= maxDurability) {
inHand.setDurability(maxDurability);
return false;
}
inHand.setDurability(finalDurability);
}
return true;
}
/**
* Handles the dropping of blocks
*
* @param treeFellerBlocks List of blocks to be dropped
* @param player Player using the ability
*/
private static void dropBlocks(List<BlockState> treeFellerBlocks, Player player) {
int xp = 0;
for (BlockState blockState : treeFellerBlocks) {
if (!SkillUtils.blockBreakSimulate(blockState.getBlock(), player, true)) {
break; // TODO: Shouldn't we use continue instead?
}
Material material = blockState.getType();
if (material == Material.HUGE_MUSHROOM_1 || material == Material.HUGE_MUSHROOM_2) {
xp += Woodcutting.getExperienceFromLog(blockState, ExperienceGainMethod.TREE_FELLER);
for (ItemStack drop : blockState.getBlock().getDrops()) {
Misc.dropItem(blockState.getLocation(), drop);
}
}
else if (ModUtils.isCustomLogBlock(blockState)) {
Woodcutting.checkForDoubleDrop(player, blockState);
CustomBlock customBlock = ModUtils.getCustomBlock(blockState);
xp = customBlock.getXpGain();
int minimumDropAmount = customBlock.getMinimumDropAmount();
int maximumDropAmount = customBlock.getMaximumDropAmount();
Location location = blockState.getLocation();
ItemStack item = customBlock.getItemDrop();;
Misc.dropItems(location, item, minimumDropAmount);
if (minimumDropAmount < maximumDropAmount) {
Misc.randomDropItems(location, item, maximumDropAmount - minimumDropAmount);
}
}
else if (ModUtils.isCustomLeafBlock(blockState)) {
Misc.randomDropItem(blockState.getLocation(), ModUtils.getCustomBlock(blockState).getItemDrop(), 10);
}
else {
Tree tree = (Tree) blockState.getData();
switch (material) {
case LOG:
Woodcutting.checkForDoubleDrop(player, blockState);
xp += Woodcutting.getExperienceFromLog(blockState, ExperienceGainMethod.TREE_FELLER);
Misc.dropItem(blockState.getLocation(), new ItemStack(Material.LOG, 1, tree.getSpecies().getData()));
break;
case LEAVES:
Misc.randomDropItem(blockState.getLocation(), new ItemStack(Material.SAPLING, 1, tree.getSpecies().getData()), 10);
break;
default:
break;
}
}
blockState.setRawData((byte) 0x0);
blockState.setType(Material.AIR);
blockState.update(true);
}
UserManager.getPlayer(player).beginXpGain(SkillType.WOODCUTTING, xp);
}
}

View File

@ -1,182 +1,182 @@
package com.gmail.nossr50.skills.woodcutting;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.BlockState;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.material.Tree;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
import com.gmail.nossr50.mods.ModChecks;
import com.gmail.nossr50.mods.datatypes.CustomBlock;
import com.gmail.nossr50.skills.utilities.SkillTools;
import com.gmail.nossr50.skills.utilities.SkillType;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Users;
public final class Woodcutting {
public static double doubleDropsMaxChance = AdvancedConfig.getInstance().getWoodcuttingDoubleDropChance();
public static int doubleDropsMaxLevel = AdvancedConfig.getInstance().getWoodcuttingDoubleDropMaxLevel();
protected enum ExperienceGainMethod {
DEFAULT,
TREE_FELLER,
};
private Woodcutting() {}
/**
* Begins the Tree Feller ability
*
* @param mcMMOPlayer Player using the ability
* @param block Block being broken
*/
public static void beginTreeFeller(BlockState blockState, Player player) {
TreeFeller.processTreeFeller(blockState, player);
}
/**
* Begins the Leaf Blower ability
*
* @param player Player using the ability
* @param block Block being broken
*/
public static void beginLeafBlower(Player player, BlockState blockState) {
mcMMO.p.getServer().getPluginManager().callEvent(new FakePlayerAnimationEvent(player));
player.playSound(blockState.getLocation(), Sound.ITEM_PICKUP, Misc.POP_VOLUME, Misc.POP_PITCH);
}
/**
* Begins Woodcutting
*
* @param mcMMOPlayer Player breaking the block
* @param block Block being broken
*/
public static void beginWoodcutting(Player player, BlockState blockState) {
int xp = getExperienceFromLog(blockState, ExperienceGainMethod.DEFAULT);
if (Permissions.doubleDrops(player, SkillType.WOODCUTTING)) {
Material blockType = blockState.getType();
if (blockType != Material.HUGE_MUSHROOM_1 && blockType != Material.HUGE_MUSHROOM_2) {
checkForDoubleDrop(player, blockState);
}
}
Users.getPlayer(player).beginXpGain(SkillType.WOODCUTTING, xp);
}
/**
* Retrieves the experience reward from a log
*
* @param blockState Log being broken
* @param experienceGainMethod How the log is being broken
* @return Amount of experience
*/
protected static int getExperienceFromLog(BlockState blockState, ExperienceGainMethod experienceGainMethod) {
// Mushrooms aren't trees so we could never get species data from them
switch (blockState.getType()) {
case HUGE_MUSHROOM_1:
return Config.getInstance().getWoodcuttingXPHugeBrownMushroom();
case HUGE_MUSHROOM_2:
return Config.getInstance().getWoodcuttingXPHugeRedMushroom();
default:
break;
}
if (ModChecks.isCustomLogBlock(blockState)) {
return ModChecks.getCustomBlock(blockState).getXpGain();
}
switch (((Tree) blockState.getData()).getSpecies()) {
case GENERIC:
return Config.getInstance().getWoodcuttingXPOak();
case REDWOOD:
return Config.getInstance().getWoodcuttingXPSpruce();
case BIRCH:
return Config.getInstance().getWoodcuttingXPBirch();
case JUNGLE:
int xp = Config.getInstance().getWoodcuttingXPJungle();
if (experienceGainMethod == ExperienceGainMethod.TREE_FELLER) {
xp *= 0.5;
}
return xp;
default:
return 0;
}
}
/**
* Checks for double drops
*
* @param mcMMOPlayer Player breaking the block
* @param blockState Block being broken
*/
protected static void checkForDoubleDrop(Player player, BlockState blockState) {
if (!SkillTools.activationSuccessful(player, SkillType.WOODCUTTING, doubleDropsMaxChance, doubleDropsMaxLevel)) {
return;
}
if (ModChecks.isCustomLogBlock(blockState)) {
CustomBlock customBlock = ModChecks.getCustomBlock(blockState);
int minimumDropAmount = customBlock.getMinimumDropAmount();
int maximumDropAmount = customBlock.getMaximumDropAmount();
Location location = blockState.getLocation();
ItemStack item = customBlock.getItemDrop();
Misc.dropItems(location, item, minimumDropAmount);
if (minimumDropAmount != maximumDropAmount) {
Misc.randomDropItems(location, item, maximumDropAmount - minimumDropAmount);
}
}
else {
Location location = blockState.getLocation();
Tree tree = (Tree) blockState.getData();
ItemStack item = new ItemStack(Material.LOG, 1, tree.getSpecies().getData());
switch (((Tree) blockState.getData()).getSpecies()) {
case GENERIC:
if (Config.getInstance().getOakDoubleDropsEnabled()) {
Misc.dropItem(location, item);
}
return;
case REDWOOD:
if (Config.getInstance().getSpruceDoubleDropsEnabled()) {
Misc.dropItem(location, item);
}
return;
case BIRCH:
if (Config.getInstance().getBirchDoubleDropsEnabled()) {
Misc.dropItem(location, item);
}
return;
case JUNGLE:
if (Config.getInstance().getJungleDoubleDropsEnabled()) {
Misc.dropItem(location, item);
}
return;
default:
return;
}
}
}
}
package com.gmail.nossr50.skills.woodcutting;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.BlockState;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.material.Tree;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.mods.CustomBlock;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.ModUtils;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.SkillUtils;
public final class Woodcutting {
public static int doubleDropsMaxLevel = AdvancedConfig.getInstance().getWoodcuttingDoubleDropMaxLevel();
public static double doubleDropsMaxChance = AdvancedConfig.getInstance().getWoodcuttingDoubleDropChance();
protected enum ExperienceGainMethod {
DEFAULT,
TREE_FELLER,
};
private Woodcutting() {}
/**
* Begins the Tree Feller ability
*
* @param mcMMOPlayer Player using the ability
* @param block Block being broken
*/
public static void beginTreeFeller(BlockState blockState, Player player) {
TreeFeller.processTreeFeller(blockState, player);
}
/**
* Begins the Leaf Blower ability
*
* @param player Player using the ability
* @param block Block being broken
*/
public static void beginLeafBlower(Player player, BlockState blockState) {
mcMMO.p.getServer().getPluginManager().callEvent(new FakePlayerAnimationEvent(player));
player.playSound(blockState.getLocation(), Sound.ITEM_PICKUP, Misc.POP_VOLUME, Misc.POP_PITCH);
}
/**
* Begins Woodcutting
*
* @param mcMMOPlayer Player breaking the block
* @param block Block being broken
*/
public static void beginWoodcutting(Player player, BlockState blockState) {
int xp = getExperienceFromLog(blockState, ExperienceGainMethod.DEFAULT);
if (Permissions.doubleDrops(player, SkillType.WOODCUTTING)) {
Material blockType = blockState.getType();
if (blockType != Material.HUGE_MUSHROOM_1 && blockType != Material.HUGE_MUSHROOM_2) {
checkForDoubleDrop(player, blockState);
}
}
UserManager.getPlayer(player).beginXpGain(SkillType.WOODCUTTING, xp);
}
/**
* Retrieves the experience reward from a log
*
* @param blockState Log being broken
* @param experienceGainMethod How the log is being broken
* @return Amount of experience
*/
protected static int getExperienceFromLog(BlockState blockState, ExperienceGainMethod experienceGainMethod) {
// Mushrooms aren't trees so we could never get species data from them
switch (blockState.getType()) {
case HUGE_MUSHROOM_1:
return Config.getInstance().getWoodcuttingXPHugeBrownMushroom();
case HUGE_MUSHROOM_2:
return Config.getInstance().getWoodcuttingXPHugeRedMushroom();
default:
break;
}
if (ModUtils.isCustomLogBlock(blockState)) {
return ModUtils.getCustomBlock(blockState).getXpGain();
}
switch (((Tree) blockState.getData()).getSpecies()) {
case GENERIC:
return Config.getInstance().getWoodcuttingXPOak();
case REDWOOD:
return Config.getInstance().getWoodcuttingXPSpruce();
case BIRCH:
return Config.getInstance().getWoodcuttingXPBirch();
case JUNGLE:
int xp = Config.getInstance().getWoodcuttingXPJungle();
if (experienceGainMethod == ExperienceGainMethod.TREE_FELLER) {
xp *= 0.5;
}
return xp;
default:
return 0;
}
}
/**
* Checks for double drops
*
* @param mcMMOPlayer Player breaking the block
* @param blockState Block being broken
*/
protected static void checkForDoubleDrop(Player player, BlockState blockState) {
if (!SkillUtils.activationSuccessful(player, SkillType.WOODCUTTING, doubleDropsMaxChance, doubleDropsMaxLevel)) {
return;
}
if (ModUtils.isCustomLogBlock(blockState)) {
CustomBlock customBlock = ModUtils.getCustomBlock(blockState);
int minimumDropAmount = customBlock.getMinimumDropAmount();
int maximumDropAmount = customBlock.getMaximumDropAmount();
Location location = blockState.getLocation();
ItemStack item = customBlock.getItemDrop();
Misc.dropItems(location, item, minimumDropAmount);
if (minimumDropAmount != maximumDropAmount) {
Misc.randomDropItems(location, item, maximumDropAmount - minimumDropAmount);
}
}
else {
Location location = blockState.getLocation();
Tree tree = (Tree) blockState.getData();
ItemStack item = new ItemStack(Material.LOG, 1, tree.getSpecies().getData());
switch (((Tree) blockState.getData()).getSpecies()) {
case GENERIC:
if (Config.getInstance().getOakDoubleDropsEnabled()) {
Misc.dropItem(location, item);
}
return;
case REDWOOD:
if (Config.getInstance().getSpruceDoubleDropsEnabled()) {
Misc.dropItem(location, item);
}
return;
case BIRCH:
if (Config.getInstance().getBirchDoubleDropsEnabled()) {
Misc.dropItem(location, item);
}
return;
case JUNGLE:
if (Config.getInstance().getJungleDoubleDropsEnabled()) {
Misc.dropItem(location, item);
}
return;
default:
return;
}
}
}
}

View File

@ -1,103 +0,0 @@
package com.gmail.nossr50.skills.woodcutting;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.SkillCommand;
import com.gmail.nossr50.skills.utilities.SkillType;
import com.gmail.nossr50.util.Permissions;
public class WoodcuttingCommand extends SkillCommand {
private String treeFellerLength;
private String treeFellerLengthEndurance;
private String doubleDropChance;
private String doubleDropChanceLucky;
private boolean canTreeFell;
private boolean canLeafBlow;
private boolean canDoubleDrop;
private boolean doubleDropsDisabled;
public WoodcuttingCommand() {
super(SkillType.WOODCUTTING);
}
@Override
protected void dataCalculations() {
//TREE FELLER
String[] treeFellerStrings = calculateLengthDisplayValues();
treeFellerLength = treeFellerStrings[0];
treeFellerLengthEndurance = treeFellerStrings[1];
//DOUBLE DROPS
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);
canLeafBlow = Permissions.leafBlower(player);
doubleDropsDisabled = skill.getDoubleDropsDisabled();
}
@Override
protected boolean effectsHeaderPermissions() {
return (canDoubleDrop && !doubleDropsDisabled) || canLeafBlow || canTreeFell;
}
@Override
protected void effectsDisplay() {
luckyEffectsDisplay();
if (canTreeFell) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Woodcutting.Effect.0"), LocaleLoader.getString("Woodcutting.Effect.1")));
}
if (canLeafBlow) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Woodcutting.Effect.2"), LocaleLoader.getString("Woodcutting.Effect.3")));
}
if (canDoubleDrop && !doubleDropsDisabled) {
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;
}
@Override
protected void statsDisplay() {
if (canLeafBlow) {
int leafBlowerUnlockLevel = AdvancedConfig.getInstance().getLeafBlowUnlockLevel();
if (skillValue < leafBlowerUnlockLevel) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Woodcutting.Ability.Locked.0", leafBlowerUnlockLevel)));
}
else {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", LocaleLoader.getString("Woodcutting.Ability.0"), LocaleLoader.getString("Woodcutting.Ability.1")));
}
}
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 (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));
}
}
}
}