Skip to content

Commit ea88c82

Browse files
author
Trav
authored
Merge pull request magemonkeystudio#220 from SparkGNRK/magemonkeystudio#176
[Enhancement] Attribute and Skill Tree Reset Points magemonkeystudio#176
2 parents ba30f83 + 1086a00 commit ea88c82

File tree

4 files changed

+23
-2
lines changed

4 files changed

+23
-2
lines changed

src/main/java/com/sucy/skill/data/Settings.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public class Settings {
8585
GUI_LIST = GUI_BASE + "title-messages",
8686
GUI_CUSTOMMODELDATA = GUI_BASE + "use-custommodeldata",
8787

88-
DEFAULT_YIELD = "default",
88+
DEFAULT_YIELD = "default",
8989
ACCOUNT_BASE = "Accounts.",
9090
ACCOUNT_MAIN = ACCOUNT_BASE + "main-class-group",
9191
ACCOUNT_EACH = ACCOUNT_BASE + "one-per-class",
@@ -109,6 +109,7 @@ public class Settings {
109109
CLASS_SHOW = CLASS_BASE + "show-auto-skills",
110110
CLASS_ATTRIB = CLASS_BASE + "attributes-enabled",
111111
CLASS_REFUND = CLASS_BASE + "attributes-downgrade",
112+
CLASS_REFUND_PRICE = CLASS_BASE + "attributes-downgrade-price",
112113
CLASS_LEVEL = CLASS_BASE + "level-up-skill",
113114
MANA_BASE = "Mana.",
114115
MANA_ENABLED = MANA_BASE + "enabled",
@@ -247,6 +248,7 @@ public class Settings {
247248
* @return true if can refund, false otherwise
248249
*/
249250
@Getter private boolean attributesDowngrade;
251+
@Getter private int attributesDowngradePrice;
250252
private String levelUpSkill;
251253
/**
252254
* Checks whether or not mana is enabled
@@ -950,6 +952,7 @@ private void loadClassSettings() {
950952
showAutoSkills = config.getBoolean(CLASS_SHOW);
951953
attributesEnabled = config.getBoolean(CLASS_ATTRIB);
952954
attributesDowngrade = config.getBoolean(CLASS_REFUND);
955+
attributesDowngradePrice = config.getInt(CLASS_REFUND_PRICE);
953956
levelUpSkill = config.getString(CLASS_LEVEL);
954957
}
955958

src/main/java/com/sucy/skill/gui/handlers/AttributeHandler.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,16 @@
2828

2929
import com.sucy.skill.SkillAPI;
3030
import com.sucy.skill.gui.tool.GUIHolder;
31+
import com.sucy.skill.hook.VaultHook;
3132
import com.sucy.skill.manager.AttributeManager;
3233

3334
import java.util.HashMap;
3435

3536
public class AttributeHandler extends GUIHolder<AttributeManager.Attribute> {
3637
private HashMap<String, Integer> start = new HashMap<String, Integer>();
3738

39+
private static final String NOMONEY = "attribute-no-money";
40+
3841
@Override
3942
protected void onSetup() {
4043
AttributeManager manager = SkillAPI.getAttributeManager();
@@ -46,6 +49,18 @@ public void onClick(AttributeManager.Attribute type, int slot, boolean left, boo
4649
if (left) {
4750
if (player.upAttribute(type.getKey())) { setPage(page); }
4851
} else if (SkillAPI.getSettings().isAttributesDowngrade() || player.getAttribute(type.getKey()) > start.get(type.getKey())) {
52+
53+
if (SkillAPI.getSettings().getAttributesDowngradePrice() > 0 && VaultHook.isValid() && VaultHook.has(player.getPlayer(), String.valueOf(SkillAPI.getSettings().getAttributesDowngradePrice()))) {
54+
VaultHook.remove(player.getPlayer(), String.valueOf(SkillAPI.getSettings().getAttributesDowngradePrice()));
55+
if (player.refundAttribute(type.getKey())) {
56+
setPage(page);
57+
}
58+
return;
59+
} else if (!VaultHook.has(player.getPlayer(), String.valueOf(SkillAPI.getSettings().getAttributesDowngradePrice()))) {
60+
SkillAPI.getLanguage().sendMessage(NOMONEY, player.getPlayer());
61+
return;
62+
}
63+
4964
if (player.refundAttribute(type.getKey())) {
5065
setPage(page);
5166
}

src/main/resources/config.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,9 @@ Classes:
112112
# Whether attributes can be refunded
113113
attributes-downgrade: false
114114
#
115+
# Price player need to pay to downgrade their attributes, set to 0 to disable (need Vault)
116+
attributes-downgrade-price: 0
117+
#
115118
# This casts the dynamic skill for the player when they level up,
116119
# allowing you to use dynamic mechanics for level up effects. If
117120
# there is no existing dynamic skill with the name, no effect

src/main/resources/language.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Errors:
1818
no-mana: '&4You need &6{missing} &4more mana'
1919
no-skills: '&4That class does not have any skills'
2020
cannot-use: '&4You cannot equip that item'
21+
attribute-no-money: 'You don''t have enough money to refund this attribute.'
2122
GUI:
2223
attribute-title: 'Attributes ({points} points)'
2324
profess-title: 'Profess'
@@ -67,4 +68,3 @@ Combo:
6768
right_shift: '&6Shift R'
6869
space: '&6Jump'
6970
q: '&6Drop'
70-

0 commit comments

Comments
 (0)