mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-02 00:30:07 +01:00
commit
5404371b35
@ -9,11 +9,14 @@ Key:
|
||||
|
||||
Version 1.3.13-dev
|
||||
+ Added Craftbukkit 1.4.6 compatibility
|
||||
+ Added a configurable durability cap for ArmorImpact to advanced.yml
|
||||
= Fixed issue with missing default cases from several switch/case statements
|
||||
= Fixed issue with Mining using actual skill level rather than max skill level
|
||||
= Fixed some issues with static access
|
||||
= Fixed ItemStack deprecation issues
|
||||
= Fixed Async deprecation issues
|
||||
= Fixed some issues with mySQL databases (non-alphanumeric characters preventing MySQL)
|
||||
= Fixed skill commands displaying .x% instead of 0.x%
|
||||
! GJ stopped being a lazy slacker and got stuff done
|
||||
- Removed dead code relating to null profiles
|
||||
- Removed unused imports
|
||||
|
@ -33,7 +33,7 @@ public class AcrobaticsCommand extends SkillCommand {
|
||||
|
||||
@Override
|
||||
protected void dataCalculations() {
|
||||
DecimalFormat df = new DecimalFormat("#.0");
|
||||
DecimalFormat df = new DecimalFormat("0.0");
|
||||
// DODGE
|
||||
if(skillValue >= dodgeMaxBonusLevel) dodgeChance = df.format(dodgeChanceMax);
|
||||
else dodgeChance = df.format(((double) dodgeChanceMax / (double) dodgeMaxBonusLevel) * skillValue);
|
||||
|
@ -37,7 +37,7 @@ public class ArcheryCommand extends SkillCommand {
|
||||
|
||||
@Override
|
||||
protected void dataCalculations() {
|
||||
DecimalFormat df = new DecimalFormat("#.0");
|
||||
DecimalFormat df = new DecimalFormat("0.0");
|
||||
// SkillShot
|
||||
double bonus = (int)((double) skillValue / (double) skillShotIncreaseLevel) * skillShotIncreasePercentage;
|
||||
if (bonus > skillShotBonusMax) skillShotBonus = percent.format(skillShotBonusMax);
|
||||
|
@ -39,7 +39,7 @@ public class AxesCommand extends SkillCommand {
|
||||
|
||||
@Override
|
||||
protected void dataCalculations() {
|
||||
DecimalFormat df = new DecimalFormat("#.0");
|
||||
DecimalFormat df = new DecimalFormat("0.0");
|
||||
int skillCheck = Misc.skillCheck((int)skillValue, critMaxBonusLevel);
|
||||
|
||||
impactDamage = String.valueOf(1 + ((double) skillValue / (double) greaterImpactIncreaseLevel));
|
||||
|
@ -42,18 +42,18 @@ public class HerbalismCommand extends SkillCommand {
|
||||
|
||||
@Override
|
||||
protected void dataCalculations() {
|
||||
DecimalFormat df = new DecimalFormat("#.0");
|
||||
DecimalFormat df = new DecimalFormat("0.0");
|
||||
greenTerraLength = String.valueOf(2 + (int) ((double) skillValue / (double) abilityLengthIncreaseLevel));
|
||||
//FARMERS DIET
|
||||
if(skillValue >= farmersDietMaxLevel) farmersDietRank = "5";
|
||||
else farmersDietRank = String.valueOf((double) skillValue / (double) farmersDietRankChange);
|
||||
else farmersDietRank = String.valueOf((int) ((double) skillValue / (double) farmersDietRankChange));
|
||||
//GREEN THUMB
|
||||
if(skillValue >= greenThumbStageMaxLevel) greenThumbStage = "4";
|
||||
else greenThumbStage = String.valueOf((double) skillValue / (double) greenThumbStageChange);
|
||||
else greenThumbStage = String.valueOf((int) ((double) skillValue / (double) greenThumbStageChange));
|
||||
|
||||
|
||||
if(skillValue >= greenThumbMaxLevel) greenThumbChance = String.valueOf(greenThumbMaxBonus);
|
||||
else greenThumbChance = String.valueOf((greenThumbMaxBonus / greenThumbMaxLevel) * skillValue);
|
||||
else greenThumbChance = df.format((greenThumbMaxBonus / greenThumbMaxLevel) * skillValue);
|
||||
//DOUBLE DROPS
|
||||
if(skillValue >= doubleDropsMaxLevel) doubleDropChance = df.format(doubleDropsMaxBonus);
|
||||
else doubleDropChance = df.format((doubleDropsMaxBonus / doubleDropsMaxLevel) * skillValue);
|
||||
|
@ -45,7 +45,7 @@ public class MiningCommand extends SkillCommand {
|
||||
|
||||
@Override
|
||||
protected void dataCalculations() {
|
||||
DecimalFormat df = new DecimalFormat("#.0");
|
||||
DecimalFormat df = new DecimalFormat("0.0");
|
||||
superBreakerLength = String.valueOf(2 + (int) ((double) skillValue / (double) abilityLengthIncreaseLevel));
|
||||
if(skillValue >= doubleDropsMaxLevel) doubleDropChance = df.format(doubleDropsMaxBonus);
|
||||
else doubleDropChance = df.format((doubleDropsMaxBonus / doubleDropsMaxLevel) * skillValue);
|
||||
|
@ -49,7 +49,7 @@ public class RepairCommand extends SkillCommand {
|
||||
|
||||
@Override
|
||||
protected void dataCalculations() {
|
||||
DecimalFormat df = new DecimalFormat("#.0");
|
||||
DecimalFormat df = new DecimalFormat("0.0");
|
||||
// We're using pickaxes here, not the best but it works
|
||||
Repairable diamondRepairable = mcMMO.repairManager.getRepairable(278);
|
||||
Repairable goldRepairable = mcMMO.repairManager.getRepairable(285);
|
||||
|
@ -36,7 +36,7 @@ public class SwordsCommand extends SkillCommand {
|
||||
|
||||
@Override
|
||||
protected void dataCalculations() {
|
||||
DecimalFormat df = new DecimalFormat("#.0");
|
||||
DecimalFormat df = new DecimalFormat("0.0");
|
||||
serratedStrikesLength = String.valueOf(2 + (int) ((double) skillValue / (double) abilityLengthIncreaseLevel));
|
||||
|
||||
if (skillValue >= bleedMaxLevel) bleedLength = String.valueOf(bleedMaxTicks);
|
||||
|
@ -38,7 +38,7 @@ public class TamingCommand extends SkillCommand {
|
||||
|
||||
@Override
|
||||
protected void dataCalculations() {
|
||||
DecimalFormat df = new DecimalFormat("#.0");
|
||||
DecimalFormat df = new DecimalFormat("0.0");
|
||||
if(skillValue >= goreMaxLevel) goreChance = df.format(goreChanceMax);
|
||||
else goreChance = df.format(((double) goreChanceMax / (double) goreMaxLevel) * skillValue);
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ public class UnarmedCommand extends SkillCommand {
|
||||
|
||||
@Override
|
||||
protected void dataCalculations() {
|
||||
DecimalFormat df = new DecimalFormat("#.0");
|
||||
DecimalFormat df = new DecimalFormat("0.0");
|
||||
berserkLength = String.valueOf(2 + (int) ((double) skillValue / (double) abilityLengthIncreaseLevel));
|
||||
|
||||
if(skillValue >= disarmMaxLevel) disarmChance = df.format(disarmChanceMax);
|
||||
|
@ -61,6 +61,7 @@ public class AdvancedConfig extends ConfigLoader {
|
||||
public int getGreaterImpactBonusDamage() { return config.getInt("Skills.Axes.GreaterImpact_BonusDamage", 2); }
|
||||
|
||||
public int getArmorImpactIncreaseLevel() { return config.getInt("Skills.Axes.ArmorImpact_IncreaseLevel", 50); }
|
||||
public int getArmorImpactMaxDurabilityDamage() { return config.getInt("Skills.Axes.ArmorImpact_MaxPercentageDurabilityDamage", 20); }
|
||||
|
||||
/* EXCAVATION */
|
||||
//Nothing to configure, everything is already configurable in config.yml
|
||||
|
@ -40,20 +40,29 @@ public class Config extends ConfigLoader {
|
||||
/* mySQL */
|
||||
public boolean getUseMySQL() { return config.getBoolean("MySQL.Enabled", false); }
|
||||
public String getMySQLTablePrefix() { return config.getString("MySQL.Database.TablePrefix", "mcmmo_"); }
|
||||
public String getMySQLDatabaseName() { return config.getString("MySQL.Database.Name", "DatabaseName"); }
|
||||
public String getMySQLUserName() { return config.getString("MySQL.Database.User_Name", "UserName"); } //Really should be labeled under MySQL.User_Name instead...
|
||||
public String getMySQLDatabaseName() { return getStringIncludingInts(config, "MySQL.Database.Name"); }
|
||||
public String getMySQLUserName() { return getStringIncludingInts(config, "MySQL.Database.User_Name"); }
|
||||
public int getMySQLServerPort() { return config.getInt("MySQL.Server.Port", 3306); }
|
||||
public String getMySQLServerName() { return config.getString("MySQL.Server.Address", "localhost"); }
|
||||
|
||||
public String getMySQLUserPassword() {
|
||||
if (config.getString("MySQL.Database.User_Password", null) != null) {
|
||||
return config.getString("MySQL.Database.User_Password", null);
|
||||
if (getStringIncludingInts(config, "MySQL.Database.User_Password") != null) {
|
||||
return getStringIncludingInts(config, "MySQL.Database.User_Password");
|
||||
}
|
||||
else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
private static String getStringIncludingInts(ConfigurationSection cfg, String key) {
|
||||
String str = cfg.getString(key);
|
||||
if (str == null)
|
||||
str = String.valueOf(cfg.getInt(key));
|
||||
if (str == null)
|
||||
str = "No value set for '" + key + "'";
|
||||
return str;
|
||||
}
|
||||
|
||||
/* Hardcore Mode */
|
||||
public boolean getHardcoreEnabled() { return config.getBoolean("Hardcore.Enabled", false); }
|
||||
public double getHardcoreDeathStatPenaltyPercentage() { return config.getDouble("Hardcore.Death_Stat_Loss_Penalty_Percentage", 75); }
|
||||
|
@ -16,6 +16,7 @@ import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.party.PartyManager;
|
||||
import com.gmail.nossr50.util.ItemChecks;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
@ -130,6 +131,8 @@ public class Axes {
|
||||
|
||||
/* Every 30 Skill Levels you gain 1 durability damage */
|
||||
int impactIncreaseLevel = advancedConfig.getArmorImpactIncreaseLevel();
|
||||
float impactMaxDamage = (float) advancedConfig.getArmorImpactMaxDurabilityDamage() / 100F;
|
||||
short maxDurability;
|
||||
durabilityDamage += (int) ((double) Users.getProfile(attacker).getSkillLevel(SkillType.AXES) / (double) impactIncreaseLevel);
|
||||
|
||||
if (!hasArmor(targetPlayer)) {
|
||||
@ -137,8 +140,11 @@ public class Axes {
|
||||
}
|
||||
else {
|
||||
for (ItemStack armor : targetPlayer.getInventory().getArmorContents()) {
|
||||
if(Math.random() * 100 > 75)
|
||||
if(Math.random() * 100 > 75) {
|
||||
maxDurability = (short) (ItemChecks.getMaxDurabilityArmor(armor) * impactMaxDamage);
|
||||
if (durabilityDamage > maxDurability) durabilityDamage = (short) maxDurability;
|
||||
armor.setDurability((short) (armor.getDurability() + durabilityDamage)); //Damage armor piece
|
||||
}
|
||||
}
|
||||
targetPlayer.updateInventory();
|
||||
}
|
||||
|
@ -17,20 +17,20 @@ import com.gmail.nossr50.runnables.SQLReconnect;
|
||||
public class Database {
|
||||
|
||||
private static Config configInstance = Config.getInstance();
|
||||
private static String connectionString;
|
||||
|
||||
private static String connectionString = "jdbc:mysql://" + configInstance.getMySQLServerName() + ":" + configInstance.getMySQLServerPort() + "/" + configInstance.getMySQLDatabaseName() + "?user=" + configInstance.getMySQLUserName() + "&password=" + configInstance.getMySQLUserPassword();
|
||||
private static String tablePrefix = configInstance.getMySQLTablePrefix();
|
||||
private static Connection connection = null;
|
||||
private static mcMMO plugin = null;
|
||||
|
||||
// Scale waiting time by this much per failed attempt
|
||||
private static final double SCALING_FACTOR = 5;
|
||||
private static final double SCALING_FACTOR = 10;
|
||||
|
||||
// Minimum wait in nanoseconds (default 500ms)
|
||||
private static final long MIN_WAIT = 500*100000L;
|
||||
private static final long MIN_WAIT = 500L*1000000L;
|
||||
|
||||
// Maximum time to wait between reconnects (default 5 minutes)
|
||||
private static final long MAX_WAIT = 5*60000000000L;
|
||||
private static final long MAX_WAIT = 5L * 60L * 1000L * 1000000L;
|
||||
|
||||
// How long to wait when checking if connection is valid (default 3 seconds)
|
||||
private static final int VALID_TIMEOUT = 3;
|
||||
@ -50,28 +50,27 @@ public class Database {
|
||||
* Attempt to connect to the mySQL database.
|
||||
*/
|
||||
public static void connect() {
|
||||
try {
|
||||
System.out.println("[mcMMO] Attempting connection to MySQL...");
|
||||
connectionString = "jdbc:mysql://" + configInstance.getMySQLServerName() + ":" + configInstance.getMySQLServerPort() + "/" + configInstance.getMySQLDatabaseName();
|
||||
try {
|
||||
mcMMO.p.getLogger().info("Attempting connection to MySQL...");
|
||||
|
||||
// Force driver to load if not yet loaded
|
||||
Class.forName("com.mysql.jdbc.Driver");
|
||||
Properties connectionProperties = new Properties();
|
||||
connectionProperties.put("autoReconnect", "false");
|
||||
connectionProperties.put("maxReconnects", "0");
|
||||
connection = DriverManager.getConnection(connectionString, connectionProperties);
|
||||
// Force driver to load if not yet loaded
|
||||
Class.forName("com.mysql.jdbc.Driver");
|
||||
Properties connectionProperties = new Properties();
|
||||
connectionProperties.put("user", configInstance.getMySQLUserName());
|
||||
connectionProperties.put("password", configInstance.getMySQLUserPassword());
|
||||
connectionProperties.put("autoReconnect", "false");
|
||||
connectionProperties.put("maxReconnects", "0");
|
||||
connection = DriverManager.getConnection(connectionString, connectionProperties);
|
||||
|
||||
System.out.println("[mcMMO] Connection to MySQL was a success!");
|
||||
}
|
||||
catch (SQLException ex) {
|
||||
connection = null;
|
||||
System.out.println("[mcMMO] Connection to MySQL failed!");
|
||||
ex.printStackTrace();
|
||||
printErrors(ex);
|
||||
} catch (ClassNotFoundException ex) {
|
||||
connection = null;
|
||||
System.out.println("[mcMMO] MySQL database driver not found!");
|
||||
ex.printStackTrace();
|
||||
}
|
||||
mcMMO.p.getLogger().info("Connection to MySQL was a success!");
|
||||
} catch (SQLException ex) {
|
||||
connection = null;
|
||||
if(reconnectAttempt == 0 || reconnectAttempt >= 11) mcMMO.p.getLogger().info("Connection to MySQL failed!");
|
||||
} catch (ClassNotFoundException ex) {
|
||||
connection = null;
|
||||
if(reconnectAttempt == 0 || reconnectAttempt >= 11) mcMMO.p.getLogger().info("MySQL database driver not found!");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -156,6 +155,7 @@ public class Database {
|
||||
|
||||
PreparedStatement statement = null;
|
||||
try {
|
||||
if(!checkConnected()) return;
|
||||
statement = connection.prepareStatement(sql);
|
||||
resultSet = statement.executeQuery();
|
||||
|
||||
@ -172,12 +172,12 @@ public class Database {
|
||||
catch (SQLException ex) {
|
||||
switch (update) {
|
||||
case BLAST_MINING:
|
||||
System.out.println("Updating mcMMO MySQL tables for Blast Mining...");
|
||||
mcMMO.p.getLogger().info("Updating mcMMO MySQL tables for Blast Mining...");
|
||||
write("ALTER TABLE `"+tablePrefix + "cooldowns` ADD `blast_mining` int(32) NOT NULL DEFAULT '0' ;");
|
||||
break;
|
||||
|
||||
case FISHING:
|
||||
System.out.println("Updating mcMMO MySQL tables for Fishing...");
|
||||
mcMMO.p.getLogger().info("Updating mcMMO MySQL tables for Fishing...");
|
||||
write("ALTER TABLE `"+tablePrefix + "skills` ADD `fishing` int(10) NOT NULL DEFAULT '0' ;");
|
||||
write("ALTER TABLE `"+tablePrefix + "experience` ADD `fishing` int(10) NOT NULL DEFAULT '0' ;");
|
||||
break;
|
||||
|
@ -474,4 +474,39 @@ public class ItemChecks {
|
||||
public static boolean isEnchantable(ItemStack is) {
|
||||
return isArmor(is) || isSword(is) || isAxe(is) || isShovel(is) || isPickaxe(is) || (is.getType() == Material.BOW);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the maximum durability of an armor type.
|
||||
*
|
||||
* @param is Item to check
|
||||
* @return maximum durability value.
|
||||
*/
|
||||
public static int getMaxDurabilityArmor(ItemStack is) {
|
||||
int durability = 0;
|
||||
if (isDiamondArmor(is)) {
|
||||
if (isHelmet(is)) durability = 364;
|
||||
else if (isChestplate(is)) durability = 529;
|
||||
else if (isPants(is)) durability = 496;
|
||||
else if (isBoots(is)) durability = 430;
|
||||
}
|
||||
else if (isIronArmor(is)) {
|
||||
if (isHelmet(is)) durability = 166;
|
||||
else if (isChestplate(is)) durability = 242;
|
||||
else if (isPants(is)) durability = 226;
|
||||
else if (isBoots(is)) durability = 196;
|
||||
}
|
||||
else if (isGoldArmor(is)) {
|
||||
if (isHelmet(is)) durability = 78;
|
||||
else if (isChestplate(is)) durability = 114;
|
||||
else if (isPants(is)) durability = 106;
|
||||
else if (isBoots(is)) durability = 92;
|
||||
}
|
||||
else if (isLeatherArmor(is)) {
|
||||
if (isHelmet(is)) durability = 56;
|
||||
else if (isChestplate(is)) durability = 82;
|
||||
else if (isPants(is)) durability = 76;
|
||||
else if (isBoots(is)) durability = 66;
|
||||
}
|
||||
return durability;
|
||||
}
|
||||
}
|
||||
|
@ -45,6 +45,7 @@ Skills:
|
||||
GreaterImpact_KnockbackModifier: 1.5
|
||||
GreaterImpact_BonusDamage: 2
|
||||
ArmorImpact_IncreaseLevel: 50
|
||||
ArmorImpact_MaxPercentageDurabilityDamage: 20
|
||||
Fishing:
|
||||
Shake_UnlockLevel: 150
|
||||
Enchantment_Chance: 10
|
||||
|
Loading…
Reference in New Issue
Block a user