mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-25 22:56:45 +01:00
Added McMMOPlayerDeathPenaltyEvent
Called when a player dies and mcMMO tries to invoke Hardcore mode or Vampirism
This commit is contained in:
parent
9fb4e0988b
commit
1f53c62ced
@ -12,6 +12,7 @@ Version 1.4.07-dev
|
||||
+ Added new experience curve option. Cumulative curve, calculates experience needed for next level using power level.
|
||||
+ Added extra settings to config.yml for Call of the Wild (Taming)
|
||||
+ Added a 5 cooldown after teleporting before Acrobatics XP can be earned. + Config option to disable
|
||||
+ Added new McMMOPlayerDeathPenaltyEvent, fired when a player dies and would lose levels
|
||||
= Fixed bug with Skull Splitter not finding the locale string
|
||||
= Fixed issue where locale strings could cause the scoreboard header to be longer than 16 characters.
|
||||
= Fixed a bug with Beast Lore when the entity had no owner but was tamed.
|
||||
|
@ -0,0 +1,38 @@
|
||||
package com.gmail.nossr50.events.hardcore;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
|
||||
public class McMMOPlayerDeathPenaltyEvent extends PlayerEvent implements Cancellable {
|
||||
private boolean cancelled;
|
||||
|
||||
public McMMOPlayerDeathPenaltyEvent(Player player) {
|
||||
super(player);
|
||||
this.cancelled = false;
|
||||
}
|
||||
|
||||
/** Following are required for Cancellable **/
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancelled) {
|
||||
this.cancelled = cancelled;
|
||||
}
|
||||
|
||||
/** Rest of file is required boilerplate for custom events **/
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
@ -2,9 +2,11 @@ package com.gmail.nossr50.util;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.events.hardcore.McMMOPlayerDeathPenaltyEvent;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
|
||||
@ -18,6 +20,13 @@ public final class HardcoreManager {
|
||||
return;
|
||||
}
|
||||
|
||||
McMMOPlayerDeathPenaltyEvent eventToFire = new McMMOPlayerDeathPenaltyEvent(player);
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(eventToFire);
|
||||
|
||||
if (eventToFire.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
PlayerProfile playerProfile = UserManager.getPlayer(player).getProfile();
|
||||
int totalLost = 0;
|
||||
|
||||
@ -44,6 +53,13 @@ public final class HardcoreManager {
|
||||
return;
|
||||
}
|
||||
|
||||
McMMOPlayerDeathPenaltyEvent eventToFire = new McMMOPlayerDeathPenaltyEvent(victim);
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(eventToFire);
|
||||
|
||||
if (eventToFire.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
PlayerProfile killerProfile = UserManager.getPlayer(killer).getProfile();
|
||||
PlayerProfile victimProfile = UserManager.getPlayer(victim).getProfile();
|
||||
int totalStolen = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user