From 6558d82f5c57248c7632790620fda02e2a72b0ab Mon Sep 17 00:00:00 2001 From: Jack Fitch <55409055+Jack1424@users.noreply.github.com> Date: Fri, 28 Oct 2022 15:46:02 -0400 Subject: [PATCH] add support for Minecraft 1.7+ --- build.gradle | 6 ++--- .../realtimeweather/RealTimeWeather.java | 24 ++++++++++--------- src/main/resources/plugin.yml | 1 - 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/build.gradle b/build.gradle index cf9e380..c9b6e8f 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,7 @@ plugins { } group = 'io.github.Jack1424' -version = '1.1.2' +version = '1.2.0' repositories { mavenCentral() @@ -20,14 +20,14 @@ repositories { dependencies { implementation("org.bstats:bstats-bukkit:3.0.0") - compileOnly 'io.papermc.paper:paper-api:1.19.2-R0.1-SNAPSHOT' + implementation("org.bukkit:bukkit:1.13-R0.1-SNAPSHOT") } shadowJar { relocate('org.bstats', 'io.github.jack1424.realtimeweather') } -def targetJavaVersion = 17 +def targetJavaVersion = 11 java { def javaVersion = JavaVersion.toVersion(targetJavaVersion) sourceCompatibility = javaVersion diff --git a/src/main/java/io/github/jack1424/realtimeweather/RealTimeWeather.java b/src/main/java/io/github/jack1424/realtimeweather/RealTimeWeather.java index dcba828..4b72eb0 100644 --- a/src/main/java/io/github/jack1424/realtimeweather/RealTimeWeather.java +++ b/src/main/java/io/github/jack1424/realtimeweather/RealTimeWeather.java @@ -2,7 +2,6 @@ package io.github.jack1424.realtimeweather; import org.bstats.bukkit.Metrics; import org.bstats.charts.SimplePie; -import org.bukkit.GameRule; import org.bukkit.World; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -62,9 +61,9 @@ public final class RealTimeWeather extends JavaPlugin implements Listener { debug("Re-enabling normal daylight and weather cycles..."); if (timeEnabled) - world.setGameRule(GameRule.DO_DAYLIGHT_CYCLE, true); + world.setGameRuleValue("doDaylightCycle", "true"); if (weatherEnabled) - world.setGameRule(GameRule.DO_WEATHER_CYCLE, true); + world.setGameRuleValue("doWeatherCycle", "true"); } logger.info("Stopping..."); @@ -103,7 +102,7 @@ public final class RealTimeWeather extends JavaPlugin implements Listener { for (World world : getServer().getWorlds()) if (world.getEnvironment().equals(World.Environment.NORMAL)) - world.setGameRule(GameRule.DO_DAYLIGHT_CYCLE, false); + world.setGameRuleValue("doDaylightCycle", "false"); getServer().getScheduler().scheduleSyncRepeatingTask(this, () -> { if (timeEnabled) { @@ -129,15 +128,18 @@ public final class RealTimeWeather extends JavaPlugin implements Listener { int response = con.getResponseCode(); if (response > 499) { logger.severe("There was a server error when requesting weather information. Please try again later"); - throw new Exception("Server error"); + throw new Exception("Server/client error"); } else if (response > 399) { String message = "Error when getting weather information: "; - switch (response) { - case 401 -> logger.severe(message + "API key incorrect"); - case 404 -> logger.severe(message + "Zip/Country code incorrect"); - default -> logger.severe("Unknown error"); - } + + if (response == 401) + logger.severe(message + "API key incorrect"); + else if (response == 404) + logger.severe(message + "Zip/Country code incorrect"); + else + logger.severe("Unknown error"); + logger.severe("Please check that the values set in the config file are correct"); throw new Exception("Configuration error"); @@ -156,7 +158,7 @@ public final class RealTimeWeather extends JavaPlugin implements Listener { for (World world : getServer().getWorlds()) if (world.getEnvironment().equals(World.Environment.NORMAL)) - world.setGameRule(GameRule.DO_WEATHER_CYCLE, false); + world.setGameRuleValue("doWeatherCycle", "false"); getServer().getScheduler().scheduleSyncRepeatingTask(this, () -> { debug("Syncing weather..."); diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index b792591..2fda3b7 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -2,6 +2,5 @@ name: RealTimeWeather version: '${version}' description: Sync your server time and weather with the real world main: io.github.jack1424.realtimeweather.RealTimeWeather -api-version: 1.19 authors: [ Jack1424 ] website: https://github.com/Jack1424/RealTimeWeather