mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-29 16:46:46 +01:00
Added basic hardcore mode functionality, needs testing.
This commit is contained in:
parent
ff1326a44f
commit
d8c0a56577
@ -0,0 +1,20 @@
|
|||||||
|
package com.gmail.nossr50.listeners;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.util.Hardcore;
|
||||||
|
import com.gmail.nossr50.util.Permissions;
|
||||||
|
|
||||||
|
public class HardcoreListener implements Listener {
|
||||||
|
|
||||||
|
@EventHandler()
|
||||||
|
public void PlayerDeathEvent(PlayerDeathEvent event) {
|
||||||
|
Player player = event.getEntity(); //Note this returns a Player object for this subevent
|
||||||
|
if(!Permissions.getInstance().hardcoremodeBypass(player)) {
|
||||||
|
Hardcore.invokeStatPenalty(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
27
src/main/java/com/gmail/nossr50/util/Hardcore.java
Normal file
27
src/main/java/com/gmail/nossr50/util/Hardcore.java
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
package com.gmail.nossr50.util;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.config.Config;
|
||||||
|
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||||
|
import com.gmail.nossr50.datatypes.SkillType;
|
||||||
|
|
||||||
|
public class Hardcore {
|
||||||
|
public static void invokeStatPenalty(Player player) {
|
||||||
|
PlayerProfile PP = Users.getProfile(player);
|
||||||
|
|
||||||
|
for(SkillType st : SkillType.values()) {
|
||||||
|
if(st.equals(SkillType.ALL))
|
||||||
|
continue;
|
||||||
|
int newValue = (int) (PP.getSkillLevel(st) / Config.getInstance().getHardcoreDeathStatPenaltyPercentage());
|
||||||
|
|
||||||
|
if(newValue < 0)
|
||||||
|
newValue = 0;
|
||||||
|
|
||||||
|
PP.modifySkill(st, newValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
player.sendMessage(ChatColor.GOLD+"[mcMMO] "+ChatColor.DARK_RED+"You've suffered a penalty to your knowledge from death.");
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user