mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 23:26:45 +01:00
Removed needs for SkillType.ALL
Also apparently made /Skillreset work on offline players and fixed missing permissions check
This commit is contained in:
parent
458f7f5f5b
commit
35cdcb62b7
@ -21,7 +21,7 @@ Version 1.4.00-dev
|
|||||||
+ Added ability to config Hylian Luck drops through treasures.yml
|
+ Added ability to config Hylian Luck drops through treasures.yml
|
||||||
+ Added party XP sharing
|
+ Added party XP sharing
|
||||||
+ Added vanilla XP boost for Fishing - includes permissions, config options, etc
|
+ Added vanilla XP boost for Fishing - includes permissions, config options, etc
|
||||||
= Fixed /addlevels not working properly on offline players
|
= Fixed multiple commands not working properly on offline players
|
||||||
= Fixed /mmoedit not giving feedback when modifying another players stats
|
= Fixed /mmoedit not giving feedback when modifying another players stats
|
||||||
= Fixed the guide usage string showing up every time /skillname was called
|
= Fixed the guide usage string showing up every time /skillname was called
|
||||||
= Fixed Spout not being able to precache our resources properly, and therefore making our XP bars fail
|
= Fixed Spout not being able to precache our resources properly, and therefore making our XP bars fail
|
||||||
|
@ -18,12 +18,7 @@ public final class ExperienceAPI {
|
|||||||
* @deprecated Calling this function is no longer needed and should be avoided
|
* @deprecated Calling this function is no longer needed and should be avoided
|
||||||
*/
|
*/
|
||||||
private static void checkXP(Player player, SkillType skillType) {
|
private static void checkXP(Player player, SkillType skillType) {
|
||||||
if (skillType.equals(SkillType.ALL)) {
|
SkillTools.xpCheckSkill(skillType, player, Users.getProfile(player));
|
||||||
SkillTools.xpCheckAll(player, Users.getProfile(player));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
SkillTools.xpCheckSkill(skillType, player, Users.getProfile(player));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -35,84 +35,82 @@ public final class CommandRegistrationHelper {
|
|||||||
|
|
||||||
public static void registerSkillCommands() {
|
public static void registerSkillCommands() {
|
||||||
for (SkillType skill : SkillType.values()) {
|
for (SkillType skill : SkillType.values()) {
|
||||||
if (skill != SkillType.ALL) {
|
String commandName = skill.toString().toLowerCase();
|
||||||
String commandName = skill.toString().toLowerCase();
|
String localizedName = LocaleLoader.getString(Misc.getCapitalized(commandName) + ".SkillName").toLowerCase();
|
||||||
String localizedName = LocaleLoader.getString(Misc.getCapitalized(commandName) + ".SkillName").toLowerCase();
|
|
||||||
|
|
||||||
List<String> aliasList = new ArrayList<String>();
|
List<String> aliasList = new ArrayList<String>();
|
||||||
aliasList.add(localizedName);
|
aliasList.add(localizedName);
|
||||||
|
|
||||||
PluginCommand command;
|
PluginCommand command;
|
||||||
|
|
||||||
// Make us play nice with Essentials
|
// Make us play nice with Essentials
|
||||||
if (skill == SkillType.REPAIR && mcMMO.p.getServer().getPluginManager().isPluginEnabled("Essentials")) {
|
if (skill == SkillType.REPAIR && mcMMO.p.getServer().getPluginManager().isPluginEnabled("Essentials")) {
|
||||||
command = mcMMO.p.getCommand("mcrepair");
|
command = mcMMO.p.getCommand("mcrepair");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
command = mcMMO.p.getCommand(commandName);
|
command = mcMMO.p.getCommand(commandName);
|
||||||
}
|
}
|
||||||
|
|
||||||
command.setAliases(aliasList);
|
command.setAliases(aliasList);
|
||||||
command.setDescription(LocaleLoader.getString("Commands.Description.Skill", Misc.getCapitalized(localizedName)));
|
command.setDescription(LocaleLoader.getString("Commands.Description.Skill", Misc.getCapitalized(localizedName)));
|
||||||
command.setPermission("mcmmo.commands." + commandName);
|
command.setPermission("mcmmo.commands." + commandName);
|
||||||
command.setPermissionMessage(permissionsMessage);
|
command.setPermissionMessage(permissionsMessage);
|
||||||
|
|
||||||
switch (skill) {
|
switch (skill) {
|
||||||
case ACROBATICS:
|
case ACROBATICS:
|
||||||
command.setExecutor(new AcrobaticsCommand());
|
command.setExecutor(new AcrobaticsCommand());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ARCHERY:
|
case ARCHERY:
|
||||||
command.setExecutor(new ArcheryCommand());
|
command.setExecutor(new ArcheryCommand());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case AXES:
|
case AXES:
|
||||||
command.setExecutor(new AxesCommand());
|
command.setExecutor(new AxesCommand());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EXCAVATION:
|
case EXCAVATION:
|
||||||
command.setExecutor(new ExcavationCommand());
|
command.setExecutor(new ExcavationCommand());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FISHING:
|
case FISHING:
|
||||||
command.setExecutor(new FishingCommand());
|
command.setExecutor(new FishingCommand());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HERBALISM:
|
case HERBALISM:
|
||||||
command.setExecutor(new HerbalismCommand());
|
command.setExecutor(new HerbalismCommand());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MINING:
|
case MINING:
|
||||||
command.setExecutor(new MiningCommand());
|
command.setExecutor(new MiningCommand());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case REPAIR:
|
case REPAIR:
|
||||||
command.setExecutor(new RepairCommand());
|
command.setExecutor(new RepairCommand());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SMELTING:
|
case SMELTING:
|
||||||
command.setExecutor(new SmeltingCommand());
|
command.setExecutor(new SmeltingCommand());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SWORDS:
|
case SWORDS:
|
||||||
command.setExecutor(new SwordsCommand());
|
command.setExecutor(new SwordsCommand());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TAMING:
|
case TAMING:
|
||||||
command.setExecutor(new TamingCommand());
|
command.setExecutor(new TamingCommand());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case UNARMED:
|
case UNARMED:
|
||||||
command.setExecutor(new UnarmedCommand());
|
command.setExecutor(new UnarmedCommand());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WOODCUTTING:
|
case WOODCUTTING:
|
||||||
command.setExecutor(new WoodcuttingCommand());
|
command.setExecutor(new WoodcuttingCommand());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ public class AddlevelsCommand implements CommandExecutor{
|
|||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
PlayerProfile profile;
|
PlayerProfile profile;
|
||||||
int levels;
|
int levels;
|
||||||
SkillType skill;
|
boolean allSkills = false;
|
||||||
|
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 2:
|
case 2:
|
||||||
@ -27,7 +27,10 @@ public class AddlevelsCommand implements CommandExecutor{
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!SkillTools.isSkill(args[0])) {
|
if (args[0].equalsIgnoreCase("all")) {
|
||||||
|
allSkills = true;
|
||||||
|
}
|
||||||
|
else if (!SkillTools.isSkill(args[0])) {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -37,17 +40,28 @@ public class AddlevelsCommand implements CommandExecutor{
|
|||||||
}
|
}
|
||||||
|
|
||||||
levels = Integer.valueOf(args[1]);
|
levels = Integer.valueOf(args[1]);
|
||||||
skill = SkillTools.getSkillType(args[0]);
|
|
||||||
profile = Users.getPlayer((Player) sender).getProfile();
|
profile = Users.getPlayer((Player) sender).getProfile();
|
||||||
|
|
||||||
if (skill.equals(SkillType.ALL)) {
|
if (allSkills) {
|
||||||
|
for (SkillType skillType : SkillType.values()) {
|
||||||
|
if (skillType.isChildSkill()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
profile.addLevels(skillType, levels);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
profile.addLevels(SkillTools.getSkillType(args[0]), levels);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (allSkills) {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.1", levels));
|
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.1", levels));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.1", levels, Misc.getCapitalized(skill.toString())));
|
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.1", levels, Misc.getCapitalized(args[0])));
|
||||||
}
|
}
|
||||||
|
|
||||||
profile.addLevels(skill, levels);
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
@ -56,7 +70,10 @@ public class AddlevelsCommand implements CommandExecutor{
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!SkillTools.isSkill(args[1])) {
|
if (args[1].equalsIgnoreCase("all")) {
|
||||||
|
allSkills = true;
|
||||||
|
}
|
||||||
|
else if (!SkillTools.isSkill(args[1])) {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -67,7 +84,6 @@ public class AddlevelsCommand implements CommandExecutor{
|
|||||||
|
|
||||||
McMMOPlayer mcMMOPlayer = Users.getPlayer(args[0]);
|
McMMOPlayer mcMMOPlayer = Users.getPlayer(args[0]);
|
||||||
levels = Integer.valueOf(args[2]);
|
levels = Integer.valueOf(args[2]);
|
||||||
skill = SkillTools.getSkillType(args[1]);
|
|
||||||
|
|
||||||
// If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process.
|
// If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process.
|
||||||
if (mcMMOPlayer == null) {
|
if (mcMMOPlayer == null) {
|
||||||
@ -78,31 +94,46 @@ public class AddlevelsCommand implements CommandExecutor{
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
profile.addLevels(skill, levels);
|
if (allSkills) {
|
||||||
|
for (SkillType skillType : SkillType.values()) {
|
||||||
|
if (skillType.isChildSkill()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
profile.addLevels(skillType, levels);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
profile.addLevels(SkillTools.getSkillType(args[1]), levels);
|
||||||
|
}
|
||||||
|
|
||||||
profile.save(); // Since this is a temporary profile, we save it here.
|
profile.save(); // Since this is a temporary profile, we save it here.
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
profile = mcMMOPlayer.getProfile();
|
profile = mcMMOPlayer.getProfile();
|
||||||
Player player = mcMMOPlayer.getPlayer();
|
|
||||||
|
|
||||||
profile.addLevels(skill, levels);
|
if (allSkills) {
|
||||||
|
for (SkillType skillType : SkillType.values()) {
|
||||||
|
if (skillType.isChildSkill()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// Check if the player is online before we try to send them a message.
|
profile.addLevels(skillType, levels);
|
||||||
if (player.isOnline()) {
|
|
||||||
if (skill.equals(SkillType.ALL)) {
|
|
||||||
player.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.1", levels));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
player.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.1", levels, Misc.getCapitalized(skill.toString())));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.1", levels));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
profile.addLevels(SkillTools.getSkillType(args[1]), levels);
|
||||||
|
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.1", levels, Misc.getCapitalized(args[1])));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (skill.equals(SkillType.ALL)) {
|
if (allSkills) {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", args[0]));
|
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", args[0]));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.2", Misc.getCapitalized(skill.toString()), args[0]));
|
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.2", Misc.getCapitalized(args[1]), args[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -17,11 +17,10 @@ import com.gmail.nossr50.util.Users;
|
|||||||
public class AddxpCommand implements CommandExecutor {
|
public class AddxpCommand implements CommandExecutor {
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
Player modifiedPlayer;
|
|
||||||
int xp;
|
int xp;
|
||||||
SkillType skill;
|
|
||||||
McMMOPlayer mcMMOPlayer;
|
McMMOPlayer mcMMOPlayer;
|
||||||
PlayerProfile profile;
|
PlayerProfile profile;
|
||||||
|
boolean allSkills = false;
|
||||||
|
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 2:
|
case 2:
|
||||||
@ -29,7 +28,10 @@ public class AddxpCommand implements CommandExecutor {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!SkillTools.isSkill(args[0])) {
|
if (args[0].equalsIgnoreCase("all")) {
|
||||||
|
allSkills = true;
|
||||||
|
}
|
||||||
|
else if (!SkillTools.isSkill(args[0])) {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -39,25 +41,23 @@ public class AddxpCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
xp = Integer.valueOf(args[1]);
|
xp = Integer.valueOf(args[1]);
|
||||||
skill = SkillTools.getSkillType(args[0]);
|
mcMMOPlayer = Users.getPlayer((Player) sender);
|
||||||
modifiedPlayer = (Player) sender;
|
|
||||||
mcMMOPlayer = Users.getPlayer(modifiedPlayer);
|
|
||||||
profile = mcMMOPlayer.getProfile();
|
profile = mcMMOPlayer.getProfile();
|
||||||
|
|
||||||
if (skill.equals(SkillType.ALL)) {
|
if (allSkills) {
|
||||||
for (SkillType type : SkillType.values()) {
|
for (SkillType skillType : SkillType.values()) {
|
||||||
if (type.equals(SkillType.ALL) || type.isChildSkill()) {
|
if (skillType.isChildSkill()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
mcMMOPlayer.applyXpGain(type, xp);
|
mcMMOPlayer.applyXpGain(skillType, xp);
|
||||||
}
|
}
|
||||||
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.addxp.AwardAll", xp));
|
sender.sendMessage(LocaleLoader.getString("Commands.addxp.AwardAll", xp));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
mcMMOPlayer.applyXpGain(skill, xp);
|
mcMMOPlayer.applyXpGain(SkillTools.getSkillType(args[0]), xp);
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.addxp.AwardSkill", xp, Misc.getCapitalized(skill.toString())));
|
sender.sendMessage(LocaleLoader.getString("Commands.addxp.AwardSkill", xp, Misc.getCapitalized(args[0])));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -68,7 +68,10 @@ public class AddxpCommand implements CommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!SkillTools.isSkill(args[1])) {
|
if (args[1].equalsIgnoreCase("all")) {
|
||||||
|
allSkills = true;
|
||||||
|
}
|
||||||
|
else if (!SkillTools.isSkill(args[1])) {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -79,7 +82,6 @@ public class AddxpCommand implements CommandExecutor {
|
|||||||
|
|
||||||
mcMMOPlayer = Users.getPlayer(args[0]);
|
mcMMOPlayer = Users.getPlayer(args[0]);
|
||||||
xp = Integer.valueOf(args[2]);
|
xp = Integer.valueOf(args[2]);
|
||||||
skill = SkillTools.getSkillType(args[1]);
|
|
||||||
|
|
||||||
// If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process.
|
// If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process.
|
||||||
if (mcMMOPlayer == null) {
|
if (mcMMOPlayer == null) {
|
||||||
@ -91,53 +93,44 @@ public class AddxpCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Currently the offline player doesn't level up automatically
|
// TODO: Currently the offline player doesn't level up automatically
|
||||||
if (skill.equals(SkillType.ALL)) {
|
if (allSkills) {
|
||||||
for (SkillType type : SkillType.values()) {
|
for (SkillType skillType : SkillType.values()) {
|
||||||
if (type.equals(SkillType.ALL) || type.isChildSkill()) {
|
if (skillType.isChildSkill()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
profile.setSkillXpLevel(type, profile.getSkillXpLevel(type) + xp);
|
profile.setSkillXpLevel(skillType, xp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
profile.setSkillXpLevel(skill, profile.getSkillXpLevel(skill) + xp);
|
profile.setSkillXpLevel(SkillTools.getSkillType(args[1]), xp);
|
||||||
}
|
}
|
||||||
|
|
||||||
profile.save(); // Since this is a temporary profile, we save it here.
|
profile.save(); // Since this is a temporary profile, we save it here.
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (skill.equals(SkillType.ALL)) {
|
if (allSkills) {
|
||||||
for (SkillType type : SkillType.values()) {
|
for (SkillType skillType : SkillType.values()) {
|
||||||
if (type.equals(SkillType.ALL) || type.isChildSkill()) {
|
if (skillType.isChildSkill()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
mcMMOPlayer.applyXpGain(type, xp);
|
mcMMOPlayer.applyXpGain(skillType, xp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.addxp.AwardAll", xp));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
mcMMOPlayer.applyXpGain(skill, xp);
|
mcMMOPlayer.applyXpGain(SkillTools.getSkillType(args[1]), xp);
|
||||||
}
|
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.addxp.AwardSkill", xp, Misc.getCapitalized(args[1])));
|
||||||
|
|
||||||
modifiedPlayer = mcMMOPlayer.getPlayer();
|
|
||||||
|
|
||||||
|
|
||||||
if (modifiedPlayer.isOnline()) {
|
|
||||||
if (skill.equals(SkillType.ALL)) {
|
|
||||||
modifiedPlayer.sendMessage(LocaleLoader.getString("Commands.addxp.AwardAll", xp));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
modifiedPlayer.sendMessage(LocaleLoader.getString("Commands.addxp.AwardSkill", xp, Misc.getCapitalized(skill.toString())));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (skill.equals(SkillType.ALL)) {
|
if (allSkills) {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", args[0]));
|
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", args[0]));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.2", Misc.getCapitalized(skill.toString()), args[0]));
|
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.2", Misc.getCapitalized(args[1]), args[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -19,7 +19,7 @@ public class MmoeditCommand implements CommandExecutor {
|
|||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
PlayerProfile profile;
|
PlayerProfile profile;
|
||||||
int newValue;
|
int newValue;
|
||||||
SkillType skill;
|
boolean allSkills = false;
|
||||||
|
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 2:
|
case 2:
|
||||||
@ -27,7 +27,10 @@ public class MmoeditCommand implements CommandExecutor {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!SkillTools.isSkill(args[0])) {
|
if (args[0].equalsIgnoreCase("all")) {
|
||||||
|
allSkills = true;
|
||||||
|
}
|
||||||
|
else if (!SkillTools.isSkill(args[0])) {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -37,26 +40,36 @@ public class MmoeditCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
newValue = Integer.valueOf(args[1]);
|
newValue = Integer.valueOf(args[1]);
|
||||||
skill = SkillTools.getSkillType(args[0]);
|
|
||||||
profile = Users.getPlayer((Player) sender).getProfile();
|
profile = Users.getPlayer((Player) sender).getProfile();
|
||||||
|
|
||||||
if (skill == SkillType.ALL) {
|
if (allSkills) {
|
||||||
|
for (SkillType skillType : SkillType.values()) {
|
||||||
|
if (skillType.isChildSkill()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
profile.modifySkill(skillType, newValue);
|
||||||
|
}
|
||||||
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.mmoedit.AllSkills.1", newValue));
|
sender.sendMessage(LocaleLoader.getString("Commands.mmoedit.AllSkills.1", newValue));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.1", Misc.getCapitalized(skill.toString()), newValue));
|
profile.modifySkill(SkillTools.getSkillType(args[0]), newValue);
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.1", Misc.getCapitalized(args[0]), newValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
profile.modifySkill(skill, newValue);
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
if (Permissions.hasPermission(sender, "mcmmo.commands.mmoedit.others")) {
|
if (!Permissions.hasPermission(sender, "mcmmo.commands.mmoedit.others")) {
|
||||||
sender.sendMessage(command.getPermissionMessage());
|
sender.sendMessage(command.getPermissionMessage());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!SkillTools.isSkill(args[1])) {
|
if (args[1].equalsIgnoreCase("all")) {
|
||||||
|
allSkills = true;
|
||||||
|
}
|
||||||
|
else if (!SkillTools.isSkill(args[1])) {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -66,43 +79,57 @@ public class MmoeditCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
newValue = Integer.valueOf(args[2]);
|
newValue = Integer.valueOf(args[2]);
|
||||||
skill = SkillTools.getSkillType(args[1]);
|
|
||||||
McMMOPlayer mcMMOPlayer = Users.getPlayer(args[0]);
|
McMMOPlayer mcMMOPlayer = Users.getPlayer(args[0]);
|
||||||
|
|
||||||
// If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process.
|
// If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process.
|
||||||
if (mcMMOPlayer == null) {
|
if (mcMMOPlayer == null) {
|
||||||
profile = new PlayerProfile(args[0], false); //Temporary Profile
|
profile = new PlayerProfile(args[0], false);
|
||||||
|
|
||||||
if (!profile.isLoaded()) {
|
if (!profile.isLoaded()) {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
profile.modifySkill(skill, newValue);
|
if (allSkills) {
|
||||||
|
for (SkillType skillType : SkillType.values()) {
|
||||||
|
if (skillType.isChildSkill()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
profile.modifySkill(skillType, newValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
profile.modifySkill(SkillTools.getSkillType(args[1]), newValue);
|
||||||
|
}
|
||||||
|
|
||||||
profile.save(); // Since this is a temporary profile, we save it here.
|
profile.save(); // Since this is a temporary profile, we save it here.
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
profile = mcMMOPlayer.getProfile();
|
profile = mcMMOPlayer.getProfile();
|
||||||
Player player = mcMMOPlayer.getPlayer();
|
|
||||||
|
|
||||||
profile.modifySkill(skill, newValue);
|
if (allSkills) {
|
||||||
|
for (SkillType skillType : SkillType.values()) {
|
||||||
|
if (skillType.isChildSkill()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// Check if the player is online before we try to send them a message.
|
profile.modifySkill(skillType, newValue);
|
||||||
if (player.isOnline()) {
|
|
||||||
if (skill == SkillType.ALL) {
|
|
||||||
player.sendMessage(LocaleLoader.getString("Commands.mmoedit.AllSkills.1", newValue));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
player.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.1", Misc.getCapitalized(skill.toString()), newValue));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.mmoedit.AllSkills.1", newValue));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
profile.modifySkill(SkillTools.getSkillType(args[1]), newValue);
|
||||||
|
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.1", Misc.getCapitalized(args[1]), newValue));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (skill == SkillType.ALL) {
|
if (allSkills) {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", args[0]));
|
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", args[0]));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.2", Misc.getCapitalized(skill.toString()), args[0]));
|
sender.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.2", Misc.getCapitalized(args[1]), args[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -18,7 +18,7 @@ public class SkillresetCommand implements CommandExecutor {
|
|||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
PlayerProfile profile;
|
PlayerProfile profile;
|
||||||
SkillType skill;
|
boolean allSkills = false;
|
||||||
|
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 1:
|
case 1:
|
||||||
@ -26,48 +26,79 @@ public class SkillresetCommand implements CommandExecutor {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!SkillTools.isSkill(args[0])) {
|
if (args[0].equalsIgnoreCase("all")) {
|
||||||
|
allSkills = true;
|
||||||
|
}
|
||||||
|
else if (!SkillTools.isSkill(args[0])) {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
skill = SkillTools.getSkillType(args[0]);
|
if (allSkills) {
|
||||||
|
for (SkillType skillType : SkillType.values()) {
|
||||||
|
if (skillType.isChildSkill()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (skill != SkillType.ALL && !Permissions.hasPermission(sender, "mcmmo.commands.skillreset." + skill.toString().toLowerCase())) {
|
if (!Permissions.hasPermission(sender, "mcmmo.commands.skillreset." + args[0].toLowerCase())) {
|
||||||
sender.sendMessage(command.getPermissionMessage());
|
sender.sendMessage(command.getPermissionMessage());
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
|
|
||||||
profile = Users.getPlayer((Player) sender).getProfile();
|
|
||||||
|
|
||||||
if (skill == SkillType.ALL) {
|
|
||||||
for (SkillType type : SkillType.values()) {
|
|
||||||
if (type != SkillType.ALL) {
|
|
||||||
if (Permissions.hasPermission(sender, "mcmmo.commands.skillreset." + type.toString().toLowerCase())) {
|
|
||||||
profile.modifySkill(type, 0);
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Reset.Single", Misc.getCapitalized(type.toString())));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
profile.modifySkill(skill, 0);
|
if (!Permissions.hasPermission(sender, "mcmmo.commands.skillreset." + args[0].toLowerCase())) {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Reset.Single", Misc.getCapitalized(skill.toString())));
|
sender.sendMessage(command.getPermissionMessage());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
profile = Users.getPlayer((Player) sender).getProfile();
|
||||||
|
|
||||||
|
if (allSkills) {
|
||||||
|
for (SkillType skillType : SkillType.values()) {
|
||||||
|
if (skillType.isChildSkill()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
profile.modifySkill(skillType, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.Reset.All"));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
profile.modifySkill(SkillTools.getSkillType(args[0]), 0);
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.Reset.Single", Misc.getCapitalized(args[0])));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
if (!SkillTools.isSkill(args[1])) {
|
if (args[1].equalsIgnoreCase("all")) {
|
||||||
|
allSkills = true;
|
||||||
|
}
|
||||||
|
else if (!SkillTools.isSkill(args[1])) {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
skill = SkillTools.getSkillType(args[1]);
|
if (allSkills) {
|
||||||
|
for (SkillType skillType : SkillType.values()) {
|
||||||
|
if (skillType.isChildSkill()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (skill != SkillType.ALL && !Permissions.hasPermission(sender, "mcmmo.commands.skillreset.others." + skill.toString().toLowerCase())) {
|
if (!Permissions.hasPermission(sender, "mcmmo.commands.skillreset." + args[1].toLowerCase())) {
|
||||||
sender.sendMessage(command.getPermissionMessage());
|
sender.sendMessage(command.getPermissionMessage());
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (!Permissions.hasPermission(sender, "mcmmo.commands.skillreset." + args[1].toLowerCase())) {
|
||||||
|
sender.sendMessage(command.getPermissionMessage());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
McMMOPlayer mcMMOPlayer = Users.getPlayer(args[0]);
|
McMMOPlayer mcMMOPlayer = Users.getPlayer(args[0]);
|
||||||
@ -81,45 +112,48 @@ public class SkillresetCommand implements CommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (skill == SkillType.ALL) {
|
if (allSkills) {
|
||||||
for (SkillType type : SkillType.values()) {
|
for (SkillType skillType : SkillType.values()) {
|
||||||
if (type != SkillType.ALL) {
|
if (skillType.isChildSkill()) {
|
||||||
if (Permissions.hasPermission(sender, "mcmmo.commands.skillreset.others" + type.toString().toLowerCase())) {
|
continue;
|
||||||
profile.modifySkill(type, 0);
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.2", Misc.getCapitalized(type.toString()), args[0]));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
profile.modifySkill(skillType, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
profile.modifySkill(skill, 0);
|
profile.modifySkill(SkillTools.getSkillType(args[1]), 0);
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.2", Misc.getCapitalized(skill.toString()), args[0]));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
profile.save(); // Since this is a temporary profile, we save it here.
|
profile.save(); // Since this is a temporary profile, we save it here.
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
profile = mcMMOPlayer.getProfile();
|
profile = mcMMOPlayer.getProfile();
|
||||||
Player player = mcMMOPlayer.getPlayer();
|
|
||||||
|
|
||||||
if (skill == SkillType.ALL) {
|
if (allSkills) {
|
||||||
for (SkillType type : SkillType.values()) {
|
for (SkillType skillType : SkillType.values()) {
|
||||||
if (type != SkillType.ALL) {
|
if (skillType.isChildSkill()) {
|
||||||
if (Permissions.hasPermission(sender, "mcmmo.commands.skillreset.others" + type.toString().toLowerCase())) {
|
continue;
|
||||||
profile.modifySkill(type, 0);
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.2", Misc.getCapitalized(type.toString()), args[0]));
|
|
||||||
player.sendMessage(LocaleLoader.getString("Commands.Reset.Single", Misc.getCapitalized(type.toString())));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
profile.modifySkill(skillType, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.Reset.All"));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
profile.modifySkill(skill, 0);
|
profile.modifySkill(SkillTools.getSkillType(args[1]), 0);
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.2", Misc.getCapitalized(skill.toString()), args[0]));
|
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.Reset.Single", Misc.getCapitalized(args[1])));
|
||||||
player.sendMessage(LocaleLoader.getString("Commands.Reset.Single", Misc.getCapitalized(skill.toString())));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (allSkills) {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", args[0]));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.2", Misc.getCapitalized(args[1]), args[0]));
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -6,6 +6,7 @@ import org.bukkit.command.CommandExecutor;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.commands.CommandHelper;
|
import com.gmail.nossr50.commands.CommandHelper;
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||||
@ -21,10 +22,9 @@ import com.gmail.nossr50.util.Users;
|
|||||||
public class McrankCommand implements CommandExecutor {
|
public class McrankCommand implements CommandExecutor {
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
//TODO: Better input handling, add usage string
|
// TODO: Better input handling, add usage string
|
||||||
|
|
||||||
if (!Config.getInstance().getUseMySQL()) {
|
if (!Config.getInstance().getUseMySQL()) {
|
||||||
Leaderboard.updateLeaderboards(); //Make sure the information is up to date
|
Leaderboard.updateLeaderboards(); // Make sure the information is up to date
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CommandHelper.noConsoleUsage(sender)) {
|
if (CommandHelper.noConsoleUsage(sender)) {
|
||||||
@ -37,6 +37,7 @@ public class McrankCommand implements CommandExecutor {
|
|||||||
|
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
String playerName;
|
String playerName;
|
||||||
|
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 0:
|
case 0:
|
||||||
playerName = player.getName();
|
playerName = player.getName();
|
||||||
@ -48,7 +49,6 @@ public class McrankCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
playerName = args[0];
|
playerName = args[0];
|
||||||
|
|
||||||
McMMOPlayer mcmmoPlayer = Users.getPlayer(playerName);
|
McMMOPlayer mcmmoPlayer = Users.getPlayer(playerName);
|
||||||
|
|
||||||
if (mcmmoPlayer != null) {
|
if (mcmmoPlayer != null) {
|
||||||
@ -83,29 +83,27 @@ public class McrankCommand implements CommandExecutor {
|
|||||||
public void flatfileDisplay(CommandSender sender, String playerName) {
|
public void flatfileDisplay(CommandSender sender, String playerName) {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Heading"));
|
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Heading"));
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Player", playerName));
|
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Player", playerName));
|
||||||
|
|
||||||
for (SkillType skillType : SkillType.values()) {
|
for (SkillType skillType : SkillType.values()) {
|
||||||
int[] rankInts = Leaderboard.getPlayerRank(playerName, skillType);
|
int[] rankInts = Leaderboard.getPlayerRank(playerName, skillType);
|
||||||
|
|
||||||
if (skillType.isChildSkill()) {
|
if (skillType.isChildSkill()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (skillType.equals(SkillType.ALL)) {
|
|
||||||
continue; // We want the overall ranking to be at the bottom
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rankInts[1] == 0) {
|
if (rankInts[1] == 0) {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", SkillTools.localizeSkillName(skillType), LocaleLoader.getString("Commands.mcrank.Unranked"))); //Don't bother showing ranking for players without skills
|
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", SkillTools.localizeSkillName(skillType), LocaleLoader.getString("Commands.mcrank.Unranked"))); // Don't bother showing ranking for players without skills
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", SkillTools.localizeSkillName(skillType), String.valueOf(rankInts[0])));
|
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", SkillTools.localizeSkillName(skillType), String.valueOf(rankInts[0])));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Show the powerlevel ranking
|
// Show the powerlevel ranking
|
||||||
int[] rankInts = Leaderboard.getPlayerRank(playerName, SkillType.ALL);
|
int[] rankInts = Leaderboard.getPlayerRank(playerName);
|
||||||
|
|
||||||
if (rankInts[1] == 0) {
|
if (rankInts[1] == 0) {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Overalll", LocaleLoader.getString("Commands.mcrank.Unranked"))); //Don't bother showing ranking for players without skills
|
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Overalll", LocaleLoader.getString("Commands.mcrank.Unranked"))); // Don't bother showing ranking for players without skills
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Overall", String.valueOf(rankInts[0])));
|
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Overall", String.valueOf(rankInts[0])));
|
||||||
@ -113,6 +111,6 @@ public class McrankCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void sqlDisplay(CommandSender sender, String playerName) {
|
private void sqlDisplay(CommandSender sender, String playerName) {
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(Bukkit.getPluginManager().getPlugin("mcMMO"), new McRankAsync(playerName, sender));
|
Bukkit.getScheduler().runTaskAsynchronously(mcMMO.p, new McRankAsync(playerName, sender));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,6 @@ import com.gmail.nossr50.config.Config;
|
|||||||
import com.gmail.nossr50.database.Database;
|
import com.gmail.nossr50.database.Database;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||||
import com.gmail.nossr50.skills.utilities.SkillType;
|
|
||||||
import com.gmail.nossr50.util.Leaderboard;
|
import com.gmail.nossr50.util.Leaderboard;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
|
|
||||||
@ -125,10 +124,10 @@ public class MctopCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Leaderboard.updateLeaderboards(); //Make sure we have the latest information
|
Leaderboard.updateLeaderboards(); //Make sure we have the latest information
|
||||||
SkillType skillType = SkillType.getSkill(skill);
|
|
||||||
String[] info = Leaderboard.retrieveInfo(skillType, page);
|
|
||||||
|
|
||||||
if (skill.equalsIgnoreCase("ALL")) {
|
String[] info = Leaderboard.retrieveInfo(skill, page);
|
||||||
|
|
||||||
|
if (skill.equalsIgnoreCase("all")) {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Leaderboard"));
|
sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Leaderboard"));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -473,44 +473,43 @@ public final class Database {
|
|||||||
public static Map<String, Integer> readSQLRank(String playerName) {
|
public static Map<String, Integer> readSQLRank(String playerName) {
|
||||||
ResultSet resultSet;
|
ResultSet resultSet;
|
||||||
Map<String, Integer> skills = new HashMap<String, Integer>();
|
Map<String, Integer> skills = new HashMap<String, Integer>();
|
||||||
|
|
||||||
if (checkConnected()) {
|
if (checkConnected()) {
|
||||||
try {
|
try {
|
||||||
for (SkillType skillType: SkillType.values()) {
|
for (SkillType skillType: SkillType.values()) {
|
||||||
if (skillType.isChildSkill()) continue;
|
if (skillType.isChildSkill()) {
|
||||||
String sql;
|
continue;
|
||||||
if (skillType != SkillType.ALL) {
|
|
||||||
sql = "SELECT COUNT(*) AS rank FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE " + skillType.name().toLowerCase() + " > 0 AND " + skillType.name().toLowerCase() + " > (SELECT " + skillType.name().toLowerCase() + " FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE user = '" + playerName + "')";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
sql = "SELECT COUNT(*) AS rank FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing > 0 AND taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing > (SELECT taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE user = '" + playerName + "')";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String sql = "SELECT COUNT(*) AS rank FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE " + skillType.name().toLowerCase() + " > 0 AND " + skillType.name().toLowerCase() + " > (SELECT " + skillType.name().toLowerCase() + " FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE user = '" + playerName + "')";
|
||||||
|
|
||||||
PreparedStatement statement = connection.prepareStatement(sql);
|
PreparedStatement statement = connection.prepareStatement(sql);
|
||||||
resultSet = statement.executeQuery();
|
resultSet = statement.executeQuery();
|
||||||
|
|
||||||
resultSet.next();
|
resultSet.next();
|
||||||
|
|
||||||
int rank = resultSet.getInt("rank");
|
int rank = resultSet.getInt("rank");
|
||||||
if (skillType != SkillType.ALL) {
|
|
||||||
sql = "SELECT user, " + skillType.name().toLowerCase() + " FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE " + skillType.name().toLowerCase() + " > 0 AND " + skillType.name().toLowerCase() + " = (SELECT " + skillType.name().toLowerCase() + " FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE user = '" + playerName + "') ORDER BY user";
|
sql = "SELECT user, " + skillType.name().toLowerCase() + " FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE " + skillType.name().toLowerCase() + " > 0 AND " + skillType.name().toLowerCase() + " = (SELECT " + skillType.name().toLowerCase() + " FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE user = '" + playerName + "') ORDER BY user";
|
||||||
}
|
|
||||||
else {
|
|
||||||
sql = "SELECT user, taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing > 0 AND taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing = (SELECT taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE user = '" + playerName + "') ORDER BY user";
|
|
||||||
}
|
|
||||||
statement = connection.prepareStatement(sql);
|
statement = connection.prepareStatement(sql);
|
||||||
resultSet = statement.executeQuery();
|
resultSet = statement.executeQuery();
|
||||||
|
|
||||||
while (resultSet.next()) {
|
while (resultSet.next()) {
|
||||||
if (resultSet.getString("user").equalsIgnoreCase(playerName)) {
|
if (resultSet.getString("user").equalsIgnoreCase(playerName)) {
|
||||||
skills.put(skillType.name(), rank + resultSet.getRow());
|
skills.put(skillType.name(), rank + resultSet.getRow());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
statement.close();
|
statement.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (SQLException ex) {
|
catch (SQLException ex) {
|
||||||
printErrors(ex);
|
printErrors(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return skills;
|
return skills;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ public class PlayerProfile {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (SkillType skillType : SkillType.values()) {
|
for (SkillType skillType : SkillType.values()) {
|
||||||
if (skillType != SkillType.ALL && !skillType.isChildSkill()) {
|
if (!skillType.isChildSkill()) {
|
||||||
skills.put(skillType, 0);
|
skills.put(skillType, 0);
|
||||||
skillsXp.put(skillType, 0);
|
skillsXp.put(skillType, 0);
|
||||||
}
|
}
|
||||||
@ -1012,18 +1012,7 @@ public class PlayerProfile {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (skillType.equals(SkillType.ALL)) {
|
skillsXp.put(skillType, skillsXp.get(skillType) - xp);
|
||||||
for (SkillType skill : SkillType.values()) {
|
|
||||||
if (skill.equals(SkillType.ALL)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
skillsXp.put(skill, skillsXp.get(skill) - xp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
skillsXp.put(skillType, skillsXp.get(skillType) - xp);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1037,20 +1026,8 @@ public class PlayerProfile {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (skillType.equals(SkillType.ALL)) {
|
skills.put(skillType, newValue);
|
||||||
for (SkillType skill : SkillType.values()) {
|
skillsXp.put(skillType, 0);
|
||||||
if (skill.equals(SkillType.ALL)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
skills.put(skill, newValue);
|
|
||||||
skillsXp.put(skill, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
skills.put(skillType, newValue);
|
|
||||||
skillsXp.put(skillType, 0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1064,20 +1041,8 @@ public class PlayerProfile {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (skillType == SkillType.ALL) {
|
skills.put(skillType, skills.get(skillType) + levels);
|
||||||
for (SkillType skill : SkillType.values()) {
|
skillsXp.put(skillType, 0);
|
||||||
if (skill == SkillType.ALL || skill.isChildSkill()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
skills.put(skill, skills.get(skill) + levels);
|
|
||||||
skillsXp.put(skill, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
skills.put(skillType, skills.get(skillType) + levels);
|
|
||||||
skillsXp.put(skillType, 0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1133,8 +1098,4 @@ public class PlayerProfile {
|
|||||||
//
|
//
|
||||||
// return bonusModifier;
|
// return bonusModifier;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
/*
|
|
||||||
* Party Stuff
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import java.util.Map;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.database.Database;
|
import com.gmail.nossr50.database.Database;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.skills.utilities.SkillTools;
|
import com.gmail.nossr50.skills.utilities.SkillTools;
|
||||||
@ -22,7 +23,8 @@ public class McRankAsync implements Runnable {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
final Map<String, Integer> skills = Database.readSQLRank(playerName);
|
final Map<String, Integer> skills = Database.readSQLRank(playerName);
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(Bukkit.getPluginManager().getPlugin("mcMMO"), new Runnable() {
|
|
||||||
|
Bukkit.getScheduler().scheduleSyncDelayedTask(mcMMO.p, new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Heading"));
|
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Heading"));
|
||||||
@ -33,9 +35,6 @@ public class McRankAsync implements Runnable {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (skillType.equals(SkillType.ALL))
|
|
||||||
continue; // We want the overall ranking to be at the bottom
|
|
||||||
|
|
||||||
if (skills.get(skillType.name()) == null) {
|
if (skills.get(skillType.name()) == null) {
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", SkillTools.localizeSkillName(skillType), LocaleLoader.getString("Commands.mcrank.Unranked")));
|
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", SkillTools.localizeSkillName(skillType), LocaleLoader.getString("Commands.mcrank.Unranked")));
|
||||||
}
|
}
|
||||||
|
@ -275,23 +275,6 @@ public class SkillTools {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Check XP of all skills.
|
|
||||||
*
|
|
||||||
* @param player The player to check XP for.
|
|
||||||
* @param profile The profile of the player whose skill to check
|
|
||||||
*/
|
|
||||||
public static void xpCheckAll(Player player, PlayerProfile profile) {
|
|
||||||
for (SkillType skillType : SkillType.values()) {
|
|
||||||
//Don't want to do anything with this one
|
|
||||||
if (skillType == SkillType.ALL || skillType.isChildSkill()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
xpCheckSkill(skillType, player, profile);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the skill represented by the given string
|
* Get the skill represented by the given string
|
||||||
*
|
*
|
||||||
|
@ -8,7 +8,6 @@ import com.gmail.nossr50.util.Users;
|
|||||||
|
|
||||||
public enum SkillType {
|
public enum SkillType {
|
||||||
ACROBATICS(Config.getInstance().getLevelCapAcrobatics(), Config.getInstance().getFormulaMultiplierAcrobatics()),
|
ACROBATICS(Config.getInstance().getLevelCapAcrobatics(), Config.getInstance().getFormulaMultiplierAcrobatics()),
|
||||||
ALL, //This one is just for convenience
|
|
||||||
ARCHERY(Config.getInstance().getLevelCapArchery(), Config.getInstance().getFormulaMultiplierArchery()),
|
ARCHERY(Config.getInstance().getLevelCapArchery(), Config.getInstance().getFormulaMultiplierArchery()),
|
||||||
AXES(AbilityType.SKULL_SPLIITER, Config.getInstance().getLevelCapAxes(), ToolType.AXE, Config.getInstance().getFormulaMultiplierAxes()),
|
AXES(AbilityType.SKULL_SPLIITER, Config.getInstance().getLevelCapAxes(), ToolType.AXE, Config.getInstance().getFormulaMultiplierAxes()),
|
||||||
EXCAVATION(AbilityType.GIGA_DRILL_BREAKER, Config.getInstance().getLevelCapExcavation(), ToolType.SHOVEL, Config.getInstance().getFormulaMultiplierExcavation()),
|
EXCAVATION(AbilityType.GIGA_DRILL_BREAKER, Config.getInstance().getLevelCapExcavation(), ToolType.SHOVEL, Config.getInstance().getFormulaMultiplierExcavation()),
|
||||||
@ -120,10 +119,6 @@ public enum SkillType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static SkillType getSkill(String skillName) {
|
public static SkillType getSkill(String skillName) {
|
||||||
if (skillName.equalsIgnoreCase("powerlevel") || skillName.equalsIgnoreCase("all")) {
|
|
||||||
return SkillType.ALL;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (SkillType type : SkillType.values()) {
|
for (SkillType type : SkillType.values()) {
|
||||||
if (type.name().equalsIgnoreCase(skillName)) {
|
if (type.name().equalsIgnoreCase(skillName)) {
|
||||||
return type;
|
return type;
|
||||||
@ -141,6 +136,7 @@ public enum SkillType {
|
|||||||
* @return the player's skill level
|
* @return the player's skill level
|
||||||
*/
|
*/
|
||||||
public int getSkillLevel(Player player) {
|
public int getSkillLevel(Player player) {
|
||||||
|
// TODO: Child skills aren't handled here
|
||||||
return Users.getPlayer(player).getProfile().getSkillLevel(this);
|
return Users.getPlayer(player).getProfile().getSkillLevel(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,15 +116,14 @@ public class SpoutTools {
|
|||||||
* Extract Spout files to the Resources directory.
|
* Extract Spout files to the Resources directory.
|
||||||
*/
|
*/
|
||||||
public static void extractFiles() {
|
public static void extractFiles() {
|
||||||
|
// Setup directories
|
||||||
//Setup directories
|
|
||||||
new File(spoutDirectory).mkdir();
|
new File(spoutDirectory).mkdir();
|
||||||
new File(hudDirectory).mkdir();
|
new File(hudDirectory).mkdir();
|
||||||
new File(hudStandardDirectory).mkdir();
|
new File(hudStandardDirectory).mkdir();
|
||||||
new File(hudRetroDirectory).mkdir();
|
new File(hudRetroDirectory).mkdir();
|
||||||
new File(soundDirectory).mkdir();
|
new File(soundDirectory).mkdir();
|
||||||
|
|
||||||
//XP Bar images
|
// XP Bar images
|
||||||
for (int x = 0; x < 255; x++) {
|
for (int x = 0; x < 255; x++) {
|
||||||
String theFileName;
|
String theFileName;
|
||||||
|
|
||||||
@ -141,24 +140,25 @@ public class SpoutTools {
|
|||||||
writeFile(theFileName, hudStandardDirectory);
|
writeFile(theFileName, hudStandardDirectory);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Standard XP Icons
|
// Standard XP Icons
|
||||||
for (SkillType y : SkillType.values()) {
|
for (SkillType skillType : SkillType.values()) {
|
||||||
if (y.equals(SkillType.ALL) || y.isChildSkill()) {
|
if (skillType.isChildSkill()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
String standardFileName = Misc.getCapitalized(y.toString())+".png";
|
String skillTypeString = skillType.toString();
|
||||||
String retroFileName = Misc.getCapitalized(y.toString())+"_r.png";
|
String standardFileName = Misc.getCapitalized(skillTypeString)+".png";
|
||||||
|
String retroFileName = Misc.getCapitalized(skillTypeString)+"_r.png";
|
||||||
|
|
||||||
writeFile(standardFileName, hudStandardDirectory);
|
writeFile(standardFileName, hudStandardDirectory);
|
||||||
writeFile(retroFileName, hudRetroDirectory);
|
writeFile(retroFileName, hudRetroDirectory);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Blank icons
|
// Blank icons
|
||||||
writeFile("Icon.png", hudStandardDirectory);
|
writeFile("Icon.png", hudStandardDirectory);
|
||||||
writeFile("Icon_r.png", hudRetroDirectory);
|
writeFile("Icon_r.png", hudRetroDirectory);
|
||||||
|
|
||||||
//Sound FX
|
// Sound FX
|
||||||
writeFile("level.wav", soundDirectory);
|
writeFile("level.wav", soundDirectory);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -189,7 +189,7 @@ public class SpoutTools {
|
|||||||
public static ArrayList<File> getFiles() {
|
public static ArrayList<File> getFiles() {
|
||||||
ArrayList<File> files = new ArrayList<File>();
|
ArrayList<File> files = new ArrayList<File>();
|
||||||
|
|
||||||
/* XP BAR */
|
// XP BAR
|
||||||
for (int x = 0; x < 255; x++) {
|
for (int x = 0; x < 255; x++) {
|
||||||
if (x < 10) {
|
if (x < 10) {
|
||||||
files.add(new File(hudStandardDirectory + "xpbar_inc00" + x + ".png"));
|
files.add(new File(hudStandardDirectory + "xpbar_inc00" + x + ".png"));
|
||||||
@ -202,21 +202,23 @@ public class SpoutTools {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Standard XP Icons */
|
// Standard XP Icons
|
||||||
for (SkillType y : SkillType.values()) {
|
for (SkillType skillType : SkillType.values()) {
|
||||||
if (y.equals(SkillType.ALL) || y.isChildSkill()) {
|
if (skillType.isChildSkill()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
files.add(new File(hudStandardDirectory + Misc.getCapitalized(y.toString()) + ".png"));
|
String skillTypeString = skillType.toString();
|
||||||
files.add(new File(hudRetroDirectory + Misc.getCapitalized(y.toString()) + "_r.png"));
|
|
||||||
|
files.add(new File(hudStandardDirectory + Misc.getCapitalized(skillTypeString) + ".png"));
|
||||||
|
files.add(new File(hudRetroDirectory + Misc.getCapitalized(skillTypeString) + "_r.png"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Blank icons */
|
// Blank icons
|
||||||
files.add(new File(hudStandardDirectory + "Icon.png"));
|
files.add(new File(hudStandardDirectory + "Icon.png"));
|
||||||
files.add(new File(hudRetroDirectory + "Icon_r.png"));
|
files.add(new File(hudRetroDirectory + "Icon_r.png"));
|
||||||
|
|
||||||
//Level SFX
|
// Level SFX
|
||||||
files.add(new File(soundDirectory + "level.wav"));
|
files.add(new File(soundDirectory + "level.wav"));
|
||||||
|
|
||||||
return files;
|
return files;
|
||||||
|
@ -24,13 +24,12 @@ public final class Hardcore {
|
|||||||
int totalLost = 0;
|
int totalLost = 0;
|
||||||
|
|
||||||
for (SkillType skillType : SkillType.values()) {
|
for (SkillType skillType : SkillType.values()) {
|
||||||
if (skillType.equals(SkillType.ALL) || skillType.isChildSkill()) {
|
if (skillType.isChildSkill()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
int playerSkillLevel = playerProfile.getSkillLevel(skillType);
|
int playerSkillLevel = playerProfile.getSkillLevel(skillType);
|
||||||
|
|
||||||
//Should we really care about negative skill levels?
|
|
||||||
if (playerSkillLevel <= 0) {
|
if (playerSkillLevel <= 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -54,14 +53,13 @@ public final class Hardcore {
|
|||||||
int totalStolen = 0;
|
int totalStolen = 0;
|
||||||
|
|
||||||
for (SkillType skillType : SkillType.values()) {
|
for (SkillType skillType : SkillType.values()) {
|
||||||
if (skillType.equals(SkillType.ALL) || skillType.isChildSkill()) {
|
if (skillType.isChildSkill()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
int killerSkillLevel = killerProfile.getSkillLevel(skillType);
|
int killerSkillLevel = killerProfile.getSkillLevel(skillType);
|
||||||
int victimSkillLevel = victimProfile.getSkillLevel(skillType);
|
int victimSkillLevel = victimProfile.getSkillLevel(skillType);
|
||||||
|
|
||||||
//Should we really care about negative skill levels?
|
|
||||||
if (victimSkillLevel <= 0 || victimSkillLevel < killerSkillLevel / 2) {
|
if (victimSkillLevel <= 0 || victimSkillLevel < killerSkillLevel / 2) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@ import com.gmail.nossr50.skills.utilities.SkillType;
|
|||||||
|
|
||||||
public final class Leaderboard {
|
public final class Leaderboard {
|
||||||
private static HashMap<SkillType, List<PlayerStat>> playerStatHash = new HashMap<SkillType, List<PlayerStat>>();
|
private static HashMap<SkillType, List<PlayerStat>> playerStatHash = new HashMap<SkillType, List<PlayerStat>>();
|
||||||
|
private static List<PlayerStat> powerLevels = new ArrayList<PlayerStat>();
|
||||||
private static long lastUpdate = 0;
|
private static long lastUpdate = 0;
|
||||||
|
|
||||||
private Leaderboard() {}
|
private Leaderboard() {}
|
||||||
@ -29,7 +30,7 @@ public final class Leaderboard {
|
|||||||
lastUpdate = System.currentTimeMillis(); //Log when the last update was run
|
lastUpdate = System.currentTimeMillis(); //Log when the last update was run
|
||||||
|
|
||||||
//Initialize lists
|
//Initialize lists
|
||||||
List<PlayerStat> mining, woodcutting, herbalism, excavation, acrobatics, repair, swords, axes, archery, unarmed, taming, fishing, powerlevel;
|
List<PlayerStat> mining, woodcutting, herbalism, excavation, acrobatics, repair, swords, axes, archery, unarmed, taming, fishing;
|
||||||
|
|
||||||
mining = new ArrayList<PlayerStat>();
|
mining = new ArrayList<PlayerStat>();
|
||||||
woodcutting = new ArrayList<PlayerStat>();
|
woodcutting = new ArrayList<PlayerStat>();
|
||||||
@ -43,7 +44,6 @@ public final class Leaderboard {
|
|||||||
unarmed = new ArrayList<PlayerStat>();
|
unarmed = new ArrayList<PlayerStat>();
|
||||||
taming = new ArrayList<PlayerStat>();
|
taming = new ArrayList<PlayerStat>();
|
||||||
fishing = new ArrayList<PlayerStat>();
|
fishing = new ArrayList<PlayerStat>();
|
||||||
powerlevel = new ArrayList<PlayerStat>();
|
|
||||||
|
|
||||||
//Read from the FlatFile database and fill our arrays with information
|
//Read from the FlatFile database and fill our arrays with information
|
||||||
try {
|
try {
|
||||||
@ -125,7 +125,7 @@ public final class Leaderboard {
|
|||||||
powerLevel += Integer.valueOf(character[34]);
|
powerLevel += Integer.valueOf(character[34]);
|
||||||
}
|
}
|
||||||
|
|
||||||
powerlevel.add(new PlayerStat(p, powerLevel));
|
powerLevels.add(new PlayerStat(p, powerLevel));
|
||||||
}
|
}
|
||||||
in.close();
|
in.close();
|
||||||
}
|
}
|
||||||
@ -146,7 +146,7 @@ public final class Leaderboard {
|
|||||||
Collections.sort(acrobatics, c);
|
Collections.sort(acrobatics, c);
|
||||||
Collections.sort(taming, c);
|
Collections.sort(taming, c);
|
||||||
Collections.sort(fishing, c);
|
Collections.sort(fishing, c);
|
||||||
Collections.sort(powerlevel, c);
|
Collections.sort(powerLevels, c);
|
||||||
|
|
||||||
playerStatHash.put(SkillType.MINING, mining);
|
playerStatHash.put(SkillType.MINING, mining);
|
||||||
playerStatHash.put(SkillType.WOODCUTTING, woodcutting);
|
playerStatHash.put(SkillType.WOODCUTTING, woodcutting);
|
||||||
@ -160,7 +160,6 @@ public final class Leaderboard {
|
|||||||
playerStatHash.put(SkillType.ACROBATICS, acrobatics);
|
playerStatHash.put(SkillType.ACROBATICS, acrobatics);
|
||||||
playerStatHash.put(SkillType.TAMING, taming);
|
playerStatHash.put(SkillType.TAMING, taming);
|
||||||
playerStatHash.put(SkillType.FISHING, fishing);
|
playerStatHash.put(SkillType.FISHING, fishing);
|
||||||
playerStatHash.put(SkillType.ALL, powerlevel);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -170,43 +169,64 @@ public final class Leaderboard {
|
|||||||
* @param pageNumber Which page in the leaderboards to retrieve
|
* @param pageNumber Which page in the leaderboards to retrieve
|
||||||
* @return the requested leaderboard information
|
* @return the requested leaderboard information
|
||||||
*/
|
*/
|
||||||
public static String[] retrieveInfo(SkillType skillType, int pageNumber) {
|
public static String[] retrieveInfo(String skillType, int pageNumber) {
|
||||||
String[] info = new String[10];
|
String[] info = new String[10];
|
||||||
|
List<PlayerStat> statsList;
|
||||||
|
|
||||||
List<PlayerStat> statsList = playerStatHash.get(skillType);
|
if (skillType.equalsIgnoreCase("all")) {
|
||||||
|
statsList = powerLevels;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
statsList = playerStatHash.get(SkillType.getSkill(skillType));
|
||||||
|
}
|
||||||
|
|
||||||
if(statsList != null) {
|
int destination;
|
||||||
int destination;
|
|
||||||
|
|
||||||
//How many lines to skip through
|
// How many lines to skip through
|
||||||
if (pageNumber == 1) {
|
if (pageNumber == 1) {
|
||||||
destination = 0;
|
destination = 0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
destination = (pageNumber * 10) - 9;
|
destination = (pageNumber * 10) - 9;
|
||||||
|
}
|
||||||
|
|
||||||
|
int currentPos = 0;
|
||||||
|
|
||||||
|
for (PlayerStat ps : statsList) {
|
||||||
|
if (currentPos == 10) {
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
int currentPos = 0;
|
if (destination > 1) {
|
||||||
|
destination--;
|
||||||
for(PlayerStat ps : statsList) {
|
continue;
|
||||||
if(currentPos == 10)
|
|
||||||
break;
|
|
||||||
if(destination > 1) {
|
|
||||||
destination--;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
info[currentPos] = ps.name+":"+ps.statVal;
|
|
||||||
currentPos++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
info[currentPos] = ps.name + ":" + ps.statVal;
|
||||||
info[0] = "DummyPlayer:0"; //Coming up with a better solution soon...
|
currentPos++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int[] getPlayerRank(String playerName) {
|
||||||
|
int currentPos = 1;
|
||||||
|
|
||||||
|
if (powerLevels != null) {
|
||||||
|
for (PlayerStat stat : powerLevels) {
|
||||||
|
if (stat.name.equalsIgnoreCase(playerName)) {
|
||||||
|
return new int[] {currentPos, stat.statVal};
|
||||||
|
}
|
||||||
|
|
||||||
|
currentPos++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
return new int[] {0, 0};
|
||||||
|
}
|
||||||
|
|
||||||
|
return new int[] {0, 0};
|
||||||
|
}
|
||||||
|
|
||||||
public static int[] getPlayerRank(String playerName, SkillType skillType) {
|
public static int[] getPlayerRank(String playerName, SkillType skillType) {
|
||||||
int currentPos = 1;
|
int currentPos = 1;
|
||||||
List<PlayerStat> statsList = playerStatHash.get(skillType);
|
List<PlayerStat> statsList = playerStatHash.get(skillType);
|
||||||
|
Loading…
Reference in New Issue
Block a user