wire up creatures config

This commit is contained in:
nossr50 2019-03-19 09:23:53 -07:00
parent 7cd8099d3c
commit 956b01a28e
15 changed files with 74 additions and 53 deletions

View File

@ -46,6 +46,8 @@ Version 2.2.0
Language config options will now be found in "language.conf"
Creature config settings will now be found in "creatures.conf"
Particle settings will now be found in "particle_spawning.conf"
Party config options will now be found in "party.conf"
@ -125,9 +127,12 @@ Version 2.2.0
removed child.yml, child skills now have hard coded parents
removed the hardcore and vampirism commands, these are dangerous settings and should not be toggle-able (turn them on in your configs if you want to use them)
Removed the following config settings from various configs for literally doing nothing
Removed the following config settings from various configs for doing nothing
Update_Check, Prefer_Beta
Removed the following config settings for being unwanted
Config_Update_Overwrite
API Changes
Added API method to check if player parties are size capped
Added API method to grab the level cap of a skill by its PrimarySkillType ENUM definition

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.commands;
import com.gmail.nossr50.config.MainConfig;
import com.gmail.nossr50.database.FlatfileDatabaseManager;
import com.gmail.nossr50.database.SQLDatabaseManager;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
@ -21,7 +20,7 @@ public class MHDCommand implements TabExecutor {
SQLDatabaseManager m = (SQLDatabaseManager) mcMMO.getDatabaseManager();
m.resetMobHealthSettings();
for (McMMOPlayer player : UserManager.getPlayers()) {
player.getProfile().setMobHealthbarType(MainConfig.getInstance().getMobHealthbarDefault());
player.getProfile().setMobHealthbarType(mcMMO.getConfigManager().getConfigMobs().getCombat().getHealthBars().getDisplayBarType());
}
sender.sendMessage("Mob health reset");
return true;
@ -30,7 +29,7 @@ public class MHDCommand implements TabExecutor {
FlatfileDatabaseManager m = (FlatfileDatabaseManager) mcMMO.getDatabaseManager();
m.resetMobHealthSettings();
for (McMMOPlayer player : UserManager.getPlayers()) {
player.getProfile().setMobHealthbarType(MainConfig.getInstance().getMobHealthbarDefault());
player.getProfile().setMobHealthbarType(mcMMO.getConfigManager().getConfigMobs().getCombat().getHealthBars().getDisplayBarType());
}
sender.sendMessage("Mob health reset");
return true;

View File

@ -1,8 +1,6 @@
package com.gmail.nossr50.config;
import com.gmail.nossr50.datatypes.MobHealthbarType;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SuperAbilityType;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.StringUtils;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
@ -255,7 +253,7 @@ public class MainConfig extends ConfigValidated {
}*/
/* Mob Healthbar */
if (getMobHealthbarTime() == 0) {
if (mcMMO.getConfigManager().getConfigMobs().getCombat().getHealthBars().getDisplayTimeSeconds() == 0) {
reason.add(MOB_HEALTHBAR + "." + DISPLAY_TIME + " cannot be 0! Set to -1 to disable or set a valid value.");
}
@ -462,23 +460,6 @@ public class MainConfig extends ConfigValidated {
return getBooleanValue(GENERAL, REFRESH_CHUNKS);
}
public boolean getMobHealthbarEnabled() {
return getBooleanValue(MOB_HEALTHBAR, ENABLED);
}
/* Mob Healthbar */
public MobHealthbarType getMobHealthbarDefault() {
try {
return MobHealthbarType.valueOf(getStringValue(MOB_HEALTHBAR, DISPLAY_TYPE, HEARTS).toUpperCase().trim());
} catch (IllegalArgumentException ex) {
return MobHealthbarType.HEARTS;
}
}
public int getMobHealthbarTime() {
return getIntValue(MOB_HEALTHBAR, DISPLAY_TIME);
}
/* Hardcore Mode */
public boolean getHardcoreStatLossEnabled(PrimarySkillType primarySkillType) {
return getBooleanValue(HARDCORE, DEATH_STAT_LOSS, ENABLED, StringUtils.getCapitalized(primarySkillType.toString()));

View File

@ -1,6 +1,16 @@
package com.gmail.nossr50.config.hocon.mobs;
import ninja.leaping.configurate.objectmapping.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
@ConfigSerializable
public class ConfigSectionCombat {
@Setting(value = "Mob-Health-Bars", comment = "Health bars appear over a mobs world model when they are damaged by a player," +
"\nTypically this is a visually representation of their health using hearts.")
private ConfigSectionHealthBars healthBars = new ConfigSectionHealthBars();
public ConfigSectionHealthBars getHealthBars() {
return healthBars;
}
}

View File

@ -1,6 +1,39 @@
package com.gmail.nossr50.config.hocon.mobs;
import com.gmail.nossr50.datatypes.MobHealthbarType;
import ninja.leaping.configurate.objectmapping.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
@ConfigSerializable
public class ConfigSectionHealthBars {
public static final boolean MOB_HEALTH_BARS_DEFAULT = true;
public static final int DISPLAY_TIME_SECONDS_DEFAULT = 3;
public static final String HEARTS = "HEARTS";
public static final String displayTypesList = "\nYou can use the following MobHealthBarType values: HEARTS, BAR";
@Setting(value = "Enable-Health-Bars", comment = "Turn this off to disable health bars appearing above mobs when damaged." +
"\nDefault value: "+MOB_HEALTH_BARS_DEFAULT)
private boolean enableHealthBars = MOB_HEALTH_BARS_DEFAULT;
@Setting(value = "Display-Bar-Type", comment = "The type of display to use for the mobs health bar." +
displayTypesList +
"\nDefault value: "+HEARTS)
private MobHealthbarType displayBarType = MobHealthbarType.HEARTS;
@Setting(value = "Display-Time-In-Seconds", comment = "How many seconds mob health bars should be displayed before being hidden." +
"\nDefault value: "+DISPLAY_TIME_SECONDS_DEFAULT)
private int displayTimeSeconds = DISPLAY_TIME_SECONDS_DEFAULT;
public boolean isEnableHealthBars() {
return enableHealthBars;
}
public MobHealthbarType getDisplayBarType() {
return displayBarType;
}
public int getDisplayTimeSeconds() {
return displayTimeSeconds;
}
}

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.database;
import com.gmail.nossr50.config.MainConfig;
import com.gmail.nossr50.datatypes.MobHealthbarType;
import com.gmail.nossr50.datatypes.database.DatabaseType;
import com.gmail.nossr50.datatypes.database.PlayerStat;
@ -345,7 +344,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
writer.append((int) profile.getAbilityDATS(SuperAbilityType.BLAST_MINING)).append(":");
writer.append(System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR).append(":");
MobHealthbarType mobHealthbarType = profile.getMobHealthbarType();
writer.append(mobHealthbarType == null ? MainConfig.getInstance().getMobHealthbarDefault().toString() : mobHealthbarType.toString()).append(":");
writer.append(mobHealthbarType == null ? mcMMO.getConfigManager().getConfigMobs().getCombat().getHealthBars().getDisplayBarType().toString() : mobHealthbarType.toString()).append(":");
writer.append(profile.getSkillLevel(PrimarySkillType.ALCHEMY)).append(":");
writer.append(profile.getSkillXpLevel(PrimarySkillType.ALCHEMY)).append(":");
writer.append(uuid != null ? uuid.toString() : "NULL").append(":");
@ -424,7 +423,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
out.append("0:"); // FishingXp
out.append("0:"); // Blast Mining
out.append(String.valueOf(System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR)).append(":"); // LastLogin
out.append(MainConfig.getInstance().getMobHealthbarDefault().toString()).append(":"); // Mob Healthbar HUD
out.append(mcMMO.getConfigManager().getConfigMobs().getCombat().getHealthBars().getDisplayBarType().toString()).append(":"); // Mob Healthbar HUD
out.append(startingLevel); // Alchemy
out.append("0:"); // AlchemyXp
out.append(uuid != null ? uuid.toString() : "NULL").append(":"); // UUID
@ -964,7 +963,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
// Version 1.4.06
// commit da29185b7dc7e0d992754bba555576d48fa08aa6
character = Arrays.copyOf(character, character.length + 1);
character[character.length - 1] = MainConfig.getInstance().getMobHealthbarDefault().toString();
character[character.length - 1] = mcMMO.getConfigManager().getConfigMobs().getCombat().getHealthBars().getDisplayBarType().toString();
if (oldVersion == null) {
oldVersion = "1.4.06";
}
@ -1008,7 +1007,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
character[i] = String.valueOf(System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR);
}
else if (i == 38) {
character[i] = MainConfig.getInstance().getMobHealthbarDefault().toString();
character[i] = mcMMO.getConfigManager().getConfigMobs().getCombat().getHealthBars().getDisplayBarType().toString();
}
else {
character[i] = "0";
@ -1017,7 +1016,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
if (StringUtils.isInt(character[i]) && i == 38) {
corrupted = true;
character[i] = MainConfig.getInstance().getMobHealthbarDefault().toString();
character[i] = mcMMO.getConfigManager().getConfigMobs().getCombat().getHealthBars().getDisplayBarType().toString();
}
if (!StringUtils.isInt(character[i]) && !(i == 0 || i == 2 || i == 3 || i == 23 || i == 33 || i == 38 || i == 41)) {
@ -1173,7 +1172,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
mobHealthbarType = MobHealthbarType.valueOf(character[HEALTHBAR]);
}
catch (Exception e) {
mobHealthbarType = MainConfig.getInstance().getMobHealthbarDefault();
mobHealthbarType = mcMMO.getConfigManager().getConfigMobs().getCombat().getHealthBars().getDisplayBarType();
}
UUID uuid;
@ -1321,7 +1320,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
}
String[] character = line.split(":");
character[HEALTHBAR] = MainConfig.getInstance().getMobHealthbarDefault().toString();
character[HEALTHBAR] = mcMMO.getConfigManager().getConfigMobs().getCombat().getHealthBars().getDisplayBarType().toString();
line = new StringBuilder(org.apache.commons.lang.StringUtils.join(character, ":")).append(":").toString();

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.database;
import com.gmail.nossr50.config.MainConfig;
import com.gmail.nossr50.datatypes.MobHealthbarType;
import com.gmail.nossr50.datatypes.database.DatabaseType;
import com.gmail.nossr50.datatypes.database.PlayerStat;
@ -322,7 +321,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
}
statement = connection.prepareStatement("UPDATE " + tablePrefix + "huds SET mobhealthbar = ?, scoreboardtips = ? WHERE user_id = ?");
statement.setString(1, profile.getMobHealthbarType() == null ? MainConfig.getInstance().getMobHealthbarDefault().name() : profile.getMobHealthbarType().name());
statement.setString(1, profile.getMobHealthbarType() == null ? mcMMO.getConfigManager().getConfigMobs().getCombat().getHealthBars().getDisplayBarType().name() : profile.getMobHealthbarType().name());
statement.setInt(2, profile.getScoreboardTipsShown());
statement.setInt(3, id);
success = (statement.executeUpdate() != 0);
@ -817,7 +816,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
createStatement = connection.createStatement();
createStatement.executeUpdate("CREATE TABLE IF NOT EXISTS `" + tablePrefix + "huds` ("
+ "`user_id` int(10) unsigned NOT NULL,"
+ "`mobhealthbar` varchar(50) NOT NULL DEFAULT '" + MainConfig.getInstance().getMobHealthbarDefault() + "',"
+ "`mobhealthbar` varchar(50) NOT NULL DEFAULT '" + mcMMO.getConfigManager().getConfigMobs().getCombat().getHealthBars().getDisplayBarType() + "',"
+ "`scoreboardtips` int(10) NOT NULL DEFAULT '0',"
+ "PRIMARY KEY (`user_id`)) "
+ "DEFAULT CHARSET=latin1;");
@ -1063,7 +1062,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
statement = connection.prepareStatement("INSERT IGNORE INTO " + tablePrefix + "huds (user_id, mobhealthbar, scoreboardtips) VALUES (?, ?, ?)");
statement.setInt(1, id);
statement.setString(2, MainConfig.getInstance().getMobHealthbarDefault().name());
statement.setString(2, mcMMO.getConfigManager().getConfigMobs().getCombat().getHealthBars().getDisplayBarType().name());
statement.setInt(3, 0);
statement.execute();
statement.close();
@ -1138,7 +1137,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
mobHealthbarType = MobHealthbarType.valueOf(result.getString(OFFSET_OTHER + 1));
}
catch (Exception e) {
mobHealthbarType = MainConfig.getInstance().getMobHealthbarDefault();
mobHealthbarType = mcMMO.getConfigManager().getConfigMobs().getCombat().getHealthBars().getDisplayBarType();
}
try {
@ -1240,7 +1239,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
}
catch (SQLException ex) {
mcMMO.p.getLogger().info("Updating mcMMO MySQL tables for mob healthbars...");
statement.executeUpdate("ALTER TABLE `" + tablePrefix + "huds` ADD `mobhealthbar` varchar(50) NOT NULL DEFAULT '" + MainConfig.getInstance().getMobHealthbarDefault() + "'");
statement.executeUpdate("ALTER TABLE `" + tablePrefix + "huds` ADD `mobhealthbar` varchar(50) NOT NULL DEFAULT '" + mcMMO.getConfigManager().getConfigMobs().getCombat().getHealthBars().getDisplayBarType() + "'");
}
}
@ -1537,7 +1536,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
try {
connection = getConnection(PoolIdentifier.MISC);
statement = connection.prepareStatement("UPDATE " + tablePrefix + "huds SET mobhealthbar = ?");
statement.setString(1, MainConfig.getInstance().getMobHealthbarDefault().toString());
statement.setString(1, mcMMO.getConfigManager().getConfigMobs().getCombat().getHealthBars().getDisplayBarType().toString());
statement.executeUpdate();
}
catch (SQLException ex) {

View File

@ -2,6 +2,5 @@ package com.gmail.nossr50.datatypes;
public enum MobHealthbarType {
HEARTS,
BAR,
DISABLED;
BAR
}

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.datatypes.player;
import com.gmail.nossr50.config.MainConfig;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.datatypes.MobHealthbarType;
import com.gmail.nossr50.datatypes.experience.FormulaType;
@ -48,7 +47,7 @@ public class PlayerProfile {
this.uuid = uuid;
this.playerName = playerName;
mobHealthbarType = MainConfig.getInstance().getMobHealthbarDefault();
mobHealthbarType = mcMMO.getConfigManager().getConfigMobs().getCombat().getHealthBars().getDisplayBarType();
scoreboardTipsShown = 0;
for (SuperAbilityType superAbilityType : SuperAbilityType.values()) {

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.datatypes.skills;
import com.gmail.nossr50.config.MainConfig;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.BlockUtils;
import com.gmail.nossr50.util.Permissions;

View File

@ -1,13 +1,15 @@
package com.gmail.nossr50.runnables.backups;
import com.gmail.nossr50.config.MainConfig;
import com.gmail.nossr50.mcMMO;
import org.bukkit.scheduler.BukkitRunnable;
import java.io.File;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.concurrent.TimeUnit;
public class CleanBackupsTask extends BukkitRunnable {

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.runnables.skills;
import com.gmail.nossr50.config.MainConfig;
import com.gmail.nossr50.datatypes.interactions.NotificationType;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.ToolType;

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.skills.excavation;
import com.gmail.nossr50.config.MainConfig;
import com.gmail.nossr50.datatypes.experience.XPGainReason;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.util;
import com.gmail.nossr50.config.MainConfig;
import com.gmail.nossr50.datatypes.MobHealthbarType;
import com.gmail.nossr50.datatypes.meta.OldName;
import com.gmail.nossr50.mcMMO;
@ -35,7 +34,7 @@ public final class MobHealthbarUtils {
* @param damage damage done by the attack triggering this
*/
public static void handleMobHealthbars(LivingEntity target, double damage, mcMMO plugin) {
if (mcMMO.isHealthBarPluginEnabled() || !MainConfig.getInstance().getMobHealthbarEnabled()) {
if (mcMMO.isHealthBarPluginEnabled() || !mcMMO.getConfigManager().getConfigMobs().getCombat().getHealthBars().isEnableHealthBars()) {
return;
}
@ -57,12 +56,12 @@ public final class MobHealthbarUtils {
}
boolean oldNameVisible = target.isCustomNameVisible();
String newName = createHealthDisplay(MainConfig.getInstance().getMobHealthbarDefault(), target, damage);
String newName = createHealthDisplay(mcMMO.getConfigManager().getConfigMobs().getCombat().getHealthBars().getDisplayBarType(), target, damage);
target.setCustomName(newName);
target.setCustomNameVisible(true);
int displayTime = MainConfig.getInstance().getMobHealthbarTime();
int displayTime = Math.max(mcMMO.getConfigManager().getConfigMobs().getCombat().getHealthBars().getDisplayTimeSeconds(), 1);
if (displayTime != -1) {
boolean updateName = !ChatColor.stripColor(oldName).equalsIgnoreCase(ChatColor.stripColor(newName));

View File

@ -1,7 +1,6 @@
package com.gmail.nossr50.util.skills;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.MainConfig;
import com.gmail.nossr50.datatypes.experience.XPGainReason;
import com.gmail.nossr50.datatypes.experience.XPGainSource;
import com.gmail.nossr50.datatypes.interactions.NotificationType;