Fixed migration

This commit is contained in:
Auxilor 2021-11-01 21:29:38 +00:00
parent d281430a4d
commit 8ae4964d2e
2 changed files with 8 additions and 6 deletions

View File

@ -5,6 +5,7 @@ import com.willfp.eco.core.command.impl.Subcommand;
import com.willfp.eco.core.data.PlayerProfile;
import com.willfp.eco.core.data.keys.PersistentDataKey;
import com.willfp.eco.core.data.keys.PersistentDataKeyType;
import com.willfp.eco.util.NamespacedKeyUtils;
import com.willfp.ecoenchants.EcoEnchantsPlugin;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
@ -13,8 +14,8 @@ public class CommandToggleDescriptions extends Subcommand {
/**
* Persistent data key for descriptions.
*/
private final PersistentDataKey<Boolean> descriptionsKey = new PersistentDataKey<>(
this.getPlugin().getNamespacedKeyFactory().create("descriptions_enabled"),
public static final PersistentDataKey<Boolean> DESCRIPTIONS_KEY = new PersistentDataKey<>(
NamespacedKeyUtils.create("ecoenchants", "descriptions_enabled"),
PersistentDataKeyType.BOOLEAN,
true
);
@ -37,9 +38,9 @@ public class CommandToggleDescriptions extends Subcommand {
}
Player player = (Player) sender;
PlayerProfile profile = PlayerProfile.load(player);
boolean currentStatus = profile.read(descriptionsKey);
boolean currentStatus = profile.read(DESCRIPTIONS_KEY);
currentStatus = !currentStatus;
profile.write(descriptionsKey, currentStatus);
profile.write(DESCRIPTIONS_KEY, currentStatus);
if (currentStatus) {
player.sendMessage(this.getPlugin().getLangYml().getMessage("enabled-descriptions"));
} else {

View File

@ -2,7 +2,8 @@ package com.willfp.ecoenchants.display.options;
import com.willfp.eco.core.EcoPlugin;
import com.willfp.eco.core.PluginDependent;
import com.willfp.ecoenchants.data.storage.PlayerProfile;
import com.willfp.eco.core.data.PlayerProfile;
import com.willfp.ecoenchants.command.CommandToggleDescriptions;
import lombok.Getter;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
@ -62,6 +63,6 @@ public class DescriptionOptions extends PluginDependent<EcoPlugin> {
return true;
}
return PlayerProfile.getProfile(player).read("descriptions", true);
return PlayerProfile.load(player).read(CommandToggleDescriptions.DESCRIPTIONS_KEY);
}
}