mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-08-01 03:55:28 +02:00
more refactoring/rewrites for player data loading stuff
This commit is contained in:
@@ -13,6 +13,7 @@ import com.google.common.collect.ImmutableList;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -118,15 +119,6 @@ public final class CommandUtils {
|
||||
return hasPlayerDataKey;
|
||||
}
|
||||
|
||||
public static boolean isLoaded(CommandSender sender, PlayerProfile profile) {
|
||||
if (profile.isLoaded()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.NotLoaded"));
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isInvalidInteger(CommandSender sender, String value) {
|
||||
if (StringUtils.isInt(value)) {
|
||||
return false;
|
||||
@@ -204,11 +196,11 @@ public final class CommandUtils {
|
||||
printMiscSkills(player, player);
|
||||
}
|
||||
|
||||
public static String displaySkill(PlayerProfile profile, PrimarySkillType skill) {
|
||||
public static String displaySkill(@NotNull PlayerProfile profile, @NotNull PrimarySkillType skill) {
|
||||
if (skill.isChildSkill()) {
|
||||
return LocaleLoader.getString("Skills.ChildStats", LocaleLoader.getString(StringUtils.getCapitalized(skill.toString()) + ".Listener") + " ", profile.getSkillLevel(skill));
|
||||
}
|
||||
if (profile.getSkillLevel(skill) == Config.getInstance().getLevelCap(skill)){
|
||||
if (profile.getExperienceManager().getSkillLevel(skill) == Config.getInstance().getLevelCap(skill)){
|
||||
return LocaleLoader.getString("Skills.Stats", LocaleLoader.getString(StringUtils.getCapitalized(skill.toString()) + ".Listener") + " ", profile.getSkillLevel(skill), profile.getSkillXpLevel(skill), LocaleLoader.getString("Skills.MaxXP"));
|
||||
}
|
||||
return LocaleLoader.getString("Skills.Stats", LocaleLoader.getString(StringUtils.getCapitalized(skill.toString()) + ".Listener") + " ", profile.getSkillLevel(skill), profile.getSkillXpLevel(skill), profile.getXpToLevel(skill));
|
||||
|
@@ -4,6 +4,7 @@ import com.gmail.nossr50.config.AdvancedConfig;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.interactions.NotificationType;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.player.PersistentPlayerData;
|
||||
import com.gmail.nossr50.datatypes.skills.AbilityToolType;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
|
||||
@@ -20,6 +21,7 @@ import com.gmail.nossr50.util.sounds.SoundManager;
|
||||
import com.gmail.nossr50.util.sounds.SoundType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -35,9 +37,11 @@ public class SuperAbilityManager {
|
||||
private boolean abilityActivationPermission = true;
|
||||
|
||||
private final Map<AbilityToolType, Boolean> toolMode = new HashMap<>();
|
||||
private final PersistentPlayerData persistentPlayerData;
|
||||
|
||||
public SuperAbilityManager(McMMOPlayer mmoPlayer) {
|
||||
public SuperAbilityManager(@NotNull McMMOPlayer mmoPlayer, @NotNull PersistentPlayerData persistentPlayerData) {
|
||||
this.mmoPlayer = mmoPlayer;
|
||||
this.persistentPlayerData = persistentPlayerData;
|
||||
this.player = mmoPlayer.getPlayer();
|
||||
|
||||
for (SuperAbilityType superAbilityType : SuperAbilityType.values()) {
|
||||
@@ -231,13 +235,17 @@ public class SuperAbilityManager {
|
||||
/**
|
||||
* Reset the mode of all abilities.
|
||||
*/
|
||||
public void resetSuperAbilities() {
|
||||
public void disableSuperAbilities() {
|
||||
for (SuperAbilityType ability : SuperAbilityType.values()) {
|
||||
// Correctly disable and handle any special deactivate code
|
||||
new AbilityDisableTask(mmoPlayer, ability).run();
|
||||
}
|
||||
}
|
||||
|
||||
public void resetCooldowns() {
|
||||
this.persistentPlayerData.resetCooldowns();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mode of an ability.
|
||||
*
|
||||
|
@@ -67,6 +67,10 @@ public final class UserManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
public @Nullable PlayerProfile queryPlayer(@NotNull String playerName) {
|
||||
return mcMMO.getDatabaseManager().queryPlayerByName(playerName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a user.
|
||||
*
|
||||
|
Reference in New Issue
Block a user