Added basic hardcore mode functionality, needs testing.

This commit is contained in:
nossr50 2012-04-30 06:41:58 -07:00
parent ff1326a44f
commit d8c0a56577
2 changed files with 47 additions and 0 deletions

View File

@ -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);
}
}
}

View 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.");
}
}