Skip to content

Commit 71b5d43

Browse files
committed
updates to hyperlib
1 parent 811cf0d commit 71b5d43

File tree

7 files changed

+61
-85
lines changed

7 files changed

+61
-85
lines changed

pom.xml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,8 @@
6464
<configuration>
6565
<relocations>
6666
<relocation>
67-
<pattern>org.bstats</pattern>
68-
<shadedPattern>lol.hyper.timebar.bstats</shadedPattern>
69-
</relocation>
70-
<relocation>
71-
<pattern>lol.hyper.githubreleaseapi</pattern>
72-
<shadedPattern>lol.hyper.timebar.updater</shadedPattern>
67+
<pattern>lol.hyper.hyperlib</pattern>
68+
<shadedPattern>lol.hyper.timebar.hyperlib</shadedPattern>
7369
</relocation>
7470
</relocations>
7571
</configuration>
@@ -116,7 +112,7 @@
116112
<dependency>
117113
<groupId>com.github.hyperdefined</groupId>
118114
<artifactId>hyperlib</artifactId>
119-
<version>1.0.2</version>
115+
<version>1.0.9</version>
120116
<scope>compile</scope>
121117
</dependency>
122118
<dependency>

src/main/java/lol/hyper/timebar/TimeBar.java

Lines changed: 19 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,16 @@
1818
package lol.hyper.timebar;
1919

2020
import lol.hyper.hyperlib.HyperLib;
21-
import lol.hyper.hyperlib.bstats.bStats;
22-
import lol.hyper.hyperlib.releases.modrinth.ModrinthPlugin;
23-
import lol.hyper.hyperlib.releases.modrinth.ModrinthRelease;
21+
import lol.hyper.hyperlib.bstats.HyperStats;
22+
import lol.hyper.hyperlib.releases.HyperUpdater;
2423
import lol.hyper.hyperlib.utils.TextUtils;
2524
import lol.hyper.timebar.commands.CommandTimeBar;
2625
import lol.hyper.timebar.events.PlayerJoinLeave;
2726
import lol.hyper.timebar.events.WorldChange;
2827
import lol.hyper.timebar.papi.TimeBarExpansion;
2928
import lol.hyper.timebar.tracker.WorldTimeTracker;
3029
import net.kyori.adventure.bossbar.BossBar;
30+
import net.kyori.adventure.text.logger.slf4j.ComponentLogger;
3131
import org.bukkit.Bukkit;
3232
import org.bukkit.World;
3333
import org.bukkit.configuration.ConfigurationSection;
@@ -38,14 +38,13 @@
3838

3939
import java.io.File;
4040
import java.util.*;
41-
import java.util.logging.Logger;
4241

4342
public final class TimeBar extends JavaPlugin {
4443

4544
public final File configFile = new File(this.getDataFolder(), "config.yml");
4645
public final File realisticSeasonsConfigFile = new File(this.getDataFolder(), "realisticseasons.yml");
4746
public final File advancedSeasonsConfigFile = new File(this.getDataFolder(), "advancedseasons.yml");
48-
public final Logger logger = this.getLogger();
47+
public final ComponentLogger logger = this.getComponentLogger();
4948
public FileConfiguration config;
5049
public FileConfiguration realisticSeasonsConfig;
5150
public FileConfiguration advancedSeasonsConfig;
@@ -68,7 +67,7 @@ public void onEnable() {
6867
hyperLib = new HyperLib(this);
6968
hyperLib.setup();
7069

71-
bStats bstats = new bStats(hyperLib, 10674);
70+
HyperStats bstats = new HyperStats(hyperLib, 10674);
7271
bstats.setup();
7372

7473
textUtils = new TextUtils(hyperLib);
@@ -80,7 +79,7 @@ public void onEnable() {
8079
if (expansion.register()) {
8180
logger.info("Successfully registered placeholders!");
8281
} else {
83-
logger.warning("Unable to register placeholders!");
82+
logger.warn("Unable to register placeholders!");
8483
}
8584
}
8685
if (Bukkit.getPluginManager().getPlugin("RealisticSeasons") != null) {
@@ -102,27 +101,11 @@ public void onEnable() {
102101
Bukkit.getServer().getPluginManager().registerEvents(playerJoinLeave, this);
103102
Bukkit.getServer().getPluginManager().registerEvents(worldChange, this);
104103

105-
Bukkit.getAsyncScheduler().runNow(this, scheduledTask -> {
106-
ModrinthPlugin modrinthPlugin = new ModrinthPlugin("3w9zYjq5");
107-
modrinthPlugin.get();
108-
109-
ModrinthRelease release = modrinthPlugin.getReleaseByVersion(this.getPluginMeta().getVersion());
110-
if (release == null) {
111-
logger.warning("You are running a version not published.");
112-
} else {
113-
int buildsBehind = modrinthPlugin.buildsVersionsBehind(release);
114-
if (buildsBehind > 0) {
115-
ModrinthRelease latest = modrinthPlugin.getLatestRelease();
116-
if (latest != null) {
117-
logger.info("You are " + buildsBehind + " versions behind. Please update!");
118-
logger.info("The latest version is " + latest.getVersion());
119-
logger.info(latest.getVersionPage());
120-
}
121-
} else {
122-
logger.info("Yay! You are running the latest version.");
123-
}
124-
}
125-
});
104+
HyperUpdater updater = new HyperUpdater(hyperLib);
105+
updater.setGitHub("hyperdefined", "TimeBar");
106+
updater.setModrinth("3w9zYjq5");
107+
updater.setHangar("TimeBar", "paper");
108+
updater.check();
126109

127110
for (WorldTimeTracker worldTimeTracker : worldTimeTrackers) {
128111
worldTimeTracker.startTimer();
@@ -136,17 +119,17 @@ public void loadConfig() {
136119
config = YamlConfiguration.loadConfiguration(configFile);
137120
int CONFIG_VERSION = 5;
138121
if (config.getInt("config-version") != CONFIG_VERSION) {
139-
logger.warning("You configuration is out of date! Some features may not work!");
122+
logger.warn("You configuration is out of date! Some features may not work!");
140123
// don't feel like adding a config updater
141124
if (config.getInt("config-version") == 3) {
142-
logger.warning("The configuration system has changed for this version. Please delete your configs and restart the server.");
125+
logger.warn("The configuration system has changed for this version. Please delete your configs and restart the server.");
143126
}
144127
}
145128

146129
// make sure there are worlds on the list
147130
ConfigurationSection worldsSection = config.getConfigurationSection("worlds");
148131
if (worldsSection == null) {
149-
logger.severe("No worlds section found in config! Plugin is unable to function.");
132+
logger.error("No worlds section found in config! Plugin is unable to function.");
150133
Bukkit.getPluginManager().disablePlugin(this);
151134
return;
152135
}
@@ -157,7 +140,7 @@ public void loadConfig() {
157140
World mainWorld = Bukkit.getWorld(worldName);
158141
// skip if the world is invalid
159142
if (mainWorld == null) {
160-
logger.warning(worldName + " is not a valid world, skipping. If it is a valid world, wait for your server to load then try '/timebar reload'");
143+
logger.warn("{} is not a valid world, skipping. If it is a valid world, wait for your server to load then try '/timebar reload'", worldName);
161144
continue;
162145
}
163146
// these are the worlds to display the timebar based on this world
@@ -168,7 +151,7 @@ public void loadConfig() {
168151
if (world != null) {
169152
displayWorlds.add(world);
170153
} else {
171-
logger.warning(worldName + " is not a valid world, skipping. If it is a valid world, wait for your server to load then try '/timebar reload'");
154+
logger.warn("{} is not a valid world, skipping. If it is a valid world, wait for your server to load then try '/timebar reload'", worldName);
172155
}
173156
}
174157

@@ -186,7 +169,7 @@ public void loadConfig() {
186169
try {
187170
bossBarColor = BossBar.Color.valueOf(color);
188171
} catch (IllegalArgumentException exception) {
189-
logger.warning(color + " is not a valid bossbar color. Defaulting to blue.");
172+
logger.warn("{} is not a valid bossbar color. Defaulting to blue.", color);
190173
bossBarColor = BossBar.Color.BLUE;
191174
}
192175
}
@@ -198,7 +181,7 @@ public void loadConfig() {
198181
realisticSeasonsConfig = YamlConfiguration.loadConfiguration(realisticSeasonsConfigFile);
199182
int REALISTIC_SEASONS_CONFIG_VERSION = 4;
200183
if (realisticSeasonsConfig.getInt("config-version") != REALISTIC_SEASONS_CONFIG_VERSION) {
201-
logger.warning("Your /plugins/TimeBar/realisticseasons.yml configuration is out of date! Some features may not work!");
184+
logger.warn("Your /plugins/TimeBar/realisticseasons.yml configuration is out of date! Some features may not work!");
202185
}
203186
}
204187
if (advancedSeasons) {
@@ -208,7 +191,7 @@ public void loadConfig() {
208191
advancedSeasonsConfig = YamlConfiguration.loadConfiguration(advancedSeasonsConfigFile);
209192
int ADVANCED_SEASONS_CONFIG_VERSION = 1;
210193
if (advancedSeasonsConfig.getInt("config-version") != ADVANCED_SEASONS_CONFIG_VERSION) {
211-
logger.warning("Your /plugins/TimeBar/advancedseasons.yml configuration is out of date! Some features may not work!");
194+
logger.warn("Your /plugins/TimeBar/advancedseasons.yml configuration is out of date! Some features may not work!");
212195
}
213196
}
214197
}

src/main/java/lol/hyper/timebar/commands/CommandTimeBar.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636
public class CommandTimeBar implements TabExecutor {
3737

38-
private final TimeBar timeBar;;
38+
private final TimeBar timeBar;
3939

4040
public CommandTimeBar(TimeBar timeBar) {
4141
this.timeBar = timeBar;
@@ -44,7 +44,7 @@ public CommandTimeBar(TimeBar timeBar) {
4444
@Override
4545
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
4646
if (args.length == 0) {
47-
sender.sendMessage(Component.text("TimeBar version " + timeBar.getDescription().getVersion() + ". Created by hyperdefined.", NamedTextColor.GREEN));
47+
sender.sendMessage(Component.text("TimeBar version " + timeBar.getPluginMeta().getVersion() + ". Created by hyperdefined.", NamedTextColor.GREEN));
4848
return true;
4949
}
5050

@@ -137,7 +137,7 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command
137137
}
138138

139139
@Override
140-
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) {
140+
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String @NotNull [] args) {
141141
return Arrays.asList("reload", "on", "off");
142142
}
143143
}

src/main/java/lol/hyper/timebar/timers/AdvancedSeasonsTask.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ public void run() {
5151
return;
5252
}
5353
if (api == null) {
54-
worldTimeTracker.timeBar.logger.severe("Unable to hook into AdvancedSeasonsAPI!");
55-
worldTimeTracker.timeBar.logger.severe("Canceling AdvancedSeasonsTask, please try /timebar reload.");
56-
worldTimeTracker.timeBar.logger.severe("If you keep seeing this issue, please file an issue on GitHub!");
54+
worldTimeTracker.timeBar.logger.error("Unable to hook into AdvancedSeasonsAPI!");
55+
worldTimeTracker.timeBar.logger.error("Canceling AdvancedSeasonsTask, please try /timebar reload.");
56+
worldTimeTracker.timeBar.logger.error("If you keep seeing this issue, please file an issue on GitHub!");
5757
worldTimeTracker.stopTimer();
5858
return;
5959
}
@@ -66,14 +66,14 @@ public void run() {
6666
String timeOfDay = getTimeOfDay(time);
6767
String currentSeason = api.getSeason(world);
6868
if (currentSeason == null) {
69-
worldTimeTracker.timeBar.logger.severe("Unable to read season information from world " + world.getName());
70-
worldTimeTracker.timeBar.logger.severe("This world is not setup with AdvancedSeasons, canceling...");
69+
worldTimeTracker.timeBar.logger.error("Unable to read season information from world {}", world.getName());
70+
worldTimeTracker.timeBar.logger.error("This world is not setup with AdvancedSeasons, canceling...");
7171
this.cancel();
7272
return;
7373
}
7474
String seasonFromConfig = worldTimeTracker.timeBar.advancedSeasonsConfig.getString("seasons." + currentSeason);
7575
if (seasonFromConfig == null) {
76-
worldTimeTracker.timeBar.logger.warning("seasons." + currentSeason + " does not exist in advancedseasons.yml, using default season names...");
76+
worldTimeTracker.timeBar.logger.warn("seasons.{} does not exist in advancedseasons.yml, using default season names...", currentSeason);
7777
seasonFromConfig = currentSeason;
7878
}
7979

@@ -86,14 +86,13 @@ public void run() {
8686
String colorConfig = worldTimeTracker.timeBar.advancedSeasonsConfig.getString("colors." + currentSeason.toUpperCase(Locale.ROOT));
8787
// load from config first
8888
BossBar.Color color = worldTimeTracker.timeBar.bossBarColor;
89-
;
9089
if (colorConfig != null) {
9190
// see if the color is valid
9291
try {
9392
color = BossBar.Color.valueOf(colorConfig);
9493
} catch (IllegalArgumentException exception) {
9594
// if the color is not valid, fall back
96-
worldTimeTracker.timeBar.logger.warning(colorConfig + " is not a valid color for TimeBar.");
95+
worldTimeTracker.timeBar.logger.warn("{} is not a valid color for TimeBar.", colorConfig);
9796
}
9897
}
9998

@@ -142,7 +141,7 @@ public void run() {
142141
private String parseTitle(String timeOfDay, int dayCount, String season, int temp, float progress) {
143142
String title = worldTimeTracker.timeBar.advancedSeasonsConfig.getString("timebar-title");
144143
if (title == null) {
145-
worldTimeTracker.timeBar.logger.severe("timebar-title is not set! Using default.");
144+
worldTimeTracker.timeBar.logger.error("timebar-title is not set! Using default.");
146145
title = "{TIME} (Day {DAYCOUNT}) {SEASON} - {TEMP}";
147146
}
148147

0 commit comments

Comments
 (0)