mirror of
https://gitlab.com/phoenix-dvpmt/mmocore.git
synced 2024-11-23 00:05:52 +01:00
Merge branch 'mr-origin-7'
This commit is contained in:
commit
b6f26a627f
@ -16,6 +16,8 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class AttributeView extends EditableInventory {
|
||||
public AttributeView() {
|
||||
super("attribute-view");
|
||||
@ -45,12 +47,20 @@ public class AttributeView extends EditableInventory {
|
||||
|
||||
public static class AttributeItem extends InventoryItem {
|
||||
private final PlayerAttribute attribute;
|
||||
private int shiftCost=1;
|
||||
|
||||
public AttributeItem(String function, ConfigurationSection config) {
|
||||
super(config);
|
||||
|
||||
attribute = MMOCore.plugin.attributeManager
|
||||
.get(function.substring("attribute_".length()).toLowerCase().replace(" ", "-").replace("_", "-"));
|
||||
if(config.contains("shift-cost")) {
|
||||
shiftCost = config.getInt("shift-cost");
|
||||
if (shiftCost < 1) {
|
||||
MMOCore.log(Level.WARNING, "Level up points cost must not be less than 1. Using default value: 1");
|
||||
shiftCost = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -64,6 +74,7 @@ public class AttributeView extends EditableInventory {
|
||||
holders.register("max", attribute.getMax());
|
||||
holders.register("current", total);
|
||||
holders.register("attribute_points", inv.getPlayerData().getAttributePoints());
|
||||
holders.register("shift_points", shiftCost);
|
||||
attribute.getBuffs().forEach(buff -> {
|
||||
StatInfo info = StatInfo.valueOf(buff.getStat());
|
||||
holders.register("buff_" + buff.getStat().toLowerCase(), info.format(buff.getValue()));
|
||||
@ -110,6 +121,7 @@ public class AttributeView extends EditableInventory {
|
||||
|
||||
if (item.getFunction().startsWith("attribute_")) {
|
||||
PlayerAttribute attribute = ((AttributeItem) item).attribute;
|
||||
int shiftCost = ((AttributeItem) item).shiftCost;
|
||||
|
||||
if (playerData.getAttributePoints() < 1) {
|
||||
MMOCore.plugin.configManager.getSimpleMessage("not-attribute-point").send(player);
|
||||
@ -123,9 +135,21 @@ public class AttributeView extends EditableInventory {
|
||||
MMOCore.plugin.soundManager.getSound(SoundEvent.NOT_ENOUGH_POINTS).playTo(getPlayer());
|
||||
return;
|
||||
}
|
||||
|
||||
ins.addBase(1);
|
||||
playerData.giveAttributePoints(-1);
|
||||
|
||||
if (event.isShiftClick()) {
|
||||
if (playerData.getAttributePoints() < shiftCost) {
|
||||
MMOCore.plugin.configManager.getSimpleMessage("not-attribute-point-shift", "shift_points", "" + shiftCost).send(player);
|
||||
MMOCore.plugin.soundManager.getSound(SoundEvent.NOT_ENOUGH_POINTS).playTo(getPlayer());
|
||||
return;
|
||||
}
|
||||
|
||||
ins.addBase(shiftCost);
|
||||
playerData.giveAttributePoints(-shiftCost);
|
||||
} else {
|
||||
ins.addBase(1);
|
||||
playerData.giveAttributePoints(-1);
|
||||
}
|
||||
|
||||
MMOCore.plugin.configManager.getSimpleMessage("attribute-level-up", "attribute", attribute.getName(), "level", "" + ins.getBase()).send(player);
|
||||
MMOCore.plugin.soundManager.getSound(SoundEvent.LEVEL_ATTRIBUTE).playTo(getPlayer());
|
||||
|
||||
|
@ -25,6 +25,7 @@ import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class SkillList extends EditableInventory {
|
||||
public SkillList() {
|
||||
@ -41,20 +42,7 @@ public class SkillList extends EditableInventory {
|
||||
return new LevelItem(config);
|
||||
|
||||
if (function.equals("upgrade"))
|
||||
return new InventoryItem<SkillViewerInventory>(config) {
|
||||
|
||||
@Override
|
||||
public Placeholders getPlaceholders(SkillViewerInventory inv, int n) {
|
||||
RegisteredSkill selected = inv.selected == null ? null : inv.selected.getSkill();
|
||||
Placeholders holders = new Placeholders();
|
||||
|
||||
holders.register("skill_caps", selected.getName().toUpperCase());
|
||||
holders.register("skill", selected.getName());
|
||||
holders.register("skill_points", "" + inv.getPlayerData().getSkillPoints());
|
||||
|
||||
return holders;
|
||||
}
|
||||
};
|
||||
return new UpgradeItem(config);
|
||||
|
||||
if (function.equals("slot"))
|
||||
return new InventoryItem<SkillViewerInventory>(config) {
|
||||
@ -235,7 +223,35 @@ public class SkillList extends EditableInventory {
|
||||
return new Placeholders();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class UpgradeItem extends InventoryItem<SkillViewerInventory> {
|
||||
private int shiftCost=1;
|
||||
|
||||
public UpgradeItem(ConfigurationSection config) {
|
||||
super(config);
|
||||
if(config.contains("shift-cost")) {
|
||||
this.shiftCost = config.getInt("shift-cost");
|
||||
if (shiftCost < 1) {
|
||||
MMOCore.log(Level.WARNING, "Upgrade shift-cost cannot be less than 1. Using default value: 1");
|
||||
shiftCost = 1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Placeholders getPlaceholders(SkillViewerInventory inv, int n) {
|
||||
RegisteredSkill selected = inv.selected == null ? null : inv.selected.getSkill();
|
||||
Placeholders holders = new Placeholders();
|
||||
|
||||
holders.register("skill_caps", selected.getName().toUpperCase());
|
||||
holders.register("skill", selected.getName());
|
||||
holders.register("skill_points", "" + inv.getPlayerData().getSkillPoints());
|
||||
holders.register("shift_points", shiftCost);
|
||||
return holders;
|
||||
}
|
||||
}
|
||||
|
||||
public class SkillViewerInventory extends GeneratedInventory {
|
||||
|
||||
// Cached information
|
||||
@ -348,6 +364,8 @@ public class SkillList extends EditableInventory {
|
||||
* upgrading a player skill
|
||||
*/
|
||||
if (item.getFunction().equals("upgrade")) {
|
||||
int shiftCost = ((UpgradeItem) item).shiftCost;
|
||||
|
||||
if (!playerData.hasSkillUnlocked(selected)) {
|
||||
MMOCore.plugin.configManager.getSimpleMessage("not-unlocked-skill").send(player);
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 2);
|
||||
@ -365,9 +383,21 @@ public class SkillList extends EditableInventory {
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 2);
|
||||
return;
|
||||
}
|
||||
|
||||
playerData.giveSkillPoints(-1);
|
||||
playerData.setSkillLevel(selected.getSkill(), playerData.getSkillLevel(selected.getSkill()) + 1);
|
||||
|
||||
if (event.isShiftClick()) {
|
||||
if (playerData.getSkillPoints() < shiftCost) {
|
||||
MMOCore.plugin.configManager.getSimpleMessage("not-enough-skill-points-shift", "shift_points", "" + shiftCost).send(player);
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 2);
|
||||
return;
|
||||
}
|
||||
|
||||
playerData.giveSkillPoints(-shiftCost);
|
||||
playerData.setSkillLevel(selected.getSkill(), playerData.getSkillLevel(selected.getSkill()) + shiftCost);
|
||||
} else {
|
||||
playerData.giveSkillPoints(-1);
|
||||
playerData.setSkillLevel(selected.getSkill(), playerData.getSkillLevel(selected.getSkill()) + 1);
|
||||
}
|
||||
|
||||
MMOCore.plugin.configManager.getSimpleMessage("upgrade-skill", "skill", selected.getSkill().getName(), "level",
|
||||
"" + playerData.getSkillLevel(selected.getSkill())).send(player);
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1, 2);
|
||||
|
@ -22,6 +22,7 @@ items:
|
||||
str:
|
||||
slots: [11]
|
||||
function: attribute_strength
|
||||
shift-cost: 10
|
||||
name: '&a{name}'
|
||||
item: GOLDEN_APPLE
|
||||
lore: # {buffs} returns amount of buffs
|
||||
@ -34,10 +35,13 @@ items:
|
||||
- '&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
|
||||
@ -52,10 +56,13 @@ items:
|
||||
- '&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:
|
||||
@ -68,4 +75,6 @@ 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}'
|
||||
|
@ -87,9 +87,11 @@ 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}'
|
||||
|
@ -157,6 +157,7 @@ cant-choose-new-class:
|
||||
no-attribute-points-spent: '&cYou have not spent any attribute points.'
|
||||
not-attribute-reallocation-point: '&cYou do not have 1 reallocation point.'
|
||||
not-attribute-point: '&cYou do not have 1 attribute point.'
|
||||
not-attribute-point-shift: '&cYou do not have &4{shift_points} &cattribute points.'
|
||||
attribute-points-reallocated: '&eYou successfully reset your attributes. You now have &6{points} &eattribute points.'
|
||||
attribute-max-points-hit: '&cYou cannot level up this attribute anymore.'
|
||||
attribute-level-up: '&eYou successfully leveled up your &6{attribute}&e.' # {level}
|
||||
@ -164,6 +165,7 @@ attribute-level-up: '&eYou successfully leveled up your &6{attribute}&e.' # {lev
|
||||
# Skills
|
||||
no-class-skill: '&cYour class has no skill.'
|
||||
not-enough-skill-points: '&cYou need one skill point.'
|
||||
not-enough-skill-points-shift: '&cYou need {shift_points} skill points.'
|
||||
upgrade-skill: '&eYour &6{skill} &eis now Level &6{level}&e!'
|
||||
not-unlocked-skill: '&cYou have not unlocked that skill yet.'
|
||||
no-skill-bound: '&cYou don''t have any skill bound to this slot.'
|
||||
|
Loading…
Reference in New Issue
Block a user