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