2012-04-30 15:41:58 +02:00
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 ) {
2012-05-22 08:30:16 +02:00
if ( Config . getInstance ( ) . getHardcoreDeathStatPenaltyPercentage ( ) < = 0 )
return ;
2012-04-30 15:41:58 +02:00
PlayerProfile PP = Users . getProfile ( player ) ;
2012-05-22 08:56:08 +02:00
int totalCount = 0 ;
2012-04-30 15:41:58 +02:00
for ( SkillType st : SkillType . values ( ) ) {
2012-05-22 08:30:16 +02:00
2012-04-30 15:41:58 +02:00
if ( st . equals ( SkillType . ALL ) )
continue ;
2012-05-22 08:30:16 +02:00
2012-04-30 16:05:11 +02:00
int newValue = ( int ) ( PP . getSkillLevel ( st ) - ( PP . getSkillLevel ( st ) * ( Config . getInstance ( ) . getHardcoreDeathStatPenaltyPercentage ( ) * 0 . 01D ) ) ) ;
2012-04-30 15:41:58 +02:00
if ( newValue < 0 )
newValue = 0 ;
2012-05-22 08:56:08 +02:00
totalCount + = PP . getSkillLevel ( st ) - newValue ;
2012-04-30 15:41:58 +02:00
PP . modifySkill ( st , newValue ) ;
}
2012-05-22 08:56:08 +02:00
player . sendMessage ( ChatColor . GOLD + " [mcMMO] " + ChatColor . DARK_RED + " You've lost " + ChatColor . BLUE + totalCount + ChatColor . DARK_RED + " from death. " ) ;
2012-04-30 15:41:58 +02:00
}
2012-05-01 17:47:57 +02:00
public static void invokeVampirism ( Player killer , Player defender ) {
2012-05-22 08:30:16 +02:00
if ( Config . getInstance ( ) . getHardcoreVampirismStatLeechPercentage ( ) < = 0 )
return ;
2012-05-01 17:47:57 +02:00
PlayerProfile PPk = Users . getProfile ( killer ) ;
PlayerProfile PPd = Users . getProfile ( defender ) ;
2012-05-22 08:56:08 +02:00
int totalCount = 0 ;
2012-05-01 17:47:57 +02:00
for ( SkillType st : SkillType . values ( ) ) {
if ( st . equals ( SkillType . ALL ) )
continue ;
2012-05-22 08:30:16 +02:00
2012-05-22 08:56:08 +02:00
if ( PPd . getSkillLevel ( st ) < = 0 | | PPd . getSkillLevel ( st ) < ( PPk . getSkillLevel ( st ) / 2 ) )
2012-05-22 08:30:16 +02:00
continue ;
2012-05-01 18:04:29 +02:00
int newValue = ( int ) ( PPd . getSkillLevel ( st ) * ( Config . getInstance ( ) . getHardcoreVampirismStatLeechPercentage ( ) * 0 . 01D ) ) ;
2012-05-22 08:30:16 +02:00
if ( newValue < = 0 )
newValue = 1 ;
2012-05-22 08:56:08 +02:00
totalCount + = 1 ;
2012-05-01 17:47:57 +02:00
PPk . modifySkill ( st , newValue + PPk . getSkillLevel ( st ) ) ;
2012-05-22 08:30:16 +02:00
PPd . modifySkill ( st , PPd . getSkillLevel ( st ) - newValue ) ;
2012-05-01 17:47:57 +02:00
}
2012-05-22 08:56:08 +02:00
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! " ) ;
}
2012-05-01 17:47:57 +02:00
}
2012-04-30 15:41:58 +02:00
}