forked from Upstream/mmocore
skill realloc points
This commit is contained in:
parent
a61b9bc634
commit
5e6b504a35
@ -13,7 +13,8 @@ public enum SoundEvent {
|
||||
SELECT_CLASS,
|
||||
LEVEL_ATTRIBUTE,
|
||||
RESET_ATTRIBUTES,
|
||||
NOT_ENOUGH_POINTS,
|
||||
RESET_SKILLS
|
||||
,NOT_ENOUGH_POINTS,
|
||||
CANCEL_QUEST,
|
||||
START_QUEST,
|
||||
CLOSE_LOOT_CHEST;
|
||||
|
@ -66,7 +66,7 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
|
||||
*/
|
||||
@Nullable
|
||||
private PlayerClass profess;
|
||||
private int level, classPoints, skillPoints, attributePoints, attributeReallocationPoints;// skillReallocationPoints,
|
||||
private int level, classPoints, skillPoints, attributePoints, attributeReallocationPoints, skillReallocationPoints;
|
||||
private double experience;
|
||||
private double mana, stamina, stellium;
|
||||
private Guild guild;
|
||||
@ -238,6 +238,19 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
|
||||
return skillPoints;
|
||||
}
|
||||
|
||||
public void giveSkillReallocationPoints(int value) {
|
||||
skillReallocationPoints+=value;
|
||||
}
|
||||
|
||||
public int countSkillPointsWhenReallocate() {
|
||||
int sum = 0;
|
||||
for(ClassSkill skill:getProfess().getSkills()) {
|
||||
//0 if the skill is level 1(just unlocked) or 0 locked.
|
||||
sum+=Math.max(0,getSkillLevel(skill.getSkill())-1);
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getClaims(ExperienceObject object, ExperienceTable table, ExperienceItem item) {
|
||||
@ -350,6 +363,14 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
|
||||
attributeReallocationPoints = Math.max(0, value);
|
||||
}
|
||||
|
||||
public void setSkillReallocationPoints(int value) {
|
||||
skillReallocationPoints = Math.max(0, value);
|
||||
}
|
||||
|
||||
public int getSkillReallocationPoints() {
|
||||
return skillReallocationPoints;
|
||||
}
|
||||
|
||||
public void setSkillPoints(int value) {
|
||||
skillPoints = Math.max(0, value);
|
||||
}
|
||||
@ -851,7 +872,6 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
|
||||
Validate.notNull(skill, "Skill cannot be null");
|
||||
|
||||
|
||||
|
||||
if (boundSkills.size() < getProfess().getMaxBoundSkills())
|
||||
boundSkills.add(skill);
|
||||
else
|
||||
|
@ -25,6 +25,7 @@ public class AdminCommandTreeNode extends CommandTreeNode {
|
||||
addChild(new PointsCommandTreeNode("class", this, PlayerData::setClassPoints, PlayerData::giveClassPoints, PlayerData::getClassPoints));
|
||||
addChild(new PointsCommandTreeNode("attribute", this, PlayerData::setAttributePoints, PlayerData::giveAttributePoints, PlayerData::getAttributePoints));
|
||||
addChild(new PointsCommandTreeNode("attr-realloc", this, PlayerData::setAttributeReallocationPoints, PlayerData::giveAttributeReallocationPoints, PlayerData::getAttributeReallocationPoints));
|
||||
addChild(new PointsCommandTreeNode("skill-realloc",this,PlayerData::setSkillReallocationPoints,PlayerData::giveSkillReallocationPoints,PlayerData::getSkillReallocationPoints));
|
||||
addChild(new SkillCommandTreeNode(this));
|
||||
for (PlayerResource res : PlayerResource.values())
|
||||
addChild(new ResourceCommandTreeNode(res.name().toLowerCase(), this, res));
|
||||
|
@ -4,6 +4,7 @@ import io.lumine.mythic.lib.MythicLib;
|
||||
import io.lumine.mythic.lib.api.item.ItemTag;
|
||||
import io.lumine.mythic.lib.api.item.NBTItem;
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.SoundEvent;
|
||||
import net.Indyuce.mmocore.gui.api.InventoryClickContext;
|
||||
import net.Indyuce.mmocore.gui.api.item.InventoryItem;
|
||||
import net.Indyuce.mmocore.gui.api.item.SimplePlaceholderItem;
|
||||
@ -14,6 +15,7 @@ import net.Indyuce.mmocore.gui.api.GeneratedInventory;
|
||||
import net.Indyuce.mmocore.gui.api.item.Placeholders;
|
||||
import net.Indyuce.mmocore.skill.ClassSkill;
|
||||
import net.Indyuce.mmocore.skill.RegisteredSkill;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
@ -46,6 +48,23 @@ public class SkillList extends EditableInventory {
|
||||
if (function.equals("upgrade"))
|
||||
return new UpgradeItem(config);
|
||||
|
||||
if (function.equals("reallocation")) {
|
||||
|
||||
return new InventoryItem(config) {
|
||||
|
||||
@Override
|
||||
public Placeholders getPlaceholders(GeneratedInventory inv, int n) {
|
||||
Placeholders holders = new Placeholders();
|
||||
holders.register("skill_points", inv.getPlayerData().getSkillPoints());
|
||||
holders.register("points", inv.getPlayerData().getSkillReallocationPoints());
|
||||
holders.register("total", inv.getPlayerData().countSkillPointsWhenReallocate());
|
||||
return holders;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (function.equals("slot"))
|
||||
return new InventoryItem<SkillViewerInventory>(config) {
|
||||
private final String none = MythicLib.plugin.parseColors(config.getString("no-skill"));
|
||||
@ -308,6 +327,35 @@ public class SkillList extends EditableInventory {
|
||||
return;
|
||||
}
|
||||
|
||||
if(item.getFunction().equals("reallocation")) {
|
||||
|
||||
|
||||
|
||||
int spent= getPlayerData().countSkillPointsWhenReallocate();
|
||||
|
||||
if (spent < 1) {
|
||||
MMOCore.plugin.configManager.getSimpleMessage("no-skill-points-spent").send(player);
|
||||
MMOCore.plugin.soundManager.getSound(SoundEvent.NOT_ENOUGH_POINTS).playTo(getPlayer());
|
||||
return;
|
||||
}
|
||||
|
||||
if (playerData.getSkillReallocationPoints() < 1) {
|
||||
MMOCore.plugin.configManager.getSimpleMessage("not-skill-reallocation-point").send(player);
|
||||
MMOCore.plugin.soundManager.getSound(SoundEvent.NOT_ENOUGH_POINTS).playTo(getPlayer());
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
for(ClassSkill skill:playerData.getProfess().getSkills()) {
|
||||
playerData.setSkillLevel(skill.getSkill(), 1);
|
||||
}
|
||||
playerData.giveSkillPoints(spent);
|
||||
playerData.setSkillReallocationPoints(playerData.getSkillReallocationPoints()-1);
|
||||
MMOCore.plugin.configManager.getSimpleMessage("skill-points-reallocated", "points", "" + playerData.getSkillPoints()).send(player);
|
||||
MMOCore.plugin.soundManager.getSound(SoundEvent.RESET_SKILLS).playTo(getPlayer());
|
||||
open();
|
||||
}
|
||||
|
||||
if (item.getFunction().equals("previous")) {
|
||||
player.playSound(player.getLocation(), Sound.UI_BUTTON_CLICK, 1, 2);
|
||||
page--;
|
||||
|
@ -16,7 +16,7 @@ import java.util.*;
|
||||
public abstract class PlayerDataManager {
|
||||
private final static Map<UUID, PlayerData> data = Collections.synchronizedMap(new HashMap<>());
|
||||
|
||||
private DefaultPlayerData defaultData = new DefaultPlayerData(1, 0, 0, 0, 0);
|
||||
private DefaultPlayerData defaultData = new DefaultPlayerData(1, 0, 0, 0, 0,0);
|
||||
|
||||
public PlayerData get(OfflinePlayer player) {
|
||||
return get(player.getUniqueId());
|
||||
@ -134,7 +134,7 @@ public abstract class PlayerDataManager {
|
||||
public abstract void saveData(PlayerData data);
|
||||
|
||||
public class DefaultPlayerData {
|
||||
private final int level, classPoints, skillPoints, attributePoints, attrReallocPoints;
|
||||
private final int level, classPoints, skillPoints, attributePoints, attrReallocPoints,skillReallocPoints;
|
||||
|
||||
public DefaultPlayerData(ConfigurationSection config) {
|
||||
level = config.getInt("level", 1);
|
||||
@ -142,14 +142,17 @@ public abstract class PlayerDataManager {
|
||||
skillPoints = config.getInt("skill-points");
|
||||
attributePoints = config.getInt("attribute-points");
|
||||
attrReallocPoints = config.getInt("attribute-realloc-points");
|
||||
skillReallocPoints=config.getInt("skill-realloc-points",0);
|
||||
}
|
||||
|
||||
public DefaultPlayerData(int level, int classPoints, int skillPoints, int attributePoints, int attrReallocPoints) {
|
||||
public DefaultPlayerData(int level, int classPoints, int skillPoints, int attributePoints, int attrReallocPoints,int skillReallocPoints) {
|
||||
this.level = level;
|
||||
this.classPoints = classPoints;
|
||||
this.skillPoints = skillPoints;
|
||||
this.attributePoints = attributePoints;
|
||||
this.attrReallocPoints = attrReallocPoints;
|
||||
this.skillReallocPoints=skillReallocPoints;
|
||||
|
||||
}
|
||||
|
||||
public int getLevel() {
|
||||
@ -172,6 +175,10 @@ public abstract class PlayerDataManager {
|
||||
return attributePoints;
|
||||
}
|
||||
|
||||
public int getSkillReallocPoints() {
|
||||
return skillReallocPoints;
|
||||
}
|
||||
|
||||
public void apply(PlayerData player) {
|
||||
player.setLevel(level);
|
||||
player.setClassPoints(classPoints);
|
||||
|
@ -60,6 +60,7 @@ public class MySQLPlayerDataManager extends PlayerDataManager {
|
||||
|
||||
data.setClassPoints(result.getInt("class_points"));
|
||||
data.setSkillPoints(result.getInt("skill_points"));
|
||||
data.setSkillReallocationPoints(result.getInt("skill_reallocation_points"));
|
||||
data.setAttributePoints(result.getInt("attribute_points"));
|
||||
data.setAttributeReallocationPoints(result.getInt("attribute_realloc_points"));
|
||||
data.setLevel(result.getInt("level"));
|
||||
@ -126,6 +127,7 @@ public class MySQLPlayerDataManager extends PlayerDataManager {
|
||||
data.setLevel(getDefaultData().getLevel());
|
||||
data.setClassPoints(getDefaultData().getClassPoints());
|
||||
data.setSkillPoints(getDefaultData().getSkillPoints());
|
||||
data.setSkillReallocationPoints(getDefaultData().getSkillReallocPoints());
|
||||
data.setAttributePoints(getDefaultData().getAttributePoints());
|
||||
data.setAttributeReallocationPoints(getDefaultData().getAttrReallocPoints());
|
||||
data.setExperience(0);
|
||||
@ -155,6 +157,7 @@ public class MySQLPlayerDataManager extends PlayerDataManager {
|
||||
|
||||
sql.updateData("class_points", data.getClassPoints());
|
||||
sql.updateData("skill_points", data.getSkillPoints());
|
||||
sql.updateData("skill_reallocation_points",data.getSkillReallocationPoints());
|
||||
sql.updateData("attribute_points", data.getAttributePoints());
|
||||
sql.updateData("attribute_realloc_points", data.getAttributeReallocationPoints());
|
||||
sql.updateData("level", data.getLevel());
|
||||
|
@ -30,6 +30,7 @@ public class YAMLPlayerDataManager extends PlayerDataManager {
|
||||
|
||||
data.setClassPoints(config.getInt("class-points", getDefaultData().getClassPoints()));
|
||||
data.setSkillPoints(config.getInt("skill-points", getDefaultData().getSkillPoints()));
|
||||
data.setSkillReallocationPoints(config.getInt("skill-reallocation-points",getDefaultData().getSkillReallocPoints()));
|
||||
data.setAttributePoints(config.getInt("attribute-points", getDefaultData().getAttributePoints()));
|
||||
data.setAttributeReallocationPoints(config.getInt("attribute-realloc-points", getDefaultData().getAttrReallocPoints()));
|
||||
data.setLevel(config.getInt("level", getDefaultData().getLevel()));
|
||||
@ -90,6 +91,7 @@ public class YAMLPlayerDataManager extends PlayerDataManager {
|
||||
|
||||
config.set("class-points", data.getClassPoints());
|
||||
config.set("skill-points", data.getSkillPoints());
|
||||
config.set("skill-reallocation-points",data.getSkillReallocationPoints());
|
||||
config.set("attribute-points", data.getAttributePoints());
|
||||
// config.set("skill-realloc-points", skillReallocationPoints);
|
||||
config.set("attribute-realloc-points", data.getAttributeReallocationPoints());
|
||||
|
@ -31,9 +31,11 @@ default-playerdata:
|
||||
level: 1
|
||||
class-points: 0
|
||||
skill-points: 0
|
||||
skill-realloc-points: 0
|
||||
attribute-points: 0
|
||||
attribute-realloc-points: 0
|
||||
|
||||
|
||||
# The list of all conditions which must be met for the
|
||||
# BLOCK REGEN and BLOCK RESTRICTIONS to apply. Set to
|
||||
# 'custom-mine-conditions: []' to disable custom mining entirely.
|
||||
|
@ -2,6 +2,7 @@
|
||||
# GUI display name
|
||||
name: Player Attributes
|
||||
|
||||
|
||||
# Number of slots in your inventory. Must be
|
||||
# between 9 and 54 and must be a multiple of 9.
|
||||
slots: 27
|
||||
@ -11,10 +12,10 @@ items:
|
||||
slots: [26]
|
||||
function: reallocation
|
||||
item: CAULDRON
|
||||
name: '&aReallocate Skill Points'
|
||||
name: '&aAttribute Points'
|
||||
lore:
|
||||
- ''
|
||||
- 'You have spent a total of &6{total}&7 skill points.'
|
||||
- 'You have spent a total of &6{total}&7 attribute points.'
|
||||
- '&7Right click to reallocate them.'
|
||||
- ''
|
||||
- '&eCosts 1 attribute reallocation point.'
|
||||
@ -22,7 +23,6 @@ items:
|
||||
str:
|
||||
slots: [11]
|
||||
function: attribute_strength
|
||||
shift-cost: 10
|
||||
name: '&a{name}'
|
||||
item: GOLDEN_APPLE
|
||||
lore: # {buffs} returns amount of buffs
|
||||
@ -32,16 +32,13 @@ items:
|
||||
- ''
|
||||
- '&8When Leveled Up:'
|
||||
- '&7 +{buff_weapon_damage}% Weapon Damage (&a+{total_weapon_damage}%&7)'
|
||||
- '&7 +{buff_max_health}% Max Health (&a+{total_max_health}%&7)'
|
||||
- '&7 +{buff_max_health} Max Health (&a+{total_max_health}&7)'
|
||||
- ''
|
||||
- '&eClick to level up for 1 attribute point.'
|
||||
- '&eShift-Click to level up for {shift_points} attribute points.'
|
||||
- ''
|
||||
- '&e◆ Current Attribute Points: {attribute_points}'
|
||||
dex:
|
||||
slots: [13]
|
||||
function: attribute_dexterity
|
||||
shift-cost: 10
|
||||
name: '&a{name}'
|
||||
item: LEATHER_BOOTS
|
||||
hide-flags: true
|
||||
@ -53,16 +50,13 @@ items:
|
||||
- '&8When Leveled Up:'
|
||||
- '&7 +{buff_physical_damage}% Physical Damage (&a+{total_physical_damage}%&7)'
|
||||
- '&7 +{buff_projectile_damage}% Projectile Damage (&a+{total_projectile_damage}%&7)'
|
||||
- '&7 +{buff_attack_speed}% Attack Speed (&a+{total_attack_speed}&7)'
|
||||
- '&7 +{buff_attack_speed} Attack Speed (&a+{total_attack_speed}&7)'
|
||||
- ''
|
||||
- '&eClick to level up for 1 attribute point.'
|
||||
- '&eShift-Click to level up for {shift_points} attribute points.'
|
||||
- ''
|
||||
- '&e◆ Current Attribute Points: {attribute_points}'
|
||||
int:
|
||||
slots: [15]
|
||||
function: attribute_intelligence
|
||||
shift-cost: 10
|
||||
name: '&a{name}'
|
||||
item: BOOK
|
||||
lore:
|
||||
@ -75,6 +69,4 @@ items:
|
||||
- '&7 +{buff_cooldown_reduction}% Cooldown Reduction (&a+{total_cooldown_reduction}%&7)'
|
||||
- ''
|
||||
- '&eClick to level up for 1 attribute point.'
|
||||
- '&eShift-Click to level up for {shift_points} attribute points.'
|
||||
- ''
|
||||
- '&e◆ Current Attribute Points: {attribute_points}'
|
||||
|
@ -33,6 +33,18 @@ items:
|
||||
name: '&aPrevious'
|
||||
lore: { }
|
||||
|
||||
reallocate:
|
||||
slots: [26]
|
||||
function: reallocation
|
||||
item: CAULDRON
|
||||
name: '&aReallocate Skill Points'
|
||||
lore:
|
||||
- ''
|
||||
- 'You have spent a total of &6{total}&7 skill points.'
|
||||
- '&7Right click to reallocate them.'
|
||||
- ''
|
||||
- '&eCosts 1 skill reallocation point.'
|
||||
- '&e◆ Skill Reallocation Points: &6{points}'
|
||||
|
||||
#switch:
|
||||
#
|
||||
@ -87,11 +99,9 @@ items:
|
||||
upgrade:
|
||||
slots: [ 15 ]
|
||||
function: upgrade
|
||||
shift-cost: 10
|
||||
item: GREEN_STAINED_GLASS_PANE
|
||||
name: '&a&lUPGRADE {skill_caps}'
|
||||
lore:
|
||||
- '&7Costs 1 skill point.'
|
||||
- '&7Shift-Click to spend {shift_points} points'
|
||||
- ''
|
||||
- '&eCurrent Skill Points: {skill_points}'
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
# Level & Experience
|
||||
level-up:
|
||||
- ''
|
||||
@ -173,3 +172,6 @@ no-skill-bound: '&cYou don''t have any skill bound to this slot.'
|
||||
not-active-skill: '&cThis is not an active skill.'
|
||||
skill-max-level-hit: '&cYou already hit the max level for that skill.'
|
||||
no-skill-placeholder: 'No Skill Bound'
|
||||
not-skill-reallocation-point: '&cYou do not have 1 skill reallocation point.'
|
||||
no-skill-points-spent: '&cYou have not spent any skill points.'
|
||||
skill-points-reallocated: '&eYou successfully reset your attributes. You now have &6{points} &eskill points.'
|
||||
|
@ -19,7 +19,7 @@ select-class: UI_TOAST_CHALLENGE_COMPLETE
|
||||
|
||||
level-attribute: ENTITY_PLAYER_LEVELUP
|
||||
reset-attributes: ENTITY_PLAYER_LEVELUP
|
||||
|
||||
reset-skills: ENTITY_PLAYER_LEVELUP
|
||||
not-enough-points: ENTITY_VILLAGER_NO
|
||||
|
||||
cancel-quest: ENTITY_VILLAGER_NO
|
||||
|
Loading…
Reference in New Issue
Block a user