Skip to content

Commit

Permalink
- Fixed scoreboard conversion from old config to new config
Browse files Browse the repository at this point in the history
  • Loading branch information
joserodpt committed Apr 7, 2024
1 parent febbb77 commit 48a6f19
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public static void setup(JavaPlugin javaPlugin) {
GeneralSettings.builder().setUseDefaults(false).build(),
LoaderSettings.builder().setAutoUpdate(true).build(),
DumperSettings.DEFAULT,
UpdaterSettings.builder().setVersioning(new BasicVersioning("Version")).addIgnoredRoute("15", "Config.Scoreboard", '.').build());
UpdaterSettings.builder().setVersioning(new BasicVersioning("Version")).addIgnoredRoute("16", "Config.Scoreboard", '.').build());
sqlConfigFile = YamlDocument.create(new File(javaPlugin.getDataFolder(), "sql.yml"), javaPlugin.getResource("sql.yml"));
} catch (IOException e) {
Bukkit.getLogger().log(Level.SEVERE, "Couldn't setup config files!");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ public void run() {
return;
}

//DEBUGGING RealScoreboardAPI.getInstance().getLogger().warning(p.getName() + " - " + current.getName());

String title = current.getTitle();
if (RSBConfig.file().getBoolean("Config.Use-Placeholders-In-Scoreboard-Titles")) {
title = RealScoreboardAPI.getInstance().getPlaceholders().setPlaceHolders(p, title);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,10 @@ public RScoreboardBoards(final String name, final String displayName, final Stri
}
}

public RScoreboardBoards(final String name, final String displayName, final String permission, final String defaultWord,
final int titleRefresh, final int titleLoopDelay, final int globalScoreboardRefresh, final int boardLoopDelay, final List<RBoard> boards, final boolean defaultSB) {
super(name, displayName, permission, defaultWord, titleRefresh, titleLoopDelay, globalScoreboardRefresh, defaultSB);
this.boardLoopDelay = boardLoopDelay;
this.boards = boards;
}

//loading from old config format
public RScoreboardBoards(final String name, final String permission, final String defaultWord,
final int titleRefresh, final int titleLoopDelay, final int globalScoreboardRefresh, final int boardLoopDelay) {
super(name,"&7" + name, permission, defaultWord, titleRefresh, titleLoopDelay, globalScoreboardRefresh, false);
final int titleRefresh, final int titleLoopDelay, final int globalScoreboardRefresh, final int boardLoopDelay, final boolean defaultSB) {
super(name,"&7" + name, permission, defaultWord, titleRefresh, titleLoopDelay, globalScoreboardRefresh, defaultSB);
this.boardLoopDelay = boardLoopDelay;
//save in new format below in setBoards
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,6 @@ public void setscoreboardcmd(final CommandSender commandSender, final String nam
return;
}

rsa.getLogger().warning(rsa.getPlayerManager().getPlayerHook(target.getUniqueId()).getScoreboard().getName());
rsa.getLogger().warning(sb.getName());

if (rsa.getPlayerManager().getPlayerHook(target.getUniqueId()).getScoreboard() == sb) {
Text.send(commandSender, target.getName() + " &calready has that scoreboard applied.");
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public void loadScoreboards() {
//starting from version 1.4, scoreboards are stored in the scoreboards.yml file and have a new structure,
//this next part of the code is responsible for the conversion of those old scoreboards in the config.yml
if (RSBConfig.file().contains("Config.Scoreboard")) {
rsa.getLogger().warning("Starting scoreboard conversion to scoreboards.yml...");
convertOldScoreboardsV1dot4();
return;
}
Expand Down Expand Up @@ -96,7 +97,6 @@ public void loadScoreboards() {
}

private void convertOldScoreboardsV1dot4() {
rsa.getLogger().warning("Starting scoreboard conversion to scoreboards.yml...");
//remove the template scoreboards
//RSBScoreboards.file().remove("Scoreboards");
int counter = 0;
Expand All @@ -112,15 +112,15 @@ private void convertOldScoreboardsV1dot4() {
List<String> title = RSBConfig.file().getStringList(boardEntry + ".Title");
List<String> lines = RSBConfig.file().getStringList(boardEntry + ".Lines");

this.scoreboards.put(permNode, new RScoreboardSingle(permNode, permNode.equalsIgnoreCase("default") ? "none" : "realscoreboard.scoreboard" + permNode, world, title, lines,
this.scoreboards.put(permNode, new RScoreboardSingle(permNode, permNode.equalsIgnoreCase("default") ? "none" : ("realscoreboard.scoreboard" + permNode), world, title, lines,
20, 20, 20));
++counter;
}
} else {
List<RBoard> boards = new ArrayList<>();

RScoreboardBoards rsbb = new RScoreboardBoards(permNode, permNode.equalsIgnoreCase("default") ? "none" : "realscoreboard.scoreboard" + permNode, world,
20, 20, 20 , RSBConfig.file().getInt(scoreboardEntry + "Switch-Timer")); ++counter;
RScoreboardBoards rsbb = new RScoreboardBoards(permNode, permNode.equalsIgnoreCase("default") ? "none" : ("realscoreboard.scoreboard" + permNode), world,
20, 20, 20 , RSBConfig.file().getInt(scoreboardEntry + "Switch-Timer"), permNode.equalsIgnoreCase("default")); ++counter;

for (String boardName : RSBConfig.file().getSection(scoreboardEntry + "Boards").getRoutesAsStrings(false)) {
String boardEntry = scoreboardEntry + "Boards." + boardName;
Expand All @@ -140,11 +140,6 @@ private void convertOldScoreboardsV1dot4() {
rsa.getLogger().warning("Converted Scoreboard " + permNode);
}
}
for (RScoreboard value : this.scoreboards.values()) {
value.setPermission("none");
value.setDefault(true);
break;
}

this.scoreboards.values().forEach(RScoreboard::init);

Expand Down
2 changes: 1 addition & 1 deletion realscoreboard-plugin/src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#RealScoreboard created by joserodpt and maintained by Neziw
#
#Useful links:
#SpigotMC - https://www.spigotmc.org/resources/realscoreboard-1-13-to-1-19-2.22928/
#SpigotMC - https://www.spigotmc.org/resources/22928/
#Discord Server - https://discord.gg/t7gfnYZKy8
#bStats - https://bstats.org/plugin/bukkit/RealScoreboard/10080
#HEX Color Formats: https://github.com/Iridium-Development/IridiumColorAPI
Expand Down
2 changes: 1 addition & 1 deletion realscoreboard-plugin/src/main/resources/sql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#List of available drivers: MYSQL, SQLITE, POSTGRESQL, MARIADB, SQLSERVER
#
#Useful links:
#SpigotMC - https://www.spigotmc.org/resources/realscoreboard-1-13-to-1-19-2.22928/
#SpigotMC - https://www.spigotmc.org/resources/22928/
#Discord Server - https://discord.gg/t7gfnYZKy8
#bStats - https://bstats.org/plugin/bukkit/RealScoreboard/10080
#HEX Color Formats: https://github.com/Iridium-Development/IridiumColorAPI
Expand Down

0 comments on commit 48a6f19

Please sign in to comment.