add support for Minecraft 1.7+

This commit is contained in:
Jack Fitch
2022-10-28 15:46:02 -04:00
parent 8954e93310
commit 6558d82f5c
3 changed files with 16 additions and 15 deletions

View File

@@ -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

View File

@@ -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...");

View File

@@ -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