mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-25 22:56:45 +01:00
Formatting cleanup from the scoreboard update. Also handle skill permissions differently.
This commit is contained in:
parent
f55039ac6b
commit
9ef3c721df
@ -14,57 +14,58 @@ import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
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
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (CommandUtils.noConsoleUsage(sender)) {
|
||||
return true;
|
||||
}
|
||||
if (args.length == 0) {
|
||||
help(sender);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("clear") || args[0].equalsIgnoreCase("reset")) {
|
||||
ScoreboardManager.clearBoard(sender.getName());
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Clear"));
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("keep")) {
|
||||
if (!Config.getInstance().getAllowKeepBoard()) {
|
||||
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;
|
||||
}
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
if (args[0].equalsIgnoreCase("clear") || args[0].equalsIgnoreCase("reset")) {
|
||||
ScoreboardManager.clearBoard(sender.getName());
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Clear"));
|
||||
return true;
|
||||
}
|
||||
|
||||
private void 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"));
|
||||
if (args[0].equalsIgnoreCase("keep")) {
|
||||
if (!Config.getInstance().getAllowKeepBoard()) {
|
||||
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"));
|
||||
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
|
||||
@ -73,8 +74,15 @@ public class McscoreboardCommand implements TabExecutor {
|
||||
case 1:
|
||||
return StringUtil.copyPartialMatches(args[0], FIRST_ARGS, new ArrayList<String>(FIRST_ARGS.size()));
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -37,6 +37,6 @@ public class AddlevelsCommand extends ExperienceCommand {
|
||||
|
||||
@Override
|
||||
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()));
|
||||
}
|
||||
}
|
||||
|
@ -34,6 +34,6 @@ public class AddxpCommand extends ExperienceCommand {
|
||||
|
||||
@Override
|
||||
protected void handlePlayerMessageSkill() {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.addxp.AwardSkill", value, skill.getSkillName()));
|
||||
player.sendMessage(LocaleLoader.getString("Commands.addxp.AwardSkill", value, skill.getName()));
|
||||
}
|
||||
}
|
||||
|
@ -148,7 +148,7 @@ public abstract class ExperienceCommand implements TabExecutor {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", playerName));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.2", skill.getSkillName(), playerName));
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.2", skill.getName(), playerName));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -39,6 +39,6 @@ public class MmoeditCommand extends ExperienceCommand {
|
||||
|
||||
@Override
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
@ -121,6 +121,6 @@ public class SkillresetCommand extends ExperienceCommand {
|
||||
|
||||
@Override
|
||||
protected void handlePlayerMessageSkill() {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Reset.Single", skill.getSkillName()));
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Reset.Single", skill.getName()));
|
||||
}
|
||||
}
|
||||
|
@ -42,7 +42,10 @@ public class InspectCommand implements TabExecutor {
|
||||
|
||||
if (sender instanceof Player && Config.getInstance().getInspectUseBoard()) {
|
||||
ScoreboardManager.enablePlayerInspectScoreboard((Player) sender, profile);
|
||||
if (!Config.getInstance().getInspectUseChat()) return true;
|
||||
|
||||
if (!Config.getInstance().getInspectUseChat()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Inspect.OfflineStats", playerName));
|
||||
@ -78,7 +81,10 @@ public class InspectCommand implements TabExecutor {
|
||||
|
||||
if (sender instanceof Player && Config.getInstance().getInspectUseBoard()) {
|
||||
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()));
|
||||
|
@ -6,14 +6,11 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
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.datatypes.player.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
||||
@ -33,7 +30,10 @@ public class MccooldownCommand implements TabExecutor {
|
||||
|
||||
if (Config.getInstance().getCooldownUseBoard()) {
|
||||
ScoreboardManager.enablePlayerCooldownScoreboard(player);
|
||||
if (!Config.getInstance().getCooldownUseChat()) return true;
|
||||
|
||||
if (!Config.getInstance().getCooldownUseChat()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
PlayerProfile profile = UserManager.getPlayer(player).getProfile();
|
||||
@ -42,17 +42,17 @@ public class MccooldownCommand implements TabExecutor {
|
||||
player.sendMessage(LocaleLoader.getString("mcMMO.NoSkillNote"));
|
||||
|
||||
for (AbilityType ability : AbilityType.NORMAL_ABILITIES) {
|
||||
if (!hasPermission(player, ability)) {
|
||||
if (!ability.getPermissions(player)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
int seconds = SkillUtils.calculateTimeLeft(ability, profile, player);
|
||||
|
||||
if (seconds <= 0) {
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Cooldowns.Row.Y", ability.getAbilityName()));
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Cooldowns.Row.Y", ability.getName()));
|
||||
}
|
||||
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
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
return ImmutableList.of();
|
||||
|
@ -49,9 +49,10 @@ public class McrankCommand implements TabExecutor {
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName, true);
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
@ -80,16 +81,19 @@ public class McrankCommand implements TabExecutor {
|
||||
|
||||
private void display(CommandSender sender, String playerName) {
|
||||
if (sender instanceof Player) {
|
||||
McMMOPlayer mcpl = UserManager.getPlayer(sender.getName());
|
||||
if (mcpl.getDatabaseATS() + Misc.PLAYER_DATABASE_COOLDOWN_MILLIS > System.currentTimeMillis()) {
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName());
|
||||
|
||||
if (mcMMOPlayer.getDatabaseATS() + Misc.PLAYER_DATABASE_COOLDOWN_MILLIS > System.currentTimeMillis()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Database.Cooldown"));
|
||||
return;
|
||||
}
|
||||
mcpl.actualizeDatabaseATS();
|
||||
|
||||
mcMMOPlayer.actualizeDatabaseATS();
|
||||
}
|
||||
|
||||
boolean useBoard = (sender instanceof Player) && (Config.getInstance().getRankUseBoard());
|
||||
boolean useChat = useBoard ? Config.getInstance().getRankUseChat() : true;
|
||||
|
||||
new McrankCommandAsyncTask(playerName, sender, useBoard, useChat).runTaskAsynchronously(mcMMO.p);
|
||||
}
|
||||
}
|
||||
|
@ -28,8 +28,12 @@ public class McstatsCommand implements TabExecutor {
|
||||
|
||||
if (Config.getInstance().getStatsUseBoard()) {
|
||||
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("mcMMO.NoSkillNote"));
|
||||
|
||||
|
@ -23,27 +23,26 @@ import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
public class MctopCommand implements TabExecutor {
|
||||
private SkillType skill;
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
SkillType skill;
|
||||
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
display(1, null, sender, command);
|
||||
display(1, sender, command);
|
||||
return true;
|
||||
|
||||
case 1:
|
||||
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;
|
||||
}
|
||||
|
||||
if ((skill = extractSkill(sender, args[0])) == null) {
|
||||
if (!extractSkill(sender, args[0])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
display(1, skill, sender, command);
|
||||
display(1, sender, command);
|
||||
return true;
|
||||
|
||||
case 2:
|
||||
@ -51,11 +50,11 @@ public class MctopCommand implements TabExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((skill = extractSkill(sender, args[0])) == null) {
|
||||
if (!extractSkill(sender, args[0])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
display(Math.abs(Integer.parseInt(args[1])), skill, sender, command);
|
||||
display(Math.abs(Integer.parseInt(args[1])), sender, command);
|
||||
return true;
|
||||
|
||||
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)) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
if (sender instanceof Player) {
|
||||
McMMOPlayer mcpl = UserManager.getPlayer(sender.getName());
|
||||
if (mcpl.getDatabaseATS() + Misc.PLAYER_DATABASE_COOLDOWN_MILLIS > System.currentTimeMillis()) {
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(sender.getName());
|
||||
|
||||
if (mcMMOPlayer.getDatabaseATS() + Misc.PLAYER_DATABASE_COOLDOWN_MILLIS > System.currentTimeMillis()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Database.Cooldown"));
|
||||
return;
|
||||
}
|
||||
mcpl.actualizeDatabaseATS();
|
||||
|
||||
mcMMOPlayer.actualizeDatabaseATS();
|
||||
}
|
||||
|
||||
display(page, skill, sender);
|
||||
@ -98,16 +99,17 @@ public class MctopCommand implements TabExecutor {
|
||||
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)) {
|
||||
return null;
|
||||
}
|
||||
SkillType skill = SkillType.getSkill(skillName);
|
||||
|
||||
if (skill != null && CommandUtils.isChildSkill(sender, skill)) {
|
||||
return null;
|
||||
return false;
|
||||
}
|
||||
|
||||
return skill;
|
||||
skill = SkillType.getSkill(skillName);
|
||||
|
||||
if (CommandUtils.isChildSkill(sender, skill)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ public abstract class SkillCommand implements TabExecutor {
|
||||
|
||||
public SkillCommand(SkillType skill) {
|
||||
this.skill = skill;
|
||||
skillName = skill.getSkillName();
|
||||
skillName = skill.getName();
|
||||
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("Commands.XPGain", LocaleLoader.getString("Commands.XPGain." + StringUtils.getCapitalized(skill.toString()))));
|
||||
player.sendMessage(LocaleLoader.getString("Effects.Level", (int) skillValue, profile.getSkillXpLevel(skill), profile.getXpToLevel(skill)));
|
||||
|
||||
}
|
||||
else {
|
||||
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);
|
||||
|
||||
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)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,7 @@ public class SkillGuideCommand implements CommandExecutor {
|
||||
private String invalidPage;
|
||||
|
||||
public SkillGuideCommand(SkillType skillType) {
|
||||
header = LocaleLoader.getString("Guides.Header", skillType.getSkillName());
|
||||
header = LocaleLoader.getString("Guides.Header", skillType.getName());
|
||||
guide = getGuide(skillType);
|
||||
|
||||
invalidPage = LocaleLoader.getString("Guides.Page.Invalid");
|
||||
|
@ -85,12 +85,6 @@ public class Config extends AutoUpdateConfigLoader {
|
||||
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 */
|
||||
if (getPurgeInterval() < -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 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 int getSkillScoreboardTime() { return config.getInt("Scoreboard.Types.Skill.Display_Time", 30); }
|
||||
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 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 getMaxLength(AbilityType ability) { return config.getInt("Abilities.Max_Seconds." + 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.toString()); }
|
||||
|
||||
/* Durability Settings */
|
||||
public int getAbilityToolDamage() { return config.getInt("Abilities.Tools.Durability_Loss", 1); }
|
||||
|
@ -543,7 +543,7 @@ public class McMMOPlayer {
|
||||
int powerLevel = 0;
|
||||
|
||||
for (SkillType type : SkillType.NON_CHILD_SKILLS) {
|
||||
if (Permissions.skillEnabled(player, type)) {
|
||||
if (type.getPermissions(player)) {
|
||||
powerLevel += profile.getSkillLevel(type);
|
||||
}
|
||||
}
|
||||
@ -566,7 +566,7 @@ public class McMMOPlayer {
|
||||
Set<SkillType> parentSkills = FamilyTree.getParents(skillType);
|
||||
|
||||
for (SkillType parentSkill : parentSkills) {
|
||||
if (Permissions.skillEnabled(player, parentSkill)) {
|
||||
if (parentSkill.getPermissions(player)) {
|
||||
beginXpGain(parentSkill, xp / parentSkills.size());
|
||||
}
|
||||
}
|
||||
@ -601,7 +601,7 @@ public class McMMOPlayer {
|
||||
* @param xp Experience amount to add
|
||||
*/
|
||||
public void applyXpGain(SkillType skillType, float xp) {
|
||||
if (!Permissions.skillEnabled(player, skillType)) {
|
||||
if (!skillType.getPermissions(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,6 @@ import com.google.common.collect.ImmutableList;
|
||||
|
||||
public enum AbilityType {
|
||||
BERSERK(
|
||||
"Unarmed.Skills.Berserk.Name",
|
||||
"Unarmed.Skills.Berserk.On",
|
||||
"Unarmed.Skills.Berserk.Off",
|
||||
"Unarmed.Skills.Berserk.Other.On",
|
||||
@ -25,7 +24,6 @@ public enum AbilityType {
|
||||
"Unarmed.Skills.Berserk.Other.Off"),
|
||||
|
||||
SUPER_BREAKER(
|
||||
"Mining.Skills.SuperBreaker.Name",
|
||||
"Mining.Skills.SuperBreaker.On",
|
||||
"Mining.Skills.SuperBreaker.Off",
|
||||
"Mining.Skills.SuperBreaker.Other.On",
|
||||
@ -33,7 +31,6 @@ public enum AbilityType {
|
||||
"Mining.Skills.SuperBreaker.Other.Off"),
|
||||
|
||||
GIGA_DRILL_BREAKER(
|
||||
"Excavation.Skills.GigaDrillBreaker.Name",
|
||||
"Excavation.Skills.GigaDrillBreaker.On",
|
||||
"Excavation.Skills.GigaDrillBreaker.Off",
|
||||
"Excavation.Skills.GigaDrillBreaker.Other.On",
|
||||
@ -41,7 +38,6 @@ public enum AbilityType {
|
||||
"Excavation.Skills.GigaDrillBreaker.Other.Off"),
|
||||
|
||||
GREEN_TERRA(
|
||||
"Herbalism.Skills.GTe.Name",
|
||||
"Herbalism.Skills.GTe.On",
|
||||
"Herbalism.Skills.GTe.Off",
|
||||
"Herbalism.Skills.GTe.Other.On",
|
||||
@ -49,7 +45,6 @@ public enum AbilityType {
|
||||
"Herbalism.Skills.GTe.Other.Off"),
|
||||
|
||||
SKULL_SPLITTER(
|
||||
"Axes.Skills.SS.Name",
|
||||
"Axes.Skills.SS.On",
|
||||
"Axes.Skills.SS.Off",
|
||||
"Axes.Skills.SS.Other.On",
|
||||
@ -57,7 +52,6 @@ public enum AbilityType {
|
||||
"Axes.Skills.SS.Other.Off"),
|
||||
|
||||
TREE_FELLER(
|
||||
"Woodcutting.Skills.TreeFeller.Name",
|
||||
"Woodcutting.Skills.TreeFeller.On",
|
||||
"Woodcutting.Skills.TreeFeller.Off",
|
||||
"Woodcutting.Skills.TreeFeller.Other.On",
|
||||
@ -65,7 +59,6 @@ public enum AbilityType {
|
||||
"Woodcutting.Skills.TreeFeller.Other.Off"),
|
||||
|
||||
SERRATED_STRIKES(
|
||||
"Swords.Skills.SS.Name",
|
||||
"Swords.Skills.SS.On",
|
||||
"Swords.Skills.SS.Off",
|
||||
"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
|
||||
*/
|
||||
BLAST_MINING(
|
||||
"Mining.Blast.Name",
|
||||
null,
|
||||
null,
|
||||
"Mining.Blast.Other.On",
|
||||
@ -86,26 +78,13 @@ public enum AbilityType {
|
||||
/**
|
||||
* No cooldown - always active
|
||||
*/
|
||||
LEAF_BLOWER(
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null),
|
||||
LEAF_BLOWER,
|
||||
|
||||
/**
|
||||
* Not a first-class Ability - part of Berserk
|
||||
*/
|
||||
BLOCK_CRACKER(
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null);
|
||||
BLOCK_CRACKER;
|
||||
|
||||
private String abilityName;
|
||||
private String abilityOn;
|
||||
private String abilityOff;
|
||||
private String abilityPlayer;
|
||||
@ -115,31 +94,18 @@ public enum AbilityType {
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
public static final List<AbilityType> NON_NORMAL_ABILITIES;
|
||||
public static final List<AbilityType> NON_NORMAL_ABILITIES = ImmutableList.of(BLOCK_CRACKER, LEAF_BLOWER);
|
||||
|
||||
static {
|
||||
NORMAL_ABILITIES = ImmutableList.of(
|
||||
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() {
|
||||
this(null, null, null, null, null);
|
||||
}
|
||||
|
||||
private AbilityType(String abilityName, String abilityOn, String abilityOff, String abilityPlayer, String abilityRefresh, String abilityPlayerOff) {
|
||||
this.abilityName = abilityName;
|
||||
private AbilityType(String abilityOn, String abilityOff, String abilityPlayer, String abilityRefresh, String abilityPlayerOff) {
|
||||
this.abilityOn = abilityOn;
|
||||
this.abilityOff = abilityOff;
|
||||
this.abilityPlayer = abilityPlayer;
|
||||
@ -155,17 +121,6 @@ public enum AbilityType {
|
||||
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() {
|
||||
return LocaleLoader.getString(this.abilityOn);
|
||||
}
|
||||
@ -186,9 +141,8 @@ public enum AbilityType {
|
||||
return LocaleLoader.getString(this.abilityRefresh);
|
||||
}
|
||||
|
||||
public String getConfigString() {
|
||||
// If toString() changes, place old code here to not break config.yml
|
||||
return this.toString();
|
||||
public String getName() {
|
||||
return StringUtils.getPrettyAbilityString(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -5,6 +5,7 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
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.unarmed.UnarmedManager;
|
||||
import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
@ -70,7 +72,7 @@ public enum SkillType {
|
||||
nonChildSkills.add(skill);
|
||||
}
|
||||
|
||||
names.add(skill.getSkillName());
|
||||
names.add(skill.getName());
|
||||
}
|
||||
|
||||
Collections.sort(names);
|
||||
@ -191,7 +193,11 @@ public enum SkillType {
|
||||
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"));
|
||||
}
|
||||
|
||||
public boolean getPermissions(Player player) {
|
||||
return Permissions.skillEnabled(player, this);
|
||||
}
|
||||
}
|
||||
|
@ -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.
|
||||
* Instead, we check it inside the drops handler.
|
||||
*/
|
||||
if (Permissions.skillEnabled(player, SkillType.HERBALISM)) {
|
||||
if (SkillType.HERBALISM.getPermissions(player)) {
|
||||
herbalismManager.herbalismBlockCheck(blockState);
|
||||
}
|
||||
}
|
||||
|
||||
/* 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.miningBlockCheck(blockState);
|
||||
}
|
||||
|
||||
/* 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();
|
||||
|
||||
if (woodcuttingManager.canUseTreeFeller(heldItem)) {
|
||||
@ -180,7 +180,7 @@ public class BlockListener implements Listener {
|
||||
}
|
||||
|
||||
/* 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.excavationBlockCheck(blockState);
|
||||
|
||||
|
@ -91,7 +91,7 @@ public class InventoryListener implements Listener {
|
||||
|
||||
Player player = Misc.getPlayerFromFurnace(furnaceBlock);
|
||||
|
||||
if (Misc.isNPCEntity(player) || !Permissions.skillEnabled(player, SkillType.SMELTING)) {
|
||||
if (Misc.isNPCEntity(player) || !SkillType.SMELTING.getPermissions(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -204,7 +204,7 @@ public class PlayerListener implements Listener {
|
||||
public void onPlayerFishHighest(PlayerFishEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (Misc.isNPCEntity(player) || !Permissions.skillEnabled(player, SkillType.FISHING)) {
|
||||
if (Misc.isNPCEntity(player) || !SkillType.FISHING.getPermissions(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -249,7 +249,7 @@ public class PlayerListener implements Listener {
|
||||
public void onPlayerFishMonitor(PlayerFishEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (Misc.isNPCEntity(player) || !Permissions.skillEnabled(player, SkillType.FISHING)) {
|
||||
if (Misc.isNPCEntity(player) || !SkillType.FISHING.getPermissions(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -421,7 +421,7 @@ public class PlayerListener implements Listener {
|
||||
|
||||
if (!Config.getInstance().getAbilitiesOnlyActivateWhenSneaking() || player.isSneaking()) {
|
||||
/* 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();
|
||||
event.setCancelled(true);
|
||||
|
||||
@ -460,7 +460,7 @@ public class PlayerListener implements Listener {
|
||||
|
||||
if ((Config.getInstance().getAbilitiesOnlyActivateWhenSneaking() && player.isSneaking()) || !Config.getInstance().getAbilitiesOnlyActivateWhenSneaking()) {
|
||||
/* 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();
|
||||
|
||||
// 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?
|
||||
for (SkillType skill : SkillType.values()) {
|
||||
String skillName = skill.toString().toLowerCase();
|
||||
String localizedName = skill.getSkillName().toLowerCase();
|
||||
String localizedName = skill.getName().toLowerCase();
|
||||
|
||||
if (lowerCaseCommand.equals(localizedName)) {
|
||||
event.setMessage(message.replace(command, skillName));
|
||||
|
@ -12,28 +12,28 @@ import com.gmail.nossr50.events.skills.abilities.McMMOPlayerAbilityActivateEvent
|
||||
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
||||
|
||||
public class ScoreboardsListener implements Listener {
|
||||
@EventHandler
|
||||
public void onPlayerJoin(PlayerJoinEvent e) {
|
||||
ScoreboardManager.setupPlayer(e.getPlayer());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerQuit(PlayerQuitEvent e) {
|
||||
ScoreboardManager.teardownPlayer(e.getPlayer());
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
ScoreboardManager.setupPlayer(event.getPlayer());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerLevelUp(McMMOPlayerLevelUpEvent e) {
|
||||
ScoreboardManager.handleLevelUp(e.getPlayer(), e.getSkill());
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
ScoreboardManager.teardownPlayer(event.getPlayer());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerXp(McMMOPlayerXpGainEvent e) {
|
||||
ScoreboardManager.handleXp(e.getPlayer(), e.getSkill());
|
||||
public void onPlayerLevelUp(McMMOPlayerLevelUpEvent event) {
|
||||
ScoreboardManager.handleLevelUp(event.getPlayer(), event.getSkill());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onAbility(McMMOPlayerAbilityActivateEvent e) {
|
||||
ScoreboardManager.cooldownUpdate(e.getPlayer(), e.getSkill());
|
||||
public void onPlayerXp(McMMOPlayerXpGainEvent event) {
|
||||
ScoreboardManager.handleXp(event.getPlayer(), event.getSkill());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onAbility(McMMOPlayerAbilityActivateEvent event) {
|
||||
ScoreboardManager.cooldownUpdate(event.getPlayer(), event.getSkill());
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,11 @@ public class McrankCommandAsyncTask extends BukkitRunnable {
|
||||
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.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.sender = sender;
|
||||
this.useBoard = useBoard;
|
||||
|
@ -9,7 +9,6 @@ import org.bukkit.scheduler.BukkitRunnable;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
||||
|
||||
/**
|
||||
@ -21,7 +20,7 @@ public class McrankCommandDisplayTask extends BukkitRunnable {
|
||||
private final String playerName;
|
||||
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.sender = sender;
|
||||
this.playerName = playerName;
|
||||
@ -34,6 +33,7 @@ public class McrankCommandDisplayTask extends BukkitRunnable {
|
||||
if (useBoard) {
|
||||
displayBoard();
|
||||
}
|
||||
|
||||
if (useChat){
|
||||
displayChat();
|
||||
}
|
||||
@ -47,12 +47,12 @@ public class McrankCommandDisplayTask extends BukkitRunnable {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Player", playerName));
|
||||
|
||||
for (SkillType skill : SkillType.NON_CHILD_SKILLS) {
|
||||
if (player != null && !Permissions.skillEnabled(player, skill)) {
|
||||
if (!skill.getPermissions(player)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
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);
|
||||
@ -60,7 +60,7 @@ public class McrankCommandDisplayTask extends BukkitRunnable {
|
||||
}
|
||||
|
||||
public void displayBoard() {
|
||||
if (playerName == null || sender.getName().equalsIgnoreCase(playerName)) {
|
||||
if (sender.getName().equalsIgnoreCase(playerName)) {
|
||||
ScoreboardManager.showPlayerRankScoreboard((Player) sender, skills);
|
||||
}
|
||||
else {
|
||||
|
@ -20,7 +20,11 @@ public class MctopCommandAsyncTask extends BukkitRunnable {
|
||||
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.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.skill = skill;
|
||||
this.sender = sender;
|
||||
|
@ -22,7 +22,7 @@ public class MctopCommandDisplayTask extends BukkitRunnable {
|
||||
private final int page;
|
||||
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.page = page;
|
||||
this.skill = skill;
|
||||
@ -36,9 +36,11 @@ public class MctopCommandDisplayTask extends BukkitRunnable {
|
||||
if (useBoard) {
|
||||
displayBoard();
|
||||
}
|
||||
|
||||
if (useChat) {
|
||||
displayChat();
|
||||
}
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.mctop.Tip"));
|
||||
}
|
||||
|
||||
@ -47,7 +49,7 @@ public class MctopCommandDisplayTask extends BukkitRunnable {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Leaderboard"));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Leaderboard", skill.getSkillName()));
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Leaderboard", skill.getName()));
|
||||
}
|
||||
|
||||
int place = (page * 10) - 9;
|
||||
|
@ -3,6 +3,8 @@ package com.gmail.nossr50.util;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
||||
|
||||
public class StringUtils {
|
||||
/**
|
||||
* Gets a capitalized version of the target string.
|
||||
@ -22,6 +24,10 @@ public class StringUtils {
|
||||
return createPrettyEnumString(entity.toString());
|
||||
}
|
||||
|
||||
public static String getPrettyAbilityString(AbilityType ability) {
|
||||
return createPrettyEnumString(ability.toString());
|
||||
}
|
||||
|
||||
private static String createPrettyEnumString(String baseString) {
|
||||
String[] substrings = baseString.split("_");
|
||||
String prettyString = "";
|
||||
|
@ -60,7 +60,7 @@ public final class CommandRegistrationManager {
|
||||
private static void registerSkillCommands() {
|
||||
for (SkillType skill : SkillType.values()) {
|
||||
String commandName = skill.toString().toLowerCase();
|
||||
String localizedName = skill.getSkillName().toLowerCase();
|
||||
String localizedName = skill.getName().toLowerCase();
|
||||
|
||||
PluginCommand command;
|
||||
|
||||
@ -385,7 +385,8 @@ public final class CommandRegistrationManager {
|
||||
command.setDescription("Change the current mcMMO scoreboard being displayed"); //TODO: Localize
|
||||
command.setPermission("mcmmo.commands.mcscoreboard");
|
||||
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());
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,6 @@ package com.gmail.nossr50.util.commands;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
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.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
@ -98,9 +96,10 @@ public final class CommandUtils {
|
||||
return true;
|
||||
}
|
||||
|
||||
OfflinePlayer player = Bukkit.getOfflinePlayer(playerName);
|
||||
if (!player.hasPlayedBefore()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
PlayerProfile profile = new PlayerProfile(playerName, false);
|
||||
|
||||
if (unloadedProfile(sender, profile)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
@ -208,7 +207,7 @@ public final class CommandUtils {
|
||||
displayData.add(header);
|
||||
|
||||
for (SkillType skill : skillGroup) {
|
||||
if (Permissions.skillEnabled(inspect, skill)) {
|
||||
if (skill.getPermissions(inspect)) {
|
||||
displayData.add(displaySkill(profile, skill));
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,11 @@
|
||||
package com.gmail.nossr50.util.scoreboards;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
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_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> abilityLabelsSkill;
|
||||
|
||||
static {
|
||||
ImmutableMap.Builder<SkillType, OfflinePlayer> b = ImmutableMap.builder();
|
||||
ImmutableMap.Builder<AbilityType, OfflinePlayer> c = ImmutableMap.builder();
|
||||
ImmutableMap.Builder<AbilityType, OfflinePlayer> d = ImmutableMap.builder();
|
||||
ImmutableMap.Builder<SkillType, OfflinePlayer> skillLabelBuilder = ImmutableMap.builder();
|
||||
ImmutableMap.Builder<AbilityType, OfflinePlayer> abilityLabelBuilder = ImmutableMap.builder();
|
||||
ImmutableMap.Builder<AbilityType, OfflinePlayer> abilityLabelSkillBuilder = ImmutableMap.builder();
|
||||
|
||||
if (Config.getInstance().getScoreboardRainbows()) {
|
||||
Random shuffler = new Random(Bukkit.getWorlds().get(0).getSeed());
|
||||
List<ChatColor> colors = Arrays.asList(
|
||||
ChatColor.WHITE,
|
||||
ChatColor.YELLOW,
|
||||
ChatColor.LIGHT_PURPLE,
|
||||
ChatColor.RED,
|
||||
ChatColor.AQUA,
|
||||
ChatColor.GREEN,
|
||||
ChatColor.DARK_GRAY,
|
||||
ChatColor.BLUE,
|
||||
ChatColor.DARK_PURPLE,
|
||||
ChatColor.DARK_RED,
|
||||
ChatColor.DARK_AQUA,
|
||||
ChatColor.DARK_GREEN,
|
||||
ChatColor.DARK_BLUE
|
||||
);
|
||||
Collections.shuffle(colors, shuffler);
|
||||
List<ChatColor> colors = new ArrayList<ChatColor>();
|
||||
|
||||
for (ChatColor color : ChatColor.values()) {
|
||||
if (color.isColor()) {
|
||||
colors.add(color);
|
||||
}
|
||||
}
|
||||
|
||||
Collections.shuffle(colors, Misc.getRandom());
|
||||
|
||||
int i = 0;
|
||||
for (SkillType type : SkillType.values()) {
|
||||
// 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) {
|
||||
// the toString is the properly formatted verison for abilities
|
||||
c.put(type.getAbility(), getOfflinePlayer(colors.get(i) + type.getAbility().getAbilityName()));
|
||||
abilityLabelBuilder.put(type.getAbility(), getOfflinePlayer(colors.get(i) + type.getAbility().getName()));
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (SkillType type : SkillType.values()) {
|
||||
// Include child skills
|
||||
b.put(type, getOfflinePlayer(ChatColor.GREEN + type.getSkillName()));
|
||||
skillLabelBuilder.put(type, getOfflinePlayer(ChatColor.GREEN + type.getName()));
|
||||
|
||||
if (type.getAbility() != null) {
|
||||
// the toString is the properly formatted verison for abilities
|
||||
c.put(type.getAbility(), getOfflinePlayerDots(ChatColor.AQUA + type.getAbility().getAbilityName()));
|
||||
abilityLabelBuilder.put(type.getAbility(), getOfflinePlayerDots(ChatColor.AQUA + type.getAbility().getName()));
|
||||
|
||||
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) {
|
||||
if (type == AbilityType.BLAST_MINING) {
|
||||
// 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()));
|
||||
}
|
||||
abilityLabelSkillBuilder.put(type, getOfflinePlayerDots((type == AbilityType.BLAST_MINING ? ChatColor.BLUE : ChatColor.AQUA) + type.getName()));
|
||||
}
|
||||
|
||||
skillLabels = b.build();
|
||||
abilityLabelsColored = c.build();
|
||||
abilityLabelsSkill = d.build();
|
||||
skillLabels = skillLabelBuilder.build();
|
||||
abilityLabelsColored = abilityLabelBuilder.build();
|
||||
abilityLabelsSkill = abilityLabelSkillBuilder.build();
|
||||
}
|
||||
|
||||
private static List<String> dirtyPowerLevels = new ArrayList<String>();
|
||||
|
||||
private static OfflinePlayer getOfflinePlayer(String name) {
|
||||
if (name.length() > 16) {
|
||||
name = name.substring(0, 16);
|
||||
}
|
||||
return Bukkit.getOfflinePlayer(name);
|
||||
return getOfflinePlayer(name, false);
|
||||
}
|
||||
|
||||
private static OfflinePlayer getOfflinePlayerDots(String name) {
|
||||
return getOfflinePlayer(name, true);
|
||||
}
|
||||
|
||||
private static OfflinePlayer getOfflinePlayer(String name, boolean useDots) {
|
||||
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 {
|
||||
@ -144,14 +135,15 @@ public class ScoreboardManager {
|
||||
// **** Listener call-ins **** //
|
||||
|
||||
// Called by PlayerJoinEvent listener
|
||||
public static void setupPlayer(Player p) {
|
||||
PLAYER_SCOREBOARDS.put(p.getName(), ScoreboardWrapper.create(p));
|
||||
dirtyPowerLevels.add(p.getName());
|
||||
public static void setupPlayer(Player player) {
|
||||
PLAYER_SCOREBOARDS.put(player.getName(), ScoreboardWrapper.create(player));
|
||||
dirtyPowerLevels.add(player.getName());
|
||||
}
|
||||
|
||||
// Called by PlayerQuitEvent listener
|
||||
public static void teardownPlayer(Player p) {
|
||||
ScoreboardWrapper wrapper = PLAYER_SCOREBOARDS.remove(p.getName());
|
||||
public static void teardownPlayer(Player player) {
|
||||
ScoreboardWrapper wrapper = PLAYER_SCOREBOARDS.remove(player.getName());
|
||||
|
||||
if (wrapper.revertTask != null) {
|
||||
wrapper.revertTask.cancel();
|
||||
}
|
||||
@ -159,14 +151,15 @@ public class ScoreboardManager {
|
||||
|
||||
// Called in onDisable()
|
||||
public static void teardownAll() {
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
teardownPlayer(p);
|
||||
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
|
||||
teardownPlayer(player);
|
||||
}
|
||||
}
|
||||
|
||||
// Called by ScoreboardWrapper when its Player logs off and an action tries to be performed
|
||||
public static void cleanup(ScoreboardWrapper wrapper) {
|
||||
PLAYER_SCOREBOARDS.remove(wrapper.playerName);
|
||||
|
||||
if (wrapper.revertTask != null) {
|
||||
wrapper.revertTask.cancel();
|
||||
}
|
||||
@ -175,16 +168,18 @@ public class ScoreboardManager {
|
||||
// Called by internal level-up event listener
|
||||
public static void handleLevelUp(Player player, SkillType skill) {
|
||||
// Selfboards
|
||||
ScoreboardWrapper wrapper = PLAYER_SCOREBOARDS.get(player.getName());
|
||||
if ((wrapper.isSkillScoreboard() && wrapper.targetSkill == skill) || (wrapper.isStatsScoreboard()) && wrapper.isBoardShown()) {
|
||||
wrapper.doSidebarUpdateSoon();
|
||||
ScoreboardWrapper selfboardWrapper = PLAYER_SCOREBOARDS.get(player.getName());
|
||||
|
||||
if ((selfboardWrapper.isSkillScoreboard() && selfboardWrapper.targetSkill == skill) || (selfboardWrapper.isStatsScoreboard()) && selfboardWrapper.isBoardShown()) {
|
||||
selfboardWrapper.doSidebarUpdateSoon();
|
||||
}
|
||||
|
||||
// Otherboards
|
||||
String playerName = player.getName();
|
||||
for (ScoreboardWrapper w : PLAYER_SCOREBOARDS.values()) {
|
||||
if (w.isStatsScoreboard() && playerName.equals(w.targetPlayer) && wrapper.isBoardShown()) {
|
||||
wrapper.doSidebarUpdateSoon();
|
||||
|
||||
for (ScoreboardWrapper wrapper : PLAYER_SCOREBOARDS.values()) {
|
||||
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) {
|
||||
// Selfboards
|
||||
ScoreboardWrapper wrapper = PLAYER_SCOREBOARDS.get(player.getName());
|
||||
|
||||
if (wrapper.isSkillScoreboard() && wrapper.targetSkill == skill && wrapper.isBoardShown()) {
|
||||
wrapper.doSidebarUpdateSoon();
|
||||
}
|
||||
@ -210,6 +206,7 @@ public class ScoreboardManager {
|
||||
public static void cooldownUpdate(Player player, SkillType skill) {
|
||||
// Selfboards
|
||||
ScoreboardWrapper wrapper = PLAYER_SCOREBOARDS.get(player.getName());
|
||||
|
||||
if ((wrapper.isCooldownScoreboard() || wrapper.isSkillScoreboard() && wrapper.targetSkill == skill) && wrapper.isBoardShown()) {
|
||||
wrapper.doSidebarUpdateSoon();
|
||||
}
|
||||
@ -267,8 +264,8 @@ public class ScoreboardManager {
|
||||
changeScoreboard(wrapper, Config.getInstance().getCooldownScoreboardTime());
|
||||
}
|
||||
|
||||
public static void showPlayerRankScoreboard(Player bukkitPlayer, Map<SkillType, Integer> rank) {
|
||||
ScoreboardWrapper wrapper = PLAYER_SCOREBOARDS.get(bukkitPlayer.getName());
|
||||
public static void showPlayerRankScoreboard(Player player, Map<SkillType, Integer> rank) {
|
||||
ScoreboardWrapper wrapper = PLAYER_SCOREBOARDS.get(player.getName());
|
||||
|
||||
wrapper.setOldScoreboard();
|
||||
wrapper.setTypeSelfRank();
|
||||
@ -277,8 +274,8 @@ public class ScoreboardManager {
|
||||
changeScoreboard(wrapper, Config.getInstance().getRankScoreboardTime());
|
||||
}
|
||||
|
||||
public static void showPlayerRankScoreboardOthers(Player bukkitPlayer, String targetName, Map<SkillType, Integer> rank) {
|
||||
ScoreboardWrapper wrapper = PLAYER_SCOREBOARDS.get(bukkitPlayer.getName());
|
||||
public static void showPlayerRankScoreboardOthers(Player player, String targetName, Map<SkillType, Integer> rank) {
|
||||
ScoreboardWrapper wrapper = PLAYER_SCOREBOARDS.get(player.getName());
|
||||
|
||||
wrapper.setOldScoreboard();
|
||||
wrapper.setTypeInspectRank(targetName);
|
||||
@ -314,24 +311,28 @@ public class ScoreboardManager {
|
||||
*/
|
||||
public static boolean powerLevelHeartbeat() {
|
||||
Objective mainObjective = getPowerLevelObjective();
|
||||
|
||||
if (mainObjective == null) {
|
||||
return false; // indicates
|
||||
}
|
||||
|
||||
if (!dirtyPowerLevels.isEmpty())
|
||||
if (!dirtyPowerLevels.isEmpty()) {
|
||||
mcMMO.p.getLogger().info(dirtyPowerLevels.toString());
|
||||
}
|
||||
|
||||
for (String playerName : dirtyPowerLevels) {
|
||||
McMMOPlayer mcpl = UserManager.getPlayer(playerName);
|
||||
Player player = mcpl.getPlayer();
|
||||
int power = mcpl.getPowerLevel();
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName);
|
||||
Player player = mcMMOPlayer.getPlayer();
|
||||
int power = mcMMOPlayer.getPowerLevel();
|
||||
|
||||
mainObjective.getScore(player).setScore(power);
|
||||
|
||||
for (ScoreboardWrapper wrapper : PLAYER_SCOREBOARDS.values()) {
|
||||
wrapper.updatePowerLevel(player, power);
|
||||
}
|
||||
}
|
||||
dirtyPowerLevels.clear();
|
||||
|
||||
dirtyPowerLevels.clear();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -345,21 +346,25 @@ public class ScoreboardManager {
|
||||
*/
|
||||
public static Objective getPowerLevelObjective() {
|
||||
if (!Config.getInstance().getPowerLevelTagsEnabled()) {
|
||||
Objective obj = Bukkit.getScoreboardManager().getMainScoreboard().getObjective(POWER_OBJECTIVE);
|
||||
if (obj != null) {
|
||||
obj.unregister();
|
||||
Objective objective = mcMMO.p.getServer().getScoreboardManager().getMainScoreboard().getObjective(POWER_OBJECTIVE);
|
||||
|
||||
if (objective != null) {
|
||||
objective.unregister();
|
||||
mcMMO.p.debug("Removed leftover scoreboard objects from Power Level Tags.");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
Objective powerObj = Bukkit.getScoreboardManager().getMainScoreboard().getObjective(POWER_OBJECTIVE);
|
||||
if (powerObj == null) {
|
||||
powerObj = Bukkit.getScoreboardManager().getMainScoreboard().registerNewObjective(POWER_OBJECTIVE, "dummy");
|
||||
powerObj.setDisplayName(TAG_POWER_LEVEL);
|
||||
powerObj.setDisplaySlot(DisplaySlot.BELOW_NAME);
|
||||
Objective powerObjective = mcMMO.p.getServer().getScoreboardManager().getMainScoreboard().getObjective(POWER_OBJECTIVE);
|
||||
|
||||
if (powerObjective == null) {
|
||||
powerObjective = mcMMO.p.getServer().getScoreboardManager().getMainScoreboard().registerNewObjective(POWER_OBJECTIVE, "dummy");
|
||||
powerObjective.setDisplayName(TAG_POWER_LEVEL);
|
||||
powerObjective.setDisplaySlot(DisplaySlot.BELOW_NAME);
|
||||
}
|
||||
return powerObj;
|
||||
|
||||
return powerObjective;
|
||||
}
|
||||
|
||||
private static void changeScoreboard(ScoreboardWrapper wrapper, int displayTime) {
|
||||
|
@ -2,10 +2,8 @@ package com.gmail.nossr50.util.scoreboards;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
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.skills.child.FamilyTree;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.player.UserManager;
|
||||
import com.gmail.nossr50.util.scoreboards.ScoreboardManager.SidebarType;
|
||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||
@ -34,14 +31,14 @@ public class ScoreboardWrapper {
|
||||
|
||||
// Initialization variables
|
||||
public final String playerName;
|
||||
private final Scoreboard board;
|
||||
private final Scoreboard scoreboard;
|
||||
private boolean tippedKeep = false;
|
||||
private boolean tippedClear = false;
|
||||
|
||||
// Internal usage variables (should exist)
|
||||
private SidebarType sidebarType;
|
||||
private Objective sidebarObj;
|
||||
private Objective powerObj;
|
||||
private Objective sidebarObjective;
|
||||
private Objective powerObjective;
|
||||
|
||||
// Parameter variables (May be null / invalid)
|
||||
private Scoreboard oldBoard = null;
|
||||
@ -50,30 +47,32 @@ public class ScoreboardWrapper {
|
||||
private PlayerProfile targetProfile = null;
|
||||
public int leaderboardPage = -1;
|
||||
|
||||
private ScoreboardWrapper(String playerName, Scoreboard s) {
|
||||
private ScoreboardWrapper(String playerName, Scoreboard scoreboard) {
|
||||
this.playerName = playerName;
|
||||
board = s;
|
||||
this.scoreboard = scoreboard;
|
||||
sidebarType = SidebarType.NONE;
|
||||
sidebarObj = board.registerNewObjective(ScoreboardManager.SIDEBAR_OBJECTIVE, "dummy");
|
||||
powerObj = board.registerNewObjective(ScoreboardManager.POWER_OBJECTIVE, "dummy");
|
||||
sidebarObjective = this.scoreboard.registerNewObjective(ScoreboardManager.SIDEBAR_OBJECTIVE, "dummy");
|
||||
powerObjective = this.scoreboard.registerNewObjective(ScoreboardManager.POWER_OBJECTIVE, "dummy");
|
||||
|
||||
if (Config.getInstance().getPowerLevelTagsEnabled()) {
|
||||
powerObj.setDisplayName(ScoreboardManager.TAG_POWER_LEVEL);
|
||||
powerObj.setDisplaySlot(DisplaySlot.BELOW_NAME);
|
||||
for (McMMOPlayer mcpl : UserManager.getPlayers()) {
|
||||
powerObj.getScore(mcpl.getPlayer()).setScore(mcpl.getPowerLevel());
|
||||
powerObjective.setDisplayName(ScoreboardManager.TAG_POWER_LEVEL);
|
||||
powerObjective.setDisplaySlot(DisplaySlot.BELOW_NAME);
|
||||
|
||||
for (McMMOPlayer mcMMOPlayer : UserManager.getPlayers()) {
|
||||
powerObjective.getScore(mcMMOPlayer.getPlayer()).setScore(mcMMOPlayer.getPowerLevel());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static ScoreboardWrapper create(Player p) {
|
||||
return new ScoreboardWrapper(p.getName(), mcMMO.p.getServer().getScoreboardManager().getNewScoreboard());
|
||||
public static ScoreboardWrapper create(Player player) {
|
||||
return new ScoreboardWrapper(player.getName(), mcMMO.p.getServer().getScoreboardManager().getNewScoreboard());
|
||||
}
|
||||
|
||||
public BukkitTask updateTask = null;
|
||||
private class ScoreboardQuickUpdate extends BukkitRunnable {
|
||||
@Override
|
||||
public void run() {
|
||||
ScoreboardWrapper.this.updateSidebar();
|
||||
updateSidebar();
|
||||
updateTask = null;
|
||||
}
|
||||
}
|
||||
@ -82,7 +81,7 @@ public class ScoreboardWrapper {
|
||||
private class ScoreboardChangeTask extends BukkitRunnable {
|
||||
@Override
|
||||
public void run() {
|
||||
ScoreboardWrapper.this.tryRevertBoard();
|
||||
tryRevertBoard();
|
||||
revertTask = null;
|
||||
}
|
||||
}
|
||||
@ -91,13 +90,12 @@ public class ScoreboardWrapper {
|
||||
private class ScoreboardCooldownTask extends BukkitRunnable {
|
||||
@Override
|
||||
public void run() {
|
||||
ScoreboardWrapper wrapper = ScoreboardWrapper.this;
|
||||
// Stop updating if it's no longer something displaying cooldowns
|
||||
if (wrapper.isBoardShown() && (wrapper.isSkillScoreboard() || wrapper.isCooldownScoreboard())) {
|
||||
wrapper.doSidebarUpdateSoon();
|
||||
if (isBoardShown() && (isSkillScoreboard() || isCooldownScoreboard())) {
|
||||
doSidebarUpdateSoon();
|
||||
}
|
||||
else {
|
||||
wrapper.stopCooldownUpdating();
|
||||
stopCooldownUpdating();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -122,7 +120,9 @@ public class ScoreboardWrapper {
|
||||
if (cooldownTask != null) {
|
||||
try {
|
||||
cooldownTask.cancel();
|
||||
} catch (Throwable ignored) {}
|
||||
}
|
||||
catch (Throwable ignored) {}
|
||||
|
||||
cooldownTask = null;
|
||||
}
|
||||
}
|
||||
@ -143,29 +143,29 @@ public class ScoreboardWrapper {
|
||||
* Set the old scoreboard, for use in reverting.
|
||||
*/
|
||||
public void setOldScoreboard() {
|
||||
Player player = Bukkit.getPlayerExact(playerName);
|
||||
Player player = mcMMO.p.getServer().getPlayerExact(playerName);
|
||||
|
||||
if (player == null) {
|
||||
ScoreboardManager.cleanup(this);
|
||||
return;
|
||||
}
|
||||
|
||||
Scoreboard old = player.getScoreboard();
|
||||
if (old == board) { // Already displaying it
|
||||
if (oldBoard == null) {
|
||||
Scoreboard oldBoard = player.getScoreboard();
|
||||
|
||||
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
|
||||
oldBoard = Bukkit.getScoreboardManager().getMainScoreboard();
|
||||
}
|
||||
else {
|
||||
// Do nothing, we already have a prev board
|
||||
this.oldBoard = mcMMO.p.getServer().getScoreboardManager().getMainScoreboard();
|
||||
}
|
||||
}
|
||||
else {
|
||||
oldBoard = old;
|
||||
this.oldBoard = oldBoard;
|
||||
}
|
||||
}
|
||||
|
||||
public void showBoardWithNoRevert() {
|
||||
Player player = Bukkit.getPlayerExact(playerName);
|
||||
Player player = mcMMO.p.getServer().getPlayerExact(playerName);
|
||||
|
||||
if (player == null) {
|
||||
ScoreboardManager.cleanup(this);
|
||||
return;
|
||||
@ -174,12 +174,14 @@ public class ScoreboardWrapper {
|
||||
if (revertTask != null) {
|
||||
revertTask.cancel();
|
||||
}
|
||||
player.setScoreboard(board);
|
||||
|
||||
player.setScoreboard(scoreboard);
|
||||
revertTask = null;
|
||||
}
|
||||
|
||||
public void showBoardAndScheduleRevert(int ticks) {
|
||||
Player player = Bukkit.getPlayerExact(playerName);
|
||||
Player player = mcMMO.p.getServer().getPlayerExact(playerName);
|
||||
|
||||
if (player == null) {
|
||||
ScoreboardManager.cleanup(this);
|
||||
return;
|
||||
@ -188,7 +190,8 @@ public class ScoreboardWrapper {
|
||||
if (revertTask != null) {
|
||||
revertTask.cancel();
|
||||
}
|
||||
player.setScoreboard(board);
|
||||
|
||||
player.setScoreboard(scoreboard);
|
||||
revertTask = new ScoreboardChangeTask().runTaskLater(mcMMO.p, ticks);
|
||||
|
||||
// TODO is there any way to do the time that looks acceptable?
|
||||
@ -204,14 +207,15 @@ public class ScoreboardWrapper {
|
||||
}
|
||||
|
||||
public void tryRevertBoard() {
|
||||
Player player = Bukkit.getPlayerExact(playerName);
|
||||
Player player = mcMMO.p.getServer().getPlayerExact(playerName);
|
||||
|
||||
if (player == null) {
|
||||
ScoreboardManager.cleanup(this);
|
||||
return;
|
||||
}
|
||||
|
||||
if (oldBoard != null) {
|
||||
if (player.getScoreboard() == board) {
|
||||
if (player.getScoreboard() == scoreboard) {
|
||||
player.setScoreboard(oldBoard);
|
||||
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!)");
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Was already reverted
|
||||
}
|
||||
|
||||
if (revertTask != null) {
|
||||
revertTask.cancel();
|
||||
revertTask = null;
|
||||
}
|
||||
cancelRevert();
|
||||
|
||||
sidebarType = SidebarType.NONE;
|
||||
targetPlayer = null;
|
||||
targetSkill = null;
|
||||
@ -235,19 +234,22 @@ public class ScoreboardWrapper {
|
||||
}
|
||||
|
||||
public boolean isBoardShown() {
|
||||
Player player = Bukkit.getPlayerExact(playerName);
|
||||
Player player = mcMMO.p.getServer().getPlayerExact(playerName);
|
||||
|
||||
if (player == null) {
|
||||
ScoreboardManager.cleanup(this);
|
||||
return false;
|
||||
}
|
||||
|
||||
return player.getScoreboard() == board;
|
||||
return player.getScoreboard() == scoreboard;
|
||||
}
|
||||
|
||||
public void cancelRevert() {
|
||||
if (revertTask != null) {
|
||||
revertTask.cancel();
|
||||
if (revertTask == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
revertTask.cancel();
|
||||
revertTask = null;
|
||||
}
|
||||
|
||||
@ -358,17 +360,18 @@ public class ScoreboardWrapper {
|
||||
|
||||
// Setup for after a board type change
|
||||
protected void loadObjective(String displayName) {
|
||||
sidebarObj.unregister();
|
||||
sidebarObj = board.registerNewObjective(ScoreboardManager.SIDEBAR_OBJECTIVE, "dummy");
|
||||
sidebarObjective.unregister();
|
||||
sidebarObjective = scoreboard.registerNewObjective(ScoreboardManager.SIDEBAR_OBJECTIVE, "dummy");
|
||||
|
||||
if (displayName.length() > 32) {
|
||||
displayName = displayName.substring(0, 32);
|
||||
}
|
||||
sidebarObj.setDisplayName(displayName);
|
||||
|
||||
sidebarObjective.setDisplayName(displayName);
|
||||
|
||||
updateSidebar();
|
||||
// Do last! Minimize packets!
|
||||
sidebarObj.setDisplaySlot(DisplaySlot.SIDEBAR);
|
||||
sidebarObjective.setDisplaySlot(DisplaySlot.SIDEBAR);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -377,21 +380,24 @@ public class ScoreboardWrapper {
|
||||
private void updateSidebar() {
|
||||
try {
|
||||
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;
|
||||
|
||||
if (sidebarType == SidebarType.NONE) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player bukkitPlayer = Bukkit.getPlayerExact(playerName);
|
||||
if (bukkitPlayer == null) {
|
||||
Player player = mcMMO.p.getServer().getPlayerExact(playerName);
|
||||
|
||||
if (player == null) {
|
||||
ScoreboardManager.cleanup(this);
|
||||
return;
|
||||
}
|
||||
|
||||
McMMOPlayer mcPlayer = UserManager.getPlayer(bukkitPlayer);
|
||||
PlayerProfile profile = mcPlayer.getProfile();
|
||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||
PlayerProfile profile = mcMMOPlayer.getProfile();
|
||||
|
||||
switch (sidebarType) {
|
||||
case NONE:
|
||||
@ -399,65 +405,66 @@ public class ScoreboardWrapper {
|
||||
|
||||
case SKILL_BOARD:
|
||||
Validate.notNull(targetSkill);
|
||||
|
||||
if (!targetSkill.isChildSkill()) {
|
||||
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 {
|
||||
Set<SkillType> parents = FamilyTree.getParents(targetSkill);
|
||||
for (SkillType parentSkill : parents) {
|
||||
sidebarObj.getScore(ScoreboardManager.skillLabels.get(parentSkill)).setScore(profile.getSkillLevel(parentSkill));
|
||||
for (SkillType parentSkill : FamilyTree.getParents(targetSkill)) {
|
||||
sidebarObjective.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 != SkillType.MINING) {
|
||||
AbilityType ab = targetSkill.getAbility();
|
||||
Score cooldown = sidebarObj.getScore(ScoreboardManager.abilityLabelsSkill.get(ab));
|
||||
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 {
|
||||
boolean stopUpdating;
|
||||
|
||||
if (targetSkill == SkillType.MINING) {
|
||||
// Special-Case: Mining has two abilities, both with cooldowns
|
||||
AbilityType sb = AbilityType.SUPER_BREAKER;
|
||||
AbilityType bm = AbilityType.BLAST_MINING;
|
||||
Score cooldownSB = sidebarObj.getScore(ScoreboardManager.abilityLabelsSkill.get(sb));
|
||||
Score cooldownBM = sidebarObj.getScore(ScoreboardManager.abilityLabelsSkill.get(bm));
|
||||
int secondsSB = SkillUtils.calculateTimeLeft(sb, profile, bukkitPlayer);
|
||||
int secondsBM = SkillUtils.calculateTimeLeft(bm, profile, bukkitPlayer);
|
||||
secondsSB = (secondsSB <= 0) ? 0 : secondsSB;
|
||||
secondsBM = (secondsBM <= 0) ? 0 : secondsBM;
|
||||
if (secondsSB == 0 && secondsBM == 0) {
|
||||
cooldownSB.setScore(0);
|
||||
cooldownBM.setScore(0);
|
||||
stopCooldownUpdating();
|
||||
}
|
||||
else {
|
||||
cooldownSB.setScore(secondsSB);
|
||||
cooldownBM.setScore(secondsBM);
|
||||
startCooldownUpdating();
|
||||
}
|
||||
Score cooldownSB = sidebarObjective.getScore(ScoreboardManager.abilityLabelsSkill.get(AbilityType.SUPER_BREAKER));
|
||||
Score cooldownBM = sidebarObjective.getScore(ScoreboardManager.abilityLabelsSkill.get(AbilityType.BLAST_MINING));
|
||||
int secondsSB = Math.max(SkillUtils.calculateTimeLeft(AbilityType.SUPER_BREAKER, profile, player), 0);
|
||||
int secondsBM = Math.max(SkillUtils.calculateTimeLeft(AbilityType.BLAST_MINING, profile, player), 0);
|
||||
|
||||
cooldownSB.setScore(secondsSB);
|
||||
cooldownBM.setScore(secondsBM);
|
||||
|
||||
stopUpdating = (secondsSB == 0 && secondsBM == 0);
|
||||
}
|
||||
else {
|
||||
AbilityType ability = targetSkill.getAbility();
|
||||
Score cooldown = sidebarObjective.getScore(ScoreboardManager.abilityLabelsSkill.get(ability));
|
||||
int seconds = Math.max(SkillUtils.calculateTimeLeft(ability, profile, player), 0);
|
||||
|
||||
cooldown.setScore(seconds);
|
||||
|
||||
stopUpdating = seconds == 0;
|
||||
}
|
||||
|
||||
if (stopUpdating) {
|
||||
stopCooldownUpdating();
|
||||
}
|
||||
else {
|
||||
startCooldownUpdating();
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case COOLDOWNS_BOARD:
|
||||
boolean anyCooldownsActive = false;
|
||||
|
||||
for (AbilityType ability : AbilityType.NORMAL_ABILITIES) {
|
||||
int seconds = SkillUtils.calculateTimeLeft(ability, profile, bukkitPlayer);
|
||||
seconds = (seconds <= 0) ? 0 : seconds;
|
||||
int seconds = Math.max(SkillUtils.calculateTimeLeft(ability, profile, player), 0);
|
||||
|
||||
if (seconds != 0) {
|
||||
anyCooldownsActive = true;
|
||||
}
|
||||
sidebarObj.getScore(ScoreboardManager.abilityLabelsColored.get(ability)).setScore(seconds);
|
||||
|
||||
sidebarObjective.getScore(ScoreboardManager.abilityLabelsColored.get(ability)).setScore(seconds);
|
||||
}
|
||||
|
||||
if (anyCooldownsActive) {
|
||||
@ -470,30 +477,35 @@ public class ScoreboardWrapper {
|
||||
|
||||
case STATS_BOARD:
|
||||
// Select the profile to read from
|
||||
PlayerProfile prof;
|
||||
PlayerProfile newProfile;
|
||||
|
||||
if (targetProfile != null) {
|
||||
prof = targetProfile; // offline
|
||||
newProfile = targetProfile; // offline
|
||||
}
|
||||
else if (targetPlayer == null) {
|
||||
prof = profile; // self
|
||||
newProfile = profile; // self
|
||||
}
|
||||
else {
|
||||
prof = UserManager.getPlayer(targetPlayer).getProfile(); // online
|
||||
newProfile = UserManager.getPlayer(targetPlayer).getProfile(); // online
|
||||
}
|
||||
|
||||
// Calculate power level here
|
||||
int powerLevel = 0;
|
||||
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())
|
||||
powerLevel += level;
|
||||
|
||||
// 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;
|
||||
}
|
||||
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;
|
||||
|
||||
case RANK_BOARD:
|
||||
@ -504,40 +516,47 @@ public class ScoreboardWrapper {
|
||||
*/
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void acceptRankData(Map<SkillType, Integer> rankData) {
|
||||
Integer rank;
|
||||
Player bukkitPlayer = Bukkit.getPlayerExact(playerName);
|
||||
Player player = mcMMO.p.getServer().getPlayerExact(playerName);
|
||||
|
||||
for (SkillType skill : SkillType.NON_CHILD_SKILLS) {
|
||||
if (!Permissions.skillEnabled(bukkitPlayer, skill)) {
|
||||
if (!skill.getPermissions(player)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
rank = rankData.get(skill);
|
||||
|
||||
if (rank != null) {
|
||||
sidebarObj.getScore(ScoreboardManager.skillLabels.get(skill)).setScore(rank);
|
||||
sidebarObjective.getScore(ScoreboardManager.skillLabels.get(skill)).setScore(rank);
|
||||
}
|
||||
}
|
||||
|
||||
rank = rankData.get(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) {
|
||||
for (PlayerStat stat : leaderboardData) {
|
||||
String statname = stat.name;
|
||||
if (statname.equals(playerName)) {
|
||||
statname = ChatColor.GOLD + "--You--";
|
||||
String name = stat.name;
|
||||
|
||||
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) {
|
||||
powerObj.getScore(leveledPlayer).setScore(newPowerLevel);
|
||||
public void updatePowerLevel(Player player, int newPowerLevel) {
|
||||
powerObjective.getScore(player).setScore(newPowerLevel);
|
||||
}
|
||||
}
|
||||
|
@ -224,7 +224,7 @@ public final class CombatUtils {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Permissions.skillEnabled(player, SkillType.SWORDS)) {
|
||||
if (SkillType.SWORDS.getPermissions(player)) {
|
||||
processSwordCombat(target, player, event.getDamage());
|
||||
}
|
||||
}
|
||||
@ -233,7 +233,7 @@ public final class CombatUtils {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Permissions.skillEnabled(player, SkillType.AXES)) {
|
||||
if (SkillType.AXES.getPermissions(player)) {
|
||||
processAxeCombat(target, player, event);
|
||||
}
|
||||
}
|
||||
@ -242,7 +242,7 @@ public final class CombatUtils {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Permissions.skillEnabled(player, SkillType.UNARMED)) {
|
||||
if (SkillType.UNARMED.getPermissions(player)) {
|
||||
processUnarmedCombat(target, player, event);
|
||||
}
|
||||
}
|
||||
@ -260,7 +260,7 @@ public final class CombatUtils {
|
||||
if (tamer != null && tamer instanceof Player && shouldProcessSkill(target, SkillType.TAMING)) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
@ -272,7 +272,7 @@ public final class CombatUtils {
|
||||
if (shooter != null && shooter instanceof Player && shouldProcessSkill(target, SkillType.ARCHERY)) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -74,7 +74,6 @@ Axes.Effect.8=Greater Impact
|
||||
Axes.Effect.9=Deal bonus damage to unarmored foes
|
||||
Axes.Listener=Axes:
|
||||
Axes.SkillName=AXES
|
||||
Axes.Skills.SS.Name=Skull Splitter
|
||||
Axes.Skills.SS.Off=[[RED]]**Skull Splitter has worn off**
|
||||
Axes.Skills.SS.On=[[GREEN]]**Skull Splitter ACTIVATED**
|
||||
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.Listener=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.On=[[GREEN]]**GIGA DRILL BREAKER ACTIVATED**
|
||||
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.Listener=Herbalism:
|
||||
Herbalism.SkillName=HERBALISM
|
||||
Herbalism.Skills.GTe.Name=Green Terra
|
||||
Herbalism.Skills.GTe.Off=[[RED]]**Green Terra has worn off**
|
||||
Herbalism.Skills.GTe[[RED]]**Green Terra has worn off**
|
||||
Herbalism.Skills.GTe.On=[[GREEN]]**GREEN TERRA ACTIVATED**
|
||||
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}
|
||||
@ -193,7 +190,6 @@ Mining.Effect.Decrease=[[RED]]Demolitions Expert Damage Decrease: [[YELLOW]]{0}
|
||||
Mining.Effect.DropChance=[[RED]]Double Drop Chance: [[YELLOW]]{0}
|
||||
Mining.Listener=Mining:
|
||||
Mining.SkillName=MINING
|
||||
Mining.Skills.SuperBreaker.Name=Super Breaker
|
||||
Mining.Skills.SuperBreaker.Off=[[RED]]**Super Breaker has worn off**
|
||||
Mining.Skills.SuperBreaker.On=[[GREEN]]**SUPER BREAKER ACTIVATED**
|
||||
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})
|
||||
|
||||
#Blast Mining
|
||||
Mining.Blast.Name=Blast Mining
|
||||
Mining.Blast.Boom=[[GRAY]]**BOOM**
|
||||
Mining.Blast.Effect=+{0} ore yield, -{1} debris yield, {2}x drops
|
||||
Mining.Blast.Radius.Increase=[[RED]]Blast Radius Increase: [[YELLOW]]+{0}
|
||||
@ -283,7 +278,6 @@ Swords.Effect.6=Bleed
|
||||
Swords.Effect.7=Apply a bleed DoT
|
||||
Swords.Listener=Swords:
|
||||
Swords.SkillName=SWORDS
|
||||
Swords.Skills.SS.Name=Serrated Strikes
|
||||
Swords.Skills.SS.Off=[[RED]]**Serrated Strikes has worn off**
|
||||
Swords.Skills.SS.On=[[GREEN]]**SERRATED STRIKES ACTIVATED**
|
||||
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.Listener=Unarmed:
|
||||
Unarmed.SkillName=UNARMED
|
||||
Unarmed.Skills.Berserk.Name=Berserk
|
||||
Unarmed.Skills.Berserk.Off=[[RED]]**Berserk has worn off**
|
||||
Unarmed.Skills.Berserk.On=[[GREEN]]**BERSERK ACTIVATED**
|
||||
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.Listener=Woodcutting:
|
||||
Woodcutting.SkillName=WOODCUTTING
|
||||
Woodcutting.Skills.TreeFeller.Name=Tree Feller
|
||||
Woodcutting.Skills.TreeFeller.Off=[[RED]]**Tree Feller has worn off**
|
||||
Woodcutting.Skills.TreeFeller.On=[[GREEN]]**TREE FELLER ACTIVATED**
|
||||
Woodcutting.Skills.TreeFeller.Refresh=[[GREEN]]Your [[YELLOW]]Tree Feller [[GREEN]]ability is refreshed!
|
||||
|
Loading…
Reference in New Issue
Block a user