Throw errors for child skill leaderboard requests

This commit is contained in:
nossr50 2020-11-10 11:20:32 -08:00
parent c9b950d0c8
commit 592851e80b
6 changed files with 27 additions and 4 deletions

View File

@ -1,5 +1,6 @@
Version 2.1.156
Fixed a bug where the admin and party chat toggles in chat.yml didn't function as intended
Added some errors that trigger if a plugin hooking into mcMMO is grabbing leaderboards for child skills through our SQL/FlatFile class (which don't exist)
Version 2.1.155
Master Angler now has 8 ranks

View File

@ -6,4 +6,8 @@ public class InvalidSkillException extends RuntimeException {
public InvalidSkillException() {
super("That is not a valid skill.");
}
public InvalidSkillException(String msg) {
super(msg);
}
}

View File

@ -1,5 +1,6 @@
package com.gmail.nossr50.database;
import com.gmail.nossr50.api.exceptions.InvalidSkillException;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.database.DatabaseType;
import com.gmail.nossr50.datatypes.database.PlayerStat;
@ -58,7 +59,7 @@ public interface DatabaseManager {
* @param statsPerPage The number of stats per page
* @return the requested leaderboard information
*/
List<PlayerStat> readLeaderboard(PrimarySkillType skill, int pageNumber, int statsPerPage);
List<PlayerStat> readLeaderboard(PrimarySkillType skill, int pageNumber, int statsPerPage) throws InvalidSkillException;
/**
* Retrieve rank info into a HashMap from PrimarySkillType to the rank.

View File

@ -1,5 +1,6 @@
package com.gmail.nossr50.database;
import com.gmail.nossr50.api.exceptions.InvalidSkillException;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.MobHealthbarType;
@ -363,7 +364,13 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
writer.append("\r\n");
}
public List<PlayerStat> readLeaderboard(PrimarySkillType skill, int pageNumber, int statsPerPage) {
public List<PlayerStat> readLeaderboard(PrimarySkillType skill, int pageNumber, int statsPerPage) throws InvalidSkillException {
//Fix for a plugin that people are using that is throwing SQL errors
if(skill.isChildSkill()) {
mcMMO.p.getLogger().severe("A plugin hooking into mcMMO is being naughty with our database commands, update all plugins that hook into mcMMO and contact their devs!");
throw new InvalidSkillException("A plugin hooking into mcMMO that you are using is attempting to read leaderboard skills for child skills, child skills do not have leaderboards! This is NOT an mcMMO error!");
}
updateLeaderboards();
List<PlayerStat> statsList = skill == null ? powerLevels : playerStatHash.get(skill);
int fromIndex = (Math.max(pageNumber, 1) - 1) * statsPerPage;

View File

@ -1,5 +1,6 @@
package com.gmail.nossr50.database;
import com.gmail.nossr50.api.exceptions.InvalidSkillException;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.MobHealthbarType;
@ -343,9 +344,16 @@ public final class SQLDatabaseManager implements DatabaseManager {
return success;
}
public List<PlayerStat> readLeaderboard(PrimarySkillType skill, int pageNumber, int statsPerPage) {
public List<PlayerStat> readLeaderboard(PrimarySkillType skill, int pageNumber, int statsPerPage) throws InvalidSkillException {
List<PlayerStat> stats = new ArrayList<>();
//Fix for a plugin that people are using that is throwing SQL errors
if(skill.isChildSkill()) {
mcMMO.p.getLogger().severe("A plugin hooking into mcMMO is being naughty with our database commands, update all plugins that hook into mcMMO and contact their devs!");
throw new InvalidSkillException("A plugin hooking into mcMMO that you are using is attempting to read leaderboard skills for child skills, child skills do not have leaderboards! This is NOT an mcMMO error!");
}
String query = skill == null ? ALL_QUERY_VERSION : skill.name().toLowerCase(Locale.ENGLISH);
ResultSet resultSet = null;
PreparedStatement statement = null;

View File

@ -91,7 +91,9 @@ public class SalvageManager extends SkillManager {
// Level check
if (getSkillLevel() < minimumSalvageableLevel) {
NotificationManager.sendPlayerInformation(player, NotificationType.REQUIREMENTS_NOT_MET, "Salvage.Skills.Adept.Level", String.valueOf(salvageable.getMinimumLevel()), StringUtils.getPrettyItemString(item.getType()));
NotificationManager.sendPlayerInformation(player, NotificationType.REQUIREMENTS_NOT_MET,
"Salvage.Skills.Adept.Level",
String.valueOf(minimumSalvageableLevel), StringUtils.getPrettyItemString(item.getType()));
return;
}