Copy-pasta code is bad.

This commit is contained in:
GJ
2013-01-21 20:01:33 -05:00
parent 67fd45ef25
commit ddbf5a559a
16 changed files with 69 additions and 149 deletions

View File

@ -33,6 +33,22 @@ public class Misc {
public static final int PLAYER_RESPAWN_COOLDOWN_SECONDS = 5;
public static final int TIME_CONVERSION_FACTOR = 1000;
public static final double SKILL_MESSAGE_MAX_SENDING_DISTANCE = 10.0;
public static final int NORMAL_SKILL_ACTIVATION_CHANCE = 100;
public static final int LUCKY_SKILL_ACTIVATION_CHANCE = 75;
/**
* 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;
}
/**
* Check if a player has armor.

View File

@ -3,6 +3,8 @@ package com.gmail.nossr50.util;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.SkillType;
public class Permissions {
public static boolean hasPermission(CommandSender sender, String perm)
{
@ -75,6 +77,10 @@ public class Permissions {
* MCMMO.PERKS.LUCKY*
*/
public static boolean lucky(Player player, SkillType skill) {
return hasPermission(player, "mcmmo.perks.lucky." + skill.toString().toLowerCase());
}
public static boolean luckyAcrobatics(Player player) {
return hasPermission(player, "mcmmo.perks.lucky.acrobatics");
}