mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 15:16:45 +01:00
Cleanup formatting.
This commit is contained in:
parent
6b3bde585d
commit
36d5344ded
@ -7,7 +7,7 @@ Key:
|
|||||||
! Change
|
! Change
|
||||||
- Removal
|
- Removal
|
||||||
|
|
||||||
Version 1.3.13
|
Version 1.3.13-dev
|
||||||
+ Added Craftbukkit 1.4.6 compatibility
|
+ Added Craftbukkit 1.4.6 compatibility
|
||||||
= Fixed issue with missing default cases from several switch/case statements
|
= Fixed issue with missing default cases from several switch/case statements
|
||||||
= Fixed issue with Mining using actual skill level rather than max skill level
|
= Fixed issue with Mining using actual skill level rather than max skill level
|
||||||
|
@ -30,9 +30,9 @@ public class McstatsCommand implements CommandExecutor {
|
|||||||
int powerLevelCap = Config.getInstance().getPowerLevelCap();
|
int powerLevelCap = Config.getInstance().getPowerLevelCap();
|
||||||
|
|
||||||
if (powerLevelCap > 0)
|
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
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ public class SkillResetCommand implements CommandExecutor {
|
|||||||
|
|
||||||
//make sure there's only one argument. output at least some kind of error if not
|
//make sure there's only one argument. output at least some kind of error if not
|
||||||
if (args.length != 1 && args[0] != null) {
|
if (args.length != 1 && args[0] != null) {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -36,12 +36,12 @@ public class SkillResetCommand implements CommandExecutor {
|
|||||||
//parse the skilltype that they sent
|
//parse the skilltype that they sent
|
||||||
try
|
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)
|
}catch(IllegalArgumentException ex)
|
||||||
{
|
{
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//reset the values in the hash table and persist them
|
//reset the values in the hash table and persist them
|
||||||
PlayerProfile profile = Users.getProfile((Player)sender);
|
PlayerProfile profile = Users.getProfile((Player)sender);
|
||||||
@ -56,9 +56,9 @@ public class SkillResetCommand implements CommandExecutor {
|
|||||||
|
|
||||||
//display a success message to the user
|
//display a success message to the user
|
||||||
if (skillType == SkillType.ALL)
|
if (skillType == SkillType.ALL)
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Reset.All"));
|
sender.sendMessage(LocaleLoader.getString("Commands.Reset.All"));
|
||||||
else
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -85,5 +85,5 @@ public class PtpCommand implements CommandExecutor {
|
|||||||
sender.sendMessage(usage);
|
sender.sendMessage(usage);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,13 +36,13 @@ public class AcrobaticsCommand extends SkillCommand {
|
|||||||
DecimalFormat df = new DecimalFormat("#.0");
|
DecimalFormat df = new DecimalFormat("#.0");
|
||||||
// DODGE
|
// DODGE
|
||||||
if(skillValue >= dodgeMaxBonusLevel) dodgeChance = df.format(dodgeChanceMax);
|
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
|
// ROLL
|
||||||
if(skillValue >= rollMaxBonusLevel) rollChance = df.format(rollChanceMax);
|
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
|
// GRACEFULROLL
|
||||||
if(skillValue >= gracefulRollMaxBonusLevel) gracefulRollChance = df.format(gracefulRollChanceMax);
|
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
|
@Override
|
||||||
@ -59,10 +59,10 @@ public class AcrobaticsCommand extends SkillCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void effectsDisplay() {
|
protected void effectsDisplay() {
|
||||||
if (player.hasPermission("mcmmo.perks.lucky.acrobatics")) {
|
if (player.hasPermission("mcmmo.perks.lucky.acrobatics")) {
|
||||||
String perkPrefix = ChatColor.RED + "[mcMMO Perks] ";
|
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" }) }));
|
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.lucky.name"), LocaleLoader.getString("Perks.lucky.desc", new Object[] { "Acrobatics" }) }));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (canRoll) {
|
if (canRoll) {
|
||||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Acrobatics.Effect.0"), LocaleLoader.getString("Acrobatics.Effect.1") }));
|
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Acrobatics.Effect.0"), LocaleLoader.getString("Acrobatics.Effect.1") }));
|
||||||
|
@ -39,17 +39,17 @@ public class ArcheryCommand extends SkillCommand {
|
|||||||
protected void dataCalculations() {
|
protected void dataCalculations() {
|
||||||
DecimalFormat df = new DecimalFormat("#.0");
|
DecimalFormat df = new DecimalFormat("#.0");
|
||||||
// SkillShot
|
// 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);
|
if (bonus > skillShotBonusMax) skillShotBonus = percent.format(skillShotBonusMax);
|
||||||
else skillShotBonus = percent.format(bonus);
|
else skillShotBonus = percent.format(bonus);
|
||||||
|
|
||||||
// Daze
|
// Daze
|
||||||
if(skillValue >= dazeMaxBonusLevel) dazeChance = df.format(dazeBonusMax);
|
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
|
// Retrieve
|
||||||
if(skillValue >= retrieveMaxBonusLevel) retrieveChance = df.format(retrieveBonusMax);
|
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
|
@Override
|
||||||
@ -66,10 +66,10 @@ public class ArcheryCommand extends SkillCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void effectsDisplay() {
|
protected void effectsDisplay() {
|
||||||
if (player.hasPermission("mcmmo.perks.lucky.archery")) {
|
if (player.hasPermission("mcmmo.perks.lucky.archery")) {
|
||||||
String perkPrefix = ChatColor.RED + "[mcMMO Perks] ";
|
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" }) }));
|
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.lucky.name"), LocaleLoader.getString("Perks.lucky.desc", new Object[] { "Archery" }) }));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (canSkillShot) {
|
if (canSkillShot) {
|
||||||
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Archery.Effect.0"), LocaleLoader.getString("Archery.Effect.1") }));
|
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Archery.Effect.0"), LocaleLoader.getString("Archery.Effect.1") }));
|
||||||
|
@ -24,7 +24,7 @@ public class AxesCommand extends SkillCommand {
|
|||||||
private double critMaxChance = advancedConfig.getAxesCriticalChance();
|
private double critMaxChance = advancedConfig.getAxesCriticalChance();
|
||||||
private int critMaxBonusLevel = advancedConfig.getAxesCriticalMaxBonusLevel();
|
private int critMaxBonusLevel = advancedConfig.getAxesCriticalMaxBonusLevel();
|
||||||
private int greaterImpactIncreaseLevel = advancedConfig.getArmorImpactIncreaseLevel();
|
private int greaterImpactIncreaseLevel = advancedConfig.getArmorImpactIncreaseLevel();
|
||||||
// private double greaterImpactModifier = advancedConfig.getGreaterImpactModifier();
|
// private double greaterImpactModifier = advancedConfig.getGreaterImpactModifier();
|
||||||
private int abilityLengthIncreaseLevel = advancedConfig.getAbilityLength();
|
private int abilityLengthIncreaseLevel = advancedConfig.getAbilityLength();
|
||||||
|
|
||||||
private boolean canSkullSplitter;
|
private boolean canSkullSplitter;
|
||||||
@ -47,9 +47,9 @@ public class AxesCommand extends SkillCommand {
|
|||||||
greaterImpactDamage = "2";
|
greaterImpactDamage = "2";
|
||||||
|
|
||||||
if (skillValue >= critMaxBonusLevel) critChance = df.format(critMaxChance);
|
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);
|
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
|
@Override
|
||||||
|
@ -30,10 +30,10 @@ public class FishingCommand extends SkillCommand {
|
|||||||
@Override
|
@Override
|
||||||
protected void dataCalculations() {
|
protected void dataCalculations() {
|
||||||
lootTier = Fishing.getFishingLootTier(profile);
|
lootTier = Fishing.getFishingLootTier(profile);
|
||||||
magicChance = percent.format((double) lootTier / 15D);
|
magicChance = percent.format(lootTier / 15D);
|
||||||
int dropChance = Fishing.getShakeChance(lootTier);
|
int dropChance = Fishing.getShakeChance(lootTier);
|
||||||
if (player.hasPermission("mcmmo.perks.lucky.fishing")) {
|
if (player.hasPermission("mcmmo.perks.lucky.fishing")) {
|
||||||
dropChance = (int) ((double) dropChance * 1.25D);
|
dropChance = (int) (dropChance * 1.25D);
|
||||||
}
|
}
|
||||||
shakeChance = String.valueOf(dropChance);
|
shakeChance = String.valueOf(dropChance);
|
||||||
|
|
||||||
|
@ -53,10 +53,10 @@ public class HerbalismCommand extends SkillCommand {
|
|||||||
|
|
||||||
|
|
||||||
if(skillValue >= greenThumbMaxLevel) greenThumbChance = String.valueOf(greenThumbMaxBonus);
|
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
|
//DOUBLE DROPS
|
||||||
if(skillValue >= doubleDropsMaxLevel) doubleDropChance = df.format(doubleDropsMaxBonus);
|
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
|
@Override
|
||||||
|
@ -48,7 +48,7 @@ public class MiningCommand extends SkillCommand {
|
|||||||
DecimalFormat df = new DecimalFormat("#.0");
|
DecimalFormat df = new DecimalFormat("#.0");
|
||||||
superBreakerLength = String.valueOf(2 + (int) ((double) skillValue / (double) abilityLengthIncreaseLevel));
|
superBreakerLength = String.valueOf(2 + (int) ((double) skillValue / (double) abilityLengthIncreaseLevel));
|
||||||
if(skillValue >= doubleDropsMaxLevel) doubleDropChance = df.format(doubleDropsMaxBonus);
|
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) {
|
if (skillValue >= blastMiningRank8) {
|
||||||
blastMiningRank = "8";
|
blastMiningRank = "8";
|
||||||
|
@ -64,10 +64,10 @@ public class RepairCommand extends SkillCommand {
|
|||||||
salvageLevel = Config.getInstance().getSalvageUnlockLevel();
|
salvageLevel = Config.getInstance().getSalvageUnlockLevel();
|
||||||
|
|
||||||
if(skillValue >= repairMasteryMaxBonusLevel) repairMasteryBonus = df.format(repairMasteryChanceMax);
|
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);
|
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);
|
arcaneForgingRank = Repair.getArcaneForgingRank(profile);
|
||||||
}
|
}
|
||||||
@ -85,7 +85,7 @@ public class RepairCommand extends SkillCommand {
|
|||||||
canRepairString = permInstance.stringRepair(player);
|
canRepairString = permInstance.stringRepair(player);
|
||||||
canRepairLeather = permInstance.leatherRepair(player);
|
canRepairLeather = permInstance.leatherRepair(player);
|
||||||
canRepairWood = permInstance.woodRepair(player);
|
canRepairWood = permInstance.woodRepair(player);
|
||||||
arcaneBypass = permInstance.arcaneBypass(player);
|
arcaneBypass = permInstance.arcaneBypass(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -43,10 +43,10 @@ public class SwordsCommand extends SkillCommand {
|
|||||||
else bleedLength = String.valueOf(bleedBaseTicks);
|
else bleedLength = String.valueOf(bleedBaseTicks);
|
||||||
|
|
||||||
if(skillValue >= bleedMaxLevel) bleedChance = df.format(bleedChanceMax);
|
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);
|
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);
|
serratedStrikesLength = String.valueOf(serratedBleedTicks);
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ public class TamingCommand extends SkillCommand {
|
|||||||
protected void dataCalculations() {
|
protected void dataCalculations() {
|
||||||
DecimalFormat df = new DecimalFormat("#.0");
|
DecimalFormat df = new DecimalFormat("#.0");
|
||||||
if(skillValue >= goreMaxLevel) goreChance = df.format(goreChanceMax);
|
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
|
@Override
|
||||||
|
@ -39,10 +39,10 @@ public class UnarmedCommand extends SkillCommand {
|
|||||||
berserkLength = String.valueOf(2 + (int) ((double) skillValue / (double) abilityLengthIncreaseLevel));
|
berserkLength = String.valueOf(2 + (int) ((double) skillValue / (double) abilityLengthIncreaseLevel));
|
||||||
|
|
||||||
if(skillValue >= disarmMaxLevel) disarmChance = df.format(disarmChanceMax);
|
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);
|
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);
|
if (skillValue >= 250) ironArmBonus = String.valueOf(ironArmMaxBonus);
|
||||||
else ironArmBonus = String.valueOf(3 + ((double) skillValue / (double) ironArmIncreaseLevel));
|
else ironArmBonus = String.valueOf(3 + ((double) skillValue / (double) ironArmIncreaseLevel));
|
||||||
|
@ -35,7 +35,7 @@ public class WoodcuttingCommand extends SkillCommand {
|
|||||||
|
|
||||||
treeFellerLength = String.valueOf(2 + (int) ((double) skillValue / (double) abilityLengthIncreaseLevel));
|
treeFellerLength = String.valueOf(2 + (int) ((double) skillValue / (double) abilityLengthIncreaseLevel));
|
||||||
if(skillValue >= doubleDropsMaxLevel) doubleDropChance = df.format(doubleDropsMaxBonus);
|
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
|
@Override
|
||||||
|
@ -148,6 +148,6 @@ public class AdvancedConfig extends ConfigLoader {
|
|||||||
public int getSpoutNotificationTier3() { return config.getInt("Spout.Notifications.Tier3", 600); }
|
public int getSpoutNotificationTier3() { return config.getInt("Spout.Notifications.Tier3", 600); }
|
||||||
public int getSpoutNotificationTier4() { return config.getInt("Spout.Notifications.Tier4", 800); }
|
public int getSpoutNotificationTier4() { return config.getInt("Spout.Notifications.Tier4", 800); }
|
||||||
//TODO Make the sounds configurable! :D
|
//TODO Make the sounds configurable! :D
|
||||||
// public String getSpoutSoundRepair() { return config.getString("Spout.Sounds.RepairSound", "url here"); }
|
// public String getSpoutSoundRepair() { return config.getString("Spout.Sounds.RepairSound", "url here"); }
|
||||||
// public String getSpoutSoundLevelUp() { return config.getString("Spout.Sounds.LevelUp", "url here"); }
|
// public String getSpoutSoundLevelUp() { return config.getString("Spout.Sounds.LevelUp", "url here"); }
|
||||||
}
|
}
|
||||||
|
@ -190,7 +190,7 @@ public class TreasuresConfig extends ConfigLoader{
|
|||||||
|
|
||||||
List<String> excavationTreasures = config.getStringList("Excavation.Treasure");
|
List<String> excavationTreasures = config.getStringList("Excavation.Treasure");
|
||||||
List<String> fishingTreasures = config.getStringList("Fishing.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();
|
Iterator<Entry<String,Treasure>> treasureIterator = treasures.entrySet().iterator();
|
||||||
|
|
||||||
while (treasureIterator.hasNext()) {
|
while (treasureIterator.hasNext()) {
|
||||||
|
@ -36,9 +36,9 @@ public class PlayerProfile {
|
|||||||
private boolean godMode;
|
private boolean godMode;
|
||||||
private boolean greenTerraMode, treeFellerMode, superBreakerMode, gigaDrillBreakerMode, serratedStrikesMode, skullSplitterMode, berserkMode;
|
private boolean greenTerraMode, treeFellerMode, superBreakerMode, gigaDrillBreakerMode, serratedStrikesMode, skullSplitterMode, berserkMode;
|
||||||
private boolean greenTerraInformed = true, berserkInformed = true, skullSplitterInformed = true, gigaDrillBreakerInformed = true,
|
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,
|
private boolean hoePreparationMode, shovelPreparationMode, swordsPreparationMode, fistsPreparationMode,
|
||||||
pickaxePreparationMode, axePreparationMode;
|
pickaxePreparationMode, axePreparationMode;
|
||||||
private boolean abilityUse = true;
|
private boolean abilityUse = true;
|
||||||
|
|
||||||
/* Timestamps */
|
/* Timestamps */
|
||||||
@ -364,7 +364,7 @@ public class PlayerProfile {
|
|||||||
writer.append(line).append("\r\n");
|
writer.append(line).append("\r\n");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
//Otherwise write the new player information
|
//Otherwise write the new player information
|
||||||
writer.append(playerName + ":");
|
writer.append(playerName + ":");
|
||||||
writer.append(skills.get(SkillType.MINING) + ":");
|
writer.append(skills.get(SkillType.MINING) + ":");
|
||||||
writer.append("" + ":");
|
writer.append("" + ":");
|
||||||
@ -513,7 +513,7 @@ public class PlayerProfile {
|
|||||||
* Salvage Anvil Placement
|
* Salvage Anvil Placement
|
||||||
*/
|
*/
|
||||||
public void togglePlacedSalvageAnvil() {
|
public void togglePlacedSalvageAnvil() {
|
||||||
placedSalvageAnvil = !placedSalvageAnvil;
|
placedSalvageAnvil = !placedSalvageAnvil;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean getPlacedSalvageAnvil() {
|
public Boolean getPlacedSalvageAnvil() {
|
||||||
@ -891,8 +891,8 @@ public class PlayerProfile {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Exploit Prevention
|
* Exploit Prevention
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public int getRespawnATS() {
|
public int getRespawnATS() {
|
||||||
return respawnATS;
|
return respawnATS;
|
||||||
@ -926,113 +926,113 @@ public class PlayerProfile {
|
|||||||
|
|
||||||
public void resetSkill(SkillType skillType)
|
public void resetSkill(SkillType skillType)
|
||||||
{
|
{
|
||||||
//do a single skilltype
|
//do a single skilltype
|
||||||
if (skillType != SkillType.ALL)
|
if (skillType != SkillType.ALL)
|
||||||
skills.put(skillType, 0);
|
skills.put(skillType, 0);
|
||||||
else //do them all
|
else //do them all
|
||||||
{
|
{
|
||||||
for(SkillType skill : SkillType.values()) //iterate over all items in the enumeration
|
for(SkillType skill : SkillType.values()) //iterate over all items in the enumeration
|
||||||
{
|
{
|
||||||
if (skill != SkillType.ALL) // skip the "all" value
|
if (skill != SkillType.ALL) // skip the "all" value
|
||||||
skills.put(skill, 0);
|
skills.put(skill, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
save(false);
|
save(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// /**
|
// /**
|
||||||
// * Adds XP to the player, doesn't calculate for XP Rate
|
// * Adds XP to the player, doesn't calculate for XP Rate
|
||||||
// *
|
// *
|
||||||
// * @param skillType The skill to add XP to
|
// * @param skillType The skill to add XP to
|
||||||
// * @param newValue The amount of XP to add
|
// * @param newValue The amount of XP to add
|
||||||
// */
|
// */
|
||||||
// public void addXPOverride(SkillType skillType, int newValue) {
|
// public void addXPOverride(SkillType skillType, int newValue) {
|
||||||
// if (skillType.equals(SkillType.ALL)) {
|
// if (skillType.equals(SkillType.ALL)) {
|
||||||
// for (SkillType x : SkillType.values()) {
|
// for (SkillType x : SkillType.values()) {
|
||||||
// if (x.equals(SkillType.ALL)) {
|
// if (x.equals(SkillType.ALL)) {
|
||||||
// continue;
|
// continue;
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerXpGainEvent(player, x, newValue));
|
// mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerXpGainEvent(player, x, newValue));
|
||||||
// skillsXp.put(x, skillsXp.get(x) + newValue);
|
// skillsXp.put(x, skillsXp.get(x) + newValue);
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// else {
|
// else {
|
||||||
// mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerXpGainEvent(player, skillType, newValue));
|
// mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerXpGainEvent(player, skillType, newValue));
|
||||||
// skillsXp.put(skillType, skillsXp.get(skillType) + newValue);
|
// skillsXp.put(skillType, skillsXp.get(skillType) + newValue);
|
||||||
// spoutHud.setLastGained(skillType);
|
// spoutHud.setLastGained(skillType);
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// /**
|
// /**
|
||||||
// * Adds XP to the player, this ignores skill modifiers.
|
// * Adds XP to the player, this ignores skill modifiers.
|
||||||
// *
|
// *
|
||||||
// * @param skillType The skill to add XP to
|
// * @param skillType The skill to add XP to
|
||||||
// * @param newValue The amount of XP to add
|
// * @param newValue The amount of XP to add
|
||||||
// */
|
// */
|
||||||
// public void addXPOverrideBonus(SkillType skillType, int newValue) {
|
// public void addXPOverrideBonus(SkillType skillType, int newValue) {
|
||||||
// int xp = newValue * Config.getInstance().xpGainMultiplier;
|
// int xp = newValue * Config.getInstance().xpGainMultiplier;
|
||||||
// addXPOverride(skillType, xp);
|
// addXPOverride(skillType, xp);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// /**
|
// /**
|
||||||
// * Adds XP to the player, this is affected by skill modifiers and XP Rate and Permissions
|
// * 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 skillType The skill to add XP to
|
||||||
// * @param newvalue The amount of XP to add
|
// * @param newvalue The amount of XP to add
|
||||||
// */
|
// */
|
||||||
// public void addXP(SkillType skillType, int newValue) {
|
// public void addXP(SkillType skillType, int newValue) {
|
||||||
// if (player.getGameMode().equals(GameMode.CREATIVE)) {
|
// if (player.getGameMode().equals(GameMode.CREATIVE)) {
|
||||||
// return;
|
// return;
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// double bonusModifier = 0;
|
// double bonusModifier = 0;
|
||||||
//
|
//
|
||||||
// if (inParty()) {
|
// if (inParty()) {
|
||||||
// bonusModifier = partyModifier(skillType);
|
// bonusModifier = partyModifier(skillType);
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// int xp = (int) (newValue / skillType.getXpModifier()) * Config.getInstance().xpGainMultiplier;
|
// int xp = (int) (newValue / skillType.getXpModifier()) * Config.getInstance().xpGainMultiplier;
|
||||||
//
|
//
|
||||||
// if (bonusModifier > 0) {
|
// if (bonusModifier > 0) {
|
||||||
// if (bonusModifier >= 2) {
|
// if (bonusModifier >= 2) {
|
||||||
// bonusModifier = 2;
|
// bonusModifier = 2;
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// double trueBonus = bonusModifier * xp;
|
// double trueBonus = bonusModifier * xp;
|
||||||
// xp += trueBonus;
|
// xp += trueBonus;
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// if (Config.getInstance().getToolModsEnabled()) {
|
// if (Config.getInstance().getToolModsEnabled()) {
|
||||||
// ItemStack item = player.getItemInHand();
|
// ItemStack item = player.getItemInHand();
|
||||||
// CustomTool tool = ModChecks.getToolFromItemStack(item);
|
// CustomTool tool = ModChecks.getToolFromItemStack(item);
|
||||||
//
|
//
|
||||||
// if (tool != null) {
|
// if (tool != null) {
|
||||||
// xp = (int) (xp * tool.getXpMultiplier());
|
// xp = (int) (xp * tool.getXpMultiplier());
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// //TODO: Can we make this so we do perks by doing "mcmmo.perks.xp.[multiplier]" ?
|
// //TODO: Can we make this so we do perks by doing "mcmmo.perks.xp.[multiplier]" ?
|
||||||
// if (player.hasPermission("mcmmo.perks.xp.quadruple")) {
|
// if (player.hasPermission("mcmmo.perks.xp.quadruple")) {
|
||||||
// xp = xp * 4;
|
// xp = xp * 4;
|
||||||
// }
|
// }
|
||||||
// else if (player.hasPermission("mcmmo.perks.xp.triple")) {
|
// else if (player.hasPermission("mcmmo.perks.xp.triple")) {
|
||||||
// xp = xp * 3;
|
// xp = xp * 3;
|
||||||
// }
|
// }
|
||||||
// else if (player.hasPermission("mcmmo.perks.xp.150percentboost")) {
|
// else if (player.hasPermission("mcmmo.perks.xp.150percentboost")) {
|
||||||
// xp = (int) (xp * 2.5);
|
// xp = (int) (xp * 2.5);
|
||||||
// }
|
// }
|
||||||
// else if (player.hasPermission("mcmmo.perks.xp.double")) {
|
// else if (player.hasPermission("mcmmo.perks.xp.double")) {
|
||||||
// xp = xp * 2;
|
// xp = xp * 2;
|
||||||
// }
|
// }
|
||||||
// else if (player.hasPermission("mcmmo.perks.xp.50percentboost")) {
|
// else if (player.hasPermission("mcmmo.perks.xp.50percentboost")) {
|
||||||
// xp = (int) (xp * 1.5);
|
// xp = (int) (xp * 1.5);
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerXpGainEvent(player, skillType, xp));
|
// mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerXpGainEvent(player, skillType, xp));
|
||||||
// skillsXp.put(skillType, skillsXp.get(skillType) + xp);
|
// skillsXp.put(skillType, skillsXp.get(skillType) + xp);
|
||||||
// spoutHud.setLastGained(skillType);
|
// spoutHud.setLastGained(skillType);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove XP from a skill.
|
* Remove XP from a skill.
|
||||||
@ -1114,49 +1114,49 @@ public class PlayerProfile {
|
|||||||
return 1020 + (skills.get(skillType) * Config.getInstance().getFormulaMultiplierCurve());
|
return 1020 + (skills.get(skillType) * Config.getInstance().getFormulaMultiplierCurve());
|
||||||
}
|
}
|
||||||
|
|
||||||
// /**
|
// /**
|
||||||
// * Gets the power level of a player.
|
// * Gets the power level of a player.
|
||||||
// *
|
// *
|
||||||
// * @return the power level of the player
|
// * @return the power level of the player
|
||||||
// */
|
// */
|
||||||
// public int getPowerLevel() {
|
// public int getPowerLevel() {
|
||||||
// int powerLevel = 0;
|
// int powerLevel = 0;
|
||||||
//
|
//
|
||||||
// for (SkillType type : SkillType.values()) {
|
// for (SkillType type : SkillType.values()) {
|
||||||
// if (type.getPermissions(player)) {
|
// if (type.getPermissions(player)) {
|
||||||
// powerLevel += getSkillLevel(type);
|
// powerLevel += getSkillLevel(type);
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// return powerLevel;
|
// return powerLevel;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// /**
|
// /**
|
||||||
// * Calculate the party XP modifier.
|
// * Calculate the party XP modifier.
|
||||||
// *
|
// *
|
||||||
// * @param skillType Type of skill to check
|
// * @param skillType Type of skill to check
|
||||||
// * @return the party bonus multiplier
|
// * @return the party bonus multiplier
|
||||||
// */
|
// */
|
||||||
// private double partyModifier(SkillType skillType) {
|
// private double partyModifier(SkillType skillType) {
|
||||||
// double bonusModifier = 0.0;
|
// double bonusModifier = 0.0;
|
||||||
//
|
//
|
||||||
// for (Player member : party.getOnlineMembers()) {
|
// for (Player member : party.getOnlineMembers()) {
|
||||||
// if (party.getLeader().equals(member.getName())) {
|
// if (party.getLeader().equals(member.getName())) {
|
||||||
// if (Misc.isNear(player.getLocation(), member.getLocation(), 25.0)) {
|
// if (Misc.isNear(player.getLocation(), member.getLocation(), 25.0)) {
|
||||||
// PlayerProfile PartyLeader = Users.getProfile(member);
|
// PlayerProfile PartyLeader = Users.getProfile(member);
|
||||||
// int leaderSkill = PartyLeader.getSkillLevel(skillType);
|
// int leaderSkill = PartyLeader.getSkillLevel(skillType);
|
||||||
// int playerSkill = getSkillLevel(skillType);
|
// int playerSkill = getSkillLevel(skillType);
|
||||||
//
|
//
|
||||||
// if (leaderSkill >= playerSkill) {
|
// if (leaderSkill >= playerSkill) {
|
||||||
// int difference = leaderSkill - playerSkill;
|
// int difference = leaderSkill - playerSkill;
|
||||||
// bonusModifier = (difference * 0.75) / 100.0;
|
// bonusModifier = (difference * 0.75) / 100.0;
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// return bonusModifier;
|
// return bonusModifier;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Party Stuff
|
* Party Stuff
|
||||||
|
@ -231,44 +231,44 @@ public class XpBar {
|
|||||||
|
|
||||||
private static Color getRetroColor(SkillType type) {
|
private static Color getRetroColor(SkillType type) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case ACROBATICS:
|
case ACROBATICS:
|
||||||
return new Color((float) SpoutConfig.getInstance().getRetroHUDAcrobaticsRed(), (float) SpoutConfig.getInstance().getRetroHUDAcrobaticsGreen(), (float) SpoutConfig.getInstance().getRetroHUDAcrobaticsBlue(), 1f);
|
return new Color((float) SpoutConfig.getInstance().getRetroHUDAcrobaticsRed(), (float) SpoutConfig.getInstance().getRetroHUDAcrobaticsGreen(), (float) SpoutConfig.getInstance().getRetroHUDAcrobaticsBlue(), 1f);
|
||||||
|
|
||||||
case ARCHERY:
|
case ARCHERY:
|
||||||
return new Color((float) SpoutConfig.getInstance().getRetroHUDArcheryRed(), (float) SpoutConfig.getInstance().getRetroHUDArcheryGreen(), (float) SpoutConfig.getInstance().getRetroHUDArcheryBlue(), 1f);
|
return new Color((float) SpoutConfig.getInstance().getRetroHUDArcheryRed(), (float) SpoutConfig.getInstance().getRetroHUDArcheryGreen(), (float) SpoutConfig.getInstance().getRetroHUDArcheryBlue(), 1f);
|
||||||
|
|
||||||
case AXES:
|
case AXES:
|
||||||
return new Color((float) SpoutConfig.getInstance().getRetroHUDAxesRed(), (float) SpoutConfig.getInstance().getRetroHUDAxesGreen(), (float) SpoutConfig.getInstance().getRetroHUDAxesBlue(), 1f);
|
return new Color((float) SpoutConfig.getInstance().getRetroHUDAxesRed(), (float) SpoutConfig.getInstance().getRetroHUDAxesGreen(), (float) SpoutConfig.getInstance().getRetroHUDAxesBlue(), 1f);
|
||||||
|
|
||||||
case EXCAVATION:
|
case EXCAVATION:
|
||||||
return new Color((float) SpoutConfig.getInstance().getRetroHUDExcavationRed(), (float) SpoutConfig.getInstance().getRetroHUDExcavationGreen(), (float) SpoutConfig.getInstance().getRetroHUDExcavationBlue(), 1f);
|
return new Color((float) SpoutConfig.getInstance().getRetroHUDExcavationRed(), (float) SpoutConfig.getInstance().getRetroHUDExcavationGreen(), (float) SpoutConfig.getInstance().getRetroHUDExcavationBlue(), 1f);
|
||||||
|
|
||||||
case HERBALISM:
|
case HERBALISM:
|
||||||
return new Color((float) SpoutConfig.getInstance().getRetroHUDHerbalismRed(), (float) SpoutConfig.getInstance().getRetroHUDHerbalismGreen(), (float) SpoutConfig.getInstance().getRetroHUDHerbalismBlue(), 1f);
|
return new Color((float) SpoutConfig.getInstance().getRetroHUDHerbalismRed(), (float) SpoutConfig.getInstance().getRetroHUDHerbalismGreen(), (float) SpoutConfig.getInstance().getRetroHUDHerbalismBlue(), 1f);
|
||||||
|
|
||||||
case MINING:
|
case MINING:
|
||||||
return new Color((float) SpoutConfig.getInstance().getRetroHUDMiningRed(), (float) SpoutConfig.getInstance().getRetroHUDMiningGreen(), (float) SpoutConfig.getInstance().getRetroHUDMiningBlue(), 1f);
|
return new Color((float) SpoutConfig.getInstance().getRetroHUDMiningRed(), (float) SpoutConfig.getInstance().getRetroHUDMiningGreen(), (float) SpoutConfig.getInstance().getRetroHUDMiningBlue(), 1f);
|
||||||
|
|
||||||
case REPAIR:
|
case REPAIR:
|
||||||
return new Color((float) SpoutConfig.getInstance().getRetroHUDRepairRed(), (float) SpoutConfig.getInstance().getRetroHUDRepairGreen(), (float) SpoutConfig.getInstance().getRetroHUDRepairBlue(), 1f);
|
return new Color((float) SpoutConfig.getInstance().getRetroHUDRepairRed(), (float) SpoutConfig.getInstance().getRetroHUDRepairGreen(), (float) SpoutConfig.getInstance().getRetroHUDRepairBlue(), 1f);
|
||||||
|
|
||||||
case SWORDS:
|
case SWORDS:
|
||||||
return new Color((float) SpoutConfig.getInstance().getRetroHUDSwordsRed(), (float) SpoutConfig.getInstance().getRetroHUDSwordsGreen(), (float) SpoutConfig.getInstance().getRetroHUDSwordsBlue(), 1f);
|
return new Color((float) SpoutConfig.getInstance().getRetroHUDSwordsRed(), (float) SpoutConfig.getInstance().getRetroHUDSwordsGreen(), (float) SpoutConfig.getInstance().getRetroHUDSwordsBlue(), 1f);
|
||||||
|
|
||||||
case TAMING:
|
case TAMING:
|
||||||
return new Color((float) SpoutConfig.getInstance().getRetroHUDTamingRed(), (float) SpoutConfig.getInstance().getRetroHUDTamingGreen(), (float) SpoutConfig.getInstance().getRetroHUDTamingBlue(), 1f);
|
return new Color((float) SpoutConfig.getInstance().getRetroHUDTamingRed(), (float) SpoutConfig.getInstance().getRetroHUDTamingGreen(), (float) SpoutConfig.getInstance().getRetroHUDTamingBlue(), 1f);
|
||||||
|
|
||||||
case UNARMED:
|
case UNARMED:
|
||||||
return new Color((float) SpoutConfig.getInstance().getRetroHUDUnarmedRed(), (float) SpoutConfig.getInstance().getRetroHUDUnarmedGreen(), (float) SpoutConfig.getInstance().getRetroHUDUnarmedBlue(), 1f);
|
return new Color((float) SpoutConfig.getInstance().getRetroHUDUnarmedRed(), (float) SpoutConfig.getInstance().getRetroHUDUnarmedGreen(), (float) SpoutConfig.getInstance().getRetroHUDUnarmedBlue(), 1f);
|
||||||
|
|
||||||
case WOODCUTTING:
|
case WOODCUTTING:
|
||||||
return new Color((float) SpoutConfig.getInstance().getRetroHUDWoodcuttingRed(), (float) SpoutConfig.getInstance().getRetroHUDWoodcuttingGreen(), (float) SpoutConfig.getInstance().getRetroHUDWoodcuttingBlue(), 1f);
|
return new Color((float) SpoutConfig.getInstance().getRetroHUDWoodcuttingRed(), (float) SpoutConfig.getInstance().getRetroHUDWoodcuttingGreen(), (float) SpoutConfig.getInstance().getRetroHUDWoodcuttingBlue(), 1f);
|
||||||
|
|
||||||
case FISHING:
|
case FISHING:
|
||||||
return new Color((float) SpoutConfig.getInstance().getRetroHUDFishingRed(), (float) SpoutConfig.getInstance().getRetroHUDFishingGreen(), (float) SpoutConfig.getInstance().getRetroHUDFishingBlue(), 1f);
|
return new Color((float) SpoutConfig.getInstance().getRetroHUDFishingRed(), (float) SpoutConfig.getInstance().getRetroHUDFishingGreen(), (float) SpoutConfig.getInstance().getRetroHUDFishingBlue(), 1f);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return new Color(0.3f, 0.3f, 0.75f, 1f);
|
return new Color(0.3f, 0.3f, 0.75f, 1f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,8 +84,8 @@ public class BlockListener implements Listener {
|
|||||||
*
|
*
|
||||||
* @param event The event to monitor
|
* @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)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void onBlockPhysics(BlockPhysicsEvent event) {
|
public void onBlockPhysics(BlockPhysicsEvent event) {
|
||||||
//TODO: Figure out how to REMOVE metadata from the location the sand/gravel fell from.
|
//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.
|
* Monitor BlockPistonRetract events.
|
||||||
|
@ -255,7 +255,7 @@ public class EntityListener implements Listener {
|
|||||||
*/
|
*/
|
||||||
@EventHandler (priority = EventPriority.LOW)
|
@EventHandler (priority = EventPriority.LOW)
|
||||||
public void onFoodLevelChange(FoodLevelChangeEvent event) {
|
public void onFoodLevelChange(FoodLevelChangeEvent event) {
|
||||||
AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
|
AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
|
||||||
if (event.getEntity() instanceof Player) {
|
if (event.getEntity() instanceof Player) {
|
||||||
Player player = (Player) event.getEntity();
|
Player player = (Player) event.getEntity();
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ public class PlayerListener implements Listener {
|
|||||||
*/
|
*/
|
||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
public void onPlayerFish(PlayerFishEvent event) {
|
public void onPlayerFish(PlayerFishEvent event) {
|
||||||
AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
|
AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
|
||||||
int shakeUnlockLevel = advancedConfig.getShakeUnlockLevel();
|
int shakeUnlockLevel = advancedConfig.getShakeUnlockLevel();
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
@ -131,7 +131,7 @@ public class PlayerListener implements Listener {
|
|||||||
@EventHandler(ignoreCancelled = true)
|
@EventHandler(ignoreCancelled = true)
|
||||||
public void onPlayerPickupItem(PlayerPickupItemEvent event) {
|
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());
|
PlayerProfile profile = Users.getProfile(event.getPlayer());
|
||||||
|
|
||||||
@ -140,7 +140,7 @@ public class PlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (profile.getAbilityMode(AbilityType.BERSERK)) {
|
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)
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
public void onPlayerLogin(PlayerLoginEvent event) {
|
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();
|
Users.addUser(event.getPlayer()).getProfile().actualizeRespawnATS();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -287,7 +287,7 @@ public class PlayerListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
public void onPlayerRespawn(PlayerRespawnEvent event) {
|
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());
|
PlayerProfile profile = Users.getProfile(event.getPlayer());
|
||||||
|
|
||||||
if (profile != null) {
|
if (profile != null) {
|
||||||
@ -331,8 +331,8 @@ public class PlayerListener implements Listener {
|
|||||||
/* SALVAGE CHECKS */
|
/* SALVAGE CHECKS */
|
||||||
if (Permissions.getInstance().salvage(player) && block.getTypeId() == Config.getInstance().getSalvageAnvilId()) {
|
if (Permissions.getInstance().salvage(player) && block.getTypeId() == Config.getInstance().getSalvageAnvilId()) {
|
||||||
if (Salvage.isSalvageable(inHand)) {
|
if (Salvage.isSalvageable(inHand)) {
|
||||||
final Location location = block.getLocation();
|
final Location location = block.getLocation();
|
||||||
Salvage.handleSalvage(player, location, inHand);
|
Salvage.handleSalvage(player, location, inHand);
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
player.updateInventory();
|
player.updateInventory();
|
||||||
}
|
}
|
||||||
|
@ -148,7 +148,7 @@ public class mcMMO extends JavaPlugin {
|
|||||||
|
|
||||||
//Check if Repair Anvil and Salvage Anvil have different itemID's
|
//Check if Repair Anvil and Salvage Anvil have different itemID's
|
||||||
if (configInstance.getSalvageAnvilId() == configInstance.getRepairAnvilId()){
|
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()) {
|
if (!configInstance.getUseMySQL()) {
|
||||||
|
@ -91,7 +91,7 @@ public class BleedTimer implements Runnable {
|
|||||||
if (bleedList.containsKey(entity)) {
|
if (bleedList.containsKey(entity)) {
|
||||||
Combat.dealDamage(entity, bleedList.get(entity) * 2);
|
Combat.dealDamage(entity, bleedList.get(entity) * 2);
|
||||||
bleedList.remove(entity);
|
bleedList.remove(entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -221,9 +221,9 @@ public class SQLConversionTask implements Runnable {
|
|||||||
+ playerName + "',"
|
+ playerName + "',"
|
||||||
+ System.currentTimeMillis() / 1000 + ")");
|
+ System.currentTimeMillis() / 1000 + ")");
|
||||||
id = database.getInt("SELECT id FROM "
|
id = database.getInt("SELECT id FROM "
|
||||||
+ tablePrefix
|
+ tablePrefix
|
||||||
+ "users WHERE user = '"
|
+ "users WHERE user = '"
|
||||||
+ playerName + "'");
|
+ playerName + "'");
|
||||||
database.write("INSERT INTO "
|
database.write("INSERT INTO "
|
||||||
+ tablePrefix
|
+ tablePrefix
|
||||||
+ "skills (user_id) VALUES (" + id + ")");
|
+ "skills (user_id) VALUES (" + id + ")");
|
||||||
|
@ -20,8 +20,8 @@ public class BlockStoreConversionMain implements Runnable {
|
|||||||
this.taskID = -1;
|
this.taskID = -1;
|
||||||
this.world = world;
|
this.world = world;
|
||||||
this.scheduler = mcMMO.p.getServer().getScheduler();
|
this.scheduler = mcMMO.p.getServer().getScheduler();
|
||||||
this.dataDir = new File(this.world.getWorldFolder(), "mcmmo_data");
|
this.dataDir = new File(this.world.getWorldFolder(), "mcmmo_data");
|
||||||
this.converters = new BlockStoreConversionXDirectory[HiddenConfig.getInstance().getConversionRate()];
|
this.converters = new BlockStoreConversionXDirectory[HiddenConfig.getInstance().getConversionRate()];
|
||||||
}
|
}
|
||||||
|
|
||||||
public void start() {
|
public void start() {
|
||||||
@ -32,6 +32,7 @@ public class BlockStoreConversionMain implements Runnable {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if(!this.dataDir.exists()) {
|
if(!this.dataDir.exists()) {
|
||||||
softStop();
|
softStop();
|
||||||
|
@ -33,6 +33,7 @@ public class BlockStoreConversionXDirectory implements Runnable {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if(!this.dataDir.exists()) {
|
if(!this.dataDir.exists()) {
|
||||||
stop();
|
stop();
|
||||||
@ -51,7 +52,7 @@ public class BlockStoreConversionXDirectory implements Runnable {
|
|||||||
return;
|
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++) {
|
for (this.i = 0; (this.i < HiddenConfig.getInstance().getConversionRate()) && (this.i < this.zDirs.length); this.i++) {
|
||||||
if(this.converters[this.i] == null)
|
if(this.converters[this.i] == null)
|
||||||
@ -70,10 +71,10 @@ public class BlockStoreConversionXDirectory implements Runnable {
|
|||||||
this.scheduler.cancelTask(this.taskID);
|
this.scheduler.cancelTask(this.taskID);
|
||||||
this.taskID = -1;
|
this.taskID = -1;
|
||||||
|
|
||||||
this.dataDir = null;
|
this.dataDir = null;
|
||||||
this.zDirs = null;
|
this.zDirs = null;
|
||||||
this.world = null;
|
this.world = null;
|
||||||
this.scheduler = null;
|
this.scheduler = null;
|
||||||
this.converters = null;
|
this.converters = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -47,6 +47,7 @@ public class BlockStoreConversionZDirectory implements Runnable {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if(!this.dataDir.exists()) {
|
if(!this.dataDir.exists()) {
|
||||||
stop();
|
stop();
|
||||||
@ -84,7 +85,7 @@ public class BlockStoreConversionZDirectory implements Runnable {
|
|||||||
|
|
||||||
for(this.y = 0; this.y < (this.world.getMaxHeight() / 64); this.y++) {
|
for(this.y = 0; this.y < (this.world.getMaxHeight() / 64); this.y++) {
|
||||||
this.chunkletName = this.world.getName() + "," + this.cx + "," + this.cz + "," + 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)
|
if(this.tempChunklet instanceof PrimitiveChunkletStore)
|
||||||
this.primitiveChunklet = (PrimitiveChunkletStore) this.tempChunklet;
|
this.primitiveChunklet = (PrimitiveChunkletStore) this.tempChunklet;
|
||||||
else if(this.tempChunklet instanceof PrimitiveExChunkletStore)
|
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.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);
|
this.currentChunk = (PrimitiveChunkStore) this.newManager.store.get(this.chunkName);
|
||||||
|
|
||||||
for(this.x = 0; this.x < 16; this.x++) {
|
for(this.x = 0; this.x < 16; this.x++) {
|
||||||
|
@ -57,7 +57,7 @@ public class ArcheryManager {
|
|||||||
if (player.hasPermission("mcmmo.perks.lucky.archery")) {
|
if (player.hasPermission("mcmmo.perks.lucky.archery")) {
|
||||||
randomChance = (int) (randomChance * 0.75);
|
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)) {
|
if (chance > Archery.getRandom().nextInt(randomChance)) {
|
||||||
eventHandler.addToTracker();
|
eventHandler.addToTracker();
|
||||||
}
|
}
|
||||||
@ -88,7 +88,7 @@ public class ArcheryManager {
|
|||||||
randomChance = (int) (randomChance * 0.75);
|
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)) {
|
if (chance > Archery.getRandom().nextInt(randomChance)) {
|
||||||
eventHandler.handleDazeEffect();
|
eventHandler.handleDazeEffect();
|
||||||
eventHandler.sendAbilityMessages();
|
eventHandler.sendAbilityMessages();
|
||||||
|
@ -87,14 +87,14 @@ public class Axes {
|
|||||||
int skillCheck = Misc.skillCheck(skillLevel, MAX_BONUS_LEVEL);
|
int skillCheck = Misc.skillCheck(skillLevel, MAX_BONUS_LEVEL);
|
||||||
|
|
||||||
int randomChance = 100;
|
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")) {
|
if (attacker.hasPermission("mcmmo.perks.lucky.axes")) {
|
||||||
randomChance = (int) (randomChance * 0.75);
|
randomChance = (int) (randomChance * 0.75);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chance > random.nextInt(randomChance) && !entity.isDead()){
|
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();
|
int damage = event.getDamage();
|
||||||
|
|
||||||
if (entity instanceof Player){
|
if (entity instanceof Player){
|
||||||
|
@ -317,7 +317,7 @@ public class BlastMining {
|
|||||||
player.sendMessage(LocaleLoader.getString("Mining.Blast.Boom"));
|
player.sendMessage(LocaleLoader.getString("Mining.Blast.Boom"));
|
||||||
|
|
||||||
/* Create the TNT entity */
|
/* 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);
|
TNTPrimed tnt = player.getWorld().spawn(block.getLocation(), TNTPrimed.class);
|
||||||
plugin.addToTNTTracker(tnt.getEntityId(), player.getName());
|
plugin.addToTNTTracker(tnt.getEntityId(), player.getName());
|
||||||
tnt.setFuseTicks(0);
|
tnt.setFuseTicks(0);
|
||||||
|
@ -41,7 +41,8 @@ public class Fishing {
|
|||||||
/**
|
/**
|
||||||
* Get the player's current fishing loot tier.
|
* 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
|
* @return the player's current fishing rank
|
||||||
*/
|
*/
|
||||||
public static int getFishingLootTier(PlayerProfile profile) {
|
public static int getFishingLootTier(PlayerProfile profile) {
|
||||||
@ -50,18 +51,14 @@ public class Fishing {
|
|||||||
|
|
||||||
if (level >= Config.getInstance().getFishingTierLevelsTier5()) {
|
if (level >= Config.getInstance().getFishingTierLevelsTier5()) {
|
||||||
fishingTier = 5;
|
fishingTier = 5;
|
||||||
}
|
} else if (level >= Config.getInstance().getFishingTierLevelsTier4()) {
|
||||||
else if (level >= Config.getInstance().getFishingTierLevelsTier4()) {
|
|
||||||
fishingTier = 4;
|
fishingTier = 4;
|
||||||
}
|
} else if (level >= Config.getInstance().getFishingTierLevelsTier3()) {
|
||||||
else if (level >= Config.getInstance().getFishingTierLevelsTier3()) {
|
fishingTier = 3;
|
||||||
fishingTier = 3;
|
} else if (level >= Config.getInstance().getFishingTierLevelsTier2()) {
|
||||||
}
|
fishingTier = 2;
|
||||||
else if (level >= Config.getInstance().getFishingTierLevelsTier2()) {
|
} else {
|
||||||
fishingTier = 2;
|
fishingTier = 1;
|
||||||
}
|
|
||||||
else {
|
|
||||||
fishingTier = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return fishingTier;
|
return fishingTier;
|
||||||
@ -70,11 +67,13 @@ public class Fishing {
|
|||||||
/**
|
/**
|
||||||
* Get item results from Fishing.
|
* Get item results from Fishing.
|
||||||
*
|
*
|
||||||
* @param player The player that was fishing
|
* @param player
|
||||||
* @param event The event to modify
|
* The player that was fishing
|
||||||
|
* @param event
|
||||||
|
* The event to modify
|
||||||
*/
|
*/
|
||||||
private static void getFishingResults(Player player, PlayerFishEvent event) {
|
private static void getFishingResults(Player player, PlayerFishEvent event) {
|
||||||
if(player == null)
|
if (player == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
PlayerProfile profile = Users.getProfile(player);
|
PlayerProfile profile = Users.getProfile(player);
|
||||||
@ -106,8 +105,10 @@ public class Fishing {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Config.getInstance().getFishingDropsEnabled() && rewards.size() > 0 && Permissions.getInstance().fishingTreasures(player)) {
|
if (Config.getInstance().getFishingDropsEnabled() && rewards.size() > 0
|
||||||
FishingTreasure treasure = rewards.get(random.nextInt(rewards.size()));
|
&& Permissions.getInstance().fishingTreasures(player)) {
|
||||||
|
FishingTreasure treasure = rewards.get(random.nextInt(rewards
|
||||||
|
.size()));
|
||||||
|
|
||||||
int randomChance = 100;
|
int randomChance = 100;
|
||||||
|
|
||||||
@ -116,31 +117,37 @@ public class Fishing {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (random.nextDouble() * randomChance <= treasure.getDropChance()) {
|
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());
|
theCatch.setItemStack(treasure.getDrop());
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
theCatch.setItemStack(new ItemStack(Material.RAW_FISH));
|
theCatch.setItemStack(new ItemStack(Material.RAW_FISH));
|
||||||
}
|
}
|
||||||
|
|
||||||
short maxDurability = theCatch.getItemStack().getType().getMaxDurability();
|
short maxDurability = theCatch.getItemStack().getType()
|
||||||
|
.getMaxDurability();
|
||||||
|
|
||||||
if (maxDurability > 0) {
|
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.
|
* Process results from Fishing.
|
||||||
*
|
*
|
||||||
* @param event The event to modify
|
* @param event
|
||||||
|
* The event to modify
|
||||||
*/
|
*/
|
||||||
public static void processResults(PlayerFishEvent event) {
|
public static void processResults(PlayerFishEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
if(player == null)
|
if (player == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
PlayerProfile profile = Users.getProfile(player);
|
PlayerProfile profile = Users.getProfile(player);
|
||||||
@ -149,7 +156,8 @@ public class Fishing {
|
|||||||
Item theCatch = (Item) event.getCaught();
|
Item theCatch = (Item) event.getCaught();
|
||||||
|
|
||||||
if (theCatch.getItemStack().getType() != Material.RAW_FISH) {
|
if (theCatch.getItemStack().getType() != Material.RAW_FISH) {
|
||||||
final int ENCHANTMENT_CHANCE = advancedConfig.getFishingEnchantmentChance();
|
final int ENCHANTMENT_CHANCE = advancedConfig
|
||||||
|
.getFishingEnchantmentChance();
|
||||||
boolean enchanted = false;
|
boolean enchanted = false;
|
||||||
ItemStack fishingResults = theCatch.getItemStack();
|
ItemStack fishingResults = theCatch.getItemStack();
|
||||||
|
|
||||||
@ -162,29 +170,40 @@ public class Fishing {
|
|||||||
randomChance = (int) (randomChance * 0.75);
|
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()) {
|
for (Enchantment newEnchant : Enchantment.values()) {
|
||||||
if (newEnchant.canEnchantItem(fishingResults)) {
|
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))
|
if (oldEnchant.conflictsWith(newEnchant))
|
||||||
continue;
|
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;
|
enchanted = true;
|
||||||
int randomEnchantLevel = random.nextInt(newEnchant.getMaxLevel()) + 1;
|
int randomEnchantLevel = random
|
||||||
|
.nextInt(newEnchant.getMaxLevel()) + 1;
|
||||||
|
|
||||||
if (randomEnchantLevel < newEnchant.getStartLevel()) {
|
if (randomEnchantLevel < newEnchant
|
||||||
randomEnchantLevel = newEnchant.getStartLevel();
|
.getStartLevel()) {
|
||||||
|
randomEnchantLevel = newEnchant
|
||||||
|
.getStartLevel();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(randomEnchantLevel >= 1000)
|
if (randomEnchantLevel >= 1000)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
fishingResults.addEnchantment(newEnchant, randomEnchantLevel);
|
fishingResults.addEnchantment(newEnchant,
|
||||||
|
randomEnchantLevel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -200,7 +219,8 @@ public class Fishing {
|
|||||||
/**
|
/**
|
||||||
* Shake a mob, have them drop an item.
|
* 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) {
|
public static void shakeMob(PlayerFishEvent event) {
|
||||||
int randomChance = 100;
|
int randomChance = 100;
|
||||||
@ -216,7 +236,8 @@ public class Fishing {
|
|||||||
int dropChance = getShakeChance(lootTier);
|
int dropChance = getShakeChance(lootTier);
|
||||||
|
|
||||||
if (event.getPlayer().hasPermission("mcmmo.perks.lucky.fishing")) {
|
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);
|
final int DROP_CHANCE = random.nextInt(100);
|
||||||
@ -263,7 +284,8 @@ public class Fishing {
|
|||||||
|
|
||||||
case CREEPER:
|
case CREEPER:
|
||||||
if (DROP_NUMBER > 97) {
|
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 {
|
} else {
|
||||||
Misc.dropItem(location, new ItemStack(Material.SULPHUR));
|
Misc.dropItem(location, new ItemStack(Material.SULPHUR));
|
||||||
}
|
}
|
||||||
@ -299,14 +321,17 @@ public class Fishing {
|
|||||||
if (DROP_NUMBER > 95) {
|
if (DROP_NUMBER > 95) {
|
||||||
Misc.dropItem(location, new ItemStack(Material.MILK_BUCKET));
|
Misc.dropItem(location, new ItemStack(Material.MILK_BUCKET));
|
||||||
} else if (DROP_NUMBER > 90) {
|
} 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) {
|
} else if (DROP_NUMBER > 60) {
|
||||||
Misc.dropItem(location, new ItemStack(Material.LEATHER));
|
Misc.dropItem(location, new ItemStack(Material.LEATHER));
|
||||||
} else if (DROP_NUMBER > 30) {
|
} else if (DROP_NUMBER > 30) {
|
||||||
Misc.dropItem(location, new ItemStack(Material.RAW_BEEF));
|
Misc.dropItem(location, new ItemStack(Material.RAW_BEEF));
|
||||||
} else {
|
} else {
|
||||||
Misc.dropItem(location, new ItemStack(Material.RED_MUSHROOM));
|
Misc.dropItem(location,
|
||||||
Misc.randomDropItems(location, new ItemStack(Material.RED_MUSHROOM), 50, 2);
|
new ItemStack(Material.RED_MUSHROOM));
|
||||||
|
Misc.randomDropItems(location, new ItemStack(
|
||||||
|
Material.RED_MUSHROOM), 50, 2);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -316,7 +341,8 @@ public class Fishing {
|
|||||||
|
|
||||||
case PIG_ZOMBIE:
|
case PIG_ZOMBIE:
|
||||||
if (DROP_NUMBER > 50) {
|
if (DROP_NUMBER > 50) {
|
||||||
Misc.dropItem(location, new ItemStack(Material.ROTTEN_FLESH));
|
Misc.dropItem(location,
|
||||||
|
new ItemStack(Material.ROTTEN_FLESH));
|
||||||
} else {
|
} else {
|
||||||
Misc.dropItem(location, new ItemStack(Material.GOLD_NUGGET));
|
Misc.dropItem(location, new ItemStack(Material.GOLD_NUGGET));
|
||||||
}
|
}
|
||||||
@ -338,23 +364,27 @@ public class Fishing {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case SKELETON:
|
case SKELETON:
|
||||||
if (((Skeleton)le).getSkeletonType() == SkeletonType.WITHER) {
|
if (((Skeleton) le).getSkeletonType() == SkeletonType.WITHER) {
|
||||||
if (DROP_NUMBER > 97) {
|
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) {
|
} else if (DROP_NUMBER > 50) {
|
||||||
Misc.dropItem(location, new ItemStack(Material.BONE));
|
Misc.dropItem(location, new ItemStack(Material.BONE));
|
||||||
} else {
|
} else {
|
||||||
Misc.dropItem(location, new ItemStack(Material.COAL));
|
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 {
|
} else {
|
||||||
if (DROP_NUMBER > 97) {
|
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) {
|
} else if (DROP_NUMBER > 50) {
|
||||||
Misc.dropItem(location, new ItemStack(Material.BONE));
|
Misc.dropItem(location, new ItemStack(Material.BONE));
|
||||||
} else {
|
} else {
|
||||||
Misc.dropItem(location, new ItemStack(Material.ARROW));
|
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;
|
break;
|
||||||
@ -368,7 +398,8 @@ public class Fishing {
|
|||||||
Misc.dropItem(location, new ItemStack(Material.PUMPKIN));
|
Misc.dropItem(location, new ItemStack(Material.PUMPKIN));
|
||||||
} else {
|
} else {
|
||||||
Misc.dropItem(location, new ItemStack(Material.SNOW_BALL));
|
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;
|
break;
|
||||||
|
|
||||||
@ -381,30 +412,38 @@ public class Fishing {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case SQUID:
|
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;
|
break;
|
||||||
|
|
||||||
case WITCH:
|
case WITCH:
|
||||||
final int DROP_NUMBER_2 = random.nextInt(randomChance) + 1;
|
final int DROP_NUMBER_2 = random.nextInt(randomChance) + 1;
|
||||||
if (DROP_NUMBER > 95) {
|
if (DROP_NUMBER > 95) {
|
||||||
if (DROP_NUMBER_2 > 66) {
|
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) {
|
} 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 {
|
} else {
|
||||||
Misc.dropItem(location, new ItemStack(Material.POTION, 1, (short) 8194));
|
Misc.dropItem(location, new ItemStack(Material.POTION,
|
||||||
|
1, (short) 8194));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (DROP_NUMBER_2 > 88) {
|
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) {
|
} 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) {
|
} else if (DROP_NUMBER_2 > 63) {
|
||||||
Misc.dropItem(location, new ItemStack(Material.SULPHUR));
|
Misc.dropItem(location, new ItemStack(Material.SULPHUR));
|
||||||
} else if (DROP_NUMBER_2 > 50) {
|
} 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) {
|
} 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) {
|
} else if (DROP_NUMBER_2 > 25) {
|
||||||
Misc.dropItem(location, new ItemStack(Material.STICK));
|
Misc.dropItem(location, new ItemStack(Material.STICK));
|
||||||
} else if (DROP_NUMBER_2 > 13) {
|
} else if (DROP_NUMBER_2 > 13) {
|
||||||
@ -417,9 +456,11 @@ public class Fishing {
|
|||||||
|
|
||||||
case ZOMBIE:
|
case ZOMBIE:
|
||||||
if (DROP_NUMBER > 97) {
|
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 {
|
} else {
|
||||||
Misc.dropItem(location, new ItemStack(Material.ROTTEN_FLESH));
|
Misc.dropItem(location,
|
||||||
|
new ItemStack(Material.ROTTEN_FLESH));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -430,10 +471,12 @@ public class Fishing {
|
|||||||
|
|
||||||
Combat.dealDamage(le, 1);
|
Combat.dealDamage(le, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets chance of shake success.
|
* Gets chance of shake success.
|
||||||
*
|
*
|
||||||
* @param rank Treasure hunter rank
|
* @param rank
|
||||||
|
* Treasure hunter rank
|
||||||
* @return The chance of a successful shake
|
* @return The chance of a successful shake
|
||||||
*/
|
*/
|
||||||
public static int getShakeChance(int lootTier) {
|
public static int getShakeChance(int lootTier) {
|
||||||
|
@ -205,7 +205,7 @@ public class Herbalism {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case COCOA:
|
case COCOA:
|
||||||
if ((((byte) data) & 0x8) == 0x8) {
|
if (((data) & 0x8) == 0x8) {
|
||||||
mat = Material.COCOA;
|
mat = Material.COCOA;
|
||||||
xp = Config.getInstance().getHerbalismXPCocoa();
|
xp = Config.getInstance().getHerbalismXPCocoa();
|
||||||
|
|
||||||
|
@ -329,7 +329,7 @@ public class Mining {
|
|||||||
int skillCheck = Misc.skillCheck(skillLevel, MAX_BONUS_LEVEL);
|
int skillCheck = Misc.skillCheck(skillLevel, MAX_BONUS_LEVEL);
|
||||||
|
|
||||||
int randomChance = 100;
|
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")) {
|
if (player.hasPermission("mcmmo.perks.lucky.mining")) {
|
||||||
randomChance = (int) (randomChance * 0.75);
|
randomChance = (int) (randomChance * 0.75);
|
||||||
|
@ -173,24 +173,24 @@ public class WoodCutting {
|
|||||||
WoodCutting.woodCuttingProcCheck(player, x);
|
WoodCutting.woodCuttingProcCheck(player, x);
|
||||||
|
|
||||||
switch (species) {
|
switch (species) {
|
||||||
case GENERIC:
|
case GENERIC:
|
||||||
xp += Config.getInstance().getWoodcuttingXPOak();
|
xp += Config.getInstance().getWoodcuttingXPOak();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case REDWOOD:
|
case REDWOOD:
|
||||||
xp += Config.getInstance().getWoodcuttingXPSpruce();
|
xp += Config.getInstance().getWoodcuttingXPSpruce();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BIRCH:
|
case BIRCH:
|
||||||
xp += Config.getInstance().getWoodcuttingXPBirch();
|
xp += Config.getInstance().getWoodcuttingXPBirch();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case JUNGLE:
|
case JUNGLE:
|
||||||
xp += Config.getInstance().getWoodcuttingXPJungle() / 2; //Nerf XP from Jungle Trees when using Tree Feller
|
xp += Config.getInstance().getWoodcuttingXPJungle() / 2; //Nerf XP from Jungle Trees when using Tree Feller
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -345,7 +345,7 @@ public class WoodCutting {
|
|||||||
Material mat = Material.getMaterial(block.getTypeId());
|
Material mat = Material.getMaterial(block.getTypeId());
|
||||||
|
|
||||||
int randomChance = 100;
|
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")) {
|
if (player.hasPermission("mcmmo.perks.lucky.woodcutting")) {
|
||||||
randomChance = (int) (randomChance * 0.75);
|
randomChance = (int) (randomChance * 0.75);
|
||||||
|
@ -224,7 +224,7 @@ public class Repair {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(repairAmount <= 0 || repairAmount > 32767)
|
if(repairAmount <= 0 || repairAmount > 32767)
|
||||||
repairAmount = 32767;
|
repairAmount = 32767;
|
||||||
|
|
||||||
durability -= repairAmount;
|
durability -= repairAmount;
|
||||||
|
|
||||||
@ -248,7 +248,7 @@ public class Repair {
|
|||||||
int skillLevel = Users.getProfile(player).getSkillLevel(SkillType.REPAIR);
|
int skillLevel = Users.getProfile(player).getSkillLevel(SkillType.REPAIR);
|
||||||
|
|
||||||
int randomChance = 100;
|
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 (skillLevel >= MAX_BONUS_LEVEL) chance = MAX_CHANCE;
|
||||||
|
|
||||||
if (player.hasPermission("mcmmo.perks.lucky.repair")) randomChance = (int) (randomChance * 0.75);
|
if (player.hasPermission("mcmmo.perks.lucky.repair")) randomChance = (int) (randomChance * 0.75);
|
||||||
|
@ -29,27 +29,27 @@ public class Salvage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(player.getGameMode() == GameMode.SURVIVAL) {
|
if(player.getGameMode() == GameMode.SURVIVAL) {
|
||||||
final PlayerProfile profile = Users.getProfile(player);
|
final PlayerProfile profile = Users.getProfile(player);
|
||||||
final int skillLevel = profile.getSkillLevel(SkillType.REPAIR);
|
final int skillLevel = profile.getSkillLevel(SkillType.REPAIR);
|
||||||
final int unlockLevel = configInstance.getSalvageUnlockLevel();
|
final int unlockLevel = configInstance.getSalvageUnlockLevel();
|
||||||
|
|
||||||
if (skillLevel >= unlockLevel) {
|
if (skillLevel >= unlockLevel) {
|
||||||
final float currentdura = inHand.getDurability();
|
final float currentdura = inHand.getDurability();
|
||||||
|
|
||||||
if (currentdura == 0) {
|
if (currentdura == 0) {
|
||||||
final int salvagedAmount = getSalvagedAmount(inHand);
|
final int salvagedAmount = getSalvagedAmount(inHand);
|
||||||
final int itemID = getSalvagedItemID(inHand);
|
final int itemID = getSalvagedItemID(inHand);
|
||||||
|
|
||||||
player.setItemInHand(new ItemStack(0));
|
player.setItemInHand(new ItemStack(0));
|
||||||
location.setY(location.getY() + 1);
|
location.setY(location.getY() + 1);
|
||||||
Misc.dropItem(location, new ItemStack(itemID, salvagedAmount));
|
Misc.dropItem(location, new ItemStack(itemID, salvagedAmount));
|
||||||
player.sendMessage(LocaleLoader.getString("Repair.Skills.SalvageSuccess"));
|
player.sendMessage(LocaleLoader.getString("Repair.Skills.SalvageSuccess"));
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(LocaleLoader.getString("Repair.Skills.NotFullDurability"));
|
player.sendMessage(LocaleLoader.getString("Repair.Skills.NotFullDurability"));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(LocaleLoader.getString("Repair.Skills.AdeptSalvage"));
|
player.sendMessage(LocaleLoader.getString("Repair.Skills.AdeptSalvage"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,12 +38,12 @@ public class SimpleRepairable implements Repairable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RepairItemType getRepairItemType() {
|
public RepairItemType getRepairItemType() {
|
||||||
return repairItemType;
|
return repairItemType;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RepairMaterialType getRepairMaterialType() {
|
public RepairMaterialType getRepairMaterialType() {
|
||||||
return repairMaterialType;
|
return repairMaterialType;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -50,7 +50,7 @@ public class SwordsManager {
|
|||||||
randomChance = (int) (randomChance * 0.75);
|
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)) {
|
if (chance > Swords.getRandom().nextInt(randomChance)) {
|
||||||
eventHandler.addBleedTicks();
|
eventHandler.addBleedTicks();
|
||||||
eventHandler.sendAbilityMessages();
|
eventHandler.sendAbilityMessages();
|
||||||
@ -81,7 +81,7 @@ public class SwordsManager {
|
|||||||
randomChance = (int) (randomChance * 0.75);
|
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)) {
|
if (chance > Swords.getRandom().nextInt(randomChance)) {
|
||||||
eventHandler.dealDamage();
|
eventHandler.dealDamage();
|
||||||
eventHandler.sendAbilityMessages();
|
eventHandler.sendAbilityMessages();
|
||||||
|
@ -111,7 +111,7 @@ public class TamingManager {
|
|||||||
randomChance = (int) (randomChance * 0.75);
|
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)) {
|
if (chance > Taming.getRandom().nextInt(randomChance)) {
|
||||||
eventHandler.modifyEventDamage();
|
eventHandler.modifyEventDamage();
|
||||||
eventHandler.applyBleed();
|
eventHandler.applyBleed();
|
||||||
@ -281,9 +281,9 @@ public class TamingManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (skillLevel >= Taming.THICK_FUR_ACTIVATION_LEVEL) {
|
if (skillLevel >= Taming.THICK_FUR_ACTIVATION_LEVEL) {
|
||||||
ThickFurEventHandler eventHandler = new ThickFurEventHandler(event, cause);
|
ThickFurEventHandler eventHandler = new ThickFurEventHandler(event, cause);
|
||||||
|
|
||||||
eventHandler.modifyEventDamage();
|
eventHandler.modifyEventDamage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ public class UnarmedManager {
|
|||||||
randomChance = (int) (randomChance * 0.75);
|
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 (chance > Unarmed.getRandom().nextInt(randomChance)) {
|
||||||
if (!hasIronGrip(defender)) {
|
if (!hasIronGrip(defender)) {
|
||||||
eventHandler.sendAbilityMessage();
|
eventHandler.sendAbilityMessage();
|
||||||
@ -88,7 +88,7 @@ public class UnarmedManager {
|
|||||||
randomChance = (int) (randomChance * 0.75);
|
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)) {
|
if (chance > Unarmed.getRandom().nextInt(randomChance)) {
|
||||||
eventHandler.cancelEvent();
|
eventHandler.cancelEvent();
|
||||||
eventHandler.sendAbilityMessage();
|
eventHandler.sendAbilityMessage();
|
||||||
@ -144,7 +144,7 @@ public class UnarmedManager {
|
|||||||
randomChance = (int) (randomChance * 0.75);
|
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)) {
|
if (chance > Unarmed.getRandom().nextInt(randomChance)) {
|
||||||
eventHandler.sendAbilityMessages();
|
eventHandler.sendAbilityMessages();
|
||||||
return true;
|
return true;
|
||||||
|
@ -63,15 +63,15 @@ public class Database {
|
|||||||
System.out.println("[mcMMO] Connection to MySQL was a success!");
|
System.out.println("[mcMMO] Connection to MySQL was a success!");
|
||||||
}
|
}
|
||||||
catch (SQLException ex) {
|
catch (SQLException ex) {
|
||||||
connection = null;
|
connection = null;
|
||||||
System.out.println("[mcMMO] Connection to MySQL failed!");
|
System.out.println("[mcMMO] Connection to MySQL failed!");
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
printErrors(ex);
|
printErrors(ex);
|
||||||
} catch (ClassNotFoundException ex) {
|
} catch (ClassNotFoundException ex) {
|
||||||
connection = null;
|
connection = null;
|
||||||
System.out.println("[mcMMO] MySQL database driver not found!");
|
System.out.println("[mcMMO] MySQL database driver not found!");
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -186,20 +186,20 @@ public class Database {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
if (resultSet != null) {
|
if (resultSet != null) {
|
||||||
try {
|
|
||||||
resultSet.close();
|
|
||||||
} catch (SQLException e) {
|
|
||||||
// Ignore the error, we're leaving
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (statement != null) {
|
|
||||||
try {
|
try {
|
||||||
statement.close();
|
resultSet.close();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
// Ignore the error, we're leaving
|
// 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) {
|
public boolean write(String sql) {
|
||||||
if (checkConnected()) {
|
if (checkConnected()) {
|
||||||
PreparedStatement statement = null;
|
PreparedStatement statement = null;
|
||||||
try {
|
try {
|
||||||
statement = connection.prepareStatement(sql);
|
statement = connection.prepareStatement(sql);
|
||||||
statement.executeUpdate();
|
statement.executeUpdate();
|
||||||
@ -221,14 +221,14 @@ public class Database {
|
|||||||
printErrors(ex);
|
printErrors(ex);
|
||||||
return false;
|
return false;
|
||||||
} finally {
|
} finally {
|
||||||
if (statement != null) {
|
if (statement != null) {
|
||||||
try {
|
try {
|
||||||
statement.close();
|
statement.close();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
printErrors(e);
|
printErrors(e);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -283,80 +283,80 @@ public class Database {
|
|||||||
* @return the boolean value for whether or not we are connected
|
* @return the boolean value for whether or not we are connected
|
||||||
*/
|
*/
|
||||||
public static boolean checkConnected() {
|
public static boolean checkConnected() {
|
||||||
boolean isClosed = true;
|
boolean isClosed = true;
|
||||||
boolean isValid = false;
|
boolean isValid = false;
|
||||||
boolean exists = (connection != null);
|
boolean exists = (connection != null);
|
||||||
|
|
||||||
// Initialized as needed later
|
// Initialized as needed later
|
||||||
long timestamp=0;
|
long timestamp=0;
|
||||||
|
|
||||||
// If we're waiting for server to recover then leave early
|
// If we're waiting for server to recover then leave early
|
||||||
if (nextReconnectTimestamp > 0 && nextReconnectTimestamp > System.nanoTime()) {
|
if (nextReconnectTimestamp > 0 && nextReconnectTimestamp > System.nanoTime()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (exists) {
|
if (exists) {
|
||||||
try {
|
try {
|
||||||
isClosed = connection.isClosed();
|
isClosed = connection.isClosed();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
isClosed = true;
|
isClosed = true;
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
printErrors(e);
|
printErrors(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isClosed) {
|
if (!isClosed) {
|
||||||
try {
|
try {
|
||||||
isValid = connection.isValid(VALID_TIMEOUT);
|
isValid = connection.isValid(VALID_TIMEOUT);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
// Don't print stack trace because it's valid to lose idle connections
|
// Don't print stack trace because it's valid to lose idle connections
|
||||||
// to the server and have to restart them.
|
// to the server and have to restart them.
|
||||||
isValid = false;
|
isValid = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Leave if all ok
|
// Leave if all ok
|
||||||
if (exists && !isClosed && isValid) {
|
if (exists && !isClosed && isValid) {
|
||||||
// Housekeeping
|
// Housekeeping
|
||||||
nextReconnectTimestamp = 0;
|
nextReconnectTimestamp = 0;
|
||||||
reconnectAttempt = 0;
|
reconnectAttempt = 0;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cleanup after ourselves for GC and MySQL's sake
|
// Cleanup after ourselves for GC and MySQL's sake
|
||||||
if (exists && !isClosed) {
|
if (exists && !isClosed) {
|
||||||
try {
|
try {
|
||||||
connection.close();
|
connection.close();
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
// This is a housekeeping exercise, ignore errors
|
// This is a housekeeping exercise, ignore errors
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try to connect again
|
// Try to connect again
|
||||||
connect();
|
connect();
|
||||||
|
|
||||||
// Leave if connection is good
|
// Leave if connection is good
|
||||||
try {
|
try {
|
||||||
if (connection != null && !connection.isClosed()) {
|
if (connection != null && !connection.isClosed()) {
|
||||||
// Schedule a database save if we really had an outage
|
// Schedule a database save if we really had an outage
|
||||||
if (reconnectAttempt > 1) {
|
if (reconnectAttempt > 1) {
|
||||||
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new SQLReconnect(plugin), 5);
|
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new SQLReconnect(plugin), 5);
|
||||||
}
|
}
|
||||||
nextReconnectTimestamp = 0;
|
nextReconnectTimestamp = 0;
|
||||||
reconnectAttempt = 0;
|
reconnectAttempt = 0;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
// Failed to check isClosed, so presume connection is bad and attempt later
|
// Failed to check isClosed, so presume connection is bad and attempt later
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
printErrors(e);
|
printErrors(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
reconnectAttempt++;
|
reconnectAttempt++;
|
||||||
|
|
||||||
nextReconnectTimestamp = (long)(System.nanoTime() + Math.min(MAX_WAIT, (reconnectAttempt*SCALING_FACTOR*MIN_WAIT)));
|
nextReconnectTimestamp = (long)(System.nanoTime() + Math.min(MAX_WAIT, (reconnectAttempt*SCALING_FACTOR*MIN_WAIT)));
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -394,12 +394,12 @@ public class ItemChecks {
|
|||||||
*/
|
*/
|
||||||
public static boolean isStringTool(ItemStack is) {
|
public static boolean isStringTool(ItemStack is) {
|
||||||
switch (is.getType()) {
|
switch (is.getType()) {
|
||||||
case BOW:
|
case BOW:
|
||||||
case FISHING_ROD:
|
case FISHING_ROD:
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -217,7 +217,7 @@ public class Leaderboard {
|
|||||||
BufferedReader in = new BufferedReader(file);
|
BufferedReader in = new BufferedReader(file);
|
||||||
int destination;
|
int destination;
|
||||||
|
|
||||||
//How many lines to skip through
|
//How many lines to skip through
|
||||||
if (pagenumber == 1) {
|
if (pagenumber == 1) {
|
||||||
destination = 0;
|
destination = 0;
|
||||||
}
|
}
|
||||||
|
@ -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.
|
* Enables metrics for the server by setting "opt-out" to false in the config file and starting the metrics task.
|
||||||
*
|
*
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public void enable() throws IOException {
|
public void enable() throws IOException {
|
||||||
// This has to be synchronized or it can collide with the check in the task.
|
// This has to be synchronized or it can collide with the check in the task.
|
||||||
synchronized (optOutLock) {
|
synchronized (optOutLock) {
|
||||||
// Check if the server owner has already set opt-out, if not, set it.
|
// Check if the server owner has already set opt-out, if not, set it.
|
||||||
if (isOptOut()) {
|
if (isOptOut()) {
|
||||||
configuration.set("opt-out", false);
|
configuration.set("opt-out", false);
|
||||||
configuration.save(configurationFile);
|
configuration.save(configurationFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable Task, if it is not running
|
// Enable Task, if it is not running
|
||||||
if (taskId < 0) {
|
if (taskId < 0) {
|
||||||
start();
|
start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -289,4 +289,3 @@ public class Misc {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -25,8 +25,8 @@ import com.gmail.nossr50.locale.LocaleLoader;
|
|||||||
import com.gmail.nossr50.spout.SpoutStuff;
|
import com.gmail.nossr50.spout.SpoutStuff;
|
||||||
|
|
||||||
public class Skills {
|
public class Skills {
|
||||||
static AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
|
static AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
|
||||||
public static int abilityLengthIncreaseLevel = advancedConfig.getAbilityLength();
|
public static int abilityLengthIncreaseLevel = advancedConfig.getAbilityLength();
|
||||||
|
|
||||||
private final static int TIME_CONVERSION_FACTOR = 1000;
|
private final static int TIME_CONVERSION_FACTOR = 1000;
|
||||||
private final static double MAX_DISTANCE_AWAY = 10.0;
|
private final static double MAX_DISTANCE_AWAY = 10.0;
|
||||||
@ -530,7 +530,7 @@ public class Skills {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (type.getPermissions(player)) {
|
if (type.getPermissions(player)) {
|
||||||
if(Users.getPlayer(player) == null)
|
if(Users.getPlayer(player) == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Users.getPlayer(player).addXP(type, xp);
|
Users.getPlayer(player).addXP(type, xp);
|
||||||
|
@ -381,7 +381,7 @@ public class HashChunkletManager implements ChunkletManager {
|
|||||||
}
|
}
|
||||||
storeIn = tempStore;
|
storeIn = tempStore;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
return storeIn;
|
return storeIn;
|
||||||
}
|
}
|
||||||
|
@ -14,20 +14,20 @@ public class NullChunkletManager implements ChunkletManager {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void unloadChunklet(int cx, int cy, int cz, World world) {
|
public void unloadChunklet(int cx, int cy, int cz, World world) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadChunk(int cx, int cz, World world) {
|
public void loadChunk(int cx, int cz, World world) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void unloadChunk(int cx, int cz, World world) {
|
public void unloadChunk(int cx, int cz, World world) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void chunkLoaded(int cx, int cz, World world) {
|
public void chunkLoaded(int cx, int cz, World world) {
|
||||||
|
@ -112,7 +112,7 @@ public class HashChunkManager implements ChunkManager {
|
|||||||
int rx = x >> 5;
|
int rx = x >> 5;
|
||||||
int rz = z >> 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);
|
mcMMOSimpleRegionFile regionFile = worldRegions.get(key2);
|
||||||
|
|
||||||
@ -221,9 +221,9 @@ public class HashChunkManager implements ChunkManager {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
cx = Integer.parseInt(info[1]);
|
cx = Integer.parseInt(info[1]);
|
||||||
cz = Integer.parseInt(info[2]);
|
cz = Integer.parseInt(info[2]);
|
||||||
}
|
}
|
||||||
catch(Exception e) {
|
catch(Exception e) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
saveChunk(cx, cz, world);
|
saveChunk(cx, cz, world);
|
||||||
@ -247,9 +247,9 @@ public class HashChunkManager implements ChunkManager {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
cx = Integer.parseInt(info[1]);
|
cx = Integer.parseInt(info[1]);
|
||||||
cz = Integer.parseInt(info[2]);
|
cz = Integer.parseInt(info[2]);
|
||||||
}
|
}
|
||||||
catch(Exception e) {
|
catch(Exception e) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
unloadChunk(cx, cz, world);
|
unloadChunk(cx, cz, world);
|
||||||
|
@ -28,7 +28,7 @@ public class PrimitiveChunkStore implements ChunkStore {
|
|||||||
public PrimitiveChunkStore(World world, int cx, int cz) {
|
public PrimitiveChunkStore(World world, int cx, int cz) {
|
||||||
this.cx = cx;
|
this.cx = cx;
|
||||||
this.cz = cz;
|
this.cz = cz;
|
||||||
this.worldUid = world.getUID();
|
this.worldUid = world.getUID();
|
||||||
|
|
||||||
this.worldHeight = world != null ? world.getMaxHeight() : 128;
|
this.worldHeight = world != null ? world.getMaxHeight() : 128;
|
||||||
this.xBitShifts = 11;
|
this.xBitShifts = 11;
|
||||||
@ -108,7 +108,7 @@ public class PrimitiveChunkStore implements ChunkStore {
|
|||||||
out.writeLong(worldUid.getMostSignificantBits());
|
out.writeLong(worldUid.getMostSignificantBits());
|
||||||
out.writeInt(cx);
|
out.writeInt(cx);
|
||||||
out.writeInt(cz);
|
out.writeInt(cz);
|
||||||
out.writeObject(store);
|
out.writeObject(store);
|
||||||
|
|
||||||
dirty = false;
|
dirty = false;
|
||||||
}
|
}
|
||||||
|
@ -23,17 +23,17 @@ import java.io.ByteArrayOutputStream;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class mcMMOSimpleChunkBuffer extends ByteArrayOutputStream {
|
public class mcMMOSimpleChunkBuffer extends ByteArrayOutputStream {
|
||||||
final mcMMOSimpleRegionFile rf;
|
final mcMMOSimpleRegionFile rf;
|
||||||
final int index;
|
final int index;
|
||||||
|
|
||||||
mcMMOSimpleChunkBuffer(mcMMOSimpleRegionFile rf, int index) {
|
mcMMOSimpleChunkBuffer(mcMMOSimpleRegionFile rf, int index) {
|
||||||
super(1024);
|
super(1024);
|
||||||
this.rf = rf;
|
this.rf = rf;
|
||||||
this.index = index;
|
this.index = index;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void close() throws IOException {
|
public void close() throws IOException {
|
||||||
rf.write(index, buf, count);
|
rf.write(index, buf, count);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -30,271 +30,271 @@ import java.util.zip.DeflaterOutputStream;
|
|||||||
import java.util.zip.InflaterInputStream;
|
import java.util.zip.InflaterInputStream;
|
||||||
|
|
||||||
public class mcMMOSimpleRegionFile {
|
public class mcMMOSimpleRegionFile {
|
||||||
private RandomAccessFile file;
|
private RandomAccessFile file;
|
||||||
private final int[] dataStart = new int[1024];
|
private final int[] dataStart = new int[1024];
|
||||||
private final int[] dataActualLength = new int[1024];
|
private final int[] dataActualLength = new int[1024];
|
||||||
private final int[] dataLength = new int[1024];
|
private final int[] dataLength = new int[1024];
|
||||||
private final ArrayList<Boolean> inuse = new ArrayList<Boolean>();
|
private final ArrayList<Boolean> inuse = new ArrayList<Boolean>();
|
||||||
private int segmentSize;
|
private int segmentSize;
|
||||||
private int segmentMask;
|
private int segmentMask;
|
||||||
private final int rx;
|
private final int rx;
|
||||||
private final int rz;
|
private final int rz;
|
||||||
private final int defaultSegmentSize;
|
private final int defaultSegmentSize;
|
||||||
private final File parent;
|
private final File parent;
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private long lastAccessTime = System.currentTimeMillis();
|
private long lastAccessTime = System.currentTimeMillis();
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private static long TIMEOUT_TIME = 300000; // 5 min
|
private static long TIMEOUT_TIME = 300000; // 5 min
|
||||||
|
|
||||||
public mcMMOSimpleRegionFile(File f, int rx, int rz) {
|
public mcMMOSimpleRegionFile(File f, int rx, int rz) {
|
||||||
this(f, rx, rz, 10);
|
this(f, rx, rz, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
public mcMMOSimpleRegionFile(File f, int rx, int rz, int defaultSegmentSize) {
|
public mcMMOSimpleRegionFile(File f, int rx, int rz, int defaultSegmentSize) {
|
||||||
this.rx = rx;
|
this.rx = rx;
|
||||||
this.rz = rz;
|
this.rz = rz;
|
||||||
this.defaultSegmentSize = defaultSegmentSize;
|
this.defaultSegmentSize = defaultSegmentSize;
|
||||||
this.parent = f;
|
this.parent = f;
|
||||||
|
|
||||||
lastAccessTime = System.currentTimeMillis();
|
lastAccessTime = System.currentTimeMillis();
|
||||||
if (file == null) {
|
if (file == null) {
|
||||||
try {
|
try {
|
||||||
this.file = new RandomAccessFile(parent, "rw");
|
this.file = new RandomAccessFile(parent, "rw");
|
||||||
|
|
||||||
if (file.length() < 4096 * 3) {
|
if (file.length() < 4096 * 3) {
|
||||||
for (int i = 0; i < 1024 * 3; i++) {
|
for (int i = 0; i < 1024 * 3; i++) {
|
||||||
file.writeInt(0);
|
file.writeInt(0);
|
||||||
}
|
}
|
||||||
file.seek(4096 * 2);
|
file.seek(4096 * 2);
|
||||||
file.writeInt(defaultSegmentSize);
|
file.writeInt(defaultSegmentSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
file.seek(4096 * 2);
|
file.seek(4096 * 2);
|
||||||
|
|
||||||
this.segmentSize = file.readInt();
|
this.segmentSize = file.readInt();
|
||||||
this.segmentMask = (1 << segmentSize) - 1;
|
this.segmentMask = (1 << segmentSize) - 1;
|
||||||
|
|
||||||
int reservedSegments = this.sizeToSegments(4096 * 3);
|
int reservedSegments = this.sizeToSegments(4096 * 3);
|
||||||
|
|
||||||
for (int i = 0; i < reservedSegments; i++) {
|
for (int i = 0; i < reservedSegments; i++) {
|
||||||
while (inuse.size() <= i) {
|
while (inuse.size() <= i) {
|
||||||
inuse.add(false);
|
inuse.add(false);
|
||||||
}
|
}
|
||||||
inuse.set(i, true);
|
inuse.set(i, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
file.seek(0);
|
file.seek(0);
|
||||||
|
|
||||||
for (int i = 0; i < 1024; i++) {
|
for (int i = 0; i < 1024; i++) {
|
||||||
dataStart[i] = file.readInt();
|
dataStart[i] = file.readInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < 1024; i++) {
|
for (int i = 0; i < 1024; i++) {
|
||||||
dataActualLength[i] = file.readInt();
|
dataActualLength[i] = file.readInt();
|
||||||
dataLength[i] = sizeToSegments(dataActualLength[i]);
|
dataLength[i] = sizeToSegments(dataActualLength[i]);
|
||||||
setInUse(i, true);
|
setInUse(i, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
extendFile();
|
extendFile();
|
||||||
} catch (IOException fnfe) {
|
} catch (IOException fnfe) {
|
||||||
throw new RuntimeException(fnfe);
|
throw new RuntimeException(fnfe);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized final RandomAccessFile getFile() {
|
public synchronized final RandomAccessFile getFile() {
|
||||||
lastAccessTime = System.currentTimeMillis();
|
lastAccessTime = System.currentTimeMillis();
|
||||||
if (file == null) {
|
if (file == null) {
|
||||||
try {
|
try {
|
||||||
this.file = new RandomAccessFile(parent, "rw");
|
this.file = new RandomAccessFile(parent, "rw");
|
||||||
|
|
||||||
if (file.length() < 4096 * 3) {
|
if (file.length() < 4096 * 3) {
|
||||||
for (int i = 0; i < 1024 * 3; i++) {
|
for (int i = 0; i < 1024 * 3; i++) {
|
||||||
file.writeInt(0);
|
file.writeInt(0);
|
||||||
}
|
}
|
||||||
file.seek(4096 * 2);
|
file.seek(4096 * 2);
|
||||||
file.writeInt(defaultSegmentSize);
|
file.writeInt(defaultSegmentSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
file.seek(4096 * 2);
|
file.seek(4096 * 2);
|
||||||
|
|
||||||
this.segmentSize = file.readInt();
|
this.segmentSize = file.readInt();
|
||||||
this.segmentMask = (1 << segmentSize) - 1;
|
this.segmentMask = (1 << segmentSize) - 1;
|
||||||
|
|
||||||
int reservedSegments = this.sizeToSegments(4096 * 3);
|
int reservedSegments = this.sizeToSegments(4096 * 3);
|
||||||
|
|
||||||
for (int i = 0; i < reservedSegments; i++) {
|
for (int i = 0; i < reservedSegments; i++) {
|
||||||
while (inuse.size() <= i) {
|
while (inuse.size() <= i) {
|
||||||
inuse.add(false);
|
inuse.add(false);
|
||||||
}
|
}
|
||||||
inuse.set(i, true);
|
inuse.set(i, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
file.seek(0);
|
file.seek(0);
|
||||||
|
|
||||||
for (int i = 0; i < 1024; i++) {
|
for (int i = 0; i < 1024; i++) {
|
||||||
dataStart[i] = file.readInt();
|
dataStart[i] = file.readInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < 1024; i++) {
|
for (int i = 0; i < 1024; i++) {
|
||||||
dataActualLength[i] = file.readInt();
|
dataActualLength[i] = file.readInt();
|
||||||
dataLength[i] = sizeToSegments(dataActualLength[i]);
|
dataLength[i] = sizeToSegments(dataActualLength[i]);
|
||||||
setInUse(i, true);
|
setInUse(i, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
extendFile();
|
extendFile();
|
||||||
} catch (IOException fnfe) {
|
} catch (IOException fnfe) {
|
||||||
throw new RuntimeException(fnfe);
|
throw new RuntimeException(fnfe);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized boolean testCloseTimeout() {
|
public synchronized boolean testCloseTimeout() {
|
||||||
/*if (System.currentTimeMillis() - TIMEOUT_TIME > lastAccessTime) {
|
/*if (System.currentTimeMillis() - TIMEOUT_TIME > lastAccessTime) {
|
||||||
close();
|
close();
|
||||||
return true;
|
return true;
|
||||||
}*/
|
}*/
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized DataOutputStream getOutputStream(int x, int z) {
|
public synchronized DataOutputStream getOutputStream(int x, int z) {
|
||||||
int index = getChunkIndex(x, z);
|
int index = getChunkIndex(x, z);
|
||||||
return new DataOutputStream(new DeflaterOutputStream(new mcMMOSimpleChunkBuffer(this, index)));
|
return new DataOutputStream(new DeflaterOutputStream(new mcMMOSimpleChunkBuffer(this, index)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized DataInputStream getInputStream(int x, int z) throws IOException {
|
public synchronized DataInputStream getInputStream(int x, int z) throws IOException {
|
||||||
int index = getChunkIndex(x, z);
|
int index = getChunkIndex(x, z);
|
||||||
int actualLength = dataActualLength[index];
|
int actualLength = dataActualLength[index];
|
||||||
if (actualLength == 0) {
|
if (actualLength == 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
byte[] data = new byte[actualLength];
|
byte[] data = new byte[actualLength];
|
||||||
|
|
||||||
getFile().seek(dataStart[index] << segmentSize);
|
getFile().seek(dataStart[index] << segmentSize);
|
||||||
getFile().readFully(data);
|
getFile().readFully(data);
|
||||||
return new DataInputStream(new InflaterInputStream(new ByteArrayInputStream(data)));
|
return new DataInputStream(new InflaterInputStream(new ByteArrayInputStream(data)));
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized void write(int index, byte[] buffer, int size) throws IOException {
|
synchronized void write(int index, byte[] buffer, int size) throws IOException {
|
||||||
int oldStart = setInUse(index, false);
|
int oldStart = setInUse(index, false);
|
||||||
int start = findSpace(oldStart, size);
|
int start = findSpace(oldStart, size);
|
||||||
getFile().seek(start << segmentSize);
|
getFile().seek(start << segmentSize);
|
||||||
getFile().write(buffer, 0, size);
|
getFile().write(buffer, 0, size);
|
||||||
dataStart[index] = start;
|
dataStart[index] = start;
|
||||||
dataActualLength[index] = size;
|
dataActualLength[index] = size;
|
||||||
dataLength[index] = sizeToSegments(size);
|
dataLength[index] = sizeToSegments(size);
|
||||||
setInUse(index, true);
|
setInUse(index, true);
|
||||||
saveFAT();
|
saveFAT();
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void close() {
|
public synchronized void close() {
|
||||||
try {
|
try {
|
||||||
if (file != null) {
|
if (file != null) {
|
||||||
file.seek(4096 * 2);
|
file.seek(4096 * 2);
|
||||||
file.close();
|
file.close();
|
||||||
}
|
}
|
||||||
file = null;
|
file = null;
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
throw new RuntimeException("Unable to close file", ioe);
|
throw new RuntimeException("Unable to close file", ioe);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized int setInUse(int index, boolean used) {
|
private synchronized int setInUse(int index, boolean used) {
|
||||||
if (dataActualLength[index] == 0) {
|
if (dataActualLength[index] == 0) {
|
||||||
return dataStart[index];
|
return dataStart[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
int start = dataStart[index];
|
int start = dataStart[index];
|
||||||
int end = start + dataLength[index];
|
int end = start + dataLength[index];
|
||||||
|
|
||||||
for (int i = start; i < end; i++) {
|
for (int i = start; i < end; i++) {
|
||||||
while (i > inuse.size() - 1) {
|
while (i > inuse.size() - 1) {
|
||||||
inuse.add(false);
|
inuse.add(false);
|
||||||
}
|
}
|
||||||
Boolean old = inuse.set(i, used);
|
Boolean old = inuse.set(i, used);
|
||||||
if (old != null && old == used) {
|
if (old != null && old == used) {
|
||||||
if (old) {
|
if (old) {
|
||||||
throw new IllegalStateException("Attempting to overwrite an in-use segment");
|
throw new IllegalStateException("Attempting to overwrite an in-use segment");
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalStateException("Attempting to delete empty segment");
|
throw new IllegalStateException("Attempting to delete empty segment");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return dataStart[index];
|
return dataStart[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized void extendFile() throws IOException {
|
private synchronized void extendFile() throws IOException {
|
||||||
long extend = (-getFile().length()) & segmentMask;
|
long extend = (-getFile().length()) & segmentMask;
|
||||||
|
|
||||||
getFile().seek(getFile().length());
|
getFile().seek(getFile().length());
|
||||||
|
|
||||||
while ((extend--) > 0) {
|
while ((extend--) > 0) {
|
||||||
getFile().write(0);
|
getFile().write(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized int findSpace(int oldStart, int size) {
|
private synchronized int findSpace(int oldStart, int size) {
|
||||||
int segments = sizeToSegments(size);
|
int segments = sizeToSegments(size);
|
||||||
|
|
||||||
boolean oldFree = true;
|
boolean oldFree = true;
|
||||||
for (int i = oldStart; i < inuse.size() && i < oldStart + segments; i++) {
|
for (int i = oldStart; i < inuse.size() && i < oldStart + segments; i++) {
|
||||||
if (inuse.get(i)) {
|
if (inuse.get(i)) {
|
||||||
oldFree = false;
|
oldFree = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oldFree) {
|
if (oldFree) {
|
||||||
return oldStart;
|
return oldStart;
|
||||||
}
|
}
|
||||||
|
|
||||||
int start = 0;
|
int start = 0;
|
||||||
int end = 0;
|
int end = 0;
|
||||||
|
|
||||||
while (end < inuse.size()) {
|
while (end < inuse.size()) {
|
||||||
if (inuse.get(end)) {
|
if (inuse.get(end)) {
|
||||||
end++;
|
end++;
|
||||||
start = end;
|
start = end;
|
||||||
} else {
|
} else {
|
||||||
end++;
|
end++;
|
||||||
}
|
}
|
||||||
if (end - start >= segments) {
|
if (end - start >= segments) {
|
||||||
return start;
|
return start;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return start;
|
return start;
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized int sizeToSegments(int size) {
|
private synchronized int sizeToSegments(int size) {
|
||||||
if (size <= 0) {
|
if (size <= 0) {
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
return ((size - 1) >> segmentSize) + 1;
|
return ((size - 1) >> segmentSize) + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized Integer getChunkIndex(int x, int z) {
|
private synchronized Integer getChunkIndex(int x, int z) {
|
||||||
if (rx != (x >> 5) || rz != (z >> 5)) {
|
if (rx != (x >> 5) || rz != (z >> 5)) {
|
||||||
throw new RuntimeException(x + ", " + z + " not in region " + rx + ", " + rz);
|
throw new RuntimeException(x + ", " + z + " not in region " + rx + ", " + rz);
|
||||||
}
|
}
|
||||||
|
|
||||||
x = x & 0x1F;
|
x = x & 0x1F;
|
||||||
z = z & 0x1F;
|
z = z & 0x1F;
|
||||||
|
|
||||||
return (x << 5) + z;
|
return (x << 5) + z;
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized void saveFAT() throws IOException {
|
private synchronized void saveFAT() throws IOException {
|
||||||
getFile().seek(0);
|
getFile().seek(0);
|
||||||
for (int i = 0; i < 1024; i++) {
|
for (int i = 0; i < 1024; i++) {
|
||||||
getFile().writeInt(dataStart[i]);
|
getFile().writeInt(dataStart[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < 1024; i++) {
|
for (int i = 0; i < 1024; i++) {
|
||||||
getFile().writeInt(dataActualLength[i]);
|
getFile().writeInt(dataActualLength[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user