mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-06-28 03:34:43 +02:00
Added '/hardcore' and '/vampirism' commands for toggling these modes on
or off, along with the necessary permissions nodes.
This commit is contained in:
@ -8,14 +8,11 @@ import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
|
||||
public final 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();
|
||||
|
||||
private Hardcore() {}
|
||||
|
||||
public static void invokeStatPenalty(Player player) {
|
||||
double statLossPercentage = Config.getInstance().getHardcoreDeathStatPenaltyPercentage();
|
||||
|
||||
if (statLossPercentage <= 0 || statLossPercentage > 100) {
|
||||
return;
|
||||
}
|
||||
@ -44,6 +41,8 @@ public final class Hardcore {
|
||||
}
|
||||
|
||||
public static void invokeVampirism(Player killer, Player victim) {
|
||||
double vampirismStatLeechPercentage = Config.getInstance().getHardcoreVampirismStatLeechPercentage();
|
||||
|
||||
if (vampirismStatLeechPercentage <= 0 || vampirismStatLeechPercentage > 100) {
|
||||
return;
|
||||
}
|
||||
|
@ -166,6 +166,21 @@ public final class Misc {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the long represented by this string.
|
||||
*
|
||||
* @param string The string to parse
|
||||
* @return the long represented by this string
|
||||
*/
|
||||
public static double getDouble(String string) {
|
||||
if (isDouble(string)) {
|
||||
return Double.parseDouble(string);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if an entity is currently invincible.
|
||||
*
|
||||
@ -300,6 +315,22 @@ public final class Misc {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if a string represents a Double
|
||||
*
|
||||
* @param string String to check
|
||||
* @return true if the string is a Double, false otherwise
|
||||
*/
|
||||
public static boolean isDouble(String string) {
|
||||
try {
|
||||
Double.parseDouble(string);
|
||||
return true;
|
||||
}
|
||||
catch (NumberFormatException nFE) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Drop items at a given location.
|
||||
*
|
||||
|
@ -4,6 +4,7 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.config.Config;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
||||
|
||||
@ -37,15 +38,15 @@ public final class Motd {
|
||||
* @param player Target player
|
||||
*/
|
||||
public static void displayHardcoreSettings(Player player) {
|
||||
if (Hardcore.statLossEnabled) {
|
||||
if (Hardcore.vampirismEnabled) {
|
||||
if (Config.getInstance().getHardcoreEnabled()) {
|
||||
if (Config.getInstance().getHardcoreVampirismEnabled()) {
|
||||
player.sendMessage(LocaleLoader.getString("MOTD.Hardcore.VampireOn"));
|
||||
player.sendMessage(LocaleLoader.getString("MOTD.Hardcore.Stats", Hardcore.statLossPercentage));
|
||||
player.sendMessage(LocaleLoader.getString("MOTD.Vampire.Stats", Hardcore.vampirismStatLeechPercentage));
|
||||
player.sendMessage(LocaleLoader.getString("MOTD.Hardcore.Stats", Config.getInstance().getHardcoreDeathStatPenaltyPercentage()));
|
||||
player.sendMessage(LocaleLoader.getString("MOTD.Vampire.Stats", Config.getInstance().getHardcoreVampirismStatLeechPercentage()));
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("MOTD.Hardcore.VampireOff"));
|
||||
player.sendMessage(LocaleLoader.getString("MOTD.Hardcore.Stats", Hardcore.statLossPercentage ));
|
||||
player.sendMessage(LocaleLoader.getString("MOTD.Hardcore.Stats", Config.getInstance().getHardcoreDeathStatPenaltyPercentage()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user