|
@@ -7,66 +7,77 @@ import com.gmail.nossr50.config.Config;
|
|
import com.gmail.nossr50.datatypes.PlayerProfile;
|
|
import com.gmail.nossr50.datatypes.PlayerProfile;
|
|
import com.gmail.nossr50.datatypes.SkillType;
|
|
import com.gmail.nossr50.datatypes.SkillType;
|
|
|
|
|
|
-public class Hardcore {
|
|
|
|
- public static void invokeStatPenalty(Player player) {
|
|
|
|
- if(Config.getInstance().getHardcoreDeathStatPenaltyPercentage() <= 0)
|
|
|
|
- return;
|
|
|
|
|
|
+public abstract class Hardcore {
|
|
|
|
|
|
- PlayerProfile PP = Users.getProfile(player);
|
|
|
|
|
|
+ public static void invokeStatPenalty(Player player) {
|
|
|
|
+ double hardcorePenalty = Config.getInstance().getHardcoreDeathStatPenaltyPercentage();
|
|
|
|
|
|
- int totalCount = 0;
|
|
|
|
|
|
+ if (hardcorePenalty <= 0 || hardcorePenalty > 100) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
|
|
- for(SkillType st : SkillType.values()) {
|
|
|
|
|
|
+ PlayerProfile playerProfile = Users.getProfile(player);
|
|
|
|
+ int totalLost = 0;
|
|
|
|
|
|
- if(st.equals(SkillType.ALL))
|
|
|
|
|
|
+ for (SkillType skillType : SkillType.values()) {
|
|
|
|
+ if (skillType.equals(SkillType.ALL)) {
|
|
continue;
|
|
continue;
|
|
|
|
+ }
|
|
|
|
|
|
- int newValue = (int) (PP.getSkillLevel(st) - (PP.getSkillLevel(st) * (Config.getInstance().getHardcoreDeathStatPenaltyPercentage() * 0.01D)));
|
|
|
|
|
|
+ int playerSkillLevel = playerProfile.getSkillLevel(skillType);
|
|
|
|
|
|
- if(newValue < 0)
|
|
|
|
- newValue = 0;
|
|
|
|
|
|
+ //Should we really care about negative skill levels?
|
|
|
|
+ if (playerSkillLevel <= 0) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
|
|
- totalCount+=PP.getSkillLevel(st)-newValue;
|
|
|
|
|
|
+ int levelsLost = (int) (playerSkillLevel * (hardcorePenalty * 0.01D));
|
|
|
|
+ totalLost += levelsLost;
|
|
|
|
|
|
- PP.modifySkill(st, newValue);
|
|
|
|
|
|
+ playerProfile.modifySkill(skillType, playerSkillLevel - levelsLost);
|
|
}
|
|
}
|
|
|
|
|
|
- player.sendMessage(ChatColor.GOLD+"[mcMMO] "+ChatColor.DARK_RED+"You've lost "+ChatColor.BLUE+totalCount+ChatColor.DARK_RED+" from death.");
|
|
|
|
|
|
+ player.sendMessage(ChatColor.GOLD + "[mcMMO] " + ChatColor.DARK_RED + "You've lost " + ChatColor.BLUE + totalLost + ChatColor.DARK_RED + " from death.");
|
|
}
|
|
}
|
|
|
|
|
|
- public static void invokeVampirism(Player killer, Player defender) {
|
|
|
|
- if(Config.getInstance().getHardcoreVampirismStatLeechPercentage() <= 0)
|
|
|
|
- return;
|
|
|
|
|
|
+ public static void invokeVampirism(Player killer, Player victim) {
|
|
|
|
+ double vampirismLeech = Config.getInstance().getHardcoreVampirismStatLeechPercentage();
|
|
|
|
|
|
- PlayerProfile PPk = Users.getProfile(killer);
|
|
|
|
- PlayerProfile PPd = Users.getProfile(defender);
|
|
|
|
-
|
|
|
|
- int totalCount = 0;
|
|
|
|
|
|
+ if (vampirismLeech <= 0 || vampirismLeech > 100) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
|
|
- for(SkillType st : SkillType.values()) {
|
|
|
|
- if(st.equals(SkillType.ALL))
|
|
|
|
- continue;
|
|
|
|
|
|
+ PlayerProfile killerProfile = Users.getProfile(killer);
|
|
|
|
+ PlayerProfile victimProfile = Users.getProfile(victim);
|
|
|
|
+ int totalStolen = 0;
|
|
|
|
|
|
- if(PPd.getSkillLevel(st) <= 0 || PPd.getSkillLevel(st) < (PPk.getSkillLevel(st)/2))
|
|
|
|
|
|
+ for (SkillType skillType : SkillType.values()) {
|
|
|
|
+ if (skillType.equals(SkillType.ALL)) {
|
|
continue;
|
|
continue;
|
|
|
|
+ }
|
|
|
|
|
|
- int newValue = (int) (PPd.getSkillLevel(st) * (Config.getInstance().getHardcoreVampirismStatLeechPercentage() * 0.01D));
|
|
|
|
|
|
+ int killerSkillLevel = killerProfile.getSkillLevel(skillType);
|
|
|
|
+ int victimSkillLevel = victimProfile.getSkillLevel(skillType);
|
|
|
|
|
|
- if(newValue <= 0)
|
|
|
|
- newValue = 1;
|
|
|
|
|
|
+ //Should we really care about negative skill levels?
|
|
|
|
+ if (victimSkillLevel <= 0 || victimSkillLevel < killerSkillLevel / 2) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
|
|
- totalCount += newValue;
|
|
|
|
|
|
+ int levelsStolen = (int) (victimSkillLevel * (vampirismLeech * 0.01D));
|
|
|
|
+ totalStolen += levelsStolen;
|
|
|
|
|
|
- PPk.modifySkill(st, newValue+PPk.getSkillLevel(st));
|
|
|
|
- PPd.modifySkill(st, PPd.getSkillLevel(st)-newValue);
|
|
|
|
|
|
+ killerProfile.modifySkill(skillType, killerSkillLevel + levelsStolen);
|
|
|
|
+ victimProfile.modifySkill(skillType, victimSkillLevel - levelsStolen);
|
|
}
|
|
}
|
|
|
|
|
|
- if(totalCount >= 1) {
|
|
|
|
- killer.sendMessage(ChatColor.GOLD+"[mcMMO] "+ChatColor.DARK_AQUA+"You've stolen "+ChatColor.BLUE+totalCount+ChatColor.DARK_AQUA+" levels from that player.");
|
|
|
|
- defender.sendMessage(ChatColor.GOLD+"[mcMMO] "+ChatColor.YELLOW+killer.getName()+ChatColor.DARK_RED+" has stolen "+ChatColor.BLUE+totalCount+ChatColor.DARK_RED+" levels from you!");
|
|
|
|
- } else {
|
|
|
|
- killer.sendMessage(ChatColor.GOLD+"[mcMMO] "+ChatColor.GRAY+"That player was too unskilled to grant you any knowledge.");
|
|
|
|
- defender.sendMessage(ChatColor.GOLD+"[mcMMO] "+ChatColor.YELLOW+killer.getName()+ChatColor.GRAY+" was unable to steal knowledge from you!");
|
|
|
|
|
|
+ if (totalStolen > 0) {
|
|
|
|
+ killer.sendMessage(ChatColor.GOLD + "[mcMMO] " + ChatColor.DARK_AQUA + "You've stolen " + ChatColor.BLUE + totalStolen + ChatColor.DARK_AQUA + " levels from that player.");
|
|
|
|
+ victim.sendMessage(ChatColor.GOLD + "[mcMMO] " + ChatColor.YELLOW + killer.getName() + ChatColor.DARK_RED + " has stolen " + ChatColor.BLUE + totalStolen + ChatColor.DARK_RED + " levels from you!");
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ killer.sendMessage(ChatColor.GOLD + "[mcMMO] " + ChatColor.GRAY + "That player was too unskilled to grant you any knowledge.");
|
|
|
|
+ victim.sendMessage(ChatColor.GOLD + "[mcMMO] " + ChatColor.YELLOW + killer.getName() + ChatColor.GRAY + " was unable to steal knowledge from you!");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|