use of com.archyx.aureliumskills.data.PlayerData in project AureliumSkills by Archy-X.
the class SkillsCommand method onSkillSetall.
@Subcommand("skill setall")
@CommandCompletion("@players")
@CommandPermission("aureliumskills.skill.setlevel")
@Description("Sets all of a player's skills to a level.")
public void onSkillSetall(CommandSender sender, @Flags("other") Player player, int level) {
Locale locale = plugin.getLang().getLocale(sender);
if (level > 0) {
PlayerData playerData = plugin.getPlayerManager().getPlayerData(player);
if (playerData == null)
return;
for (Skill skill : plugin.getSkillRegistry().getSkills()) {
if (OptionL.isEnabled(skill)) {
int oldLevel = playerData.getSkillLevel(skill);
playerData.setSkillLevel(skill, level);
playerData.setSkillXp(skill, 0);
// Reload items and armor to check for newly met requirements
plugin.getModifierManager().reloadPlayer(player);
plugin.getLeveler().applyRevertCommands(player, skill, oldLevel, level);
plugin.getLeveler().applyLevelUpCommands(player, skill, oldLevel, level);
}
}
plugin.getLeveler().updateStats(player);
plugin.getLeveler().updatePermissions(player);
sender.sendMessage(AureliumSkills.getPrefix(locale) + Lang.getMessage(CommandMessage.SKILL_SETALL_SET, locale).replace("{level}", String.valueOf(level)).replace("{player}", player.getName()));
} else {
sender.sendMessage(AureliumSkills.getPrefix(locale) + Lang.getMessage(CommandMessage.SKILL_SETALL_AT_LEAST_ONE, locale));
}
}
use of com.archyx.aureliumskills.data.PlayerData in project AureliumSkills by Archy-X.
the class SkillsCommand method listModifiers.
private void listModifiers(CommandSender sender, @Optional @Flags("other") Player player, @Optional Stat stat, Locale locale) {
PlayerData playerData = plugin.getPlayerManager().getPlayerData(player);
if (playerData != null) {
StringBuilder message;
if (stat == null) {
message = new StringBuilder(StatModifier.applyPlaceholders(Lang.getMessage(CommandMessage.MODIFIER_LIST_ALL_STATS_HEADER, locale), player));
for (String key : playerData.getStatModifiers().keySet()) {
StatModifier modifier = playerData.getStatModifiers().get(key);
message.append("\n").append(StatModifier.applyPlaceholders(Lang.getMessage(CommandMessage.MODIFIER_LIST_ALL_STATS_ENTRY, locale), modifier, player, locale));
}
} else {
message = new StringBuilder(StatModifier.applyPlaceholders(Lang.getMessage(CommandMessage.MODIFIER_LIST_ONE_STAT_HEADER, locale), stat, player, locale));
for (String key : playerData.getStatModifiers().keySet()) {
StatModifier modifier = playerData.getStatModifiers().get(key);
if (modifier.getStat() == stat) {
message.append("\n").append(StatModifier.applyPlaceholders(Lang.getMessage(CommandMessage.MODIFIER_LIST_ONE_STAT_ENTRY, locale), modifier, player, locale));
}
}
}
sender.sendMessage(message.toString());
} else {
sender.sendMessage(AureliumSkills.getPrefix(locale) + Lang.getMessage(CommandMessage.NO_PROFILE, locale));
}
}
use of com.archyx.aureliumskills.data.PlayerData in project AureliumSkills by Archy-X.
the class SkillsCommand method onRemoveAll.
@Subcommand("modifier removeall")
@CommandCompletion("@players @stats")
@CommandPermission("aureliumskills.modifier.removeall")
@Description("Removes all stat modifiers from a player.")
public void onRemoveAll(CommandSender sender, @Flags("other") @Optional Player player, @Optional Stat stat, @Default("false") boolean silent) {
Locale locale = plugin.getLang().getLocale(sender);
if (player == null) {
if (sender instanceof Player) {
Player target = (Player) sender;
PlayerData playerData = plugin.getPlayerManager().getPlayerData(target);
removeAllModifiers(sender, stat, silent, locale, target, playerData);
} else {
if (!silent) {
sender.sendMessage(AureliumSkills.getPrefix(locale) + Lang.getMessage(CommandMessage.MODIFIER_REMOVEALL_PLAYERS_ONLY, locale));
}
}
} else {
PlayerData playerData = plugin.getPlayerManager().getPlayerData(player);
removeAllModifiers(sender, stat, silent, locale, player, playerData);
}
}
use of com.archyx.aureliumskills.data.PlayerData in project AureliumSkills by Archy-X.
the class SkillsCommand method onLanguage.
@Subcommand("lang")
@CommandCompletion("@lang")
@CommandPermission("aureliumskills.lang")
@Description("Changes your player language")
public void onLanguage(Player player, String language) {
Locale locale = new Locale(language.toLowerCase(Locale.ENGLISH));
if (Lang.hasLocale(locale)) {
PlayerData playerData = plugin.getPlayerManager().getPlayerData(player);
if (playerData == null)
return;
playerData.setLocale(locale);
plugin.getCommandManager().setPlayerLocale(player, locale);
player.sendMessage(AureliumSkills.getPrefix(locale) + Lang.getMessage(CommandMessage.LANG_SET, locale).replace("{lang}", Lang.getDefinedLanguages().get(locale)));
} else {
player.sendMessage(AureliumSkills.getPrefix(locale) + Lang.getMessage(CommandMessage.LANG_NOT_FOUND, plugin.getLang().getLocale(player)));
}
}
use of com.archyx.aureliumskills.data.PlayerData in project AureliumSkills by Archy-X.
the class SkillsCommand method onBackupLoad.
@Subcommand("backup load")
@CommandPermission("aureliumskills.backup.load")
public void onBackupLoad(CommandSender sender, String fileName) {
StorageProvider storageProvider = plugin.getStorageProvider();
Locale locale = plugin.getLang().getLocale(sender);
if (storageProvider != null) {
File file = new File(plugin.getDataFolder() + "/backups/" + fileName);
if (file.exists()) {
if (file.getName().endsWith(".yml")) {
// Require player to double type command
if (sender instanceof Player) {
PlayerData playerData = plugin.getPlayerManager().getPlayerData((Player) sender);
if (playerData == null)
return;
Object typed = playerData.getMetadata().get("backup_command");
if (typed != null) {
if (typed instanceof String) {
String typedFile = (String) typed;
if (typedFile.equals(file.getName())) {
sender.sendMessage(AureliumSkills.getPrefix(locale) + Lang.getMessage(CommandMessage.BACKUP_LOAD_LOADING, locale));
storageProvider.loadBackup(YamlConfiguration.loadConfiguration(file), sender);
playerData.getMetadata().remove("backup_command");
} else {
backupLoadConfirm(playerData, sender, file);
}
} else {
backupLoadConfirm(playerData, sender, file);
}
} else {
backupLoadConfirm(playerData, sender, file);
}
} else {
sender.sendMessage(AureliumSkills.getPrefix(locale) + Lang.getMessage(CommandMessage.BACKUP_LOAD_LOADING, locale));
storageProvider.loadBackup(YamlConfiguration.loadConfiguration(file), sender);
}
} else {
sender.sendMessage(AureliumSkills.getPrefix(locale) + Lang.getMessage(CommandMessage.BACKUP_LOAD_MUST_BE_YAML, locale));
}
} else {
// If file does not exist
sender.sendMessage(AureliumSkills.getPrefix(locale) + Lang.getMessage(CommandMessage.BACKUP_LOAD_FILE_NOT_FOUND, locale));
}
}
}
Aggregations