more API migration

This commit is contained in:
nossr50 2020-12-15 09:31:51 -08:00
parent d8f8d541fc
commit 407b6fb343
5 changed files with 374 additions and 33 deletions

View File

@ -15,7 +15,10 @@ import com.gmail.nossr50.util.experience.MMOExperienceBarManager;
import com.gmail.nossr50.util.skills.SkillUtils;
import com.gmail.nossr50.util.text.StringUtils;
import com.google.common.collect.ImmutableMap;
import com.neetgames.mcmmo.MobHealthBarType;
import com.neetgames.mcmmo.UniqueDataType;
import com.neetgames.mcmmo.exceptions.ProfileRetrievalException;
import com.neetgames.mcmmo.skill.SkillBossBarState;
import org.apache.commons.lang.NullArgumentException;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
@ -321,7 +324,7 @@ public final class FlatFileDatabaseManager extends AbstractDatabaseManager {
}
}
private void writeUserToLine(MMODataSnapshot mmoDataSnapshot, String playerName, UUID uuid, StringBuilder writer) {
private void writeUserToLine(@NotNull MMODataSnapshot mmoDataSnapshot, @NotNull String playerName, @NotNull UUID uuid, @NotNull StringBuilder writer) {
ImmutableMap<PrimarySkillType, Integer> primarySkillLevelMap = mmoDataSnapshot.getSkillLevelValues();
ImmutableMap<PrimarySkillType, Float> primarySkillExperienceValueMap = mmoDataSnapshot.getSkillExperienceValues();
@ -1267,7 +1270,7 @@ public final class FlatFileDatabaseManager extends AbstractDatabaseManager {
EnumMap<PrimarySkillType, Float> skillExperienceValueMap = new EnumMap<PrimarySkillType, Float>(PrimarySkillType.class); // Skill & XP
EnumMap<SuperAbilityType, Integer> skillAbilityDeactivationTimeStamp = new EnumMap<SuperAbilityType, Integer>(SuperAbilityType.class); // Ability & Cooldown
EnumMap<UniqueDataType, Integer> uniquePlayerDataMap = new EnumMap<UniqueDataType, Integer>(UniqueDataType.class);
EnumMap<PrimarySkillType, MMOExperienceBarManager.BarState> xpBarStateMap = new EnumMap<PrimarySkillType, MMOExperienceBarManager.BarState>(PrimarySkillType.class);
EnumMap<PrimarySkillType, SkillBossBarState> xpBarStateMap = new EnumMap<PrimarySkillType, SkillBossBarState>(PrimarySkillType.class);
// MobHealthBarType mobHealthbarType;
int scoreboardTipsShown;

View File

@ -1,7 +1,5 @@
package com.gmail.nossr50.database;
import com.gmail.nossr50.api.exceptions.InvalidSkillException;
import com.gmail.nossr50.api.exceptions.ProfileRetrievalException;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.database.DatabaseType;
import com.gmail.nossr50.datatypes.database.PlayerStat;
@ -12,10 +10,12 @@ import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.runnables.database.UUIDUpdateAsyncTask;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.experience.MMOExperienceBarManager;
import com.gmail.nossr50.util.skills.SkillUtils;
import com.neetgames.mcmmo.MobHealthBarType;
import com.neetgames.mcmmo.UniqueDataType;
import com.neetgames.mcmmo.exceptions.InvalidSkillException;
import com.neetgames.mcmmo.exceptions.ProfileRetrievalException;
import com.neetgames.mcmmo.skill.SkillBossBarState;
import org.apache.commons.lang.NullArgumentException;
import org.apache.tomcat.jdbc.pool.DataSource;
import org.apache.tomcat.jdbc.pool.PoolProperties;
@ -1193,7 +1193,7 @@ public final class SQLDatabaseManager extends AbstractDatabaseManager {
EnumMap<PrimarySkillType, Float> skillsXp = new EnumMap<PrimarySkillType, Float>(PrimarySkillType.class); // Skill & XP
EnumMap<SuperAbilityType, Integer> skillsDATS = new EnumMap<SuperAbilityType, Integer>(SuperAbilityType.class); // Ability & Cooldown
EnumMap<UniqueDataType, Integer> uniqueData = new EnumMap<UniqueDataType, Integer>(UniqueDataType.class); //Chimaera wing cooldown and other misc info
EnumMap<PrimarySkillType, MMOExperienceBarManager.BarState> xpBarStateMap = new EnumMap<PrimarySkillType, MMOExperienceBarManager.BarState>(PrimarySkillType.class);
EnumMap<PrimarySkillType, SkillBossBarState> xpBarStateMap = new EnumMap<PrimarySkillType, SkillBossBarState>(PrimarySkillType.class);
MobHealthBarType mobHealthbarType;
UUID uuid;

View File

@ -4,6 +4,9 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.experience.MMOExperienceBarManager;
import com.neetgames.mcmmo.MobHealthBarType;
import com.neetgames.mcmmo.UniqueDataType;
import com.neetgames.mcmmo.skill.SkillBossBarState;
import org.apache.commons.lang.NullArgumentException;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
@ -30,7 +33,7 @@ public class PersistentPlayerDataBuilder {
private @Nullable EnumMap<PrimarySkillType, Float> skillExperienceValues;
private @Nullable EnumMap<SuperAbilityType, Integer> abilityDeactivationTimestamps; // Ability & Cooldown
private @Nullable EnumMap<UniqueDataType, Integer> uniquePlayerData; //Misc data that doesn't fit into other categories (chimaera wing, etc..)
private @Nullable EnumMap<PrimarySkillType, MMOExperienceBarManager.BarState> barStateMap;
private @Nullable EnumMap<PrimarySkillType, SkillBossBarState> barStateMap;
/* Special Flags */
private boolean partyChatSpying;
@ -99,8 +102,8 @@ public class PersistentPlayerDataBuilder {
return new PersistentPlayerData(playerUUID, playerName, partyChatSpying, skillLevelValues, skillExperienceValues, abilityDeactivationTimestamps, uniquePlayerData, barStateMap, scoreboardTipsShown, mobHealthBarType, lastLogin, leaderBoardExemption);
}
private void validateBarStateMapEntries(@NotNull EnumMap<PrimarySkillType, MMOExperienceBarManager.BarState> map) {
EnumMap<PrimarySkillType, MMOExperienceBarManager.BarState> barMapDefaults = MMOExperienceBarManager.generateDefaultBarStateMap();
private void validateBarStateMapEntries(@NotNull EnumMap<PrimarySkillType, SkillBossBarState> map) {
EnumMap<PrimarySkillType, SkillBossBarState> barMapDefaults = MMOExperienceBarManager.generateDefaultBarStateMap();
for(PrimarySkillType primarySkillType : PrimarySkillType.values()) {
map.putIfAbsent(primarySkillType, barMapDefaults.get(primarySkillType));
@ -223,11 +226,11 @@ public class PersistentPlayerDataBuilder {
return this;
}
public @Nullable EnumMap<PrimarySkillType, MMOExperienceBarManager.BarState> getBarStateMap() {
public @Nullable EnumMap<PrimarySkillType, SkillBossBarState> getBarStateMap() {
return barStateMap;
}
public @NotNull PersistentPlayerDataBuilder setBarStateMap(@NotNull EnumMap<PrimarySkillType, MMOExperienceBarManager.BarState> barStateMap) {
public @NotNull PersistentPlayerDataBuilder setBarStateMap(@NotNull EnumMap<PrimarySkillType, SkillBossBarState> barStateMap) {
this.barStateMap = barStateMap;
return this;
}

View File

@ -18,6 +18,8 @@ import com.gmail.nossr50.util.compat.layers.persistentdata.AbstractPersistentDat
import com.gmail.nossr50.util.experience.MMOExperienceBarManager;
import com.gmail.nossr50.util.player.NotificationManager;
import com.gmail.nossr50.util.text.StringUtils;
import com.neetgames.mcmmo.exceptions.UnexpectedValueException;
import com.neetgames.mcmmo.skill.SkillBossBarState;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
@ -42,30 +44,30 @@ public final class SkillUtils {
*/
private SkillUtils() {}
public static void applyXpGain(McMMOPlayer mmoPlayer, PrimarySkillType primarySkillType, float xp, XPGainReason xpGainReason) {
public static void applyXpGain(@NotNull McMMOPlayer mmoPlayer, @NotNull PrimarySkillType primarySkillType, float xp, @NotNull XPGainReason xpGainReason) {
mmoPlayer.getExperienceManager().beginXpGain(mmoPlayer.getPlayer(), primarySkillType, xp, xpGainReason, XPGainSource.SELF);
}
public static void applyXpGain(McMMOPlayer mmoPlayer, PrimarySkillType primarySkillType, float xp, XPGainReason xpGainReason, XPGainSource xpGainSource) {
public static void applyXpGain(@NotNull McMMOPlayer mmoPlayer, @NotNull PrimarySkillType primarySkillType, float xp, @NotNull XPGainReason xpGainReason, @NotNull XPGainSource xpGainSource) {
mmoPlayer.getExperienceManager().beginXpGain(mmoPlayer.getPlayer(), primarySkillType, xp, xpGainReason, xpGainSource);
}
public static MMOExperienceBarManager.BarState asBarState(String str) {
for(MMOExperienceBarManager.BarState barState : MMOExperienceBarManager.BarState.values()) {
public static @NotNull SkillBossBarState asBarState(String str) {
for(SkillBossBarState barState : SkillBossBarState.values()) {
if(barState.toString().equalsIgnoreCase(str)) {
return barState;
}
}
mcMMO.p.getLogger().severe("Unable to read bar state for value " + str + " setting to default instead.");
return MMOExperienceBarManager.BarState.NORMAL;
return SkillBossBarState.NORMAL;
}
/*
* Skill Stat Calculations
*/
public static String[] calculateLengthDisplayValues(Player player, float skillValue, PrimarySkillType skill) {
public static @NotNull String[] calculateLengthDisplayValues(@NotNull McMMOPlayer mmoPlayer, float skillValue, @NotNull PrimarySkillType skill) {
int maxLength = skill.getSuperAbilityType().getMaxLength();
int abilityLengthVar = AdvancedConfig.getInstance().getAbilityLength();
int abilityLengthCap = AdvancedConfig.getInstance().getAbilityLengthCap();
@ -79,7 +81,7 @@ public final class SkillUtils {
length = 2 + (int) (skillValue / abilityLengthVar);
}
int enduranceLength = PerksUtils.handleActivationPerks(player, length, maxLength);
int enduranceLength = PerksUtils.handleActivationPerks(mmoPlayer.getPlayer(), length, maxLength);
if (maxLength != 0) {
length = Math.min(length, maxLength);
@ -92,10 +94,10 @@ public final class SkillUtils {
* Others
*/
public static int handleFoodSkills(Player player, int eventFoodLevel, SubSkillType subSkillType) {
int curRank = RankUtils.getRank(player, subSkillType);
public static int handleFoodSkills(@NotNull McMMOPlayer mmoPlayer, int eventFoodLevel, @NotNull SubSkillType subSkillType) {
int curRank = RankUtils.getRank(mmoPlayer, subSkillType);
int currentFoodLevel = player.getFoodLevel();
int currentFoodLevel = mmoPlayer.getPlayer().getFoodLevel();
int foodChange = eventFoodLevel - currentFoodLevel;
foodChange+=curRank;
@ -108,12 +110,12 @@ public final class SkillUtils {
*
* @param deactivatedTimeStamp Time of deactivation
* @param cooldown The length of the cooldown
* @param player The Player to check for cooldown perks
* @param mmoPlayer The Player to check for cooldown perks
*
* @return the number of seconds remaining before the cooldown expires
*/
public static int calculateTimeLeft(long deactivatedTimeStamp, int cooldown, Player player) {
return (int) (((deactivatedTimeStamp + (PerksUtils.handleCooldownPerks(player, cooldown) * Misc.TIME_CONVERSION_FACTOR)) - System.currentTimeMillis()) / Misc.TIME_CONVERSION_FACTOR);
public static int calculateTimeLeft(long deactivatedTimeStamp, int cooldown, @NotNull McMMOPlayer mmoPlayer) {
return (int) (((deactivatedTimeStamp + (PerksUtils.handleCooldownPerks(mmoPlayer.getPlayer(), cooldown) * Misc.TIME_CONVERSION_FACTOR)) - System.currentTimeMillis()) / Misc.TIME_CONVERSION_FACTOR);
}
/**
@ -135,11 +137,11 @@ public final class SkillUtils {
* @param skillName The name of the skill to check
* @return true if this is a valid skill, false otherwise
*/
public static boolean isSkill(String skillName) {
public static boolean isSkill(@NotNull String skillName) {
return Config.getInstance().getLocale().equalsIgnoreCase("en_US") ? PrimarySkillType.getSkill(skillName) != null : isLocalizedSkill(skillName);
}
public static void sendSkillMessage(Player player, NotificationType notificationType, String key) {
public static void sendSkillMessage(@NotNull Player player, @NotNull NotificationType notificationType, @NotNull String key) {
Location location = player.getLocation();
for (Player otherPlayer : player.getWorld().getPlayers()) {
@ -149,7 +151,7 @@ public final class SkillUtils {
}
}
public static void handleAbilitySpeedIncrease(Player player) {
public static void handleAbilitySpeedIncrease(@NotNull Player player) {
if (HiddenConfig.getInstance().useEnchantmentBuffs()) {
ItemStack heldItem = player.getInventory().getItemInMainHand();
@ -245,7 +247,7 @@ public final class SkillUtils {
}
}
public static void handleDurabilityChange(ItemStack itemStack, int durabilityModifier) {
public static void handleDurabilityChange(@NotNull ItemStack itemStack, int durabilityModifier) {
handleDurabilityChange(itemStack, durabilityModifier, 1.0);
}
@ -256,7 +258,7 @@ public final class SkillUtils {
* @param durabilityModifier the amount to modify the durability by
* @param maxDamageModifier the amount to adjust the max damage by
*/
public static void handleDurabilityChange(ItemStack itemStack, double durabilityModifier, double maxDamageModifier) {
public static void handleDurabilityChange(@NotNull ItemStack itemStack, double durabilityModifier, double maxDamageModifier) {
if(itemStack.getItemMeta() != null && itemStack.getItemMeta().isUnbreakable()) {
return;
}
@ -278,8 +280,7 @@ public final class SkillUtils {
return false;
}
@Nullable
public static Material getRepairAndSalvageItem(@NotNull ItemStack inHand) {
public static @Nullable Material getRepairAndSalvageItem(@NotNull ItemStack inHand) {
if (ItemUtils.isDiamondTool(inHand) || ItemUtils.isDiamondArmor(inHand)) {
return Material.DIAMOND;
}
@ -306,11 +307,16 @@ public final class SkillUtils {
}
}
public static int getRepairAndSalvageQuantities(ItemStack item) {
public static int getRepairAndSalvageQuantities(@NotNull ItemStack item) {
if(getRepairAndSalvageItem(item) == null) {
mcMMO.p.getLogger().severe("No value defined for item "+item.toString()+" in getRepairAndSalvageItem()");
throw new UnexpectedValueException();
}
return getRepairAndSalvageQuantities(item.getType(), getRepairAndSalvageItem(item));
}
public static int getRepairAndSalvageQuantities(Material itemMaterial, Material recipeMaterial) {
public static int getRepairAndSalvageQuantities(@NotNull Material itemMaterial, @NotNull Material recipeMaterial) {
int quantity = 0;
if(mcMMO.getMaterialMapStore().isNetheriteTool(itemMaterial) || mcMMO.getMaterialMapStore().isNetheriteArmor(itemMaterial)) {

View File

@ -0,0 +1,329 @@
# This file defines the rank level requirements for a subskill.
# You cannot alter how many ranks a skill has, that is coded into mcMMO directly.
# You can however, change when they unlock, if you make all ranks of a skill level 0 for example every player will have the most powerful version of that skill right away.
# Retro Mode and Standard have separate config settings to make it easier for server owners to understand the difference between the two.
# Retro Mode is setup to be an entirely cosmetic change, keeping the old 0-1000 feeling of mcMMO.
# Retro Mode has 10x faster leveling and 10x higher skill requirements, if you do the math you can see its the same as Standard and only cosmetic!.
###
Alchemy:
Catalysis:
Rank_1: 0
Concoctions:
Rank_1: 0
Rank_2: 100
Rank_3: 200
Rank_4: 350
Rank_5: 500
Rank_6: 750
Rank_7: 900
Rank_8: 1000
Archery:
ArcheryLimitBreak:
Rank_1: 100
Rank_2: 200
Rank_3: 300
Rank_4: 400
Rank_5: 500
Rank_6: 600
Rank_7: 700
Rank_8: 800
Rank_9: 900
Rank_10: 1000
ArrowRetrieval:
Rank_1: 1
SkillShot:
Rank_1: 1
Rank_2: 100
Rank_3: 150
Rank_4: 200
Rank_5: 250
Rank_6: 300
Rank_7: 350
Rank_8: 400
Rank_9: 450
Rank_10: 500
Rank_11: 550
Rank_12: 600
Rank_13: 650
Rank_14: 700
Rank_15: 750
Rank_16: 800
Rank_17: 850
Rank_18: 900
Rank_19: 950
Rank_20: 1000
Acrobatics:
Dodge:
Rank_1: 1
Axes:
AxesLimitBreak:
Rank_1: 100
Rank_2: 200
Rank_3: 300
Rank_4: 400
Rank_5: 500
Rank_6: 600
Rank_7: 700
Rank_8: 800
Rank_9: 900
Rank_10: 1000
SkullSplitter:
Rank_1: 50
CriticalStrikes:
Rank_1: 1
GreaterImpact:
Rank_1: 250
ArmorImpact:
Rank_1: 1
Rank_2: 100
Rank_3: 150
Rank_4: 200
Rank_5: 250
Rank_6: 300
Rank_7: 350
Rank_8: 400
Rank_9: 450
Rank_10: 500
Rank_11: 550
Rank_12: 600
Rank_13: 650
Rank_14: 700
Rank_15: 750
Rank_16: 800
Rank_17: 850
Rank_18: 900
Rank_19: 950
Rank_20: 1000
AxeMastery:
Rank_1: 50
Rank_2: 100
Rank_3: 150
Rank_4: 200
Taming:
Rank_1: 1
Gore:
Rank_1: 150
CallOfTheWild:
Rank_1: 1
Pummel:
Rank_1: 200
FastFoodService:
Rank_1: 200
EnvironmentallyAware:
Rank_1: 100
ThickFur:
Rank_1: 250
HolyHound:
Rank_1: 350
ShockProof:
Rank_1: 500
SharpenedClaws:
Rank_1: 750
Smelting:
FuelEfficiency:
Rank_1: 100
Rank_2: 500
Rank_3: 750
UnderstandingTheArt:
Rank_1: 100
Rank_2: 250
Rank_3: 350
Rank_4: 500
Rank_5: 650
Rank_6: 750
Rank_7: 850
Rank_8: 1000
Salvage:
ScrapCollector:
Rank_1: 1
Rank_2: 100
Rank_3: 150
Rank_4: 200
Rank_5: 250
Rank_6: 300
Rank_7: 350
Rank_8: 400
ArcaneSalvage:
Rank_1: 100
Rank_2: 250
Rank_3: 350
Rank_4: 500
Rank_5: 650
Rank_6: 750
Rank_7: 850
Rank_8: 1000
Mining:
DoubleDrops:
Rank_1: 1
SuperBreaker:
Rank_1: 50
# For now make sure rank 1 is the same as blast mining rank 1, it's a bit hacky, I'll fix it later
BiggerBombs:
Rank_1: 100
# For now make sure rank 1 is the same as blast mining rank 1, it's a bit hacky, I'll fix it later
DemolitionsExpertise:
Rank_1: 100
BlastMining:
Rank_1: 100
Rank_2: 250
Rank_3: 350
Rank_4: 500
Rank_5: 650
Rank_6: 750
Rank_7: 850
Rank_8: 1000
Herbalism:
DoubleDrops:
Rank_1: 1
GreenTerra:
Rank_1: 50
GreenThumb:
Rank_1: 250
Rank_2: 500
Rank_3: 750
Rank_4: 1000
FarmersDiet:
Rank_1: 200
Rank_2: 400
Rank_3: 600
Rank_4: 800
Rank_5: 1000
Fishing:
MagicHunter:
Rank_1: 200
Shake:
Rank_1: 150
MasterAngler:
Rank_1: 1
Rank_2: 200
Rank_3: 300
Rank_4: 400
Rank_5: 600
Rank_6: 700
Rank_7: 800
Rank_8: 900
IceFishing:
Rank_1: 50
FishermansDiet:
Rank_1: 200
Rank_2: 400
Rank_3: 600
Rank_4: 800
Rank_5: 1000
TreasureHunter:
Rank_1: 1
Rank_2: 250
Rank_3: 350
Rank_4: 500
Rank_5: 650
Rank_6: 750
Rank_7: 850
Rank_8: 1000
Swords:
SwordsLimitBreak:
Rank_1: 100
Rank_2: 200
Rank_3: 300
Rank_4: 400
Rank_5: 500
Rank_6: 600
Rank_7: 700
Rank_8: 800
Rank_9: 900
Rank_10: 1000
Stab:
Rank_1: 750
Rank_2: 1000
CounterAttack:
Rank_1: 200
Rupture:
Rank_1: 1
Rank_2: 150
Rank_3: 750
Rank_4: 900
SerratedStrikes:
Rank_1: 50
Unarmed:
UnarmedLimitBreak:
Rank_1: 100
Rank_2: 200
Rank_3: 300
Rank_4: 400
Rank_5: 500
Rank_6: 600
Rank_7: 700
Rank_8: 800
Rank_9: 900
Rank_10: 1000
Berserk:
Rank_1: 50
ArrowDeflect:
Rank_1: 200
Disarm:
Rank_1: 250
IronGrip:
Rank_1: 600
SteelArmStyle:
Rank_1: 1
Rank_2: 100
Rank_3: 150
Rank_4: 200
Rank_5: 250
Rank_6: 300
Rank_7: 350
Rank_8: 400
Rank_9: 450
Rank_10: 500
Rank_11: 550
Rank_12: 600
Rank_13: 650
Rank_14: 700
Rank_15: 750
Rank_16: 800
Rank_17: 850
Rank_18: 900
Rank_19: 950
Rank_20: 1000
Woodcutting:
TreeFeller:
Rank_1: 50
Rank_2: 250
Rank_3: 500
Rank_4: 750
Rank_5: 1000
HarvestLumber:
Rank_1: 1
KnockOnWood:
Rank_1: 300
Rank_2: 600
LeafBlower:
Rank_1: 150
Rank_2: 350
Rank_3: 650
Excavation:
GigaDrillBreaker:
Rank_1: 50
Archaeology:
Rank_1: 1
Rank_2: 250
Rank_3: 350
Rank_4: 500
Rank_5: 650
Rank_6: 750
Rank_7: 850
Rank_8: 1000
Repair:
RepairMastery:
Rank_1: 1
SuperRepair:
Rank_1: 400
ArcaneForging:
Rank_1: 100
Rank_2: 250
Rank_3: 350
Rank_4: 500
Rank_5: 650
Rank_6: 750
Rank_7: 850
Rank_8: 1000