mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-25 22:56:45 +01:00
Experience PreGain event
This commit is contained in:
parent
556515eefd
commit
67a4b6c7c1
@ -17,6 +17,7 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
|||||||
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
||||||
import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
|
import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
|
||||||
import com.gmail.nossr50.datatypes.skills.ToolType;
|
import com.gmail.nossr50.datatypes.skills.ToolType;
|
||||||
|
import com.gmail.nossr50.events.experience.McMMOPlayerPreXpGainEvent;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.party.PartyManager;
|
import com.gmail.nossr50.party.PartyManager;
|
||||||
@ -56,6 +57,8 @@ import com.gmail.nossr50.util.sounds.SoundManager;
|
|||||||
import com.gmail.nossr50.util.sounds.SoundType;
|
import com.gmail.nossr50.util.sounds.SoundType;
|
||||||
import net.kyori.adventure.identity.Identified;
|
import net.kyori.adventure.identity.Identified;
|
||||||
import net.kyori.adventure.identity.Identity;
|
import net.kyori.adventure.identity.Identity;
|
||||||
|
import org.apache.commons.lang.Validate;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
@ -601,6 +604,10 @@ public class McMMOPlayer implements Identified {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final McMMOPlayerPreXpGainEvent mcMMOPlayerPreXpGainEvent = new McMMOPlayerPreXpGainEvent(player, primarySkillType, xp, xpGainReason);
|
||||||
|
Bukkit.getPluginManager().callEvent(mcMMOPlayerPreXpGainEvent);
|
||||||
|
xp = mcMMOPlayerPreXpGainEvent.getXpGained();
|
||||||
|
|
||||||
if (primarySkillType.isChildSkill()) {
|
if (primarySkillType.isChildSkill()) {
|
||||||
Set<PrimarySkillType> parentSkills = FamilyTree.getParents(primarySkillType);
|
Set<PrimarySkillType> parentSkills = FamilyTree.getParents(primarySkillType);
|
||||||
|
|
||||||
|
@ -0,0 +1,50 @@
|
|||||||
|
package com.gmail.nossr50.events.experience;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.datatypes.experience.XPGainReason;
|
||||||
|
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a player gains XP in a skill
|
||||||
|
*/
|
||||||
|
public class McMMOPlayerPreXpGainEvent extends McMMOPlayerExperienceEvent {
|
||||||
|
private float xpGained;
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
public McMMOPlayerPreXpGainEvent(Player player, PrimarySkillType skill, float xpGained) {
|
||||||
|
super(player, skill, XPGainReason.UNKNOWN);
|
||||||
|
this.xpGained = xpGained;
|
||||||
|
}
|
||||||
|
|
||||||
|
public McMMOPlayerPreXpGainEvent(Player player, PrimarySkillType skill, float xpGained, XPGainReason xpGainReason) {
|
||||||
|
super(player, skill, xpGainReason);
|
||||||
|
this.xpGained = xpGained;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return int amount of experience gained in this event
|
||||||
|
*/
|
||||||
|
public int getXpGained() {
|
||||||
|
return (int) xpGained;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param xpGained int amount of experience gained in this event
|
||||||
|
*/
|
||||||
|
public void setXpGained(int xpGained) {
|
||||||
|
this.xpGained = xpGained;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull HandlerList getHandlers() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user