Merge remote-tracking branch 'origin/master'

This commit is contained in:
Ka0rX 2022-07-25 10:19:35 +02:00
commit b5825c370a
7 changed files with 52 additions and 29 deletions

View File

@ -804,12 +804,10 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
Validate.isTrue(isCasting(), "Player not in casting mode");
skillCasting.close();
this.skillCasting = null;
setLastActivity(PlayerActivity.ACTION_BAR_MESSAGE, 0); // Reset action bar
}
public void displayActionBar(String message) {
if (!isOnline())
return;
setLastActivity(PlayerActivity.ACTION_BAR_MESSAGE);
getPlayer().spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(message));
}

View File

@ -55,9 +55,7 @@ public class ExperienceItem {
Validate.isTrue(config.contains("triggers"));
id = config.getName();
final int periodOption = config.getInt("period", 1);
// A period of 0 means the item will only trigger once
period = periodOption == 0 ? Integer.MAX_VALUE : periodOption;
period = config.getInt("period", 1);
firstTrigger = config.getInt("first-trigger", period);
lastTrigger = config.getInt("last-trigger", Integer.MAX_VALUE);
claimChance = config.getDouble("chance", 100) / 100;
@ -79,10 +77,17 @@ public class ExperienceItem {
* account the randomness factor from the 'chance' parameter
*/
public boolean roll(int professionLevel, int timesCollected) {
// Check for the last triggering level
if (professionLevel > lastTrigger)
return false;
int claimsRequired = (professionLevel + 1 - (firstTrigger + timesCollected * period));
// A period of 0 means the item only triggers once
if (period == 0 && timesCollected > 0)
return false;
// Basic formula
final int claimsRequired = (professionLevel + 1 - (firstTrigger + timesCollected * period));
if (claimsRequired < 1)
return false;

View File

@ -16,8 +16,6 @@ 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");
@ -47,20 +45,14 @@ public class AttributeView extends EditableInventory {
public static class AttributeItem extends InventoryItem {
private final PlayerAttribute attribute;
private int shiftCost=1;
private final int shiftCost;
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;
}
}
shiftCost = Math.max(config.getInt("shift-cost"), 1);
}
@Override
@ -124,7 +116,6 @@ 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);
@ -140,18 +131,17 @@ public class AttributeView extends EditableInventory {
}
// 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 (playerData.getAttributePoints() < shiftCost) {
MMOCore.plugin.configManager.getSimpleMessage("not-attribute-point-shift", "shift_points", "" + shiftCost).send(player);
if (shiftClick && playerData.getAttributePoints() < pointsSpent) {
MMOCore.plugin.configManager.getSimpleMessage("not-attribute-point-shift", "shift_points", String.valueOf(pointsSpent)).send(player);
MMOCore.plugin.soundManager.getSound(SoundEvent.NOT_ENOUGH_POINTS).playTo(getPlayer());
return;
}
pointsSpent = shiftCost;
}
ins.addBase(pointsSpent);
playerData.giveAttributePoints(-pointsSpent);

View File

@ -0,0 +1,19 @@
package net.Indyuce.mmocore.guild;
public enum RelationType {
/**
* In the same guild
*/
ALLY,
/**
* One of the two players has no guild
*/
NEUTRAL,
/**
*
*/
ENEMY;
}

View File

@ -107,6 +107,9 @@ public class SkillScroller implements Listener {
CustomSkillCastingHandler casting = (CustomSkillCastingHandler) playerData.getSkillCasting();
casting.index = mod(casting.index + change, playerData.getBoundSkills().size());
casting.onTick();
if (changeSound != null)
changeSound.playTo(event.getPlayer());
}
private int mod(int x, int n) {

View File

@ -211,6 +211,14 @@ can-creative-cast: false
# This replaces anvil inputs by chat inputs.
use-chat-input: true
ability-targeting-options:
# Prevent heals/buffs on players in a different guild
cant-heal-enemies: true
# Prevent heals/buffs UNLESS the player is in your party/guild
cant-heal-neutrals: false
# Prevents mobs spawned from spawners from giving XP points.
prevent-spawner-xp: true

View File

@ -156,8 +156,8 @@ cant-choose-new-class:
# Attributes
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.'
not-attribute-point: '&cYou have no attribute point.'
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-max-points-hit: '&cYou cannot level up this attribute anymore.'
attribute-level-up: '&eYou successfully leveled up your &6{attribute}&e.' # {level}