mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 07:06:45 +01:00
Only show the scoreboard tips a couple of times
We can assume a player knows how scoreboards work after showing them the tips a few times across multiple login sessions Adds #1833
This commit is contained in:
parent
a2c395db36
commit
eda18bc990
@ -12,6 +12,7 @@ Version 1.5.02-dev
|
||||
= Fixed bug where no Mining XP was granted when Flux Mining was successful
|
||||
= Fixed bug where MobHealthbarTypes were not saved between server restarts
|
||||
! Changed Flux Mining mechanics. In order to use the ability, you need to infuse a pickaxe with furnace powers first.
|
||||
! Scoreboard tips are only shown a couple of times to the player, instead of once per login session
|
||||
|
||||
Version 1.5.01
|
||||
+ Added new child skill; Salvage
|
||||
|
@ -280,6 +280,7 @@ public class Config extends AutoUpdateConfigLoader {
|
||||
/* Scoreboards */
|
||||
public boolean getPowerLevelTagsEnabled() { return config.getBoolean("Scoreboard.Power_Level_Tags", false); }
|
||||
public boolean getAllowKeepBoard() { return config.getBoolean("Scoreboard.Allow_Keep", true); }
|
||||
public int getTipsAmount() { return config.getInt("Scoreboard.Tips_Amount", 5); }
|
||||
public boolean getShowStatsAfterLogin() { return config.getBoolean("Scoreboard.Show_Stats_After_Login", false); }
|
||||
public boolean getScoreboardRainbows() { return config.getBoolean("Scoreboard.Rainbows", false); }
|
||||
public boolean getShowAbilityNames() { return config.getBoolean("Scoreboard.Ability_Names", true); }
|
||||
|
@ -320,6 +320,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
||||
writer.append(profile.getSkillLevel(SkillType.ALCHEMY)).append(":");
|
||||
writer.append(profile.getSkillXpLevel(SkillType.ALCHEMY)).append(":");
|
||||
writer.append(uuid.toString()).append(":");
|
||||
writer.append(profile.getScoreboardTipsShown()).append(":");
|
||||
writer.append("\r\n");
|
||||
}
|
||||
}
|
||||
@ -426,7 +427,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
||||
out.append("0:"); // Alchemy
|
||||
out.append("0:"); // AlchemyXp
|
||||
out.append(uuid != null ? uuid.toString() : "NULL").append(":"); // UUID
|
||||
|
||||
out.append("0:"); // Scoreboard tips shown
|
||||
// Add more in the same format as the line above
|
||||
|
||||
out.newLine();
|
||||
@ -952,6 +953,14 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
||||
oldVersion = "1.5.01";
|
||||
}
|
||||
}
|
||||
if (character.length <= 42) {
|
||||
// Addition of scoreboard tips auto disable
|
||||
// Version 1.5.02
|
||||
newLine.append("0").append(":");
|
||||
if (oldVersion == null) {
|
||||
oldVersion = "1.5.02";
|
||||
}
|
||||
}
|
||||
|
||||
// Remove any blanks that shouldn't be there, and validate the other fields
|
||||
String[] newCharacter = newLine.toString().split(":");
|
||||
@ -1087,6 +1096,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
||||
Map<SkillType, Float> skillsXp = new EnumMap<SkillType, Float>(SkillType.class); // Skill & XP
|
||||
Map<AbilityType, Integer> skillsDATS = new EnumMap<AbilityType, Integer>(AbilityType.class); // Ability & Cooldown
|
||||
MobHealthbarType mobHealthbarType;
|
||||
int scoreboardTipsShown;
|
||||
|
||||
// TODO on updates, put new values in a try{} ?
|
||||
|
||||
@ -1131,8 +1141,14 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
|
||||
catch (Exception e) {
|
||||
uuid = null;
|
||||
}
|
||||
try {
|
||||
scoreboardTipsShown = Integer.valueOf(character[41]);
|
||||
}
|
||||
catch (Exception e) {
|
||||
scoreboardTipsShown = 0;
|
||||
}
|
||||
|
||||
return new PlayerProfile(character[0], uuid, skills, skillsXp, skillsDATS, mobHealthbarType);
|
||||
return new PlayerProfile(character[0], uuid, skills, skillsXp, skillsDATS, mobHealthbarType, scoreboardTipsShown);
|
||||
}
|
||||
|
||||
private Map<SkillType, Integer> getSkillMapFromLine(String[] character) {
|
||||
|
@ -14,8 +14,6 @@ import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
import org.apache.tomcat.jdbc.pool.DataSource;
|
||||
import org.apache.tomcat.jdbc.pool.PoolProperties;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
@ -30,6 +28,9 @@ import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.gmail.nossr50.runnables.database.UUIDUpdateAsyncTask;
|
||||
import com.gmail.nossr50.util.Misc;
|
||||
|
||||
import org.apache.tomcat.jdbc.pool.DataSource;
|
||||
import org.apache.tomcat.jdbc.pool.PoolProperties;
|
||||
|
||||
public final class SQLDatabaseManager implements DatabaseManager {
|
||||
private static final String ALL_QUERY_VERSION = "taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing+alchemy";
|
||||
private String tablePrefix = Config.getInstance().getMySQLTablePrefix();
|
||||
@ -329,9 +330,10 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
success = (statement.executeUpdate() != 0);
|
||||
statement.close();
|
||||
|
||||
statement = connection.prepareStatement("UPDATE " + tablePrefix + "huds SET mobhealthbar = ? WHERE user_id = ?");
|
||||
statement = connection.prepareStatement("UPDATE " + tablePrefix + "huds SET mobhealthbar = ?, scoreboardtips = ? WHERE user_id = ?");
|
||||
statement.setString(1, profile.getMobHealthbarType() == null ? Config.getInstance().getMobHealthbarDefault().name() : profile.getMobHealthbarType().name());
|
||||
statement.setInt(2, id);
|
||||
statement.setInt(2, profile.getScoreboardTipsShown());
|
||||
statement.setInt(3, id);
|
||||
success = (statement.executeUpdate() != 0);
|
||||
statement.close();
|
||||
}
|
||||
@ -640,7 +642,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
+ "s.taming, s.mining, s.repair, s.woodcutting, s.unarmed, s.herbalism, s.excavation, s.archery, s.swords, s.axes, s.acrobatics, s.fishing, s.alchemy, "
|
||||
+ "e.taming, e.mining, e.repair, e.woodcutting, e.unarmed, e.herbalism, e.excavation, e.archery, e.swords, e.axes, e.acrobatics, e.fishing, e.alchemy, "
|
||||
+ "c.taming, c.mining, c.repair, c.woodcutting, c.unarmed, c.herbalism, c.excavation, c.archery, c.swords, c.axes, c.acrobatics, c.blast_mining, "
|
||||
+ "h.mobhealthbar, u.uuid "
|
||||
+ "h.mobhealthbar, h.scoreboardtips, u.uuid "
|
||||
+ "FROM " + tablePrefix + "users u "
|
||||
+ "JOIN " + tablePrefix + "skills s ON (u.id = s.user_id) "
|
||||
+ "JOIN " + tablePrefix + "experience e ON (u.id = e.user_id) "
|
||||
@ -729,7 +731,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
+ "s.taming, s.mining, s.repair, s.woodcutting, s.unarmed, s.herbalism, s.excavation, s.archery, s.swords, s.axes, s.acrobatics, s.fishing, s.alchemy, "
|
||||
+ "e.taming, e.mining, e.repair, e.woodcutting, e.unarmed, e.herbalism, e.excavation, e.archery, e.swords, e.axes, e.acrobatics, e.fishing, e.alchemy, "
|
||||
+ "c.taming, c.mining, c.repair, c.woodcutting, c.unarmed, c.herbalism, c.excavation, c.archery, c.swords, c.axes, c.acrobatics, c.blast_mining, "
|
||||
+ "h.mobhealthbar, u.uuid "
|
||||
+ "h.mobhealthbar, h.scoreboardtips, u.uuid "
|
||||
+ "FROM " + tablePrefix + "users u "
|
||||
+ "JOIN " + tablePrefix + "skills s ON (u.id = s.user_id) "
|
||||
+ "JOIN " + tablePrefix + "experience e ON (u.id = e.user_id) "
|
||||
@ -965,6 +967,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
createStatement.executeUpdate("CREATE TABLE IF NOT EXISTS `" + tablePrefix + "huds` ("
|
||||
+ "`user_id` int(10) unsigned NOT NULL,"
|
||||
+ "`mobhealthbar` varchar(50) NOT NULL DEFAULT '" + Config.getInstance().getMobHealthbarDefault() + "',"
|
||||
+ "`scoreboardtips` int(10) NOT NULL DEFAULT '0',"
|
||||
+ "PRIMARY KEY (`user_id`)) "
|
||||
+ "DEFAULT CHARSET=latin1;");
|
||||
createStatement.close();
|
||||
@ -1165,6 +1168,10 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
checkUpgradeAddUUIDs(statement);
|
||||
return;
|
||||
|
||||
case ADD_SCOREBOARD_TIPS:
|
||||
checkUpgradeAddScoreboardTips(statement);
|
||||
return;
|
||||
|
||||
default:
|
||||
break;
|
||||
|
||||
@ -1206,9 +1213,10 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
statement.execute();
|
||||
statement.close();
|
||||
|
||||
statement = connection.prepareStatement("INSERT IGNORE INTO " + tablePrefix + "huds (user_id, mobhealthbar) VALUES (?, ?)");
|
||||
statement = connection.prepareStatement("INSERT IGNORE INTO " + tablePrefix + "huds (user_id, mobhealthbar, scoreboardtips) VALUES (?, ?, ?)");
|
||||
statement.setInt(1, id);
|
||||
statement.setString(2, Config.getInstance().getMobHealthbarDefault().name());
|
||||
statement.setInt(3, 0);
|
||||
statement.execute();
|
||||
statement.close();
|
||||
}
|
||||
@ -1233,6 +1241,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
Map<AbilityType, Integer> skillsDATS = new EnumMap<AbilityType, Integer>(AbilityType.class); // Ability & Cooldown
|
||||
MobHealthbarType mobHealthbarType;
|
||||
UUID uuid;
|
||||
int scoreboardTipsShown;
|
||||
|
||||
final int OFFSET_SKILLS = 0; // TODO update these numbers when the query
|
||||
// changes (a new skill is added)
|
||||
@ -1282,12 +1291,19 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
skillsDATS.put(AbilityType.BLAST_MINING, result.getInt(OFFSET_DATS + 12));
|
||||
|
||||
try {
|
||||
mobHealthbarType = MobHealthbarType.valueOf(result.getString(OFFSET_OTHER + 2));
|
||||
mobHealthbarType = MobHealthbarType.valueOf(result.getString(OFFSET_OTHER + 1));
|
||||
}
|
||||
catch (Exception e) {
|
||||
mobHealthbarType = Config.getInstance().getMobHealthbarDefault();
|
||||
}
|
||||
|
||||
try {
|
||||
scoreboardTipsShown = result.getInt(OFFSET_OTHER + 2);
|
||||
}
|
||||
catch (Exception e) {
|
||||
scoreboardTipsShown = 0;
|
||||
}
|
||||
|
||||
try {
|
||||
uuid = UUID.fromString(result.getString(OFFSET_OTHER + 3));
|
||||
}
|
||||
@ -1295,7 +1311,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
uuid = null;
|
||||
}
|
||||
|
||||
return new PlayerProfile(playerName, uuid, skills, skillsXp, skillsDATS, mobHealthbarType);
|
||||
return new PlayerProfile(playerName, uuid, skills, skillsXp, skillsDATS, mobHealthbarType, scoreboardTipsShown);
|
||||
}
|
||||
|
||||
private void printErrors(SQLException ex) {
|
||||
@ -1352,6 +1368,16 @@ public final class SQLDatabaseManager implements DatabaseManager {
|
||||
}
|
||||
}
|
||||
|
||||
private void checkUpgradeAddScoreboardTips(final Statement statement) throws SQLException {
|
||||
try {
|
||||
statement.executeQuery("SELECT `scoreboardtips` FROM `" + tablePrefix + "huds` LIMIT 1");
|
||||
}
|
||||
catch (SQLException ex) {
|
||||
mcMMO.p.getLogger().info("Updating mcMMO MySQL tables for scoreboard tips...");
|
||||
statement.executeUpdate("ALTER TABLE `" + tablePrefix + "huds` ADD `scoreboardtips` int(10) NOT NULL DEFAULT '0' ;");
|
||||
}
|
||||
}
|
||||
|
||||
private void checkUpgradeAddSQLIndexes(final Statement statement) throws SQLException {
|
||||
ResultSet resultSet = null;
|
||||
|
||||
|
@ -9,5 +9,6 @@ public enum UpgradeType {
|
||||
DROP_SPOUT,
|
||||
ADD_ALCHEMY,
|
||||
ADD_UUIDS,
|
||||
ADD_UUIDS_PARTY;
|
||||
ADD_UUIDS_PARTY,
|
||||
ADD_SCOREBOARD_TIPS;
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ public class PlayerProfile {
|
||||
|
||||
/* HUDs */
|
||||
private MobHealthbarType mobHealthbarType;
|
||||
private int scoreboardTipsShown;
|
||||
|
||||
/* Skill Data */
|
||||
private final Map<SkillType, Integer> skills = new HashMap<SkillType, Integer>(); // Skill & Level
|
||||
@ -48,6 +49,7 @@ public class PlayerProfile {
|
||||
this.playerName = playerName;
|
||||
|
||||
mobHealthbarType = Config.getInstance().getMobHealthbarDefault();
|
||||
scoreboardTipsShown = 0;
|
||||
|
||||
for (AbilityType abilityType : AbilityType.values()) {
|
||||
abilityDATS.put(abilityType, 0);
|
||||
@ -70,10 +72,11 @@ public class PlayerProfile {
|
||||
this.loaded = isLoaded;
|
||||
}
|
||||
|
||||
public PlayerProfile(String playerName, UUID uuid, Map<SkillType, Integer> levelData, Map<SkillType, Float> xpData, Map<AbilityType, Integer> cooldownData, MobHealthbarType mobHealthbarType) {
|
||||
public PlayerProfile(String playerName, UUID uuid, Map<SkillType, Integer> levelData, Map<SkillType, Float> xpData, Map<AbilityType, Integer> cooldownData, MobHealthbarType mobHealthbarType, int scoreboardTipsShown) {
|
||||
this.playerName = playerName;
|
||||
this.uuid = uuid;
|
||||
this.mobHealthbarType = mobHealthbarType;
|
||||
this.scoreboardTipsShown = scoreboardTipsShown;
|
||||
|
||||
skills.putAll(levelData);
|
||||
skillsXp.putAll(xpData);
|
||||
@ -92,7 +95,7 @@ public class PlayerProfile {
|
||||
}
|
||||
|
||||
// TODO should this part be synchronized?
|
||||
PlayerProfile profileCopy = new PlayerProfile(playerName, uuid, ImmutableMap.copyOf(skills), ImmutableMap.copyOf(skillsXp), ImmutableMap.copyOf(abilityDATS), mobHealthbarType);
|
||||
PlayerProfile profileCopy = new PlayerProfile(playerName, uuid, ImmutableMap.copyOf(skills), ImmutableMap.copyOf(skillsXp), ImmutableMap.copyOf(abilityDATS), mobHealthbarType, scoreboardTipsShown);
|
||||
changed = !mcMMO.getDatabaseManager().saveUser(profileCopy);
|
||||
|
||||
if (changed) {
|
||||
@ -132,6 +135,20 @@ public class PlayerProfile {
|
||||
this.mobHealthbarType = mobHealthbarType;
|
||||
}
|
||||
|
||||
public int getScoreboardTipsShown() {
|
||||
return scoreboardTipsShown;
|
||||
}
|
||||
|
||||
public void setScoreboardTipsShown(int scoreboardTipsShown) {
|
||||
changed = true;
|
||||
|
||||
this.scoreboardTipsShown = scoreboardTipsShown;
|
||||
}
|
||||
|
||||
public void increaseTipsShown() {
|
||||
setScoreboardTipsShown(getScoreboardTipsShown() + 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Cooldowns
|
||||
*/
|
||||
|
@ -199,6 +199,13 @@ public class ScoreboardWrapper {
|
||||
|
||||
// TODO is there any way to do the time that looks acceptable?
|
||||
// player.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Timer", StringUtils.capitalize(sidebarType.toString().toLowerCase()), ticks / 20F));
|
||||
|
||||
PlayerProfile profile = UserManager.getPlayer(player).getProfile();
|
||||
|
||||
if (profile.getScoreboardTipsShown() >= Config.getInstance().getTipsAmount()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!tippedKeep) {
|
||||
tippedKeep = true;
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Tip.Keep"));
|
||||
@ -206,6 +213,7 @@ public class ScoreboardWrapper {
|
||||
else if (!tippedClear) {
|
||||
tippedClear = true;
|
||||
player.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Tip.Clear"));
|
||||
profile.increaseTipsShown();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -45,6 +45,10 @@ Scoreboard:
|
||||
# Show the /mcstats scoreboard automatically after logging in
|
||||
Show_Stats_After_Login: false
|
||||
|
||||
# Show scoreboard tips 5 times. Tips are only displayed once for every login session.
|
||||
# Set to 0 to never show these tips.
|
||||
Tips_Amount: 5
|
||||
|
||||
# Add some more color on the board :-)
|
||||
Rainbows: false
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user