Turned skilltypes into constants instead of enum

This commit is contained in:
ile123ile
2014-08-23 14:14:36 -07:00
parent be690962ee
commit ebd02dc30e
77 changed files with 492 additions and 497 deletions

View File

@ -25,7 +25,7 @@ public class AcrobaticsManager extends SkillManager {
Location lastFallLocation;
public AcrobaticsManager(McMMOPlayer mcMMOPlayer) {
super(mcMMOPlayer, SkillType.ACROBATICS);
super(mcMMOPlayer, SkillType.acrobatics);
}
public boolean canRoll() {

View File

@ -17,7 +17,7 @@ public class AlchemyManager extends SkillManager {
private final double LUCKY_MODIFIER = 4.0 / 3.0;
public AlchemyManager(McMMOPlayer mcMMOPlayer) {
super(mcMMOPlayer, SkillType.ALCHEMY);
super(mcMMOPlayer, SkillType.alchemy);
}
public int getTier() {

View File

@ -20,7 +20,7 @@ import com.gmail.nossr50.util.skills.SkillUtils;
public class ArcheryManager extends SkillManager {
public ArcheryManager(McMMOPlayer mcMMOPlayer) {
super(mcMMOPlayer, SkillType.ARCHERY);
super(mcMMOPlayer, SkillType.archery);
}
public boolean canDaze(LivingEntity target) {

View File

@ -23,7 +23,7 @@ import com.gmail.nossr50.util.skills.SkillUtils;
public class AxesManager extends SkillManager {
public AxesManager(McMMOPlayer mcMMOPlayer) {
super(mcMMOPlayer, SkillType.AXES);
super(mcMMOPlayer, SkillType.axes);
}
public boolean canUseAxeMastery() {

View File

@ -1,6 +1,8 @@
package com.gmail.nossr50.skills.child;
import java.util.EnumSet;
import java.util.HashSet;
import java.util.Set;
import org.bukkit.configuration.file.YamlConfiguration;
@ -20,15 +22,15 @@ public class ChildConfig extends AutoUpdateConfigLoader {
FamilyTree.clearRegistrations(); // when reloading, need to clear statics
for (SkillType skill : SkillType.CHILD_SKILLS) {
plugin.debug("Finding parents of " + skill.name());
for (SkillType skill : SkillType.childSkills) {
plugin.debug("Finding parents of " + skill.getLocalizedName());
EnumSet<SkillType> parentSkills = EnumSet.noneOf(SkillType.class);
Set<SkillType> parentSkills = new HashSet<SkillType>();
boolean useDefaults = false; // If we had an error we back out and use defaults
for (String name : config.getStringList(StringUtils.getCapitalized(skill.name()))) {
for (String name : config.getStringList(StringUtils.getCapitalized(skill.getName()))) {
try {
SkillType parentSkill = SkillType.valueOf(name.toUpperCase());
SkillType parentSkill = SkillType.getSkill(name);
FamilyTree.enforceNotChildSkill(parentSkill);
parentSkills.add(parentSkill);
}
@ -41,18 +43,18 @@ public class ChildConfig extends AutoUpdateConfigLoader {
if (useDefaults) {
parentSkills.clear();
for (String name : config.getDefaults().getStringList(StringUtils.getCapitalized(skill.name()))) {
for (String name : config.getDefaults().getStringList(StringUtils.getCapitalized(skill.getName()))) {
/* We do less checks in here because it's from inside our jar.
* If they're dedicated enough to have modified it, they can have the errors it may produce.
* Alternatively, this can be used to allow child skills to be parent skills, provided there are no circular dependencies this is an advanced sort of configuration.
*/
parentSkills.add(SkillType.valueOf(name.toUpperCase()));
parentSkills.add(SkillType.getSkill(name));
}
}
// Register them
for (SkillType parentSkill : parentSkills) {
plugin.debug("Registering " + parentSkill.name() + " as parent of " + skill.name());
plugin.debug("Registering " + parentSkill.getName() + " as parent of " + skill.getName());
FamilyTree.registerParent(skill, parentSkill);
}
}

View File

@ -3,6 +3,7 @@ package com.gmail.nossr50.skills.child;
import java.util.Collections;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;
import com.gmail.nossr50.datatypes.skills.SkillType;
@ -22,7 +23,7 @@ public class FamilyTree {
enforceNotChildSkill(parentSkill);
if (!tree.containsKey(childSkill)) {
tree.put(childSkill, EnumSet.noneOf(SkillType.class));
tree.put(childSkill, new HashSet<SkillType>());
}
tree.get(childSkill).add(parentSkill);
@ -41,13 +42,13 @@ public class FamilyTree {
protected static void enforceChildSkill(SkillType skill) {
if (!skill.isChildSkill()) {
throw new IllegalArgumentException(skill.name() + " is not a child skill!");
throw new IllegalArgumentException(skill.getName() + " is not a child skill!");
}
}
protected static void enforceNotChildSkill(SkillType skill) {
if (skill.isChildSkill()) {
throw new IllegalArgumentException(skill.name() + " is a child skill!");
throw new IllegalArgumentException(skill.getName() + " is a child skill!");
}
}
}

View File

@ -58,7 +58,7 @@ public class Excavation {
xp = ExperienceConfig.getInstance().getDirtAndSandXp(blockState.getData());
}
else {
xp = ExperienceConfig.getInstance().getXp(SkillType.EXCAVATION, material);
xp = ExperienceConfig.getInstance().getXp(SkillType.excavation, material);
}
if (xp == 0 && mcMMO.getModManager().isCustomExcavationBlock(blockState)) {

View File

@ -18,7 +18,7 @@ import com.gmail.nossr50.util.skills.SkillUtils;
public class ExcavationManager extends SkillManager {
public ExcavationManager(McMMOPlayer mcMMOPlayer) {
super(mcMMOPlayer, SkillType.EXCAVATION);
super(mcMMOPlayer, SkillType.excavation);
}
/**

View File

@ -72,7 +72,7 @@ public class FishingManager extends SkillManager {
private Location hookLocation;
public FishingManager(McMMOPlayer mcMMOPlayer) {
super(mcMMOPlayer, SkillType.FISHING);
super(mcMMOPlayer, SkillType.fishing);
}
public boolean canShake(Entity target) {

View File

@ -40,7 +40,7 @@ import com.gmail.nossr50.util.skills.SkillUtils;
public class HerbalismManager extends SkillManager {
public HerbalismManager(McMMOPlayer mcMMOPlayer) {
super(mcMMOPlayer, SkillType.HERBALISM);
super(mcMMOPlayer, SkillType.herbalism);
}
public boolean canBlockCheck() {

View File

@ -19,7 +19,7 @@ public class Mining {
*/
protected static int getBlockXp(BlockState blockState) {
Material blockType = blockState.getType();
int xp = ExperienceConfig.getInstance().getXp(SkillType.MINING, blockType != Material.GLOWING_REDSTONE_ORE ? blockType : Material.REDSTONE_ORE);
int xp = ExperienceConfig.getInstance().getXp(SkillType.mining, blockType != Material.GLOWING_REDSTONE_ORE ? blockType : Material.REDSTONE_ORE);
if (xp == 0 && mcMMO.getModManager().isCustomMiningBlock(blockState)) {
xp = mcMMO.getModManager().getBlock(blockState).getXpGain();
@ -50,7 +50,7 @@ public class Mining {
return;
case GLOWING_REDSTONE_ORE:
if (Config.getInstance().getDoubleDropsEnabled(SkillType.MINING, Material.REDSTONE_ORE)) {
if (Config.getInstance().getDoubleDropsEnabled(SkillType.mining, Material.REDSTONE_ORE)) {
Misc.dropItem(blockState.getLocation(), new ItemStack(Material.REDSTONE_ORE));
}
return;
@ -104,7 +104,7 @@ public class Mining {
return;
case GLOWING_REDSTONE_ORE:
if (Config.getInstance().getDoubleDropsEnabled(SkillType.MINING, Material.REDSTONE_ORE)) {
if (Config.getInstance().getDoubleDropsEnabled(SkillType.mining, Material.REDSTONE_ORE)) {
Misc.dropItems(blockState.getLocation(), blockState.getBlock().getDrops());
}
return;

View File

@ -29,7 +29,7 @@ import com.gmail.nossr50.util.skills.SkillUtils;
public class MiningManager extends SkillManager {
public MiningManager(McMMOPlayer mcMMOPlayer) {
super(mcMMOPlayer, SkillType.MINING);
super(mcMMOPlayer, SkillType.mining);
}
public boolean canUseDemolitionsExpertise() {

View File

@ -33,7 +33,7 @@ public class RepairManager extends SkillManager {
private int lastClick;
public RepairManager(McMMOPlayer mcMMOPlayer) {
super(mcMMOPlayer, SkillType.REPAIR);
super(mcMMOPlayer, SkillType.repair);
}
/**

View File

@ -30,7 +30,7 @@ public class SalvageManager extends SkillManager {
private int lastClick;
public SalvageManager(McMMOPlayer mcMMOPlayer) {
super(mcMMOPlayer, SkillType.SALVAGE);
super(mcMMOPlayer, SkillType.salvage);
}
/**

View File

@ -50,6 +50,6 @@ public class Smelting {
MaterialData data = smelting.getData();
Material resourceType = smelting.getType();
return mcMMO.getModManager().isCustomOre(data) ? mcMMO.getModManager().getBlock(data).getSmeltingXpGain() : ExperienceConfig.getInstance().getXp(SkillType.SMELTING, resourceType != Material.GLOWING_REDSTONE_ORE ? resourceType : Material.REDSTONE_ORE);
return mcMMO.getModManager().isCustomOre(data) ? mcMMO.getModManager().getBlock(data).getSmeltingXpGain() : ExperienceConfig.getInstance().getXp(SkillType.smelting, resourceType != Material.GLOWING_REDSTONE_ORE ? resourceType : Material.REDSTONE_ORE);
}
}

View File

@ -22,7 +22,7 @@ import com.gmail.nossr50.util.skills.SkillUtils;
public class SmeltingManager extends SkillManager {
public SmeltingManager(McMMOPlayer mcMMOPlayer) {
super(mcMMOPlayer, SkillType.SMELTING);
super(mcMMOPlayer, SkillType.smelting);
}
public boolean canUseFluxMining(BlockState blockState) {

View File

@ -23,7 +23,7 @@ import com.gmail.nossr50.util.skills.SkillUtils;
public class SwordsManager extends SkillManager {
public SwordsManager(McMMOPlayer mcMMOPlayer) {
super(mcMMOPlayer, SkillType.SWORDS);
super(mcMMOPlayer, SkillType.swords);
}
public boolean canActivateAbility() {

View File

@ -28,7 +28,7 @@ import com.gmail.nossr50.util.skills.SkillUtils;
public class TamingManager extends SkillManager {
public TamingManager(McMMOPlayer mcMMOPlayer) {
super(mcMMOPlayer, SkillType.TAMING);
super(mcMMOPlayer, SkillType.taming);
}
public boolean canUseThickFur() {

View File

@ -26,7 +26,7 @@ import com.gmail.nossr50.util.skills.SkillUtils;
public class UnarmedManager extends SkillManager {
public UnarmedManager(McMMOPlayer mcMMOPlayer) {
super(mcMMOPlayer, SkillType.UNARMED);
super(mcMMOPlayer, SkillType.unarmed);
}
public boolean canActivateAbility() {

View File

@ -30,7 +30,7 @@ import com.gmail.nossr50.util.skills.SkillUtils;
public class WoodcuttingManager extends SkillManager {
public WoodcuttingManager(McMMOPlayer mcMMOPlayer) {
super(mcMMOPlayer, SkillType.WOODCUTTING);
super(mcMMOPlayer, SkillType.woodcutting);
}
public boolean canUseLeafBlower(ItemStack heldItem) {