mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-02 00:30:07 +01:00
New custom event McMMOPlayerLevelUpEvent
This commit is contained in:
parent
299f440f63
commit
23354ce049
@ -0,0 +1,55 @@
|
|||||||
|
package com.gmail.nossr50.events;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.datatypes.SkillType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a user levels up in a skill
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("serial")
|
||||||
|
public class McMMOPlayerLevelUpEvent extends Event {
|
||||||
|
private Player player;
|
||||||
|
private SkillType skill;
|
||||||
|
private int levelsGained;
|
||||||
|
|
||||||
|
public McMMOPlayerLevelUpEvent(Player player, SkillType skill) {
|
||||||
|
this.player = player;
|
||||||
|
this.skill = skill;
|
||||||
|
this.levelsGained = 1; // Always 1 for now as we call in the loop where the levelups are calculated, could change later!
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Player leveling up
|
||||||
|
*/
|
||||||
|
public Player getPlayer() {
|
||||||
|
return player;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return SkillType that is being leveled up
|
||||||
|
*/
|
||||||
|
public SkillType getSkill() {
|
||||||
|
return skill;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return The number of levels gained in this event
|
||||||
|
*/
|
||||||
|
public int getLevelsGained() {
|
||||||
|
return levelsGained;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Rest of file is required boilerplate for custom events **/
|
||||||
|
private static final HandlerList handers = new HandlerList();
|
||||||
|
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return handers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return handers;
|
||||||
|
}
|
||||||
|
}
|
@ -18,6 +18,7 @@ package com.gmail.nossr50.skills;
|
|||||||
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -35,6 +36,7 @@ import com.gmail.nossr50.spout.SpoutStuff;
|
|||||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||||
import com.gmail.nossr50.datatypes.PlayerStat;
|
import com.gmail.nossr50.datatypes.PlayerStat;
|
||||||
import com.gmail.nossr50.datatypes.SkillType;
|
import com.gmail.nossr50.datatypes.SkillType;
|
||||||
|
import com.gmail.nossr50.events.McMMOPlayerLevelUpEvent;
|
||||||
import com.gmail.nossr50.locale.mcLocale;
|
import com.gmail.nossr50.locale.mcLocale;
|
||||||
|
|
||||||
|
|
||||||
@ -326,6 +328,9 @@ public class Skills
|
|||||||
skillups++;
|
skillups++;
|
||||||
PP.removeXP(skillType, PP.getXpToLevel(skillType));
|
PP.removeXP(skillType, PP.getXpToLevel(skillType));
|
||||||
PP.skillUp(skillType, 1);
|
PP.skillUp(skillType, 1);
|
||||||
|
|
||||||
|
McMMOPlayerLevelUpEvent eventToFire = new McMMOPlayerLevelUpEvent(player, skillType);
|
||||||
|
Bukkit.getPluginManager().callEvent(eventToFire);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!LoadProperties.useMySQL)
|
if(!LoadProperties.useMySQL)
|
||||||
|
Loading…
Reference in New Issue
Block a user