Formatting cleanup from the scoreboard update. Also handle skill permissions differently.

This commit is contained in:
GJ 2013-10-28 13:04:06 -04:00
parent f55039ac6b
commit 9ef3c721df
32 changed files with 419 additions and 439 deletions

View File

@ -14,57 +14,58 @@ import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
public class McscoreboardCommand implements TabExecutor { public class McscoreboardCommand implements TabExecutor {
private static final List<String> FIRST_ARGS = ImmutableList.of("keep", "time", "clear", "reset"); private static final List<String> FIRST_ARGS = ImmutableList.of("keep", "time", "clear");
@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 (CommandUtils.noConsoleUsage(sender)) { if (CommandUtils.noConsoleUsage(sender)) {
return true; return true;
} }
if (args.length == 0) {
help(sender);
return true;
}
if (args[0].equalsIgnoreCase("clear") || args[0].equalsIgnoreCase("reset")) { switch (args.length) {
ScoreboardManager.clearBoard(sender.getName()); case 1:
sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Clear")); if (args[0].equalsIgnoreCase("clear") || args[0].equalsIgnoreCase("reset")) {
} ScoreboardManager.clearBoard(sender.getName());
else if (args[0].equalsIgnoreCase("keep")) { sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Clear"));
if (!Config.getInstance().getAllowKeepBoard()) { return true;
sender.sendMessage(LocaleLoader.getString("Commands.Disabled")); }
return true;
}
if (!ScoreboardManager.isBoardShown(sender.getName())) {
sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.NoBoard"));
return true;
}
ScoreboardManager.keepBoard(sender.getName());
sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Keep"));
}
else if (args[0].equalsIgnoreCase("time") || args[0].equalsIgnoreCase("timer")) {
if (args.length == 1) {
help(sender);
return true;
}
if (CommandUtils.isInvalidInteger(sender, args[1])) {
return true;
}
int time = Math.abs(Integer.parseInt(args[1]));
ScoreboardManager.setRevertTimer(sender.getName(), time);
sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Timer", time));
}
else {
help(sender);
}
return true;
}
private void help(CommandSender sender) { if (args[0].equalsIgnoreCase("keep")) {
sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Help.0")); if (!Config.getInstance().getAllowKeepBoard()) {
sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Help.1")); sender.sendMessage(LocaleLoader.getString("Commands.Disabled"));
sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Help.2")); return true;
sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Help.3")); }
if (!ScoreboardManager.isBoardShown(sender.getName())) {
sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.NoBoard"));
return true;
}
ScoreboardManager.keepBoard(sender.getName());
sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Keep"));
return true;
}
return help(sender);
case 2:
if (args[0].equalsIgnoreCase("time") || args[0].equalsIgnoreCase("timer")) {
if (CommandUtils.isInvalidInteger(sender, args[1])) {
return true;
}
int time = Math.abs(Integer.parseInt(args[1]));
ScoreboardManager.setRevertTimer(sender.getName(), time);
sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Timer", time));
return true;
}
return help(sender);
default:
return help(sender);
}
} }
@Override @Override
@ -73,8 +74,15 @@ public class McscoreboardCommand implements TabExecutor {
case 1: case 1:
return StringUtil.copyPartialMatches(args[0], FIRST_ARGS, new ArrayList<String>(FIRST_ARGS.size())); return StringUtil.copyPartialMatches(args[0], FIRST_ARGS, new ArrayList<String>(FIRST_ARGS.size()));
default: default:
break; return ImmutableList.of();
} }
return ImmutableList.of(); }
private boolean help(CommandSender sender) {
sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Help.0"));
sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Help.1"));
sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Help.2"));
sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Help.3"));
return true;
} }
} }

View File

@ -37,6 +37,6 @@ public class AddlevelsCommand extends ExperienceCommand {
@Override @Override
protected void handlePlayerMessageSkill() { protected void handlePlayerMessageSkill() {
player.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.1", value, skill.getSkillName())); player.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.1", value, skill.getName()));
} }
} }

View File

@ -34,6 +34,6 @@ public class AddxpCommand extends ExperienceCommand {
@Override @Override
protected void handlePlayerMessageSkill() { protected void handlePlayerMessageSkill() {
player.sendMessage(LocaleLoader.getString("Commands.addxp.AwardSkill", value, skill.getSkillName())); player.sendMessage(LocaleLoader.getString("Commands.addxp.AwardSkill", value, skill.getName()));
} }
} }

View File

@ -148,7 +148,7 @@ public abstract class ExperienceCommand implements TabExecutor {
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", playerName)); sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", playerName));
} }
else { else {
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.2", skill.getSkillName(), playerName)); sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.2", skill.getName(), playerName));
} }
} }

View File

@ -39,6 +39,6 @@ public class MmoeditCommand extends ExperienceCommand {
@Override @Override
protected void handlePlayerMessageSkill() { protected void handlePlayerMessageSkill() {
player.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.1", skill.getSkillName(), value)); player.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.1", skill.getName(), value));
} }
} }

View File

@ -121,6 +121,6 @@ public class SkillresetCommand extends ExperienceCommand {
@Override @Override
protected void handlePlayerMessageSkill() { protected void handlePlayerMessageSkill() {
player.sendMessage(LocaleLoader.getString("Commands.Reset.Single", skill.getSkillName())); player.sendMessage(LocaleLoader.getString("Commands.Reset.Single", skill.getName()));
} }
} }

View File

@ -42,7 +42,10 @@ public class InspectCommand implements TabExecutor {
if (sender instanceof Player && Config.getInstance().getInspectUseBoard()) { if (sender instanceof Player && Config.getInstance().getInspectUseBoard()) {
ScoreboardManager.enablePlayerInspectScoreboard((Player) sender, profile); ScoreboardManager.enablePlayerInspectScoreboard((Player) sender, profile);
if (!Config.getInstance().getInspectUseChat()) return true;
if (!Config.getInstance().getInspectUseChat()) {
return true;
}
} }
sender.sendMessage(LocaleLoader.getString("Inspect.OfflineStats", playerName)); sender.sendMessage(LocaleLoader.getString("Inspect.OfflineStats", playerName));
@ -78,7 +81,10 @@ public class InspectCommand implements TabExecutor {
if (sender instanceof Player && Config.getInstance().getInspectUseBoard()) { if (sender instanceof Player && Config.getInstance().getInspectUseBoard()) {
ScoreboardManager.enablePlayerInspectScoreboard((Player) sender, mcMMOPlayer.getProfile()); ScoreboardManager.enablePlayerInspectScoreboard((Player) sender, mcMMOPlayer.getProfile());
if (!Config.getInstance().getInspectUseChat()) return true;
if (!Config.getInstance().getInspectUseChat()) {
return true;
}
} }
sender.sendMessage(LocaleLoader.getString("Inspect.Stats", target.getName())); sender.sendMessage(LocaleLoader.getString("Inspect.Stats", target.getName()));

View File

@ -6,14 +6,11 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor; import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.permissions.Permissible;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config; import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.player.PlayerProfile; import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.AbilityType; import com.gmail.nossr50.datatypes.skills.AbilityType;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager; import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
@ -33,7 +30,10 @@ public class MccooldownCommand implements TabExecutor {
if (Config.getInstance().getCooldownUseBoard()) { if (Config.getInstance().getCooldownUseBoard()) {
ScoreboardManager.enablePlayerCooldownScoreboard(player); ScoreboardManager.enablePlayerCooldownScoreboard(player);
if (!Config.getInstance().getCooldownUseChat()) return true;
if (!Config.getInstance().getCooldownUseChat()) {
return true;
}
} }
PlayerProfile profile = UserManager.getPlayer(player).getProfile(); PlayerProfile profile = UserManager.getPlayer(player).getProfile();
@ -42,17 +42,17 @@ public class MccooldownCommand implements TabExecutor {
player.sendMessage(LocaleLoader.getString("mcMMO.NoSkillNote")); player.sendMessage(LocaleLoader.getString("mcMMO.NoSkillNote"));
for (AbilityType ability : AbilityType.NORMAL_ABILITIES) { for (AbilityType ability : AbilityType.NORMAL_ABILITIES) {
if (!hasPermission(player, ability)) { if (!ability.getPermissions(player)) {
continue; continue;
} }
int seconds = SkillUtils.calculateTimeLeft(ability, profile, player); int seconds = SkillUtils.calculateTimeLeft(ability, profile, player);
if (seconds <= 0) { if (seconds <= 0) {
player.sendMessage(LocaleLoader.getString("Commands.Cooldowns.Row.Y", ability.getAbilityName())); player.sendMessage(LocaleLoader.getString("Commands.Cooldowns.Row.Y", ability.getName()));
} }
else { else {
player.sendMessage(LocaleLoader.getString("Commands.Cooldowns.Row.N", ability.getAbilityName(), Integer.toString(seconds))); player.sendMessage(LocaleLoader.getString("Commands.Cooldowns.Row.N", ability.getName(), seconds));
} }
} }
@ -63,34 +63,6 @@ public class MccooldownCommand implements TabExecutor {
} }
} }
private boolean hasPermission(Permissible permissible, AbilityType ability) {
switch (ability) {
case BERSERK:
return Permissions.berserk(permissible);
case BLAST_MINING:
return Permissions.remoteDetonation(permissible);
case BLOCK_CRACKER:
return Permissions.blockCracker(permissible);
case GIGA_DRILL_BREAKER:
return Permissions.gigaDrillBreaker(permissible);
case GREEN_TERRA:
return Permissions.greenTerra(permissible);
case LEAF_BLOWER:
return Permissions.leafBlower(permissible);
case SERRATED_STRIKES:
return Permissions.serratedStrikes(permissible);
case SKULL_SPLITTER:
return Permissions.skullSplitter(permissible);
case SUPER_BREAKER:
return Permissions.superBreaker(permissible);
case TREE_FELLER:
return Permissions.treeFeller(permissible);
default:
mcMMO.p.getLogger().warning("MccooldownCommand - couldn't check permission for AbilityType." + ability.name());
return false;
}
}
@Override @Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) { public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
return ImmutableList.of(); return ImmutableList.of();

View File

@ -49,9 +49,10 @@ public class McrankCommand implements TabExecutor {
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName, true); McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName, true);
if (mcMMOPlayer != null) { if (mcMMOPlayer != null) {
playerName = mcMMOPlayer.getPlayer().getName(); Player player = mcMMOPlayer.getPlayer();
playerName = player.getName();
if (CommandUtils.tooFar(sender, mcMMOPlayer.getPlayer(), Permissions.mcrankFar(sender))) { if (CommandUtils.tooFar(sender, player, Permissions.mcrankFar(sender))) {
return true; return true;
} }
} }
@ -80,16 +81,19 @@ public class McrankCommand implements TabExecutor {
private void display(CommandSender sender, String playerName) { private void display(CommandSender sender, String playerName) {
if (sender instanceof Player) { if (sender instanceof Player) {
McMMOPlayer mcpl = UserManager.getPlayer(sender.getName()); McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName());
if (mcpl.getDatabaseATS() + Misc.PLAYER_DATABASE_COOLDOWN_MILLIS > System.currentTimeMillis()) {
if (mcMMOPlayer.getDatabaseATS() + Misc.PLAYER_DATABASE_COOLDOWN_MILLIS > System.currentTimeMillis()) {
sender.sendMessage(LocaleLoader.getString("Commands.Database.Cooldown")); sender.sendMessage(LocaleLoader.getString("Commands.Database.Cooldown"));
return; return;
} }
mcpl.actualizeDatabaseATS();
mcMMOPlayer.actualizeDatabaseATS();
} }
boolean useBoard = (sender instanceof Player) && (Config.getInstance().getRankUseBoard()); boolean useBoard = (sender instanceof Player) && (Config.getInstance().getRankUseBoard());
boolean useChat = useBoard ? Config.getInstance().getRankUseChat() : true; boolean useChat = useBoard ? Config.getInstance().getRankUseChat() : true;
new McrankCommandAsyncTask(playerName, sender, useBoard, useChat).runTaskAsynchronously(mcMMO.p); new McrankCommandAsyncTask(playerName, sender, useBoard, useChat).runTaskAsynchronously(mcMMO.p);
} }
} }

View File

@ -28,8 +28,12 @@ public class McstatsCommand implements TabExecutor {
if (Config.getInstance().getStatsUseBoard()) { if (Config.getInstance().getStatsUseBoard()) {
ScoreboardManager.enablePlayerStatsScoreboard(player); ScoreboardManager.enablePlayerStatsScoreboard(player);
if (!Config.getInstance().getStatsUseChat()) return true;
if (!Config.getInstance().getStatsUseChat()) {
return true;
}
} }
player.sendMessage(LocaleLoader.getString("Stats.Own.Stats")); player.sendMessage(LocaleLoader.getString("Stats.Own.Stats"));
player.sendMessage(LocaleLoader.getString("mcMMO.NoSkillNote")); player.sendMessage(LocaleLoader.getString("mcMMO.NoSkillNote"));

View File

@ -23,27 +23,26 @@ import com.gmail.nossr50.util.player.UserManager;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
public class MctopCommand implements TabExecutor { public class MctopCommand implements TabExecutor {
private SkillType skill;
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
SkillType skill;
switch (args.length) { switch (args.length) {
case 0: case 0:
display(1, null, sender, command); display(1, sender, command);
return true; return true;
case 1: case 1:
if (StringUtils.isInt(args[0])) { if (StringUtils.isInt(args[0])) {
display(Math.abs(Integer.parseInt(args[0])), null, sender, command); display(Math.abs(Integer.parseInt(args[0])), sender, command);
return true; return true;
} }
if ((skill = extractSkill(sender, args[0])) == null) { if (!extractSkill(sender, args[0])) {
return true; return true;
} }
display(1, skill, sender, command); display(1, sender, command);
return true; return true;
case 2: case 2:
@ -51,11 +50,11 @@ public class MctopCommand implements TabExecutor {
return true; return true;
} }
if ((skill = extractSkill(sender, args[0])) == null) { if (!extractSkill(sender, args[0])) {
return true; return true;
} }
display(Math.abs(Integer.parseInt(args[1])), skill, sender, command); display(Math.abs(Integer.parseInt(args[1])), sender, command);
return true; return true;
default: default:
@ -73,19 +72,21 @@ public class MctopCommand implements TabExecutor {
} }
} }
private void display(int page, SkillType skill, CommandSender sender, Command command) { private void display(int page, CommandSender sender, Command command) {
if (skill != null && !Permissions.mctop(sender, skill)) { if (skill != null && !Permissions.mctop(sender, skill)) {
sender.sendMessage(command.getPermissionMessage()); sender.sendMessage(command.getPermissionMessage());
return; return;
} }
if (sender instanceof Player) { if (sender instanceof Player) {
McMMOPlayer mcpl = UserManager.getPlayer(sender.getName()); McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName());
if (mcpl.getDatabaseATS() + Misc.PLAYER_DATABASE_COOLDOWN_MILLIS > System.currentTimeMillis()) {
if (mcMMOPlayer.getDatabaseATS() + Misc.PLAYER_DATABASE_COOLDOWN_MILLIS > System.currentTimeMillis()) {
sender.sendMessage(LocaleLoader.getString("Commands.Database.Cooldown")); sender.sendMessage(LocaleLoader.getString("Commands.Database.Cooldown"));
return; return;
} }
mcpl.actualizeDatabaseATS();
mcMMOPlayer.actualizeDatabaseATS();
} }
display(page, skill, sender); display(page, skill, sender);
@ -98,16 +99,17 @@ public class MctopCommand implements TabExecutor {
new MctopCommandAsyncTask(page, skill, sender, useBoard, useChat).runTaskAsynchronously(mcMMO.p); new MctopCommandAsyncTask(page, skill, sender, useBoard, useChat).runTaskAsynchronously(mcMMO.p);
} }
private SkillType extractSkill(CommandSender sender, String skillName) { private boolean extractSkill(CommandSender sender, String skillName) {
if (CommandUtils.isInvalidSkill(sender, skillName)) { if (CommandUtils.isInvalidSkill(sender, skillName)) {
return null; return false;
}
SkillType skill = SkillType.getSkill(skillName);
if (skill != null && CommandUtils.isChildSkill(sender, skill)) {
return null;
} }
return skill; skill = SkillType.getSkill(skillName);
if (CommandUtils.isChildSkill(sender, skill)) {
return false;
}
return true;
} }
} }

View File

@ -45,7 +45,7 @@ public abstract class SkillCommand implements TabExecutor {
public SkillCommand(SkillType skill) { public SkillCommand(SkillType skill) {
this.skill = skill; this.skill = skill;
skillName = skill.getSkillName(); skillName = skill.getName();
skillGuideCommand = new SkillGuideCommand(skill); skillGuideCommand = new SkillGuideCommand(skill);
} }
@ -77,7 +77,6 @@ public abstract class SkillCommand implements TabExecutor {
player.sendMessage(LocaleLoader.getString("Skills.Header", skillName)); player.sendMessage(LocaleLoader.getString("Skills.Header", skillName));
player.sendMessage(LocaleLoader.getString("Commands.XPGain", LocaleLoader.getString("Commands.XPGain." + StringUtils.getCapitalized(skill.toString())))); player.sendMessage(LocaleLoader.getString("Commands.XPGain", LocaleLoader.getString("Commands.XPGain." + StringUtils.getCapitalized(skill.toString()))));
player.sendMessage(LocaleLoader.getString("Effects.Level", (int) skillValue, profile.getSkillXpLevel(skill), profile.getXpToLevel(skill))); player.sendMessage(LocaleLoader.getString("Effects.Level", (int) skillValue, profile.getSkillXpLevel(skill), profile.getXpToLevel(skill)));
} }
else { else {
player.sendMessage(LocaleLoader.getString("Skills.Header", skillName + " " + LocaleLoader.getString("Skills.Child"))); player.sendMessage(LocaleLoader.getString("Skills.Header", skillName + " " + LocaleLoader.getString("Skills.Child")));
@ -88,7 +87,7 @@ public abstract class SkillCommand implements TabExecutor {
Set<SkillType> parents = FamilyTree.getParents(skill); Set<SkillType> parents = FamilyTree.getParents(skill);
for (SkillType parent : parents) { for (SkillType parent : parents) {
player.sendMessage(parent.getSkillName() + " - " + LocaleLoader.getString("Effects.Level", profile.getSkillLevel(parent), profile.getSkillXpLevel(parent), profile.getXpToLevel(parent))); player.sendMessage(parent.getName() + " - " + LocaleLoader.getString("Effects.Level", profile.getSkillLevel(parent), profile.getSkillXpLevel(parent), profile.getXpToLevel(parent)));
} }
} }

View File

@ -18,7 +18,7 @@ public class SkillGuideCommand implements CommandExecutor {
private String invalidPage; private String invalidPage;
public SkillGuideCommand(SkillType skillType) { public SkillGuideCommand(SkillType skillType) {
header = LocaleLoader.getString("Guides.Header", skillType.getSkillName()); header = LocaleLoader.getString("Guides.Header", skillType.getName());
guide = getGuide(skillType); guide = getGuide(skillType);
invalidPage = LocaleLoader.getString("Guides.Page.Invalid"); invalidPage = LocaleLoader.getString("Guides.Page.Invalid");

View File

@ -85,12 +85,6 @@ public class Config extends AutoUpdateConfigLoader {
reason.add("Either Board or Print in Scoreboard.Types.Inspect must be true!"); reason.add("Either Board or Print in Scoreboard.Types.Inspect must be true!");
} }
/* Skill.Print setting removed, as I can't think of a good use for it
if (!(getSkillUseChat() || getSkillUseBoard())) {
reason.add("Either Board or Print in Scoreboard.Commands.Skill must be true!");
}
// */
/* Database Purging */ /* Database Purging */
if (getPurgeInterval() < -1) { if (getPurgeInterval() < -1) {
reason.add("Database_Purging.Purge_Interval should be greater than, or equal to -1!"); reason.add("Database_Purging.Purge_Interval should be greater than, or equal to -1!");
@ -258,7 +252,6 @@ public class Config extends AutoUpdateConfigLoader {
public boolean getCooldownUseBoard() { return config.getBoolean("Scoreboard.Types.Cooldown.Board", true); } public boolean getCooldownUseBoard() { return config.getBoolean("Scoreboard.Types.Cooldown.Board", true); }
public int getCooldownScoreboardTime() { return config.getInt("Scoreboard.Types.Cooldown.Display_Time", 41); } public int getCooldownScoreboardTime() { return config.getInt("Scoreboard.Types.Cooldown.Display_Time", 41); }
// public boolean getSkillUseChat() { return config.getBoolean("Scoreboard.Types.Skill.Print", false); }
public boolean getSkillUseBoard() { return config.getBoolean("Scoreboard.Types.Skill.Board", true); } public boolean getSkillUseBoard() { return config.getBoolean("Scoreboard.Types.Skill.Board", true); }
public int getSkillScoreboardTime() { return config.getInt("Scoreboard.Types.Skill.Display_Time", 30); } public int getSkillScoreboardTime() { return config.getInt("Scoreboard.Types.Skill.Display_Time", 30); }
public boolean getSkillLevelUpBoard() { return config.getBoolean("Scoreboard.Types.Skill.LevelUp_Board", true); } public boolean getSkillLevelUpBoard() { return config.getBoolean("Scoreboard.Types.Skill.LevelUp_Board", true); }
@ -364,8 +357,8 @@ public class Config extends AutoUpdateConfigLoader {
public boolean getAbilitiesEnabled() { return config.getBoolean("Abilities.Enabled", true); } public boolean getAbilitiesEnabled() { return config.getBoolean("Abilities.Enabled", true); }
public boolean getAbilitiesOnlyActivateWhenSneaking() { return config.getBoolean("Abilities.Activation.Only_Activate_When_Sneaking", false); } public boolean getAbilitiesOnlyActivateWhenSneaking() { return config.getBoolean("Abilities.Activation.Only_Activate_When_Sneaking", false); }
public int getCooldown(AbilityType ability) { return config.getInt("Abilities.Cooldowns." + ability.getConfigString()); } public int getCooldown(AbilityType ability) { return config.getInt("Abilities.Cooldowns." + ability.toString()); }
public int getMaxLength(AbilityType ability) { return config.getInt("Abilities.Max_Seconds." + ability.getConfigString()); } public int getMaxLength(AbilityType ability) { return config.getInt("Abilities.Max_Seconds." + ability.toString()); }
/* Durability Settings */ /* Durability Settings */
public int getAbilityToolDamage() { return config.getInt("Abilities.Tools.Durability_Loss", 1); } public int getAbilityToolDamage() { return config.getInt("Abilities.Tools.Durability_Loss", 1); }

View File

@ -543,7 +543,7 @@ public class McMMOPlayer {
int powerLevel = 0; int powerLevel = 0;
for (SkillType type : SkillType.NON_CHILD_SKILLS) { for (SkillType type : SkillType.NON_CHILD_SKILLS) {
if (Permissions.skillEnabled(player, type)) { if (type.getPermissions(player)) {
powerLevel += profile.getSkillLevel(type); powerLevel += profile.getSkillLevel(type);
} }
} }
@ -566,7 +566,7 @@ public class McMMOPlayer {
Set<SkillType> parentSkills = FamilyTree.getParents(skillType); Set<SkillType> parentSkills = FamilyTree.getParents(skillType);
for (SkillType parentSkill : parentSkills) { for (SkillType parentSkill : parentSkills) {
if (Permissions.skillEnabled(player, parentSkill)) { if (parentSkill.getPermissions(player)) {
beginXpGain(parentSkill, xp / parentSkills.size()); beginXpGain(parentSkill, xp / parentSkills.size());
} }
} }
@ -601,7 +601,7 @@ public class McMMOPlayer {
* @param xp Experience amount to add * @param xp Experience amount to add
*/ */
public void applyXpGain(SkillType skillType, float xp) { public void applyXpGain(SkillType skillType, float xp) {
if (!Permissions.skillEnabled(player, skillType)) { if (!skillType.getPermissions(player)) {
return; return;
} }

View File

@ -17,7 +17,6 @@ import com.google.common.collect.ImmutableList;
public enum AbilityType { public enum AbilityType {
BERSERK( BERSERK(
"Unarmed.Skills.Berserk.Name",
"Unarmed.Skills.Berserk.On", "Unarmed.Skills.Berserk.On",
"Unarmed.Skills.Berserk.Off", "Unarmed.Skills.Berserk.Off",
"Unarmed.Skills.Berserk.Other.On", "Unarmed.Skills.Berserk.Other.On",
@ -25,7 +24,6 @@ public enum AbilityType {
"Unarmed.Skills.Berserk.Other.Off"), "Unarmed.Skills.Berserk.Other.Off"),
SUPER_BREAKER( SUPER_BREAKER(
"Mining.Skills.SuperBreaker.Name",
"Mining.Skills.SuperBreaker.On", "Mining.Skills.SuperBreaker.On",
"Mining.Skills.SuperBreaker.Off", "Mining.Skills.SuperBreaker.Off",
"Mining.Skills.SuperBreaker.Other.On", "Mining.Skills.SuperBreaker.Other.On",
@ -33,7 +31,6 @@ public enum AbilityType {
"Mining.Skills.SuperBreaker.Other.Off"), "Mining.Skills.SuperBreaker.Other.Off"),
GIGA_DRILL_BREAKER( GIGA_DRILL_BREAKER(
"Excavation.Skills.GigaDrillBreaker.Name",
"Excavation.Skills.GigaDrillBreaker.On", "Excavation.Skills.GigaDrillBreaker.On",
"Excavation.Skills.GigaDrillBreaker.Off", "Excavation.Skills.GigaDrillBreaker.Off",
"Excavation.Skills.GigaDrillBreaker.Other.On", "Excavation.Skills.GigaDrillBreaker.Other.On",
@ -41,7 +38,6 @@ public enum AbilityType {
"Excavation.Skills.GigaDrillBreaker.Other.Off"), "Excavation.Skills.GigaDrillBreaker.Other.Off"),
GREEN_TERRA( GREEN_TERRA(
"Herbalism.Skills.GTe.Name",
"Herbalism.Skills.GTe.On", "Herbalism.Skills.GTe.On",
"Herbalism.Skills.GTe.Off", "Herbalism.Skills.GTe.Off",
"Herbalism.Skills.GTe.Other.On", "Herbalism.Skills.GTe.Other.On",
@ -49,7 +45,6 @@ public enum AbilityType {
"Herbalism.Skills.GTe.Other.Off"), "Herbalism.Skills.GTe.Other.Off"),
SKULL_SPLITTER( SKULL_SPLITTER(
"Axes.Skills.SS.Name",
"Axes.Skills.SS.On", "Axes.Skills.SS.On",
"Axes.Skills.SS.Off", "Axes.Skills.SS.Off",
"Axes.Skills.SS.Other.On", "Axes.Skills.SS.Other.On",
@ -57,7 +52,6 @@ public enum AbilityType {
"Axes.Skills.SS.Other.Off"), "Axes.Skills.SS.Other.Off"),
TREE_FELLER( TREE_FELLER(
"Woodcutting.Skills.TreeFeller.Name",
"Woodcutting.Skills.TreeFeller.On", "Woodcutting.Skills.TreeFeller.On",
"Woodcutting.Skills.TreeFeller.Off", "Woodcutting.Skills.TreeFeller.Off",
"Woodcutting.Skills.TreeFeller.Other.On", "Woodcutting.Skills.TreeFeller.Other.On",
@ -65,7 +59,6 @@ public enum AbilityType {
"Woodcutting.Skills.TreeFeller.Other.Off"), "Woodcutting.Skills.TreeFeller.Other.Off"),
SERRATED_STRIKES( SERRATED_STRIKES(
"Swords.Skills.SS.Name",
"Swords.Skills.SS.On", "Swords.Skills.SS.On",
"Swords.Skills.SS.Off", "Swords.Skills.SS.Off",
"Swords.Skills.SS.Other.On", "Swords.Skills.SS.Other.On",
@ -76,7 +69,6 @@ public enum AbilityType {
* Has cooldown - but has to share a skill with Super Breaker, so needs special treatment * Has cooldown - but has to share a skill with Super Breaker, so needs special treatment
*/ */
BLAST_MINING( BLAST_MINING(
"Mining.Blast.Name",
null, null,
null, null,
"Mining.Blast.Other.On", "Mining.Blast.Other.On",
@ -86,26 +78,13 @@ public enum AbilityType {
/** /**
* No cooldown - always active * No cooldown - always active
*/ */
LEAF_BLOWER( LEAF_BLOWER,
null,
null,
null,
null,
null,
null),
/** /**
* Not a first-class Ability - part of Berserk * Not a first-class Ability - part of Berserk
*/ */
BLOCK_CRACKER( BLOCK_CRACKER;
null,
null,
null,
null,
null,
null);
private String abilityName;
private String abilityOn; private String abilityOn;
private String abilityOff; private String abilityOff;
private String abilityPlayer; private String abilityPlayer;
@ -115,31 +94,18 @@ public enum AbilityType {
/** /**
* Those abilities that have a cooldown saved to the database. * Those abilities that have a cooldown saved to the database.
*/ */
public static final List<AbilityType> NORMAL_ABILITIES; public static final List<AbilityType> NORMAL_ABILITIES = ImmutableList.of(BERSERK, BLAST_MINING, GIGA_DRILL_BREAKER, GREEN_TERRA, SERRATED_STRIKES, SKULL_SPLITTER, SUPER_BREAKER, TREE_FELLER);
/** /**
* Those abilities that do not have a cooldown saved to the database. * Those abilities that do not have a cooldown saved to the database.
*/ */
public static final List<AbilityType> NON_NORMAL_ABILITIES; public static final List<AbilityType> NON_NORMAL_ABILITIES = ImmutableList.of(BLOCK_CRACKER, LEAF_BLOWER);
static { private AbilityType() {
NORMAL_ABILITIES = ImmutableList.of( this(null, null, null, null, null);
BERSERK,
SUPER_BREAKER,
GIGA_DRILL_BREAKER,
GREEN_TERRA,
SKULL_SPLITTER,
TREE_FELLER,
SERRATED_STRIKES,
BLAST_MINING
);
NON_NORMAL_ABILITIES = ImmutableList.of(
LEAF_BLOWER,
BLOCK_CRACKER
);
} }
private AbilityType(String abilityName, String abilityOn, String abilityOff, String abilityPlayer, String abilityRefresh, String abilityPlayerOff) { private AbilityType(String abilityOn, String abilityOff, String abilityPlayer, String abilityRefresh, String abilityPlayerOff) {
this.abilityName = abilityName;
this.abilityOn = abilityOn; this.abilityOn = abilityOn;
this.abilityOff = abilityOff; this.abilityOff = abilityOff;
this.abilityPlayer = abilityPlayer; this.abilityPlayer = abilityPlayer;
@ -155,17 +121,6 @@ public enum AbilityType {
return Config.getInstance().getMaxLength(this); return Config.getInstance().getMaxLength(this);
} }
/**
* May return null
* @return ability name, or null if unavailable
*/
public String getAbilityName() {
if (this.abilityName == null) {
return null;
}
return LocaleLoader.getString(this.abilityName);
}
public String getAbilityOn() { public String getAbilityOn() {
return LocaleLoader.getString(this.abilityOn); return LocaleLoader.getString(this.abilityOn);
} }
@ -186,9 +141,8 @@ public enum AbilityType {
return LocaleLoader.getString(this.abilityRefresh); return LocaleLoader.getString(this.abilityRefresh);
} }
public String getConfigString() { public String getName() {
// If toString() changes, place old code here to not break config.yml return StringUtils.getPrettyAbilityString(this);
return this.toString();
} }
@Override @Override

View File

@ -5,6 +5,7 @@ import java.util.Collections;
import java.util.List; import java.util.List;
import org.bukkit.Color; import org.bukkit.Color;
import org.bukkit.entity.Player;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config; import com.gmail.nossr50.config.Config;
@ -24,6 +25,7 @@ import com.gmail.nossr50.skills.swords.SwordsManager;
import com.gmail.nossr50.skills.taming.TamingManager; import com.gmail.nossr50.skills.taming.TamingManager;
import com.gmail.nossr50.skills.unarmed.UnarmedManager; import com.gmail.nossr50.skills.unarmed.UnarmedManager;
import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager; import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.StringUtils; import com.gmail.nossr50.util.StringUtils;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
@ -70,7 +72,7 @@ public enum SkillType {
nonChildSkills.add(skill); nonChildSkills.add(skill);
} }
names.add(skill.getSkillName()); names.add(skill.getName());
} }
Collections.sort(names); Collections.sort(names);
@ -191,7 +193,11 @@ public enum SkillType {
return null; return null;
} }
public String getSkillName() { public String getName() {
return Config.getInstance().getLocale().equalsIgnoreCase("en_US") ? StringUtils.getCapitalized(this.toString()) : StringUtils.getCapitalized(LocaleLoader.getString(StringUtils.getCapitalized(this.toString()) + ".SkillName")); return Config.getInstance().getLocale().equalsIgnoreCase("en_US") ? StringUtils.getCapitalized(this.toString()) : StringUtils.getCapitalized(LocaleLoader.getString(StringUtils.getCapitalized(this.toString()) + ".SkillName"));
} }
public boolean getPermissions(Player player) {
return Permissions.skillEnabled(player, this);
}
} }

View File

@ -156,19 +156,19 @@ public class BlockListener implements Listener {
* We don't check the block store here because herbalism has too many unusual edge cases. * We don't check the block store here because herbalism has too many unusual edge cases.
* Instead, we check it inside the drops handler. * Instead, we check it inside the drops handler.
*/ */
if (Permissions.skillEnabled(player, SkillType.HERBALISM)) { if (SkillType.HERBALISM.getPermissions(player)) {
herbalismManager.herbalismBlockCheck(blockState); herbalismManager.herbalismBlockCheck(blockState);
} }
} }
/* MINING */ /* MINING */
else if (BlockUtils.affectedBySuperBreaker(blockState) && ItemUtils.isPickaxe(heldItem) && Permissions.skillEnabled(player, SkillType.MINING) && !mcMMO.getPlaceStore().isTrue(blockState)) { else if (BlockUtils.affectedBySuperBreaker(blockState) && ItemUtils.isPickaxe(heldItem) && SkillType.MINING.getPermissions(player) && !mcMMO.getPlaceStore().isTrue(blockState)) {
MiningManager miningManager = mcMMOPlayer.getMiningManager(); MiningManager miningManager = mcMMOPlayer.getMiningManager();
miningManager.miningBlockCheck(blockState); miningManager.miningBlockCheck(blockState);
} }
/* WOOD CUTTING */ /* WOOD CUTTING */
else if (BlockUtils.isLog(blockState) && Permissions.skillEnabled(player, SkillType.WOODCUTTING) && !mcMMO.getPlaceStore().isTrue(blockState)) { else if (BlockUtils.isLog(blockState) && SkillType.WOODCUTTING.getPermissions(player) && !mcMMO.getPlaceStore().isTrue(blockState)) {
WoodcuttingManager woodcuttingManager = mcMMOPlayer.getWoodcuttingManager(); WoodcuttingManager woodcuttingManager = mcMMOPlayer.getWoodcuttingManager();
if (woodcuttingManager.canUseTreeFeller(heldItem)) { if (woodcuttingManager.canUseTreeFeller(heldItem)) {
@ -180,7 +180,7 @@ public class BlockListener implements Listener {
} }
/* EXCAVATION */ /* EXCAVATION */
else if (BlockUtils.affectedByGigaDrillBreaker(blockState) && ItemUtils.isShovel(heldItem) && Permissions.skillEnabled(player, SkillType.EXCAVATION) && !mcMMO.getPlaceStore().isTrue(blockState)) { else if (BlockUtils.affectedByGigaDrillBreaker(blockState) && ItemUtils.isShovel(heldItem) && SkillType.EXCAVATION.getPermissions(player) && !mcMMO.getPlaceStore().isTrue(blockState)) {
ExcavationManager excavationManager = mcMMOPlayer.getExcavationManager(); ExcavationManager excavationManager = mcMMOPlayer.getExcavationManager();
excavationManager.excavationBlockCheck(blockState); excavationManager.excavationBlockCheck(blockState);

View File

@ -91,7 +91,7 @@ public class InventoryListener implements Listener {
Player player = Misc.getPlayerFromFurnace(furnaceBlock); Player player = Misc.getPlayerFromFurnace(furnaceBlock);
if (Misc.isNPCEntity(player) || !Permissions.skillEnabled(player, SkillType.SMELTING)) { if (Misc.isNPCEntity(player) || !SkillType.SMELTING.getPermissions(player)) {
return; return;
} }

View File

@ -204,7 +204,7 @@ public class PlayerListener implements Listener {
public void onPlayerFishHighest(PlayerFishEvent event) { public void onPlayerFishHighest(PlayerFishEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
if (Misc.isNPCEntity(player) || !Permissions.skillEnabled(player, SkillType.FISHING)) { if (Misc.isNPCEntity(player) || !SkillType.FISHING.getPermissions(player)) {
return; return;
} }
@ -249,7 +249,7 @@ public class PlayerListener implements Listener {
public void onPlayerFishMonitor(PlayerFishEvent event) { public void onPlayerFishMonitor(PlayerFishEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
if (Misc.isNPCEntity(player) || !Permissions.skillEnabled(player, SkillType.FISHING)) { if (Misc.isNPCEntity(player) || !SkillType.FISHING.getPermissions(player)) {
return; return;
} }
@ -421,7 +421,7 @@ public class PlayerListener implements Listener {
if (!Config.getInstance().getAbilitiesOnlyActivateWhenSneaking() || player.isSneaking()) { if (!Config.getInstance().getAbilitiesOnlyActivateWhenSneaking() || player.isSneaking()) {
/* REPAIR CHECKS */ /* REPAIR CHECKS */
if (type == Repair.repairAnvilMaterial && Permissions.skillEnabled(player, SkillType.REPAIR) && mcMMO.getRepairableManager().isRepairable(heldItem)) { if (type == Repair.repairAnvilMaterial && SkillType.REPAIR.getPermissions(player) && mcMMO.getRepairableManager().isRepairable(heldItem)) {
RepairManager repairManager = mcMMOPlayer.getRepairManager(); RepairManager repairManager = mcMMOPlayer.getRepairManager();
event.setCancelled(true); event.setCancelled(true);
@ -460,7 +460,7 @@ public class PlayerListener implements Listener {
if ((Config.getInstance().getAbilitiesOnlyActivateWhenSneaking() && player.isSneaking()) || !Config.getInstance().getAbilitiesOnlyActivateWhenSneaking()) { if ((Config.getInstance().getAbilitiesOnlyActivateWhenSneaking() && player.isSneaking()) || !Config.getInstance().getAbilitiesOnlyActivateWhenSneaking()) {
/* REPAIR CHECKS */ /* REPAIR CHECKS */
if (type == Repair.repairAnvilMaterial && Permissions.skillEnabled(player, SkillType.REPAIR) && mcMMO.getRepairableManager().isRepairable(heldItem)) { if (type == Repair.repairAnvilMaterial && SkillType.REPAIR.getPermissions(player) && mcMMO.getRepairableManager().isRepairable(heldItem)) {
RepairManager repairManager = mcMMOPlayer.getRepairManager(); RepairManager repairManager = mcMMOPlayer.getRepairManager();
// Cancel repairing an enchanted item // Cancel repairing an enchanted item
@ -658,7 +658,7 @@ public class PlayerListener implements Listener {
// Do these ACTUALLY have to be lower case to work properly? // Do these ACTUALLY have to be lower case to work properly?
for (SkillType skill : SkillType.values()) { for (SkillType skill : SkillType.values()) {
String skillName = skill.toString().toLowerCase(); String skillName = skill.toString().toLowerCase();
String localizedName = skill.getSkillName().toLowerCase(); String localizedName = skill.getName().toLowerCase();
if (lowerCaseCommand.equals(localizedName)) { if (lowerCaseCommand.equals(localizedName)) {
event.setMessage(message.replace(command, skillName)); event.setMessage(message.replace(command, skillName));

View File

@ -12,28 +12,28 @@ import com.gmail.nossr50.events.skills.abilities.McMMOPlayerAbilityActivateEvent
import com.gmail.nossr50.util.scoreboards.ScoreboardManager; import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
public class ScoreboardsListener implements Listener { public class ScoreboardsListener implements Listener {
@EventHandler @EventHandler(priority = EventPriority.MONITOR)
public void onPlayerJoin(PlayerJoinEvent e) { public void onPlayerJoin(PlayerJoinEvent event) {
ScoreboardManager.setupPlayer(e.getPlayer()); ScoreboardManager.setupPlayer(event.getPlayer());
}
@EventHandler
public void onPlayerQuit(PlayerQuitEvent e) {
ScoreboardManager.teardownPlayer(e.getPlayer());
} }
@EventHandler(priority = EventPriority.MONITOR) @EventHandler(priority = EventPriority.MONITOR)
public void onPlayerLevelUp(McMMOPlayerLevelUpEvent e) { public void onPlayerQuit(PlayerQuitEvent event) {
ScoreboardManager.handleLevelUp(e.getPlayer(), e.getSkill()); ScoreboardManager.teardownPlayer(event.getPlayer());
} }
@EventHandler(priority = EventPriority.MONITOR) @EventHandler(priority = EventPriority.MONITOR)
public void onPlayerXp(McMMOPlayerXpGainEvent e) { public void onPlayerLevelUp(McMMOPlayerLevelUpEvent event) {
ScoreboardManager.handleXp(e.getPlayer(), e.getSkill()); ScoreboardManager.handleLevelUp(event.getPlayer(), event.getSkill());
} }
@EventHandler(priority = EventPriority.MONITOR) @EventHandler(priority = EventPriority.MONITOR)
public void onAbility(McMMOPlayerAbilityActivateEvent e) { public void onPlayerXp(McMMOPlayerXpGainEvent event) {
ScoreboardManager.cooldownUpdate(e.getPlayer(), e.getSkill()); ScoreboardManager.handleXp(event.getPlayer(), event.getSkill());
}
@EventHandler(priority = EventPriority.MONITOR)
public void onAbility(McMMOPlayerAbilityActivateEvent event) {
ScoreboardManager.cooldownUpdate(event.getPlayer(), event.getSkill());
} }
} }

View File

@ -18,7 +18,11 @@ public class McrankCommandAsyncTask extends BukkitRunnable {
public McrankCommandAsyncTask(String playerName, CommandSender sender, boolean useBoard, boolean useChat) { public McrankCommandAsyncTask(String playerName, CommandSender sender, boolean useBoard, boolean useChat) {
Validate.isTrue(useBoard || useChat, "Attempted to start a rank retrieval with both board and chat off"); Validate.isTrue(useBoard || useChat, "Attempted to start a rank retrieval with both board and chat off");
Validate.notNull(sender, "Attempted to start a rank retrieval with no recipient"); Validate.notNull(sender, "Attempted to start a rank retrieval with no recipient");
if (useBoard) Validate.isTrue(sender instanceof Player, "Attempted to start a rank retrieval displaying scoreboard to a non-player");
if (useBoard) {
Validate.isTrue(sender instanceof Player, "Attempted to start a rank retrieval displaying scoreboard to a non-player");
}
this.playerName = playerName; this.playerName = playerName;
this.sender = sender; this.sender = sender;
this.useBoard = useBoard; this.useBoard = useBoard;

View File

@ -9,7 +9,6 @@ import org.bukkit.scheduler.BukkitRunnable;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager; import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
/** /**
@ -21,7 +20,7 @@ public class McrankCommandDisplayTask extends BukkitRunnable {
private final String playerName; private final String playerName;
private final boolean useBoard, useChat; private final boolean useBoard, useChat;
/*package-private*/ McrankCommandDisplayTask(Map<SkillType, Integer> skills, CommandSender sender, String playerName, boolean useBoard, boolean useChat) { McrankCommandDisplayTask(Map<SkillType, Integer> skills, CommandSender sender, String playerName, boolean useBoard, boolean useChat) {
this.skills = skills; this.skills = skills;
this.sender = sender; this.sender = sender;
this.playerName = playerName; this.playerName = playerName;
@ -34,6 +33,7 @@ public class McrankCommandDisplayTask extends BukkitRunnable {
if (useBoard) { if (useBoard) {
displayBoard(); displayBoard();
} }
if (useChat){ if (useChat){
displayChat(); displayChat();
} }
@ -47,12 +47,12 @@ public class McrankCommandDisplayTask extends BukkitRunnable {
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Player", playerName)); sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Player", playerName));
for (SkillType skill : SkillType.NON_CHILD_SKILLS) { for (SkillType skill : SkillType.NON_CHILD_SKILLS) {
if (player != null && !Permissions.skillEnabled(player, skill)) { if (!skill.getPermissions(player)) {
continue; continue;
} }
rank = skills.get(skill); rank = skills.get(skill);
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", skill.getSkillName(), (rank == null ? LocaleLoader.getString("Commands.mcrank.Unranked") : rank))); sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", skill.getName(), (rank == null ? LocaleLoader.getString("Commands.mcrank.Unranked") : rank)));
} }
rank = skills.get(null); rank = skills.get(null);
@ -60,7 +60,7 @@ public class McrankCommandDisplayTask extends BukkitRunnable {
} }
public void displayBoard() { public void displayBoard() {
if (playerName == null || sender.getName().equalsIgnoreCase(playerName)) { if (sender.getName().equalsIgnoreCase(playerName)) {
ScoreboardManager.showPlayerRankScoreboard((Player) sender, skills); ScoreboardManager.showPlayerRankScoreboard((Player) sender, skills);
} }
else { else {

View File

@ -20,7 +20,11 @@ public class MctopCommandAsyncTask extends BukkitRunnable {
public MctopCommandAsyncTask(int page, SkillType skill, CommandSender sender, boolean useBoard, boolean useChat) { public MctopCommandAsyncTask(int page, SkillType skill, CommandSender sender, boolean useBoard, boolean useChat) {
Validate.isTrue(useBoard || useChat, "Attempted to start a rank retrieval with both board and chat off"); Validate.isTrue(useBoard || useChat, "Attempted to start a rank retrieval with both board and chat off");
Validate.notNull(sender, "Attempted to start a rank retrieval with no recipient"); Validate.notNull(sender, "Attempted to start a rank retrieval with no recipient");
if (useBoard) Validate.isTrue(sender instanceof Player, "Attempted to start a rank retrieval displaying scoreboard to a non-player");
if (useBoard) {
Validate.isTrue(sender instanceof Player, "Attempted to start a rank retrieval displaying scoreboard to a non-player");
}
this.page = page; this.page = page;
this.skill = skill; this.skill = skill;
this.sender = sender; this.sender = sender;

View File

@ -22,7 +22,7 @@ public class MctopCommandDisplayTask extends BukkitRunnable {
private final int page; private final int page;
private final boolean useBoard, useChat; private final boolean useBoard, useChat;
/*package-private*/ MctopCommandDisplayTask(List<PlayerStat> userStats, int page, SkillType skill, CommandSender sender, boolean useBoard, boolean useChat) { MctopCommandDisplayTask(List<PlayerStat> userStats, int page, SkillType skill, CommandSender sender, boolean useBoard, boolean useChat) {
this.userStats = userStats; this.userStats = userStats;
this.page = page; this.page = page;
this.skill = skill; this.skill = skill;
@ -36,9 +36,11 @@ public class MctopCommandDisplayTask extends BukkitRunnable {
if (useBoard) { if (useBoard) {
displayBoard(); displayBoard();
} }
if (useChat) { if (useChat) {
displayChat(); displayChat();
} }
sender.sendMessage(LocaleLoader.getString("Commands.mctop.Tip")); sender.sendMessage(LocaleLoader.getString("Commands.mctop.Tip"));
} }
@ -47,7 +49,7 @@ public class MctopCommandDisplayTask extends BukkitRunnable {
sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Leaderboard")); sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Leaderboard"));
} }
else { else {
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Leaderboard", skill.getSkillName())); sender.sendMessage(LocaleLoader.getString("Commands.Skill.Leaderboard", skill.getName()));
} }
int place = (page * 10) - 9; int place = (page * 10) - 9;

View File

@ -3,6 +3,8 @@ package com.gmail.nossr50.util;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import com.gmail.nossr50.datatypes.skills.AbilityType;
public class StringUtils { public class StringUtils {
/** /**
* Gets a capitalized version of the target string. * Gets a capitalized version of the target string.
@ -22,6 +24,10 @@ public class StringUtils {
return createPrettyEnumString(entity.toString()); return createPrettyEnumString(entity.toString());
} }
public static String getPrettyAbilityString(AbilityType ability) {
return createPrettyEnumString(ability.toString());
}
private static String createPrettyEnumString(String baseString) { private static String createPrettyEnumString(String baseString) {
String[] substrings = baseString.split("_"); String[] substrings = baseString.split("_");
String prettyString = ""; String prettyString = "";

View File

@ -60,7 +60,7 @@ public final class CommandRegistrationManager {
private static void registerSkillCommands() { private static void registerSkillCommands() {
for (SkillType skill : SkillType.values()) { for (SkillType skill : SkillType.values()) {
String commandName = skill.toString().toLowerCase(); String commandName = skill.toString().toLowerCase();
String localizedName = skill.getSkillName().toLowerCase(); String localizedName = skill.getName().toLowerCase();
PluginCommand command; PluginCommand command;
@ -385,7 +385,8 @@ public final class CommandRegistrationManager {
command.setDescription("Change the current mcMMO scoreboard being displayed"); //TODO: Localize command.setDescription("Change the current mcMMO scoreboard being displayed"); //TODO: Localize
command.setPermission("mcmmo.commands.mcscoreboard"); command.setPermission("mcmmo.commands.mcscoreboard");
command.setPermissionMessage(permissionsMessage); command.setPermissionMessage(permissionsMessage);
command.setUsage(LocaleLoader.getString("Commands.Usage.1", "mcscoreboard", "<CLEAR | KEEP | TIME>")); command.setUsage(LocaleLoader.getString("Commands.Usage.1", "mcscoreboard", "<CLEAR | KEEP>"));
command.setUsage(command.getUsage() + "\n" + LocaleLoader.getString("Commands.Usage.2", "mcscoreboard", "time", "<seconds>"));
command.setExecutor(new McscoreboardCommand()); command.setExecutor(new McscoreboardCommand());
} }

View File

@ -3,7 +3,6 @@ package com.gmail.nossr50.util.commands;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -14,7 +13,6 @@ import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.StringUtils; import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.SkillUtils; import com.gmail.nossr50.util.skills.SkillUtils;
@ -98,9 +96,10 @@ public final class CommandUtils {
return true; return true;
} }
OfflinePlayer player = Bukkit.getOfflinePlayer(playerName); PlayerProfile profile = new PlayerProfile(playerName, false);
if (!player.hasPlayedBefore()) {
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist")); if (unloadedProfile(sender, profile)) {
return false;
} }
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist")); sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
@ -208,7 +207,7 @@ public final class CommandUtils {
displayData.add(header); displayData.add(header);
for (SkillType skill : skillGroup) { for (SkillType skill : skillGroup) {
if (Permissions.skillEnabled(inspect, skill)) { if (skill.getPermissions(inspect)) {
displayData.add(displaySkill(profile, skill)); displayData.add(displaySkill(profile, skill));
} }
} }

View File

@ -1,14 +1,11 @@
package com.gmail.nossr50.util.scoreboards; package com.gmail.nossr50.util.scoreboards;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Random;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -48,88 +45,82 @@ public class ScoreboardManager {
static final OfflinePlayer LABEL_ABILITY_COOLDOWN = getOfflinePlayer(LocaleLoader.getString("Scoreboard.Misc.Cooldown")); static final OfflinePlayer LABEL_ABILITY_COOLDOWN = getOfflinePlayer(LocaleLoader.getString("Scoreboard.Misc.Cooldown"));
static final OfflinePlayer LABEL_OVERALL = getOfflinePlayer(LocaleLoader.getString("Scoreboard.Misc.Overall")); static final OfflinePlayer LABEL_OVERALL = getOfflinePlayer(LocaleLoader.getString("Scoreboard.Misc.Overall"));
static final Map<SkillType, OfflinePlayer> skillLabels; static final Map<SkillType, OfflinePlayer> skillLabels;
static final Map<AbilityType, OfflinePlayer> abilityLabelsColored; static final Map<AbilityType, OfflinePlayer> abilityLabelsColored;
static final Map<AbilityType, OfflinePlayer> abilityLabelsSkill; static final Map<AbilityType, OfflinePlayer> abilityLabelsSkill;
static { static {
ImmutableMap.Builder<SkillType, OfflinePlayer> b = ImmutableMap.builder(); ImmutableMap.Builder<SkillType, OfflinePlayer> skillLabelBuilder = ImmutableMap.builder();
ImmutableMap.Builder<AbilityType, OfflinePlayer> c = ImmutableMap.builder(); ImmutableMap.Builder<AbilityType, OfflinePlayer> abilityLabelBuilder = ImmutableMap.builder();
ImmutableMap.Builder<AbilityType, OfflinePlayer> d = ImmutableMap.builder(); ImmutableMap.Builder<AbilityType, OfflinePlayer> abilityLabelSkillBuilder = ImmutableMap.builder();
if (Config.getInstance().getScoreboardRainbows()) { if (Config.getInstance().getScoreboardRainbows()) {
Random shuffler = new Random(Bukkit.getWorlds().get(0).getSeed()); List<ChatColor> colors = new ArrayList<ChatColor>();
List<ChatColor> colors = Arrays.asList(
ChatColor.WHITE, for (ChatColor color : ChatColor.values()) {
ChatColor.YELLOW, if (color.isColor()) {
ChatColor.LIGHT_PURPLE, colors.add(color);
ChatColor.RED, }
ChatColor.AQUA, }
ChatColor.GREEN,
ChatColor.DARK_GRAY, Collections.shuffle(colors, Misc.getRandom());
ChatColor.BLUE,
ChatColor.DARK_PURPLE,
ChatColor.DARK_RED,
ChatColor.DARK_AQUA,
ChatColor.DARK_GREEN,
ChatColor.DARK_BLUE
);
Collections.shuffle(colors, shuffler);
int i = 0; int i = 0;
for (SkillType type : SkillType.values()) { for (SkillType type : SkillType.values()) {
// Include child skills // Include child skills
b.put(type, getOfflinePlayer(colors.get(i) + type.getSkillName())); skillLabelBuilder.put(type, getOfflinePlayer(colors.get(i) + type.getName()));
if (type.getAbility() != null) { if (type.getAbility() != null) {
// the toString is the properly formatted verison for abilities abilityLabelBuilder.put(type.getAbility(), getOfflinePlayer(colors.get(i) + type.getAbility().getName()));
c.put(type.getAbility(), getOfflinePlayer(colors.get(i) + type.getAbility().getAbilityName()));
if (type == SkillType.MINING) { if (type == SkillType.MINING) {
c.put(AbilityType.BLAST_MINING, getOfflinePlayer(colors.get(i) + AbilityType.BLAST_MINING.getAbilityName())); abilityLabelBuilder.put(AbilityType.BLAST_MINING, getOfflinePlayer(colors.get(i) + AbilityType.BLAST_MINING.getName()));
} }
} }
if (++i == colors.size()) i = 0; if (++i == colors.size()) i = 0;
} }
} }
else { else {
for (SkillType type : SkillType.values()) { for (SkillType type : SkillType.values()) {
// Include child skills // Include child skills
b.put(type, getOfflinePlayer(ChatColor.GREEN + type.getSkillName())); skillLabelBuilder.put(type, getOfflinePlayer(ChatColor.GREEN + type.getName()));
if (type.getAbility() != null) { if (type.getAbility() != null) {
// the toString is the properly formatted verison for abilities abilityLabelBuilder.put(type.getAbility(), getOfflinePlayerDots(ChatColor.AQUA + type.getAbility().getName()));
c.put(type.getAbility(), getOfflinePlayerDots(ChatColor.AQUA + type.getAbility().getAbilityName()));
if (type == SkillType.MINING) { if (type == SkillType.MINING) {
c.put(AbilityType.BLAST_MINING, getOfflinePlayerDots(ChatColor.AQUA + AbilityType.BLAST_MINING.getAbilityName())); abilityLabelBuilder.put(AbilityType.BLAST_MINING, getOfflinePlayerDots(ChatColor.AQUA + AbilityType.BLAST_MINING.getName()));
} }
} }
} }
} }
for (AbilityType type : AbilityType.NORMAL_ABILITIES) { for (AbilityType type : AbilityType.NORMAL_ABILITIES) {
if (type == AbilityType.BLAST_MINING) { abilityLabelSkillBuilder.put(type, getOfflinePlayerDots((type == AbilityType.BLAST_MINING ? ChatColor.BLUE : ChatColor.AQUA) + type.getName()));
// Special-case: get a different color
d.put(AbilityType.BLAST_MINING, getOfflinePlayerDots(ChatColor.BLUE + AbilityType.BLAST_MINING.getAbilityName()));
}
else {
d.put(type, getOfflinePlayerDots(ChatColor.AQUA + type.getAbilityName()));
}
} }
skillLabels = b.build(); skillLabels = skillLabelBuilder.build();
abilityLabelsColored = c.build(); abilityLabelsColored = abilityLabelBuilder.build();
abilityLabelsSkill = d.build(); abilityLabelsSkill = abilityLabelSkillBuilder.build();
} }
private static List<String> dirtyPowerLevels = new ArrayList<String>(); private static List<String> dirtyPowerLevels = new ArrayList<String>();
private static OfflinePlayer getOfflinePlayer(String name) { private static OfflinePlayer getOfflinePlayer(String name) {
if (name.length() > 16) { return getOfflinePlayer(name, false);
name = name.substring(0, 16);
}
return Bukkit.getOfflinePlayer(name);
} }
private static OfflinePlayer getOfflinePlayerDots(String name) { private static OfflinePlayer getOfflinePlayerDots(String name) {
return getOfflinePlayer(name, true);
}
private static OfflinePlayer getOfflinePlayer(String name, boolean useDots) {
if (name.length() > 16) { if (name.length() > 16) {
name = name.substring(0, 16 - 2) + ".."; name = useDots ? name.substring(0, 14) + ".." : name.substring(0, 16);
} }
return Bukkit.getOfflinePlayer(name);
return mcMMO.p.getServer().getOfflinePlayer(name);
} }
public enum SidebarType { public enum SidebarType {
@ -144,14 +135,15 @@ public class ScoreboardManager {
// **** Listener call-ins **** // // **** Listener call-ins **** //
// Called by PlayerJoinEvent listener // Called by PlayerJoinEvent listener
public static void setupPlayer(Player p) { public static void setupPlayer(Player player) {
PLAYER_SCOREBOARDS.put(p.getName(), ScoreboardWrapper.create(p)); PLAYER_SCOREBOARDS.put(player.getName(), ScoreboardWrapper.create(player));
dirtyPowerLevels.add(p.getName()); dirtyPowerLevels.add(player.getName());
} }
// Called by PlayerQuitEvent listener // Called by PlayerQuitEvent listener
public static void teardownPlayer(Player p) { public static void teardownPlayer(Player player) {
ScoreboardWrapper wrapper = PLAYER_SCOREBOARDS.remove(p.getName()); ScoreboardWrapper wrapper = PLAYER_SCOREBOARDS.remove(player.getName());
if (wrapper.revertTask != null) { if (wrapper.revertTask != null) {
wrapper.revertTask.cancel(); wrapper.revertTask.cancel();
} }
@ -159,14 +151,15 @@ public class ScoreboardManager {
// Called in onDisable() // Called in onDisable()
public static void teardownAll() { public static void teardownAll() {
for (Player p : Bukkit.getOnlinePlayers()) { for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
teardownPlayer(p); teardownPlayer(player);
} }
} }
// Called by ScoreboardWrapper when its Player logs off and an action tries to be performed // Called by ScoreboardWrapper when its Player logs off and an action tries to be performed
public static void cleanup(ScoreboardWrapper wrapper) { public static void cleanup(ScoreboardWrapper wrapper) {
PLAYER_SCOREBOARDS.remove(wrapper.playerName); PLAYER_SCOREBOARDS.remove(wrapper.playerName);
if (wrapper.revertTask != null) { if (wrapper.revertTask != null) {
wrapper.revertTask.cancel(); wrapper.revertTask.cancel();
} }
@ -175,16 +168,18 @@ public class ScoreboardManager {
// Called by internal level-up event listener // Called by internal level-up event listener
public static void handleLevelUp(Player player, SkillType skill) { public static void handleLevelUp(Player player, SkillType skill) {
// Selfboards // Selfboards
ScoreboardWrapper wrapper = PLAYER_SCOREBOARDS.get(player.getName()); ScoreboardWrapper selfboardWrapper = PLAYER_SCOREBOARDS.get(player.getName());
if ((wrapper.isSkillScoreboard() && wrapper.targetSkill == skill) || (wrapper.isStatsScoreboard()) && wrapper.isBoardShown()) {
wrapper.doSidebarUpdateSoon(); if ((selfboardWrapper.isSkillScoreboard() && selfboardWrapper.targetSkill == skill) || (selfboardWrapper.isStatsScoreboard()) && selfboardWrapper.isBoardShown()) {
selfboardWrapper.doSidebarUpdateSoon();
} }
// Otherboards // Otherboards
String playerName = player.getName(); String playerName = player.getName();
for (ScoreboardWrapper w : PLAYER_SCOREBOARDS.values()) {
if (w.isStatsScoreboard() && playerName.equals(w.targetPlayer) && wrapper.isBoardShown()) { for (ScoreboardWrapper wrapper : PLAYER_SCOREBOARDS.values()) {
wrapper.doSidebarUpdateSoon(); if (wrapper.isStatsScoreboard() && playerName.equals(wrapper.targetPlayer) && selfboardWrapper.isBoardShown()) {
selfboardWrapper.doSidebarUpdateSoon();
} }
} }
@ -201,6 +196,7 @@ public class ScoreboardManager {
public static void handleXp(Player player, SkillType skill) { public static void handleXp(Player player, SkillType skill) {
// Selfboards // Selfboards
ScoreboardWrapper wrapper = PLAYER_SCOREBOARDS.get(player.getName()); ScoreboardWrapper wrapper = PLAYER_SCOREBOARDS.get(player.getName());
if (wrapper.isSkillScoreboard() && wrapper.targetSkill == skill && wrapper.isBoardShown()) { if (wrapper.isSkillScoreboard() && wrapper.targetSkill == skill && wrapper.isBoardShown()) {
wrapper.doSidebarUpdateSoon(); wrapper.doSidebarUpdateSoon();
} }
@ -210,6 +206,7 @@ public class ScoreboardManager {
public static void cooldownUpdate(Player player, SkillType skill) { public static void cooldownUpdate(Player player, SkillType skill) {
// Selfboards // Selfboards
ScoreboardWrapper wrapper = PLAYER_SCOREBOARDS.get(player.getName()); ScoreboardWrapper wrapper = PLAYER_SCOREBOARDS.get(player.getName());
if ((wrapper.isCooldownScoreboard() || wrapper.isSkillScoreboard() && wrapper.targetSkill == skill) && wrapper.isBoardShown()) { if ((wrapper.isCooldownScoreboard() || wrapper.isSkillScoreboard() && wrapper.targetSkill == skill) && wrapper.isBoardShown()) {
wrapper.doSidebarUpdateSoon(); wrapper.doSidebarUpdateSoon();
} }
@ -267,8 +264,8 @@ public class ScoreboardManager {
changeScoreboard(wrapper, Config.getInstance().getCooldownScoreboardTime()); changeScoreboard(wrapper, Config.getInstance().getCooldownScoreboardTime());
} }
public static void showPlayerRankScoreboard(Player bukkitPlayer, Map<SkillType, Integer> rank) { public static void showPlayerRankScoreboard(Player player, Map<SkillType, Integer> rank) {
ScoreboardWrapper wrapper = PLAYER_SCOREBOARDS.get(bukkitPlayer.getName()); ScoreboardWrapper wrapper = PLAYER_SCOREBOARDS.get(player.getName());
wrapper.setOldScoreboard(); wrapper.setOldScoreboard();
wrapper.setTypeSelfRank(); wrapper.setTypeSelfRank();
@ -277,8 +274,8 @@ public class ScoreboardManager {
changeScoreboard(wrapper, Config.getInstance().getRankScoreboardTime()); changeScoreboard(wrapper, Config.getInstance().getRankScoreboardTime());
} }
public static void showPlayerRankScoreboardOthers(Player bukkitPlayer, String targetName, Map<SkillType, Integer> rank) { public static void showPlayerRankScoreboardOthers(Player player, String targetName, Map<SkillType, Integer> rank) {
ScoreboardWrapper wrapper = PLAYER_SCOREBOARDS.get(bukkitPlayer.getName()); ScoreboardWrapper wrapper = PLAYER_SCOREBOARDS.get(player.getName());
wrapper.setOldScoreboard(); wrapper.setOldScoreboard();
wrapper.setTypeInspectRank(targetName); wrapper.setTypeInspectRank(targetName);
@ -314,24 +311,28 @@ public class ScoreboardManager {
*/ */
public static boolean powerLevelHeartbeat() { public static boolean powerLevelHeartbeat() {
Objective mainObjective = getPowerLevelObjective(); Objective mainObjective = getPowerLevelObjective();
if (mainObjective == null) { if (mainObjective == null) {
return false; // indicates return false; // indicates
} }
if (!dirtyPowerLevels.isEmpty()) if (!dirtyPowerLevels.isEmpty()) {
mcMMO.p.getLogger().info(dirtyPowerLevels.toString()); mcMMO.p.getLogger().info(dirtyPowerLevels.toString());
}
for (String playerName : dirtyPowerLevels) { for (String playerName : dirtyPowerLevels) {
McMMOPlayer mcpl = UserManager.getPlayer(playerName); McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName);
Player player = mcpl.getPlayer(); Player player = mcMMOPlayer.getPlayer();
int power = mcpl.getPowerLevel(); int power = mcMMOPlayer.getPowerLevel();
mainObjective.getScore(player).setScore(power); mainObjective.getScore(player).setScore(power);
for (ScoreboardWrapper wrapper : PLAYER_SCOREBOARDS.values()) { for (ScoreboardWrapper wrapper : PLAYER_SCOREBOARDS.values()) {
wrapper.updatePowerLevel(player, power); wrapper.updatePowerLevel(player, power);
} }
} }
dirtyPowerLevels.clear();
dirtyPowerLevels.clear();
return true; return true;
} }
@ -345,21 +346,25 @@ public class ScoreboardManager {
*/ */
public static Objective getPowerLevelObjective() { public static Objective getPowerLevelObjective() {
if (!Config.getInstance().getPowerLevelTagsEnabled()) { if (!Config.getInstance().getPowerLevelTagsEnabled()) {
Objective obj = Bukkit.getScoreboardManager().getMainScoreboard().getObjective(POWER_OBJECTIVE); Objective objective = mcMMO.p.getServer().getScoreboardManager().getMainScoreboard().getObjective(POWER_OBJECTIVE);
if (obj != null) {
obj.unregister(); if (objective != null) {
objective.unregister();
mcMMO.p.debug("Removed leftover scoreboard objects from Power Level Tags."); mcMMO.p.debug("Removed leftover scoreboard objects from Power Level Tags.");
} }
return null; return null;
} }
Objective powerObj = Bukkit.getScoreboardManager().getMainScoreboard().getObjective(POWER_OBJECTIVE); Objective powerObjective = mcMMO.p.getServer().getScoreboardManager().getMainScoreboard().getObjective(POWER_OBJECTIVE);
if (powerObj == null) {
powerObj = Bukkit.getScoreboardManager().getMainScoreboard().registerNewObjective(POWER_OBJECTIVE, "dummy"); if (powerObjective == null) {
powerObj.setDisplayName(TAG_POWER_LEVEL); powerObjective = mcMMO.p.getServer().getScoreboardManager().getMainScoreboard().registerNewObjective(POWER_OBJECTIVE, "dummy");
powerObj.setDisplaySlot(DisplaySlot.BELOW_NAME); powerObjective.setDisplayName(TAG_POWER_LEVEL);
powerObjective.setDisplaySlot(DisplaySlot.BELOW_NAME);
} }
return powerObj;
return powerObjective;
} }
private static void changeScoreboard(ScoreboardWrapper wrapper, int displayTime) { private static void changeScoreboard(ScoreboardWrapper wrapper, int displayTime) {

View File

@ -2,10 +2,8 @@ package com.gmail.nossr50.util.scoreboards;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set;
import org.apache.commons.lang.Validate; import org.apache.commons.lang.Validate;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
@ -25,7 +23,6 @@ import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.child.FamilyTree; import com.gmail.nossr50.skills.child.FamilyTree;
import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager.SidebarType; import com.gmail.nossr50.util.scoreboards.ScoreboardManager.SidebarType;
import com.gmail.nossr50.util.skills.SkillUtils; import com.gmail.nossr50.util.skills.SkillUtils;
@ -34,14 +31,14 @@ public class ScoreboardWrapper {
// Initialization variables // Initialization variables
public final String playerName; public final String playerName;
private final Scoreboard board; private final Scoreboard scoreboard;
private boolean tippedKeep = false; private boolean tippedKeep = false;
private boolean tippedClear = false; private boolean tippedClear = false;
// Internal usage variables (should exist) // Internal usage variables (should exist)
private SidebarType sidebarType; private SidebarType sidebarType;
private Objective sidebarObj; private Objective sidebarObjective;
private Objective powerObj; private Objective powerObjective;
// Parameter variables (May be null / invalid) // Parameter variables (May be null / invalid)
private Scoreboard oldBoard = null; private Scoreboard oldBoard = null;
@ -50,30 +47,32 @@ public class ScoreboardWrapper {
private PlayerProfile targetProfile = null; private PlayerProfile targetProfile = null;
public int leaderboardPage = -1; public int leaderboardPage = -1;
private ScoreboardWrapper(String playerName, Scoreboard s) { private ScoreboardWrapper(String playerName, Scoreboard scoreboard) {
this.playerName = playerName; this.playerName = playerName;
board = s; this.scoreboard = scoreboard;
sidebarType = SidebarType.NONE; sidebarType = SidebarType.NONE;
sidebarObj = board.registerNewObjective(ScoreboardManager.SIDEBAR_OBJECTIVE, "dummy"); sidebarObjective = this.scoreboard.registerNewObjective(ScoreboardManager.SIDEBAR_OBJECTIVE, "dummy");
powerObj = board.registerNewObjective(ScoreboardManager.POWER_OBJECTIVE, "dummy"); powerObjective = this.scoreboard.registerNewObjective(ScoreboardManager.POWER_OBJECTIVE, "dummy");
if (Config.getInstance().getPowerLevelTagsEnabled()) { if (Config.getInstance().getPowerLevelTagsEnabled()) {
powerObj.setDisplayName(ScoreboardManager.TAG_POWER_LEVEL); powerObjective.setDisplayName(ScoreboardManager.TAG_POWER_LEVEL);
powerObj.setDisplaySlot(DisplaySlot.BELOW_NAME); powerObjective.setDisplaySlot(DisplaySlot.BELOW_NAME);
for (McMMOPlayer mcpl : UserManager.getPlayers()) {
powerObj.getScore(mcpl.getPlayer()).setScore(mcpl.getPowerLevel()); for (McMMOPlayer mcMMOPlayer : UserManager.getPlayers()) {
powerObjective.getScore(mcMMOPlayer.getPlayer()).setScore(mcMMOPlayer.getPowerLevel());
} }
} }
} }
public static ScoreboardWrapper create(Player p) { public static ScoreboardWrapper create(Player player) {
return new ScoreboardWrapper(p.getName(), mcMMO.p.getServer().getScoreboardManager().getNewScoreboard()); return new ScoreboardWrapper(player.getName(), mcMMO.p.getServer().getScoreboardManager().getNewScoreboard());
} }
public BukkitTask updateTask = null; public BukkitTask updateTask = null;
private class ScoreboardQuickUpdate extends BukkitRunnable { private class ScoreboardQuickUpdate extends BukkitRunnable {
@Override @Override
public void run() { public void run() {
ScoreboardWrapper.this.updateSidebar(); updateSidebar();
updateTask = null; updateTask = null;
} }
} }
@ -82,7 +81,7 @@ public class ScoreboardWrapper {
private class ScoreboardChangeTask extends BukkitRunnable { private class ScoreboardChangeTask extends BukkitRunnable {
@Override @Override
public void run() { public void run() {
ScoreboardWrapper.this.tryRevertBoard(); tryRevertBoard();
revertTask = null; revertTask = null;
} }
} }
@ -91,13 +90,12 @@ public class ScoreboardWrapper {
private class ScoreboardCooldownTask extends BukkitRunnable { private class ScoreboardCooldownTask extends BukkitRunnable {
@Override @Override
public void run() { public void run() {
ScoreboardWrapper wrapper = ScoreboardWrapper.this;
// Stop updating if it's no longer something displaying cooldowns // Stop updating if it's no longer something displaying cooldowns
if (wrapper.isBoardShown() && (wrapper.isSkillScoreboard() || wrapper.isCooldownScoreboard())) { if (isBoardShown() && (isSkillScoreboard() || isCooldownScoreboard())) {
wrapper.doSidebarUpdateSoon(); doSidebarUpdateSoon();
} }
else { else {
wrapper.stopCooldownUpdating(); stopCooldownUpdating();
} }
} }
} }
@ -122,7 +120,9 @@ public class ScoreboardWrapper {
if (cooldownTask != null) { if (cooldownTask != null) {
try { try {
cooldownTask.cancel(); cooldownTask.cancel();
} catch (Throwable ignored) {} }
catch (Throwable ignored) {}
cooldownTask = null; cooldownTask = null;
} }
} }
@ -143,29 +143,29 @@ public class ScoreboardWrapper {
* Set the old scoreboard, for use in reverting. * Set the old scoreboard, for use in reverting.
*/ */
public void setOldScoreboard() { public void setOldScoreboard() {
Player player = Bukkit.getPlayerExact(playerName); Player player = mcMMO.p.getServer().getPlayerExact(playerName);
if (player == null) { if (player == null) {
ScoreboardManager.cleanup(this); ScoreboardManager.cleanup(this);
return; return;
} }
Scoreboard old = player.getScoreboard(); Scoreboard oldBoard = player.getScoreboard();
if (old == board) { // Already displaying it
if (oldBoard == null) { if (oldBoard == scoreboard) { // Already displaying it
if (this.oldBoard == null) {
// (Shouldn't happen) Use failsafe value - we're already displaying our board, but we don't have the one we should revert to // (Shouldn't happen) Use failsafe value - we're already displaying our board, but we don't have the one we should revert to
oldBoard = Bukkit.getScoreboardManager().getMainScoreboard(); this.oldBoard = mcMMO.p.getServer().getScoreboardManager().getMainScoreboard();
}
else {
// Do nothing, we already have a prev board
} }
} }
else { else {
oldBoard = old; this.oldBoard = oldBoard;
} }
} }
public void showBoardWithNoRevert() { public void showBoardWithNoRevert() {
Player player = Bukkit.getPlayerExact(playerName); Player player = mcMMO.p.getServer().getPlayerExact(playerName);
if (player == null) { if (player == null) {
ScoreboardManager.cleanup(this); ScoreboardManager.cleanup(this);
return; return;
@ -174,12 +174,14 @@ public class ScoreboardWrapper {
if (revertTask != null) { if (revertTask != null) {
revertTask.cancel(); revertTask.cancel();
} }
player.setScoreboard(board);
player.setScoreboard(scoreboard);
revertTask = null; revertTask = null;
} }
public void showBoardAndScheduleRevert(int ticks) { public void showBoardAndScheduleRevert(int ticks) {
Player player = Bukkit.getPlayerExact(playerName); Player player = mcMMO.p.getServer().getPlayerExact(playerName);
if (player == null) { if (player == null) {
ScoreboardManager.cleanup(this); ScoreboardManager.cleanup(this);
return; return;
@ -188,7 +190,8 @@ public class ScoreboardWrapper {
if (revertTask != null) { if (revertTask != null) {
revertTask.cancel(); revertTask.cancel();
} }
player.setScoreboard(board);
player.setScoreboard(scoreboard);
revertTask = new ScoreboardChangeTask().runTaskLater(mcMMO.p, ticks); revertTask = new ScoreboardChangeTask().runTaskLater(mcMMO.p, ticks);
// TODO is there any way to do the time that looks acceptable? // TODO is there any way to do the time that looks acceptable?
@ -204,14 +207,15 @@ public class ScoreboardWrapper {
} }
public void tryRevertBoard() { public void tryRevertBoard() {
Player player = Bukkit.getPlayerExact(playerName); Player player = mcMMO.p.getServer().getPlayerExact(playerName);
if (player == null) { if (player == null) {
ScoreboardManager.cleanup(this); ScoreboardManager.cleanup(this);
return; return;
} }
if (oldBoard != null) { if (oldBoard != null) {
if (player.getScoreboard() == board) { if (player.getScoreboard() == scoreboard) {
player.setScoreboard(oldBoard); player.setScoreboard(oldBoard);
oldBoard = null; oldBoard = null;
} }
@ -219,14 +223,9 @@ public class ScoreboardWrapper {
mcMMO.p.debug("Not reverting scoreboard for " + playerName + " - scoreboard was changed by another plugin (Consider disabling the mcMMO scoreboards if you don't want them!)"); mcMMO.p.debug("Not reverting scoreboard for " + playerName + " - scoreboard was changed by another plugin (Consider disabling the mcMMO scoreboards if you don't want them!)");
} }
} }
else {
// Was already reverted
}
if (revertTask != null) { cancelRevert();
revertTask.cancel();
revertTask = null;
}
sidebarType = SidebarType.NONE; sidebarType = SidebarType.NONE;
targetPlayer = null; targetPlayer = null;
targetSkill = null; targetSkill = null;
@ -235,19 +234,22 @@ public class ScoreboardWrapper {
} }
public boolean isBoardShown() { public boolean isBoardShown() {
Player player = Bukkit.getPlayerExact(playerName); Player player = mcMMO.p.getServer().getPlayerExact(playerName);
if (player == null) { if (player == null) {
ScoreboardManager.cleanup(this); ScoreboardManager.cleanup(this);
return false; return false;
} }
return player.getScoreboard() == board; return player.getScoreboard() == scoreboard;
} }
public void cancelRevert() { public void cancelRevert() {
if (revertTask != null) { if (revertTask == null) {
revertTask.cancel(); return;
} }
revertTask.cancel();
revertTask = null; revertTask = null;
} }
@ -358,17 +360,18 @@ public class ScoreboardWrapper {
// Setup for after a board type change // Setup for after a board type change
protected void loadObjective(String displayName) { protected void loadObjective(String displayName) {
sidebarObj.unregister(); sidebarObjective.unregister();
sidebarObj = board.registerNewObjective(ScoreboardManager.SIDEBAR_OBJECTIVE, "dummy"); sidebarObjective = scoreboard.registerNewObjective(ScoreboardManager.SIDEBAR_OBJECTIVE, "dummy");
if (displayName.length() > 32) { if (displayName.length() > 32) {
displayName = displayName.substring(0, 32); displayName = displayName.substring(0, 32);
} }
sidebarObj.setDisplayName(displayName);
sidebarObjective.setDisplayName(displayName);
updateSidebar(); updateSidebar();
// Do last! Minimize packets! // Do last! Minimize packets!
sidebarObj.setDisplaySlot(DisplaySlot.SIDEBAR); sidebarObjective.setDisplaySlot(DisplaySlot.SIDEBAR);
} }
/** /**
@ -377,21 +380,24 @@ public class ScoreboardWrapper {
private void updateSidebar() { private void updateSidebar() {
try { try {
updateTask.cancel(); updateTask.cancel();
} catch (Throwable ignored) {} // catch NullPointerException and IllegalStateException and any Error; don't care }
catch (Throwable ignored) {} // catch NullPointerException and IllegalStateException and any Error; don't care
updateTask = null; updateTask = null;
if (sidebarType == SidebarType.NONE) { if (sidebarType == SidebarType.NONE) {
return; return;
} }
Player bukkitPlayer = Bukkit.getPlayerExact(playerName); Player player = mcMMO.p.getServer().getPlayerExact(playerName);
if (bukkitPlayer == null) {
if (player == null) {
ScoreboardManager.cleanup(this); ScoreboardManager.cleanup(this);
return; return;
} }
McMMOPlayer mcPlayer = UserManager.getPlayer(bukkitPlayer); McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
PlayerProfile profile = mcPlayer.getProfile(); PlayerProfile profile = mcMMOPlayer.getProfile();
switch (sidebarType) { switch (sidebarType) {
case NONE: case NONE:
@ -399,65 +405,66 @@ public class ScoreboardWrapper {
case SKILL_BOARD: case SKILL_BOARD:
Validate.notNull(targetSkill); Validate.notNull(targetSkill);
if (!targetSkill.isChildSkill()) { if (!targetSkill.isChildSkill()) {
int currentXP = profile.getSkillXpLevel(targetSkill); int currentXP = profile.getSkillXpLevel(targetSkill);
sidebarObj.getScore(ScoreboardManager.LABEL_CURRENT_XP).setScore(currentXP);
sidebarObj.getScore(ScoreboardManager.LABEL_REMAINING_XP).setScore(profile.getXpToLevel(targetSkill) - currentXP); sidebarObjective.getScore(ScoreboardManager.LABEL_CURRENT_XP).setScore(currentXP);
sidebarObjective.getScore(ScoreboardManager.LABEL_REMAINING_XP).setScore(profile.getXpToLevel(targetSkill) - currentXP);
} }
else { else {
Set<SkillType> parents = FamilyTree.getParents(targetSkill); for (SkillType parentSkill : FamilyTree.getParents(targetSkill)) {
for (SkillType parentSkill : parents) { sidebarObjective.getScore(ScoreboardManager.skillLabels.get(parentSkill)).setScore(profile.getSkillLevel(parentSkill));
sidebarObj.getScore(ScoreboardManager.skillLabels.get(parentSkill)).setScore(profile.getSkillLevel(parentSkill));
} }
} }
sidebarObj.getScore(ScoreboardManager.LABEL_LEVEL).setScore(profile.getSkillLevel(targetSkill));
sidebarObjective.getScore(ScoreboardManager.LABEL_LEVEL).setScore(profile.getSkillLevel(targetSkill));
if (targetSkill.getAbility() != null) { if (targetSkill.getAbility() != null) {
if (targetSkill != SkillType.MINING) { boolean stopUpdating;
AbilityType ab = targetSkill.getAbility();
Score cooldown = sidebarObj.getScore(ScoreboardManager.abilityLabelsSkill.get(ab)); if (targetSkill == SkillType.MINING) {
int seconds = SkillUtils.calculateTimeLeft(ab, profile, bukkitPlayer);
seconds = (seconds <= 0) ? 0 : seconds;
if (seconds == 0) {
cooldown.setScore(0);
stopCooldownUpdating();
}
else {
cooldown.setScore(seconds);
startCooldownUpdating();
}
} else {
// Special-Case: Mining has two abilities, both with cooldowns // Special-Case: Mining has two abilities, both with cooldowns
AbilityType sb = AbilityType.SUPER_BREAKER; Score cooldownSB = sidebarObjective.getScore(ScoreboardManager.abilityLabelsSkill.get(AbilityType.SUPER_BREAKER));
AbilityType bm = AbilityType.BLAST_MINING; Score cooldownBM = sidebarObjective.getScore(ScoreboardManager.abilityLabelsSkill.get(AbilityType.BLAST_MINING));
Score cooldownSB = sidebarObj.getScore(ScoreboardManager.abilityLabelsSkill.get(sb)); int secondsSB = Math.max(SkillUtils.calculateTimeLeft(AbilityType.SUPER_BREAKER, profile, player), 0);
Score cooldownBM = sidebarObj.getScore(ScoreboardManager.abilityLabelsSkill.get(bm)); int secondsBM = Math.max(SkillUtils.calculateTimeLeft(AbilityType.BLAST_MINING, profile, player), 0);
int secondsSB = SkillUtils.calculateTimeLeft(sb, profile, bukkitPlayer);
int secondsBM = SkillUtils.calculateTimeLeft(bm, profile, bukkitPlayer); cooldownSB.setScore(secondsSB);
secondsSB = (secondsSB <= 0) ? 0 : secondsSB; cooldownBM.setScore(secondsBM);
secondsBM = (secondsBM <= 0) ? 0 : secondsBM;
if (secondsSB == 0 && secondsBM == 0) { stopUpdating = (secondsSB == 0 && secondsBM == 0);
cooldownSB.setScore(0); }
cooldownBM.setScore(0); else {
stopCooldownUpdating(); AbilityType ability = targetSkill.getAbility();
} Score cooldown = sidebarObjective.getScore(ScoreboardManager.abilityLabelsSkill.get(ability));
else { int seconds = Math.max(SkillUtils.calculateTimeLeft(ability, profile, player), 0);
cooldownSB.setScore(secondsSB);
cooldownBM.setScore(secondsBM); cooldown.setScore(seconds);
startCooldownUpdating();
} stopUpdating = seconds == 0;
}
if (stopUpdating) {
stopCooldownUpdating();
}
else {
startCooldownUpdating();
} }
} }
break; break;
case COOLDOWNS_BOARD: case COOLDOWNS_BOARD:
boolean anyCooldownsActive = false; boolean anyCooldownsActive = false;
for (AbilityType ability : AbilityType.NORMAL_ABILITIES) { for (AbilityType ability : AbilityType.NORMAL_ABILITIES) {
int seconds = SkillUtils.calculateTimeLeft(ability, profile, bukkitPlayer); int seconds = Math.max(SkillUtils.calculateTimeLeft(ability, profile, player), 0);
seconds = (seconds <= 0) ? 0 : seconds;
if (seconds != 0) { if (seconds != 0) {
anyCooldownsActive = true; anyCooldownsActive = true;
} }
sidebarObj.getScore(ScoreboardManager.abilityLabelsColored.get(ability)).setScore(seconds);
sidebarObjective.getScore(ScoreboardManager.abilityLabelsColored.get(ability)).setScore(seconds);
} }
if (anyCooldownsActive) { if (anyCooldownsActive) {
@ -470,30 +477,35 @@ public class ScoreboardWrapper {
case STATS_BOARD: case STATS_BOARD:
// Select the profile to read from // Select the profile to read from
PlayerProfile prof; PlayerProfile newProfile;
if (targetProfile != null) { if (targetProfile != null) {
prof = targetProfile; // offline newProfile = targetProfile; // offline
} }
else if (targetPlayer == null) { else if (targetPlayer == null) {
prof = profile; // self newProfile = profile; // self
} }
else { else {
prof = UserManager.getPlayer(targetPlayer).getProfile(); // online newProfile = UserManager.getPlayer(targetPlayer).getProfile(); // online
} }
// Calculate power level here // Calculate power level here
int powerLevel = 0; int powerLevel = 0;
for (SkillType skill : SkillType.values()) { // Include child skills, but not in power level for (SkillType skill : SkillType.values()) { // Include child skills, but not in power level
int level = prof.getSkillLevel(skill); int level = newProfile.getSkillLevel(skill);
if (!skill.isChildSkill()) if (!skill.isChildSkill())
powerLevel += level; powerLevel += level;
// TODO: Verify that this is what we want - calculated in power level but not displayed // TODO: Verify that this is what we want - calculated in power level but not displayed
if (!Permissions.skillEnabled(bukkitPlayer, skill)) { if (!skill.getPermissions(player)) {
continue; continue;
} }
sidebarObj.getScore(ScoreboardManager.skillLabels.get(skill)).setScore(level);
sidebarObjective.getScore(ScoreboardManager.skillLabels.get(skill)).setScore(level);
} }
sidebarObj.getScore(ScoreboardManager.LABEL_POWER_LEVEL).setScore(powerLevel);
sidebarObjective.getScore(ScoreboardManager.LABEL_POWER_LEVEL).setScore(powerLevel);
break; break;
case RANK_BOARD: case RANK_BOARD:
@ -504,40 +516,47 @@ public class ScoreboardWrapper {
*/ */
break; break;
default:
break;
} }
} }
public void acceptRankData(Map<SkillType, Integer> rankData) { public void acceptRankData(Map<SkillType, Integer> rankData) {
Integer rank; Integer rank;
Player bukkitPlayer = Bukkit.getPlayerExact(playerName); Player player = mcMMO.p.getServer().getPlayerExact(playerName);
for (SkillType skill : SkillType.NON_CHILD_SKILLS) { for (SkillType skill : SkillType.NON_CHILD_SKILLS) {
if (!Permissions.skillEnabled(bukkitPlayer, skill)) { if (!skill.getPermissions(player)) {
continue; continue;
} }
rank = rankData.get(skill); rank = rankData.get(skill);
if (rank != null) { if (rank != null) {
sidebarObj.getScore(ScoreboardManager.skillLabels.get(skill)).setScore(rank); sidebarObjective.getScore(ScoreboardManager.skillLabels.get(skill)).setScore(rank);
} }
} }
rank = rankData.get(null); rank = rankData.get(null);
if (rank != null) { if (rank != null) {
sidebarObj.getScore(ScoreboardManager.LABEL_POWER_LEVEL).setScore(rank); sidebarObjective.getScore(ScoreboardManager.LABEL_POWER_LEVEL).setScore(rank);
} }
} }
public void acceptLeaderboardData(List<PlayerStat> leaderboardData) { public void acceptLeaderboardData(List<PlayerStat> leaderboardData) {
for (PlayerStat stat : leaderboardData) { for (PlayerStat stat : leaderboardData) {
String statname = stat.name; String name = stat.name;
if (statname.equals(playerName)) {
statname = ChatColor.GOLD + "--You--"; if (name.equals(playerName)) {
name = ChatColor.GOLD + "--You--";
} }
sidebarObj.getScore(Bukkit.getOfflinePlayer(statname)).setScore(stat.statVal);
sidebarObjective.getScore(mcMMO.p.getServer().getOfflinePlayer(name)).setScore(stat.statVal);
} }
} }
public void updatePowerLevel(Player leveledPlayer, int newPowerLevel) { public void updatePowerLevel(Player player, int newPowerLevel) {
powerObj.getScore(leveledPlayer).setScore(newPowerLevel); powerObjective.getScore(player).setScore(newPowerLevel);
} }
} }

View File

@ -224,7 +224,7 @@ public final class CombatUtils {
return; return;
} }
if (Permissions.skillEnabled(player, SkillType.SWORDS)) { if (SkillType.SWORDS.getPermissions(player)) {
processSwordCombat(target, player, event.getDamage()); processSwordCombat(target, player, event.getDamage());
} }
} }
@ -233,7 +233,7 @@ public final class CombatUtils {
return; return;
} }
if (Permissions.skillEnabled(player, SkillType.AXES)) { if (SkillType.AXES.getPermissions(player)) {
processAxeCombat(target, player, event); processAxeCombat(target, player, event);
} }
} }
@ -242,7 +242,7 @@ public final class CombatUtils {
return; return;
} }
if (Permissions.skillEnabled(player, SkillType.UNARMED)) { if (SkillType.UNARMED.getPermissions(player)) {
processUnarmedCombat(target, player, event); processUnarmedCombat(target, player, event);
} }
} }
@ -260,7 +260,7 @@ public final class CombatUtils {
if (tamer != null && tamer instanceof Player && shouldProcessSkill(target, SkillType.TAMING)) { if (tamer != null && tamer instanceof Player && shouldProcessSkill(target, SkillType.TAMING)) {
Player master = (Player) tamer; Player master = (Player) tamer;
if (!Misc.isNPCEntity(master) && Permissions.skillEnabled(master, SkillType.TAMING)) { if (!Misc.isNPCEntity(master) && SkillType.TAMING.getPermissions(master)) {
processTamingCombat(target, master, wolf, event); processTamingCombat(target, master, wolf, event);
} }
} }
@ -272,7 +272,7 @@ public final class CombatUtils {
if (shooter != null && shooter instanceof Player && shouldProcessSkill(target, SkillType.ARCHERY)) { if (shooter != null && shooter instanceof Player && shouldProcessSkill(target, SkillType.ARCHERY)) {
Player player = (Player) shooter; Player player = (Player) shooter;
if (!Misc.isNPCEntity(player) && Permissions.skillEnabled(player, SkillType.ARCHERY)) { if (!Misc.isNPCEntity(player) && SkillType.ARCHERY.getPermissions(player)) {
processArcheryCombat(target, player, event, arrow); processArcheryCombat(target, player, event, arrow);
} }
} }

View File

@ -74,7 +74,6 @@ Axes.Effect.8=Greater Impact
Axes.Effect.9=Deal bonus damage to unarmored foes Axes.Effect.9=Deal bonus damage to unarmored foes
Axes.Listener=Axes: Axes.Listener=Axes:
Axes.SkillName=AXES Axes.SkillName=AXES
Axes.Skills.SS.Name=Skull Splitter
Axes.Skills.SS.Off=[[RED]]**Skull Splitter has worn off** Axes.Skills.SS.Off=[[RED]]**Skull Splitter has worn off**
Axes.Skills.SS.On=[[GREEN]]**Skull Splitter ACTIVATED** Axes.Skills.SS.On=[[GREEN]]**Skull Splitter ACTIVATED**
Axes.Skills.SS.Refresh=[[GREEN]]Your [[YELLOW]]Skull Splitter [[GREEN]]ability is refreshed! Axes.Skills.SS.Refresh=[[GREEN]]Your [[YELLOW]]Skull Splitter [[GREEN]]ability is refreshed!
@ -92,7 +91,6 @@ Excavation.Effect.3=Ability to dig for treasure
Excavation.Effect.Length=[[RED]]Giga Drill Breaker Length: [[YELLOW]]{0}s Excavation.Effect.Length=[[RED]]Giga Drill Breaker Length: [[YELLOW]]{0}s
Excavation.Listener=Excavation: Excavation.Listener=Excavation:
Excavation.SkillName=EXCAVATION Excavation.SkillName=EXCAVATION
Excavation.Skills.GigaDrillBreaker.Name=Giga Drill Breaker
Excavation.Skills.GigaDrillBreaker.Off=[[RED]]**Giga Drill Breaker has worn off** Excavation.Skills.GigaDrillBreaker.Off=[[RED]]**Giga Drill Breaker has worn off**
Excavation.Skills.GigaDrillBreaker.On=[[GREEN]]**GIGA DRILL BREAKER ACTIVATED** Excavation.Skills.GigaDrillBreaker.On=[[GREEN]]**GIGA DRILL BREAKER ACTIVATED**
Excavation.Skills.GigaDrillBreaker.Refresh=[[GREEN]]Your [[YELLOW]]Giga Drill Breaker [[GREEN]]ability is refreshed! Excavation.Skills.GigaDrillBreaker.Refresh=[[GREEN]]Your [[YELLOW]]Giga Drill Breaker [[GREEN]]ability is refreshed!
@ -164,8 +162,7 @@ Herbalism.Effect.13=Spread mycelium to dirt & grass
Herbalism.HylianLuck=[[GREEN]]The luck of Hyrule is with you today! Herbalism.HylianLuck=[[GREEN]]The luck of Hyrule is with you today!
Herbalism.Listener=Herbalism: Herbalism.Listener=Herbalism:
Herbalism.SkillName=HERBALISM Herbalism.SkillName=HERBALISM
Herbalism.Skills.GTe.Name=Green Terra Herbalism.Skills.GTe[[RED]]**Green Terra has worn off**
Herbalism.Skills.GTe.Off=[[RED]]**Green Terra has worn off**
Herbalism.Skills.GTe.On=[[GREEN]]**GREEN TERRA ACTIVATED** Herbalism.Skills.GTe.On=[[GREEN]]**GREEN TERRA ACTIVATED**
Herbalism.Skills.GTe.Refresh=[[GREEN]]Your [[YELLOW]]Green Terra [[GREEN]]ability is refreshed! Herbalism.Skills.GTe.Refresh=[[GREEN]]Your [[YELLOW]]Green Terra [[GREEN]]ability is refreshed!
Herbalism.Skills.GTe.Other.Off=[[RED]]Green Terra[[GREEN]] has worn off for [[YELLOW]]{0} Herbalism.Skills.GTe.Other.Off=[[RED]]Green Terra[[GREEN]] has worn off for [[YELLOW]]{0}
@ -193,7 +190,6 @@ Mining.Effect.Decrease=[[RED]]Demolitions Expert Damage Decrease: [[YELLOW]]{0}
Mining.Effect.DropChance=[[RED]]Double Drop Chance: [[YELLOW]]{0} Mining.Effect.DropChance=[[RED]]Double Drop Chance: [[YELLOW]]{0}
Mining.Listener=Mining: Mining.Listener=Mining:
Mining.SkillName=MINING Mining.SkillName=MINING
Mining.Skills.SuperBreaker.Name=Super Breaker
Mining.Skills.SuperBreaker.Off=[[RED]]**Super Breaker has worn off** Mining.Skills.SuperBreaker.Off=[[RED]]**Super Breaker has worn off**
Mining.Skills.SuperBreaker.On=[[GREEN]]**SUPER BREAKER ACTIVATED** Mining.Skills.SuperBreaker.On=[[GREEN]]**SUPER BREAKER ACTIVATED**
Mining.Skills.SuperBreaker.Other.Off=[[RED]]Super Breaker[[GREEN]] has worn off for [[YELLOW]]{0} Mining.Skills.SuperBreaker.Other.Off=[[RED]]Super Breaker[[GREEN]] has worn off for [[YELLOW]]{0}
@ -202,7 +198,6 @@ Mining.Skills.SuperBreaker.Refresh=[[GREEN]]Your [[YELLOW]]Super Breaker [[GREEN
Mining.Skillup=[[YELLOW]]Mining skill increased by {0}. Total ({1}) Mining.Skillup=[[YELLOW]]Mining skill increased by {0}. Total ({1})
#Blast Mining #Blast Mining
Mining.Blast.Name=Blast Mining
Mining.Blast.Boom=[[GRAY]]**BOOM** Mining.Blast.Boom=[[GRAY]]**BOOM**
Mining.Blast.Effect=+{0} ore yield, -{1} debris yield, {2}x drops Mining.Blast.Effect=+{0} ore yield, -{1} debris yield, {2}x drops
Mining.Blast.Radius.Increase=[[RED]]Blast Radius Increase: [[YELLOW]]+{0} Mining.Blast.Radius.Increase=[[RED]]Blast Radius Increase: [[YELLOW]]+{0}
@ -282,8 +277,7 @@ Swords.Effect.5={0} Tick Bleed
Swords.Effect.6=Bleed Swords.Effect.6=Bleed
Swords.Effect.7=Apply a bleed DoT Swords.Effect.7=Apply a bleed DoT
Swords.Listener=Swords: Swords.Listener=Swords:
Swords.SkillName=SWORDS Swords.SkillName=SWORDS
Swords.Skills.SS.Name=Serrated Strikes
Swords.Skills.SS.Off=[[RED]]**Serrated Strikes has worn off** Swords.Skills.SS.Off=[[RED]]**Serrated Strikes has worn off**
Swords.Skills.SS.On=[[GREEN]]**SERRATED STRIKES ACTIVATED** Swords.Skills.SS.On=[[GREEN]]**SERRATED STRIKES ACTIVATED**
Swords.Skills.SS.Refresh=[[GREEN]]Your [[YELLOW]]Serrated Strikes [[GREEN]]ability is refreshed! Swords.Skills.SS.Refresh=[[GREEN]]Your [[YELLOW]]Serrated Strikes [[GREEN]]ability is refreshed!
@ -366,7 +360,6 @@ Unarmed.Effect.8=Iron Grip
Unarmed.Effect.9=Prevents you from being disarmed Unarmed.Effect.9=Prevents you from being disarmed
Unarmed.Listener=Unarmed: Unarmed.Listener=Unarmed:
Unarmed.SkillName=UNARMED Unarmed.SkillName=UNARMED
Unarmed.Skills.Berserk.Name=Berserk
Unarmed.Skills.Berserk.Off=[[RED]]**Berserk has worn off** Unarmed.Skills.Berserk.Off=[[RED]]**Berserk has worn off**
Unarmed.Skills.Berserk.On=[[GREEN]]**BERSERK ACTIVATED** Unarmed.Skills.Berserk.On=[[GREEN]]**BERSERK ACTIVATED**
Unarmed.Skills.Berserk.Other.Off=[[RED]]Berserk[[GREEN]] has worn off for [[YELLOW]]{0} Unarmed.Skills.Berserk.Other.Off=[[RED]]Berserk[[GREEN]] has worn off for [[YELLOW]]{0}
@ -388,7 +381,6 @@ Woodcutting.Effect.4=Double Drops
Woodcutting.Effect.5=Double the normal loot Woodcutting.Effect.5=Double the normal loot
Woodcutting.Listener=Woodcutting: Woodcutting.Listener=Woodcutting:
Woodcutting.SkillName=WOODCUTTING Woodcutting.SkillName=WOODCUTTING
Woodcutting.Skills.TreeFeller.Name=Tree Feller
Woodcutting.Skills.TreeFeller.Off=[[RED]]**Tree Feller has worn off** Woodcutting.Skills.TreeFeller.Off=[[RED]]**Tree Feller has worn off**
Woodcutting.Skills.TreeFeller.On=[[GREEN]]**TREE FELLER ACTIVATED** Woodcutting.Skills.TreeFeller.On=[[GREEN]]**TREE FELLER ACTIVATED**
Woodcutting.Skills.TreeFeller.Refresh=[[GREEN]]Your [[YELLOW]]Tree Feller [[GREEN]]ability is refreshed! Woodcutting.Skills.TreeFeller.Refresh=[[GREEN]]Your [[YELLOW]]Tree Feller [[GREEN]]ability is refreshed!