5 Commits
main ... v1

Author SHA1 Message Date
Jack
9b34da0fdf change version to 1.4.1 2024-08-06 21:28:00 -04:00
Jack
51664841a6 forgot to update line 164... (my bad) 2024-08-06 21:25:30 -04:00
Jack
ae32363e0f Port fix in #12 to legacy 2024-08-06 21:12:54 -04:00
Jack
b1cc12ba85 Merge pull request #9 from Jack1424/main
Add v1.4.0 changes to legacy
2024-07-23 18:10:08 -04:00
Jack
5a48428057 update README.md with legacy information 2024-06-28 18:07:47 -04:00
15 changed files with 55 additions and 76 deletions

View File

@@ -1,6 +1,6 @@
name: Bug report
description: Report problems/issues here
labels: [bug]
labels: bug
body:
- type: checkboxes
attributes:

View File

@@ -1,6 +1,6 @@
name: Feature request
description: Use this to request new features and/or changes
labels: [enhancement]
labels: enhancement
body:
- type: checkboxes
attributes:

View File

@@ -1,3 +1 @@
#file: noinspection YAMLSchemaValidation
#IntelliJ IDEA interprets this as another issue template so the above line is required
blank_issues_enabled: false

View File

@@ -1,2 +1,2 @@
language: java
jdk: openjdk21
jdk: openjdk17

View File

@@ -2,6 +2,11 @@
[![Build Status](https://app.travis-ci.com/Jack1424/RealTimeWeather.svg?branch=master)](https://app.travis-ci.com/Jack1424/RealTimeWeather)
### A lightweight Minecraft server plugin that allows you to sync your server's time and weather with the real world
## ⚠️ This is the legacy branch of RealTimeWeather ⚠️
**Only use legacy versions of RealTimeWeather (v1.x.x) if you NEED support for older versions of Minecraft.**
**If you don't need support for versions older than the most recent versions of Minecraft, don't use the legacy versions of this plugin.**
Legacy versions of RealTimeWeather will not receive as many (if any) updates.
___
**Current Features:**
- Lightweight
@@ -9,19 +14,16 @@ ___
- Supports all Minecraft versions from 1.7+
- Constant time syncing (including custom or real-world sunrise/sunset times)
- Weather syncing (rain/snow and thunder)
- Enable/disable specific worlds
**Upcoming Features:**
- [ ] Commands
- [ ] Multi-world support
- [ ] Folia support
## Installation
Just download the [latest version](https://github.com/Jack1424/RealTimeWeather/releases/latest) of RTW and put it in your `plugins` directory.
Just download the [latest version](https://github.com/Jack1424/RealTimeWeather/releases/) of **a legacy version** of RTW **(legacy versions are any version that starts with v1)** and put it in your `plugins` directory.
You'll need to run your server at least once to generate the configuration file.
After running (and then stopping) your server, simply change the values in the configuration file to what you'd like, and you're good to go.
## Contributions/Support
I'm open to any help/ideas that you have. Just open an issue or a pull request, and I'll be sure to look at it as soon as I can. Builds with `gradlew shadowJar`.
**Legacy versions won't receive as many (if any) updates**, but I'm open to any help/ideas that you have. Just open an issue or a pull request, and I'll be sure to look at it as soon as I can. Builds with `gradlew shadowJar`.
License: GPL-3.0

View File

@@ -1,45 +1,33 @@
plugins {
id 'java'
id 'io.github.goooler.shadow' version '8.1.8' // TODO: Temporarily using fork
id 'com.github.johnrengelman.shadow' version '8.1.1'
}
group = 'io.github.jack1424'
version = '2.0.0-DEV'
group = 'io.github.Jack1424'
version = '1.4.1'
repositories {
mavenCentral()
maven {
name = "papermc-repo"
url = "https://repo.papermc.io/repository/maven-public/"
name = 'papermc-repo'
url = 'https://repo.papermc.io/repository/maven-public/'
}
maven {
name = "sonatype"
url = "https://oss.sonatype.org/content/groups/public/"
name = 'sonatype'
url = 'https://oss.sonatype.org/content/groups/public/'
}
}
dependencies {
compileOnly("io.papermc.paper:paper-api:1.21-R0.1-SNAPSHOT")
implementation("org.bstats:bstats-bukkit:3.0.2")
implementation("org.bukkit:bukkit:1.13-R0.1-SNAPSHOT")
}
shadowJar {
relocate('org.bstats', 'io.github.jack1424.realTimeWeather')
relocate('org.bstats', 'io.github.jack1424.realtimeweather')
}
tasks.jar {
manifest {
attributes["paperweight-mappings-namespace"] = "mojang"
}
}
tasks.shadowJar {
manifest {
attributes["paperweight-mappings-namespace"] = "mojang"
}
}
def targetJavaVersion = 21
def targetJavaVersion = 11
java {
def javaVersion = JavaVersion.toVersion(targetJavaVersion)
sourceCompatibility = javaVersion
@@ -50,10 +38,8 @@ java {
}
tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8'
if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) {
options.release.set(targetJavaVersion)
options.release = targetJavaVersion
}
}

0
gradlew vendored Normal file → Executable file
View File

View File

@@ -1,13 +1,12 @@
package io.github.jack1424.realTimeWeather;
package io.github.jack1424.realtimeweather;
import io.github.jack1424.realTimeWeather.requests.WeatherRequestObject;
import io.github.jack1424.realtimeweather.requests.WeatherRequestObject;
import org.bukkit.World;
import org.bukkit.configuration.file.FileConfiguration;
import org.json.simple.parser.ParseException;
import javax.naming.ConfigurationException;
import java.io.IOException;
import java.net.URISyntaxException;
import java.time.LocalTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
@@ -343,7 +342,7 @@ public class ConfigManager {
} catch (NullPointerException e) {
throw new ConfigurationException("The APIKey cannot be blank");
}
catch (IOException | ParseException | URISyntaxException e) {
catch (IOException | ParseException e) {
rtw.getLogger().severe(e.getMessage());
throw new ConfigurationException("There was an error when validating this APIKey (this does not mean that the API key is invalid)");
}

View File

@@ -1,4 +1,4 @@
package io.github.jack1424.realTimeWeather;
package io.github.jack1424.realtimeweather;
import org.bukkit.World;
import org.bukkit.entity.Player;
@@ -18,8 +18,8 @@ public class EventHandlers implements Listener {
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onCommandPreprocess(PlayerCommandPreprocessEvent event) {
if ((config.getBlockTimeSetCommand() && config.isTimeEnabled() && event.getMessage().toLowerCase().contains("time set "))
|| (config.getBlockWeatherCommand() && config.isWeatherEnabled() && event.getMessage().toLowerCase().contains("weather "))) {
if ((config.getBlockTimeSetCommand() && config.isTimeEnabled() && event.getMessage().contains("time set"))
|| (config.getBlockWeatherCommand() && config.isWeatherEnabled() && event.getMessage().contains("weather"))) {
event.setCancelled(true);
event.getPlayer().sendMessage("Command disabled by RealTimeWeather");
}
@@ -27,8 +27,8 @@ public class EventHandlers implements Listener {
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onConsoleCommand(ServerCommandEvent event) {
if ((config.getBlockTimeSetCommand() && config.isTimeEnabled() && event.getCommand().toLowerCase().contains("time set "))
|| (config.getBlockWeatherCommand() && config.isWeatherEnabled() && event.getCommand().toLowerCase().contains("weather "))) {
if ((config.getBlockTimeSetCommand() && config.isTimeEnabled() && event.getCommand().contains("time set"))
|| (config.getBlockWeatherCommand() && config.isWeatherEnabled() && event.getCommand().contains("weather"))) {
event.setCancelled(true);
event.getSender().sendMessage("Command disabled by RealTimeWeather");
}

View File

@@ -1,9 +1,8 @@
package io.github.jack1424.realTimeWeather;
package io.github.jack1424.realtimeweather;
import io.github.jack1424.realTimeWeather.requests.*;
import io.github.jack1424.realtimeweather.requests.*;
import org.bstats.bukkit.Metrics;
import org.bstats.charts.SimplePie;
import org.bukkit.GameRule;
import org.bukkit.World;
import org.bukkit.plugin.java.JavaPlugin;
@@ -12,6 +11,7 @@ import java.time.LocalTime;
import java.util.Calendar;
import java.util.logging.Logger;
@SuppressWarnings("deprecation")
public final class RealTimeWeather extends JavaPlugin {
private Logger logger;
private ConfigManager config;
@@ -59,9 +59,9 @@ public final class RealTimeWeather extends JavaPlugin {
debug("Re-enabling normal daylight and weather cycles...");
if (config.isTimeEnabled())
world.setGameRule(GameRule.DO_DAYLIGHT_CYCLE, true);
world.setGameRuleValue("doDaylightCycle", "true");
if (config.isWeatherEnabled())
world.setGameRule(GameRule.DO_WEATHER_CYCLE, true);
world.setGameRuleValue("doWeatherCycle", "true");
}
logger.info("Stopping...");
@@ -78,7 +78,7 @@ public final class RealTimeWeather extends JavaPlugin {
debug("Using custom sunrise/sunset times. Sunrise: " + config.getSunriseCustomTime() + ", Sunset: " + config.getSunsetCustomTime());
for (World world : config.getTimeSyncWorlds())
world.setGameRule(GameRule.DO_DAYLIGHT_CYCLE, false);
world.setGameRuleValue("doDaylightCycle", "false");
getServer().getScheduler().scheduleSyncRepeatingTask(this, () -> {
if (config.isTimeEnabled()) {
@@ -87,7 +87,7 @@ public final class RealTimeWeather extends JavaPlugin {
if (config.getSunriseSunset().equals("real")) {
SunriseSunsetRequestObject sunriseSunset;
try {
sunriseSunset = new SunriseSunsetRequestObject(config.getTimeZone(), config.getSunriseSunsetLatitude(), config.getSunriseSunsetLongitude());
sunriseSunset = new SunriseSunsetRequestObject(config.getTimeZone(), config.getWeatherLatitude(), config.getWeatherLongitude());
world.setTime(calculateWorldTime(cal, sunriseSunset.getSunriseTime(), sunriseSunset.getSunsetTime()));
} catch (Exception e) {
logger.severe(e.getMessage());
@@ -126,7 +126,7 @@ public final class RealTimeWeather extends JavaPlugin {
}
for (World world : config.getWeatherSyncWorlds())
world.setGameRule(GameRule.DO_WEATHER_CYCLE, false);
world.setGameRuleValue("doWeatherCycle", "false");
getServer().getScheduler().scheduleSyncRepeatingTask(this, () -> {
debug("Syncing weather...");
@@ -173,9 +173,8 @@ public final class RealTimeWeather extends JavaPlugin {
}
}
@SuppressWarnings("UnstableApiUsage")
public String getUpdateCheck() {
String currentVersion = this.getPluginMeta().getVersion();
String currentVersion = this.getDescription().getVersion();
String latestVersion;
try {
debug("Getting latest version...");

View File

@@ -1,4 +1,4 @@
package io.github.jack1424.realTimeWeather.requests;
package io.github.jack1424.realtimeweather.requests;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
@@ -7,18 +7,16 @@ import org.json.simple.parser.ParseException;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.Scanner;
public class RequestFunctions {
public static Object makeRequest(String URLString) throws IOException, HTTPResponseException, ParseException, URISyntaxException {
public static Object makeRequest(String URLString) throws IOException, HTTPResponseException, ParseException {
int responseCode = getResponseCode(URLString);
if (responseCode > 399)
throw new HTTPResponseException(responseCode);
Scanner scanner = new Scanner(new URI(URLString).toURL().openStream());
Scanner scanner = new Scanner(new URL(URLString).openStream());
StringBuilder response = new StringBuilder();
while (scanner.hasNextLine())
response.append(scanner.nextLine());
@@ -27,8 +25,8 @@ public class RequestFunctions {
return new JSONParser().parse(response.toString());
}
public static int getResponseCode(String URLString) throws IOException, URISyntaxException {
URL url = new URI(URLString).toURL();
public static int getResponseCode(String URLString) throws IOException {
URL url = new URL(URLString);
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestMethod("GET");
con.connect();
@@ -36,7 +34,7 @@ public class RequestFunctions {
}
public static String getLatestVersion() throws Exception {
return ((JSONObject) ((JSONArray) makeRequest("https://api.modrinth.com/v2/project/WRA6ODcm/version")).getFirst()).get("version_number").toString();
return ((JSONObject) ((JSONArray) makeRequest("https://api.modrinth.com/v2/project/WRA6ODcm/version")).get(0)).get("version_number").toString();
}
public static class HTTPResponseException extends Exception {

View File

@@ -1,11 +1,10 @@
package io.github.jack1424.realTimeWeather.requests;
package io.github.jack1424.realtimeweather.requests;
import org.json.simple.JSONObject;
import org.json.simple.parser.ParseException;
import javax.naming.ConfigurationException;
import java.io.IOException;
import java.net.URISyntaxException;
import java.time.LocalDate;
import java.time.LocalTime;
import java.time.ZoneId;
@@ -16,7 +15,7 @@ import java.util.*;
public class SunriseSunsetRequestObject {
private String sunriseTime, sunsetTime;
public SunriseSunsetRequestObject(TimeZone timeZone, String lat, String lon) throws IOException, ParseException, ConfigurationException, URISyntaxException {
public SunriseSunsetRequestObject(TimeZone timeZone, String lat, String lon) throws IOException, ParseException, ConfigurationException {
JSONObject response;
try {
response = (JSONObject) ((JSONObject) RequestFunctions.makeRequest(String.format("https://api.sunrisesunset.io/json?lat=%s&lng=%s&timezone=UTC", lat, lon))).get("results");

View File

@@ -1,4 +1,4 @@
package io.github.jack1424.realTimeWeather.requests;
package io.github.jack1424.realtimeweather.requests;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
@@ -7,12 +7,11 @@ import org.json.simple.parser.ParseException;
import javax.naming.ConfigurationException;
import java.io.IOException;
import java.net.ProtocolException;
import java.net.URISyntaxException;
public class WeatherRequestObject {
private boolean rain = false, thunder = false;
public WeatherRequestObject(String apiKey, String lat, String lon) throws IOException, ParseException, ConfigurationException, URISyntaxException {
public WeatherRequestObject(String apiKey, String lat, String lon) throws IOException, ParseException, ConfigurationException {
JSONArray conditions;
try {
conditions = (JSONArray) ((JSONObject) RequestFunctions.makeRequest(String.format("https://api.openweathermap.org/data/2.5/weather?lat=%s&lon=%s&appid=%s", lat, lon, apiKey))).get("weather");

View File

@@ -1,4 +1,4 @@
# RealTimeWeather Configuration File (v2.0.0)
# RealTimeWeather Configuration File (v1.4.0)
# You can find detailed instructions at: https://github.com/Jack1424/RealTimeWeather/wiki#editing-the-configuration-file
######################################## Real Time Weather Settings ##################################################

View File

@@ -1,8 +1,7 @@
main: io.github.jack1424.realTimeWeather.RealTimeWeather
name: RealTimeWeather
version: '${version}'
description: Sync your Minecraft server's time and weather with the real world
api-version: '1.21'
description: Sync your server time and weather with the real world
main: io.github.jack1424.realtimeweather.RealTimeWeather
load: POSTWORLD
author: Jack1424
website: github.com/Jack1424/RealTimeWeather
authors: [Jack1424]
website: https://github.com/Jack1424/RealTimeWeather