2012-01-09 20:00:13 +01:00
|
|
|
package com.gmail.nossr50.datatypes;
|
|
|
|
|
2012-02-27 23:28:32 +01:00
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
|
2012-04-26 16:27:57 +02:00
|
|
|
import com.gmail.nossr50.config.Config;
|
2012-04-27 11:47:11 +02:00
|
|
|
import com.gmail.nossr50.util.Permissions;
|
|
|
|
import com.gmail.nossr50.util.Users;
|
2012-02-27 23:28:32 +01:00
|
|
|
|
2012-03-30 05:08:51 +02:00
|
|
|
public enum SkillType {
|
2012-04-27 05:58:21 +02:00
|
|
|
ACROBATICS(Config.getInstance().getLevelCapAcrobatics(), Config.getInstance().getFormulaMultiplierAcrobatics()),
|
2012-03-30 05:08:51 +02:00
|
|
|
ALL, //This one is just for convenience
|
2012-04-27 05:58:21 +02:00
|
|
|
ARCHERY(Config.getInstance().getLevelCapArchery(), Config.getInstance().getFormulaMultiplierArchery()),
|
|
|
|
AXES(AbilityType.SKULL_SPLIITER, Config.getInstance().getLevelCapAxes(), ToolType.AXE, Config.getInstance().getFormulaMultiplierAxes()),
|
|
|
|
EXCAVATION(AbilityType.GIGA_DRILL_BREAKER, Config.getInstance().getLevelCapExcavation(), ToolType.SHOVEL, Config.getInstance().getFormulaMultiplierExcavation()),
|
|
|
|
FISHING(Config.getInstance().getLevelCapFishing(), Config.getInstance().getFormulaMultiplierFishing()),
|
|
|
|
HERBALISM(AbilityType.GREEN_TERRA, Config.getInstance().getLevelCapHerbalism(), ToolType.HOE, Config.getInstance().getFormulaMultiplierHerbalism()),
|
|
|
|
MINING(AbilityType.SUPER_BREAKER, Config.getInstance().getLevelCapMining(), ToolType.PICKAXE, Config.getInstance().getFormulaMultiplierMining()),
|
|
|
|
REPAIR(Config.getInstance().getLevelCapRepair(), Config.getInstance().getFormulaMultiplierRepair()),
|
|
|
|
SWORDS(AbilityType.SERRATED_STRIKES, Config.getInstance().getLevelCapSwords(), ToolType.SWORD, Config.getInstance().getFormulaMultiplierSwords()),
|
|
|
|
TAMING(Config.getInstance().getLevelCapTaming(), Config.getInstance().getFormulaMultiplierTaming()),
|
|
|
|
UNARMED(AbilityType.BERSERK, Config.getInstance().getLevelCapUnarmed(), ToolType.FISTS, Config.getInstance().getFormulaMultiplierUnarmed()),
|
|
|
|
WOODCUTTING(AbilityType.TREE_FELLER, Config.getInstance().getLevelCapWoodcutting(), ToolType.AXE, Config.getInstance().getFormulaMultiplierWoodcutting());
|
2012-03-30 05:08:51 +02:00
|
|
|
|
|
|
|
private AbilityType ability;
|
|
|
|
private int maxLevel;
|
|
|
|
private ToolType tool;
|
|
|
|
private double xpModifier;
|
|
|
|
|
|
|
|
private SkillType() {
|
|
|
|
this.ability = null;
|
|
|
|
this.maxLevel = 0;
|
|
|
|
this.tool = null;
|
|
|
|
this.xpModifier = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
private SkillType(AbilityType ability, int maxLevel, ToolType tool, double xpModifier) {
|
|
|
|
this.ability = ability;
|
|
|
|
this.maxLevel = maxLevel;
|
|
|
|
this.tool = tool;
|
|
|
|
this.xpModifier = xpModifier;
|
|
|
|
}
|
|
|
|
|
|
|
|
private SkillType(int maxLevel, double xpModifier) {
|
|
|
|
this(null, maxLevel, null, xpModifier);
|
|
|
|
}
|
|
|
|
|
|
|
|
public AbilityType getAbility() {
|
|
|
|
return ability;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the max level of this skill.
|
|
|
|
*
|
|
|
|
* @return the max level of this skill
|
|
|
|
*/
|
|
|
|
public int getMaxLevel() {
|
|
|
|
if (maxLevel > 0) {
|
|
|
|
return maxLevel;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return Integer.MAX_VALUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public ToolType getTool() {
|
|
|
|
return tool;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the base permissions associated with this skill.
|
|
|
|
*
|
|
|
|
* @param player The player to check the permissions for
|
|
|
|
* @return true if the player has permissions, false otherwise
|
|
|
|
*/
|
|
|
|
public boolean getPermissions(Player player) {
|
|
|
|
switch (this) {
|
|
|
|
case ACROBATICS:
|
2013-01-07 02:52:31 +01:00
|
|
|
return Permissions.acrobatics(player);
|
2012-03-30 05:08:51 +02:00
|
|
|
|
|
|
|
case ARCHERY:
|
2013-01-07 02:52:31 +01:00
|
|
|
return Permissions.archery(player);
|
2012-03-30 05:08:51 +02:00
|
|
|
|
|
|
|
case AXES:
|
2013-01-07 02:52:31 +01:00
|
|
|
return Permissions.axes(player);
|
2012-03-30 05:08:51 +02:00
|
|
|
|
|
|
|
case EXCAVATION:
|
2013-01-07 02:52:31 +01:00
|
|
|
return Permissions.excavation(player);
|
2012-03-30 05:08:51 +02:00
|
|
|
|
|
|
|
case FISHING:
|
2013-01-07 02:52:31 +01:00
|
|
|
return Permissions.fishing(player);
|
2012-03-30 05:08:51 +02:00
|
|
|
|
|
|
|
case HERBALISM:
|
2013-01-07 02:52:31 +01:00
|
|
|
return Permissions.herbalism(player);
|
2012-03-30 05:08:51 +02:00
|
|
|
|
|
|
|
case MINING:
|
2013-01-07 02:52:31 +01:00
|
|
|
return Permissions.mining(player);
|
2012-03-30 05:08:51 +02:00
|
|
|
|
|
|
|
case REPAIR:
|
2013-01-07 02:52:31 +01:00
|
|
|
return Permissions.repair(player);
|
2012-03-30 05:08:51 +02:00
|
|
|
|
|
|
|
case SWORDS:
|
2013-01-07 02:52:31 +01:00
|
|
|
return Permissions.swords(player);
|
2012-03-30 05:08:51 +02:00
|
|
|
|
|
|
|
case TAMING:
|
2013-01-07 02:52:31 +01:00
|
|
|
return Permissions.taming(player);
|
2012-03-30 05:08:51 +02:00
|
|
|
|
|
|
|
case UNARMED:
|
2013-01-07 02:52:31 +01:00
|
|
|
return Permissions.unarmed(player);
|
2012-03-30 05:08:51 +02:00
|
|
|
|
|
|
|
case WOODCUTTING:
|
2013-01-07 02:52:31 +01:00
|
|
|
return Permissions.woodcutting(player);
|
2012-03-30 05:08:51 +02:00
|
|
|
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2012-03-26 23:31:15 +02:00
|
|
|
|
|
|
|
public double getXpModifier() {
|
|
|
|
return xpModifier;
|
|
|
|
}
|
2012-03-27 05:01:51 +02:00
|
|
|
|
2012-03-30 07:32:36 +02:00
|
|
|
/**
|
|
|
|
* Get the skill level for this skill.
|
|
|
|
*
|
|
|
|
* @param player The player to check
|
|
|
|
* @return
|
|
|
|
*/
|
2012-03-27 05:01:51 +02:00
|
|
|
public int getSkillLevel(Player player) {
|
|
|
|
return Users.getProfile(player).getSkillLevel(this);
|
|
|
|
}
|
2012-01-09 20:00:13 +01:00
|
|
|
}
|