mirror of
https://gitlab.com/phoenix-dvpmt/mmocore.git
synced 2025-02-02 11:21:22 +01:00
Fixed attributes points spending overflow
This commit is contained in:
parent
55d1a3cf13
commit
1ac652e459
@ -804,12 +804,10 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
|
|||||||
Validate.isTrue(isCasting(), "Player not in casting mode");
|
Validate.isTrue(isCasting(), "Player not in casting mode");
|
||||||
skillCasting.close();
|
skillCasting.close();
|
||||||
this.skillCasting = null;
|
this.skillCasting = null;
|
||||||
|
setLastActivity(PlayerActivity.ACTION_BAR_MESSAGE, 0); // Reset action bar
|
||||||
}
|
}
|
||||||
|
|
||||||
public void displayActionBar(String message) {
|
public void displayActionBar(String message) {
|
||||||
if (!isOnline())
|
|
||||||
return;
|
|
||||||
|
|
||||||
setLastActivity(PlayerActivity.ACTION_BAR_MESSAGE);
|
setLastActivity(PlayerActivity.ACTION_BAR_MESSAGE);
|
||||||
getPlayer().spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(message));
|
getPlayer().spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(message));
|
||||||
}
|
}
|
||||||
|
@ -16,8 +16,6 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
|
|
||||||
import java.util.logging.Level;
|
|
||||||
|
|
||||||
public class AttributeView extends EditableInventory {
|
public class AttributeView extends EditableInventory {
|
||||||
public AttributeView() {
|
public AttributeView() {
|
||||||
super("attribute-view");
|
super("attribute-view");
|
||||||
@ -47,20 +45,14 @@ public class AttributeView extends EditableInventory {
|
|||||||
|
|
||||||
public static class AttributeItem extends InventoryItem {
|
public static class AttributeItem extends InventoryItem {
|
||||||
private final PlayerAttribute attribute;
|
private final PlayerAttribute attribute;
|
||||||
private int shiftCost=1;
|
private final int shiftCost;
|
||||||
|
|
||||||
public AttributeItem(String function, ConfigurationSection config) {
|
public AttributeItem(String function, ConfigurationSection config) {
|
||||||
super(config);
|
super(config);
|
||||||
|
|
||||||
attribute = MMOCore.plugin.attributeManager
|
attribute = MMOCore.plugin.attributeManager
|
||||||
.get(function.substring("attribute_".length()).toLowerCase().replace(" ", "-").replace("_", "-"));
|
.get(function.substring("attribute_".length()).toLowerCase().replace(" ", "-").replace("_", "-"));
|
||||||
if(config.contains("shift-cost")) {
|
shiftCost = Math.max(config.getInt("shift-cost"), 1);
|
||||||
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
|
@Override
|
||||||
@ -124,7 +116,6 @@ public class AttributeView extends EditableInventory {
|
|||||||
|
|
||||||
if (item.getFunction().startsWith("attribute_")) {
|
if (item.getFunction().startsWith("attribute_")) {
|
||||||
PlayerAttribute attribute = ((AttributeItem) item).attribute;
|
PlayerAttribute attribute = ((AttributeItem) item).attribute;
|
||||||
int shiftCost = ((AttributeItem) item).shiftCost;
|
|
||||||
|
|
||||||
if (playerData.getAttributePoints() < 1) {
|
if (playerData.getAttributePoints() < 1) {
|
||||||
MMOCore.plugin.configManager.getSimpleMessage("not-attribute-point").send(player);
|
MMOCore.plugin.configManager.getSimpleMessage("not-attribute-point").send(player);
|
||||||
@ -140,16 +131,15 @@ public class AttributeView extends EditableInventory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Amount of points spent
|
// Amount of points spent
|
||||||
int pointsSpent = 1;
|
final boolean shiftClick = event.isShiftClick();
|
||||||
|
int pointsSpent = shiftClick ? ((AttributeItem) item).shiftCost : 1;
|
||||||
|
if (attribute.hasMax())
|
||||||
|
pointsSpent = Math.min(pointsSpent, attribute.getMax() - ins.getBase());
|
||||||
|
|
||||||
if (event.isShiftClick()) {
|
if (shiftClick && playerData.getAttributePoints() < pointsSpent) {
|
||||||
if (playerData.getAttributePoints() < shiftCost) {
|
MMOCore.plugin.configManager.getSimpleMessage("not-attribute-point-shift", "shift_points", String.valueOf(pointsSpent)).send(player);
|
||||||
MMOCore.plugin.configManager.getSimpleMessage("not-attribute-point-shift", "shift_points", "" + shiftCost).send(player);
|
MMOCore.plugin.soundManager.getSound(SoundEvent.NOT_ENOUGH_POINTS).playTo(getPlayer());
|
||||||
MMOCore.plugin.soundManager.getSound(SoundEvent.NOT_ENOUGH_POINTS).playTo(getPlayer());
|
return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
pointsSpent = shiftCost;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ins.addBase(pointsSpent);
|
ins.addBase(pointsSpent);
|
||||||
|
@ -156,8 +156,8 @@ cant-choose-new-class:
|
|||||||
# Attributes
|
# Attributes
|
||||||
no-attribute-points-spent: '&cYou have not spent any attribute points.'
|
no-attribute-points-spent: '&cYou have not spent any attribute points.'
|
||||||
not-attribute-reallocation-point: '&cYou do not have 1 reallocation point.'
|
not-attribute-reallocation-point: '&cYou do not have 1 reallocation point.'
|
||||||
not-attribute-point: '&cYou do not have 1 attribute point.'
|
not-attribute-point: '&cYou have no attribute point.'
|
||||||
not-attribute-point-shift: '&cYou do not have &4{shift_points} &cattribute points.'
|
not-attribute-point-shift: '&cYou must have &4{shift_points} &cattribute points.'
|
||||||
attribute-points-reallocated: '&eYou successfully reset your attributes. You now have &6{points} &eattribute 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-max-points-hit: '&cYou cannot level up this attribute anymore.'
|
||||||
attribute-level-up: '&eYou successfully leveled up your &6{attribute}&e.' # {level}
|
attribute-level-up: '&eYou successfully leveled up your &6{attribute}&e.' # {level}
|
||||||
|
Loading…
Reference in New Issue
Block a user