Command format & permission changes, other minor cleanup.

This commit is contained in:
GJ 2012-04-29 22:58:54 -04:00
parent 67de70432c
commit 064fc0a8e2
11 changed files with 113 additions and 63 deletions

View File

@ -8,7 +8,9 @@ Key:
- Removal - Removal
Version 1.3.07 Version 1.3.07
+ Added a permission node for Archery bonus damage
! Changed MySQL to save player information 50ms apart from each other to reduce the load on the MySQL server ! Changed MySQL to save player information 50ms apart from each other to reduce the load on the MySQL server
- Removed some unused permission nodes
Version 1.3.06 Version 1.3.06
+ Added Iron Golem XP for aggressive golems + Added Iron Golem XP for aggressive golems

View File

@ -1,5 +1,7 @@
package com.gmail.nossr50.commands.skills; package com.gmail.nossr50.commands.skills;
import java.text.DecimalFormat;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -82,25 +84,27 @@ public class AcrobaticsCommand implements CommandExecutor {
} }
private void dataCalculations(float skillValue) { private void dataCalculations(float skillValue) {
DecimalFormat percent = new DecimalFormat("##0.00%");
if (skillValue >= 1000) { if (skillValue >= 1000) {
dodgeChance = "20"; dodgeChance = "20.00%";
rollChance = "100"; rollChance = "100.00%";
gracefulRollChance = "100"; gracefulRollChance = "100.00%";
} }
else if (skillValue >= 800) { else if (skillValue >= 800) {
dodgeChance = "20"; dodgeChance = "20.00%";
rollChance = String.valueOf(skillValue / 10); rollChance = percent.format(skillValue / 1000);
gracefulRollChance = "100"; gracefulRollChance = "100.00%";
} }
else if (skillValue >= 500) { else if (skillValue >= 500) {
dodgeChance = String.valueOf(skillValue / 40); dodgeChance = percent.format(skillValue / 4000);
rollChance = String.valueOf(skillValue / 10); rollChance = percent.format(skillValue / 1000);
gracefulRollChance = "100"; gracefulRollChance = "100.00%";
} }
else { else {
dodgeChance = String.valueOf(skillValue / 40); dodgeChance = percent.format(skillValue / 4000);
rollChance = String.valueOf(skillValue / 10); rollChance = percent.format(skillValue / 1000);
gracefulRollChance = String.valueOf(skillValue / 5); gracefulRollChance = percent.format(skillValue / 500);
} }
} }

View File

@ -1,5 +1,7 @@
package com.gmail.nossr50.commands.skills; package com.gmail.nossr50.commands.skills;
import java.text.DecimalFormat;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -10,6 +12,7 @@ import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType; import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Page; import com.gmail.nossr50.util.Page;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Users; import com.gmail.nossr50.util.Users;
public class ArcheryCommand implements CommandExecutor { public class ArcheryCommand implements CommandExecutor {
@ -18,6 +21,10 @@ public class ArcheryCommand implements CommandExecutor {
private String dazeChance; private String dazeChance;
private String retrieveChance; private String retrieveChance;
private boolean canSkillShot;
private boolean canDaze;
private boolean canRetrieve;
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (CommandHelper.noConsoleUsage(sender)) { if (CommandHelper.noConsoleUsage(sender)) {
@ -33,20 +40,43 @@ public class ArcheryCommand implements CommandExecutor {
skillValue = (float) PP.getSkillLevel(SkillType.ARCHERY); skillValue = (float) PP.getSkillLevel(SkillType.ARCHERY);
dataCalculations(skillValue); dataCalculations(skillValue);
permissionsCheck(player);
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Archery.SkillName") })); player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Archery.SkillName") }));
player.sendMessage(LocaleLoader.getString("Commands.XPGain", new Object[] { LocaleLoader.getString("Commands.XPGain.Archery") })); player.sendMessage(LocaleLoader.getString("Commands.XPGain", new Object[] { LocaleLoader.getString("Commands.XPGain.Archery") }));
player.sendMessage(LocaleLoader.getString("Effects.Level", new Object[] { PP.getSkillLevel(SkillType.ARCHERY), PP.getSkillXpLevel(SkillType.ARCHERY), PP.getXpToLevel(SkillType.ARCHERY) })); player.sendMessage(LocaleLoader.getString("Effects.Level", new Object[] { PP.getSkillLevel(SkillType.ARCHERY), PP.getSkillXpLevel(SkillType.ARCHERY), PP.getXpToLevel(SkillType.ARCHERY) }));
if (canSkillShot || canDaze || canRetrieve) {
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") })); player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Archery.Effect.0"), LocaleLoader.getString("Archery.Effect.1") })); }
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Archery.Effect.2"), LocaleLoader.getString("Archery.Effect.3") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Archery.Effect.4"), LocaleLoader.getString("Archery.Effect.5") }));
if (canSkillShot) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Archery.Effect.0"), LocaleLoader.getString("Archery.Effect.1") }));
}
if (canDaze) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Archery.Effect.2"), LocaleLoader.getString("Archery.Effect.3") }));
}
if (canRetrieve) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Archery.Effect.4"), LocaleLoader.getString("Archery.Effect.5") }));
}
if (canSkillShot || canDaze || canRetrieve) {
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") })); player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
}
if (canSkillShot) {
player.sendMessage(LocaleLoader.getString("Archery.Combat.SkillshotBonus", new Object[] { skillShotBonus })); player.sendMessage(LocaleLoader.getString("Archery.Combat.SkillshotBonus", new Object[] { skillShotBonus }));
}
if (canDaze) {
player.sendMessage(LocaleLoader.getString("Archery.Combat.DazeChance", new Object[] { dazeChance })); player.sendMessage(LocaleLoader.getString("Archery.Combat.DazeChance", new Object[] { dazeChance }));
}
if (canRetrieve) {
player.sendMessage(LocaleLoader.getString("Archery.Combat.RetrieveChance", new Object[] { retrieveChance })); player.sendMessage(LocaleLoader.getString("Archery.Combat.RetrieveChance", new Object[] { retrieveChance }));
}
Page.grabGuidePageForSkill(SkillType.ARCHERY, player, args); Page.grabGuidePageForSkill(SkillType.ARCHERY, player, args);
@ -54,15 +84,24 @@ public class ArcheryCommand implements CommandExecutor {
} }
private void dataCalculations(float skillValue) { private void dataCalculations(float skillValue) {
DecimalFormat percent = new DecimalFormat("##0.00%");
if (skillValue >= 1000) { if (skillValue >= 1000) {
skillShotBonus = "200"; skillShotBonus = "200.00%";
dazeChance = "50"; dazeChance = "50.00%";
retrieveChance = "100"; retrieveChance = "100.00%";
} }
else { else {
skillShotBonus = String.valueOf((int) skillValue / 5); skillShotBonus = percent.format(((int) skillValue / 50) * 0.1D); //TODO: Not sure if this is the best way to calculate this or not...
dazeChance = String.valueOf(skillValue / 20); dazeChance = percent.format(skillValue / 2000);
retrieveChance = String.valueOf(skillValue / 10); retrieveChance = percent.format(skillValue / 1000);
} }
} }
private void permissionsCheck(Player player) {
Permissions permInstance = Permissions.getInstance();
canSkillShot = permInstance.archeryBonus(player);
canDaze = permInstance.daze(player);
canRetrieve = permInstance.trackArrows(player);
}
} }

View File

@ -19,6 +19,7 @@ public class Config extends ConfigLoader {
* GENERAL SETTINGS * GENERAL SETTINGS
*/ */
/* General Settings */ /* General Settings */
public String getLocale() { return config.getString("General.Locale", "en_us"); } public String getLocale() { return config.getString("General.Locale", "en_us"); }
public boolean getMOTDEnabled() { return config.getBoolean("General.MOTD_Enabled", true); } public boolean getMOTDEnabled() { return config.getBoolean("General.MOTD_Enabled", true); }
@ -33,6 +34,7 @@ public class Config extends ConfigLoader {
public String getMySQLUserName() { return config.getString("MySQL.Database.User_Name", "UserName"); } //Really should be labeled under MySQL.User_Name instead... public String getMySQLUserName() { return config.getString("MySQL.Database.User_Name", "UserName"); } //Really should be labeled under MySQL.User_Name instead...
public int getMySQLServerPort() { return config.getInt("MySQL.Server.Port", 3306); } public int getMySQLServerPort() { return config.getInt("MySQL.Server.Port", 3306); }
public String getMySQLServerName() { return config.getString("MySQL.Server.Address", "localhost"); } public String getMySQLServerName() { return config.getString("MySQL.Server.Address", "localhost"); }
public String getMySQLUserPassword() { public String getMySQLUserPassword() {
if (config.getString("MySQL.Database.User_Password", null) != null) { if (config.getString("MySQL.Database.User_Password", null) != null) {
return config.getString("MySQL.Database.User_Password", null); return config.getString("MySQL.Database.User_Password", null);

View File

@ -5,7 +5,6 @@ import org.bukkit.entity.Player;
import com.gmail.nossr50.util.Users; import com.gmail.nossr50.util.Users;
public class ProfileSaveTask implements Runnable { public class ProfileSaveTask implements Runnable {
Player player = null; Player player = null;
public ProfileSaveTask(Player player) { public ProfileSaveTask(Player player) {

View File

@ -1,10 +1,8 @@
package com.gmail.nossr50.runnables; package com.gmail.nossr50.runnables;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Users;
public class SaveTimer implements Runnable { public class SaveTimer implements Runnable {
private final mcMMO plugin; private final mcMMO plugin;
@ -17,8 +15,9 @@ public class SaveTimer implements Runnable {
public void run() { public void run() {
//All player data will be saved periodically through this //All player data will be saved periodically through this
int count = 1; int count = 1;
for (Player player : plugin.getServer().getOnlinePlayers()) { for (Player player : plugin.getServer().getOnlinePlayers()) {
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new ProfileSaveTask(player), count); plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new ProfileSaveTask(player), count);
count++; count++;
} }
} }

View File

@ -14,7 +14,6 @@ import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Combat; import com.gmail.nossr50.util.Combat;
import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Users; import com.gmail.nossr50.util.Users;
public class Archery { public class Archery {
@ -61,7 +60,7 @@ public class Archery {
loc.setPitch(-90); loc.setPitch(-90);
} }
if (random.nextInt(2000) <= skillCheck && Permissions.getInstance().daze(attacker)) { if (random.nextInt(2000) <= skillCheck) {
defender.teleport(loc); defender.teleport(loc);
Combat.dealDamage(defender, 4); Combat.dealDamage(defender, 4);
defender.sendMessage(LocaleLoader.getString("Combat.TouchedFuzzy")); defender.sendMessage(LocaleLoader.getString("Combat.TouchedFuzzy"));

View File

@ -181,7 +181,7 @@ public class Combat {
if (target instanceof Player) { if (target instanceof Player) {
Player defender = (Player) target; Player defender = (Player) target;
if (Permissions.getInstance().unarmed(defender) && defender.getItemInHand().getType().equals(Material.AIR)) { if (defender.getItemInHand().getType().equals(Material.AIR)) {
Unarmed.deflectCheck(defender, event); Unarmed.deflectCheck(defender, event);
} }
} }
@ -193,19 +193,23 @@ public class Combat {
if (Permissions.getInstance().archery(attacker) && damage > 0) { if (Permissions.getInstance().archery(attacker) && damage > 0) {
if (Permissions.getInstance().archeryBonus(attacker)) {
/*Archery needs a damage bonus to be viable in PVP*/ /*Archery needs a damage bonus to be viable in PVP*/
int skillLvl = Users.getProfile(attacker).getSkillLevel(SkillType.ARCHERY); int skillLvl = Users.getProfile(attacker).getSkillLevel(SkillType.ARCHERY);
double dmgBonusPercent = ((skillLvl / 50) * 0.1D); double dmgBonusPercent = ((skillLvl / 50) * 0.1D);
/* Cap maximum bonus at 200% */ /* Cap maximum bonus at 200% */
if(dmgBonusPercent > 2) if (dmgBonusPercent > 2) {
dmgBonusPercent = 2; dmgBonusPercent = 2;
}
/* Every 100 skill levels Archery gains 20% damage bonus, set that here */ /* Every 100 skill levels Archery gains 20% damage bonus, set that here */
//TODO: Work in progress for balancing out Archery, will work on it more later... //TODO: Work in progress for balancing out Archery, will work on it more later...
//TODO: Right now this is calculating a 10% bonus every 50 levels, not 20% every 100. Is this intended? //TODO: Right now this is calculating a 10% bonus every 50 levels, not 20% every 100. Is this intended?
int archeryBonus = (int)(event.getDamage() * dmgBonusPercent); int archeryBonus = (int)(event.getDamage() * dmgBonusPercent);
event.setDamage(event.getDamage() + archeryBonus); event.setDamage(event.getDamage() + archeryBonus);
}
if (Permissions.getInstance().trackArrows(attacker)) { if (Permissions.getInstance().trackArrows(attacker)) {
Archery.trackArrows(pluginx, target, PPa); Archery.trackArrows(pluginx, target, PPa);
@ -222,11 +226,13 @@ public class Combat {
return; return;
} }
if (Permissions.getInstance().daze(attacker)) {
Archery.dazeCheck(defender, attacker); Archery.dazeCheck(defender, attacker);
} }
} }
} }
} }
}
/** /**
* Attempt to damage target for value dmg with reason CUSTOM * Attempt to damage target for value dmg with reason CUSTOM

View File

@ -212,14 +212,14 @@ public class Permissions {
return player.hasPermission("mcmmo.ability.archery.trackarrows"); return player.hasPermission("mcmmo.ability.archery.trackarrows");
} }
public boolean ignition(Player player) {
return player.hasPermission("mcmmo.ability.archery.ignition");
}
public boolean daze(Player player) { public boolean daze(Player player) {
return player.hasPermission("mcmmo.ability.archery.daze"); return player.hasPermission("mcmmo.ability.archery.daze");
} }
public boolean archeryBonus(Player player) {
return player.hasPermission("mcmmo.ability.archery.bonusdamage");
}
/* /*
* MCMMO.ABILITY.HERBALISM.* * MCMMO.ABILITY.HERBALISM.*
*/ */

View File

@ -18,7 +18,7 @@
# ACROBATICS # ACROBATICS
Acrobatics.Ability.Proc=[[GREEN]]**Graceful Landing** Acrobatics.Ability.Proc=[[GREEN]]**Graceful Landing**
Acrobatics.Combat.Proc=[[GREEN]]**Dodged** Acrobatics.Combat.Proc=[[GREEN]]**Dodged**
Acrobatics.DodgeChance=[[RED]]Dodge Chance: [[YELLOW]]{0}% Acrobatics.DodgeChance=[[RED]]Dodge Chance: [[YELLOW]]{0}
Acrobatics.Effect.0=Roll Acrobatics.Effect.0=Roll
Acrobatics.Effect.1=Reduces or Negates fall damage Acrobatics.Effect.1=Reduces or Negates fall damage
Acrobatics.Effect.2=Graceful Roll Acrobatics.Effect.2=Graceful Roll
@ -26,16 +26,16 @@ Acrobatics.Effect.3=Twice as effective as a normal Roll
Acrobatics.Effect.4=Dodge Acrobatics.Effect.4=Dodge
Acrobatics.Effect.5=Reduce attack damage by half Acrobatics.Effect.5=Reduce attack damage by half
Acrobatics.Listener=Acrobatics: Acrobatics.Listener=Acrobatics:
Acrobatics.Roll.Chance=[[RED]]Roll Chance: [[YELLOW]]{0}% Acrobatics.Roll.Chance=[[RED]]Roll Chance: [[YELLOW]]{0}
Acrobatics.Roll.GraceChance=[[RED]]Graceful Roll Chance: [[YELLOW]]{0}% Acrobatics.Roll.GraceChance=[[RED]]Graceful Roll Chance: [[YELLOW]]{0}
Acrobatics.Roll.Text=**Rolled** Acrobatics.Roll.Text=**Rolled**
Acrobatics.SkillName=ACROBATICS Acrobatics.SkillName=ACROBATICS
Acrobatics.Skillup=[[YELLOW]]Acrobatics skill increased by {0}. Total ({1}) Acrobatics.Skillup=[[YELLOW]]Acrobatics skill increased by {0}. Total ({1})
#ARCHERY #ARCHERY
Archery.Combat.DazeChance=[[RED]]Chance to Daze: [[YELLOW]]{0}% Archery.Combat.DazeChance=[[RED]]Chance to Daze: [[YELLOW]]{0}
Archery.Combat.RetrieveChance=[[RED]]Chance to Retrieve Arrows: [[YELLOW]]{0}% Archery.Combat.RetrieveChance=[[RED]]Chance to Retrieve Arrows: [[YELLOW]]{0}
Archery.Combat.SkillshotBonus=[[RED]]Skill Shot Bonus Damage: [[YELLOW]]{0}% Archery.Combat.SkillshotBonus=[[RED]]Skill Shot Bonus Damage: [[YELLOW]]{0}
Archery.Effect.0=Skill Shot Archery.Effect.0=Skill Shot
Archery.Effect.1=Increases damage done with bows Archery.Effect.1=Increases damage done with bows
Archery.Effect.2=Daze (Players) Archery.Effect.2=Daze (Players)

View File

@ -291,14 +291,14 @@ permissions:
description: Allows access to all Archery abilities description: Allows access to all Archery abilities
children: children:
mcmmo.ability.archery.trackarrows: true mcmmo.ability.archery.trackarrows: true
mcmmo.ability.archery.ignition: true
mcmmo.ability.archery.daze: true mcmmo.ability.archery.daze: true
mcmmo.ability.archery.bonusdamage : true
mcmmo.ability.archery.trackarrows: mcmmo.ability.archery.trackarrows:
description: Allows tracking & retrieval of arrows description: Allows tracking & retrieval of arrows
mcmmo.ability.archery.ignition:
description: Allows access to the Ignition ability
mcmmo.ability.archery.daze: mcmmo.ability.archery.daze:
description: Allows access to the Daze ability description: Allows access to the Daze ability
mcmmo.ability.archery.bonusdamage:
description: Allows bonus damage from Archery
mcmmo.ability.herbalism.*: mcmmo.ability.herbalism.*:
description: Allows access to all Herbalism abilities description: Allows access to all Herbalism abilities
children: children: