Compare commits
14 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
f99eceb46f | ||
|
df9b8f1fcd | ||
|
6f5f69ee9e | ||
|
333325c4e0 | ||
|
c83fe91f4e | ||
|
6fb3745d64 | ||
|
23b64653a8 | ||
|
5ef5db1cd5 | ||
|
bb14509fbd | ||
|
92b92b5969 | ||
|
8280d9b78c | ||
|
cca328c5ee | ||
|
d2796f7992 | ||
|
c4c5ca7558 |
2
.github/ISSUE_TEMPLATE/BUG-REPORT.yml
vendored
2
.github/ISSUE_TEMPLATE/BUG-REPORT.yml
vendored
@@ -1,6 +1,6 @@
|
||||
name: Bug report
|
||||
description: Report problems/issues here
|
||||
labels: bug
|
||||
labels: [bug]
|
||||
body:
|
||||
- type: checkboxes
|
||||
attributes:
|
||||
|
2
.github/ISSUE_TEMPLATE/FEATURE-REQUEST.yml
vendored
2
.github/ISSUE_TEMPLATE/FEATURE-REQUEST.yml
vendored
@@ -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:
|
||||
|
2
.github/ISSUE_TEMPLATE/config.yml
vendored
2
.github/ISSUE_TEMPLATE/config.yml
vendored
@@ -1 +1,3 @@
|
||||
#file: noinspection YAMLSchemaValidation
|
||||
#IntelliJ IDEA interprets this as another issue template so the above line is required
|
||||
blank_issues_enabled: false
|
||||
|
@@ -1,2 +1,2 @@
|
||||
language: java
|
||||
jdk: openjdk17
|
||||
jdk: openjdk21
|
12
README.md
12
README.md
@@ -2,11 +2,6 @@
|
||||
[](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
|
||||
@@ -14,16 +9,19 @@ ___
|
||||
- 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/) of **a legacy version** of RTW **(legacy versions are any version that starts with v1)** and put it in your `plugins` directory.
|
||||
Just download the [latest version](https://github.com/Jack1424/RealTimeWeather/releases/latest) of RTW 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
|
||||
**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`.
|
||||
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
|
||||
|
36
build.gradle
36
build.gradle
@@ -1,33 +1,45 @@
|
||||
plugins {
|
||||
id 'java'
|
||||
id 'com.github.johnrengelman.shadow' version '8.1.1'
|
||||
id 'io.github.goooler.shadow' version '8.1.8' // TODO: Temporarily using fork
|
||||
}
|
||||
|
||||
group = 'io.github.Jack1424'
|
||||
version = '1.4.1'
|
||||
group = 'io.github.jack1424'
|
||||
version = '2.0.0-DEV'
|
||||
|
||||
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')
|
||||
}
|
||||
|
||||
def targetJavaVersion = 11
|
||||
tasks.jar {
|
||||
manifest {
|
||||
attributes["paperweight-mappings-namespace"] = "mojang"
|
||||
}
|
||||
}
|
||||
|
||||
tasks.shadowJar {
|
||||
manifest {
|
||||
attributes["paperweight-mappings-namespace"] = "mojang"
|
||||
}
|
||||
}
|
||||
|
||||
def targetJavaVersion = 21
|
||||
java {
|
||||
def javaVersion = JavaVersion.toVersion(targetJavaVersion)
|
||||
sourceCompatibility = javaVersion
|
||||
@@ -38,8 +50,10 @@ java {
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
options.encoding = 'UTF-8'
|
||||
|
||||
if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) {
|
||||
options.release = targetJavaVersion
|
||||
options.release.set(targetJavaVersion)
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,12 +1,13 @@
|
||||
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;
|
||||
@@ -342,7 +343,7 @@ public class ConfigManager {
|
||||
} catch (NullPointerException e) {
|
||||
throw new ConfigurationException("The APIKey cannot be blank");
|
||||
}
|
||||
catch (IOException | ParseException e) {
|
||||
catch (IOException | ParseException | URISyntaxException 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)");
|
||||
}
|
@@ -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().contains("time set"))
|
||||
|| (config.getBlockWeatherCommand() && config.isWeatherEnabled() && event.getMessage().contains("weather"))) {
|
||||
if ((config.getBlockTimeSetCommand() && config.isTimeEnabled() && event.getMessage().toLowerCase().contains("time set "))
|
||||
|| (config.getBlockWeatherCommand() && config.isWeatherEnabled() && event.getMessage().toLowerCase().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().contains("time set"))
|
||||
|| (config.getBlockWeatherCommand() && config.isWeatherEnabled() && event.getCommand().contains("weather"))) {
|
||||
if ((config.getBlockTimeSetCommand() && config.isTimeEnabled() && event.getCommand().toLowerCase().contains("time set "))
|
||||
|| (config.getBlockWeatherCommand() && config.isWeatherEnabled() && event.getCommand().toLowerCase().contains("weather "))) {
|
||||
event.setCancelled(true);
|
||||
event.getSender().sendMessage("Command disabled by RealTimeWeather");
|
||||
}
|
@@ -1,8 +1,9 @@
|
||||
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;
|
||||
|
||||
@@ -11,7 +12,6 @@ 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.setGameRuleValue("doDaylightCycle", "true");
|
||||
world.setGameRule(GameRule.DO_DAYLIGHT_CYCLE, true);
|
||||
if (config.isWeatherEnabled())
|
||||
world.setGameRuleValue("doWeatherCycle", "true");
|
||||
world.setGameRule(GameRule.DO_WEATHER_CYCLE, 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.setGameRuleValue("doDaylightCycle", "false");
|
||||
world.setGameRule(GameRule.DO_DAYLIGHT_CYCLE, 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.getWeatherLatitude(), config.getWeatherLongitude());
|
||||
sunriseSunset = new SunriseSunsetRequestObject(config.getTimeZone(), config.getSunriseSunsetLatitude(), config.getSunriseSunsetLongitude());
|
||||
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.setGameRuleValue("doWeatherCycle", "false");
|
||||
world.setGameRule(GameRule.DO_WEATHER_CYCLE, false);
|
||||
|
||||
getServer().getScheduler().scheduleSyncRepeatingTask(this, () -> {
|
||||
debug("Syncing weather...");
|
||||
@@ -173,8 +173,9 @@ public final class RealTimeWeather extends JavaPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("UnstableApiUsage")
|
||||
public String getUpdateCheck() {
|
||||
String currentVersion = this.getDescription().getVersion();
|
||||
String currentVersion = this.getPluginMeta().getVersion();
|
||||
String latestVersion;
|
||||
try {
|
||||
debug("Getting latest version...");
|
@@ -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,16 +7,18 @@ 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 {
|
||||
public static Object makeRequest(String URLString) throws IOException, HTTPResponseException, ParseException, URISyntaxException {
|
||||
int responseCode = getResponseCode(URLString);
|
||||
if (responseCode > 399)
|
||||
throw new HTTPResponseException(responseCode);
|
||||
|
||||
Scanner scanner = new Scanner(new URL(URLString).openStream());
|
||||
Scanner scanner = new Scanner(new URI(URLString).toURL().openStream());
|
||||
StringBuilder response = new StringBuilder();
|
||||
while (scanner.hasNextLine())
|
||||
response.append(scanner.nextLine());
|
||||
@@ -25,8 +27,8 @@ public class RequestFunctions {
|
||||
return new JSONParser().parse(response.toString());
|
||||
}
|
||||
|
||||
public static int getResponseCode(String URLString) throws IOException {
|
||||
URL url = new URL(URLString);
|
||||
public static int getResponseCode(String URLString) throws IOException, URISyntaxException {
|
||||
URL url = new URI(URLString).toURL();
|
||||
HttpURLConnection con = (HttpURLConnection) url.openConnection();
|
||||
con.setRequestMethod("GET");
|
||||
con.connect();
|
||||
@@ -34,7 +36,7 @@ public class RequestFunctions {
|
||||
}
|
||||
|
||||
public static String getLatestVersion() throws Exception {
|
||||
return ((JSONObject) ((JSONArray) makeRequest("https://api.modrinth.com/v2/project/WRA6ODcm/version")).get(0)).get("version_number").toString();
|
||||
return ((JSONObject) ((JSONArray) makeRequest("https://api.modrinth.com/v2/project/WRA6ODcm/version")).getFirst()).get("version_number").toString();
|
||||
}
|
||||
|
||||
public static class HTTPResponseException extends Exception {
|
@@ -1,10 +1,11 @@
|
||||
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;
|
||||
@@ -15,7 +16,7 @@ import java.util.*;
|
||||
public class SunriseSunsetRequestObject {
|
||||
private String sunriseTime, sunsetTime;
|
||||
|
||||
public SunriseSunsetRequestObject(TimeZone timeZone, String lat, String lon) throws IOException, ParseException, ConfigurationException {
|
||||
public SunriseSunsetRequestObject(TimeZone timeZone, String lat, String lon) throws IOException, ParseException, ConfigurationException, URISyntaxException {
|
||||
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");
|
@@ -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,11 +7,12 @@ 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 {
|
||||
public WeatherRequestObject(String apiKey, String lat, String lon) throws IOException, ParseException, ConfigurationException, URISyntaxException {
|
||||
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");
|
@@ -1,4 +1,4 @@
|
||||
# RealTimeWeather Configuration File (v1.4.0)
|
||||
# RealTimeWeather Configuration File (v2.0.0)
|
||||
# You can find detailed instructions at: https://github.com/Jack1424/RealTimeWeather/wiki#editing-the-configuration-file
|
||||
|
||||
######################################## Real Time Weather Settings ##################################################
|
||||
|
@@ -1,7 +1,8 @@
|
||||
main: io.github.jack1424.realTimeWeather.RealTimeWeather
|
||||
name: RealTimeWeather
|
||||
version: '${version}'
|
||||
description: Sync your server time and weather with the real world
|
||||
main: io.github.jack1424.realtimeweather.RealTimeWeather
|
||||
description: Sync your Minecraft server's time and weather with the real world
|
||||
api-version: '1.21'
|
||||
load: POSTWORLD
|
||||
authors: [Jack1424]
|
||||
website: https://github.com/Jack1424/RealTimeWeather
|
||||
author: Jack1424
|
||||
website: github.com/Jack1424/RealTimeWeather
|
||||
|
Reference in New Issue
Block a user