Cleanup formatting.

This commit is contained in:
Grant 2012-12-24 16:56:25 -05:00
parent 6b3bde585d
commit 36d5344ded
67 changed files with 894 additions and 849 deletions

View File

@ -7,7 +7,7 @@ Key:
! Change
- Removal
Version 1.3.13
Version 1.3.13-dev
+ Added Craftbukkit 1.4.6 compatibility
= Fixed issue with missing default cases from several switch/case statements
= Fixed issue with Mining using actual skill level rather than max skill level

View File

@ -84,7 +84,7 @@ public class AddxpCommand implements CommandExecutor {
String playerName = modifiedPlayer.getName();
McMMOPlayer mcMMOPlayer = Users.getPlayer(modifiedPlayer);
PlayerProfile profile = Users.getProfile(modifiedPlayer);
if (profile == null) {
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
return true;

View File

@ -28,11 +28,11 @@ public class McstatsCommand implements CommandExecutor {
CommandHelper.printMiscSkills(player);
int powerLevelCap = Config.getInstance().getPowerLevelCap();
if (powerLevelCap > 0)
player.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Capped", new Object[] { String.valueOf(Users.getPlayer(player).getPowerLevel()), String.valueOf(powerLevelCap) }));
player.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Capped", new Object[] { String.valueOf(Users.getPlayer(player).getPowerLevel()), String.valueOf(powerLevelCap) }));
else
player.sendMessage(LocaleLoader.getString("Commands.PowerLevel", new Object[] { String.valueOf(Users.getPlayer(player).getPowerLevel()) }));
player.sendMessage(LocaleLoader.getString("Commands.PowerLevel", new Object[] { String.valueOf(Users.getPlayer(player).getPowerLevel()) }));
return true;
}

View File

@ -18,31 +18,31 @@ public class SkillResetCommand implements CommandExecutor {
if (CommandHelper.noConsoleUsage(sender)) {
return true;
}
//ensure they have the skillreset perm
if (CommandHelper.noCommandPermissions(sender, "mcmmo.skillreset")) {
return true;
}
SkillType skillType = null; //simple initialization
//make sure there's only one argument. output at least some kind of error if not
if (args.length != 1 && args[0] != null) {
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
return true;
}
//parse the skilltype that they sent
try
{
skillType = SkillType.valueOf(args[0].toUpperCase().trim()); //ucase needed to match enum since it's case sensitive. trim to be nice
skillType = SkillType.valueOf(args[0].toUpperCase().trim()); //ucase needed to match enum since it's case sensitive. trim to be nice
}catch(IllegalArgumentException ex)
{
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
{
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
return true;
}
}
//reset the values in the hash table and persist them
PlayerProfile profile = Users.getProfile((Player)sender);
@ -53,13 +53,13 @@ public class SkillResetCommand implements CommandExecutor {
profile.resetSkill(skillType);
profile.save();
//display a success message to the user
if (skillType == SkillType.ALL)
sender.sendMessage(LocaleLoader.getString("Commands.Reset.All"));
sender.sendMessage(LocaleLoader.getString("Commands.Reset.All"));
else
sender.sendMessage(LocaleLoader.getString("Commands.Reset.Single", new Object[] { args[0] }));
sender.sendMessage(LocaleLoader.getString("Commands.Reset.Single", new Object[] { args[0] }));
return true;
}
}

View File

@ -48,7 +48,7 @@ public class MccCommand implements CommandExecutor {
if (Config.getInstance().getCommandSkillResetEnabled() && Permissions.getInstance().skillReset(player)) {
player.sendMessage("/skillreset <skill|all> " + LocaleLoader.getString("Commands.Reset"));
}
if (Permissions.getInstance().mcAbility(player)) {
player.sendMessage("/mcability " + LocaleLoader.getString("Commands.ToggleAbility"));
}

View File

@ -49,7 +49,7 @@ public class InviteCommand implements CommandExecutor {
if (target != null) {
if (PartyManager.getInstance().canInvite(player, playerProfile)) {
Party party = playerProfile.getParty();
Users.getProfile(target).setInvite(party);
player.sendMessage(LocaleLoader.getString("Commands.Invite.Success"));
target.sendMessage(LocaleLoader.getString("Commands.Party.Invite.0", new Object[] {party.getName(), player.getName()}));

View File

@ -85,5 +85,5 @@ public class PtpCommand implements CommandExecutor {
sender.sendMessage(usage);
return true;
}
}
}
}

View File

@ -36,13 +36,13 @@ public class AcrobaticsCommand extends SkillCommand {
DecimalFormat df = new DecimalFormat("#.0");
// DODGE
if(skillValue >= dodgeMaxBonusLevel) dodgeChance = df.format(dodgeChanceMax);
else dodgeChance = df.format(((double) dodgeChanceMax / (double) dodgeMaxBonusLevel) * (double) skillValue);
else dodgeChance = df.format(((double) dodgeChanceMax / (double) dodgeMaxBonusLevel) * skillValue);
// ROLL
if(skillValue >= rollMaxBonusLevel) rollChance = df.format(rollChanceMax);
else rollChance = df.format(((double) rollChanceMax / (double) rollMaxBonusLevel) * (double) skillValue);
else rollChance = df.format(((double) rollChanceMax / (double) rollMaxBonusLevel) * skillValue);
// GRACEFULROLL
if(skillValue >= gracefulRollMaxBonusLevel) gracefulRollChance = df.format(gracefulRollChanceMax);
else gracefulRollChance = df.format(((double) gracefulRollChanceMax / (double) gracefulRollMaxBonusLevel) * (double) skillValue);
else gracefulRollChance = df.format(((double) gracefulRollChanceMax / (double) gracefulRollMaxBonusLevel) * skillValue);
}
@Override
@ -59,10 +59,10 @@ public class AcrobaticsCommand extends SkillCommand {
@Override
protected void effectsDisplay() {
if (player.hasPermission("mcmmo.perks.lucky.acrobatics")) {
String perkPrefix = ChatColor.RED + "[mcMMO Perks] ";
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.lucky.name"), LocaleLoader.getString("Perks.lucky.desc", new Object[] { "Acrobatics" }) }));
}
if (player.hasPermission("mcmmo.perks.lucky.acrobatics")) {
String perkPrefix = ChatColor.RED + "[mcMMO Perks] ";
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.lucky.name"), LocaleLoader.getString("Perks.lucky.desc", new Object[] { "Acrobatics" }) }));
}
if (canRoll) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Acrobatics.Effect.0"), LocaleLoader.getString("Acrobatics.Effect.1") }));

View File

@ -39,17 +39,17 @@ public class ArcheryCommand extends SkillCommand {
protected void dataCalculations() {
DecimalFormat df = new DecimalFormat("#.0");
// SkillShot
double bonus = (int)((double) skillValue / (double) skillShotIncreaseLevel) * (double) skillShotIncreasePercentage;
double bonus = (int)((double) skillValue / (double) skillShotIncreaseLevel) * skillShotIncreasePercentage;
if (bonus > skillShotBonusMax) skillShotBonus = percent.format(skillShotBonusMax);
else skillShotBonus = percent.format(bonus);
// Daze
if(skillValue >= dazeMaxBonusLevel) dazeChance = df.format(dazeBonusMax);
else dazeChance = df.format(((double) dazeBonusMax / (double) dazeMaxBonusLevel) * (double) skillValue);
else dazeChance = df.format(((double) dazeBonusMax / (double) dazeMaxBonusLevel) * skillValue);
// Retrieve
if(skillValue >= retrieveMaxBonusLevel) retrieveChance = df.format(retrieveBonusMax);
else retrieveChance = df.format(((double) retrieveBonusMax / (double) retrieveMaxBonusLevel) * (double) skillValue);
else retrieveChance = df.format(((double) retrieveBonusMax / (double) retrieveMaxBonusLevel) * skillValue);
}
@Override
@ -66,10 +66,10 @@ public class ArcheryCommand extends SkillCommand {
@Override
protected void effectsDisplay() {
if (player.hasPermission("mcmmo.perks.lucky.archery")) {
String perkPrefix = ChatColor.RED + "[mcMMO Perks] ";
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.lucky.name"), LocaleLoader.getString("Perks.lucky.desc", new Object[] { "Archery" }) }));
}
if (player.hasPermission("mcmmo.perks.lucky.archery")) {
String perkPrefix = ChatColor.RED + "[mcMMO Perks] ";
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.lucky.name"), LocaleLoader.getString("Perks.lucky.desc", new Object[] { "Archery" }) }));
}
if (canSkillShot) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Archery.Effect.0"), LocaleLoader.getString("Archery.Effect.1") }));

View File

@ -12,7 +12,7 @@ import com.gmail.nossr50.util.Misc;
public class AxesCommand extends SkillCommand {
AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
private String critChance;
private String bonusDamage;
private String impactDamage;
@ -24,7 +24,7 @@ public class AxesCommand extends SkillCommand {
private double critMaxChance = advancedConfig.getAxesCriticalChance();
private int critMaxBonusLevel = advancedConfig.getAxesCriticalMaxBonusLevel();
private int greaterImpactIncreaseLevel = advancedConfig.getArmorImpactIncreaseLevel();
// private double greaterImpactModifier = advancedConfig.getGreaterImpactModifier();
// private double greaterImpactModifier = advancedConfig.getGreaterImpactModifier();
private int abilityLengthIncreaseLevel = advancedConfig.getAbilityLength();
private boolean canSkullSplitter;
@ -47,9 +47,9 @@ public class AxesCommand extends SkillCommand {
greaterImpactDamage = "2";
if (skillValue >= critMaxBonusLevel) critChance = df.format(critMaxChance);
else critChance = String.valueOf(((double) critMaxChance / (double) critMaxBonusLevel) * (double) skillCheck);
else critChance = String.valueOf((critMaxChance / critMaxBonusLevel) * skillCheck);
if (skillValue >= bonusDamageAxesMaxBonusLevel) bonusDamage = String.valueOf(bonusDamageAxesBonusMax);
else bonusDamage = String.valueOf((double) skillValue / ((double) bonusDamageAxesMaxBonusLevel / (double) bonusDamageAxesBonusMax));
else bonusDamage = String.valueOf(skillValue / ((double) bonusDamageAxesMaxBonusLevel / (double) bonusDamageAxesBonusMax));
}
@Override

View File

@ -11,7 +11,7 @@ import com.gmail.nossr50.skills.gathering.Fishing;
public class FishingCommand extends SkillCommand {
AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
private int lootTier;
private String magicChance;
private int shakeUnlockLevel;
@ -30,10 +30,10 @@ public class FishingCommand extends SkillCommand {
@Override
protected void dataCalculations() {
lootTier = Fishing.getFishingLootTier(profile);
magicChance = percent.format((double) lootTier / 15D);
magicChance = percent.format(lootTier / 15D);
int dropChance = Fishing.getShakeChance(lootTier);
if (player.hasPermission("mcmmo.perks.lucky.fishing")) {
dropChance = (int) ((double) dropChance * 1.25D);
dropChance = (int) (dropChance * 1.25D);
}
shakeChance = String.valueOf(dropChance);

View File

@ -12,7 +12,7 @@ import com.gmail.nossr50.locale.LocaleLoader;
public class HerbalismCommand extends SkillCommand {
AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
private String greenTerraLength;
private String greenThumbChance;
private String greenThumbStage;
@ -28,7 +28,7 @@ public class HerbalismCommand extends SkillCommand {
private int greenThumbMaxLevel = advancedConfig.getGreenThumbMaxLevel();
private double doubleDropsMaxBonus = advancedConfig.getHerbalismDoubleDropsChanceMax();
private int doubleDropsMaxLevel = advancedConfig.getHerbalismDoubleDropsMaxLevel();
private boolean canGreenTerra;
private boolean canGreenThumbWheat;
private boolean canGreenThumbBlocks;
@ -50,13 +50,13 @@ public class HerbalismCommand extends SkillCommand {
//GREEN THUMB
if(skillValue >= greenThumbStageMaxLevel) greenThumbStage = "4";
else greenThumbStage = String.valueOf((double) skillValue / (double) greenThumbStageChange);
if(skillValue >= greenThumbMaxLevel) greenThumbChance = String.valueOf(greenThumbMaxBonus);
else greenThumbChance = String.valueOf(((double) greenThumbMaxBonus / (double) greenThumbMaxLevel) * (double) skillValue);
else greenThumbChance = String.valueOf((greenThumbMaxBonus / greenThumbMaxLevel) * skillValue);
//DOUBLE DROPS
if(skillValue >= doubleDropsMaxLevel) doubleDropChance = df.format(doubleDropsMaxBonus);
else doubleDropChance = df.format(((double) doubleDropsMaxBonus / (double) doubleDropsMaxLevel) * (double) skillValue);
else doubleDropChance = df.format((doubleDropsMaxBonus / doubleDropsMaxLevel) * skillValue);
}
@Override

View File

@ -48,8 +48,8 @@ public class MiningCommand extends SkillCommand {
DecimalFormat df = new DecimalFormat("#.0");
superBreakerLength = String.valueOf(2 + (int) ((double) skillValue / (double) abilityLengthIncreaseLevel));
if(skillValue >= doubleDropsMaxLevel) doubleDropChance = df.format(doubleDropsMaxBonus);
else doubleDropChance = df.format(((double) doubleDropsMaxBonus / (double) doubleDropsMaxLevel) * (double) skillValue);
else doubleDropChance = df.format((doubleDropsMaxBonus / doubleDropsMaxLevel) * skillValue);
if (skillValue >= blastMiningRank8) {
blastMiningRank = "8";
blastDamageDecrease = "100.00%";

View File

@ -64,10 +64,10 @@ public class RepairCommand extends SkillCommand {
salvageLevel = Config.getInstance().getSalvageUnlockLevel();
if(skillValue >= repairMasteryMaxBonusLevel) repairMasteryBonus = df.format(repairMasteryChanceMax);
else repairMasteryBonus = df.format(((double) repairMasteryChanceMax / (double) repairMasteryMaxBonusLevel) * (double) skillValue);
else repairMasteryBonus = df.format(((double) repairMasteryChanceMax / (double) repairMasteryMaxBonusLevel) * skillValue);
if(skillValue >= superRepairMaxBonusLevel) superRepairChance = df.format(superRepairChanceMax);
else superRepairChance = df.format(((double) superRepairChanceMax / (double) superRepairMaxBonusLevel) * (double) skillValue);
else superRepairChance = df.format(((double) superRepairChanceMax / (double) superRepairMaxBonusLevel) * skillValue);
arcaneForgingRank = Repair.getArcaneForgingRank(profile);
}
@ -85,7 +85,7 @@ public class RepairCommand extends SkillCommand {
canRepairString = permInstance.stringRepair(player);
canRepairLeather = permInstance.leatherRepair(player);
canRepairWood = permInstance.woodRepair(player);
arcaneBypass = permInstance.arcaneBypass(player);
arcaneBypass = permInstance.arcaneBypass(player);
}
@Override

View File

@ -11,7 +11,7 @@ import com.gmail.nossr50.locale.LocaleLoader;
public class SwordsCommand extends SkillCommand {
AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
private String counterAttackChance;
private String bleedLength;
private String bleedChance;
@ -38,16 +38,16 @@ public class SwordsCommand extends SkillCommand {
protected void dataCalculations() {
DecimalFormat df = new DecimalFormat("#.0");
serratedStrikesLength = String.valueOf(2 + (int) ((double) skillValue / (double) abilityLengthIncreaseLevel));
if (skillValue >= bleedMaxLevel) bleedLength = String.valueOf(bleedMaxTicks);
else bleedLength = String.valueOf(bleedBaseTicks);
if(skillValue >= bleedMaxLevel) bleedChance = df.format(bleedChanceMax);
else bleedChance = df.format(((double) bleedChanceMax / (double) bleedMaxLevel) * (double) skillValue);
else bleedChance = df.format(((double) bleedChanceMax / (double) bleedMaxLevel) * skillValue);
if(skillValue >= counterMaxLevel) counterAttackChance = df.format(counterChanceMax);
else counterAttackChance = df.format(((double) counterChanceMax / (double) counterMaxLevel) * (double) skillValue);
else counterAttackChance = df.format(((double) counterChanceMax / (double) counterMaxLevel) * skillValue);
serratedStrikesLength = String.valueOf(serratedBleedTicks);
}

View File

@ -22,7 +22,7 @@ public class TamingCommand extends SkillCommand {
private int thickFurUnlock = advancedConfig.getThickFurUnlock();
private int shockProofUnlock = advancedConfig.getShockProofUnlock();
private int sharpenedClawUnlock = advancedConfig.getSharpenedClawsUnlock();
private boolean canBeastLore;
private boolean canGore;
private boolean canSharpenedClaws;
@ -40,8 +40,8 @@ public class TamingCommand extends SkillCommand {
protected void dataCalculations() {
DecimalFormat df = new DecimalFormat("#.0");
if(skillValue >= goreMaxLevel) goreChance = df.format(goreChanceMax);
else goreChance = df.format(((double) goreChanceMax / (double) goreMaxLevel) * (double) skillValue);
}
else goreChance = df.format(((double) goreChanceMax / (double) goreMaxLevel) * skillValue);
}
@Override
protected void permissionsCheck() {

View File

@ -39,10 +39,10 @@ public class UnarmedCommand extends SkillCommand {
berserkLength = String.valueOf(2 + (int) ((double) skillValue / (double) abilityLengthIncreaseLevel));
if(skillValue >= disarmMaxLevel) disarmChance = df.format(disarmChanceMax);
else disarmChance = df.format(((double) disarmChanceMax / (double) disarmMaxLevel) * (double) skillValue);
else disarmChance = df.format(((double) disarmChanceMax / (double) disarmMaxLevel) * skillValue);
if(skillValue >= deflectMaxLevel) deflectChance = df.format(deflectChanceMax);
else deflectChance = df.format(((double) deflectChanceMax / (double) deflectMaxLevel) * (double) skillValue);
else deflectChance = df.format(((double) deflectChanceMax / (double) deflectMaxLevel) * skillValue);
if (skillValue >= 250) ironArmBonus = String.valueOf(ironArmMaxBonus);
else ironArmBonus = String.valueOf(3 + ((double) skillValue / (double) ironArmIncreaseLevel));

View File

@ -19,7 +19,7 @@ public class WoodcuttingCommand extends SkillCommand {
private double doubleDropsMaxBonus = advancedConfig.getWoodcuttingDoubleDropChance();
private int doubleDropsMaxLevel = advancedConfig.getWoodcuttingDoubleDropMaxLevel();
private int leafBlowUnlock = advancedConfig.getLeafBlowUnlockLevel();
private boolean canTreeFell;
private boolean canLeafBlow;
private boolean canDoubleDrop;
@ -35,7 +35,7 @@ public class WoodcuttingCommand extends SkillCommand {
treeFellerLength = String.valueOf(2 + (int) ((double) skillValue / (double) abilityLengthIncreaseLevel));
if(skillValue >= doubleDropsMaxLevel) doubleDropChance = df.format(doubleDropsMaxBonus);
else doubleDropChance = df.format(((double) doubleDropsMaxBonus / (double) doubleDropsMaxLevel) * (double) skillValue);
else doubleDropChance = df.format((doubleDropsMaxBonus / doubleDropsMaxLevel) * skillValue);
}
@Override

View File

@ -2,7 +2,7 @@ package com.gmail.nossr50.config;
public class AdvancedConfig extends ConfigLoader {
private static AdvancedConfig instance;
private AdvancedConfig() {
super("advanced.yml");
loadKeys();
@ -13,28 +13,28 @@ public class AdvancedConfig extends ConfigLoader {
}
return instance;
}
@Override
protected void loadKeys() {
// TODO Do I need to use this?
}
/* GENERAL */
public int getAbilityLength() { return config.getInt("Skills.General.Ability_IncreaseLevel", 50); }
/* ACROBATICS */
public int getDodgeChanceMax() { return config.getInt("Skills.Acrobatics.Dodge_ChanceMax", 20); }
public int getDodgeMaxBonusLevel() { return config.getInt("Skills.Acrobatics.Dodge_MaxBonusLevel", 800); }
public int getRollChanceMax() { return config.getInt("Skills.Acrobatics.Roll_ChanceMax", 100); }
public int getRollMaxBonusLevel() { return config.getInt("Skills.Acrobatics.Roll_MaxBonusLevel", 1000); }
public int getGracefulRollChanceMax() { return config.getInt("Skills.Acrobatics.GracefulRoll_ChanceMax", 100); }
public int getGracefulRollMaxBonusLevel() { return config.getInt("Skills.Acrobatics.GracefulRoll_MaxBonusLevel", 500); }
public int getDodgeXPModifier() { return config.getInt("Skills.Acrobatics.Dodge_XP_Modifier", 120); }
public int getRollXPModifier() { return config.getInt("Skills.Acrobatics.Roll_XP_Modifier", 80); }
public int getFallXPModifier() { return config.getInt("Skills.Acrobatics.Fall_XP_Modifier", 120); }
/* ARCHERY */
public int getSkillShotIncreaseLevel() { return config.getInt("Skills.Archery.SkillShot_IncreaseLevel", 50); }
public double getSkillShotIncreasePercentage() { return config.getDouble("Skills.Archery.SkillShot_IncreasePercentage", 0.1D); }
@ -46,7 +46,7 @@ public class AdvancedConfig extends ConfigLoader {
public int getRetrieveBonusMax() { return config.getInt("Skills.Archery.Retrieve_MaxBonus", 100); }
public int getRetrieveMaxBonusLevel() { return config.getInt("Skills.Archery.Retrieve_MaxBonusLevel", 1000); }
/* AXES */
public int getBonusDamageAxesBonusMax() { return config.getInt("Skills.Axes.DamageIncrease_MaxBonus", 4); }
public int getBonusDamageAxesMaxBonusLevel() { return config.getInt("Skills.Axes.DamageIncrease_MaxBonusLevel", 200); }
@ -55,30 +55,30 @@ public class AdvancedConfig extends ConfigLoader {
public int getAxesCriticalMaxBonusLevel() { return config.getInt("Skills.Axes.AxesCritical_MaxBonusLevel", 750); }
public double getAxesCriticalPVPModifier() { return config.getDouble("Skills.Axes.AxesCritical_PVP_Modifier", 1.5); }
public int getAxesCriticalPVEModifier() { return config.getInt("Skills.Axes.AxesCritical_PVE_Modifier", 2); }
public int getGreaterImpactChance() { return config.getInt("Skills.Axes.GreaterImpact_Chance", 25); }
public double getGreaterImpactModifier() { return config.getDouble("Skills.Axes.GreaterImpact_KnockbackModifier", 1.5); }
public int getGreaterImpactBonusDamage() { return config.getInt("Skills.Axes.GreaterImpact_BonusDamage", 2); }
public int getArmorImpactIncreaseLevel() { return config.getInt("Skills.Axes.ArmorImpact_IncreaseLevel", 50); }
/* EXCAVATION */
//Nothing to configure, everything is already configurable in config.yml
/* FISHING */
public int getShakeUnlockLevel() { return config.getInt("Skills.Fishing.Shake_UnlockLevel", 150); }
public int getFishingEnchantmentChance() { return config.getInt("Skills.Fishing.Enchantment_Chance", 10); }
/* HERBALISM */
public int getFarmerDietRankChange() { return config.getInt("Skills.Herbalism.Food_RankChange", 200); }
public int getGreenThumbStageChange() { return config.getInt("Skills.Herbalism.GreenThumb_StageChange", 200); }
public int getGreenThumbChanceMax() { return config.getInt("Skills.Herbalism.GreenThumb_ChanceMax", 100); }
public int getGreenThumbMaxLevel() { return config.getInt("Skills.Herbalism.GreenThumb_MaxBonusLevel", 1500); }
public int getHerbalismDoubleDropsChanceMax() { return config.getInt("Skills.Herbalism.DoubleDrops_ChanceMax", 100); }
public int getHerbalismDoubleDropsMaxLevel() { return config.getInt("Skills.Herbalism.DoubleDrops_MaxBonusLevel", 1000); }
/* MINING */
public int getMiningDoubleDropChance() { return config.getInt("Skills.Mining.DoubleDrops_ChanceMax", 100); }
public int getMiningDoubleDropMaxLevel() { return config.getInt("Skills.Mining.DoubleDrops_MaxBonusLevel", 1000); }
@ -96,7 +96,7 @@ public class AdvancedConfig extends ConfigLoader {
public int getRepairMasteryMaxLevel() { return config.getInt("Skills.Repair.RepairMastery_MaxBonusLevel", 1000); }
public int getSuperRepairChanceMax() { return config.getInt("Skills.Repair.SuperRepair_ChanceMax", 100); }
public int getSuperRepairMaxLevel() { return config.getInt("Skills.Repair.SuperRepair_MaxBonusLevel", 1000); }
/* SWORDS */
public int getBleedChanceMax() { return config.getInt("Skills.Sword.Bleed_ChanceMax", 75); }
public int getBleedMaxBonusLevel() { return config.getInt("Skills.Sword.Bleed_MaxBonusLevel", 750); }
@ -106,7 +106,7 @@ public class AdvancedConfig extends ConfigLoader {
public int getCounterChanceMax() { return config.getInt("Skills.Sword.Counter_ChanceMax", 30); }
public int getCounterMaxBonusLevel() { return config.getInt("Skills.Sword.Counter_MaxBonusLevel", 600); }
public int getCounterModifier() { return config.getInt("Skills.Sword.Counter_DamageModifier", 2); }
public int getSerratedStrikesModifier() { return config.getInt("Skills.Sword.SerratedStrikes_DamageModifier", 4); }
public int getSerratedStrikesTicks() { return config.getInt("Skills.Sword.SerratedStrikes_BleedTicks", 5); }
/* TAMING */
@ -117,12 +117,12 @@ public class AdvancedConfig extends ConfigLoader {
public int getFastFoodUnlock() { return config.getInt("Skills.Taming.FastFood_UnlockLevel", 50); }
public int getFastFoodChance() { return config.getInt("Skills.Taming.FastFood_Chance", 50); }
public int getEnviromentallyAwareUnlock() { return config.getInt("Skills.Taming.EnvironmentallyAware_UnlockLevel", 100); }
public int getThickFurUnlock() { return config.getInt("Skills.Taming.ThickFur_UnlockLevel", 250); }
public int getThickFurModifier() { return config.getInt("Skills.Taming.ThickFur_Modifier", 2); }
public int getShockProofUnlock() { return config.getInt("Skills.Taming.ShockProof_UnlockLevel", 500); }
public int getShockProofModifier() { return config.getInt("Skills.Taming.ShockProof_Modifier", 6); }
@ -141,13 +141,13 @@ public class AdvancedConfig extends ConfigLoader {
public int getLeafBlowUnlockLevel() { return config.getInt("Skills.Woodcutting.LeafBlower_UnlockLevel", 100); }
public int getWoodcuttingDoubleDropChance() { return config.getInt("Skills.Woodcutting.DoubleDrops_ChanceMax", 100); }
public int getWoodcuttingDoubleDropMaxLevel() { return config.getInt("Skills.Woodcutting.DoubleDrops_MaxBonusLevel", 1000); }
/* SPOUT STUFF*/
public int getSpoutNotificationTier1() { return config.getInt("Spout.Notifications.Tier1", 200); }
public int getSpoutNotificationTier2() { return config.getInt("Spout.Notifications.Tier2", 400); }
public int getSpoutNotificationTier3() { return config.getInt("Spout.Notifications.Tier3", 600); }
public int getSpoutNotificationTier4() { return config.getInt("Spout.Notifications.Tier4", 800); }
//TODO Make the sounds configurable! :D
// public String getSpoutSoundRepair() { return config.getString("Spout.Sounds.RepairSound", "url here"); }
// public String getSpoutSoundLevelUp() { return config.getString("Spout.Sounds.LevelUp", "url here"); }
// public String getSpoutSoundRepair() { return config.getString("Spout.Sounds.RepairSound", "url here"); }
// public String getSpoutSoundLevelUp() { return config.getString("Spout.Sounds.LevelUp", "url here"); }
}

View File

@ -152,7 +152,7 @@ public class Config extends ConfigLoader {
public int getFishingTierLevelsTier3() { return config.getInt("Fishing.Tier_Levels.Tier3", 400); }
public int getFishingTierLevelsTier4() { return config.getInt("Fishing.Tier_Levels.Tier4", 600); }
public int getFishingTierLevelsTier5() { return config.getInt("Fishing.Tier_Levels.Tier5", 800); }
/* Shake */
public int getShakeChanceRank1() { return config.getInt("Shake.Chance.Rank_1", 25); }
public int getShakeChanceRank2() { return config.getInt("Shake.Chance.Rank_2", 40); }

View File

@ -190,7 +190,7 @@ public class TreasuresConfig extends ConfigLoader{
List<String> excavationTreasures = config.getStringList("Excavation.Treasure");
List<String> fishingTreasures = config.getStringList("Fishing.Treasure");
// Iterator<String> treasureIterator = treasures.keySet().iterator();
// Iterator<String> treasureIterator = treasures.keySet().iterator();
Iterator<Entry<String,Treasure>> treasureIterator = treasures.entrySet().iterator();
while (treasureIterator.hasNext()) {

View File

@ -18,7 +18,7 @@ import com.gmail.nossr50.util.Misc;
public class PlayerProfile {
private String playerName;
/* HUD */
private SpoutHud spoutHud;
private HudType hudType = SpoutConfig.getInstance().defaultHudType;
@ -36,9 +36,9 @@ public class PlayerProfile {
private boolean godMode;
private boolean greenTerraMode, treeFellerMode, superBreakerMode, gigaDrillBreakerMode, serratedStrikesMode, skullSplitterMode, berserkMode;
private boolean greenTerraInformed = true, berserkInformed = true, skullSplitterInformed = true, gigaDrillBreakerInformed = true,
superBreakerInformed = true, blastMiningInformed = true, serratedStrikesInformed = true, treeFellerInformed = true;
superBreakerInformed = true, blastMiningInformed = true, serratedStrikesInformed = true, treeFellerInformed = true;
private boolean hoePreparationMode, shovelPreparationMode, swordsPreparationMode, fistsPreparationMode,
pickaxePreparationMode, axePreparationMode;
pickaxePreparationMode, axePreparationMode;
private boolean abilityUse = true;
/* Timestamps */
@ -278,7 +278,7 @@ public class PlayerProfile {
skillsXp.put(SkillType.FISHING, Integer.valueOf(character[35]));
if (character.length > 36)
skillsDATS.put(AbilityType.BLAST_MINING, Integer.valueOf(character[36]));
loaded = true;
in.close();
@ -364,7 +364,7 @@ public class PlayerProfile {
writer.append(line).append("\r\n");
}
else {
//Otherwise write the new player information
//Otherwise write the new player information
writer.append(playerName + ":");
writer.append(skills.get(SkillType.MINING) + ":");
writer.append("" + ":");
@ -513,7 +513,7 @@ public class PlayerProfile {
* Salvage Anvil Placement
*/
public void togglePlacedSalvageAnvil() {
placedSalvageAnvil = !placedSalvageAnvil;
placedSalvageAnvil = !placedSalvageAnvil;
}
public Boolean getPlacedSalvageAnvil() {
@ -891,8 +891,8 @@ public class PlayerProfile {
}
/*
* Exploit Prevention
*/
* Exploit Prevention
*/
public int getRespawnATS() {
return respawnATS;
@ -923,116 +923,116 @@ public class PlayerProfile {
skills.put(skillType, skills.get(skillType) + newValue);
save(false);
}
public void resetSkill(SkillType skillType)
{
//do a single skilltype
if (skillType != SkillType.ALL)
skills.put(skillType, 0);
else //do them all
{
for(SkillType skill : SkillType.values()) //iterate over all items in the enumeration
{
if (skill != SkillType.ALL) // skip the "all" value
skills.put(skill, 0);
}
}
//do a single skilltype
if (skillType != SkillType.ALL)
skills.put(skillType, 0);
else //do them all
{
for(SkillType skill : SkillType.values()) //iterate over all items in the enumeration
{
if (skill != SkillType.ALL) // skip the "all" value
skills.put(skill, 0);
}
}
save(false);
}
// /**
// * Adds XP to the player, doesn't calculate for XP Rate
// *
// * @param skillType The skill to add XP to
// * @param newValue The amount of XP to add
// */
// public void addXPOverride(SkillType skillType, int newValue) {
// if (skillType.equals(SkillType.ALL)) {
// for (SkillType x : SkillType.values()) {
// if (x.equals(SkillType.ALL)) {
// continue;
// }
//
// mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerXpGainEvent(player, x, newValue));
// skillsXp.put(x, skillsXp.get(x) + newValue);
// }
// }
// else {
// mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerXpGainEvent(player, skillType, newValue));
// skillsXp.put(skillType, skillsXp.get(skillType) + newValue);
// spoutHud.setLastGained(skillType);
// }
// }
// /**
// * Adds XP to the player, doesn't calculate for XP Rate
// *
// * @param skillType The skill to add XP to
// * @param newValue The amount of XP to add
// */
// public void addXPOverride(SkillType skillType, int newValue) {
// if (skillType.equals(SkillType.ALL)) {
// for (SkillType x : SkillType.values()) {
// if (x.equals(SkillType.ALL)) {
// continue;
// }
//
// mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerXpGainEvent(player, x, newValue));
// skillsXp.put(x, skillsXp.get(x) + newValue);
// }
// }
// else {
// mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerXpGainEvent(player, skillType, newValue));
// skillsXp.put(skillType, skillsXp.get(skillType) + newValue);
// spoutHud.setLastGained(skillType);
// }
// }
// /**
// * Adds XP to the player, this ignores skill modifiers.
// *
// * @param skillType The skill to add XP to
// * @param newValue The amount of XP to add
// */
// public void addXPOverrideBonus(SkillType skillType, int newValue) {
// int xp = newValue * Config.getInstance().xpGainMultiplier;
// addXPOverride(skillType, xp);
// }
// /**
// * Adds XP to the player, this ignores skill modifiers.
// *
// * @param skillType The skill to add XP to
// * @param newValue The amount of XP to add
// */
// public void addXPOverrideBonus(SkillType skillType, int newValue) {
// int xp = newValue * Config.getInstance().xpGainMultiplier;
// addXPOverride(skillType, xp);
// }
// /**
// * Adds XP to the player, this is affected by skill modifiers and XP Rate and Permissions
// *
// * @param skillType The skill to add XP to
// * @param newvalue The amount of XP to add
// */
// public void addXP(SkillType skillType, int newValue) {
// if (player.getGameMode().equals(GameMode.CREATIVE)) {
// return;
// }
//
// double bonusModifier = 0;
//
// if (inParty()) {
// bonusModifier = partyModifier(skillType);
// }
//
// int xp = (int) (newValue / skillType.getXpModifier()) * Config.getInstance().xpGainMultiplier;
//
// if (bonusModifier > 0) {
// if (bonusModifier >= 2) {
// bonusModifier = 2;
// }
//
// double trueBonus = bonusModifier * xp;
// xp += trueBonus;
// }
//
// if (Config.getInstance().getToolModsEnabled()) {
// ItemStack item = player.getItemInHand();
// CustomTool tool = ModChecks.getToolFromItemStack(item);
//
// if (tool != null) {
// xp = (int) (xp * tool.getXpMultiplier());
// }
// }
//
// //TODO: Can we make this so we do perks by doing "mcmmo.perks.xp.[multiplier]" ?
// if (player.hasPermission("mcmmo.perks.xp.quadruple")) {
// xp = xp * 4;
// }
// else if (player.hasPermission("mcmmo.perks.xp.triple")) {
// xp = xp * 3;
// }
// else if (player.hasPermission("mcmmo.perks.xp.150percentboost")) {
// xp = (int) (xp * 2.5);
// }
// else if (player.hasPermission("mcmmo.perks.xp.double")) {
// xp = xp * 2;
// }
// else if (player.hasPermission("mcmmo.perks.xp.50percentboost")) {
// xp = (int) (xp * 1.5);
// }
//
// mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerXpGainEvent(player, skillType, xp));
// skillsXp.put(skillType, skillsXp.get(skillType) + xp);
// spoutHud.setLastGained(skillType);
// }
// /**
// * Adds XP to the player, this is affected by skill modifiers and XP Rate and Permissions
// *
// * @param skillType The skill to add XP to
// * @param newvalue The amount of XP to add
// */
// public void addXP(SkillType skillType, int newValue) {
// if (player.getGameMode().equals(GameMode.CREATIVE)) {
// return;
// }
//
// double bonusModifier = 0;
//
// if (inParty()) {
// bonusModifier = partyModifier(skillType);
// }
//
// int xp = (int) (newValue / skillType.getXpModifier()) * Config.getInstance().xpGainMultiplier;
//
// if (bonusModifier > 0) {
// if (bonusModifier >= 2) {
// bonusModifier = 2;
// }
//
// double trueBonus = bonusModifier * xp;
// xp += trueBonus;
// }
//
// if (Config.getInstance().getToolModsEnabled()) {
// ItemStack item = player.getItemInHand();
// CustomTool tool = ModChecks.getToolFromItemStack(item);
//
// if (tool != null) {
// xp = (int) (xp * tool.getXpMultiplier());
// }
// }
//
// //TODO: Can we make this so we do perks by doing "mcmmo.perks.xp.[multiplier]" ?
// if (player.hasPermission("mcmmo.perks.xp.quadruple")) {
// xp = xp * 4;
// }
// else if (player.hasPermission("mcmmo.perks.xp.triple")) {
// xp = xp * 3;
// }
// else if (player.hasPermission("mcmmo.perks.xp.150percentboost")) {
// xp = (int) (xp * 2.5);
// }
// else if (player.hasPermission("mcmmo.perks.xp.double")) {
// xp = xp * 2;
// }
// else if (player.hasPermission("mcmmo.perks.xp.50percentboost")) {
// xp = (int) (xp * 1.5);
// }
//
// mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerXpGainEvent(player, skillType, xp));
// skillsXp.put(skillType, skillsXp.get(skillType) + xp);
// spoutHud.setLastGained(skillType);
// }
/**
* Remove XP from a skill.
@ -1114,49 +1114,49 @@ public class PlayerProfile {
return 1020 + (skills.get(skillType) * Config.getInstance().getFormulaMultiplierCurve());
}
// /**
// * Gets the power level of a player.
// *
// * @return the power level of the player
// */
// public int getPowerLevel() {
// int powerLevel = 0;
//
// for (SkillType type : SkillType.values()) {
// if (type.getPermissions(player)) {
// powerLevel += getSkillLevel(type);
// }
// }
//
// return powerLevel;
// }
// /**
// * Gets the power level of a player.
// *
// * @return the power level of the player
// */
// public int getPowerLevel() {
// int powerLevel = 0;
//
// for (SkillType type : SkillType.values()) {
// if (type.getPermissions(player)) {
// powerLevel += getSkillLevel(type);
// }
// }
//
// return powerLevel;
// }
// /**
// * Calculate the party XP modifier.
// *
// * @param skillType Type of skill to check
// * @return the party bonus multiplier
// */
// private double partyModifier(SkillType skillType) {
// double bonusModifier = 0.0;
//
// for (Player member : party.getOnlineMembers()) {
// if (party.getLeader().equals(member.getName())) {
// if (Misc.isNear(player.getLocation(), member.getLocation(), 25.0)) {
// PlayerProfile PartyLeader = Users.getProfile(member);
// int leaderSkill = PartyLeader.getSkillLevel(skillType);
// int playerSkill = getSkillLevel(skillType);
//
// if (leaderSkill >= playerSkill) {
// int difference = leaderSkill - playerSkill;
// bonusModifier = (difference * 0.75) / 100.0;
// }
// }
// }
// }
//
// return bonusModifier;
// }
// /**
// * Calculate the party XP modifier.
// *
// * @param skillType Type of skill to check
// * @return the party bonus multiplier
// */
// private double partyModifier(SkillType skillType) {
// double bonusModifier = 0.0;
//
// for (Player member : party.getOnlineMembers()) {
// if (party.getLeader().equals(member.getName())) {
// if (Misc.isNear(player.getLocation(), member.getLocation(), 25.0)) {
// PlayerProfile PartyLeader = Users.getProfile(member);
// int leaderSkill = PartyLeader.getSkillLevel(skillType);
// int playerSkill = getSkillLevel(skillType);
//
// if (leaderSkill >= playerSkill) {
// int difference = leaderSkill - playerSkill;
// bonusModifier = (difference * 0.75) / 100.0;
// }
// }
// }
// }
//
// return bonusModifier;
// }
/*
* Party Stuff

View File

@ -9,7 +9,7 @@ public class McmmoButton extends GenericButton {
this.setText(text);
this.setTooltip(toolTip);
}
public void connect(Slot slot) {
this.slot = slot;
}

View File

@ -32,7 +32,7 @@ public class XpBar {
case RETRO:
initializeXpBarRetro();
break;
case STANDARD:
initializeXpBarStandard();
break;
@ -44,7 +44,7 @@ public class XpBar {
case DISABLED:
break;
}
spoutPlayer.getMainScreen().setDirty(true);
}
@ -77,7 +77,7 @@ public class XpBar {
xpFill.setTopColor(green);
xpFill.setPriority(RenderPriority.Lowest);
spoutPlayer.getMainScreen().attachWidget(mcMMO.p, xpFill);
xpBackground.setWidth(126);
xpBackground.setHeight(2);
xpBackground.setX(150);
@ -231,44 +231,44 @@ public class XpBar {
private static Color getRetroColor(SkillType type) {
switch (type) {
case ACROBATICS:
return new Color((float) SpoutConfig.getInstance().getRetroHUDAcrobaticsRed(), (float) SpoutConfig.getInstance().getRetroHUDAcrobaticsGreen(), (float) SpoutConfig.getInstance().getRetroHUDAcrobaticsBlue(), 1f);
case ACROBATICS:
return new Color((float) SpoutConfig.getInstance().getRetroHUDAcrobaticsRed(), (float) SpoutConfig.getInstance().getRetroHUDAcrobaticsGreen(), (float) SpoutConfig.getInstance().getRetroHUDAcrobaticsBlue(), 1f);
case ARCHERY:
return new Color((float) SpoutConfig.getInstance().getRetroHUDArcheryRed(), (float) SpoutConfig.getInstance().getRetroHUDArcheryGreen(), (float) SpoutConfig.getInstance().getRetroHUDArcheryBlue(), 1f);
case ARCHERY:
return new Color((float) SpoutConfig.getInstance().getRetroHUDArcheryRed(), (float) SpoutConfig.getInstance().getRetroHUDArcheryGreen(), (float) SpoutConfig.getInstance().getRetroHUDArcheryBlue(), 1f);
case AXES:
return new Color((float) SpoutConfig.getInstance().getRetroHUDAxesRed(), (float) SpoutConfig.getInstance().getRetroHUDAxesGreen(), (float) SpoutConfig.getInstance().getRetroHUDAxesBlue(), 1f);
case AXES:
return new Color((float) SpoutConfig.getInstance().getRetroHUDAxesRed(), (float) SpoutConfig.getInstance().getRetroHUDAxesGreen(), (float) SpoutConfig.getInstance().getRetroHUDAxesBlue(), 1f);
case EXCAVATION:
return new Color((float) SpoutConfig.getInstance().getRetroHUDExcavationRed(), (float) SpoutConfig.getInstance().getRetroHUDExcavationGreen(), (float) SpoutConfig.getInstance().getRetroHUDExcavationBlue(), 1f);
case EXCAVATION:
return new Color((float) SpoutConfig.getInstance().getRetroHUDExcavationRed(), (float) SpoutConfig.getInstance().getRetroHUDExcavationGreen(), (float) SpoutConfig.getInstance().getRetroHUDExcavationBlue(), 1f);
case HERBALISM:
return new Color((float) SpoutConfig.getInstance().getRetroHUDHerbalismRed(), (float) SpoutConfig.getInstance().getRetroHUDHerbalismGreen(), (float) SpoutConfig.getInstance().getRetroHUDHerbalismBlue(), 1f);
case HERBALISM:
return new Color((float) SpoutConfig.getInstance().getRetroHUDHerbalismRed(), (float) SpoutConfig.getInstance().getRetroHUDHerbalismGreen(), (float) SpoutConfig.getInstance().getRetroHUDHerbalismBlue(), 1f);
case MINING:
return new Color((float) SpoutConfig.getInstance().getRetroHUDMiningRed(), (float) SpoutConfig.getInstance().getRetroHUDMiningGreen(), (float) SpoutConfig.getInstance().getRetroHUDMiningBlue(), 1f);
case MINING:
return new Color((float) SpoutConfig.getInstance().getRetroHUDMiningRed(), (float) SpoutConfig.getInstance().getRetroHUDMiningGreen(), (float) SpoutConfig.getInstance().getRetroHUDMiningBlue(), 1f);
case REPAIR:
return new Color((float) SpoutConfig.getInstance().getRetroHUDRepairRed(), (float) SpoutConfig.getInstance().getRetroHUDRepairGreen(), (float) SpoutConfig.getInstance().getRetroHUDRepairBlue(), 1f);
case REPAIR:
return new Color((float) SpoutConfig.getInstance().getRetroHUDRepairRed(), (float) SpoutConfig.getInstance().getRetroHUDRepairGreen(), (float) SpoutConfig.getInstance().getRetroHUDRepairBlue(), 1f);
case SWORDS:
return new Color((float) SpoutConfig.getInstance().getRetroHUDSwordsRed(), (float) SpoutConfig.getInstance().getRetroHUDSwordsGreen(), (float) SpoutConfig.getInstance().getRetroHUDSwordsBlue(), 1f);
case SWORDS:
return new Color((float) SpoutConfig.getInstance().getRetroHUDSwordsRed(), (float) SpoutConfig.getInstance().getRetroHUDSwordsGreen(), (float) SpoutConfig.getInstance().getRetroHUDSwordsBlue(), 1f);
case TAMING:
return new Color((float) SpoutConfig.getInstance().getRetroHUDTamingRed(), (float) SpoutConfig.getInstance().getRetroHUDTamingGreen(), (float) SpoutConfig.getInstance().getRetroHUDTamingBlue(), 1f);
case TAMING:
return new Color((float) SpoutConfig.getInstance().getRetroHUDTamingRed(), (float) SpoutConfig.getInstance().getRetroHUDTamingGreen(), (float) SpoutConfig.getInstance().getRetroHUDTamingBlue(), 1f);
case UNARMED:
return new Color((float) SpoutConfig.getInstance().getRetroHUDUnarmedRed(), (float) SpoutConfig.getInstance().getRetroHUDUnarmedGreen(), (float) SpoutConfig.getInstance().getRetroHUDUnarmedBlue(), 1f);
case UNARMED:
return new Color((float) SpoutConfig.getInstance().getRetroHUDUnarmedRed(), (float) SpoutConfig.getInstance().getRetroHUDUnarmedGreen(), (float) SpoutConfig.getInstance().getRetroHUDUnarmedBlue(), 1f);
case WOODCUTTING:
return new Color((float) SpoutConfig.getInstance().getRetroHUDWoodcuttingRed(), (float) SpoutConfig.getInstance().getRetroHUDWoodcuttingGreen(), (float) SpoutConfig.getInstance().getRetroHUDWoodcuttingBlue(), 1f);
case WOODCUTTING:
return new Color((float) SpoutConfig.getInstance().getRetroHUDWoodcuttingRed(), (float) SpoutConfig.getInstance().getRetroHUDWoodcuttingGreen(), (float) SpoutConfig.getInstance().getRetroHUDWoodcuttingBlue(), 1f);
case FISHING:
return new Color((float) SpoutConfig.getInstance().getRetroHUDFishingRed(), (float) SpoutConfig.getInstance().getRetroHUDFishingGreen(), (float) SpoutConfig.getInstance().getRetroHUDFishingBlue(), 1f);
case FISHING:
return new Color((float) SpoutConfig.getInstance().getRetroHUDFishingRed(), (float) SpoutConfig.getInstance().getRetroHUDFishingGreen(), (float) SpoutConfig.getInstance().getRetroHUDFishingBlue(), 1f);
default:
return new Color(0.3f, 0.3f, 0.75f, 1f);
default:
return new Color(0.3f, 0.3f, 0.75f, 1f);
}
}

View File

@ -84,8 +84,8 @@ public class BlockListener implements Listener {
*
* @param event The event to monitor
*/
// Disabled until a better patch can be applied. This does nothing but flag the wrong block.
/*
// Disabled until a better patch can be applied. This does nothing but flag the wrong block.
/*
@EventHandler(priority = EventPriority.MONITOR)
public void onBlockPhysics(BlockPhysicsEvent event) {
//TODO: Figure out how to REMOVE metadata from the location the sand/gravel fell from.
@ -99,7 +99,7 @@ public class BlockListener implements Listener {
}
}
}
*/
*/
/**
* Monitor BlockPistonRetract events.
@ -127,7 +127,7 @@ public class BlockListener implements Listener {
Player player = event.getPlayer();
int id = block.getTypeId();
Material type = block.getType();
if(player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
/* Code to prevent issues with placed falling Sand/Gravel not being tracked */
@ -171,9 +171,9 @@ public class BlockListener implements Listener {
}
Player player = event.getPlayer();
if(player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
PlayerProfile profile = Users.getProfile(player);
if (profile == null) {
@ -284,11 +284,11 @@ public class BlockListener implements Listener {
final int LEAF_BLOWER_LEVEL = 100;
Player player = event.getPlayer();
if(player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
PlayerProfile profile = Users.getProfile(player);
if (profile == null) {
return;
}

View File

@ -66,7 +66,7 @@ public class EntityListener implements Listener {
Entity attacker = event.getDamager();
Entity defender = event.getEntity();
if(attacker.hasMetadata("NPC") || defender.hasMetadata("NPC")) return; // Check if either players is are Citizens NPCs
if (attacker instanceof Projectile) {
@ -120,7 +120,7 @@ public class EntityListener implements Listener {
DamageCause cause = event.getCause();
if(entity.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
if (!(entity instanceof LivingEntity)) {
return;
}
@ -178,7 +178,7 @@ public class EntityListener implements Listener {
@EventHandler (priority = EventPriority.MONITOR)
public void onEntityDeath(EntityDeathEvent event) {
LivingEntity entity = event.getEntity();
if(entity.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
entity.setFireTicks(0);
@ -208,9 +208,9 @@ public class EntityListener implements Listener {
@EventHandler (priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onExplosionPrime(ExplosionPrimeEvent event) {
Entity entity = event.getEntity();
if(entity.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
if (entity instanceof TNTPrimed) {
int id = entity.getEntityId();
@ -234,7 +234,7 @@ public class EntityListener implements Listener {
Entity entity = event.getEntity();
if(entity == null) return;
if(entity.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
if (entity instanceof TNTPrimed) {
@ -255,12 +255,12 @@ public class EntityListener implements Listener {
*/
@EventHandler (priority = EventPriority.LOW)
public void onFoodLevelChange(FoodLevelChangeEvent event) {
AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
if (event.getEntity() instanceof Player) {
Player player = (Player) event.getEntity();
if(player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
PlayerProfile profile = Users.getProfile(player);
int currentFoodLevel = player.getFoodLevel();
int newFoodLevel = event.getFoodLevel();
@ -394,9 +394,9 @@ public class EntityListener implements Listener {
@EventHandler (priority = EventPriority.MONITOR)
public void onEntityTame(EntityTameEvent event) {
Player player = (Player) event.getOwner();
if(player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
if (Permissions.getInstance().taming(player) && !event.getEntity().hasMetadata("mcmmoSummoned")) {
PlayerProfile profile = Users.getProfile(player);
EntityType type = event.getEntityType();

View File

@ -20,7 +20,7 @@ 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
if(player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
if (!Permissions.getInstance().hardcoremodeBypass(player)) {

View File

@ -47,7 +47,7 @@ import com.gmail.nossr50.util.Skills;
import com.gmail.nossr50.util.Users;
public class PlayerListener implements Listener {
private final mcMMO plugin;
public PlayerListener(final mcMMO plugin) {
@ -62,9 +62,9 @@ public class PlayerListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerWorldChangeEvent(PlayerChangedWorldEvent event) {
Player player = event.getPlayer();
if(player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
PlayerProfile profile = Users.getProfile(player);
if (profile == null) {
@ -93,10 +93,10 @@ public class PlayerListener implements Listener {
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerFish(PlayerFishEvent event) {
AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
int shakeUnlockLevel = advancedConfig.getShakeUnlockLevel();
Player player = event.getPlayer();
if(player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
if (Permissions.getInstance().fishing(player)) {
@ -130,9 +130,9 @@ public class PlayerListener implements Listener {
*/
@EventHandler(ignoreCancelled = true)
public void onPlayerPickupItem(PlayerPickupItemEvent event) {
if(event.getPlayer().hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
if(event.getPlayer().hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
PlayerProfile profile = Users.getProfile(event.getPlayer());
if (profile == null) {
@ -140,7 +140,7 @@ public class PlayerListener implements Listener {
}
if (profile.getAbilityMode(AbilityType.BERSERK)) {
event.setCancelled(true);
event.setCancelled(true);
}
}
@ -151,7 +151,7 @@ public class PlayerListener implements Listener {
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerLogin(PlayerLoginEvent event) {
if(event.getPlayer().hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
if(event.getPlayer().hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
Users.addUser(event.getPlayer()).getProfile().actualizeRespawnATS();
}
@ -163,7 +163,7 @@ public class PlayerListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerQuit(PlayerQuitEvent event) {
Player player = event.getPlayer();
if(player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
/* GARBAGE COLLECTION */
@ -180,7 +180,7 @@ public class PlayerListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
if(player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
//TODO: Locale ALL the things.
@ -199,7 +199,7 @@ public class PlayerListener implements Listener {
player.sendMessage(prefix + ChatColor.DARK_RED + "Hardcore enabled.");
player.sendMessage(prefix + ChatColor.DARK_AQUA + "Skill Death Penalty: " + ChatColor.DARK_RED + Config.getInstance().getHardcoreDeathStatPenaltyPercentage() + "%");
}
}
}
if (player.hasPermission("mcmmo.perks.xp.quadruple")) {
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.xp.name"), LocaleLoader.getString("Perks.xp.desc", new Object[] { 4 }) }));
@ -287,7 +287,7 @@ public class PlayerListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerRespawn(PlayerRespawnEvent event) {
if(event.getPlayer().hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
if(event.getPlayer().hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
PlayerProfile profile = Users.getProfile(event.getPlayer());
if (profile != null) {
@ -331,8 +331,8 @@ public class PlayerListener implements Listener {
/* SALVAGE CHECKS */
if (Permissions.getInstance().salvage(player) && block.getTypeId() == Config.getInstance().getSalvageAnvilId()) {
if (Salvage.isSalvageable(inHand)) {
final Location location = block.getLocation();
Salvage.handleSalvage(player, location, inHand);
final Location location = block.getLocation();
Salvage.handleSalvage(player, location, inHand);
event.setCancelled(true);
player.updateInventory();
}
@ -424,9 +424,9 @@ public class PlayerListener implements Listener {
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onPlayerChat(AsyncPlayerChatEvent event) {
Player player = event.getPlayer();
if(player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
PlayerProfile profile = Users.getProfile(player);
if (profile == null) {

View File

@ -145,10 +145,10 @@ public class mcMMO extends JavaPlugin {
repairables.addAll(rManager.getLoadedRepairables());
repairManager = RepairManagerFactory.getRepairManager(repairables.size());
repairManager.registerRepairables(repairables);
//Check if Repair Anvil and Salvage Anvil have different itemID's
if (configInstance.getSalvageAnvilId() == configInstance.getRepairAnvilId()){
System.out.println("[WARNING!] Can't use the same itemID for Repair/Salvage Anvils!" );
System.out.println("[WARNING!] Can't use the same itemID for Repair/Salvage Anvils!" );
}
if (!configInstance.getUseMySQL()) {

View File

@ -374,7 +374,7 @@ public class PartyManager {
*/
private void loadParties() {
File file = new File(partiesFilePath);
if (!file.exists()) {
return;
}

View File

@ -91,7 +91,7 @@ public class BleedTimer implements Runnable {
if (bleedList.containsKey(entity)) {
Combat.dealDamage(entity, bleedList.get(entity) * 2);
bleedList.remove(entity);
}
}
}
/**

View File

@ -221,9 +221,9 @@ public class SQLConversionTask implements Runnable {
+ playerName + "',"
+ System.currentTimeMillis() / 1000 + ")");
id = database.getInt("SELECT id FROM "
+ tablePrefix
+ "users WHERE user = '"
+ playerName + "'");
+ tablePrefix
+ "users WHERE user = '"
+ playerName + "'");
database.write("INSERT INTO "
+ tablePrefix
+ "skills (user_id) VALUES (" + id + ")");

View File

@ -20,8 +20,8 @@ public class BlockStoreConversionMain implements Runnable {
this.taskID = -1;
this.world = world;
this.scheduler = mcMMO.p.getServer().getScheduler();
this.dataDir = new File(this.world.getWorldFolder(), "mcmmo_data");
this.converters = new BlockStoreConversionXDirectory[HiddenConfig.getInstance().getConversionRate()];
this.dataDir = new File(this.world.getWorldFolder(), "mcmmo_data");
this.converters = new BlockStoreConversionXDirectory[HiddenConfig.getInstance().getConversionRate()];
}
public void start() {
@ -32,6 +32,7 @@ public class BlockStoreConversionMain implements Runnable {
return;
}
@Override
public void run() {
if(!this.dataDir.exists()) {
softStop();

View File

@ -33,6 +33,7 @@ public class BlockStoreConversionXDirectory implements Runnable {
return;
}
@Override
public void run() {
if(!this.dataDir.exists()) {
stop();
@ -51,7 +52,7 @@ public class BlockStoreConversionXDirectory implements Runnable {
return;
}
this.zDirs = this.dataDir.listFiles();
this.zDirs = this.dataDir.listFiles();
for (this.i = 0; (this.i < HiddenConfig.getInstance().getConversionRate()) && (this.i < this.zDirs.length); this.i++) {
if(this.converters[this.i] == null)
@ -70,10 +71,10 @@ public class BlockStoreConversionXDirectory implements Runnable {
this.scheduler.cancelTask(this.taskID);
this.taskID = -1;
this.dataDir = null;
this.zDirs = null;
this.world = null;
this.scheduler = null;
this.converters = null;
this.dataDir = null;
this.zDirs = null;
this.world = null;
this.scheduler = null;
this.converters = null;
}
}

View File

@ -47,6 +47,7 @@ public class BlockStoreConversionZDirectory implements Runnable {
return;
}
@Override
public void run() {
if(!this.dataDir.exists()) {
stop();
@ -84,7 +85,7 @@ public class BlockStoreConversionZDirectory implements Runnable {
for(this.y = 0; this.y < (this.world.getMaxHeight() / 64); this.y++) {
this.chunkletName = this.world.getName() + "," + this.cx + "," + this.cz + "," + this.y;
this.tempChunklet = this.manager.store.get(this.chunkletName);
this.tempChunklet = this.manager.store.get(this.chunkletName);
if(this.tempChunklet instanceof PrimitiveChunkletStore)
this.primitiveChunklet = (PrimitiveChunkletStore) this.tempChunklet;
else if(this.tempChunklet instanceof PrimitiveExChunkletStore)
@ -119,7 +120,7 @@ public class BlockStoreConversionZDirectory implements Runnable {
}
this.newManager.setTrue(this.cx * 16, 0, this.cz * 16, this.world);
this.newManager.setFalse(this.cx * 16, 0, this.cz * 16, this.world);
this.newManager.setFalse(this.cx * 16, 0, this.cz * 16, this.world);
this.currentChunk = (PrimitiveChunkStore) this.newManager.store.get(this.chunkName);
for(this.x = 0; this.x < 16; this.x++) {

View File

@ -18,7 +18,7 @@ public class Archery {
private static List<TrackedEntity> trackedEntities = new ArrayList<TrackedEntity>();
public static final int ARROW_TRACKING_MAX_BONUS_LEVEL = advancedConfig.getRetrieveMaxBonusLevel();
public static final int BONUS_DAMAGE_INCREASE_LEVEL = advancedConfig.getSkillShotIncreaseLevel();
public static final double BONUS_DAMAGE_INCREASE_PERCENT = advancedConfig.getSkillShotIncreasePercentage();
public static final double BONUS_DAMAGE_MAX_BONUS_PERCENTAGE = advancedConfig.getSkillShotBonusMax();

View File

@ -12,7 +12,7 @@ import com.gmail.nossr50.util.Users;
public class ArcheryManager {
AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
private Player player;
private PlayerProfile profile;
private int skillLevel;
@ -22,15 +22,15 @@ public class ArcheryManager {
private float dazeMaxBonusLevel = advancedConfig.getDazeMaxBonusLevel();
private float retrieveBonusMax = advancedConfig.getRetrieveBonusMax();
private float retrieveMaxBonusLevel = advancedConfig.getRetrieveMaxBonusLevel();
public ArcheryManager (Player player) {
this.player = player;
this.profile = Users.getProfile(player);
//Compatibility with Citizens, Citizens NPCs won't create a profile so we'll check for it here
if(this.profile == null)
return;
this.skillLevel = profile.getSkillLevel(SkillType.ARCHERY);
this.permissionsInstance = Permissions.getInstance();
}
@ -57,7 +57,7 @@ public class ArcheryManager {
if (player.hasPermission("mcmmo.perks.lucky.archery")) {
randomChance = (int) (randomChance * 0.75);
}
final float chance = (float) (((double) retrieveBonusMax / (double) retrieveMaxBonusLevel) * (double) skillLevel);
final float chance = (float) (((double) retrieveBonusMax / (double) retrieveMaxBonusLevel) * skillLevel);
if (chance > Archery.getRandom().nextInt(randomChance)) {
eventHandler.addToTracker();
}
@ -81,14 +81,14 @@ public class ArcheryManager {
}
DazeEventHandler eventHandler = new DazeEventHandler(this, event, defender);
int randomChance = 100;
if (player.hasPermission("mcmmo.perks.lucky.archery")) {
randomChance = (int) (randomChance * 0.75);
}
final float chance = (float) (((double) dazeBonusMax / (double) dazeMaxBonusLevel) * (double) skillLevel);
final float chance = (float) (((double) dazeBonusMax / (double) dazeMaxBonusLevel) * skillLevel);
if (chance > Archery.getRandom().nextInt(randomChance)) {
eventHandler.handleDazeEffect();
eventHandler.sendAbilityMessages();

View File

@ -87,14 +87,14 @@ public class Axes {
int skillCheck = Misc.skillCheck(skillLevel, MAX_BONUS_LEVEL);
int randomChance = 100;
double chance = ((double) MAX_CHANCE / (double) MAX_BONUS_LEVEL) * (double) skillCheck;
double chance = (MAX_CHANCE / MAX_BONUS_LEVEL) * skillCheck;
if (attacker.hasPermission("mcmmo.perks.lucky.axes")) {
randomChance = (int) (randomChance * 0.75);
}
if (chance > random.nextInt(randomChance) && !entity.isDead()){
// if (random.nextInt(randomChance) <= skillCheck && !entity.isDead()){
// if (random.nextInt(randomChance) <= skillCheck && !entity.isDead()){
int damage = event.getDamage();
if (entity instanceof Player){
@ -158,7 +158,7 @@ public class Axes {
private static void applyGreaterImpact(Player attacker, LivingEntity target, EntityDamageByEntityEvent event) {
if(attacker == null)
return;
final int GREATER_IMPACT_CHANCE = advancedConfig.getGreaterImpactChance();
final double GREATER_IMPACT_MULTIPLIER = advancedConfig.getGreaterImpactModifier();
final int GREATER_IMPACT_DAMAGE = advancedConfig.getGreaterImpactBonusDamage();

View File

@ -31,7 +31,7 @@ public class BlastMining {
static AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
private static Random random = new Random();
private static int blastMiningRank1 = advancedConfig.getBlastMiningRank1();
private static int blastMiningRank2 = advancedConfig.getBlastMiningRank2();
private static int blastMiningRank3 = advancedConfig.getBlastMiningRank3();
@ -317,7 +317,7 @@ public class BlastMining {
player.sendMessage(LocaleLoader.getString("Mining.Blast.Boom"));
/* Create the TNT entity */
// TNTPrimed tnt = (TNTPrimed) player.getWorld().spawnEntity(block.getLocation(), EntityType.PRIMED_TNT);
// TNTPrimed tnt = (TNTPrimed) player.getWorld().spawnEntity(block.getLocation(), EntityType.PRIMED_TNT);
TNTPrimed tnt = player.getWorld().spawn(block.getLocation(), TNTPrimed.class);
plugin.addToTNTTracker(tnt.getEntityId(), player.getName());
tnt.setFuseTicks(0);

View File

@ -40,8 +40,9 @@ public class Fishing {
/**
* Get the player's current fishing loot tier.
*
* @param profile The profile of the player
*
* @param profile
* The profile of the player
* @return the player's current fishing rank
*/
public static int getFishingLootTier(PlayerProfile profile) {
@ -50,18 +51,14 @@ public class Fishing {
if (level >= Config.getInstance().getFishingTierLevelsTier5()) {
fishingTier = 5;
}
else if (level >= Config.getInstance().getFishingTierLevelsTier4()) {
} else if (level >= Config.getInstance().getFishingTierLevelsTier4()) {
fishingTier = 4;
}
else if (level >= Config.getInstance().getFishingTierLevelsTier3()) {
fishingTier = 3;
}
else if (level >= Config.getInstance().getFishingTierLevelsTier2()) {
fishingTier = 2;
}
else {
fishingTier = 1;
} else if (level >= Config.getInstance().getFishingTierLevelsTier3()) {
fishingTier = 3;
} else if (level >= Config.getInstance().getFishingTierLevelsTier2()) {
fishingTier = 2;
} else {
fishingTier = 1;
}
return fishingTier;
@ -69,12 +66,14 @@ public class Fishing {
/**
* Get item results from Fishing.
*
* @param player The player that was fishing
* @param event The event to modify
*
* @param player
* The player that was fishing
* @param event
* The event to modify
*/
private static void getFishingResults(Player player, PlayerFishEvent event) {
if(player == null)
if (player == null)
return;
PlayerProfile profile = Users.getProfile(player);
@ -106,8 +105,10 @@ public class Fishing {
break;
}
if (Config.getInstance().getFishingDropsEnabled() && rewards.size() > 0 && Permissions.getInstance().fishingTreasures(player)) {
FishingTreasure treasure = rewards.get(random.nextInt(rewards.size()));
if (Config.getInstance().getFishingDropsEnabled() && rewards.size() > 0
&& Permissions.getInstance().fishingTreasures(player)) {
FishingTreasure treasure = rewards.get(random.nextInt(rewards
.size()));
int randomChance = 100;
@ -116,31 +117,37 @@ public class Fishing {
}
if (random.nextDouble() * randomChance <= treasure.getDropChance()) {
Users.getPlayer(player).addXP(SkillType.FISHING, treasure.getXp());
Users.getPlayer(player).addXP(SkillType.FISHING,
treasure.getXp());
theCatch.setItemStack(treasure.getDrop());
}
}
else {
} else {
theCatch.setItemStack(new ItemStack(Material.RAW_FISH));
}
short maxDurability = theCatch.getItemStack().getType().getMaxDurability();
short maxDurability = theCatch.getItemStack().getType()
.getMaxDurability();
if (maxDurability > 0) {
theCatch.getItemStack().setDurability((short) (random.nextInt(maxDurability))); //Change durability to random value
theCatch.getItemStack().setDurability(
(short) (random.nextInt(maxDurability))); // Change
// durability to
// random value
}
Skills.xpProcessing(player, profile, SkillType.FISHING, Config.getInstance().getFishingBaseXP());
Skills.xpProcessing(player, profile, SkillType.FISHING, Config
.getInstance().getFishingBaseXP());
}
/**
* Process results from Fishing.
*
* @param event The event to modify
*
* @param event
* The event to modify
*/
public static void processResults(PlayerFishEvent event) {
Player player = event.getPlayer();
if(player == null)
if (player == null)
return;
PlayerProfile profile = Users.getProfile(player);
@ -149,7 +156,8 @@ public class Fishing {
Item theCatch = (Item) event.getCaught();
if (theCatch.getItemStack().getType() != Material.RAW_FISH) {
final int ENCHANTMENT_CHANCE = advancedConfig.getFishingEnchantmentChance();
final int ENCHANTMENT_CHANCE = advancedConfig
.getFishingEnchantmentChance();
boolean enchanted = false;
ItemStack fishingResults = theCatch.getItemStack();
@ -162,29 +170,40 @@ public class Fishing {
randomChance = (int) (randomChance * 0.75);
}
if (random.nextInt(randomChance) <= ENCHANTMENT_CHANCE && Permissions.getInstance().fishingMagic(player)) {
if (random.nextInt(randomChance) <= ENCHANTMENT_CHANCE
&& Permissions.getInstance().fishingMagic(player)) {
for (Enchantment newEnchant : Enchantment.values()) {
if (newEnchant.canEnchantItem(fishingResults)) {
Map<Enchantment, Integer> resultEnchantments = fishingResults.getEnchantments();
Map<Enchantment, Integer> resultEnchantments = fishingResults
.getEnchantments();
for (Enchantment oldEnchant : resultEnchantments.keySet()) {
for (Enchantment oldEnchant : resultEnchantments
.keySet()) {
if (oldEnchant.conflictsWith(newEnchant))
continue;
}
/* Actual chance to have an enchantment is related to your fishing skill */
if (random.nextInt(15) < Fishing.getFishingLootTier(profile)) {
/*
* Actual chance to have an enchantment is related
* to your fishing skill
*/
if (random.nextInt(15) < Fishing
.getFishingLootTier(profile)) {
enchanted = true;
int randomEnchantLevel = random.nextInt(newEnchant.getMaxLevel()) + 1;
int randomEnchantLevel = random
.nextInt(newEnchant.getMaxLevel()) + 1;
if (randomEnchantLevel < newEnchant.getStartLevel()) {
randomEnchantLevel = newEnchant.getStartLevel();
if (randomEnchantLevel < newEnchant
.getStartLevel()) {
randomEnchantLevel = newEnchant
.getStartLevel();
}
if(randomEnchantLevel >= 1000)
if (randomEnchantLevel >= 1000)
continue;
fishingResults.addEnchantment(newEnchant, randomEnchantLevel);
fishingResults.addEnchantment(newEnchant,
randomEnchantLevel);
}
}
}
@ -199,8 +218,9 @@ public class Fishing {
/**
* Shake a mob, have them drop an item.
*
* @param event The event to modify
*
* @param event
* The event to modify
*/
public static void shakeMob(PlayerFishEvent event) {
int randomChance = 100;
@ -214,9 +234,10 @@ public class Fishing {
int lootTier = getFishingLootTier(profile);
int dropChance = getShakeChance(lootTier);
if (event.getPlayer().hasPermission("mcmmo.perks.lucky.fishing")) {
dropChance = (int) (dropChance * 1.25); //With lucky perk on max level tier, its 100%
dropChance = (int) (dropChance * 1.25); // With lucky perk on max
// level tier, its 100%
}
final int DROP_CHANCE = random.nextInt(100);
@ -263,7 +284,8 @@ public class Fishing {
case CREEPER:
if (DROP_NUMBER > 97) {
Misc.dropItem(location, new ItemStack(Material.SKULL_ITEM, 1, (short) 4));
Misc.dropItem(location, new ItemStack(Material.SKULL_ITEM,
1, (short) 4));
} else {
Misc.dropItem(location, new ItemStack(Material.SULPHUR));
}
@ -299,14 +321,17 @@ public class Fishing {
if (DROP_NUMBER > 95) {
Misc.dropItem(location, new ItemStack(Material.MILK_BUCKET));
} else if (DROP_NUMBER > 90) {
Misc.dropItem(location, new ItemStack(Material.MUSHROOM_SOUP));
Misc.dropItem(location, new ItemStack(
Material.MUSHROOM_SOUP));
} else if (DROP_NUMBER > 60) {
Misc.dropItem(location, new ItemStack(Material.LEATHER));
} else if (DROP_NUMBER > 30) {
Misc.dropItem(location, new ItemStack(Material.RAW_BEEF));
} else {
Misc.dropItem(location, new ItemStack(Material.RED_MUSHROOM));
Misc.randomDropItems(location, new ItemStack(Material.RED_MUSHROOM), 50, 2);
Misc.dropItem(location,
new ItemStack(Material.RED_MUSHROOM));
Misc.randomDropItems(location, new ItemStack(
Material.RED_MUSHROOM), 50, 2);
}
break;
@ -316,7 +341,8 @@ public class Fishing {
case PIG_ZOMBIE:
if (DROP_NUMBER > 50) {
Misc.dropItem(location, new ItemStack(Material.ROTTEN_FLESH));
Misc.dropItem(location,
new ItemStack(Material.ROTTEN_FLESH));
} else {
Misc.dropItem(location, new ItemStack(Material.GOLD_NUGGET));
}
@ -338,23 +364,27 @@ public class Fishing {
break;
case SKELETON:
if (((Skeleton)le).getSkeletonType() == SkeletonType.WITHER) {
if (((Skeleton) le).getSkeletonType() == SkeletonType.WITHER) {
if (DROP_NUMBER > 97) {
Misc.dropItem(location, new ItemStack(Material.SKULL_ITEM, 1, (short) 1));
Misc.dropItem(location, new ItemStack(
Material.SKULL_ITEM, 1, (short) 1));
} else if (DROP_NUMBER > 50) {
Misc.dropItem(location, new ItemStack(Material.BONE));
} else {
Misc.dropItem(location, new ItemStack(Material.COAL));
Misc.randomDropItems(location, new ItemStack(Material.COAL), 50, 2);
Misc.randomDropItems(location, new ItemStack(
Material.COAL), 50, 2);
}
} else {
if (DROP_NUMBER > 97) {
Misc.dropItem(location, new ItemStack(Material.SKULL_ITEM));
Misc.dropItem(location, new ItemStack(
Material.SKULL_ITEM));
} else if (DROP_NUMBER > 50) {
Misc.dropItem(location, new ItemStack(Material.BONE));
} else {
Misc.dropItem(location, new ItemStack(Material.ARROW));
Misc.randomDropItems(location, new ItemStack(Material.ARROW), 50, 2);
Misc.randomDropItems(location, new ItemStack(
Material.ARROW), 50, 2);
}
}
break;
@ -368,7 +398,8 @@ public class Fishing {
Misc.dropItem(location, new ItemStack(Material.PUMPKIN));
} else {
Misc.dropItem(location, new ItemStack(Material.SNOW_BALL));
Misc.randomDropItems(location, new ItemStack(Material.SNOW_BALL), 50, 4);
Misc.randomDropItems(location, new ItemStack(
Material.SNOW_BALL), 50, 4);
}
break;
@ -381,30 +412,38 @@ public class Fishing {
break;
case SQUID:
Misc.dropItem(location, new ItemStack(Material.INK_SACK, 1, (short) 0));
Misc.dropItem(location, new ItemStack(Material.INK_SACK, 1,
(short) 0));
break;
case WITCH:
final int DROP_NUMBER_2 = random.nextInt(randomChance) + 1;
if (DROP_NUMBER > 95) {
if (DROP_NUMBER_2 > 66) {
Misc.dropItem(location, new ItemStack(Material.POTION, 1, (short) 8197));
Misc.dropItem(location, new ItemStack(Material.POTION,
1, (short) 8197));
} else if (DROP_NUMBER_2 > 33) {
Misc.dropItem(location, new ItemStack(Material.POTION, 1, (short) 8195));
Misc.dropItem(location, new ItemStack(Material.POTION,
1, (short) 8195));
} else {
Misc.dropItem(location, new ItemStack(Material.POTION, 1, (short) 8194));
Misc.dropItem(location, new ItemStack(Material.POTION,
1, (short) 8194));
}
} else {
if (DROP_NUMBER_2 > 88) {
Misc.dropItem(location, new ItemStack(Material.GLASS_BOTTLE));
Misc.dropItem(location, new ItemStack(
Material.GLASS_BOTTLE));
} else if (DROP_NUMBER_2 > 75) {
Misc.dropItem(location, new ItemStack(Material.GLOWSTONE_DUST));
Misc.dropItem(location, new ItemStack(
Material.GLOWSTONE_DUST));
} else if (DROP_NUMBER_2 > 63) {
Misc.dropItem(location, new ItemStack(Material.SULPHUR));
} else if (DROP_NUMBER_2 > 50) {
Misc.dropItem(location, new ItemStack(Material.REDSTONE));
Misc.dropItem(location,
new ItemStack(Material.REDSTONE));
} else if (DROP_NUMBER_2 > 38) {
Misc.dropItem(location, new ItemStack(Material.SPIDER_EYE));
Misc.dropItem(location, new ItemStack(
Material.SPIDER_EYE));
} else if (DROP_NUMBER_2 > 25) {
Misc.dropItem(location, new ItemStack(Material.STICK));
} else if (DROP_NUMBER_2 > 13) {
@ -417,9 +456,11 @@ public class Fishing {
case ZOMBIE:
if (DROP_NUMBER > 97) {
Misc.dropItem(location, new ItemStack(Material.SKULL_ITEM, 1, (short) 2));
Misc.dropItem(location, new ItemStack(Material.SKULL_ITEM,
1, (short) 2));
} else {
Misc.dropItem(location, new ItemStack(Material.ROTTEN_FLESH));
Misc.dropItem(location,
new ItemStack(Material.ROTTEN_FLESH));
}
break;
@ -430,10 +471,12 @@ public class Fishing {
Combat.dealDamage(le, 1);
}
/**
* Gets chance of shake success.
*
* @param rank Treasure hunter rank
*
* @param rank
* Treasure hunter rank
* @return The chance of a successful shake
*/
public static int getShakeChance(int lootTier) {
@ -456,5 +499,5 @@ public class Fishing {
default:
return 10;
}
}
}
}

View File

@ -203,9 +203,9 @@ public class Herbalism {
xp = Config.getInstance().getHerbalismXPLilyPads();
}
break;
case COCOA:
if ((((byte) data) & 0x8) == 0x8) {
if (((data) & 0x8) == 0x8) {
mat = Material.COCOA;
xp = Config.getInstance().getHerbalismXPCocoa();
@ -341,7 +341,7 @@ public class Herbalism {
Misc.dropItem(location, is);
}
break;
case COCOA:
if (configInstance.getCocoaDoubleDropsEnabled()) {
Misc.dropItem(location, is);

View File

@ -87,7 +87,7 @@ public class Mining {
Misc.dropItem(location, item);
}
break;
case EMERALD_ORE:
if (configInstance.getEmeraldDoubleDropsEnabled()) {
Misc.dropItem(location, item);
@ -202,7 +202,7 @@ public class Mining {
Misc.dropItem(location, item);
}
break;
case EMERALD_ORE:
if (configInstance.getEmeraldDoubleDropsEnabled()) {
item = new ItemStack(Material.EMERALD);
@ -294,7 +294,7 @@ public class Mining {
case STONE:
xp += Config.getInstance().getMiningXPStone();
break;
case EMERALD_ORE:
xp += Config.getInstance().getMiningXPEmeraldOre();
break;
@ -324,12 +324,12 @@ public class Mining {
final int MAX_BONUS_LEVEL = advancedConfig.getMiningDoubleDropMaxLevel();
int MAX_CHANCE = advancedConfig.getMiningDoubleDropChance();
int skillLevel = Users.getProfile(player).getSkillLevel(SkillType.MINING);
int skillCheck = Misc.skillCheck(skillLevel, MAX_BONUS_LEVEL);
int randomChance = 100;
int chance = (int) (((double) MAX_CHANCE / (double) MAX_BONUS_LEVEL) * (double) skillCheck);
int chance = (int) (((double) MAX_CHANCE / (double) MAX_BONUS_LEVEL) * skillCheck);
if (player.hasPermission("mcmmo.perks.lucky.mining")) {
randomChance = (int) (randomChance * 0.75);

View File

@ -173,24 +173,24 @@ public class WoodCutting {
WoodCutting.woodCuttingProcCheck(player, x);
switch (species) {
case GENERIC:
xp += Config.getInstance().getWoodcuttingXPOak();
break;
case GENERIC:
xp += Config.getInstance().getWoodcuttingXPOak();
break;
case REDWOOD:
xp += Config.getInstance().getWoodcuttingXPSpruce();
break;
case REDWOOD:
xp += Config.getInstance().getWoodcuttingXPSpruce();
break;
case BIRCH:
xp += Config.getInstance().getWoodcuttingXPBirch();
break;
case BIRCH:
xp += Config.getInstance().getWoodcuttingXPBirch();
break;
case JUNGLE:
xp += Config.getInstance().getWoodcuttingXPJungle() / 2; //Nerf XP from Jungle Trees when using Tree Feller
break;
case JUNGLE:
xp += Config.getInstance().getWoodcuttingXPJungle() / 2; //Nerf XP from Jungle Trees when using Tree Feller
break;
default:
break;
default:
break;
}
}
@ -345,7 +345,7 @@ public class WoodCutting {
Material mat = Material.getMaterial(block.getTypeId());
int randomChance = 100;
int chance = (int) (((double) MAX_CHANCE / (double) MAX_BONUS_LEVEL) * (double) skillLevel);
int chance = (int) (((double) MAX_CHANCE / (double) MAX_BONUS_LEVEL) * skillLevel);
if (player.hasPermission("mcmmo.perks.lucky.woodcutting")) {
randomChance = (int) (randomChance * 0.75);
@ -438,7 +438,7 @@ public class WoodCutting {
type ^= 0x8;
TreeSpecies species = TreeSpecies.getByData(type);
//Apparently species can be null in certain cases (custom server mods?)
//https://github.com/mcMMO-Dev/mcMMO/issues/229
if(species == null)

View File

@ -224,7 +224,7 @@ public class Repair {
}
if(repairAmount <= 0 || repairAmount > 32767)
repairAmount = 32767;
repairAmount = 32767;
durability -= repairAmount;
@ -248,11 +248,11 @@ public class Repair {
int skillLevel = Users.getProfile(player).getSkillLevel(SkillType.REPAIR);
int randomChance = 100;
int chance = (int) (((double) MAX_CHANCE / (double) MAX_BONUS_LEVEL) * (double) skillLevel);
int chance = (int) (((double) MAX_CHANCE / (double) MAX_BONUS_LEVEL) * skillLevel);
if (skillLevel >= MAX_BONUS_LEVEL) chance = MAX_CHANCE;
if (player.hasPermission("mcmmo.perks.lucky.repair")) randomChance = (int) (randomChance * 0.75);
if (chance > random.nextInt(randomChance) && permInstance.repairBonus(player)){
player.sendMessage(LocaleLoader.getString("Repair.Skills.FeltEasy"));
return true;

View File

@ -29,27 +29,27 @@ public class Salvage {
}
if(player.getGameMode() == GameMode.SURVIVAL) {
final PlayerProfile profile = Users.getProfile(player);
final int skillLevel = profile.getSkillLevel(SkillType.REPAIR);
final int unlockLevel = configInstance.getSalvageUnlockLevel();
final PlayerProfile profile = Users.getProfile(player);
final int skillLevel = profile.getSkillLevel(SkillType.REPAIR);
final int unlockLevel = configInstance.getSalvageUnlockLevel();
if (skillLevel >= unlockLevel) {
final float currentdura = inHand.getDurability();
if (skillLevel >= unlockLevel) {
final float currentdura = inHand.getDurability();
if (currentdura == 0) {
final int salvagedAmount = getSalvagedAmount(inHand);
final int itemID = getSalvagedItemID(inHand);
if (currentdura == 0) {
final int salvagedAmount = getSalvagedAmount(inHand);
final int itemID = getSalvagedItemID(inHand);
player.setItemInHand(new ItemStack(0));
location.setY(location.getY() + 1);
Misc.dropItem(location, new ItemStack(itemID, salvagedAmount));
player.sendMessage(LocaleLoader.getString("Repair.Skills.SalvageSuccess"));
} else {
player.sendMessage(LocaleLoader.getString("Repair.Skills.NotFullDurability"));
}
} else {
player.sendMessage(LocaleLoader.getString("Repair.Skills.AdeptSalvage"));
}
player.setItemInHand(new ItemStack(0));
location.setY(location.getY() + 1);
Misc.dropItem(location, new ItemStack(itemID, salvagedAmount));
player.sendMessage(LocaleLoader.getString("Repair.Skills.SalvageSuccess"));
} else {
player.sendMessage(LocaleLoader.getString("Repair.Skills.NotFullDurability"));
}
} else {
player.sendMessage(LocaleLoader.getString("Repair.Skills.AdeptSalvage"));
}
}
}

View File

@ -38,12 +38,12 @@ public class SimpleRepairable implements Repairable {
@Override
public RepairItemType getRepairItemType() {
return repairItemType;
return repairItemType;
}
@Override
public RepairMaterialType getRepairMaterialType() {
return repairMaterialType;
return repairMaterialType;
}
@Override

View File

@ -6,7 +6,7 @@ import com.gmail.nossr50.config.AdvancedConfig;
public class Swords {
static AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
public static final int BLEED_MAX_BONUS_LEVEL = advancedConfig.getBleedMaxBonusLevel();
public static final int MAX_BLEED_TICKS = advancedConfig.getBleedMaxTicks();
public static final int BASE_BLEED_TICKS = advancedConfig.getBleedBaseTicks();

View File

@ -50,7 +50,7 @@ public class SwordsManager {
randomChance = (int) (randomChance * 0.75);
}
final float chance = (float) (((double) bleedChanceMax / (double) bleedMaxLevel) * (double) skillLevel);
final float chance = (float) (((double) bleedChanceMax / (double) bleedMaxLevel) * skillLevel);
if (chance > Swords.getRandom().nextInt(randomChance)) {
eventHandler.addBleedTicks();
eventHandler.sendAbilityMessages();
@ -81,7 +81,7 @@ public class SwordsManager {
randomChance = (int) (randomChance * 0.75);
}
final float chance = (float) (((double) counterChanceMax / (double) counterMaxLevel) * (double) skillLevel);
final float chance = (float) (((double) counterChanceMax / (double) counterMaxLevel) * skillLevel);
if (chance > Swords.getRandom().nextInt(randomChance)) {
eventHandler.dealDamage();
eventHandler.sendAbilityMessages();

View File

@ -6,7 +6,7 @@ import com.gmail.nossr50.config.AdvancedConfig;
public class Taming {
static AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
public static final int ENVIRONMENTALLY_AWARE_ACTIVATION_LEVEL = advancedConfig.getEnviromentallyAwareUnlock();
public static final int FAST_FOOD_SERVICE_ACTIVATION_CHANCE = advancedConfig.getFastFoodChance();

View File

@ -102,7 +102,7 @@ public class TamingManager {
}
GoreEventHandler eventHandler = new GoreEventHandler(this, event);
int goreChanceMax = AdvancedConfig.getInstance().getGoreChanceMax();
int goreMaxLevel = AdvancedConfig.getInstance().getGoreMaxBonusLevel();
int randomChance = 100;
@ -111,7 +111,7 @@ public class TamingManager {
randomChance = (int) (randomChance * 0.75);
}
final float chance = (float) (((double) goreChanceMax / (double) goreMaxLevel) * (double) skillLevel);
final float chance = (float) (((double) goreChanceMax / (double) goreMaxLevel) * skillLevel);
if (chance > Taming.getRandom().nextInt(randomChance)) {
eventHandler.modifyEventDamage();
eventHandler.applyBleed();
@ -281,9 +281,9 @@ public class TamingManager {
}
if (skillLevel >= Taming.THICK_FUR_ACTIVATION_LEVEL) {
ThickFurEventHandler eventHandler = new ThickFurEventHandler(event, cause);
ThickFurEventHandler eventHandler = new ThickFurEventHandler(event, cause);
eventHandler.modifyEventDamage();
eventHandler.modifyEventDamage();
}
}

View File

@ -6,7 +6,7 @@ import com.gmail.nossr50.config.AdvancedConfig;
public class Unarmed {
static AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
public static final int BONUS_DAMAGE_MAX_BONUS_MODIFIER = advancedConfig.getIronArmBonus();
public static final int BONUS_DAMAGE_INCREASE_LEVEL = advancedConfig.getIronArmIncreaseLevel();
public static final int DEFLECT_MAX_CHANCE = advancedConfig.getDisarmChanceMax() ;

View File

@ -51,7 +51,7 @@ public class UnarmedManager {
randomChance = (int) (randomChance * 0.75);
}
final float chance = (float) (((double) disarmChanceMax / (double) disarmMaxLevel) * (double) skillLevel);
final float chance = (float) (((double) disarmChanceMax / (double) disarmMaxLevel) * skillLevel);
if (chance > Unarmed.getRandom().nextInt(randomChance)) {
if (!hasIronGrip(defender)) {
eventHandler.sendAbilityMessage();
@ -83,12 +83,12 @@ public class UnarmedManager {
int deflectChanceMax = AdvancedConfig.getInstance().getDeflectChanceMax();
int deflectMaxLevel = AdvancedConfig.getInstance().getDeflectMaxBonusLevel();
int randomChance = 100;
if (player.hasPermission("mcmmo.perks.lucky.unarmed")) {
randomChance = (int) (randomChance * 0.75);
}
final float chance = (float) (((double) deflectChanceMax / (double) deflectMaxLevel) * (double) skillLevel);
final float chance = (float) (((double) deflectChanceMax / (double) deflectMaxLevel) * skillLevel);
if (chance > Unarmed.getRandom().nextInt(randomChance)) {
eventHandler.cancelEvent();
eventHandler.sendAbilityMessage();
@ -143,8 +143,8 @@ public class UnarmedManager {
if (defender.hasPermission("mcmmo.perks.lucky.unarmed")) {
randomChance = (int) (randomChance * 0.75);
}
final float chance = (float) (((double) ironGripChanceMax / (double) ironGripMaxLevel) * (double) skillLevel);
final float chance = (float) (((double) ironGripChanceMax / (double) ironGripMaxLevel) * skillLevel);
if (chance > Unarmed.getRandom().nextInt(randomChance)) {
eventHandler.sendAbilityMessages();
return true;

View File

@ -504,7 +504,7 @@ public class Combat {
if (Users.getProfile(defender).getGodMode()) {
return false;
}
//It may seem a bit redundant but we need a check here to prevent bleed from being applied in applyAbilityAoE()
EntityDamageEvent ede = new FakeEntityDamageByEntityEvent(player, entity, EntityDamageEvent.DamageCause.ENTITY_ATTACK, 1);
mcMMO.p.getServer().getPluginManager().callEvent(ede);

View File

@ -25,7 +25,7 @@ public class Database {
// Scale waiting time by this much per failed attempt
private static final double SCALING_FACTOR = 5;
// Minimum wait in nanoseconds (default 500ms)
private static final long MIN_WAIT = 500*100000L;
@ -37,7 +37,7 @@ public class Database {
// When next to try connecting to Database in nanoseconds
private static long nextReconnectTimestamp = 0L;
// How many connection attemtps have failed
private static int reconnectAttempt = 0;
@ -63,15 +63,15 @@ public class Database {
System.out.println("[mcMMO] Connection to MySQL was a success!");
}
catch (SQLException ex) {
connection = null;
connection = null;
System.out.println("[mcMMO] Connection to MySQL failed!");
ex.printStackTrace();
printErrors(ex);
} catch (ClassNotFoundException ex) {
connection = null;
connection = null;
System.out.println("[mcMMO] MySQL database driver not found!");
ex.printStackTrace();
}
}
}
/**
@ -186,20 +186,20 @@ public class Database {
break;
}
} finally {
if (resultSet != null) {
try {
resultSet.close();
} catch (SQLException e) {
// Ignore the error, we're leaving
}
}
if (statement != null) {
if (resultSet != null) {
try {
statement.close();
} catch (SQLException e) {
// Ignore the error, we're leaving
}
}
resultSet.close();
} catch (SQLException e) {
// Ignore the error, we're leaving
}
}
if (statement != null) {
try {
statement.close();
} catch (SQLException e) {
// Ignore the error, we're leaving
}
}
}
}
@ -211,7 +211,7 @@ public class Database {
*/
public boolean write(String sql) {
if (checkConnected()) {
PreparedStatement statement = null;
PreparedStatement statement = null;
try {
statement = connection.prepareStatement(sql);
statement.executeUpdate();
@ -221,14 +221,14 @@ public class Database {
printErrors(ex);
return false;
} finally {
if (statement != null) {
if (statement != null) {
try {
statement.close();
} catch (SQLException e) {
printErrors(e);
return false;
}
}
statement.close();
} catch (SQLException e) {
printErrors(e);
return false;
}
}
}
}
@ -270,93 +270,93 @@ public class Database {
/**
* Check connection status and re-establish if dead or stale.
*
* If the very first immediate attempt fails, further attempts
* will be made in progressively larger intervals up to MAX_WAIT
* intervals.
* If the very first immediate attempt fails, further attempts
* will be made in progressively larger intervals up to MAX_WAIT
* intervals.
*
* This allows for MySQL to time out idle connections as needed by
* server operator, without affecting McMMO, while still providing
* protection against a database outage taking down Bukkit's tick
* This allows for MySQL to time out idle connections as needed by
* server operator, without affecting McMMO, while still providing
* protection against a database outage taking down Bukkit's tick
* processing loop due to attemping a database connection each
* time McMMO needs the database.
*
* @return the boolean value for whether or not we are connected
*/
public static boolean checkConnected() {
boolean isClosed = true;
boolean isValid = false;
boolean exists = (connection != null);
boolean isClosed = true;
boolean isValid = false;
boolean exists = (connection != null);
// Initialized as needed later
long timestamp=0;
// If we're waiting for server to recover then leave early
if (nextReconnectTimestamp > 0 && nextReconnectTimestamp > System.nanoTime()) {
return false;
}
if (exists) {
// Initialized as needed later
long timestamp=0;
// If we're waiting for server to recover then leave early
if (nextReconnectTimestamp > 0 && nextReconnectTimestamp > System.nanoTime()) {
return false;
}
if (exists) {
try {
isClosed = connection.isClosed();
} catch (SQLException e) {
isClosed = true;
e.printStackTrace();
printErrors(e);
}
isClosed = connection.isClosed();
} catch (SQLException e) {
isClosed = true;
e.printStackTrace();
printErrors(e);
}
if (!isClosed) {
try {
isValid = connection.isValid(VALID_TIMEOUT);
} catch (SQLException e) {
// Don't print stack trace because it's valid to lose idle connections
// to the server and have to restart them.
isValid = false;
}
isValid = connection.isValid(VALID_TIMEOUT);
} catch (SQLException e) {
// Don't print stack trace because it's valid to lose idle connections
// to the server and have to restart them.
isValid = false;
}
}
}
}
// Leave if all ok
if (exists && !isClosed && isValid) {
// Housekeeping
nextReconnectTimestamp = 0;
reconnectAttempt = 0;
return true;
}
// Cleanup after ourselves for GC and MySQL's sake
if (exists && !isClosed) {
try {
connection.close();
} catch (SQLException ex) {
// This is a housekeeping exercise, ignore errors
}
}
// Leave if all ok
if (exists && !isClosed && isValid) {
// Housekeeping
nextReconnectTimestamp = 0;
reconnectAttempt = 0;
return true;
}
// Try to connect again
connect();
// Cleanup after ourselves for GC and MySQL's sake
if (exists && !isClosed) {
try {
connection.close();
} catch (SQLException ex) {
// This is a housekeeping exercise, ignore errors
}
}
// Leave if connection is good
try {
if (connection != null && !connection.isClosed()) {
// Schedule a database save if we really had an outage
if (reconnectAttempt > 1) {
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new SQLReconnect(plugin), 5);
}
nextReconnectTimestamp = 0;
reconnectAttempt = 0;
return true;
}
} catch (SQLException e) {
// Failed to check isClosed, so presume connection is bad and attempt later
e.printStackTrace();
printErrors(e);
}
// Try to connect again
connect();
reconnectAttempt++;
nextReconnectTimestamp = (long)(System.nanoTime() + Math.min(MAX_WAIT, (reconnectAttempt*SCALING_FACTOR*MIN_WAIT)));
return false;
// Leave if connection is good
try {
if (connection != null && !connection.isClosed()) {
// Schedule a database save if we really had an outage
if (reconnectAttempt > 1) {
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new SQLReconnect(plugin), 5);
}
nextReconnectTimestamp = 0;
reconnectAttempt = 0;
return true;
}
} catch (SQLException e) {
// Failed to check isClosed, so presume connection is bad and attempt later
e.printStackTrace();
printErrors(e);
}
reconnectAttempt++;
nextReconnectTimestamp = (long)(System.nanoTime() + Math.min(MAX_WAIT, (reconnectAttempt*SCALING_FACTOR*MIN_WAIT)));
return false;
}
/**

View File

@ -394,12 +394,12 @@ public class ItemChecks {
*/
public static boolean isStringTool(ItemStack is) {
switch (is.getType()) {
case BOW:
case FISHING_ROD:
return true;
case BOW:
case FISHING_ROD:
return true;
default:
return false;
default:
return false;
}
}

View File

@ -217,7 +217,7 @@ public class Leaderboard {
BufferedReader in = new BufferedReader(file);
int destination;
//How many lines to skip through
//How many lines to skip through
if (pagenumber == 1) {
destination = 0;
}

View File

@ -277,23 +277,23 @@ public class Metrics {
}
/**
* Enables metrics for the server by setting "opt-out" to false in the config file and starting the metrics task.
*
* @throws IOException
*/
* Enables metrics for the server by setting "opt-out" to false in the config file and starting the metrics task.
*
* @throws IOException
*/
public void enable() throws IOException {
// This has to be synchronized or it can collide with the check in the task.
synchronized (optOutLock) {
// Check if the server owner has already set opt-out, if not, set it.
if (isOptOut()) {
configuration.set("opt-out", false);
configuration.save(configurationFile);
}
// Check if the server owner has already set opt-out, if not, set it.
if (isOptOut()) {
configuration.set("opt-out", false);
configuration.save(configurationFile);
}
// Enable Task, if it is not running
if (taskId < 0) {
start();
}
// Enable Task, if it is not running
if (taskId < 0) {
start();
}
}
}

View File

@ -289,4 +289,3 @@ public class Misc {
}
}
}

View File

@ -408,11 +408,11 @@ public class Permissions {
public boolean party(Player player) {
return player.hasPermission("mcmmo.commands.party");
}
public boolean skillReset(Player player) {
return player.hasPermission("mcmmo.skillreset");
}
/*
* MCMMO.CHAT.*

View File

@ -25,8 +25,8 @@ import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.spout.SpoutStuff;
public class Skills {
static AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
public static int abilityLengthIncreaseLevel = advancedConfig.getAbilityLength();
static AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
public static int abilityLengthIncreaseLevel = advancedConfig.getAbilityLength();
private final static int TIME_CONVERSION_FACTOR = 1000;
private final static double MAX_DISTANCE_AWAY = 10.0;
@ -530,7 +530,7 @@ public class Skills {
return;
if (type.getPermissions(player)) {
if(Users.getPlayer(player) == null)
if(Users.getPlayer(player) == null)
return;
Users.getPlayer(player).addXP(type, xp);

View File

@ -372,7 +372,7 @@ public class HashChunkletManager implements ChunkletManager {
// TODO: Make this less messy, as it is, it's kinda... depressing to do it like this.
// Might also make a mess when we move to stacks, but at that point I think I will write a new Manager...
// IMPORTANT! If ChunkletStoreFactory is going to be returning something other than PrimitiveEx we need to remove this, as it will be breaking time for old maps
/*
if(!(storeIn instanceof PrimitiveExChunkletStore)) {
ChunkletStore tempStore = ChunkletStoreFactory.getChunkletStore();
@ -381,7 +381,7 @@ public class HashChunkletManager implements ChunkletManager {
}
storeIn = tempStore;
}
*/
*/
return storeIn;
}

View File

@ -14,20 +14,20 @@ public class NullChunkletManager implements ChunkletManager {
return;
}
@Override
public void unloadChunklet(int cx, int cy, int cz, World world) {
return;
}
@Override
public void unloadChunklet(int cx, int cy, int cz, World world) {
return;
}
@Override
public void loadChunk(int cx, int cz, World world) {
return;
}
@Override
public void loadChunk(int cx, int cz, World world) {
return;
}
@Override
public void unloadChunk(int cx, int cz, World world) {
return;
}
@Override
public void unloadChunk(int cx, int cz, World world) {
return;
}
@Override
public void chunkLoaded(int cx, int cz, World world) {

View File

@ -10,7 +10,7 @@ public interface ChunkManager {
public ChunkStore readChunkStore(World world, int x, int z) throws IOException;
public void writeChunkStore(World world, int x, int z, ChunkStore data);
public void closeChunkStore(World world, int x, int z);
/**
* Loads a specific chunklet
*

View File

@ -112,7 +112,7 @@ public class HashChunkManager implements ChunkManager {
int rx = x >> 5;
int rz = z >> 5;
long key2 = (((long) rx) << 32) | (((long) rz) & 0xFFFFFFFFL);
long key2 = (((long) rx) << 32) | ((rz) & 0xFFFFFFFFL);
mcMMOSimpleRegionFile regionFile = worldRegions.get(key2);
@ -221,9 +221,9 @@ public class HashChunkManager implements ChunkManager {
try {
cx = Integer.parseInt(info[1]);
cz = Integer.parseInt(info[2]);
cz = Integer.parseInt(info[2]);
}
catch(Exception e) {
catch(Exception e) {
return;
}
saveChunk(cx, cz, world);
@ -247,9 +247,9 @@ public class HashChunkManager implements ChunkManager {
try {
cx = Integer.parseInt(info[1]);
cz = Integer.parseInt(info[2]);
cz = Integer.parseInt(info[2]);
}
catch(Exception e) {
catch(Exception e) {
return;
}
unloadChunk(cx, cz, world);

View File

@ -28,7 +28,7 @@ public class PrimitiveChunkStore implements ChunkStore {
public PrimitiveChunkStore(World world, int cx, int cz) {
this.cx = cx;
this.cz = cz;
this.worldUid = world.getUID();
this.worldUid = world.getUID();
this.worldHeight = world != null ? world.getMaxHeight() : 128;
this.xBitShifts = 11;
@ -108,7 +108,7 @@ public class PrimitiveChunkStore implements ChunkStore {
out.writeLong(worldUid.getMostSignificantBits());
out.writeInt(cx);
out.writeInt(cz);
out.writeObject(store);
out.writeObject(store);
dirty = false;
}

View File

@ -23,17 +23,17 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
public class mcMMOSimpleChunkBuffer extends ByteArrayOutputStream {
final mcMMOSimpleRegionFile rf;
final int index;
final mcMMOSimpleRegionFile rf;
final int index;
mcMMOSimpleChunkBuffer(mcMMOSimpleRegionFile rf, int index) {
super(1024);
this.rf = rf;
this.index = index;
}
mcMMOSimpleChunkBuffer(mcMMOSimpleRegionFile rf, int index) {
super(1024);
this.rf = rf;
this.index = index;
}
@Override
public void close() throws IOException {
rf.write(index, buf, count);
}
@Override
public void close() throws IOException {
rf.write(index, buf, count);
}
}

View File

@ -30,271 +30,271 @@ import java.util.zip.DeflaterOutputStream;
import java.util.zip.InflaterInputStream;
public class mcMMOSimpleRegionFile {
private RandomAccessFile file;
private final int[] dataStart = new int[1024];
private final int[] dataActualLength = new int[1024];
private final int[] dataLength = new int[1024];
private final ArrayList<Boolean> inuse = new ArrayList<Boolean>();
private int segmentSize;
private int segmentMask;
private final int rx;
private final int rz;
private final int defaultSegmentSize;
private final File parent;
@SuppressWarnings("unused")
private long lastAccessTime = System.currentTimeMillis();
@SuppressWarnings("unused")
private static long TIMEOUT_TIME = 300000; // 5 min
private RandomAccessFile file;
private final int[] dataStart = new int[1024];
private final int[] dataActualLength = new int[1024];
private final int[] dataLength = new int[1024];
private final ArrayList<Boolean> inuse = new ArrayList<Boolean>();
private int segmentSize;
private int segmentMask;
private final int rx;
private final int rz;
private final int defaultSegmentSize;
private final File parent;
@SuppressWarnings("unused")
private long lastAccessTime = System.currentTimeMillis();
@SuppressWarnings("unused")
private static long TIMEOUT_TIME = 300000; // 5 min
public mcMMOSimpleRegionFile(File f, int rx, int rz) {
this(f, rx, rz, 10);
}
public mcMMOSimpleRegionFile(File f, int rx, int rz) {
this(f, rx, rz, 10);
}
public mcMMOSimpleRegionFile(File f, int rx, int rz, int defaultSegmentSize) {
this.rx = rx;
this.rz = rz;
this.defaultSegmentSize = defaultSegmentSize;
this.parent = f;
public mcMMOSimpleRegionFile(File f, int rx, int rz, int defaultSegmentSize) {
this.rx = rx;
this.rz = rz;
this.defaultSegmentSize = defaultSegmentSize;
this.parent = f;
lastAccessTime = System.currentTimeMillis();
if (file == null) {
try {
this.file = new RandomAccessFile(parent, "rw");
lastAccessTime = System.currentTimeMillis();
if (file == null) {
try {
this.file = new RandomAccessFile(parent, "rw");
if (file.length() < 4096 * 3) {
for (int i = 0; i < 1024 * 3; i++) {
file.writeInt(0);
}
file.seek(4096 * 2);
file.writeInt(defaultSegmentSize);
}
if (file.length() < 4096 * 3) {
for (int i = 0; i < 1024 * 3; i++) {
file.writeInt(0);
}
file.seek(4096 * 2);
file.writeInt(defaultSegmentSize);
}
file.seek(4096 * 2);
file.seek(4096 * 2);
this.segmentSize = file.readInt();
this.segmentMask = (1 << segmentSize) - 1;
this.segmentSize = file.readInt();
this.segmentMask = (1 << segmentSize) - 1;
int reservedSegments = this.sizeToSegments(4096 * 3);
int reservedSegments = this.sizeToSegments(4096 * 3);
for (int i = 0; i < reservedSegments; i++) {
while (inuse.size() <= i) {
inuse.add(false);
}
inuse.set(i, true);
}
for (int i = 0; i < reservedSegments; i++) {
while (inuse.size() <= i) {
inuse.add(false);
}
inuse.set(i, true);
}
file.seek(0);
file.seek(0);
for (int i = 0; i < 1024; i++) {
dataStart[i] = file.readInt();
}
for (int i = 0; i < 1024; i++) {
dataStart[i] = file.readInt();
}
for (int i = 0; i < 1024; i++) {
dataActualLength[i] = file.readInt();
dataLength[i] = sizeToSegments(dataActualLength[i]);
setInUse(i, true);
}
for (int i = 0; i < 1024; i++) {
dataActualLength[i] = file.readInt();
dataLength[i] = sizeToSegments(dataActualLength[i]);
setInUse(i, true);
}
extendFile();
} catch (IOException fnfe) {
throw new RuntimeException(fnfe);
}
}
}
extendFile();
} catch (IOException fnfe) {
throw new RuntimeException(fnfe);
}
}
}
public synchronized final RandomAccessFile getFile() {
lastAccessTime = System.currentTimeMillis();
if (file == null) {
try {
this.file = new RandomAccessFile(parent, "rw");
public synchronized final RandomAccessFile getFile() {
lastAccessTime = System.currentTimeMillis();
if (file == null) {
try {
this.file = new RandomAccessFile(parent, "rw");
if (file.length() < 4096 * 3) {
for (int i = 0; i < 1024 * 3; i++) {
file.writeInt(0);
}
file.seek(4096 * 2);
file.writeInt(defaultSegmentSize);
}
if (file.length() < 4096 * 3) {
for (int i = 0; i < 1024 * 3; i++) {
file.writeInt(0);
}
file.seek(4096 * 2);
file.writeInt(defaultSegmentSize);
}
file.seek(4096 * 2);
file.seek(4096 * 2);
this.segmentSize = file.readInt();
this.segmentMask = (1 << segmentSize) - 1;
this.segmentSize = file.readInt();
this.segmentMask = (1 << segmentSize) - 1;
int reservedSegments = this.sizeToSegments(4096 * 3);
int reservedSegments = this.sizeToSegments(4096 * 3);
for (int i = 0; i < reservedSegments; i++) {
while (inuse.size() <= i) {
inuse.add(false);
}
inuse.set(i, true);
}
for (int i = 0; i < reservedSegments; i++) {
while (inuse.size() <= i) {
inuse.add(false);
}
inuse.set(i, true);
}
file.seek(0);
file.seek(0);
for (int i = 0; i < 1024; i++) {
dataStart[i] = file.readInt();
}
for (int i = 0; i < 1024; i++) {
dataStart[i] = file.readInt();
}
for (int i = 0; i < 1024; i++) {
dataActualLength[i] = file.readInt();
dataLength[i] = sizeToSegments(dataActualLength[i]);
setInUse(i, true);
}
for (int i = 0; i < 1024; i++) {
dataActualLength[i] = file.readInt();
dataLength[i] = sizeToSegments(dataActualLength[i]);
setInUse(i, true);
}
extendFile();
} catch (IOException fnfe) {
throw new RuntimeException(fnfe);
}
}
return file;
}
extendFile();
} catch (IOException fnfe) {
throw new RuntimeException(fnfe);
}
}
return file;
}
public synchronized boolean testCloseTimeout() {
/*if (System.currentTimeMillis() - TIMEOUT_TIME > lastAccessTime) {
public synchronized boolean testCloseTimeout() {
/*if (System.currentTimeMillis() - TIMEOUT_TIME > lastAccessTime) {
close();
return true;
}*/
return false;
}
return false;
}
public synchronized DataOutputStream getOutputStream(int x, int z) {
int index = getChunkIndex(x, z);
return new DataOutputStream(new DeflaterOutputStream(new mcMMOSimpleChunkBuffer(this, index)));
}
public synchronized DataOutputStream getOutputStream(int x, int z) {
int index = getChunkIndex(x, z);
return new DataOutputStream(new DeflaterOutputStream(new mcMMOSimpleChunkBuffer(this, index)));
}
public synchronized DataInputStream getInputStream(int x, int z) throws IOException {
int index = getChunkIndex(x, z);
int actualLength = dataActualLength[index];
if (actualLength == 0) {
return null;
}
byte[] data = new byte[actualLength];
public synchronized DataInputStream getInputStream(int x, int z) throws IOException {
int index = getChunkIndex(x, z);
int actualLength = dataActualLength[index];
if (actualLength == 0) {
return null;
}
byte[] data = new byte[actualLength];
getFile().seek(dataStart[index] << segmentSize);
getFile().readFully(data);
return new DataInputStream(new InflaterInputStream(new ByteArrayInputStream(data)));
}
getFile().seek(dataStart[index] << segmentSize);
getFile().readFully(data);
return new DataInputStream(new InflaterInputStream(new ByteArrayInputStream(data)));
}
synchronized void write(int index, byte[] buffer, int size) throws IOException {
int oldStart = setInUse(index, false);
int start = findSpace(oldStart, size);
getFile().seek(start << segmentSize);
getFile().write(buffer, 0, size);
dataStart[index] = start;
dataActualLength[index] = size;
dataLength[index] = sizeToSegments(size);
setInUse(index, true);
saveFAT();
}
synchronized void write(int index, byte[] buffer, int size) throws IOException {
int oldStart = setInUse(index, false);
int start = findSpace(oldStart, size);
getFile().seek(start << segmentSize);
getFile().write(buffer, 0, size);
dataStart[index] = start;
dataActualLength[index] = size;
dataLength[index] = sizeToSegments(size);
setInUse(index, true);
saveFAT();
}
public synchronized void close() {
try {
if (file != null) {
file.seek(4096 * 2);
file.close();
}
file = null;
} catch (IOException ioe) {
throw new RuntimeException("Unable to close file", ioe);
}
}
public synchronized void close() {
try {
if (file != null) {
file.seek(4096 * 2);
file.close();
}
file = null;
} catch (IOException ioe) {
throw new RuntimeException("Unable to close file", ioe);
}
}
private synchronized int setInUse(int index, boolean used) {
if (dataActualLength[index] == 0) {
return dataStart[index];
}
private synchronized int setInUse(int index, boolean used) {
if (dataActualLength[index] == 0) {
return dataStart[index];
}
int start = dataStart[index];
int end = start + dataLength[index];
int start = dataStart[index];
int end = start + dataLength[index];
for (int i = start; i < end; i++) {
while (i > inuse.size() - 1) {
inuse.add(false);
}
Boolean old = inuse.set(i, used);
if (old != null && old == used) {
if (old) {
throw new IllegalStateException("Attempting to overwrite an in-use segment");
} else {
throw new IllegalStateException("Attempting to delete empty segment");
}
}
}
for (int i = start; i < end; i++) {
while (i > inuse.size() - 1) {
inuse.add(false);
}
Boolean old = inuse.set(i, used);
if (old != null && old == used) {
if (old) {
throw new IllegalStateException("Attempting to overwrite an in-use segment");
} else {
throw new IllegalStateException("Attempting to delete empty segment");
}
}
}
return dataStart[index];
}
return dataStart[index];
}
private synchronized void extendFile() throws IOException {
long extend = (-getFile().length()) & segmentMask;
private synchronized void extendFile() throws IOException {
long extend = (-getFile().length()) & segmentMask;
getFile().seek(getFile().length());
getFile().seek(getFile().length());
while ((extend--) > 0) {
getFile().write(0);
}
}
while ((extend--) > 0) {
getFile().write(0);
}
}
private synchronized int findSpace(int oldStart, int size) {
int segments = sizeToSegments(size);
private synchronized int findSpace(int oldStart, int size) {
int segments = sizeToSegments(size);
boolean oldFree = true;
for (int i = oldStart; i < inuse.size() && i < oldStart + segments; i++) {
if (inuse.get(i)) {
oldFree = false;
break;
}
}
boolean oldFree = true;
for (int i = oldStart; i < inuse.size() && i < oldStart + segments; i++) {
if (inuse.get(i)) {
oldFree = false;
break;
}
}
if (oldFree) {
return oldStart;
}
if (oldFree) {
return oldStart;
}
int start = 0;
int end = 0;
int start = 0;
int end = 0;
while (end < inuse.size()) {
if (inuse.get(end)) {
end++;
start = end;
} else {
end++;
}
if (end - start >= segments) {
return start;
}
}
while (end < inuse.size()) {
if (inuse.get(end)) {
end++;
start = end;
} else {
end++;
}
if (end - start >= segments) {
return start;
}
}
return start;
}
return start;
}
private synchronized int sizeToSegments(int size) {
if (size <= 0) {
return 1;
} else {
return ((size - 1) >> segmentSize) + 1;
}
}
private synchronized int sizeToSegments(int size) {
if (size <= 0) {
return 1;
} else {
return ((size - 1) >> segmentSize) + 1;
}
}
private synchronized Integer getChunkIndex(int x, int z) {
if (rx != (x >> 5) || rz != (z >> 5)) {
throw new RuntimeException(x + ", " + z + " not in region " + rx + ", " + rz);
}
private synchronized Integer getChunkIndex(int x, int z) {
if (rx != (x >> 5) || rz != (z >> 5)) {
throw new RuntimeException(x + ", " + z + " not in region " + rx + ", " + rz);
}
x = x & 0x1F;
z = z & 0x1F;
x = x & 0x1F;
z = z & 0x1F;
return (x << 5) + z;
}
return (x << 5) + z;
}
private synchronized void saveFAT() throws IOException {
getFile().seek(0);
for (int i = 0; i < 1024; i++) {
getFile().writeInt(dataStart[i]);
}
private synchronized void saveFAT() throws IOException {
getFile().seek(0);
for (int i = 0; i < 1024; i++) {
getFile().writeInt(dataStart[i]);
}
for (int i = 0; i < 1024; i++) {
getFile().writeInt(dataActualLength[i]);
}
}
for (int i = 0; i < 1024; i++) {
getFile().writeInt(dataActualLength[i]);
}
}
}