Hardcore mode can now be toggled for each skill individually

This commit is contained in:
TfT_02 2013-08-21 16:46:38 +02:00
parent ede0757d83
commit a6e7febf77
11 changed files with 235 additions and 52 deletions

View File

@ -26,6 +26,7 @@ Version 1.4.07-dev
= Fixed a bug where the Dodge DamageModifier wasn't being read from advanced.yml
! Changed the way Repair hands out XP, also added config options to control Repair XP
! Changed Swords "Counter Attack" ability from passive to active. Blocking is required to activate.
! Hardcore mode can now be toggled for each skill individually
! Admin and Party chat prefixes are now customizable
! Changed the color of party leader names in Party chat
! Moved all experience formula related settings from config.yml to experienceFormula.yml (This includes skill modifiers and curve modifiers)

View File

@ -2,22 +2,12 @@ package com.gmail.nossr50.commands.hardcore;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.HardcoreManager;
import com.gmail.nossr50.util.Permissions;
public class HardcoreCommand extends HardcoreModeCommand {
@Override
protected void disable() {
Config.getInstance().setHardcoreEnabled(false);
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Hardcore.Disabled"));
}
@Override
protected void enable() {
Config.getInstance().setHardcoreEnabled(true);
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Hardcore.Enabled"));
}
@Override
protected boolean checkTogglePermissions() {
return Permissions.hardcoreToggle(sender);
@ -29,8 +19,41 @@ public class HardcoreCommand extends HardcoreModeCommand {
}
@Override
protected boolean checkEnabled() {
return Config.getInstance().getHardcoreEnabled();
protected boolean checkEnabled(String skill) {
if (skill.equalsIgnoreCase("ALL")) {
return !HardcoreManager.getHardcoreStatLossDisabled();
}
else {
return SkillType.getSkill(skill).getHardcoreStatLossEnabled();
}
}
@Override
protected void enable(String skill) {
if (skill.equalsIgnoreCase("ALL")) {
for (SkillType skillType : SkillType.nonChildSkills()) {
Config.getInstance().setHardcoreStatLossEnabled(skillType, true);
}
}
else {
Config.getInstance().setHardcoreStatLossEnabled(SkillType.getSkill(skill), true);
}
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Hardcore.Enabled", skill));
}
@Override
protected void disable(String skill) {
if (skill.equalsIgnoreCase("ALL")) {
for (SkillType skillType : SkillType.nonChildSkills()) {
Config.getInstance().setHardcoreStatLossEnabled(skillType, false);
}
}
else {
Config.getInstance().setHardcoreStatLossEnabled(SkillType.getSkill(skill), false);
}
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Hardcore.Disabled", skill));
}
@Override

View File

@ -9,6 +9,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.util.StringUtil;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.commands.CommandUtils;
@ -19,6 +20,7 @@ public abstract class HardcoreModeCommand implements TabExecutor {
protected CommandSender sender;
protected double newPercent;
protected DecimalFormat percent;
protected String skill;
public HardcoreModeCommand() {
percent = new DecimalFormat("##0.00%");
@ -35,11 +37,11 @@ public abstract class HardcoreModeCommand implements TabExecutor {
return true;
}
if (checkEnabled()) {
disable();
if (checkEnabled("ALL")) {
disable("ALL");
}
else {
enable();
enable("ALL");
}
return true;
@ -51,7 +53,7 @@ public abstract class HardcoreModeCommand implements TabExecutor {
return true;
}
enable();
enable("ALL");
return true;
}
@ -61,7 +63,7 @@ public abstract class HardcoreModeCommand implements TabExecutor {
return true;
}
disable();
disable("ALL");
return true;
}
@ -77,6 +79,36 @@ public abstract class HardcoreModeCommand implements TabExecutor {
modify();
return true;
case 2:
if (!args[0].equalsIgnoreCase("ALL") && CommandUtils.isChildSkill(sender, SkillType.getSkill(args[0]))) {
return true;
}
skill = args[0];
if (CommandUtils.shouldEnableToggle(args[1])) {
if (!Permissions.hardcoreToggle(sender)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
enable(skill);
return true;
}
if (CommandUtils.shouldDisableToggle(args[1])) {
if (!Permissions.hardcoreToggle(sender)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
disable(skill);
return true;
}
return true;
default:
return false;
}
@ -98,9 +130,9 @@ public abstract class HardcoreModeCommand implements TabExecutor {
protected abstract boolean checkTogglePermissions();
protected abstract boolean checkModifyPermissions();
protected abstract boolean checkEnabled();
protected abstract void enable();
protected abstract void disable();
protected abstract boolean checkEnabled(String skill);
protected abstract void enable(String skill);
protected abstract void disable(String skill);
protected abstract void modify();
private boolean isInvalidPercentage(CommandSender sender, String value) {

View File

@ -2,7 +2,9 @@ package com.gmail.nossr50.commands.hardcore;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.HardcoreManager;
import com.gmail.nossr50.util.Permissions;
public class VampirismCommand extends HardcoreModeCommand {
@ -17,20 +19,41 @@ public class VampirismCommand extends HardcoreModeCommand {
}
@Override
protected boolean checkEnabled() {
return Config.getInstance().getHardcoreVampirismEnabled();
protected boolean checkEnabled(String skill) {
if (skill.equalsIgnoreCase("ALL")) {
return !HardcoreManager.getHardcoreVampirismDisabled();
}
else {
return SkillType.getSkill(skill).getHardcoreVampirismEnabled();
}
}
@Override
protected void enable() {
Config.getInstance().setHardcoreVampirismEnabled(true);
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Vampirism.Enabled"));
protected void enable(String skill) {
if (skill.equalsIgnoreCase("ALL")) {
for (SkillType skillType : SkillType.nonChildSkills()) {
Config.getInstance().setHardcoreVampirismEnabled(skillType, true);
}
}
else {
Config.getInstance().setHardcoreVampirismEnabled(SkillType.getSkill(skill), true);
}
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Vampirism.Enabled", skill));
}
@Override
protected void disable() {
Config.getInstance().setHardcoreVampirismEnabled(false);
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Vampirism.Disabled"));
protected void disable(String skill) {
if (skill.equalsIgnoreCase("ALL")) {
for (SkillType skillType : SkillType.nonChildSkills()) {
Config.getInstance().setHardcoreVampirismEnabled(skillType, false);
}
}
else {
Config.getInstance().setHardcoreVampirismEnabled(SkillType.getSkill(skill), false);
}
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Vampirism.Disabled", skill));
}
@Override

View File

@ -77,11 +77,11 @@ public class Config extends AutoUpdateConfigLoader {
/* Hardcore Mode */
if (getHardcoreDeathStatPenaltyPercentage() < 1 || getHardcoreDeathStatPenaltyPercentage() > 100) {
reason.add("Hardcore.Death_Stat_Loss_Penalty_Percentage only accepts values from 1 to 100!");
reason.add("Hardcore.Death_Stat_Loss.Penalty_Percentage only accepts values from 1 to 100!");
}
if (getHardcoreVampirismStatLeechPercentage() < 1 || getHardcoreVampirismStatLeechPercentage() > 100) {
reason.add("Hardcore.Death_Stat_Loss_Penalty_Percentage only accepts values from 1 to 100!");
reason.add("Hardcore.Vampirism.Leech_Percentage only accepts values from 1 to 100!");
}
/* Items */
@ -286,17 +286,17 @@ public class Config extends AutoUpdateConfigLoader {
}
/* Hardcore Mode */
public boolean getHardcoreEnabled() { return config.getBoolean("Hardcore.Enabled", false); }
public void setHardcoreEnabled(boolean enabled) { config.set("Hardcore.Enabled", enabled); }
public boolean getHardcoreStatLossEnabled(SkillType skillType) { return config.getBoolean("Hardcore.Death_Stat_Loss.Enabled." + StringUtils.getCapitalized(skillType.toString()), false); }
public void setHardcoreStatLossEnabled(SkillType skillType, boolean enabled) { config.set("Hardcore.Death_Stat_Loss.Enabled." + StringUtils.getCapitalized(skillType.toString()), enabled); }
public double getHardcoreDeathStatPenaltyPercentage() { return config.getDouble("Hardcore.Death_Stat_Loss_Penalty_Percentage", 75.0); }
public void setHardcoreDeathStatPenaltyPercentage(double value) { config.set("Hardcore.Death_Stat_Loss_Penalty_Percentage", value); }
public double getHardcoreDeathStatPenaltyPercentage() { return config.getDouble("Hardcore.Death_Stat_Loss.Penalty_Percentage", 75.0); }
public void setHardcoreDeathStatPenaltyPercentage(double value) { config.set("Hardcore.Death_Stat_Loss.Penalty_Percentage", value); }
public double getHardcoreVampirismStatLeechPercentage() { return config.getDouble("Hardcore.Vampirism_Stat_Leech_Percentage", 5.0); }
public void setHardcoreVampirismStatLeechPercentage(double value) { config.set("Hardcore.Vampirism_Stat_Leech_Percentage", value); }
public boolean getHardcoreVampirismEnabled(SkillType skillType) { return config.getBoolean("Hardcore.Vampirism.Enabled." + StringUtils.getCapitalized(skillType.toString()), false); }
public void setHardcoreVampirismEnabled(SkillType skillType, boolean enabled) { config.set("Hardcore.Vampirism.Enabled." + StringUtils.getCapitalized(skillType.toString()), enabled); }
public boolean getHardcoreVampirismEnabled() { return config.getBoolean("Hardcore.Vampirism", false); }
public void setHardcoreVampirismEnabled(boolean enabled) { config.set("Hardcore.Vampirism", enabled); }
public double getHardcoreVampirismStatLeechPercentage() { return config.getDouble("Hardcore.Vampirism.Leech_Percentage", 5.0); }
public void setHardcoreVampirismStatLeechPercentage(double value) { config.set("Hardcore.Vampirism.Leech_Percentage", value); }
/* SMP Mods */
public boolean getToolModsEnabled() { return config.getBoolean("Mods.Tool_Mods_Enabled", false); }

View File

@ -104,6 +104,14 @@ public enum SkillType {
return Config.getInstance().getDoubleDropsDisabled(this);
}
public boolean getHardcoreStatLossEnabled() {
return Config.getInstance().getHardcoreStatLossEnabled(this);
}
public boolean getHardcoreVampirismEnabled() {
return Config.getInstance().getHardcoreVampirismEnabled(this);
}
public ToolType getTool() {
return tool;
}

View File

@ -123,7 +123,7 @@ public class PlayerListener implements Listener {
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerDeathMonitor(PlayerDeathEvent event) {
if (!Config.getInstance().getHardcoreEnabled()) {
if (!HardcoreManager.getHardcoreStatLossEnabled()) {
return;
}
@ -135,7 +135,7 @@ public class PlayerListener implements Listener {
Player killer = killedPlayer.getKiller();
if (killer != null && Config.getInstance().getHardcoreVampirismEnabled()) {
if (killer != null && HardcoreManager.getHardcoreVampirismEnabled()) {
HardcoreManager.invokeVampirism(killer, killedPlayer);
}

View File

@ -88,4 +88,76 @@ public final class HardcoreManager {
victim.sendMessage(LocaleLoader.getString("Vampirism.Victim.Failure", killer.getName()));
}
}
/**
* Check if Hardcore Stat Loss is enabled for one or more skill types
*
* @return true if Stat Loss is enabled for one or more skill types
*/
public static boolean getHardcoreStatLossEnabled() {
boolean enabled = false;
for (SkillType skillType : SkillType.nonChildSkills()) {
if (skillType.getHardcoreStatLossEnabled()) {
enabled = true;
break;
}
}
return enabled;
}
/**
* Check if Hardcore Stat Loss is disabled for one or more skill types
*
* @return true if Stat Loss is disabled for one or more skill types
*/
public static boolean getHardcoreStatLossDisabled() {
boolean disabled = false;
for (SkillType skillType : SkillType.nonChildSkills()) {
if (!skillType.getHardcoreStatLossEnabled()) {
disabled = true;
break;
}
}
return disabled;
}
/**
* Check if Hardcore Vampirism is enabled for one or more skill types
*
* @return true if Vampirism is enabled for one or more skill types
*/
public static boolean getHardcoreVampirismEnabled() {
boolean enabled = false;
for (SkillType skillType : SkillType.nonChildSkills()) {
if (skillType.getHardcoreVampirismEnabled()) {
enabled = true;
break;
}
}
return enabled;
}
/**
* Check if Hardcore Vampirism is disabled for one or more skill types
*
* @return true if Vampirism is disabled for one or more skill types
*/
public static boolean getHardcoreVampirismDisabled() {
boolean disabled = false;
for (SkillType skillType : SkillType.nonChildSkills()) {
if (!skillType.getHardcoreVampirismEnabled()) {
disabled = true;
break;
}
}
return disabled;
}
}

View File

@ -43,8 +43,8 @@ public final class Motd {
* @param player Target player
*/
public static void displayHardcoreSettings(Player player) {
if (Config.getInstance().getHardcoreEnabled()) {
if (Config.getInstance().getHardcoreVampirismEnabled()) {
if (HardcoreManager.getHardcoreStatLossEnabled()) {
if (HardcoreManager.getHardcoreVampirismEnabled()) {
player.sendMessage(LocaleLoader.getString("MOTD.Hardcore.VampireOn"));
player.sendMessage(LocaleLoader.getString("MOTD.Hardcore.Stats", Config.getInstance().getHardcoreDeathStatPenaltyPercentage()));
player.sendMessage(LocaleLoader.getString("MOTD.Vampire.Stats", Config.getInstance().getHardcoreVampirismStatLeechPercentage()));

View File

@ -90,10 +90,34 @@ MySQL:
# Settings for Hardcore mode
###
Hardcore:
Enabled: false
Death_Stat_Loss_Penalty_Percentage: 75
Vampirism: false
Vampirism_Stat_Leech_Percentage: 5
Death_Stat_Loss:
Penalty_Percentage: 75
Enabled:
Acrobatics: false
Archery: false
Axes: false
Fishing: false
Herbalism: false
Mining: false
Repair: false
Swords: false
Taming: false
Unarmed: false
Woodcutting: false
Vampirism:
Leech_Percentage: 5
Enabled:
Acrobatics: false
Archery: false
Axes: false
Fishing: false
Herbalism: false
Mining: false
Repair: false
Swords: false
Taming: false
Unarmed: false
Woodcutting: false
#
# Settings for SMP Mods

View File

@ -693,11 +693,11 @@ Vampirism.Killer.Failure=[[GOLD]][mcMMO] [[YELLOW]]{0}[[GRAY]] was too unskilled
Vampirism.Killer.Success=[[GOLD]][mcMMO] [[DARK_AQUA]]You have stolen [[BLUE]]{0}[[DARK_AQUA]] levels from [[YELLOW]]{1}.
Vampirism.Victim.Failure=[[GOLD]][mcMMO] [[YELLOW]]{0}[[GRAY]] was unable to steal knowledge from you!
Vampirism.Victim.Success=[[GOLD]][mcMMO] [[YELLOW]]{0}[[DARK_RED]] has stolen [[BLUE]]{1}[[DARK_RED]] levels from you!
Hardcore.Disabled=[[GOLD]][mcMMO] Hardcore mode disabled.
Hardcore.Enabled=[[GOLD]][mcMMO] Hardcore mode enabled.
Hardcore.Disabled=[[GOLD]][mcMMO] Hardcore mode disabled. {0}
Hardcore.Enabled=[[GOLD]][mcMMO] Hardcore mode enabled. {0}
Hardcore.PercentageChanged=[[GOLD]][mcMMO] The stat loss percentage was changed to {0}.
Vampirism.Disabled=[[GOLD]][mcMMO] Vampirism mode disabled.
Vampirism.Enabled=[[GOLD]][mcMMO] Vampirism mode enabled.
Vampirism.Disabled=[[GOLD]][mcMMO] Vampirism mode disabled. {0}
Vampirism.Enabled=[[GOLD]][mcMMO] Vampirism mode enabled. {0}
Vampirism.PercentageChanged=[[GOLD]][mcMMO] The stat leech percentage was changed to {0}.
#SPOUT