mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 07:06: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
|
||||||
|
@ -84,7 +84,7 @@ public class AddxpCommand implements CommandExecutor {
|
|||||||
String playerName = modifiedPlayer.getName();
|
String playerName = modifiedPlayer.getName();
|
||||||
McMMOPlayer mcMMOPlayer = Users.getPlayer(modifiedPlayer);
|
McMMOPlayer mcMMOPlayer = Users.getPlayer(modifiedPlayer);
|
||||||
PlayerProfile profile = Users.getProfile(modifiedPlayer);
|
PlayerProfile profile = Users.getProfile(modifiedPlayer);
|
||||||
|
|
||||||
if (profile == null) {
|
if (profile == null) {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||||
return true;
|
return true;
|
||||||
|
@ -28,11 +28,11 @@ public class McstatsCommand implements CommandExecutor {
|
|||||||
CommandHelper.printMiscSkills(player);
|
CommandHelper.printMiscSkills(player);
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
@ -18,31 +18,31 @@ public class SkillResetCommand implements CommandExecutor {
|
|||||||
if (CommandHelper.noConsoleUsage(sender)) {
|
if (CommandHelper.noConsoleUsage(sender)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//ensure they have the skillreset perm
|
//ensure they have the skillreset perm
|
||||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.skillreset")) {
|
if (CommandHelper.noCommandPermissions(sender, "mcmmo.skillreset")) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
SkillType skillType = null; //simple initialization
|
SkillType skillType = null; //simple initialization
|
||||||
|
|
||||||
//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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//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);
|
||||||
|
|
||||||
@ -53,13 +53,13 @@ public class SkillResetCommand implements CommandExecutor {
|
|||||||
|
|
||||||
profile.resetSkill(skillType);
|
profile.resetSkill(skillType);
|
||||||
profile.save();
|
profile.save();
|
||||||
|
|
||||||
//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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ public class MccCommand implements CommandExecutor {
|
|||||||
if (Config.getInstance().getCommandSkillResetEnabled() && Permissions.getInstance().skillReset(player)) {
|
if (Config.getInstance().getCommandSkillResetEnabled() && Permissions.getInstance().skillReset(player)) {
|
||||||
player.sendMessage("/skillreset <skill|all> " + LocaleLoader.getString("Commands.Reset"));
|
player.sendMessage("/skillreset <skill|all> " + LocaleLoader.getString("Commands.Reset"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Permissions.getInstance().mcAbility(player)) {
|
if (Permissions.getInstance().mcAbility(player)) {
|
||||||
player.sendMessage("/mcability " + LocaleLoader.getString("Commands.ToggleAbility"));
|
player.sendMessage("/mcability " + LocaleLoader.getString("Commands.ToggleAbility"));
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ public class InviteCommand implements CommandExecutor {
|
|||||||
if (target != null) {
|
if (target != null) {
|
||||||
if (PartyManager.getInstance().canInvite(player, playerProfile)) {
|
if (PartyManager.getInstance().canInvite(player, playerProfile)) {
|
||||||
Party party = playerProfile.getParty();
|
Party party = playerProfile.getParty();
|
||||||
|
|
||||||
Users.getProfile(target).setInvite(party);
|
Users.getProfile(target).setInvite(party);
|
||||||
player.sendMessage(LocaleLoader.getString("Commands.Invite.Success"));
|
player.sendMessage(LocaleLoader.getString("Commands.Invite.Success"));
|
||||||
target.sendMessage(LocaleLoader.getString("Commands.Party.Invite.0", new Object[] {party.getName(), player.getName()}));
|
target.sendMessage(LocaleLoader.getString("Commands.Party.Invite.0", new Object[] {party.getName(), player.getName()}));
|
||||||
|
@ -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") }));
|
||||||
|
@ -12,7 +12,7 @@ import com.gmail.nossr50.util.Misc;
|
|||||||
|
|
||||||
public class AxesCommand extends SkillCommand {
|
public class AxesCommand extends SkillCommand {
|
||||||
AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
|
AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
|
||||||
|
|
||||||
private String critChance;
|
private String critChance;
|
||||||
private String bonusDamage;
|
private String bonusDamage;
|
||||||
private String impactDamage;
|
private String impactDamage;
|
||||||
@ -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
|
||||||
|
@ -11,7 +11,7 @@ import com.gmail.nossr50.skills.gathering.Fishing;
|
|||||||
public class FishingCommand extends SkillCommand {
|
public class FishingCommand extends SkillCommand {
|
||||||
|
|
||||||
AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
|
AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
|
||||||
|
|
||||||
private int lootTier;
|
private int lootTier;
|
||||||
private String magicChance;
|
private String magicChance;
|
||||||
private int shakeUnlockLevel;
|
private int shakeUnlockLevel;
|
||||||
@ -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);
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ import com.gmail.nossr50.locale.LocaleLoader;
|
|||||||
|
|
||||||
public class HerbalismCommand extends SkillCommand {
|
public class HerbalismCommand extends SkillCommand {
|
||||||
AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
|
AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
|
||||||
|
|
||||||
private String greenTerraLength;
|
private String greenTerraLength;
|
||||||
private String greenThumbChance;
|
private String greenThumbChance;
|
||||||
private String greenThumbStage;
|
private String greenThumbStage;
|
||||||
@ -28,7 +28,7 @@ public class HerbalismCommand extends SkillCommand {
|
|||||||
private int greenThumbMaxLevel = advancedConfig.getGreenThumbMaxLevel();
|
private int greenThumbMaxLevel = advancedConfig.getGreenThumbMaxLevel();
|
||||||
private double doubleDropsMaxBonus = advancedConfig.getHerbalismDoubleDropsChanceMax();
|
private double doubleDropsMaxBonus = advancedConfig.getHerbalismDoubleDropsChanceMax();
|
||||||
private int doubleDropsMaxLevel = advancedConfig.getHerbalismDoubleDropsMaxLevel();
|
private int doubleDropsMaxLevel = advancedConfig.getHerbalismDoubleDropsMaxLevel();
|
||||||
|
|
||||||
private boolean canGreenTerra;
|
private boolean canGreenTerra;
|
||||||
private boolean canGreenThumbWheat;
|
private boolean canGreenThumbWheat;
|
||||||
private boolean canGreenThumbBlocks;
|
private boolean canGreenThumbBlocks;
|
||||||
@ -50,13 +50,13 @@ public class HerbalismCommand extends SkillCommand {
|
|||||||
//GREEN THUMB
|
//GREEN THUMB
|
||||||
if(skillValue >= greenThumbStageMaxLevel) greenThumbStage = "4";
|
if(skillValue >= greenThumbStageMaxLevel) greenThumbStage = "4";
|
||||||
else greenThumbStage = String.valueOf((double) skillValue / (double) greenThumbStageChange);
|
else greenThumbStage = String.valueOf((double) skillValue / (double) greenThumbStageChange);
|
||||||
|
|
||||||
|
|
||||||
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,8 +48,8 @@ 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";
|
||||||
blastDamageDecrease = "100.00%";
|
blastDamageDecrease = "100.00%";
|
||||||
|
@ -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
|
||||||
|
@ -11,7 +11,7 @@ import com.gmail.nossr50.locale.LocaleLoader;
|
|||||||
|
|
||||||
public class SwordsCommand extends SkillCommand {
|
public class SwordsCommand extends SkillCommand {
|
||||||
AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
|
AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
|
||||||
|
|
||||||
private String counterAttackChance;
|
private String counterAttackChance;
|
||||||
private String bleedLength;
|
private String bleedLength;
|
||||||
private String bleedChance;
|
private String bleedChance;
|
||||||
@ -38,16 +38,16 @@ public class SwordsCommand extends SkillCommand {
|
|||||||
protected void dataCalculations() {
|
protected void dataCalculations() {
|
||||||
DecimalFormat df = new DecimalFormat("#.0");
|
DecimalFormat df = new DecimalFormat("#.0");
|
||||||
serratedStrikesLength = String.valueOf(2 + (int) ((double) skillValue / (double) abilityLengthIncreaseLevel));
|
serratedStrikesLength = String.valueOf(2 + (int) ((double) skillValue / (double) abilityLengthIncreaseLevel));
|
||||||
|
|
||||||
if (skillValue >= bleedMaxLevel) bleedLength = String.valueOf(bleedMaxTicks);
|
if (skillValue >= bleedMaxLevel) bleedLength = String.valueOf(bleedMaxTicks);
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ public class TamingCommand extends SkillCommand {
|
|||||||
private int thickFurUnlock = advancedConfig.getThickFurUnlock();
|
private int thickFurUnlock = advancedConfig.getThickFurUnlock();
|
||||||
private int shockProofUnlock = advancedConfig.getShockProofUnlock();
|
private int shockProofUnlock = advancedConfig.getShockProofUnlock();
|
||||||
private int sharpenedClawUnlock = advancedConfig.getSharpenedClawsUnlock();
|
private int sharpenedClawUnlock = advancedConfig.getSharpenedClawsUnlock();
|
||||||
|
|
||||||
private boolean canBeastLore;
|
private boolean canBeastLore;
|
||||||
private boolean canGore;
|
private boolean canGore;
|
||||||
private boolean canSharpenedClaws;
|
private boolean canSharpenedClaws;
|
||||||
@ -40,8 +40,8 @@ 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
|
||||||
protected void permissionsCheck() {
|
protected void permissionsCheck() {
|
||||||
|
@ -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));
|
||||||
|
@ -19,7 +19,7 @@ public class WoodcuttingCommand extends SkillCommand {
|
|||||||
private double doubleDropsMaxBonus = advancedConfig.getWoodcuttingDoubleDropChance();
|
private double doubleDropsMaxBonus = advancedConfig.getWoodcuttingDoubleDropChance();
|
||||||
private int doubleDropsMaxLevel = advancedConfig.getWoodcuttingDoubleDropMaxLevel();
|
private int doubleDropsMaxLevel = advancedConfig.getWoodcuttingDoubleDropMaxLevel();
|
||||||
private int leafBlowUnlock = advancedConfig.getLeafBlowUnlockLevel();
|
private int leafBlowUnlock = advancedConfig.getLeafBlowUnlockLevel();
|
||||||
|
|
||||||
private boolean canTreeFell;
|
private boolean canTreeFell;
|
||||||
private boolean canLeafBlow;
|
private boolean canLeafBlow;
|
||||||
private boolean canDoubleDrop;
|
private boolean canDoubleDrop;
|
||||||
@ -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
|
||||||
|
@ -2,7 +2,7 @@ package com.gmail.nossr50.config;
|
|||||||
|
|
||||||
public class AdvancedConfig extends ConfigLoader {
|
public class AdvancedConfig extends ConfigLoader {
|
||||||
private static AdvancedConfig instance;
|
private static AdvancedConfig instance;
|
||||||
|
|
||||||
private AdvancedConfig() {
|
private AdvancedConfig() {
|
||||||
super("advanced.yml");
|
super("advanced.yml");
|
||||||
loadKeys();
|
loadKeys();
|
||||||
@ -13,28 +13,28 @@ public class AdvancedConfig extends ConfigLoader {
|
|||||||
}
|
}
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void loadKeys() {
|
protected void loadKeys() {
|
||||||
// TODO Do I need to use this?
|
// TODO Do I need to use this?
|
||||||
}
|
}
|
||||||
/* GENERAL */
|
/* GENERAL */
|
||||||
public int getAbilityLength() { return config.getInt("Skills.General.Ability_IncreaseLevel", 50); }
|
public int getAbilityLength() { return config.getInt("Skills.General.Ability_IncreaseLevel", 50); }
|
||||||
|
|
||||||
/* ACROBATICS */
|
/* ACROBATICS */
|
||||||
public int getDodgeChanceMax() { return config.getInt("Skills.Acrobatics.Dodge_ChanceMax", 20); }
|
public int getDodgeChanceMax() { return config.getInt("Skills.Acrobatics.Dodge_ChanceMax", 20); }
|
||||||
public int getDodgeMaxBonusLevel() { return config.getInt("Skills.Acrobatics.Dodge_MaxBonusLevel", 800); }
|
public int getDodgeMaxBonusLevel() { return config.getInt("Skills.Acrobatics.Dodge_MaxBonusLevel", 800); }
|
||||||
|
|
||||||
public int getRollChanceMax() { return config.getInt("Skills.Acrobatics.Roll_ChanceMax", 100); }
|
public int getRollChanceMax() { return config.getInt("Skills.Acrobatics.Roll_ChanceMax", 100); }
|
||||||
public int getRollMaxBonusLevel() { return config.getInt("Skills.Acrobatics.Roll_MaxBonusLevel", 1000); }
|
public int getRollMaxBonusLevel() { return config.getInt("Skills.Acrobatics.Roll_MaxBonusLevel", 1000); }
|
||||||
|
|
||||||
public int getGracefulRollChanceMax() { return config.getInt("Skills.Acrobatics.GracefulRoll_ChanceMax", 100); }
|
public int getGracefulRollChanceMax() { return config.getInt("Skills.Acrobatics.GracefulRoll_ChanceMax", 100); }
|
||||||
public int getGracefulRollMaxBonusLevel() { return config.getInt("Skills.Acrobatics.GracefulRoll_MaxBonusLevel", 500); }
|
public int getGracefulRollMaxBonusLevel() { return config.getInt("Skills.Acrobatics.GracefulRoll_MaxBonusLevel", 500); }
|
||||||
|
|
||||||
public int getDodgeXPModifier() { return config.getInt("Skills.Acrobatics.Dodge_XP_Modifier", 120); }
|
public int getDodgeXPModifier() { return config.getInt("Skills.Acrobatics.Dodge_XP_Modifier", 120); }
|
||||||
public int getRollXPModifier() { return config.getInt("Skills.Acrobatics.Roll_XP_Modifier", 80); }
|
public int getRollXPModifier() { return config.getInt("Skills.Acrobatics.Roll_XP_Modifier", 80); }
|
||||||
public int getFallXPModifier() { return config.getInt("Skills.Acrobatics.Fall_XP_Modifier", 120); }
|
public int getFallXPModifier() { return config.getInt("Skills.Acrobatics.Fall_XP_Modifier", 120); }
|
||||||
|
|
||||||
/* ARCHERY */
|
/* ARCHERY */
|
||||||
public int getSkillShotIncreaseLevel() { return config.getInt("Skills.Archery.SkillShot_IncreaseLevel", 50); }
|
public int getSkillShotIncreaseLevel() { return config.getInt("Skills.Archery.SkillShot_IncreaseLevel", 50); }
|
||||||
public double getSkillShotIncreasePercentage() { return config.getDouble("Skills.Archery.SkillShot_IncreasePercentage", 0.1D); }
|
public double getSkillShotIncreasePercentage() { return config.getDouble("Skills.Archery.SkillShot_IncreasePercentage", 0.1D); }
|
||||||
@ -46,7 +46,7 @@ public class AdvancedConfig extends ConfigLoader {
|
|||||||
|
|
||||||
public int getRetrieveBonusMax() { return config.getInt("Skills.Archery.Retrieve_MaxBonus", 100); }
|
public int getRetrieveBonusMax() { return config.getInt("Skills.Archery.Retrieve_MaxBonus", 100); }
|
||||||
public int getRetrieveMaxBonusLevel() { return config.getInt("Skills.Archery.Retrieve_MaxBonusLevel", 1000); }
|
public int getRetrieveMaxBonusLevel() { return config.getInt("Skills.Archery.Retrieve_MaxBonusLevel", 1000); }
|
||||||
|
|
||||||
/* AXES */
|
/* AXES */
|
||||||
public int getBonusDamageAxesBonusMax() { return config.getInt("Skills.Axes.DamageIncrease_MaxBonus", 4); }
|
public int getBonusDamageAxesBonusMax() { return config.getInt("Skills.Axes.DamageIncrease_MaxBonus", 4); }
|
||||||
public int getBonusDamageAxesMaxBonusLevel() { return config.getInt("Skills.Axes.DamageIncrease_MaxBonusLevel", 200); }
|
public int getBonusDamageAxesMaxBonusLevel() { return config.getInt("Skills.Axes.DamageIncrease_MaxBonusLevel", 200); }
|
||||||
@ -55,30 +55,30 @@ public class AdvancedConfig extends ConfigLoader {
|
|||||||
public int getAxesCriticalMaxBonusLevel() { return config.getInt("Skills.Axes.AxesCritical_MaxBonusLevel", 750); }
|
public int getAxesCriticalMaxBonusLevel() { return config.getInt("Skills.Axes.AxesCritical_MaxBonusLevel", 750); }
|
||||||
public double getAxesCriticalPVPModifier() { return config.getDouble("Skills.Axes.AxesCritical_PVP_Modifier", 1.5); }
|
public double getAxesCriticalPVPModifier() { return config.getDouble("Skills.Axes.AxesCritical_PVP_Modifier", 1.5); }
|
||||||
public int getAxesCriticalPVEModifier() { return config.getInt("Skills.Axes.AxesCritical_PVE_Modifier", 2); }
|
public int getAxesCriticalPVEModifier() { return config.getInt("Skills.Axes.AxesCritical_PVE_Modifier", 2); }
|
||||||
|
|
||||||
public int getGreaterImpactChance() { return config.getInt("Skills.Axes.GreaterImpact_Chance", 25); }
|
public int getGreaterImpactChance() { return config.getInt("Skills.Axes.GreaterImpact_Chance", 25); }
|
||||||
public double getGreaterImpactModifier() { return config.getDouble("Skills.Axes.GreaterImpact_KnockbackModifier", 1.5); }
|
public double getGreaterImpactModifier() { return config.getDouble("Skills.Axes.GreaterImpact_KnockbackModifier", 1.5); }
|
||||||
public int getGreaterImpactBonusDamage() { return config.getInt("Skills.Axes.GreaterImpact_BonusDamage", 2); }
|
public int getGreaterImpactBonusDamage() { return config.getInt("Skills.Axes.GreaterImpact_BonusDamage", 2); }
|
||||||
|
|
||||||
public int getArmorImpactIncreaseLevel() { return config.getInt("Skills.Axes.ArmorImpact_IncreaseLevel", 50); }
|
public int getArmorImpactIncreaseLevel() { return config.getInt("Skills.Axes.ArmorImpact_IncreaseLevel", 50); }
|
||||||
|
|
||||||
/* EXCAVATION */
|
/* EXCAVATION */
|
||||||
//Nothing to configure, everything is already configurable in config.yml
|
//Nothing to configure, everything is already configurable in config.yml
|
||||||
|
|
||||||
/* FISHING */
|
/* FISHING */
|
||||||
public int getShakeUnlockLevel() { return config.getInt("Skills.Fishing.Shake_UnlockLevel", 150); }
|
public int getShakeUnlockLevel() { return config.getInt("Skills.Fishing.Shake_UnlockLevel", 150); }
|
||||||
public int getFishingEnchantmentChance() { return config.getInt("Skills.Fishing.Enchantment_Chance", 10); }
|
public int getFishingEnchantmentChance() { return config.getInt("Skills.Fishing.Enchantment_Chance", 10); }
|
||||||
|
|
||||||
/* HERBALISM */
|
/* HERBALISM */
|
||||||
public int getFarmerDietRankChange() { return config.getInt("Skills.Herbalism.Food_RankChange", 200); }
|
public int getFarmerDietRankChange() { return config.getInt("Skills.Herbalism.Food_RankChange", 200); }
|
||||||
|
|
||||||
public int getGreenThumbStageChange() { return config.getInt("Skills.Herbalism.GreenThumb_StageChange", 200); }
|
public int getGreenThumbStageChange() { return config.getInt("Skills.Herbalism.GreenThumb_StageChange", 200); }
|
||||||
public int getGreenThumbChanceMax() { return config.getInt("Skills.Herbalism.GreenThumb_ChanceMax", 100); }
|
public int getGreenThumbChanceMax() { return config.getInt("Skills.Herbalism.GreenThumb_ChanceMax", 100); }
|
||||||
public int getGreenThumbMaxLevel() { return config.getInt("Skills.Herbalism.GreenThumb_MaxBonusLevel", 1500); }
|
public int getGreenThumbMaxLevel() { return config.getInt("Skills.Herbalism.GreenThumb_MaxBonusLevel", 1500); }
|
||||||
|
|
||||||
public int getHerbalismDoubleDropsChanceMax() { return config.getInt("Skills.Herbalism.DoubleDrops_ChanceMax", 100); }
|
public int getHerbalismDoubleDropsChanceMax() { return config.getInt("Skills.Herbalism.DoubleDrops_ChanceMax", 100); }
|
||||||
public int getHerbalismDoubleDropsMaxLevel() { return config.getInt("Skills.Herbalism.DoubleDrops_MaxBonusLevel", 1000); }
|
public int getHerbalismDoubleDropsMaxLevel() { return config.getInt("Skills.Herbalism.DoubleDrops_MaxBonusLevel", 1000); }
|
||||||
|
|
||||||
/* MINING */
|
/* MINING */
|
||||||
public int getMiningDoubleDropChance() { return config.getInt("Skills.Mining.DoubleDrops_ChanceMax", 100); }
|
public int getMiningDoubleDropChance() { return config.getInt("Skills.Mining.DoubleDrops_ChanceMax", 100); }
|
||||||
public int getMiningDoubleDropMaxLevel() { return config.getInt("Skills.Mining.DoubleDrops_MaxBonusLevel", 1000); }
|
public int getMiningDoubleDropMaxLevel() { return config.getInt("Skills.Mining.DoubleDrops_MaxBonusLevel", 1000); }
|
||||||
@ -96,7 +96,7 @@ public class AdvancedConfig extends ConfigLoader {
|
|||||||
public int getRepairMasteryMaxLevel() { return config.getInt("Skills.Repair.RepairMastery_MaxBonusLevel", 1000); }
|
public int getRepairMasteryMaxLevel() { return config.getInt("Skills.Repair.RepairMastery_MaxBonusLevel", 1000); }
|
||||||
public int getSuperRepairChanceMax() { return config.getInt("Skills.Repair.SuperRepair_ChanceMax", 100); }
|
public int getSuperRepairChanceMax() { return config.getInt("Skills.Repair.SuperRepair_ChanceMax", 100); }
|
||||||
public int getSuperRepairMaxLevel() { return config.getInt("Skills.Repair.SuperRepair_MaxBonusLevel", 1000); }
|
public int getSuperRepairMaxLevel() { return config.getInt("Skills.Repair.SuperRepair_MaxBonusLevel", 1000); }
|
||||||
|
|
||||||
/* SWORDS */
|
/* SWORDS */
|
||||||
public int getBleedChanceMax() { return config.getInt("Skills.Sword.Bleed_ChanceMax", 75); }
|
public int getBleedChanceMax() { return config.getInt("Skills.Sword.Bleed_ChanceMax", 75); }
|
||||||
public int getBleedMaxBonusLevel() { return config.getInt("Skills.Sword.Bleed_MaxBonusLevel", 750); }
|
public int getBleedMaxBonusLevel() { return config.getInt("Skills.Sword.Bleed_MaxBonusLevel", 750); }
|
||||||
@ -106,7 +106,7 @@ public class AdvancedConfig extends ConfigLoader {
|
|||||||
public int getCounterChanceMax() { return config.getInt("Skills.Sword.Counter_ChanceMax", 30); }
|
public int getCounterChanceMax() { return config.getInt("Skills.Sword.Counter_ChanceMax", 30); }
|
||||||
public int getCounterMaxBonusLevel() { return config.getInt("Skills.Sword.Counter_MaxBonusLevel", 600); }
|
public int getCounterMaxBonusLevel() { return config.getInt("Skills.Sword.Counter_MaxBonusLevel", 600); }
|
||||||
public int getCounterModifier() { return config.getInt("Skills.Sword.Counter_DamageModifier", 2); }
|
public int getCounterModifier() { return config.getInt("Skills.Sword.Counter_DamageModifier", 2); }
|
||||||
|
|
||||||
public int getSerratedStrikesModifier() { return config.getInt("Skills.Sword.SerratedStrikes_DamageModifier", 4); }
|
public int getSerratedStrikesModifier() { return config.getInt("Skills.Sword.SerratedStrikes_DamageModifier", 4); }
|
||||||
public int getSerratedStrikesTicks() { return config.getInt("Skills.Sword.SerratedStrikes_BleedTicks", 5); }
|
public int getSerratedStrikesTicks() { return config.getInt("Skills.Sword.SerratedStrikes_BleedTicks", 5); }
|
||||||
/* TAMING */
|
/* TAMING */
|
||||||
@ -117,12 +117,12 @@ public class AdvancedConfig extends ConfigLoader {
|
|||||||
|
|
||||||
public int getFastFoodUnlock() { return config.getInt("Skills.Taming.FastFood_UnlockLevel", 50); }
|
public int getFastFoodUnlock() { return config.getInt("Skills.Taming.FastFood_UnlockLevel", 50); }
|
||||||
public int getFastFoodChance() { return config.getInt("Skills.Taming.FastFood_Chance", 50); }
|
public int getFastFoodChance() { return config.getInt("Skills.Taming.FastFood_Chance", 50); }
|
||||||
|
|
||||||
public int getEnviromentallyAwareUnlock() { return config.getInt("Skills.Taming.EnvironmentallyAware_UnlockLevel", 100); }
|
public int getEnviromentallyAwareUnlock() { return config.getInt("Skills.Taming.EnvironmentallyAware_UnlockLevel", 100); }
|
||||||
|
|
||||||
public int getThickFurUnlock() { return config.getInt("Skills.Taming.ThickFur_UnlockLevel", 250); }
|
public int getThickFurUnlock() { return config.getInt("Skills.Taming.ThickFur_UnlockLevel", 250); }
|
||||||
public int getThickFurModifier() { return config.getInt("Skills.Taming.ThickFur_Modifier", 2); }
|
public int getThickFurModifier() { return config.getInt("Skills.Taming.ThickFur_Modifier", 2); }
|
||||||
|
|
||||||
public int getShockProofUnlock() { return config.getInt("Skills.Taming.ShockProof_UnlockLevel", 500); }
|
public int getShockProofUnlock() { return config.getInt("Skills.Taming.ShockProof_UnlockLevel", 500); }
|
||||||
public int getShockProofModifier() { return config.getInt("Skills.Taming.ShockProof_Modifier", 6); }
|
public int getShockProofModifier() { return config.getInt("Skills.Taming.ShockProof_Modifier", 6); }
|
||||||
|
|
||||||
@ -141,13 +141,13 @@ public class AdvancedConfig extends ConfigLoader {
|
|||||||
public int getLeafBlowUnlockLevel() { return config.getInt("Skills.Woodcutting.LeafBlower_UnlockLevel", 100); }
|
public int getLeafBlowUnlockLevel() { return config.getInt("Skills.Woodcutting.LeafBlower_UnlockLevel", 100); }
|
||||||
public int getWoodcuttingDoubleDropChance() { return config.getInt("Skills.Woodcutting.DoubleDrops_ChanceMax", 100); }
|
public int getWoodcuttingDoubleDropChance() { return config.getInt("Skills.Woodcutting.DoubleDrops_ChanceMax", 100); }
|
||||||
public int getWoodcuttingDoubleDropMaxLevel() { return config.getInt("Skills.Woodcutting.DoubleDrops_MaxBonusLevel", 1000); }
|
public int getWoodcuttingDoubleDropMaxLevel() { return config.getInt("Skills.Woodcutting.DoubleDrops_MaxBonusLevel", 1000); }
|
||||||
|
|
||||||
/* SPOUT STUFF*/
|
/* SPOUT STUFF*/
|
||||||
public int getSpoutNotificationTier1() { return config.getInt("Spout.Notifications.Tier1", 200); }
|
public int getSpoutNotificationTier1() { return config.getInt("Spout.Notifications.Tier1", 200); }
|
||||||
public int getSpoutNotificationTier2() { return config.getInt("Spout.Notifications.Tier2", 400); }
|
public int getSpoutNotificationTier2() { return config.getInt("Spout.Notifications.Tier2", 400); }
|
||||||
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"); }
|
||||||
}
|
}
|
||||||
|
@ -152,7 +152,7 @@ public class Config extends ConfigLoader {
|
|||||||
public int getFishingTierLevelsTier3() { return config.getInt("Fishing.Tier_Levels.Tier3", 400); }
|
public int getFishingTierLevelsTier3() { return config.getInt("Fishing.Tier_Levels.Tier3", 400); }
|
||||||
public int getFishingTierLevelsTier4() { return config.getInt("Fishing.Tier_Levels.Tier4", 600); }
|
public int getFishingTierLevelsTier4() { return config.getInt("Fishing.Tier_Levels.Tier4", 600); }
|
||||||
public int getFishingTierLevelsTier5() { return config.getInt("Fishing.Tier_Levels.Tier5", 800); }
|
public int getFishingTierLevelsTier5() { return config.getInt("Fishing.Tier_Levels.Tier5", 800); }
|
||||||
|
|
||||||
/* Shake */
|
/* Shake */
|
||||||
public int getShakeChanceRank1() { return config.getInt("Shake.Chance.Rank_1", 25); }
|
public int getShakeChanceRank1() { return config.getInt("Shake.Chance.Rank_1", 25); }
|
||||||
public int getShakeChanceRank2() { return config.getInt("Shake.Chance.Rank_2", 40); }
|
public int getShakeChanceRank2() { return config.getInt("Shake.Chance.Rank_2", 40); }
|
||||||
|
@ -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()) {
|
||||||
|
@ -18,7 +18,7 @@ import com.gmail.nossr50.util.Misc;
|
|||||||
public class PlayerProfile {
|
public class PlayerProfile {
|
||||||
|
|
||||||
private String playerName;
|
private String playerName;
|
||||||
|
|
||||||
/* HUD */
|
/* HUD */
|
||||||
private SpoutHud spoutHud;
|
private SpoutHud spoutHud;
|
||||||
private HudType hudType = SpoutConfig.getInstance().defaultHudType;
|
private HudType hudType = SpoutConfig.getInstance().defaultHudType;
|
||||||
@ -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 */
|
||||||
@ -278,7 +278,7 @@ public class PlayerProfile {
|
|||||||
skillsXp.put(SkillType.FISHING, Integer.valueOf(character[35]));
|
skillsXp.put(SkillType.FISHING, Integer.valueOf(character[35]));
|
||||||
if (character.length > 36)
|
if (character.length > 36)
|
||||||
skillsDATS.put(AbilityType.BLAST_MINING, Integer.valueOf(character[36]));
|
skillsDATS.put(AbilityType.BLAST_MINING, Integer.valueOf(character[36]));
|
||||||
|
|
||||||
loaded = true;
|
loaded = true;
|
||||||
|
|
||||||
in.close();
|
in.close();
|
||||||
@ -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;
|
||||||
@ -923,116 +923,116 @@ public class PlayerProfile {
|
|||||||
skills.put(skillType, skills.get(skillType) + newValue);
|
skills.put(skillType, skills.get(skillType) + newValue);
|
||||||
save(false);
|
save(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
||||||
|
@ -9,7 +9,7 @@ public class McmmoButton extends GenericButton {
|
|||||||
this.setText(text);
|
this.setText(text);
|
||||||
this.setTooltip(toolTip);
|
this.setTooltip(toolTip);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void connect(Slot slot) {
|
public void connect(Slot slot) {
|
||||||
this.slot = slot;
|
this.slot = slot;
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ public class XpBar {
|
|||||||
case RETRO:
|
case RETRO:
|
||||||
initializeXpBarRetro();
|
initializeXpBarRetro();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case STANDARD:
|
case STANDARD:
|
||||||
initializeXpBarStandard();
|
initializeXpBarStandard();
|
||||||
break;
|
break;
|
||||||
@ -44,7 +44,7 @@ public class XpBar {
|
|||||||
case DISABLED:
|
case DISABLED:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
spoutPlayer.getMainScreen().setDirty(true);
|
spoutPlayer.getMainScreen().setDirty(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,7 +77,7 @@ public class XpBar {
|
|||||||
xpFill.setTopColor(green);
|
xpFill.setTopColor(green);
|
||||||
xpFill.setPriority(RenderPriority.Lowest);
|
xpFill.setPriority(RenderPriority.Lowest);
|
||||||
spoutPlayer.getMainScreen().attachWidget(mcMMO.p, xpFill);
|
spoutPlayer.getMainScreen().attachWidget(mcMMO.p, xpFill);
|
||||||
|
|
||||||
xpBackground.setWidth(126);
|
xpBackground.setWidth(126);
|
||||||
xpBackground.setHeight(2);
|
xpBackground.setHeight(2);
|
||||||
xpBackground.setX(150);
|
xpBackground.setX(150);
|
||||||
@ -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.
|
||||||
@ -127,7 +127,7 @@ public class BlockListener implements Listener {
|
|||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
int id = block.getTypeId();
|
int id = block.getTypeId();
|
||||||
Material type = block.getType();
|
Material type = block.getType();
|
||||||
|
|
||||||
if(player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
if(player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||||
|
|
||||||
/* Code to prevent issues with placed falling Sand/Gravel not being tracked */
|
/* Code to prevent issues with placed falling Sand/Gravel not being tracked */
|
||||||
@ -171,9 +171,9 @@ public class BlockListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
if(player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
if(player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||||
|
|
||||||
PlayerProfile profile = Users.getProfile(player);
|
PlayerProfile profile = Users.getProfile(player);
|
||||||
|
|
||||||
if (profile == null) {
|
if (profile == null) {
|
||||||
@ -284,11 +284,11 @@ public class BlockListener implements Listener {
|
|||||||
final int LEAF_BLOWER_LEVEL = 100;
|
final int LEAF_BLOWER_LEVEL = 100;
|
||||||
|
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
if(player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
if(player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||||
|
|
||||||
PlayerProfile profile = Users.getProfile(player);
|
PlayerProfile profile = Users.getProfile(player);
|
||||||
|
|
||||||
if (profile == null) {
|
if (profile == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@ public class EntityListener implements Listener {
|
|||||||
|
|
||||||
Entity attacker = event.getDamager();
|
Entity attacker = event.getDamager();
|
||||||
Entity defender = event.getEntity();
|
Entity defender = event.getEntity();
|
||||||
|
|
||||||
if(attacker.hasMetadata("NPC") || defender.hasMetadata("NPC")) return; // Check if either players is are Citizens NPCs
|
if(attacker.hasMetadata("NPC") || defender.hasMetadata("NPC")) return; // Check if either players is are Citizens NPCs
|
||||||
|
|
||||||
if (attacker instanceof Projectile) {
|
if (attacker instanceof Projectile) {
|
||||||
@ -120,7 +120,7 @@ public class EntityListener implements Listener {
|
|||||||
DamageCause cause = event.getCause();
|
DamageCause cause = event.getCause();
|
||||||
|
|
||||||
if(entity.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
if(entity.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||||
|
|
||||||
if (!(entity instanceof LivingEntity)) {
|
if (!(entity instanceof LivingEntity)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -178,7 +178,7 @@ public class EntityListener implements Listener {
|
|||||||
@EventHandler (priority = EventPriority.MONITOR)
|
@EventHandler (priority = EventPriority.MONITOR)
|
||||||
public void onEntityDeath(EntityDeathEvent event) {
|
public void onEntityDeath(EntityDeathEvent event) {
|
||||||
LivingEntity entity = event.getEntity();
|
LivingEntity entity = event.getEntity();
|
||||||
|
|
||||||
if(entity.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
if(entity.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||||
|
|
||||||
entity.setFireTicks(0);
|
entity.setFireTicks(0);
|
||||||
@ -208,9 +208,9 @@ public class EntityListener implements Listener {
|
|||||||
@EventHandler (priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler (priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void onExplosionPrime(ExplosionPrimeEvent event) {
|
public void onExplosionPrime(ExplosionPrimeEvent event) {
|
||||||
Entity entity = event.getEntity();
|
Entity entity = event.getEntity();
|
||||||
|
|
||||||
if(entity.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
if(entity.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||||
|
|
||||||
if (entity instanceof TNTPrimed) {
|
if (entity instanceof TNTPrimed) {
|
||||||
int id = entity.getEntityId();
|
int id = entity.getEntityId();
|
||||||
|
|
||||||
@ -234,7 +234,7 @@ public class EntityListener implements Listener {
|
|||||||
Entity entity = event.getEntity();
|
Entity entity = event.getEntity();
|
||||||
|
|
||||||
if(entity == null) return;
|
if(entity == null) return;
|
||||||
|
|
||||||
if(entity.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
if(entity.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||||
|
|
||||||
if (entity instanceof TNTPrimed) {
|
if (entity instanceof TNTPrimed) {
|
||||||
@ -255,12 +255,12 @@ 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();
|
||||||
|
|
||||||
if(player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
if(player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||||
|
|
||||||
PlayerProfile profile = Users.getProfile(player);
|
PlayerProfile profile = Users.getProfile(player);
|
||||||
int currentFoodLevel = player.getFoodLevel();
|
int currentFoodLevel = player.getFoodLevel();
|
||||||
int newFoodLevel = event.getFoodLevel();
|
int newFoodLevel = event.getFoodLevel();
|
||||||
@ -394,9 +394,9 @@ public class EntityListener implements Listener {
|
|||||||
@EventHandler (priority = EventPriority.MONITOR)
|
@EventHandler (priority = EventPriority.MONITOR)
|
||||||
public void onEntityTame(EntityTameEvent event) {
|
public void onEntityTame(EntityTameEvent event) {
|
||||||
Player player = (Player) event.getOwner();
|
Player player = (Player) event.getOwner();
|
||||||
|
|
||||||
if(player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
if(player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||||
|
|
||||||
if (Permissions.getInstance().taming(player) && !event.getEntity().hasMetadata("mcmmoSummoned")) {
|
if (Permissions.getInstance().taming(player) && !event.getEntity().hasMetadata("mcmmoSummoned")) {
|
||||||
PlayerProfile profile = Users.getProfile(player);
|
PlayerProfile profile = Users.getProfile(player);
|
||||||
EntityType type = event.getEntityType();
|
EntityType type = event.getEntityType();
|
||||||
|
@ -20,7 +20,7 @@ public class HardcoreListener implements Listener {
|
|||||||
@EventHandler(priority = EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void onPlayerDeath(PlayerDeathEvent event) {
|
public void onPlayerDeath(PlayerDeathEvent event) {
|
||||||
Player player = event.getEntity(); //Note this returns a Player object for this subevent
|
Player player = event.getEntity(); //Note this returns a Player object for this subevent
|
||||||
|
|
||||||
if(player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
if(player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||||
|
|
||||||
if (!Permissions.getInstance().hardcoremodeBypass(player)) {
|
if (!Permissions.getInstance().hardcoremodeBypass(player)) {
|
||||||
|
@ -47,7 +47,7 @@ import com.gmail.nossr50.util.Skills;
|
|||||||
import com.gmail.nossr50.util.Users;
|
import com.gmail.nossr50.util.Users;
|
||||||
|
|
||||||
public class PlayerListener implements Listener {
|
public class PlayerListener implements Listener {
|
||||||
|
|
||||||
private final mcMMO plugin;
|
private final mcMMO plugin;
|
||||||
|
|
||||||
public PlayerListener(final mcMMO plugin) {
|
public PlayerListener(final mcMMO plugin) {
|
||||||
@ -62,9 +62,9 @@ public class PlayerListener implements Listener {
|
|||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
public void onPlayerWorldChangeEvent(PlayerChangedWorldEvent event) {
|
public void onPlayerWorldChangeEvent(PlayerChangedWorldEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
if(player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
if(player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||||
|
|
||||||
PlayerProfile profile = Users.getProfile(player);
|
PlayerProfile profile = Users.getProfile(player);
|
||||||
|
|
||||||
if (profile == null) {
|
if (profile == null) {
|
||||||
@ -93,10 +93,10 @@ 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();
|
||||||
|
|
||||||
if(player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
if(player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||||
|
|
||||||
if (Permissions.getInstance().fishing(player)) {
|
if (Permissions.getInstance().fishing(player)) {
|
||||||
@ -130,9 +130,9 @@ 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());
|
||||||
|
|
||||||
if (profile == null) {
|
if (profile == null) {
|
||||||
@ -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();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,7 +163,7 @@ public class PlayerListener implements Listener {
|
|||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
if(player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
if(player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||||
|
|
||||||
/* GARBAGE COLLECTION */
|
/* GARBAGE COLLECTION */
|
||||||
@ -180,7 +180,7 @@ public class PlayerListener implements Listener {
|
|||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
if(player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
if(player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||||
|
|
||||||
//TODO: Locale ALL the things.
|
//TODO: Locale ALL the things.
|
||||||
@ -199,7 +199,7 @@ public class PlayerListener implements Listener {
|
|||||||
player.sendMessage(prefix + ChatColor.DARK_RED + "Hardcore enabled.");
|
player.sendMessage(prefix + ChatColor.DARK_RED + "Hardcore enabled.");
|
||||||
player.sendMessage(prefix + ChatColor.DARK_AQUA + "Skill Death Penalty: " + ChatColor.DARK_RED + Config.getInstance().getHardcoreDeathStatPenaltyPercentage() + "%");
|
player.sendMessage(prefix + ChatColor.DARK_AQUA + "Skill Death Penalty: " + ChatColor.DARK_RED + Config.getInstance().getHardcoreDeathStatPenaltyPercentage() + "%");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player.hasPermission("mcmmo.perks.xp.quadruple")) {
|
if (player.hasPermission("mcmmo.perks.xp.quadruple")) {
|
||||||
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.xp.name"), LocaleLoader.getString("Perks.xp.desc", new Object[] { 4 }) }));
|
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.xp.name"), LocaleLoader.getString("Perks.xp.desc", new Object[] { 4 }) }));
|
||||||
@ -287,7 +287,7 @@ public class PlayerListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
@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();
|
||||||
}
|
}
|
||||||
@ -424,9 +424,9 @@ public class PlayerListener implements Listener {
|
|||||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||||
public void onPlayerChat(AsyncPlayerChatEvent event) {
|
public void onPlayerChat(AsyncPlayerChatEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
if(player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
if(player.hasMetadata("NPC")) return; // Check if this player is a Citizens NPC
|
||||||
|
|
||||||
PlayerProfile profile = Users.getProfile(player);
|
PlayerProfile profile = Users.getProfile(player);
|
||||||
|
|
||||||
if (profile == null) {
|
if (profile == null) {
|
||||||
|
@ -145,10 +145,10 @@ public class mcMMO extends JavaPlugin {
|
|||||||
repairables.addAll(rManager.getLoadedRepairables());
|
repairables.addAll(rManager.getLoadedRepairables());
|
||||||
repairManager = RepairManagerFactory.getRepairManager(repairables.size());
|
repairManager = RepairManagerFactory.getRepairManager(repairables.size());
|
||||||
repairManager.registerRepairables(repairables);
|
repairManager.registerRepairables(repairables);
|
||||||
|
|
||||||
//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()) {
|
||||||
|
@ -374,7 +374,7 @@ public class PartyManager {
|
|||||||
*/
|
*/
|
||||||
private void loadParties() {
|
private void loadParties() {
|
||||||
File file = new File(partiesFilePath);
|
File file = new File(partiesFilePath);
|
||||||
|
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -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++) {
|
||||||
|
@ -18,7 +18,7 @@ public class Archery {
|
|||||||
private static List<TrackedEntity> trackedEntities = new ArrayList<TrackedEntity>();
|
private static List<TrackedEntity> trackedEntities = new ArrayList<TrackedEntity>();
|
||||||
|
|
||||||
public static final int ARROW_TRACKING_MAX_BONUS_LEVEL = advancedConfig.getRetrieveMaxBonusLevel();
|
public static final int ARROW_TRACKING_MAX_BONUS_LEVEL = advancedConfig.getRetrieveMaxBonusLevel();
|
||||||
|
|
||||||
public static final int BONUS_DAMAGE_INCREASE_LEVEL = advancedConfig.getSkillShotIncreaseLevel();
|
public static final int BONUS_DAMAGE_INCREASE_LEVEL = advancedConfig.getSkillShotIncreaseLevel();
|
||||||
public static final double BONUS_DAMAGE_INCREASE_PERCENT = advancedConfig.getSkillShotIncreasePercentage();
|
public static final double BONUS_DAMAGE_INCREASE_PERCENT = advancedConfig.getSkillShotIncreasePercentage();
|
||||||
public static final double BONUS_DAMAGE_MAX_BONUS_PERCENTAGE = advancedConfig.getSkillShotBonusMax();
|
public static final double BONUS_DAMAGE_MAX_BONUS_PERCENTAGE = advancedConfig.getSkillShotBonusMax();
|
||||||
|
@ -12,7 +12,7 @@ import com.gmail.nossr50.util.Users;
|
|||||||
|
|
||||||
public class ArcheryManager {
|
public class ArcheryManager {
|
||||||
AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
|
AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
|
||||||
|
|
||||||
private Player player;
|
private Player player;
|
||||||
private PlayerProfile profile;
|
private PlayerProfile profile;
|
||||||
private int skillLevel;
|
private int skillLevel;
|
||||||
@ -22,15 +22,15 @@ public class ArcheryManager {
|
|||||||
private float dazeMaxBonusLevel = advancedConfig.getDazeMaxBonusLevel();
|
private float dazeMaxBonusLevel = advancedConfig.getDazeMaxBonusLevel();
|
||||||
private float retrieveBonusMax = advancedConfig.getRetrieveBonusMax();
|
private float retrieveBonusMax = advancedConfig.getRetrieveBonusMax();
|
||||||
private float retrieveMaxBonusLevel = advancedConfig.getRetrieveMaxBonusLevel();
|
private float retrieveMaxBonusLevel = advancedConfig.getRetrieveMaxBonusLevel();
|
||||||
|
|
||||||
public ArcheryManager (Player player) {
|
public ArcheryManager (Player player) {
|
||||||
this.player = player;
|
this.player = player;
|
||||||
this.profile = Users.getProfile(player);
|
this.profile = Users.getProfile(player);
|
||||||
|
|
||||||
//Compatibility with Citizens, Citizens NPCs won't create a profile so we'll check for it here
|
//Compatibility with Citizens, Citizens NPCs won't create a profile so we'll check for it here
|
||||||
if(this.profile == null)
|
if(this.profile == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
this.skillLevel = profile.getSkillLevel(SkillType.ARCHERY);
|
this.skillLevel = profile.getSkillLevel(SkillType.ARCHERY);
|
||||||
this.permissionsInstance = Permissions.getInstance();
|
this.permissionsInstance = Permissions.getInstance();
|
||||||
}
|
}
|
||||||
@ -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();
|
||||||
}
|
}
|
||||||
@ -81,14 +81,14 @@ public class ArcheryManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
DazeEventHandler eventHandler = new DazeEventHandler(this, event, defender);
|
DazeEventHandler eventHandler = new DazeEventHandler(this, event, defender);
|
||||||
|
|
||||||
int randomChance = 100;
|
int randomChance = 100;
|
||||||
|
|
||||||
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) 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){
|
||||||
@ -158,7 +158,7 @@ public class Axes {
|
|||||||
private static void applyGreaterImpact(Player attacker, LivingEntity target, EntityDamageByEntityEvent event) {
|
private static void applyGreaterImpact(Player attacker, LivingEntity target, EntityDamageByEntityEvent event) {
|
||||||
if(attacker == null)
|
if(attacker == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
final int GREATER_IMPACT_CHANCE = advancedConfig.getGreaterImpactChance();
|
final int GREATER_IMPACT_CHANCE = advancedConfig.getGreaterImpactChance();
|
||||||
final double GREATER_IMPACT_MULTIPLIER = advancedConfig.getGreaterImpactModifier();
|
final double GREATER_IMPACT_MULTIPLIER = advancedConfig.getGreaterImpactModifier();
|
||||||
final int GREATER_IMPACT_DAMAGE = advancedConfig.getGreaterImpactBonusDamage();
|
final int GREATER_IMPACT_DAMAGE = advancedConfig.getGreaterImpactBonusDamage();
|
||||||
|
@ -31,7 +31,7 @@ public class BlastMining {
|
|||||||
static AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
|
static AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
|
||||||
|
|
||||||
private static Random random = new Random();
|
private static Random random = new Random();
|
||||||
|
|
||||||
private static int blastMiningRank1 = advancedConfig.getBlastMiningRank1();
|
private static int blastMiningRank1 = advancedConfig.getBlastMiningRank1();
|
||||||
private static int blastMiningRank2 = advancedConfig.getBlastMiningRank2();
|
private static int blastMiningRank2 = advancedConfig.getBlastMiningRank2();
|
||||||
private static int blastMiningRank3 = advancedConfig.getBlastMiningRank3();
|
private static int blastMiningRank3 = advancedConfig.getBlastMiningRank3();
|
||||||
@ -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);
|
||||||
|
@ -40,8 +40,9 @@ 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;
|
||||||
@ -69,12 +66,14 @@ 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -199,8 +218,9 @@ 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;
|
||||||
@ -214,9 +234,10 @@ public class Fishing {
|
|||||||
int lootTier = getFishingLootTier(profile);
|
int lootTier = getFishingLootTier(profile);
|
||||||
|
|
||||||
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) {
|
||||||
@ -456,5 +499,5 @@ public class Fishing {
|
|||||||
default:
|
default:
|
||||||
return 10;
|
return 10;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -203,9 +203,9 @@ public class Herbalism {
|
|||||||
xp = Config.getInstance().getHerbalismXPLilyPads();
|
xp = Config.getInstance().getHerbalismXPLilyPads();
|
||||||
}
|
}
|
||||||
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();
|
||||||
|
|
||||||
@ -341,7 +341,7 @@ public class Herbalism {
|
|||||||
Misc.dropItem(location, is);
|
Misc.dropItem(location, is);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case COCOA:
|
case COCOA:
|
||||||
if (configInstance.getCocoaDoubleDropsEnabled()) {
|
if (configInstance.getCocoaDoubleDropsEnabled()) {
|
||||||
Misc.dropItem(location, is);
|
Misc.dropItem(location, is);
|
||||||
|
@ -87,7 +87,7 @@ public class Mining {
|
|||||||
Misc.dropItem(location, item);
|
Misc.dropItem(location, item);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EMERALD_ORE:
|
case EMERALD_ORE:
|
||||||
if (configInstance.getEmeraldDoubleDropsEnabled()) {
|
if (configInstance.getEmeraldDoubleDropsEnabled()) {
|
||||||
Misc.dropItem(location, item);
|
Misc.dropItem(location, item);
|
||||||
@ -202,7 +202,7 @@ public class Mining {
|
|||||||
Misc.dropItem(location, item);
|
Misc.dropItem(location, item);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EMERALD_ORE:
|
case EMERALD_ORE:
|
||||||
if (configInstance.getEmeraldDoubleDropsEnabled()) {
|
if (configInstance.getEmeraldDoubleDropsEnabled()) {
|
||||||
item = new ItemStack(Material.EMERALD);
|
item = new ItemStack(Material.EMERALD);
|
||||||
@ -294,7 +294,7 @@ public class Mining {
|
|||||||
case STONE:
|
case STONE:
|
||||||
xp += Config.getInstance().getMiningXPStone();
|
xp += Config.getInstance().getMiningXPStone();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EMERALD_ORE:
|
case EMERALD_ORE:
|
||||||
xp += Config.getInstance().getMiningXPEmeraldOre();
|
xp += Config.getInstance().getMiningXPEmeraldOre();
|
||||||
break;
|
break;
|
||||||
@ -324,12 +324,12 @@ public class Mining {
|
|||||||
|
|
||||||
final int MAX_BONUS_LEVEL = advancedConfig.getMiningDoubleDropMaxLevel();
|
final int MAX_BONUS_LEVEL = advancedConfig.getMiningDoubleDropMaxLevel();
|
||||||
int MAX_CHANCE = advancedConfig.getMiningDoubleDropChance();
|
int MAX_CHANCE = advancedConfig.getMiningDoubleDropChance();
|
||||||
|
|
||||||
int skillLevel = Users.getProfile(player).getSkillLevel(SkillType.MINING);
|
int skillLevel = Users.getProfile(player).getSkillLevel(SkillType.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);
|
||||||
@ -438,7 +438,7 @@ public class WoodCutting {
|
|||||||
type ^= 0x8;
|
type ^= 0x8;
|
||||||
|
|
||||||
TreeSpecies species = TreeSpecies.getByData(type);
|
TreeSpecies species = TreeSpecies.getByData(type);
|
||||||
|
|
||||||
//Apparently species can be null in certain cases (custom server mods?)
|
//Apparently species can be null in certain cases (custom server mods?)
|
||||||
//https://github.com/mcMMO-Dev/mcMMO/issues/229
|
//https://github.com/mcMMO-Dev/mcMMO/issues/229
|
||||||
if(species == null)
|
if(species == null)
|
||||||
|
@ -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,11 +248,11 @@ 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);
|
||||||
|
|
||||||
if (chance > random.nextInt(randomChance) && permInstance.repairBonus(player)){
|
if (chance > random.nextInt(randomChance) && permInstance.repairBonus(player)){
|
||||||
player.sendMessage(LocaleLoader.getString("Repair.Skills.FeltEasy"));
|
player.sendMessage(LocaleLoader.getString("Repair.Skills.FeltEasy"));
|
||||||
return true;
|
return true;
|
||||||
|
@ -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
|
||||||
|
@ -6,7 +6,7 @@ import com.gmail.nossr50.config.AdvancedConfig;
|
|||||||
|
|
||||||
public class Swords {
|
public class Swords {
|
||||||
static AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
|
static AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
|
||||||
|
|
||||||
public static final int BLEED_MAX_BONUS_LEVEL = advancedConfig.getBleedMaxBonusLevel();
|
public static final int BLEED_MAX_BONUS_LEVEL = advancedConfig.getBleedMaxBonusLevel();
|
||||||
public static final int MAX_BLEED_TICKS = advancedConfig.getBleedMaxTicks();
|
public static final int MAX_BLEED_TICKS = advancedConfig.getBleedMaxTicks();
|
||||||
public static final int BASE_BLEED_TICKS = advancedConfig.getBleedBaseTicks();
|
public static final int BASE_BLEED_TICKS = advancedConfig.getBleedBaseTicks();
|
||||||
|
@ -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();
|
||||||
|
@ -6,7 +6,7 @@ import com.gmail.nossr50.config.AdvancedConfig;
|
|||||||
|
|
||||||
public class Taming {
|
public class Taming {
|
||||||
static AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
|
static AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
|
||||||
|
|
||||||
public static final int ENVIRONMENTALLY_AWARE_ACTIVATION_LEVEL = advancedConfig.getEnviromentallyAwareUnlock();
|
public static final int ENVIRONMENTALLY_AWARE_ACTIVATION_LEVEL = advancedConfig.getEnviromentallyAwareUnlock();
|
||||||
|
|
||||||
public static final int FAST_FOOD_SERVICE_ACTIVATION_CHANCE = advancedConfig.getFastFoodChance();
|
public static final int FAST_FOOD_SERVICE_ACTIVATION_CHANCE = advancedConfig.getFastFoodChance();
|
||||||
|
@ -102,7 +102,7 @@ public class TamingManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
GoreEventHandler eventHandler = new GoreEventHandler(this, event);
|
GoreEventHandler eventHandler = new GoreEventHandler(this, event);
|
||||||
|
|
||||||
int goreChanceMax = AdvancedConfig.getInstance().getGoreChanceMax();
|
int goreChanceMax = AdvancedConfig.getInstance().getGoreChanceMax();
|
||||||
int goreMaxLevel = AdvancedConfig.getInstance().getGoreMaxBonusLevel();
|
int goreMaxLevel = AdvancedConfig.getInstance().getGoreMaxBonusLevel();
|
||||||
int randomChance = 100;
|
int randomChance = 100;
|
||||||
@ -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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ import com.gmail.nossr50.config.AdvancedConfig;
|
|||||||
|
|
||||||
public class Unarmed {
|
public class Unarmed {
|
||||||
static AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
|
static AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
|
||||||
|
|
||||||
public static final int BONUS_DAMAGE_MAX_BONUS_MODIFIER = advancedConfig.getIronArmBonus();
|
public static final int BONUS_DAMAGE_MAX_BONUS_MODIFIER = advancedConfig.getIronArmBonus();
|
||||||
public static final int BONUS_DAMAGE_INCREASE_LEVEL = advancedConfig.getIronArmIncreaseLevel();
|
public static final int BONUS_DAMAGE_INCREASE_LEVEL = advancedConfig.getIronArmIncreaseLevel();
|
||||||
public static final int DEFLECT_MAX_CHANCE = advancedConfig.getDisarmChanceMax() ;
|
public static final int DEFLECT_MAX_CHANCE = advancedConfig.getDisarmChanceMax() ;
|
||||||
|
@ -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();
|
||||||
@ -83,12 +83,12 @@ public class UnarmedManager {
|
|||||||
int deflectChanceMax = AdvancedConfig.getInstance().getDeflectChanceMax();
|
int deflectChanceMax = AdvancedConfig.getInstance().getDeflectChanceMax();
|
||||||
int deflectMaxLevel = AdvancedConfig.getInstance().getDeflectMaxBonusLevel();
|
int deflectMaxLevel = AdvancedConfig.getInstance().getDeflectMaxBonusLevel();
|
||||||
int randomChance = 100;
|
int randomChance = 100;
|
||||||
|
|
||||||
if (player.hasPermission("mcmmo.perks.lucky.unarmed")) {
|
if (player.hasPermission("mcmmo.perks.lucky.unarmed")) {
|
||||||
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();
|
||||||
@ -143,8 +143,8 @@ public class UnarmedManager {
|
|||||||
if (defender.hasPermission("mcmmo.perks.lucky.unarmed")) {
|
if (defender.hasPermission("mcmmo.perks.lucky.unarmed")) {
|
||||||
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;
|
||||||
|
@ -504,7 +504,7 @@ public class Combat {
|
|||||||
if (Users.getProfile(defender).getGodMode()) {
|
if (Users.getProfile(defender).getGodMode()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//It may seem a bit redundant but we need a check here to prevent bleed from being applied in applyAbilityAoE()
|
//It may seem a bit redundant but we need a check here to prevent bleed from being applied in applyAbilityAoE()
|
||||||
EntityDamageEvent ede = new FakeEntityDamageByEntityEvent(player, entity, EntityDamageEvent.DamageCause.ENTITY_ATTACK, 1);
|
EntityDamageEvent ede = new FakeEntityDamageByEntityEvent(player, entity, EntityDamageEvent.DamageCause.ENTITY_ATTACK, 1);
|
||||||
mcMMO.p.getServer().getPluginManager().callEvent(ede);
|
mcMMO.p.getServer().getPluginManager().callEvent(ede);
|
||||||
|
@ -25,7 +25,7 @@ public class Database {
|
|||||||
|
|
||||||
// Scale waiting time by this much per failed attempt
|
// Scale waiting time by this much per failed attempt
|
||||||
private static final double SCALING_FACTOR = 5;
|
private static final double SCALING_FACTOR = 5;
|
||||||
|
|
||||||
// Minimum wait in nanoseconds (default 500ms)
|
// Minimum wait in nanoseconds (default 500ms)
|
||||||
private static final long MIN_WAIT = 500*100000L;
|
private static final long MIN_WAIT = 500*100000L;
|
||||||
|
|
||||||
@ -37,7 +37,7 @@ public class Database {
|
|||||||
|
|
||||||
// When next to try connecting to Database in nanoseconds
|
// When next to try connecting to Database in nanoseconds
|
||||||
private static long nextReconnectTimestamp = 0L;
|
private static long nextReconnectTimestamp = 0L;
|
||||||
|
|
||||||
// How many connection attemtps have failed
|
// How many connection attemtps have failed
|
||||||
private static int reconnectAttempt = 0;
|
private static int reconnectAttempt = 0;
|
||||||
|
|
||||||
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -270,93 +270,93 @@ public class Database {
|
|||||||
/**
|
/**
|
||||||
* Check connection status and re-establish if dead or stale.
|
* Check connection status and re-establish if dead or stale.
|
||||||
*
|
*
|
||||||
* If the very first immediate attempt fails, further attempts
|
* If the very first immediate attempt fails, further attempts
|
||||||
* will be made in progressively larger intervals up to MAX_WAIT
|
* will be made in progressively larger intervals up to MAX_WAIT
|
||||||
* intervals.
|
* intervals.
|
||||||
*
|
*
|
||||||
* This allows for MySQL to time out idle connections as needed by
|
* This allows for MySQL to time out idle connections as needed by
|
||||||
* server operator, without affecting McMMO, while still providing
|
* server operator, without affecting McMMO, while still providing
|
||||||
* protection against a database outage taking down Bukkit's tick
|
* protection against a database outage taking down Bukkit's tick
|
||||||
* processing loop due to attemping a database connection each
|
* processing loop due to attemping a database connection each
|
||||||
* time McMMO needs the database.
|
* time McMMO needs the 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
|
|
||||||
if (exists && !isClosed) {
|
|
||||||
try {
|
|
||||||
connection.close();
|
|
||||||
} catch (SQLException ex) {
|
|
||||||
// This is a housekeeping exercise, ignore errors
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Try to connect again
|
// Cleanup after ourselves for GC and MySQL's sake
|
||||||
connect();
|
if (exists && !isClosed) {
|
||||||
|
try {
|
||||||
|
connection.close();
|
||||||
|
} catch (SQLException ex) {
|
||||||
|
// This is a housekeeping exercise, ignore errors
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Leave if connection is good
|
// Try to connect again
|
||||||
try {
|
connect();
|
||||||
if (connection != null && !connection.isClosed()) {
|
|
||||||
// Schedule a database save if we really had an outage
|
|
||||||
if (reconnectAttempt > 1) {
|
|
||||||
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new SQLReconnect(plugin), 5);
|
|
||||||
}
|
|
||||||
nextReconnectTimestamp = 0;
|
|
||||||
reconnectAttempt = 0;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
} catch (SQLException e) {
|
|
||||||
// Failed to check isClosed, so presume connection is bad and attempt later
|
|
||||||
e.printStackTrace();
|
|
||||||
printErrors(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
reconnectAttempt++;
|
// Leave if connection is good
|
||||||
|
try {
|
||||||
nextReconnectTimestamp = (long)(System.nanoTime() + Math.min(MAX_WAIT, (reconnectAttempt*SCALING_FACTOR*MIN_WAIT)));
|
if (connection != null && !connection.isClosed()) {
|
||||||
|
// Schedule a database save if we really had an outage
|
||||||
return false;
|
if (reconnectAttempt > 1) {
|
||||||
|
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new SQLReconnect(plugin), 5);
|
||||||
|
}
|
||||||
|
nextReconnectTimestamp = 0;
|
||||||
|
reconnectAttempt = 0;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} catch (SQLException e) {
|
||||||
|
// Failed to check isClosed, so presume connection is bad and attempt later
|
||||||
|
e.printStackTrace();
|
||||||
|
printErrors(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
reconnectAttempt++;
|
||||||
|
|
||||||
|
nextReconnectTimestamp = (long)(System.nanoTime() + Math.min(MAX_WAIT, (reconnectAttempt*SCALING_FACTOR*MIN_WAIT)));
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -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 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -408,11 +408,11 @@ public class Permissions {
|
|||||||
public boolean party(Player player) {
|
public boolean party(Player player) {
|
||||||
return player.hasPermission("mcmmo.commands.party");
|
return player.hasPermission("mcmmo.commands.party");
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean skillReset(Player player) {
|
public boolean skillReset(Player player) {
|
||||||
return player.hasPermission("mcmmo.skillreset");
|
return player.hasPermission("mcmmo.skillreset");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* MCMMO.CHAT.*
|
* MCMMO.CHAT.*
|
||||||
|
@ -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);
|
||||||
|
@ -372,7 +372,7 @@ public class HashChunkletManager implements ChunkletManager {
|
|||||||
// TODO: Make this less messy, as it is, it's kinda... depressing to do it like this.
|
// TODO: Make this less messy, as it is, it's kinda... depressing to do it like this.
|
||||||
// Might also make a mess when we move to stacks, but at that point I think I will write a new Manager...
|
// Might also make a mess when we move to stacks, but at that point I think I will write a new Manager...
|
||||||
// IMPORTANT! If ChunkletStoreFactory is going to be returning something other than PrimitiveEx we need to remove this, as it will be breaking time for old maps
|
// IMPORTANT! If ChunkletStoreFactory is going to be returning something other than PrimitiveEx we need to remove this, as it will be breaking time for old maps
|
||||||
|
|
||||||
/*
|
/*
|
||||||
if(!(storeIn instanceof PrimitiveExChunkletStore)) {
|
if(!(storeIn instanceof PrimitiveExChunkletStore)) {
|
||||||
ChunkletStore tempStore = ChunkletStoreFactory.getChunkletStore();
|
ChunkletStore tempStore = ChunkletStoreFactory.getChunkletStore();
|
||||||
@ -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) {
|
||||||
|
@ -10,7 +10,7 @@ public interface ChunkManager {
|
|||||||
public ChunkStore readChunkStore(World world, int x, int z) throws IOException;
|
public ChunkStore readChunkStore(World world, int x, int z) throws IOException;
|
||||||
public void writeChunkStore(World world, int x, int z, ChunkStore data);
|
public void writeChunkStore(World world, int x, int z, ChunkStore data);
|
||||||
public void closeChunkStore(World world, int x, int z);
|
public void closeChunkStore(World world, int x, int z);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads a specific chunklet
|
* Loads a specific chunklet
|
||||||
*
|
*
|
||||||
|
@ -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