mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-12-02 01:46:45 +01:00
Made a factory method for abilities
This commit is contained in:
parent
65400bcfae
commit
eb81f7ca96
@ -1,5 +1,6 @@
|
|||||||
package com.gmail.nossr50.api;
|
package com.gmail.nossr50.api;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@ -97,6 +98,10 @@ public final class AbilityAPI {
|
|||||||
return BleedTimerTask.isBleeding(entity);
|
return BleedTimerTask.isBleeding(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static AbilityType createAbility(String name, String skillName, final Material... materials) {
|
||||||
|
return AbilityType.createAbility(name, skillName, materials);
|
||||||
|
}
|
||||||
|
|
||||||
public static SecondaryAbility createSecondaryAbility(String name, String skillName) {
|
public static SecondaryAbility createSecondaryAbility(String name, String skillName) {
|
||||||
return createSecondaryAbility(name, skillName, 0, 100);
|
return createSecondaryAbility(name, skillName, 0, 100);
|
||||||
}
|
}
|
||||||
|
@ -109,6 +109,40 @@ public class AbilityType {
|
|||||||
"Mining.Blast.Refresh",
|
"Mining.Blast.Refresh",
|
||||||
null);
|
null);
|
||||||
|
|
||||||
|
static {
|
||||||
|
abilityTypes.add(berserk);
|
||||||
|
abilityNames.add(berserk.getUnprettyName());
|
||||||
|
lowerAbilityNames.add(berserk.getUnprettyName().toLowerCase());
|
||||||
|
|
||||||
|
abilityTypes.add(superBreaker);
|
||||||
|
abilityNames.add(superBreaker.getUnprettyName());
|
||||||
|
lowerAbilityNames.add(superBreaker.getUnprettyName().toLowerCase());
|
||||||
|
|
||||||
|
abilityTypes.add(gigaDrillBreaker);
|
||||||
|
abilityNames.add(gigaDrillBreaker.getUnprettyName());
|
||||||
|
lowerAbilityNames.add(gigaDrillBreaker.getUnprettyName().toLowerCase());
|
||||||
|
|
||||||
|
abilityTypes.add(greenTerra);
|
||||||
|
abilityNames.add(greenTerra.getUnprettyName());
|
||||||
|
lowerAbilityNames.add(greenTerra.getUnprettyName().toLowerCase());
|
||||||
|
|
||||||
|
abilityTypes.add(skullSplitter);
|
||||||
|
abilityNames.add(skullSplitter.getUnprettyName());
|
||||||
|
lowerAbilityNames.add(skullSplitter.getUnprettyName().toLowerCase());
|
||||||
|
|
||||||
|
abilityTypes.add(treeFeller);
|
||||||
|
abilityNames.add(treeFeller.getUnprettyName());
|
||||||
|
lowerAbilityNames.add(treeFeller.getUnprettyName().toLowerCase());
|
||||||
|
|
||||||
|
abilityTypes.add(serratedStrikes);
|
||||||
|
abilityNames.add(serratedStrikes.getUnprettyName());
|
||||||
|
lowerAbilityNames.add(serratedStrikes.getUnprettyName().toLowerCase());
|
||||||
|
|
||||||
|
abilityTypes.add(blastMining);
|
||||||
|
abilityNames.add(blastMining.getUnprettyName());
|
||||||
|
lowerAbilityNames.add(blastMining.getUnprettyName().toLowerCase());
|
||||||
|
}
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
private String abilityOn;
|
private String abilityOn;
|
||||||
private String abilityOff;
|
private String abilityOff;
|
||||||
@ -123,9 +157,33 @@ public class AbilityType {
|
|||||||
this.abilityPlayer = abilityPlayer;
|
this.abilityPlayer = abilityPlayer;
|
||||||
this.abilityRefresh = abilityRefresh;
|
this.abilityRefresh = abilityRefresh;
|
||||||
this.abilityPlayerOff = abilityPlayerOff;
|
this.abilityPlayerOff = abilityPlayerOff;
|
||||||
abilityTypes.add(this);
|
}
|
||||||
abilityNames.add(this.getUnprettyName());
|
|
||||||
lowerAbilityNames.add(this.getUnprettyName().toLowerCase());
|
private AbilityType(String name, String skillName) {
|
||||||
|
String capitalizedName = StringUtils.createPrettyStringWithSpacer(name, "");
|
||||||
|
String capitalizedSkill = StringUtils.getCapitalized(skillName);
|
||||||
|
this.name = name;
|
||||||
|
this.abilityOn = capitalizedSkill + ".Skills." + capitalizedName + "On";
|
||||||
|
this.abilityOff = capitalizedSkill + ".Skills." + capitalizedName + "Off";
|
||||||
|
this.abilityPlayer = capitalizedSkill + ".Skills." + capitalizedName + "Other.On";
|
||||||
|
this.abilityRefresh = capitalizedSkill + ".Skills." + capitalizedName + "Refresh";
|
||||||
|
this.abilityPlayerOff = capitalizedSkill + ".Skills." + capitalizedName + "Other.Off";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static AbilityType createAbility(String name, String skillName, final Material... materials) {
|
||||||
|
AbilityType ability = new AbilityType(name, skillName) {
|
||||||
|
@Override
|
||||||
|
public boolean blockCheck(BlockState blockState) {
|
||||||
|
for(Material material : materials) {
|
||||||
|
return blockState.getType() == material;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
abilityTypes.add(ability);
|
||||||
|
abilityNames.add(ability.getUnprettyName());
|
||||||
|
lowerAbilityNames.add(ability.getUnprettyName().toLowerCase());
|
||||||
|
return ability;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCooldown() {
|
public int getCooldown() {
|
||||||
|
@ -72,17 +72,6 @@ public class ToolType {
|
|||||||
return raiseTool;
|
return raiseTool;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ToolType createToolType(String toolName, final Material material) {
|
|
||||||
ToolType tool = new ToolType(toolName) {
|
|
||||||
@Override
|
|
||||||
public boolean inHand(ItemStack itemStack) {
|
|
||||||
return itemStack.getType() == material;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
tools.add(tool);
|
|
||||||
return tool;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ToolType createToolType(String toolName, final Material... materials) {
|
public static ToolType createToolType(String toolName, final Material... materials) {
|
||||||
ToolType tool = new ToolType(toolName) {
|
ToolType tool = new ToolType(toolName) {
|
||||||
@Override
|
@Override
|
||||||
|
@ -59,6 +59,10 @@ public class StringUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static String createPrettyEnumString(String baseString) {
|
private static String createPrettyEnumString(String baseString) {
|
||||||
|
return createPrettyStringWithSpacer(baseString, " ");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String createPrettyStringWithSpacer(String baseString, String spacer) {
|
||||||
String[] substrings = baseString.split("_");
|
String[] substrings = baseString.split("_");
|
||||||
String prettyString = "";
|
String prettyString = "";
|
||||||
int size = 1;
|
int size = 1;
|
||||||
@ -67,7 +71,7 @@ public class StringUtils {
|
|||||||
prettyString = prettyString.concat(getCapitalized(string));
|
prettyString = prettyString.concat(getCapitalized(string));
|
||||||
|
|
||||||
if (size < substrings.length) {
|
if (size < substrings.length) {
|
||||||
prettyString = prettyString.concat(" ");
|
prettyString = prettyString.concat(spacer);
|
||||||
}
|
}
|
||||||
|
|
||||||
size++;
|
size++;
|
||||||
|
Loading…
Reference in New Issue
Block a user