mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 07:06:45 +01:00
Handle all our donor perks in one class.
This commit is contained in:
parent
671be42472
commit
083a89c1a3
@ -12,6 +12,7 @@ import com.gmail.nossr50.mods.datatypes.CustomTool;
|
|||||||
import com.gmail.nossr50.party.Party;
|
import com.gmail.nossr50.party.Party;
|
||||||
import com.gmail.nossr50.party.PartyManager;
|
import com.gmail.nossr50.party.PartyManager;
|
||||||
import com.gmail.nossr50.party.ShareHandler;
|
import com.gmail.nossr50.party.ShareHandler;
|
||||||
|
import com.gmail.nossr50.skills.utilities.PerksUtils;
|
||||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||||
import com.gmail.nossr50.spout.huds.SpoutHud;
|
import com.gmail.nossr50.spout.huds.SpoutHud;
|
||||||
@ -140,23 +141,7 @@ public class McMMOPlayer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Too many permission checks here, is there no way to avoid that?
|
xp = PerksUtils.handleXpPerks(player, xp);
|
||||||
if (player.hasPermission("mcmmo.perks.xp.quadruple")) {
|
|
||||||
xp *= 4;
|
|
||||||
}
|
|
||||||
else if (player.hasPermission("mcmmo.perks.xp.triple")) {
|
|
||||||
xp *= 3;
|
|
||||||
}
|
|
||||||
else if (player.hasPermission("mcmmo.perks.xp.150percentboost")) {
|
|
||||||
xp *= 2.5;
|
|
||||||
}
|
|
||||||
else if (player.hasPermission("mcmmo.perks.xp.150percentboost")) {
|
|
||||||
xp *= 2;
|
|
||||||
}
|
|
||||||
else if (player.hasPermission("mcmmo.perks.xp.50percentboost")) {
|
|
||||||
xp *= 1.5;
|
|
||||||
}
|
|
||||||
|
|
||||||
return xp;
|
return xp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@ import org.bukkit.entity.Player;
|
|||||||
import com.gmail.nossr50.commands.CommandHelper;
|
import com.gmail.nossr50.commands.CommandHelper;
|
||||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
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.SkillTools;
|
||||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||||
import com.gmail.nossr50.util.StringUtils;
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
@ -124,26 +125,12 @@ public abstract class SkillCommand implements CommandExecutor {
|
|||||||
protected String[] calculateLengthDisplayValues() {
|
protected String[] calculateLengthDisplayValues() {
|
||||||
int maxLength = skill.getAbility().getMaxTicks();
|
int maxLength = skill.getAbility().getMaxTicks();
|
||||||
int length = 2 + (int) (skillValue / SkillTools.abilityLengthIncreaseLevel);
|
int length = 2 + (int) (skillValue / SkillTools.abilityLengthIncreaseLevel);
|
||||||
int enduranceLength = 0;
|
int enduranceLength = PerksUtils.handleActivationPerks(player, length, maxLength);
|
||||||
|
|
||||||
if (player.hasPermission("mcmmo.perks.activationtime.twelveseconds")) {
|
|
||||||
enduranceLength = length + 12;
|
|
||||||
}
|
|
||||||
else if (player.hasPermission("mcmmo.perks.activationtime.eightseconds")) {
|
|
||||||
enduranceLength = length + 8;
|
|
||||||
}
|
|
||||||
else if (player.hasPermission("mcmmo.perks.activationtime.fourseconds")) {
|
|
||||||
enduranceLength = length + 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (maxLength != 0) {
|
if (maxLength != 0) {
|
||||||
if (length > maxLength) {
|
if (length > maxLength) {
|
||||||
length = maxLength;
|
length = maxLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (enduranceLength > maxLength) {
|
|
||||||
enduranceLength = maxLength;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return new String[] { String.valueOf(length), String.valueOf(enduranceLength) };
|
return new String[] { String.valueOf(length), String.valueOf(enduranceLength) };
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package com.gmail.nossr50.skills;
|
package com.gmail.nossr50.skills;
|
||||||
|
|
||||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
import com.gmail.nossr50.skills.utilities.PerksUtils;
|
||||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
|
|
||||||
@ -13,7 +13,7 @@ public abstract class SkillManager {
|
|||||||
public SkillManager(McMMOPlayer mcMMOPlayer, SkillType skill) {
|
public SkillManager(McMMOPlayer mcMMOPlayer, SkillType skill) {
|
||||||
this.mcMMOPlayer = mcMMOPlayer;
|
this.mcMMOPlayer = mcMMOPlayer;
|
||||||
this.skillLevel = mcMMOPlayer.getProfile().getSkillLevel(skill);
|
this.skillLevel = mcMMOPlayer.getProfile().getSkillLevel(skill);
|
||||||
this.activationChance = SkillTools.calculateActivationChance(Permissions.lucky(mcMMOPlayer.getPlayer(), skill));
|
this.activationChance = PerksUtils.handleLuckyPerks(Permissions.lucky(mcMMOPlayer.getPlayer(), skill));
|
||||||
}
|
}
|
||||||
|
|
||||||
public McMMOPlayer getMcMMOPlayer() {
|
public McMMOPlayer getMcMMOPlayer() {
|
||||||
|
@ -13,7 +13,7 @@ import com.gmail.nossr50.config.TreasuresConfig;
|
|||||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||||
import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure;
|
import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure;
|
||||||
import com.gmail.nossr50.mods.ModChecks;
|
import com.gmail.nossr50.mods.ModChecks;
|
||||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
import com.gmail.nossr50.skills.utilities.PerksUtils;
|
||||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
@ -105,7 +105,7 @@ public class Excavation {
|
|||||||
|
|
||||||
for (ExcavationTreasure treasure : treasures) {
|
for (ExcavationTreasure treasure : treasures) {
|
||||||
if (mcMMOPlayer.getProfile().getSkillLevel(SkillType.EXCAVATION) >= treasure.getDropLevel()) {
|
if (mcMMOPlayer.getProfile().getSkillLevel(SkillType.EXCAVATION) >= treasure.getDropLevel()) {
|
||||||
int activationChance = SkillTools.calculateActivationChance(Permissions.luckyExcavation(player));
|
int activationChance = PerksUtils.handleLuckyPerks(Permissions.luckyExcavation(player));
|
||||||
|
|
||||||
if (Misc.getRandom().nextDouble() * activationChance <= treasure.getDropChance()) {
|
if (Misc.getRandom().nextDouble() * activationChance <= treasure.getDropChance()) {
|
||||||
xp += treasure.getXp();
|
xp += treasure.getXp();
|
||||||
|
@ -18,6 +18,7 @@ import com.gmail.nossr50.config.TreasuresConfig;
|
|||||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||||
import com.gmail.nossr50.datatypes.treasure.FishingTreasure;
|
import com.gmail.nossr50.datatypes.treasure.FishingTreasure;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
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.SkillTools;
|
||||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||||
import com.gmail.nossr50.util.ItemChecks;
|
import com.gmail.nossr50.util.ItemChecks;
|
||||||
@ -160,7 +161,7 @@ public final class Fishing {
|
|||||||
|
|
||||||
FishingTreasure treasure = rewards.get(Misc.getRandom().nextInt(rewards.size()));
|
FishingTreasure treasure = rewards.get(Misc.getRandom().nextInt(rewards.size()));
|
||||||
ItemStack treasureDrop = treasure.getDrop();
|
ItemStack treasureDrop = treasure.getDrop();
|
||||||
int activationChance = SkillTools.calculateActivationChance(Permissions.luckyFishing(player));
|
int activationChance = PerksUtils.handleLuckyPerks(Permissions.luckyFishing(player));
|
||||||
|
|
||||||
if (Misc.getRandom().nextDouble() * activationChance > treasure.getDropChance()) {
|
if (Misc.getRandom().nextDouble() * activationChance > treasure.getDropChance()) {
|
||||||
return null;
|
return null;
|
||||||
@ -189,7 +190,7 @@ public final class Fishing {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int activationChance = SkillTools.calculateActivationChance(Permissions.luckyFishing(player));
|
int activationChance = PerksUtils.handleLuckyPerks(Permissions.luckyFishing(player));
|
||||||
|
|
||||||
if (storm) {
|
if (storm) {
|
||||||
activationChance = (int) (activationChance * 0.909);
|
activationChance = (int) (activationChance * 0.909);
|
||||||
|
@ -18,7 +18,7 @@ import org.bukkit.potion.PotionType;
|
|||||||
|
|
||||||
import com.gmail.nossr50.skills.fishing.Fishing.Tier;
|
import com.gmail.nossr50.skills.fishing.Fishing.Tier;
|
||||||
import com.gmail.nossr50.skills.utilities.CombatTools;
|
import com.gmail.nossr50.skills.utilities.CombatTools;
|
||||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
import com.gmail.nossr50.skills.utilities.PerksUtils;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
|
|
||||||
@ -33,7 +33,7 @@ public final class ShakeMob {
|
|||||||
* @param skillLevel Fishing level of the player
|
* @param skillLevel Fishing level of the player
|
||||||
*/
|
*/
|
||||||
public static void process(Player player, LivingEntity mob, int skillLevel) {
|
public static void process(Player player, LivingEntity mob, int skillLevel) {
|
||||||
int activationChance = SkillTools.calculateActivationChance(Permissions.luckyFishing(player));
|
int activationChance = PerksUtils.handleLuckyPerks(Permissions.luckyFishing(player));
|
||||||
|
|
||||||
if (getShakeProbability(skillLevel) <= Misc.getRandom().nextInt(activationChance)) {
|
if (getShakeProbability(skillLevel) <= Misc.getRandom().nextInt(activationChance)) {
|
||||||
return;
|
return;
|
||||||
|
@ -25,6 +25,7 @@ import com.gmail.nossr50.locale.LocaleLoader;
|
|||||||
import com.gmail.nossr50.mods.ModChecks;
|
import com.gmail.nossr50.mods.ModChecks;
|
||||||
import com.gmail.nossr50.mods.datatypes.CustomBlock;
|
import com.gmail.nossr50.mods.datatypes.CustomBlock;
|
||||||
import com.gmail.nossr50.skills.utilities.AbilityType;
|
import com.gmail.nossr50.skills.utilities.AbilityType;
|
||||||
|
import com.gmail.nossr50.skills.utilities.PerksUtils;
|
||||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
@ -190,7 +191,7 @@ public class Herbalism {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (Permissions.herbalismDoubleDrops(player)) {
|
if (Permissions.herbalismDoubleDrops(player)) {
|
||||||
int activationChance = SkillTools.calculateActivationChance(Permissions.luckyHerbalism(player));
|
int activationChance = PerksUtils.handleLuckyPerks(Permissions.luckyHerbalism(player));
|
||||||
double chance = (doubleDropsMaxChance / doubleDropsMaxLevel) * SkillTools.skillCheck(herbLevel, doubleDropsMaxLevel);
|
double chance = (doubleDropsMaxChance / doubleDropsMaxLevel) * SkillTools.skillCheck(herbLevel, doubleDropsMaxLevel);
|
||||||
|
|
||||||
if (chance > Misc.getRandom().nextInt(activationChance)) {
|
if (chance > Misc.getRandom().nextInt(activationChance)) {
|
||||||
@ -254,7 +255,7 @@ public class Herbalism {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int activationChance = SkillTools.calculateActivationChance(Permissions.luckyHerbalism(player));
|
int activationChance = PerksUtils.handleLuckyPerks(Permissions.luckyHerbalism(player));
|
||||||
float chance = (float) (greenThumbMaxChance / greenThumbMaxLevel * herbLevel);
|
float chance = (float) (greenThumbMaxChance / greenThumbMaxLevel * herbLevel);
|
||||||
|
|
||||||
if (chance > greenThumbMaxChance) {
|
if (chance > greenThumbMaxChance) {
|
||||||
@ -301,7 +302,7 @@ public class Herbalism {
|
|||||||
|
|
||||||
player.setItemInHand(new ItemStack(Material.SEEDS, seeds - 1));
|
player.setItemInHand(new ItemStack(Material.SEEDS, seeds - 1));
|
||||||
|
|
||||||
int activationChance = SkillTools.calculateActivationChance(Permissions.luckyHerbalism(player));
|
int activationChance = PerksUtils.handleLuckyPerks(Permissions.luckyHerbalism(player));
|
||||||
|
|
||||||
float chance = (float) ((greenThumbMaxChance / greenThumbMaxLevel) * skillLevel);
|
float chance = (float) ((greenThumbMaxChance / greenThumbMaxLevel) * skillLevel);
|
||||||
if (chance > greenThumbMaxChance) chance = (float) greenThumbMaxChance;
|
if (chance > greenThumbMaxChance) chance = (float) greenThumbMaxChance;
|
||||||
@ -318,7 +319,7 @@ public class Herbalism {
|
|||||||
int skillLevel = Users.getPlayer(player).getProfile().getSkillLevel(SkillType.HERBALISM);
|
int skillLevel = Users.getPlayer(player).getProfile().getSkillLevel(SkillType.HERBALISM);
|
||||||
|
|
||||||
double chance = (hylianLuckMaxChance / hylianLuckMaxLevel) * SkillTools.skillCheck(skillLevel, hylianLuckMaxLevel);
|
double chance = (hylianLuckMaxChance / hylianLuckMaxLevel) * SkillTools.skillCheck(skillLevel, hylianLuckMaxLevel);
|
||||||
int activationChance = SkillTools.calculateActivationChance(Permissions.luckyHerbalism(player));
|
int activationChance = PerksUtils.handleLuckyPerks(Permissions.luckyHerbalism(player));
|
||||||
|
|
||||||
if (chance > Misc.getRandom().nextInt(activationChance)) {
|
if (chance > Misc.getRandom().nextInt(activationChance)) {
|
||||||
List<HylianTreasure> treasures = new ArrayList<HylianTreasure>();
|
List<HylianTreasure> treasures = new ArrayList<HylianTreasure>();
|
||||||
|
@ -17,7 +17,7 @@ import com.gmail.nossr50.config.Config;
|
|||||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
import com.gmail.nossr50.skills.utilities.PerksUtils;
|
||||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
@ -110,7 +110,7 @@ public class Repair {
|
|||||||
for (Entry<Enchantment, Integer> enchant : enchants.entrySet()) {
|
for (Entry<Enchantment, Integer> enchant : enchants.entrySet()) {
|
||||||
Enchantment enchantment = enchant.getKey();
|
Enchantment enchantment = enchant.getKey();
|
||||||
|
|
||||||
int activationChance = SkillTools.calculateActivationChance(Permissions.luckyRepair(player));
|
int activationChance = PerksUtils.handleLuckyPerks(Permissions.luckyRepair(player));
|
||||||
|
|
||||||
if (Misc.getRandom().nextInt(activationChance) <= getEnchantChance(rank)) {
|
if (Misc.getRandom().nextInt(activationChance) <= getEnchantChance(rank)) {
|
||||||
int enchantLevel = enchant.getValue();
|
int enchantLevel = enchant.getValue();
|
||||||
@ -237,7 +237,7 @@ public class Repair {
|
|||||||
int chance = (int) ((SUPER_REPAIR_CHANCE_MAX / SUPER_REPAIR_MAX_BONUS_LEVEL) * skillLevel);
|
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;
|
if (skillLevel >= SUPER_REPAIR_MAX_BONUS_LEVEL) chance = (int) SUPER_REPAIR_CHANCE_MAX;
|
||||||
|
|
||||||
int activationChance = SkillTools.calculateActivationChance(Permissions.luckyRepair(player));
|
int activationChance = PerksUtils.handleLuckyPerks(Permissions.luckyRepair(player));
|
||||||
|
|
||||||
if (chance > Misc.getRandom().nextInt(activationChance) && Permissions.repairBonus(player)) {
|
if (chance > Misc.getRandom().nextInt(activationChance) && Permissions.repairBonus(player)) {
|
||||||
player.sendMessage(LocaleLoader.getString("Repair.Skills.FeltEasy"));
|
player.sendMessage(LocaleLoader.getString("Repair.Skills.FeltEasy"));
|
||||||
|
@ -6,7 +6,7 @@ import org.bukkit.event.entity.EntityDamageEvent;
|
|||||||
|
|
||||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||||
import com.gmail.nossr50.skills.SkillManager;
|
import com.gmail.nossr50.skills.SkillManager;
|
||||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
import com.gmail.nossr50.skills.utilities.PerksUtils;
|
||||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
@ -87,7 +87,7 @@ public class UnarmedManager extends SkillManager {
|
|||||||
|
|
||||||
double chance = (Unarmed.ironGripMaxChance / Unarmed.ironGripMaxBonusLevel) * eventHandler.skillModifier;
|
double chance = (Unarmed.ironGripMaxChance / Unarmed.ironGripMaxBonusLevel) * eventHandler.skillModifier;
|
||||||
|
|
||||||
if (chance > Misc.getRandom().nextInt(SkillTools.calculateActivationChance(Permissions.luckyUnarmed(defender)))) {
|
if (chance > Misc.getRandom().nextInt(PerksUtils.handleLuckyPerks(Permissions.luckyUnarmed(defender)))) {
|
||||||
eventHandler.sendAbilityMessages();
|
eventHandler.sendAbilityMessages();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,78 @@
|
|||||||
|
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.cooldownsHalved(player)) {
|
||||||
|
cooldown *= 0.5;
|
||||||
|
}
|
||||||
|
else if (Permissions.cooldownsThirded(player)) {
|
||||||
|
cooldown *= (1.0 / 3.0);
|
||||||
|
}
|
||||||
|
else if (Permissions.cooldownsQuartered(player)) {
|
||||||
|
cooldown *= 0.75;
|
||||||
|
}
|
||||||
|
|
||||||
|
return cooldown;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int handleActivationPerks(Player player, int ticks, int maxTicks) {
|
||||||
|
if (Permissions.activationTwelve(player)) {
|
||||||
|
ticks += 12;
|
||||||
|
}
|
||||||
|
else if (Permissions.activationEight(player)) {
|
||||||
|
ticks += 8;
|
||||||
|
}
|
||||||
|
else if (Permissions.activationFour(player)) {
|
||||||
|
ticks += 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (maxTicks != 0 && ticks > maxTicks) {
|
||||||
|
ticks = maxTicks;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ticks;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int handleXpPerks(Player player, int xp) {
|
||||||
|
if (player.hasPermission("mcmmo.perks.xp.quadruple")) {
|
||||||
|
xp *= 4;
|
||||||
|
}
|
||||||
|
else if (player.hasPermission("mcmmo.perks.xp.triple")) {
|
||||||
|
xp *= 3;
|
||||||
|
}
|
||||||
|
else if (player.hasPermission("mcmmo.perks.xp.150percentboost")) {
|
||||||
|
xp *= 2.5;
|
||||||
|
}
|
||||||
|
else if (player.hasPermission("mcmmo.perks.xp.150percentboost")) {
|
||||||
|
xp *= 2;
|
||||||
|
}
|
||||||
|
else if (player.hasPermission("mcmmo.perks.xp.50percentboost")) {
|
||||||
|
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(boolean isLucky) {
|
||||||
|
if (isLucky) {
|
||||||
|
return LUCKY_SKILL_ACTIVATION_CHANCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NORMAL_SKILL_ACTIVATION_CHANCE;
|
||||||
|
}
|
||||||
|
}
|
@ -41,9 +41,6 @@ public class SkillTools {
|
|||||||
public static int toolDurabilityLoss = Config.getInstance().getAbilityToolDamage();
|
public static int toolDurabilityLoss = Config.getInstance().getAbilityToolDamage();
|
||||||
public static int abilityLengthIncreaseLevel = AdvancedConfig.getInstance().getAbilityLength();
|
public static int abilityLengthIncreaseLevel = AdvancedConfig.getInstance().getAbilityLength();
|
||||||
|
|
||||||
public static final int LUCKY_SKILL_ACTIVATION_CHANCE = 75;
|
|
||||||
public static final int NORMAL_SKILL_ACTIVATION_CHANCE = 100;
|
|
||||||
|
|
||||||
public static void handleFoodSkills(Player player, SkillType skill, FoodLevelChangeEvent event, int baseLevel, int maxLevel, int rankChange) {
|
public static void handleFoodSkills(Player player, SkillType skill, FoodLevelChangeEvent event, int baseLevel, int maxLevel, int rankChange) {
|
||||||
int skillLevel = Users.getPlayer(player).getProfile().getSkillLevel(skill);
|
int skillLevel = Users.getPlayer(player).getProfile().getSkillLevel(skill);
|
||||||
|
|
||||||
@ -70,18 +67,7 @@ public class SkillTools {
|
|||||||
*/
|
*/
|
||||||
public static boolean cooldownOver(long oldTime, int cooldown, Player player) {
|
public static boolean cooldownOver(long oldTime, int cooldown, Player player) {
|
||||||
long currentTime = System.currentTimeMillis();
|
long currentTime = System.currentTimeMillis();
|
||||||
int adjustedCooldown = cooldown;
|
int adjustedCooldown = PerksUtils.handleCooldownPerks(player, cooldown);
|
||||||
|
|
||||||
//Reduced Cooldown Donor Perks
|
|
||||||
if (Permissions.cooldownsHalved(player)) {
|
|
||||||
adjustedCooldown = (int) (adjustedCooldown * 0.5);
|
|
||||||
}
|
|
||||||
else if (Permissions.cooldownsThirded(player)) {
|
|
||||||
adjustedCooldown = (int) (adjustedCooldown * 0.66);
|
|
||||||
}
|
|
||||||
else if (Permissions.cooldownsQuartered(player)) {
|
|
||||||
adjustedCooldown = (int) (adjustedCooldown * 0.75);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (currentTime - oldTime >= (adjustedCooldown * Misc.TIME_CONVERSION_FACTOR)) {
|
if (currentTime - oldTime >= (adjustedCooldown * Misc.TIME_CONVERSION_FACTOR)) {
|
||||||
return true;
|
return true;
|
||||||
@ -98,20 +84,7 @@ public class SkillTools {
|
|||||||
* @return the number of seconds remaining before the cooldown expires
|
* @return the number of seconds remaining before the cooldown expires
|
||||||
*/
|
*/
|
||||||
public static int calculateTimeLeft(long deactivatedTimeStamp, int cooldown, Player player) {
|
public static int calculateTimeLeft(long deactivatedTimeStamp, int cooldown, Player player) {
|
||||||
int adjustedCooldown = cooldown;
|
return (int) (((deactivatedTimeStamp + (PerksUtils.handleCooldownPerks(player, cooldown) * Misc.TIME_CONVERSION_FACTOR)) - System.currentTimeMillis()) / Misc.TIME_CONVERSION_FACTOR);
|
||||||
|
|
||||||
//Reduced Cooldown Donor Perks
|
|
||||||
if (Permissions.cooldownsHalved(player)) {
|
|
||||||
adjustedCooldown = (int) (adjustedCooldown * 0.5);
|
|
||||||
}
|
|
||||||
else if (Permissions.cooldownsThirded(player)) {
|
|
||||||
adjustedCooldown = (int) (adjustedCooldown * 0.66);
|
|
||||||
}
|
|
||||||
else if (Permissions.cooldownsQuartered(player)) {
|
|
||||||
adjustedCooldown = (int) (adjustedCooldown * 0.75);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (int) (((deactivatedTimeStamp + (adjustedCooldown * Misc.TIME_CONVERSION_FACTOR)) - System.currentTimeMillis()) / Misc.TIME_CONVERSION_FACTOR);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -386,24 +359,6 @@ public class SkillTools {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Handle tool durability loss from abilities.
|
|
||||||
*
|
|
||||||
* @param inHand The item to damage
|
|
||||||
* @param durabilityLoss The durability to remove from the item
|
|
||||||
*/
|
|
||||||
public static void abilityDurabilityLoss(ItemStack inHand, int durabilityLoss) {
|
|
||||||
if (Config.getInstance().getAbilitiesDamageTools()) {
|
|
||||||
if (inHand.containsEnchantment(Enchantment.DURABILITY)) {
|
|
||||||
int level = inHand.getEnchantmentLevel(Enchantment.DURABILITY);
|
|
||||||
if (Misc.getRandom().nextInt(level + 1) > 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
inHand.setDurability((short) (inHand.getDurability() + durabilityLoss));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check to see if an ability can be activated.
|
* Check to see if an ability can be activated.
|
||||||
*
|
*
|
||||||
@ -427,30 +382,12 @@ public class SkillTools {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int ticks = 2 + (profile.getSkillLevel(type) / abilityLengthIncreaseLevel);
|
|
||||||
|
|
||||||
if (Permissions.activationTwelve(player)) {
|
|
||||||
ticks = ticks + 12;
|
|
||||||
}
|
|
||||||
else if (Permissions.activationEight(player)) {
|
|
||||||
ticks = ticks + 8;
|
|
||||||
}
|
|
||||||
else if (Permissions.activationFour(player)) {
|
|
||||||
ticks = ticks + 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
int maxTicks = ability.getMaxTicks();
|
|
||||||
|
|
||||||
if (maxTicks != 0 && ticks > maxTicks) {
|
|
||||||
ticks = maxTicks;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!profile.getAbilityMode(ability) && cooldownOver(profile.getSkillDATS(ability), ability.getCooldown(), player)) {
|
if (!profile.getAbilityMode(ability) && cooldownOver(profile.getSkillDATS(ability), ability.getCooldown(), player)) {
|
||||||
player.sendMessage(ability.getAbilityOn());
|
player.sendMessage(ability.getAbilityOn());
|
||||||
|
|
||||||
SkillTools.sendSkillMessage(player, ability.getAbilityPlayer(player));
|
SkillTools.sendSkillMessage(player, ability.getAbilityPlayer(player));
|
||||||
|
|
||||||
profile.setSkillDATS(ability, System.currentTimeMillis() + (ticks * Misc.TIME_CONVERSION_FACTOR));
|
profile.setSkillDATS(ability, System.currentTimeMillis() + (PerksUtils.handleActivationPerks(player, 2 + (profile.getSkillLevel(type) / abilityLengthIncreaseLevel), ability.getMaxTicks()) * Misc.TIME_CONVERSION_FACTOR));
|
||||||
profile.setAbilityMode(ability, true);
|
profile.setAbilityMode(ability, true);
|
||||||
|
|
||||||
if (ability == AbilityType.BERSERK) {
|
if (ability == AbilityType.BERSERK) {
|
||||||
@ -504,20 +441,6 @@ public class SkillTools {
|
|||||||
return activate;
|
return activate;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 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 calculateActivationChance(boolean isLucky) {
|
|
||||||
if (isLucky) {
|
|
||||||
return LUCKY_SKILL_ACTIVATION_CHANCE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return NORMAL_SKILL_ACTIVATION_CHANCE;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void sendSkillMessage(Player player, String message) {
|
public static void sendSkillMessage(Player player, String message) {
|
||||||
for (Player otherPlayer : player.getWorld().getPlayers()) {
|
for (Player otherPlayer : player.getWorld().getPlayers()) {
|
||||||
if (otherPlayer != player && Misc.isNear(player.getLocation(), otherPlayer.getLocation(), Misc.SKILL_MESSAGE_MAX_SENDING_DISTANCE)) {
|
if (otherPlayer != player && Misc.isNear(player.getLocation(), otherPlayer.getLocation(), Misc.SKILL_MESSAGE_MAX_SENDING_DISTANCE)) {
|
||||||
|
@ -15,7 +15,7 @@ import com.gmail.nossr50.datatypes.McMMOPlayer;
|
|||||||
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
|
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
|
||||||
import com.gmail.nossr50.mods.ModChecks;
|
import com.gmail.nossr50.mods.ModChecks;
|
||||||
import com.gmail.nossr50.mods.datatypes.CustomBlock;
|
import com.gmail.nossr50.mods.datatypes.CustomBlock;
|
||||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
import com.gmail.nossr50.skills.utilities.PerksUtils;
|
||||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
@ -143,7 +143,7 @@ public final class Woodcutting {
|
|||||||
double configDoubleDropChance = ADVANCED_CONFIG.getWoodcuttingDoubleDropChance();
|
double configDoubleDropChance = ADVANCED_CONFIG.getWoodcuttingDoubleDropChance();
|
||||||
int configDoubleDropMaxLevel = ADVANCED_CONFIG.getWoodcuttingDoubleDropMaxLevel();
|
int configDoubleDropMaxLevel = ADVANCED_CONFIG.getWoodcuttingDoubleDropMaxLevel();
|
||||||
int probability = (int) ((configDoubleDropChance / configDoubleDropMaxLevel) * Users.getPlayer(player).getProfile().getSkillLevel(SkillType.WOODCUTTING));
|
int probability = (int) ((configDoubleDropChance / configDoubleDropMaxLevel) * Users.getPlayer(player).getProfile().getSkillLevel(SkillType.WOODCUTTING));
|
||||||
int activationChance = SkillTools.calculateActivationChance(Permissions.luckyWoodcutting(player));
|
int activationChance = PerksUtils.handleLuckyPerks(Permissions.luckyWoodcutting(player));
|
||||||
|
|
||||||
if (probability > configDoubleDropChance) {
|
if (probability > configDoubleDropChance) {
|
||||||
probability = (int) configDoubleDropChance;
|
probability = (int) configDoubleDropChance;
|
||||||
|
@ -1,11 +1,14 @@
|
|||||||
package com.gmail.nossr50.util;
|
package com.gmail.nossr50.util;
|
||||||
|
|
||||||
|
import java.text.DecimalFormat;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.PluginDescriptionFile;
|
import org.bukkit.plugin.PluginDescriptionFile;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
|
import com.gmail.nossr50.skills.utilities.PerksUtils;
|
||||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||||
|
|
||||||
public final class Motd {
|
public final class Motd {
|
||||||
@ -56,21 +59,7 @@ public final class Motd {
|
|||||||
* @param player Target player
|
* @param player Target player
|
||||||
*/
|
*/
|
||||||
public static void displayXpPerks(Player player) {
|
public static void displayXpPerks(Player player) {
|
||||||
if (Permissions.xpQuadruple(player)) {
|
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Perks.xp.name"), LocaleLoader.getString("Perks.xp.desc", PerksUtils.handleXpPerks(player, 1))));
|
||||||
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Perks.xp.name"), LocaleLoader.getString("Perks.xp.desc", 4)));
|
|
||||||
}
|
|
||||||
else if (Permissions.xpTriple(player)) {
|
|
||||||
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Perks.xp.name"), LocaleLoader.getString("Perks.xp.desc", 3)));
|
|
||||||
}
|
|
||||||
else if (Permissions.xpDoubleAndOneHalf(player)) {
|
|
||||||
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Perks.xp.name"), LocaleLoader.getString("Perks.xp.desc", 2.5)));
|
|
||||||
}
|
|
||||||
else if (Permissions.xpDouble(player)) {
|
|
||||||
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Perks.xp.name"), LocaleLoader.getString("Perks.xp.desc", 2)));
|
|
||||||
}
|
|
||||||
else if (Permissions.xpOneAndOneHalf(player)) {
|
|
||||||
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Perks.xp.name"), LocaleLoader.getString("Perks.xp.desc", 1.5)));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -78,15 +67,10 @@ public final class Motd {
|
|||||||
* @param player Target player
|
* @param player Target player
|
||||||
*/
|
*/
|
||||||
public static void displayCooldownPerks(Player player) {
|
public static void displayCooldownPerks(Player player) {
|
||||||
if (Permissions.cooldownsHalved(player)) {
|
double cooldownReduction = 1 - (PerksUtils.handleCooldownPerks(player, 12) / 12.0);
|
||||||
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Perks.cooldowns.name"), LocaleLoader.getString("Perks.cooldowns.desc", "1/2")));
|
DecimalFormat percent = new DecimalFormat("##0.00%");
|
||||||
}
|
|
||||||
else if (Permissions.cooldownsThirded(player)) {
|
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Perks.cooldowns.name"), LocaleLoader.getString("Perks.cooldowns.desc", percent.format(cooldownReduction))));
|
||||||
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Perks.cooldowns.name"), LocaleLoader.getString("Perks.cooldowns.desc", "1/3")));
|
|
||||||
}
|
|
||||||
else if (Permissions.cooldownsQuartered(player)) {
|
|
||||||
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Perks.cooldowns.name"), LocaleLoader.getString("Perks.cooldowns.desc", "1/4")));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -94,15 +78,7 @@ public final class Motd {
|
|||||||
* @param player Target player
|
* @param player Target player
|
||||||
*/
|
*/
|
||||||
public static void displayActivationPerks(Player player) {
|
public static void displayActivationPerks(Player player) {
|
||||||
if (Permissions.activationTwelve(player)) {
|
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Perks.activationtime.name"), LocaleLoader.getString("Perks.activationtime.desc", PerksUtils.handleActivationPerks(player, 0, 0))));
|
||||||
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Perks.activationtime.name"), LocaleLoader.getString("Perks.activationtime.desc", 12)));
|
|
||||||
}
|
|
||||||
else if (Permissions.activationEight(player)) {
|
|
||||||
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Perks.activationtime.name"), LocaleLoader.getString("Perks.activationtime.desc", 8)));
|
|
||||||
}
|
|
||||||
else if (Permissions.activationFour(player)) {
|
|
||||||
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Perks.activationtime.name"), LocaleLoader.getString("Perks.activationtime.desc", 4)));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user