mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-12-02 01:46:45 +01:00
Added api stuff so you can actually add new skills and made it *mostyl*
work
This commit is contained in:
parent
d47a51b91d
commit
cf01241e2d
@ -5,6 +5,7 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
||||||
|
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
|
||||||
import com.gmail.nossr50.runnables.skills.BleedTimerTask;
|
import com.gmail.nossr50.runnables.skills.BleedTimerTask;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
|
||||||
@ -12,31 +13,35 @@ public final class AbilityAPI {
|
|||||||
private AbilityAPI() {}
|
private AbilityAPI() {}
|
||||||
|
|
||||||
public static boolean berserkEnabled(Player player) {
|
public static boolean berserkEnabled(Player player) {
|
||||||
return UserManager.getPlayer(player).getAbilityMode(AbilityType.berserk);
|
return abilityEnabled(player, AbilityType.berserk);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean gigaDrillBreakerEnabled(Player player) {
|
public static boolean gigaDrillBreakerEnabled(Player player) {
|
||||||
return UserManager.getPlayer(player).getAbilityMode(AbilityType.gigaDrillBreaker);
|
return abilityEnabled(player, AbilityType.gigaDrillBreaker);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean greenTerraEnabled(Player player) {
|
public static boolean greenTerraEnabled(Player player) {
|
||||||
return UserManager.getPlayer(player).getAbilityMode(AbilityType.greenTerra);
|
return abilityEnabled(player, AbilityType.greenTerra);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean serratedStrikesEnabled(Player player) {
|
public static boolean serratedStrikesEnabled(Player player) {
|
||||||
return UserManager.getPlayer(player).getAbilityMode(AbilityType.serratedStrikes);
|
return abilityEnabled(player, AbilityType.serratedStrikes);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean skullSplitterEnabled(Player player) {
|
public static boolean skullSplitterEnabled(Player player) {
|
||||||
return UserManager.getPlayer(player).getAbilityMode(AbilityType.skullSplitter);
|
return abilityEnabled(player, AbilityType.skullSplitter);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean superBreakerEnabled(Player player) {
|
public static boolean superBreakerEnabled(Player player) {
|
||||||
return UserManager.getPlayer(player).getAbilityMode(AbilityType.superBreaker);
|
return abilityEnabled(player, AbilityType.superBreaker);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean treeFellerEnabled(Player player) {
|
public static boolean treeFellerEnabled(Player player) {
|
||||||
return UserManager.getPlayer(player).getAbilityMode(AbilityType.treeFeller);
|
return abilityEnabled(player, AbilityType.treeFeller);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean abilityEnabled(Player player, AbilityType ability) {
|
||||||
|
return UserManager.getPlayer(player).getAbilityMode(ability);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isAnyAbilityEnabled(Player player) {
|
public static boolean isAnyAbilityEnabled(Player player) {
|
||||||
@ -83,7 +88,15 @@ public final class AbilityAPI {
|
|||||||
UserManager.getPlayer(player).setAbilityDATS(AbilityType.treeFeller, cooldown);
|
UserManager.getPlayer(player).setAbilityDATS(AbilityType.treeFeller, cooldown);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void setAbilityCooldown(Player player, AbilityType ability, long cooldown) {
|
||||||
|
UserManager.getPlayer(player).setAbilityDATS(ability, cooldown);
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isBleeding(LivingEntity entity) {
|
public static boolean isBleeding(LivingEntity entity) {
|
||||||
return BleedTimerTask.isBleeding(entity);
|
return BleedTimerTask.isBleeding(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static SecondaryAbility createSecondaryAbility(String name) {
|
||||||
|
return new SecondaryAbility(name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,16 @@ package com.gmail.nossr50.api;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.Color;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.commands.skills.SkillCommand;
|
||||||
|
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
||||||
|
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
|
||||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||||
|
import com.gmail.nossr50.datatypes.skills.ToolType;
|
||||||
|
import com.gmail.nossr50.datatypes.skills.SkillType.SkillUseType;
|
||||||
|
import com.gmail.nossr50.skills.SkillManager;
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
|
||||||
public final class SkillAPI {
|
public final class SkillAPI {
|
||||||
private SkillAPI() {}
|
private SkillAPI() {}
|
||||||
@ -89,4 +98,24 @@ public final class SkillAPI {
|
|||||||
|
|
||||||
return skills;
|
return skills;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static SkillType createSkill(String name, Class<? extends SkillManager> managerClass, Class<? extends SkillCommand> commandClass, boolean isChild, Color runescapeColor, SkillUseType skillUseType, List<SecondaryAbility> secondaryAbilities) {
|
||||||
|
return SkillType.createSkill(name, managerClass, commandClass, isChild, runescapeColor, skillUseType, secondaryAbilities);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SkillType createSkill(String name, Class<? extends SkillManager> managerClass, Class<? extends SkillCommand> commandClass, boolean isChild, Color runescapeColor, SkillUseType skillUseType, AbilityType ability, ToolType tool, List<SecondaryAbility> secondaryAbilities) {
|
||||||
|
return SkillType.createSkill(name, managerClass, commandClass, isChild, runescapeColor, skillUseType, ability, tool, secondaryAbilities);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SkillType createSkill(String name, Class<? extends SkillManager> managerClass, Class<? extends SkillCommand> commandClass, boolean isChild, Color runescapeColor, SkillUseType skillUseType, SecondaryAbility... secondaryAbilities) {
|
||||||
|
return SkillType.createSkill(name, managerClass, commandClass, isChild, runescapeColor, skillUseType, ImmutableList.copyOf(secondaryAbilities));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SkillType createSkill(String name, Class<? extends SkillManager> managerClass, Class<? extends SkillCommand> commandClass, boolean isChild, Color runescapeColor, SkillUseType skillUseType, AbilityType ability, ToolType tool, SecondaryAbility... secondaryAbilities) {
|
||||||
|
return SkillType.createSkill(name, managerClass, commandClass, isChild, runescapeColor, skillUseType, ability, tool, ImmutableList.copyOf(secondaryAbilities));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void loadNewSkills() {
|
||||||
|
SkillType.setUpSkillTypes();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -595,6 +595,8 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
|||||||
// There is such a user
|
// There is such a user
|
||||||
writeMissingRows(connection, id);
|
writeMissingRows(connection, id);
|
||||||
|
|
||||||
|
addNewSkills(connection);
|
||||||
|
|
||||||
statement = connection.prepareStatement(
|
statement = connection.prepareStatement(
|
||||||
"SELECT "
|
"SELECT "
|
||||||
+ com.gmail.nossr50.util.StringUtils.createStringFromList(SkillType.getLowerSkillNames(), "s.", ", ")
|
+ com.gmail.nossr50.util.StringUtils.createStringFromList(SkillType.getLowerSkillNames(), "s.", ", ")
|
||||||
@ -1471,6 +1473,37 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void addNewSkills(Connection connection) {
|
||||||
|
Statement statement = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
statement = connection.createStatement();
|
||||||
|
for (String skill : SkillType.getLowerSkillNames()) {
|
||||||
|
try {
|
||||||
|
statement.executeQuery("SELECT `" + skill + "` FROM `" + tablePrefix + "skills` LIMIT 1");
|
||||||
|
}
|
||||||
|
catch (SQLException ex) {
|
||||||
|
mcMMO.p.getLogger().info("Updating mcMMO MySQL tables for Fishing...");
|
||||||
|
statement.executeUpdate("ALTER TABLE `" + tablePrefix + "skills` ADD `" + skill + "` int(10) NOT NULL DEFAULT '0'");
|
||||||
|
statement.executeUpdate("ALTER TABLE `" + tablePrefix + "experience` ADD `" + skill + "` int(10) NOT NULL DEFAULT '0'");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (SQLException ex) {
|
||||||
|
printErrors(ex);
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
if (statement != null) {
|
||||||
|
try {
|
||||||
|
statement.close();
|
||||||
|
}
|
||||||
|
catch (SQLException e) {
|
||||||
|
// Ignore
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private int getUserID(final Connection connection, final String playerName, final UUID uuid) {
|
private int getUserID(final Connection connection, final String playerName, final UUID uuid) {
|
||||||
if (cachedUserIDs.containsKey(uuid)) {
|
if (cachedUserIDs.containsKey(uuid)) {
|
||||||
return cachedUserIDs.get(uuid);
|
return cachedUserIDs.get(uuid);
|
||||||
|
@ -85,7 +85,7 @@ public class SecondaryAbility {
|
|||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
private SecondaryAbility(String name) {
|
public SecondaryAbility(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ public class SkillType {
|
|||||||
public static final SkillType mining = createSkill("MINING" , MiningManager.class , MiningCommand.class , false, Color.GRAY, SkillUseType.GATHERING, AbilityType.superBreaker, ToolType.PICKAXE, ImmutableList.of(SecondaryAbility.miningDoubleDrops));
|
public static final SkillType mining = createSkill("MINING" , MiningManager.class , MiningCommand.class , false, Color.GRAY, SkillUseType.GATHERING, AbilityType.superBreaker, ToolType.PICKAXE, ImmutableList.of(SecondaryAbility.miningDoubleDrops));
|
||||||
public static final SkillType repair = createSkill("REPAIR" , RepairManager.class , RepairCommand.class , false, Color.SILVER, SkillUseType.MISC, ImmutableList.of(SecondaryAbility.arcaneForging, SecondaryAbility.repairMastery, SecondaryAbility.superRepair));
|
public static final SkillType repair = createSkill("REPAIR" , RepairManager.class , RepairCommand.class , false, Color.SILVER, SkillUseType.MISC, ImmutableList.of(SecondaryAbility.arcaneForging, SecondaryAbility.repairMastery, SecondaryAbility.superRepair));
|
||||||
public static final SkillType salvage = createSkill("SALVAGE" , SalvageManager.class , SalvageCommand.class , true, Color.ORANGE, SkillUseType.MISC, ImmutableList.of(SecondaryAbility.advancedSalvage, SecondaryAbility.arcaneSalvage));
|
public static final SkillType salvage = createSkill("SALVAGE" , SalvageManager.class , SalvageCommand.class , true, Color.ORANGE, SkillUseType.MISC, ImmutableList.of(SecondaryAbility.advancedSalvage, SecondaryAbility.arcaneSalvage));
|
||||||
public static final SkillType smelting = createSkill("SMELTING" , SmeltingManager.class , SmeltingCommand.class , true, Color.YELLOW, SkillUseType.MISC, ImmutableList.of(SecondaryAbility.fluxMining, SecondaryAbility.fuelEfficiency, SecondaryAbility.secondSmelt));
|
public static final SkillType smelting = createSkill("SMELTING" , SmeltingManager.class , SmeltingCommand.class , true, Color.YELLOW, SkillUseType.MISC, ImmutableList.of(SecondaryAbility.fluxMining, SecondaryAbility.fuelEfficiency, SecondaryAbility.secondSmelt));
|
||||||
public static final SkillType swords = createSkill("SWORDS" , SwordsManager.class , SwordsCommand.class , false, Color.fromRGB(178, 34, 34), SkillUseType.COMBAT, AbilityType.serratedStrikes, ToolType.SWORD, ImmutableList.of(SecondaryAbility.bleed, SecondaryAbility.counter));
|
public static final SkillType swords = createSkill("SWORDS" , SwordsManager.class , SwordsCommand.class , false, Color.fromRGB(178, 34, 34), SkillUseType.COMBAT, AbilityType.serratedStrikes, ToolType.SWORD, ImmutableList.of(SecondaryAbility.bleed, SecondaryAbility.counter));
|
||||||
public static final SkillType taming = createSkill("TAMING" , TamingManager.class , TamingCommand.class , false, Color.PURPLE, SkillUseType.COMBAT, ImmutableList.of(SecondaryAbility.beastLore, SecondaryAbility.callOfTheWild, SecondaryAbility.enviromentallyAware, SecondaryAbility.fastFood, SecondaryAbility.gore, SecondaryAbility.holyHound, SecondaryAbility.sharpenedClaws, SecondaryAbility.shockProof, SecondaryAbility.thickFur));
|
public static final SkillType taming = createSkill("TAMING" , TamingManager.class , TamingCommand.class , false, Color.PURPLE, SkillUseType.COMBAT, ImmutableList.of(SecondaryAbility.beastLore, SecondaryAbility.callOfTheWild, SecondaryAbility.enviromentallyAware, SecondaryAbility.fastFood, SecondaryAbility.gore, SecondaryAbility.holyHound, SecondaryAbility.sharpenedClaws, SecondaryAbility.shockProof, SecondaryAbility.thickFur));
|
||||||
public static final SkillType unarmed = createSkill("UNARMED" , UnarmedManager.class , UnarmedCommand.class , false, Color.BLACK, SkillUseType.COMBAT, AbilityType.berserk, ToolType.FISTS, ImmutableList.of(SecondaryAbility.blockCracker, SecondaryAbility.deflect, SecondaryAbility.disarm, SecondaryAbility.ironArm, SecondaryAbility.ironGrip));
|
public static final SkillType unarmed = createSkill("UNARMED" , UnarmedManager.class , UnarmedCommand.class , false, Color.BLACK, SkillUseType.COMBAT, AbilityType.berserk, ToolType.FISTS, ImmutableList.of(SecondaryAbility.blockCracker, SecondaryAbility.deflect, SecondaryAbility.disarm, SecondaryAbility.ironArm, SecondaryAbility.ironGrip));
|
||||||
@ -280,6 +280,7 @@ public class SkillType {
|
|||||||
public static void setUpSkillTypes()
|
public static void setUpSkillTypes()
|
||||||
{
|
{
|
||||||
Collections.sort(skillNames);
|
Collections.sort(skillNames);
|
||||||
|
lowerSkillNames = new ArrayList<String>();
|
||||||
for(SkillType skill : nonChildSkills) {
|
for(SkillType skill : nonChildSkills) {
|
||||||
if(skill != null) {
|
if(skill != null) {
|
||||||
lowerSkillNames.add(skill.getName());
|
lowerSkillNames.add(skill.getName());
|
||||||
|
Loading…
Reference in New Issue
Block a user