mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-02 00:30:07 +01:00
A little more cleanup
This commit is contained in:
parent
f5179cdcea
commit
96d59a2e81
@ -6,8 +6,8 @@ import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.util.Hardcore;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
|
||||
public class HardcoreListener implements Listener {
|
||||
@ -19,13 +19,17 @@ public class HardcoreListener implements Listener {
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerDeath(PlayerDeathEvent event) {
|
||||
Player player = event.getEntity(); //Note this returns a Player object for this subevent
|
||||
Player player = event.getEntity();
|
||||
|
||||
if (player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||
if (Misc.isNPCPlayer(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Permissions.hardcoremodeBypass(player)) {
|
||||
if (player.getKiller() != null && Config.getInstance().getHardcoreVampirismEnabled()) {
|
||||
Hardcore.invokeVampirism(player.getKiller(), player);
|
||||
Player killer = player.getKiller();
|
||||
|
||||
if (killer != null && Hardcore.vampirismEnabled) {
|
||||
Hardcore.invokeVampirism(killer, player);
|
||||
}
|
||||
|
||||
Hardcore.invokeStatPenalty(player);
|
||||
|
@ -8,11 +8,14 @@ import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.SkillType;
|
||||
|
||||
public abstract class Hardcore {
|
||||
public static double statLossPercentage = Config.getInstance().getHardcoreDeathStatPenaltyPercentage();
|
||||
public static double vampirismStatLeechPercentage = Config.getInstance().getHardcoreVampirismStatLeechPercentage();
|
||||
|
||||
public static boolean statLossEnabled = Config.getInstance().getHardcoreEnabled();
|
||||
public static boolean vampirismEnabled = Config.getInstance().getHardcoreVampirismEnabled();
|
||||
|
||||
public static void invokeStatPenalty(Player player) {
|
||||
double hardcorePenalty = Config.getInstance().getHardcoreDeathStatPenaltyPercentage();
|
||||
|
||||
if (hardcorePenalty <= 0 || hardcorePenalty > 100) {
|
||||
if (statLossPercentage <= 0 || statLossPercentage > 100) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -31,7 +34,7 @@ public abstract class Hardcore {
|
||||
continue;
|
||||
}
|
||||
|
||||
int levelsLost = (int) (playerSkillLevel * (hardcorePenalty * 0.01D));
|
||||
int levelsLost = (int) (playerSkillLevel * (statLossPercentage * 0.01D));
|
||||
totalLost += levelsLost;
|
||||
|
||||
playerProfile.modifySkill(skillType, playerSkillLevel - levelsLost);
|
||||
@ -41,9 +44,7 @@ public abstract class Hardcore {
|
||||
}
|
||||
|
||||
public static void invokeVampirism(Player killer, Player victim) {
|
||||
double vampirismLeech = Config.getInstance().getHardcoreVampirismStatLeechPercentage();
|
||||
|
||||
if (vampirismLeech <= 0 || vampirismLeech > 100) {
|
||||
if (vampirismStatLeechPercentage <= 0 || vampirismStatLeechPercentage > 100) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -64,7 +65,7 @@ public abstract class Hardcore {
|
||||
continue;
|
||||
}
|
||||
|
||||
int levelsStolen = (int) (victimSkillLevel * (vampirismLeech * 0.01D));
|
||||
int levelsStolen = (int) (victimSkillLevel * (vampirismStatLeechPercentage * 0.01D));
|
||||
totalStolen += levelsStolen;
|
||||
|
||||
killerProfile.modifySkill(skillType, killerSkillLevel + levelsStolen);
|
||||
|
@ -2,7 +2,6 @@ package com.gmail.nossr50.util;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.SkillType;
|
||||
|
||||
@ -26,15 +25,15 @@ public class MOTD {
|
||||
* Display Hardcore Mode settings.
|
||||
*/
|
||||
public void displayHardcoreSettings() {
|
||||
if (Config.getInstance().getHardcoreEnabled()) {
|
||||
if (Config.getInstance().getHardcoreVampirismEnabled()) {
|
||||
if (Hardcore.statLossEnabled) {
|
||||
if (Hardcore.vampirismEnabled) {
|
||||
player.sendMessage(LocaleLoader.getString("MOTD.Hardcore.VampireOn"));
|
||||
player.sendMessage(LocaleLoader.getString("MOTD.Hardcore.Stats", new Object[] {Config.getInstance().getHardcoreDeathStatPenaltyPercentage()}));
|
||||
player.sendMessage(LocaleLoader.getString("MOTD.Vampire.Stats", new Object[] {Config.getInstance().getHardcoreVampirismStatLeechPercentage()}));
|
||||
player.sendMessage(LocaleLoader.getString("MOTD.Hardcore.Stats", new Object[] {Hardcore.statLossPercentage}));
|
||||
player.sendMessage(LocaleLoader.getString("MOTD.Vampire.Stats", new Object[] {Hardcore.vampirismStatLeechPercentage}));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("MOTD.Hardcore.VampireOff"));
|
||||
player.sendMessage(LocaleLoader.getString("MOTD.Hardcore.Stats", new Object[] {Config.getInstance().getHardcoreDeathStatPenaltyPercentage()}));
|
||||
player.sendMessage(LocaleLoader.getString("MOTD.Hardcore.Stats", new Object[] {Hardcore.statLossPercentage }));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user