use of com.archyx.aureliumskills.skills.Skill in project AureliumSkills by Archy-X.
the class SkillsCommand method onItemMultiplierAdd.
@Subcommand("item multiplier add")
@CommandCompletion("@skills_global @nothing true|false")
@CommandPermission("aureliumskills.item.multiplier.add")
@Description("Adds an item multiplier to the held item to global or a specific skill where value is the percent more XP gained.")
public void onItemMultiplierAdd(@Flags("itemheld") Player player, String target, double value, @Default("true") boolean lore) {
ItemStack item = player.getInventory().getItemInMainHand();
Skill skill = plugin.getSkillRegistry().getSkill(target);
Locale locale = plugin.getLang().getLocale(player);
Multipliers multipliers = new Multipliers(plugin);
if (skill != null) {
// Add multiplier for specific skill
for (Multiplier multiplier : multipliers.getMultipliers(ModifierType.ITEM, item)) {
if (multiplier.getSkill() == skill) {
player.sendMessage(AureliumSkills.getPrefix(locale) + TextUtil.replace(Lang.getMessage(CommandMessage.ITEM_MULTIPLIER_ADD_ALREADY_EXISTS, locale), "{target}", skill.getDisplayName(locale)));
return;
}
}
if (lore) {
multipliers.addLore(ModifierType.ITEM, item, skill, value, locale);
}
ItemStack newItem = multipliers.addMultiplier(ModifierType.ITEM, item, skill, value);
player.getInventory().setItemInMainHand(newItem);
player.sendMessage(AureliumSkills.getPrefix(locale) + TextUtil.replace(Lang.getMessage(CommandMessage.ITEM_MULTIPLIER_ADD_ADDED, locale), "{target}", skill.getDisplayName(locale), "{value}", String.valueOf(value)));
} else if (target.equalsIgnoreCase("global")) {
// Add multiplier for all skills
String global = Lang.getMessage(CommandMessage.MULTIPLIER_GLOBAL, locale);
for (Multiplier multiplier : multipliers.getMultipliers(ModifierType.ITEM, item)) {
if (multiplier.getSkill() == null) {
player.sendMessage(AureliumSkills.getPrefix(locale) + TextUtil.replace(Lang.getMessage(CommandMessage.ITEM_MULTIPLIER_ADD_ALREADY_EXISTS, locale), "{target}", global));
return;
}
}
if (lore) {
multipliers.addLore(ModifierType.ITEM, item, null, value, locale);
}
ItemStack newItem = multipliers.addMultiplier(ModifierType.ITEM, item, null, value);
player.getInventory().setItemInMainHand(newItem);
player.sendMessage(AureliumSkills.getPrefix(locale) + TextUtil.replace(Lang.getMessage(CommandMessage.ITEM_MULTIPLIER_ADD_ADDED, locale), "{target}", global, "{value}", String.valueOf(value)));
} else {
throw new InvalidCommandArgument("Target must be valid skill name or global");
}
}
use of com.archyx.aureliumskills.skills.Skill in project AureliumSkills by Archy-X.
the class SkillsCommand method onItemMultiplierRemove.
@Subcommand("item multiplier remove")
@CommandCompletion("@skills_global")
@CommandPermission("aureliumskills.item.multiplier.remove")
@Description("Removes an item multiplier of a the specified skill or global from the held item.")
public void onItemMultiplierRemove(@Flags("itemheld") Player player, String target) {
Locale locale = plugin.getLang().getLocale(player);
ItemStack item = player.getInventory().getItemInMainHand();
Skill skill = plugin.getSkillRegistry().getSkill(target);
boolean removed = false;
Multipliers multipliers = new Multipliers(plugin);
for (Multiplier multiplier : multipliers.getMultipliers(ModifierType.ITEM, item)) {
if (multiplier.getSkill() == skill) {
item = multipliers.removeMultiplier(ModifierType.ITEM, item, skill);
removed = true;
break;
}
}
player.getInventory().setItemInMainHand(item);
// Use skill display name if skill is not null, otherwise use global name
String targetName;
if (skill != null) {
targetName = skill.getDisplayName(locale);
} else if (target.equalsIgnoreCase("global")) {
targetName = Lang.getMessage(CommandMessage.MULTIPLIER_GLOBAL, locale);
} else {
throw new InvalidCommandArgument("Target must be valid skill name or global");
}
if (removed) {
player.sendMessage(AureliumSkills.getPrefix(locale) + TextUtil.replace(Lang.getMessage(CommandMessage.ITEM_MULTIPLIER_REMOVE_REMOVED, locale), "{target}", targetName));
} else {
player.sendMessage(AureliumSkills.getPrefix(locale) + TextUtil.replace(Lang.getMessage(CommandMessage.ITEM_MULTIPLIER_REMOVE_DOES_NOT_EXIST, locale), "{target}", targetName));
}
}
use of com.archyx.aureliumskills.skills.Skill in project AureliumSkills by Archy-X.
the class SkillsCommand method onArmorMultiplierAdd.
@Subcommand("armor multiplier add")
@CommandCompletion("@skills_global @nothing true|false")
@CommandPermission("aureliumskills.armor.multiplier.add")
@Description("Adds an armor multiplier to the held item to global or a specific skill where value is the percent more XP gained.")
public void onArmorMultiplierAdd(@Flags("itemheld") Player player, String target, double value, @Default("true") boolean lore) {
ItemStack item = player.getInventory().getItemInMainHand();
Skill skill = plugin.getSkillRegistry().getSkill(target);
Locale locale = plugin.getLang().getLocale(player);
Multipliers multipliers = new Multipliers(plugin);
if (skill != null) {
// Add multiplier for specific skill
for (Multiplier multiplier : multipliers.getMultipliers(ModifierType.ARMOR, item)) {
if (multiplier.getSkill() == skill) {
player.sendMessage(AureliumSkills.getPrefix(locale) + TextUtil.replace(Lang.getMessage(CommandMessage.ARMOR_MULTIPLIER_ADD_ALREADY_EXISTS, locale), "{target}", skill.getDisplayName(locale)));
return;
}
}
if (lore) {
multipliers.addLore(ModifierType.ARMOR, item, skill, value, locale);
}
ItemStack newItem = multipliers.addMultiplier(ModifierType.ARMOR, item, skill, value);
player.getInventory().setItemInMainHand(newItem);
player.sendMessage(AureliumSkills.getPrefix(locale) + TextUtil.replace(Lang.getMessage(CommandMessage.ARMOR_MULTIPLIER_ADD_ADDED, locale), "{target}", skill.getDisplayName(locale), "{value}", String.valueOf(value)));
} else if (target.equalsIgnoreCase("global")) {
// Add multiplier for all skills
String global = Lang.getMessage(CommandMessage.MULTIPLIER_GLOBAL, locale);
for (Multiplier multiplier : multipliers.getMultipliers(ModifierType.ARMOR, item)) {
if (multiplier.getSkill() == null) {
player.sendMessage(AureliumSkills.getPrefix(locale) + TextUtil.replace(Lang.getMessage(CommandMessage.ARMOR_MULTIPLIER_ADD_ALREADY_EXISTS, locale), "{target}", global));
return;
}
}
if (lore) {
multipliers.addLore(ModifierType.ARMOR, item, null, value, locale);
}
ItemStack newItem = multipliers.addMultiplier(ModifierType.ARMOR, item, null, value);
player.getInventory().setItemInMainHand(newItem);
player.sendMessage(AureliumSkills.getPrefix(locale) + TextUtil.replace(Lang.getMessage(CommandMessage.ARMOR_MULTIPLIER_ADD_ADDED, locale), "{target}", global, "{value}", String.valueOf(value)));
} else {
throw new InvalidCommandArgument("Target must be valid skill name or global");
}
}
use of com.archyx.aureliumskills.skills.Skill in project AureliumSkills by Archy-X.
the class SkillsCommand method onArmorMultiplierRemove.
@Subcommand("armor multiplier remove")
@CommandCompletion("@skills_global")
@CommandPermission("aureliumskills.armor.multiplier.remove")
@Description("Removes an armor multiplier of a the specified skill or global from the held item.")
public void onArmorMultiplierRemove(@Flags("itemheld") Player player, String target) {
Locale locale = plugin.getLang().getLocale(player);
ItemStack item = player.getInventory().getItemInMainHand();
Skill skill = plugin.getSkillRegistry().getSkill(target);
boolean removed = false;
Multipliers multipliers = new Multipliers(plugin);
for (Multiplier multiplier : multipliers.getMultipliers(ModifierType.ARMOR, item)) {
if (multiplier.getSkill() == skill) {
item = multipliers.removeMultiplier(ModifierType.ARMOR, item, skill);
removed = true;
break;
}
}
player.getInventory().setItemInMainHand(item);
// Use skill display name if skill is not null, otherwise use global name
String targetName;
if (skill != null) {
targetName = skill.getDisplayName(locale);
} else if (target.equalsIgnoreCase("global")) {
targetName = Lang.getMessage(CommandMessage.MULTIPLIER_GLOBAL, locale);
} else {
throw new InvalidCommandArgument("Target must be valid skill name or global");
}
if (removed) {
player.sendMessage(AureliumSkills.getPrefix(locale) + TextUtil.replace(Lang.getMessage(CommandMessage.ARMOR_MULTIPLIER_REMOVE_REMOVED, locale), "{target}", targetName));
} else {
player.sendMessage(AureliumSkills.getPrefix(locale) + TextUtil.replace(Lang.getMessage(CommandMessage.ARMOR_MULTIPLIER_REMOVE_DOES_NOT_EXIST, locale), "{target}", targetName));
}
}
use of com.archyx.aureliumskills.skills.Skill in project AureliumSkills by Archy-X.
the class SkillsCommand method onSkillReset.
@Subcommand("skill reset")
@CommandCompletion("@players @skills")
@CommandPermission("aureliumskills.skill.reset")
@Description("Resets all skills or a specific skill to level 1 for a player.")
public void onSkillReset(CommandSender sender, @Flags("other") Player player, @Optional Skill skill) {
Locale locale = plugin.getLang().getLocale(sender);
if (skill != null) {
if (OptionL.isEnabled(skill)) {
PlayerData playerData = plugin.getPlayerManager().getPlayerData(player);
if (playerData == null)
return;
resetPlayerSkills(player, playerData, skill);
// Reload items and armor to check for newly met requirements
this.plugin.getModifierManager().reloadPlayer(player);
sender.sendMessage(AureliumSkills.getPrefix(locale) + Lang.getMessage(CommandMessage.SKILL_RESET_RESET_SKILL, locale).replace("{skill}", skill.getDisplayName(locale)).replace("{player}", player.getName()));
} else {
sender.sendMessage(AureliumSkills.getPrefix(locale) + Lang.getMessage(CommandMessage.UNKNOWN_SKILL, locale));
}
} else {
PlayerData playerData = plugin.getPlayerManager().getPlayerData(player);
if (playerData == null)
return;
for (Skill s : plugin.getSkillRegistry().getSkills()) {
resetPlayerSkills(player, playerData, s);
}
sender.sendMessage(AureliumSkills.getPrefix(locale) + Lang.getMessage(CommandMessage.SKILL_RESET_RESET_ALL, locale).replace("{player}", player.getName()));
}
}
Aggregations