Compare commits
No commits in common. "0.5-fix" and "master" have entirely different histories.
81 changed files with 2952 additions and 1458 deletions
57
.classpath
57
.classpath
|
@ -1,57 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
<attribute name="optional" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" path="target/generated-sources/annotations">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
<attribute name="ignore_optional_problems" value="true"/>
|
||||
<attribute name="m2e-apt" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" output="target/classes" path="src/main/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
<attribute name="test" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
<attribute name="test" value="true"/>
|
||||
<attribute name="optional" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" output="target/test-classes" path="target/generated-test-sources/test-annotations">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
<attribute name="ignore_optional_problems" value="true"/>
|
||||
<attribute name="m2e-apt" value="true"/>
|
||||
<attribute name="test" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
</classpath>
|
20
.forgejo/workflows/build.yml
Normal file
20
.forgejo/workflows/build.yml
Normal file
|
@ -0,0 +1,20 @@
|
|||
on: [push]
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: docker
|
||||
container: debian:sid
|
||||
steps:
|
||||
- name: Prepare for installation
|
||||
run: apt update
|
||||
- name: Install JDK
|
||||
run: apt install --no-install-recommends -y openjdk-21-jdk-headless maven git nodejs
|
||||
|
||||
- name: Clone repository
|
||||
run: git clone https://git.m724.eu/Minecon724/realweather.git .
|
||||
|
||||
- name: Build
|
||||
run: mvn clean package
|
||||
- name: Upload artifacts
|
||||
uses: https://github.com/actions/upload-artifact@v3
|
||||
with:
|
||||
path: target/realweather-*.jar
|
25
.github/workflows/build.yml
vendored
25
.github/workflows/build.yml
vendored
|
@ -1,25 +0,0 @@
|
|||
name: build
|
||||
run-name: Build and package
|
||||
on: [push, pull_request]
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Set up JDK 17 for x64
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
java-version: '17'
|
||||
distribution: 'temurin'
|
||||
architecture: x64
|
||||
|
||||
- name: mvn clean package
|
||||
run: mvn clean package
|
||||
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: Package
|
||||
path: target/*.jar
|
||||
if-no-files-found: error
|
9
.gitignore
vendored
9
.gitignore
vendored
|
@ -1,7 +1,2 @@
|
|||
target/
|
||||
|
||||
# IDE files
|
||||
org.eclipse.*
|
||||
.vscode/
|
||||
.classpath
|
||||
.project
|
||||
/target/
|
||||
/.settings/
|
||||
|
|
10
.gitpod.yml
10
.gitpod.yml
|
@ -1,10 +0,0 @@
|
|||
# This configuration file was automatically generated by Gitpod.
|
||||
# Please adjust to your needs (see https://www.gitpod.io/docs/config-gitpod-file)
|
||||
# and commit this file to your remote git repository to share the goodness with others.
|
||||
|
||||
image: gitpod/workspace-java-17
|
||||
|
||||
tasks:
|
||||
- init: mvn clean install
|
||||
|
||||
|
3
.idea/.gitignore
vendored
Normal file
3
.idea/.gitignore
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
13
.idea/compiler.xml
Normal file
13
.idea/compiler.xml
Normal file
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<annotationProcessing>
|
||||
<profile name="Maven default annotation processors profile" enabled="true">
|
||||
<sourceOutputDir name="target/generated-sources/annotations" />
|
||||
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
||||
<outputRelativeToContentRoot value="true" />
|
||||
<module name="realweather" />
|
||||
</profile>
|
||||
</annotationProcessing>
|
||||
</component>
|
||||
</project>
|
7
.idea/encodings.xml
Normal file
7
.idea/encodings.xml
Normal file
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding">
|
||||
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
|
||||
</component>
|
||||
</project>
|
8
.idea/inspectionProfiles/Project_Default.xml
Normal file
8
.idea/inspectionProfiles/Project_Default.xml
Normal file
|
@ -0,0 +1,8 @@
|
|||
<component name="InspectionProjectProfileManager">
|
||||
<profile version="1.0">
|
||||
<option name="myName" value="Project Default" />
|
||||
<inspection_tool class="VulnerableLibrariesLocal" enabled="true" level="WARNING" enabled_by_default="true">
|
||||
<option name="isIgnoringEnabled" value="true" />
|
||||
</inspection_tool>
|
||||
</profile>
|
||||
</component>
|
30
.idea/jarRepositories.xml
Normal file
30
.idea/jarRepositories.xml
Normal file
|
@ -0,0 +1,30 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="RemoteRepositoriesConfiguration">
|
||||
<remote-repository>
|
||||
<option name="id" value="central" />
|
||||
<option name="name" value="Central Repository" />
|
||||
<option name="url" value="https://repo.maven.apache.org/maven2" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="m724" />
|
||||
<option name="name" value="m724" />
|
||||
<option name="url" value="https://git.m724.eu/api/packages/Minecon724/maven" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="spigot-repo" />
|
||||
<option name="name" value="spigot-repo" />
|
||||
<option name="url" value="https://hub.spigotmc.org/nexus/content/repositories/snapshots/" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="central" />
|
||||
<option name="name" value="Maven Central repository" />
|
||||
<option name="url" value="https://repo1.maven.org/maven2" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="jboss.community" />
|
||||
<option name="name" value="JBoss Community repository" />
|
||||
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
|
||||
</remote-repository>
|
||||
</component>
|
||||
</project>
|
12
.idea/misc.xml
Normal file
12
.idea/misc.xml
Normal file
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="MavenProjectsManager">
|
||||
<option name="originalFiles">
|
||||
<list>
|
||||
<option value="$PROJECT_DIR$/pom.xml" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="temurin-21" project-jdk-type="JavaSDK" />
|
||||
</project>
|
8
.idea/modules.xml
Normal file
8
.idea/modules.xml
Normal file
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/realweather.iml" filepath="$PROJECT_DIR$/realweather.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
124
.idea/uiDesigner.xml
Normal file
124
.idea/uiDesigner.xml
Normal file
|
@ -0,0 +1,124 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Palette2">
|
||||
<group name="Swing">
|
||||
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
|
||||
</item>
|
||||
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.svg" removable="false" auto-create-binding="false" can-attach-label="true">
|
||||
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
|
||||
<initial-values>
|
||||
<property name="text" value="Button" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="RadioButton" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="CheckBox" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="Label" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
|
||||
<preferred-size width="-1" height="20" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
|
||||
</item>
|
||||
</group>
|
||||
</component>
|
||||
</project>
|
6
.idea/vcs.xml
Normal file
6
.idea/vcs.xml
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
34
.project
34
.project
|
@ -1,34 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>realweather</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||
</natures>
|
||||
<filteredResources>
|
||||
<filter>
|
||||
<id>1693298440613</id>
|
||||
<name></name>
|
||||
<type>30</type>
|
||||
<matcher>
|
||||
<id>org.eclipse.core.resources.regexFilterMatcher</id>
|
||||
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
|
||||
</matcher>
|
||||
</filter>
|
||||
</filteredResources>
|
||||
</projectDescription>
|
11
DOMAINS-FIREWALL.md
Normal file
11
DOMAINS-FIREWALL.md
Normal file
|
@ -0,0 +1,11 @@
|
|||
If you're using a firewall, you must allow the following hosts:
|
||||
- updater:
|
||||
* git.m724.eu
|
||||
- weather:
|
||||
* api.openweathermap.org
|
||||
- thunder:
|
||||
* ws1.blitzortung.org
|
||||
* ws7.blitzortung.org
|
||||
* ws8.blitzortung.org
|
||||
|
||||
Subject to change!
|
617
LICENSE.md
Normal file
617
LICENSE.md
Normal file
|
@ -0,0 +1,617 @@
|
|||
# GNU GENERAL PUBLIC LICENSE
|
||||
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc.
|
||||
<https://fsf.org/>
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim copies of this
|
||||
license document, but changing it is not allowed.
|
||||
|
||||
## Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom
|
||||
to share and change all versions of a program--to make sure it remains
|
||||
free software for all its users. We, the Free Software Foundation, use
|
||||
the GNU General Public License for most of our software; it applies
|
||||
also to any other work released this way by its authors. You can apply
|
||||
it to your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you
|
||||
have certain responsibilities if you distribute copies of the
|
||||
software, or if you modify it: responsibilities to respect the freedom
|
||||
of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the
|
||||
manufacturer can do so. This is fundamentally incompatible with the
|
||||
aim of protecting users' freedom to change the software. The
|
||||
systematic pattern of such abuse occurs in the area of products for
|
||||
individuals to use, which is precisely where it is most unacceptable.
|
||||
Therefore, we have designed this version of the GPL to prohibit the
|
||||
practice for those products. If such problems arise substantially in
|
||||
other domains, we stand ready to extend this provision to those
|
||||
domains in future versions of the GPL, as needed to protect the
|
||||
freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish
|
||||
to avoid the special danger that patents applied to a free program
|
||||
could make it effectively proprietary. To prevent this, the GPL
|
||||
assures that patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
## TERMS AND CONDITIONS
|
||||
|
||||
### 0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds
|
||||
of works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of
|
||||
an exact copy. The resulting work is called a "modified version" of
|
||||
the earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user
|
||||
through a computer network, with no transfer of a copy, is not
|
||||
conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices" to
|
||||
the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
### 1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work for
|
||||
making modifications to it. "Object code" means any non-source form of
|
||||
a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users can
|
||||
regenerate automatically from other parts of the Corresponding Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that same
|
||||
work.
|
||||
|
||||
### 2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not convey,
|
||||
without conditions so long as your license otherwise remains in force.
|
||||
You may convey covered works to others for the sole purpose of having
|
||||
them make modifications exclusively for you, or provide you with
|
||||
facilities for running those works, provided that you comply with the
|
||||
terms of this License in conveying all material for which you do not
|
||||
control copyright. Those thus making or running the covered works for
|
||||
you must do so exclusively on your behalf, under your direction and
|
||||
control, on terms that prohibit them from making any copies of your
|
||||
copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under the
|
||||
conditions stated below. Sublicensing is not allowed; section 10 makes
|
||||
it unnecessary.
|
||||
|
||||
### 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such
|
||||
circumvention is effected by exercising rights under this License with
|
||||
respect to the covered work, and you disclaim any intention to limit
|
||||
operation or modification of the work as a means of enforcing, against
|
||||
the work's users, your or third parties' legal rights to forbid
|
||||
circumvention of technological measures.
|
||||
|
||||
### 4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
### 5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these
|
||||
conditions:
|
||||
|
||||
- a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
- b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under
|
||||
section 7. This requirement modifies the requirement in section 4
|
||||
to "keep intact all notices".
|
||||
- c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
- d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
### 6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms of
|
||||
sections 4 and 5, provided that you also convey the machine-readable
|
||||
Corresponding Source under the terms of this License, in one of these
|
||||
ways:
|
||||
|
||||
- a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
- b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the Corresponding
|
||||
Source from a network server at no charge.
|
||||
- c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
- d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
- e) Convey the object code using peer-to-peer transmission,
|
||||
provided you inform other peers where the object code and
|
||||
Corresponding Source of the work are being offered to the general
|
||||
public at no charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal,
|
||||
family, or household purposes, or (2) anything designed or sold for
|
||||
incorporation into a dwelling. In determining whether a product is a
|
||||
consumer product, doubtful cases shall be resolved in favor of
|
||||
coverage. For a particular product received by a particular user,
|
||||
"normally used" refers to a typical or common use of that class of
|
||||
product, regardless of the status of the particular user or of the way
|
||||
in which the particular user actually uses, or expects or is expected
|
||||
to use, the product. A product is a consumer product regardless of
|
||||
whether the product has substantial commercial, industrial or
|
||||
non-consumer uses, unless such uses represent the only significant
|
||||
mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to
|
||||
install and execute modified versions of a covered work in that User
|
||||
Product from a modified version of its Corresponding Source. The
|
||||
information must suffice to ensure that the continued functioning of
|
||||
the modified object code is in no case prevented or interfered with
|
||||
solely because modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or
|
||||
updates for a work that has been modified or installed by the
|
||||
recipient, or for the User Product in which it has been modified or
|
||||
installed. Access to a network may be denied when the modification
|
||||
itself materially and adversely affects the operation of the network
|
||||
or violates the rules and protocols for communication across the
|
||||
network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
### 7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders
|
||||
of that material) supplement the terms of this License with terms:
|
||||
|
||||
- a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
- b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
- c) Prohibiting misrepresentation of the origin of that material,
|
||||
or requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
- d) Limiting the use for publicity purposes of names of licensors
|
||||
or authors of the material; or
|
||||
- e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
- f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions
|
||||
of it) with contractual assumptions of liability to the recipient,
|
||||
for any liability that these contractual assumptions directly
|
||||
impose on those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions; the
|
||||
above requirements apply either way.
|
||||
|
||||
### 8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your license
|
||||
from a particular copyright holder is reinstated (a) provisionally,
|
||||
unless and until the copyright holder explicitly and finally
|
||||
terminates your license, and (b) permanently, if the copyright holder
|
||||
fails to notify you of the violation by some reasonable means prior to
|
||||
60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
### 9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or run
|
||||
a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
### 10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
### 11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims owned
|
||||
or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within the
|
||||
scope of its coverage, prohibits the exercise of, or is conditioned on
|
||||
the non-exercise of one or more of the rights that are specifically
|
||||
granted under this License. You may not convey a covered work if you
|
||||
are a party to an arrangement with a third party that is in the
|
||||
business of distributing software, under which you make payment to the
|
||||
third party based on the extent of your activity of conveying the
|
||||
work, and under which the third party grants, to any of the parties
|
||||
who would receive the covered work from you, a discriminatory patent
|
||||
license (a) in connection with copies of the covered work conveyed by
|
||||
you (or copies made from those copies), or (b) primarily for and in
|
||||
connection with specific products or compilations that contain the
|
||||
covered work, unless you entered into that arrangement, or that patent
|
||||
license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
### 12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under
|
||||
this License and any other pertinent obligations, then as a
|
||||
consequence you may not convey it at all. For example, if you agree to
|
||||
terms that obligate you to collect a royalty for further conveying
|
||||
from those to whom you convey the Program, the only way you could
|
||||
satisfy both those terms and this License would be to refrain entirely
|
||||
from conveying the Program.
|
||||
|
||||
### 13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
### 14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions
|
||||
of the GNU General Public License from time to time. Such new versions
|
||||
will be similar in spirit to the present version, but may differ in
|
||||
detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies that a certain numbered version of the GNU General Public
|
||||
License "or any later version" applies to it, you have the option of
|
||||
following the terms and conditions either of that numbered version or
|
||||
of any later version published by the Free Software Foundation. If the
|
||||
Program does not specify a version number of the GNU General Public
|
||||
License, you may choose any version ever published by the Free
|
||||
Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future versions
|
||||
of the GNU General Public License can be used, that proxy's public
|
||||
statement of acceptance of a version permanently authorizes you to
|
||||
choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
### 15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT
|
||||
WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND
|
||||
PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE
|
||||
DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR
|
||||
CORRECTION.
|
||||
|
||||
### 16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR
|
||||
CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES
|
||||
ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT
|
||||
NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR
|
||||
LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM
|
||||
TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER
|
||||
PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
### 17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
16
README.md
16
README.md
|
@ -1 +1,15 @@
|
|||
[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/Minecon724/RealWeather)
|
||||
# realweather
|
||||
|
||||
For MC 1.19.4+ and Java 21+
|
||||
|
||||
### Building
|
||||
To compile, clone this repo and `mvn clean package`. \
|
||||
JAR will be in `target/`. Use the one without `original-`. \
|
||||
By default, it's signed with the test key.
|
||||
|
||||
#### Signing
|
||||
A test (and default) keystore is provided:
|
||||
- keystore: `testkeystore.jks`
|
||||
- storepass: `123456`
|
||||
- alias: `testkey`
|
||||
Override with `-Djarsigner.`
|
14
TODO.md
14
TODO.md
|
@ -1,14 +0,0 @@
|
|||
Milestone: yesterday
|
||||
- fix bugs
|
||||
|
||||
Milestone: 0.5.1
|
||||
- local maxmind
|
||||
- readd metrics
|
||||
- cache cleaning
|
||||
|
||||
Milestone: 0.6.0
|
||||
- account for real sun movement, not just time
|
||||
|
||||
Milestone: future
|
||||
- weather simulator (weather is clientside rn and doesnt have things such as lightning or other effects)
|
||||
- tests
|
|
@ -1,63 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>pl.minecon724</groupId>
|
||||
<artifactId>realweather</artifactId>
|
||||
<version>0.0.1</version>
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
<filtering>true</filtering>
|
||||
<directory>src/main/resources</directory>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.3.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<minimizeJar>true</minimizeJar>
|
||||
<artifactSet>
|
||||
<includes>
|
||||
<include>org.json:json</include>
|
||||
</includes>
|
||||
</artifactSet>
|
||||
<filters>
|
||||
<filter>
|
||||
<artifact>org.json:*</artifact>
|
||||
<excludes>
|
||||
<exclude>META-INF/*.MF</exclude>
|
||||
</excludes>
|
||||
</filter>
|
||||
</filters>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.18.2-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<properties>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
</properties>
|
||||
</project>
|
73
notes.txt
Normal file
73
notes.txt
Normal file
|
@ -0,0 +1,73 @@
|
|||
goal: realtime to in game time conversion
|
||||
There is no need to keep days
|
||||
|
||||
minecraft day is 0 - 24000 ticks
|
||||
where 6000 ticks is noon (peak sun) and 18000 is midnight (peak moon)
|
||||
|
||||
irl day is 0 - 86400 seconds
|
||||
|
||||
0. s = epoch % 86400 to get seconds since midnight
|
||||
^
|
||||
(* scale) here
|
||||
1. t = s / 72.0 to fit into minecraft day
|
||||
2. t = t * 20 to convert that to ticks
|
||||
3. t = t - 6000 to align noon and midnight
|
||||
this leaves us with negative time, so
|
||||
4. t = floorMod(t, 24000) to wrap if negative
|
||||
|
||||
example:
|
||||
epoch = 1713593340
|
||||
|
||||
0. getting seconds since midnight
|
||||
s = epoch % 86400
|
||||
s = 1713593340 % 86400
|
||||
s = 22140
|
||||
|
||||
1. conversion to minecraft day length
|
||||
gs = s / 72.0
|
||||
gs = 22140 / 72.0
|
||||
gs = 307.5
|
||||
|
||||
2. to ticks
|
||||
t = gs * 20
|
||||
t = 307.5 * 20
|
||||
t = 6150
|
||||
|
||||
3. step 3
|
||||
t = t - 6000
|
||||
t = 6150 - 6000
|
||||
t = 150
|
||||
|
||||
4. wrapping
|
||||
t = floorMod(150, 24000)
|
||||
t = 150
|
||||
|
||||
|
||||
goal: frequency of time update
|
||||
|
||||
t = 72 / scale
|
||||
t is the period, in ticks of course
|
||||
|
||||
to see how many irl seconds a tick represents:
|
||||
s = 3.6 * scale
|
||||
(from 1 / (1/72 * 20 * scale))
|
||||
|
||||
however, some scales result in fractions
|
||||
here's how many in game aligned seconds have passed at the end of a real day:
|
||||
84000 / 72 * scale * floor(72/scale)
|
||||
for scale 0.99: 83160
|
||||
so we'll be 14 minutes behind
|
||||
|
||||
solution? for now let's warn and update time every tick
|
||||
to check:
|
||||
scale * floor(72/scale) == 72
|
||||
|
||||
|
||||
goal: offsetting by player position
|
||||
|
||||
t = (longitude / 15) * 1000 * scale
|
||||
|
||||
accounting for sunrise and sunset
|
||||
TODO, idk yet without
|
||||
update: this is now possible with 0.8.0 api
|
||||
|
128
pom.xml
128
pom.xml
|
@ -1,12 +1,17 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>pl.minecon724</groupId>
|
||||
<groupId>eu.m724</groupId>
|
||||
<artifactId>realweather</artifactId>
|
||||
<version>0.5.0.2</version>
|
||||
<version>1.0.0-alpha-6-SNAPSHOT</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<maven.compiler.source>21</maven.compiler.source>
|
||||
<maven.compiler.target>21</maven.compiler.target>
|
||||
<jarsigner.keystore>${project.basedir}/testkeystore.jks</jarsigner.keystore>
|
||||
<jarsigner.alias>testkey</jarsigner.alias>
|
||||
<jarsigner.storepass>123456</jarsigner.storepass>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
</properties>
|
||||
|
||||
<repositories>
|
||||
|
@ -14,26 +19,39 @@
|
|||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>m724</id>
|
||||
<url>https://git.m724.eu/api/packages/Minecon724/maven</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.20.4-R0.1-SNAPSHOT</version>
|
||||
<version>1.19.4-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
<!-- Fix warning about vulnerabilities of things we don't use -->
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.yaml</groupId>
|
||||
<artifactId>snakeyaml</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.json</groupId>
|
||||
<artifactId>json</artifactId>
|
||||
<version>20231013</version>
|
||||
<scope>provided</scope>
|
||||
<groupId>eu.m724</groupId>
|
||||
<artifactId>wtapi</artifactId>
|
||||
<version>0.8.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.maxmind.geoip2</groupId>
|
||||
<artifactId>geoip2</artifactId>
|
||||
<version>4.2.0</version>
|
||||
<scope>provided</scope>
|
||||
<groupId>eu.m724</groupId>
|
||||
<artifactId>jarupdater</artifactId>
|
||||
<version>0.1.8</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
@ -44,5 +62,89 @@
|
|||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins> <!-- versions: https://maven.apache.org/plugins/ -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-release-plugin</artifactId>
|
||||
<version>3.1.1</version>
|
||||
<configuration>
|
||||
<allowTimestampedSnapshots>true</allowTimestampedSnapshots>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.6.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<minimizeJar>true</minimizeJar>
|
||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||
<artifactSet>
|
||||
<includes>
|
||||
<include>eu.m724:wtapi</include>
|
||||
<include>eu.m724:jarupdater</include>
|
||||
<!-- <include>org.java-websocket:Java-WebSocket</include> -->
|
||||
<!-- it's in plugin.yml and downloaded by server -->
|
||||
<!-- gson is bundled with spigot -->
|
||||
</includes>
|
||||
</artifactSet>
|
||||
<filters>
|
||||
<filter>
|
||||
<artifact>*</artifact>
|
||||
<excludes>
|
||||
<exclude>META-INF/MANIFEST.MF</exclude>
|
||||
</excludes>
|
||||
</filter>
|
||||
</filters>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jarsigner-plugin</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>sign</id>
|
||||
<goals>
|
||||
<goal>sign</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>verify</id>
|
||||
<goals>
|
||||
<goal>verify</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<keystore>${jarsigner.keystore}</keystore>
|
||||
<alias>${jarsigner.alias}</alias>
|
||||
<storepass>${jarsigner.storepass}</storepass>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>m724</id>
|
||||
<url>https://git.m724.eu/api/packages/Minecon724/maven</url>
|
||||
</repository>
|
||||
<snapshotRepository>
|
||||
<id>m724</id>
|
||||
<url>https://git.m724.eu/api/packages/Minecon724/maven</url>
|
||||
</snapshotRepository>
|
||||
</distributionManagement>
|
||||
|
||||
<scm>
|
||||
<developerConnection>scm:git:git@git.m724.eu:Minecon724/realweather.git</developerConnection>
|
||||
<tag>HEAD</tag>
|
||||
</scm>
|
||||
</project>
|
18
realweather.iml
Normal file
18
realweather.iml
Normal file
|
@ -0,0 +1,18 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module version="4">
|
||||
<component name="AdditionalModuleElements">
|
||||
<content url="file://$MODULE_DIR$" dumb="true">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/test" isTestSource="true" />
|
||||
</content>
|
||||
</component>
|
||||
<component name="FacetManager">
|
||||
<facet type="minecraft" name="Minecraft">
|
||||
<configuration>
|
||||
<autoDetectTypes>
|
||||
<platformType>SPIGOT</platformType>
|
||||
</autoDetectTypes>
|
||||
<projectReimportVersion>1</projectReimportVersion>
|
||||
</configuration>
|
||||
</facet>
|
||||
</component>
|
||||
</module>
|
22
src/main/java/eu/m724/realweather/Configs.java
Normal file
22
src/main/java/eu/m724/realweather/Configs.java
Normal file
|
@ -0,0 +1,22 @@
|
|||
package eu.m724.realweather;
|
||||
|
||||
import eu.m724.realweather.mapper.MapperConfig;
|
||||
import eu.m724.realweather.thunder.ThunderConfig;
|
||||
import eu.m724.realweather.time.TimeConfig;
|
||||
import eu.m724.realweather.updater.UpdaterConfig;
|
||||
import eu.m724.realweather.weather.WeatherConfig;
|
||||
|
||||
// TODO replaces GlobalConstants for configs
|
||||
public class Configs {
|
||||
static WeatherConfig weatherConfig;
|
||||
static TimeConfig timeConfig;
|
||||
static ThunderConfig thunderConfig;
|
||||
static MapperConfig mapperConfig;
|
||||
static UpdaterConfig updaterConfig;
|
||||
|
||||
public static WeatherConfig weatherConfig() { return weatherConfig; }
|
||||
public static TimeConfig timeConfig() { return timeConfig; }
|
||||
public static ThunderConfig thunderConfig() { return thunderConfig; }
|
||||
public static MapperConfig mapperConfig() { return mapperConfig; }
|
||||
public static UpdaterConfig updaterConfig() { return updaterConfig; }
|
||||
}
|
18
src/main/java/eu/m724/realweather/DebugLogger.java
Normal file
18
src/main/java/eu/m724/realweather/DebugLogger.java
Normal file
|
@ -0,0 +1,18 @@
|
|||
package eu.m724.realweather;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class DebugLogger {
|
||||
static Logger baseLogger;
|
||||
static int debugLevel;
|
||||
|
||||
public static int getDebugLevel() {
|
||||
return debugLevel;
|
||||
}
|
||||
|
||||
|
||||
public static void info(String message, int minDebugLevel, Object... format) {
|
||||
if (debugLevel >= minDebugLevel)
|
||||
baseLogger.info(message.formatted(format));
|
||||
}
|
||||
}
|
25
src/main/java/eu/m724/realweather/GlobalConstants.java
Normal file
25
src/main/java/eu/m724/realweather/GlobalConstants.java
Normal file
|
@ -0,0 +1,25 @@
|
|||
package eu.m724.realweather;
|
||||
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import eu.m724.realweather.mapper.Mapper;
|
||||
import eu.m724.realweather.weather.PlayerWeatherCache;
|
||||
|
||||
// perhaps replace with a singleton
|
||||
// TODO actually, remove it altogether
|
||||
public class GlobalConstants {
|
||||
static Mapper mapper;
|
||||
static Plugin plugin;
|
||||
static PlayerWeatherCache playerWeatherCache;
|
||||
|
||||
public static Mapper getMapper() {
|
||||
return mapper;
|
||||
}
|
||||
public static Plugin getPlugin() {
|
||||
return plugin;
|
||||
}
|
||||
public static PlayerWeatherCache getPlayerWeatherCache() {
|
||||
return playerWeatherCache;
|
||||
}
|
||||
|
||||
}
|
169
src/main/java/eu/m724/realweather/RealWeatherPlugin.java
Normal file
169
src/main/java/eu/m724/realweather/RealWeatherPlugin.java
Normal file
|
@ -0,0 +1,169 @@
|
|||
package eu.m724.realweather;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import eu.m724.realweather.commands.AdminCommand;
|
||||
import eu.m724.realweather.commands.GeoCommand;
|
||||
import eu.m724.realweather.commands.LocalTimeCommand;
|
||||
import eu.m724.realweather.commands.LocalWeatherCommand;
|
||||
import eu.m724.realweather.exception.UserError;
|
||||
import eu.m724.realweather.mapper.Mapper;
|
||||
import eu.m724.realweather.mapper.MapperConfig;
|
||||
import eu.m724.realweather.thunder.ThunderConfig;
|
||||
import eu.m724.realweather.thunder.ThunderMaster;
|
||||
import eu.m724.realweather.time.TimeConfig;
|
||||
import eu.m724.realweather.time.TimeMaster;
|
||||
import eu.m724.realweather.updater.PluginUpdater;
|
||||
import eu.m724.realweather.updater.UpdaterConfig;
|
||||
import eu.m724.realweather.weather.PlayerWeatherCache;
|
||||
import eu.m724.realweather.weather.WeatherConfig;
|
||||
import eu.m724.realweather.weather.WeatherMaster;
|
||||
import eu.m724.wtapi.provider.exception.NoSuchProviderException;
|
||||
import eu.m724.wtapi.provider.exception.ProviderException;
|
||||
|
||||
// TODO unmess this too
|
||||
public class RealWeatherPlugin extends JavaPlugin {
|
||||
private WeatherMaster weatherMaster;
|
||||
private ThunderMaster thunderMaster;
|
||||
private TimeMaster timeMaster;
|
||||
private PluginUpdater updater;
|
||||
|
||||
private Logger logger;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
logger = getLogger();
|
||||
|
||||
File dataFolder = getDataFolder();
|
||||
File modulesFolder = new File("modules");
|
||||
modulesFolder.mkdir();
|
||||
|
||||
YamlConfiguration configuration,
|
||||
mapConfiguration, weatherConfiguration,
|
||||
thunderConfiguration, timeConfiguration;
|
||||
|
||||
DebugLogger.info("loading configurations", 1);
|
||||
boolean firstRun = !new File(dataFolder, "config.yml").exists();
|
||||
|
||||
try {
|
||||
configuration = getConfig("config.yml");
|
||||
mapConfiguration = getConfig("map.yml");
|
||||
weatherConfiguration = getConfig("modules/weather.yml");
|
||||
thunderConfiguration = getConfig("modules/thunder.yml");
|
||||
timeConfiguration = getConfig("modules/time.yml");
|
||||
} catch (IOException e) {
|
||||
logger.severe("Failed to load config!");
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
if (firstRun) {
|
||||
logger.warning("This is your first time running this plugin.");
|
||||
logger.warning("Please *shut down* the server, review the config files (enable modules, enter your API keys, etc.)");
|
||||
logger.warning("Don't forget to enable the plugin in config.yml");
|
||||
|
||||
getServer().getPluginManager().disablePlugin(this);
|
||||
return;
|
||||
}
|
||||
|
||||
DebugLogger.baseLogger = logger;
|
||||
DebugLogger.debugLevel = configuration.getInt("debug");
|
||||
|
||||
if (!configuration.getBoolean("enabled")) {
|
||||
logger.warning("Plugin disabled by administrator. Enable it in config.yml");
|
||||
getServer().getPluginManager().disablePlugin(this);
|
||||
return;
|
||||
}
|
||||
|
||||
GlobalConstants.plugin = this;
|
||||
GlobalConstants.playerWeatherCache = new PlayerWeatherCache();
|
||||
|
||||
DebugLogger.info("loading mapper", 1);
|
||||
Configs.mapperConfig = MapperConfig.fromConfiguration(mapConfiguration);
|
||||
GlobalConstants.mapper = new Mapper();
|
||||
GlobalConstants.mapper.registerEvents(this);
|
||||
|
||||
try {
|
||||
DebugLogger.info("loading weather", 1);
|
||||
Configs.weatherConfig = WeatherConfig.fromConfiguration(weatherConfiguration);
|
||||
weatherMaster = new WeatherMaster();
|
||||
weatherMaster.init(this);
|
||||
|
||||
DebugLogger.info("loading thunder", 1);
|
||||
Configs.thunderConfig = ThunderConfig.fromConfiguration(thunderConfiguration);
|
||||
thunderMaster = new ThunderMaster();
|
||||
thunderMaster.init(this);
|
||||
|
||||
DebugLogger.info("loading time", 1);
|
||||
Configs.timeConfig = TimeConfig.fromConfiguration(timeConfiguration);
|
||||
timeMaster = new TimeMaster();
|
||||
timeMaster.init();
|
||||
|
||||
Configs.updaterConfig = UpdaterConfig.fromConfiguration(configuration.getConfigurationSection("updater"));
|
||||
updater = PluginUpdater.build(this, this.getFile());
|
||||
//updater.init();
|
||||
} catch (UserError | NoSuchProviderException e) {
|
||||
logger.severe("There are errors in your config:");
|
||||
logger.severe(e.getMessage());
|
||||
|
||||
getServer().getPluginManager().disablePlugin(this);
|
||||
return;
|
||||
} catch (ProviderException e) {
|
||||
logger.severe("Couldn't initialize provider!");
|
||||
logger.severe("Possible causes:");
|
||||
logger.severe("1. Your API key is invalid, or was added too recently");
|
||||
logger.severe("2. The provider or your internet is down");
|
||||
e.printStackTrace();
|
||||
|
||||
getServer().getPluginManager().disablePlugin(this);
|
||||
return;
|
||||
}
|
||||
|
||||
getCommand("rwadmin").setExecutor(new AdminCommand(updater, thunderMaster));
|
||||
getCommand("geo").setExecutor(new GeoCommand());
|
||||
|
||||
if (Configs.timeConfig.enabled())
|
||||
getCommand("localtime").setExecutor(new LocalTimeCommand(timeMaster.getTimeConverter()));
|
||||
|
||||
if (Configs.weatherConfig.enabled()) {
|
||||
getCommand("localweather").setExecutor(new LocalWeatherCommand());
|
||||
}
|
||||
|
||||
/*Metrics metrics = new Metrics(this, 15020);
|
||||
metrics.addCustomChart(new SimplePie("weather_provider", () ->
|
||||
GlobalConstants.weatherConfig.enabled ? GlobalConstants.weatherConfig.provider : "off"
|
||||
));
|
||||
metrics.addCustomChart(new SimplePie("thunder_provider", () ->
|
||||
GlobalConstants.thunderConfig.enabled ? GlobalConstants.thunderConfig.provider : "off"
|
||||
));
|
||||
metrics.addCustomChart(new SimplePie("real_time", () ->
|
||||
GlobalConstants.timeConfig.enabled() ? "on" : "off"
|
||||
));*/
|
||||
|
||||
DebugLogger.info("ended loading", 1);
|
||||
}
|
||||
|
||||
public YamlConfiguration getConfig(String configFilePath) throws IOException {
|
||||
File configFile = new File(this.getDataFolder(), configFilePath);
|
||||
YamlConfiguration config = YamlConfiguration.loadConfiguration(configFile);
|
||||
|
||||
if (!configFile.exists()) {
|
||||
final InputStream defConfigStream = getResource(configFilePath);
|
||||
|
||||
if (defConfigStream == null)
|
||||
return null;
|
||||
|
||||
config = YamlConfiguration.loadConfiguration(new InputStreamReader(defConfigStream, StandardCharsets.UTF_8));
|
||||
config.save(configFile);
|
||||
}
|
||||
|
||||
return config;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
package eu.m724.realweather.api.weather;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import eu.m724.wtapi.object.Weather;
|
||||
|
||||
/**
|
||||
* Fired when a weather state is retrieved<br>
|
||||
* It doesn't mean the weather has changed, just that we retrieved the state<br>
|
||||
*/
|
||||
public class AsyncWeatherUpdateEvent extends Event implements Cancellable {
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
|
||||
private final Player player;
|
||||
private final Weather weather;
|
||||
|
||||
private boolean cancelled;
|
||||
|
||||
public AsyncWeatherUpdateEvent(Player player, Weather weather) {
|
||||
super(true);
|
||||
this.player = player;
|
||||
this.weather = weather;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a player that the weather is for, null if worldwide (static mode)
|
||||
*/
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the weather state that was just changed
|
||||
*/
|
||||
public Weather getWeather() {
|
||||
return weather;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancel weather change<br>
|
||||
* It will only cancel changing the actual weather by the plugin, not retrieving and caching it
|
||||
* @param cancelled to cancel or not
|
||||
*/
|
||||
@Override
|
||||
public void setCancelled(boolean cancelled) {
|
||||
this.cancelled = cancelled;
|
||||
}
|
||||
}
|
73
src/main/java/eu/m724/realweather/commands/AdminCommand.java
Normal file
73
src/main/java/eu/m724/realweather/commands/AdminCommand.java
Normal file
|
@ -0,0 +1,73 @@
|
|||
package eu.m724.realweather.commands;
|
||||
|
||||
import eu.m724.realweather.Configs;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import eu.m724.realweather.GlobalConstants;
|
||||
import eu.m724.realweather.mapper.MapperConfig;
|
||||
import eu.m724.realweather.thunder.ThunderConfig;
|
||||
import eu.m724.realweather.thunder.ThunderMaster;
|
||||
import eu.m724.realweather.time.TimeConfig;
|
||||
import eu.m724.realweather.updater.PluginUpdater;
|
||||
import eu.m724.realweather.weather.WeatherConfig;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
|
||||
// TODO unmess this all
|
||||
public class AdminCommand implements CommandExecutor {
|
||||
private final UpdateCommand updateCommand;
|
||||
private final Plugin plugin = GlobalConstants.getPlugin();
|
||||
|
||||
private final WeatherConfig weatherConfig = Configs.weatherConfig();
|
||||
private final TimeConfig timeConfig = Configs.timeConfig();
|
||||
private final ThunderConfig thunderConfig = Configs.thunderConfig();
|
||||
private final MapperConfig mapperConfig = Configs.mapperConfig();
|
||||
|
||||
private final ThunderMaster thunderMaster;
|
||||
|
||||
public AdminCommand(PluginUpdater updater, ThunderMaster thunderMaster) {
|
||||
this.updateCommand = new UpdateCommand(updater);
|
||||
this.thunderMaster = thunderMaster;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (args.length > 0 && args[0].equals("update")) {
|
||||
return updateCommand.onCommand(sender, command, label, args);
|
||||
}
|
||||
|
||||
colorize(sender, "\n&eRealWeather %s\n\n", plugin.getDescription().getVersion().replace("-SNAPSHOT", "&c-SNAPSHOT"));
|
||||
|
||||
colorize(sender, "&6Coordinate scale: &b%d, %d &7blocks / deg", mapperConfig.scaleLatitude, mapperConfig.scaleLongitude);
|
||||
|
||||
colorize(sender, "\n&6Weather: %s", weatherConfig.enabled() ? (weatherConfig.dynamic() ? "&aYes, dynamic" : "&aYes, static") : "&cDisabled");
|
||||
|
||||
if (weatherConfig.enabled()) {
|
||||
colorize(sender, " &6Provider: &b%s", weatherConfig.provider());
|
||||
colorize(sender, " &6/localweather to see current weather");
|
||||
}
|
||||
|
||||
colorize(sender, "\n&6Time: %s", timeConfig.enabled() ? (timeConfig.dynamic() ? "&aYes, dynamic" : "&aYes, static") : "&cDisabled");
|
||||
|
||||
if (timeConfig.enabled()) {
|
||||
colorize(sender, " &6Scale: &b%s&7x", timeConfig.scale());
|
||||
colorize(sender, " &6/localtime to see current time");
|
||||
}
|
||||
|
||||
colorize(sender, "\n&6Thunder: %s", thunderConfig.enabled() ? "&aYes, dynamic" : "&cDisabled");
|
||||
|
||||
if (thunderConfig.enabled()) {
|
||||
colorize(sender, " &6Provider: &b%s", thunderConfig.provider());
|
||||
colorize(sender, " &6Refresh period: &b%d &7ticks", thunderConfig.refreshPeriod());
|
||||
colorize(sender, " &6API latency: &b%d&7ms", thunderMaster.getLatency());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void colorize(CommandSender sender, String text, Object... format) {
|
||||
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', text.formatted(format)));
|
||||
}
|
||||
}
|
106
src/main/java/eu/m724/realweather/commands/GeoCommand.java
Normal file
106
src/main/java/eu/m724/realweather/commands/GeoCommand.java
Normal file
|
@ -0,0 +1,106 @@
|
|||
package eu.m724.realweather.commands;
|
||||
|
||||
import net.md_5.bungee.api.chat.*;
|
||||
import net.md_5.bungee.api.chat.hover.content.Content;
|
||||
import net.md_5.bungee.api.chat.hover.content.Text;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import eu.m724.realweather.GlobalConstants;
|
||||
import eu.m724.realweather.mapper.Mapper;
|
||||
import eu.m724.realweather.weather.PlayerWeatherCache;
|
||||
import eu.m724.wtapi.object.Coordinates;
|
||||
import eu.m724.wtapi.object.Weather;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
|
||||
public class GeoCommand implements CommandExecutor {
|
||||
private final PlayerWeatherCache playerWeatherCache = GlobalConstants.getPlayerWeatherCache();
|
||||
private final Mapper mapper = GlobalConstants.getMapper();
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
Player player = sender instanceof Player ? (Player) sender : null;
|
||||
|
||||
if (args.length == 0) {
|
||||
if (player != null) {
|
||||
Location location = player.getLocation();
|
||||
Coordinates coordinates = mapper.locationToCoordinates(location);
|
||||
|
||||
Weather weather = playerWeatherCache.getWeather(player);
|
||||
String address = formatAddress(weather);
|
||||
|
||||
colorize(player, "");
|
||||
colorize(player, "&6Geolocation: &b%f&7, %b%f &7(lat, lon)", coordinates.latitude, coordinates.longitude);
|
||||
colorize(player, "&7Position: &3%f&8, %3%f &8(x, z)", location.getX(), location.getZ());
|
||||
colorize(player, "&7City: &3%s", address);
|
||||
colorize(player, "");
|
||||
}
|
||||
} else if (args.length >= 3) {
|
||||
colorize(sender, "&cInvalid arguments, &7make sure it's &a\"/geo lat,lon\" &7or &a\"/geo x z\" &7or just &a\"/geo\"");
|
||||
} else if (args.length == 2) {
|
||||
double x, z;
|
||||
|
||||
try {
|
||||
x = Double.parseDouble(args[0]);
|
||||
z = Double.parseDouble(args[1]);
|
||||
} catch (NumberFormatException e) {
|
||||
colorize(sender, "&cInvalid arguments, &7make sure it's &a\"/geo lat,lon\" &7or &a\"/geo x z\" &7or just &a\"/geo\"");
|
||||
return true;
|
||||
}
|
||||
|
||||
Location location = new Location(null, x, 0, z);
|
||||
Coordinates coordinates = mapper.locationToCoordinates(location);
|
||||
|
||||
colorize(sender, "");
|
||||
colorize(sender, "&6Position: &b%f&7, %b%f &7(x, z)", location.getX(), location.getZ());
|
||||
colorize(sender, "&7Geolocation: &3%f&8, %3%f &8(lat, lon)", coordinates.latitude, coordinates.longitude);
|
||||
colorize(sender, "&7Input interpreted as position, because you separated with a space");
|
||||
colorize(sender, "");
|
||||
|
||||
return true;
|
||||
} else {
|
||||
double latitude, longitude;
|
||||
|
||||
try {
|
||||
String[] split = args[0].split(",");
|
||||
latitude = Double.parseDouble(split[0]);
|
||||
longitude = Double.parseDouble(split[1]);
|
||||
} catch (NumberFormatException e) {
|
||||
colorize(sender, "&cInvalid arguments, &7make sure it's &a\"/geo lat,lon\" &7or &a\"/geo x z\" &7or just &a\"/geo\"");
|
||||
return true;
|
||||
}
|
||||
|
||||
Coordinates coordinates = new Coordinates(latitude, longitude);
|
||||
Location location = mapper.coordinatesToLocation(null, coordinates);
|
||||
|
||||
colorize(sender, "");
|
||||
colorize(sender, "&6Position: &b%f&7, %b%f &7(x, z)", location.getX(), location.getZ());
|
||||
colorize(sender, "&7Geolocation: &3%f&8, %3%f &8(lat, lon)", coordinates.latitude, coordinates.longitude);
|
||||
colorize(sender, "&7Input interpreted as geolocation, because you separated with a comma");
|
||||
colorize(sender, "");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void colorize(CommandSender sender, String text, Object... format) {
|
||||
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', text.formatted(format)));
|
||||
}
|
||||
|
||||
private String formatAddress(Weather weather) {
|
||||
if (weather == null) return "Not retrieved yet";
|
||||
Coordinates coordinates = weather.coordinates;
|
||||
|
||||
if (coordinates.country == null && coordinates.city == null)
|
||||
return "Unknown";
|
||||
else if (coordinates.city == null)
|
||||
return "Somewhere in " + coordinates.country;
|
||||
else if (coordinates.country == null)
|
||||
return coordinates.city;
|
||||
return coordinates.city + ", " + coordinates.country;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,81 @@
|
|||
package eu.m724.realweather.commands;
|
||||
|
||||
import java.time.Duration;
|
||||
|
||||
import eu.m724.realweather.Configs;
|
||||
import eu.m724.realweather.time.TimeConverter;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import eu.m724.realweather.GlobalConstants;
|
||||
import eu.m724.realweather.mapper.Mapper;
|
||||
import eu.m724.realweather.time.TimeConfig;
|
||||
import eu.m724.wtapi.object.Coordinates;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import net.md_5.bungee.api.chat.ComponentBuilder;
|
||||
|
||||
public class LocalTimeCommand implements CommandExecutor {
|
||||
private final Mapper mapper = GlobalConstants.getMapper();
|
||||
private final TimeConfig timeConfig = Configs.timeConfig();
|
||||
private final TimeConverter timeConverter;
|
||||
|
||||
public LocalTimeCommand(TimeConverter timeConverter) {
|
||||
this.timeConverter = timeConverter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
Player player = sender instanceof Player ? (Player) sender : null;
|
||||
|
||||
long worldTime = System.currentTimeMillis();
|
||||
worldTime = timeConverter.scale(worldTime) % 86400000;
|
||||
long worldTimeTicks = timeConverter.millisToTicks(worldTime);
|
||||
Duration worldTimeDuration = Duration.ofMillis(worldTime);
|
||||
|
||||
String worldTimeFormatted = String.format("%d:%02d:%02d",
|
||||
worldTimeDuration.toHours(),
|
||||
worldTimeDuration.toMinutesPart(),
|
||||
worldTimeDuration.toSecondsPart());
|
||||
|
||||
BaseComponent[] component = new ComponentBuilder("World time: ").color(ChatColor.GRAY)
|
||||
.append(worldTimeFormatted).color(ChatColor.DARK_AQUA)
|
||||
.create();
|
||||
|
||||
sender.spigot().sendMessage(component);
|
||||
|
||||
if (timeConfig.dynamic() && player != null && player.hasPermission("realweather.dynamic")) {
|
||||
Coordinates coordinates = mapper.locationToCoordinates(player.getLocation());
|
||||
|
||||
long offsetTime = timeConverter.calculateZoneOffset(coordinates.longitude);
|
||||
long offsetTimeTicks = timeConverter.millisToTicks(offsetTime);
|
||||
boolean negative = offsetTime < 0;
|
||||
|
||||
Duration localTimeDuration = Duration.ofMillis(Math.floorMod(worldTime + offsetTime, 86400000));
|
||||
Duration offsetTimeDuration = Duration.ofMillis(Math.floorMod(negative ? -offsetTime : offsetTime, 86400000));
|
||||
|
||||
String offsetTimeFormatted = String.format("%s%d:%02d:%02d",
|
||||
(negative ? "-" : "+"),
|
||||
offsetTimeDuration.toHours(),
|
||||
offsetTimeDuration.toMinutesPart(),
|
||||
offsetTimeDuration.toSecondsPart());
|
||||
|
||||
String localTimeFormatted = String.format("%d:%02d:%02d",
|
||||
localTimeDuration.toHours(),
|
||||
localTimeDuration.toMinutesPart(),
|
||||
localTimeDuration.toSecondsPart());
|
||||
|
||||
component = new ComponentBuilder("Local time: ").color(ChatColor.GOLD)
|
||||
.append(localTimeFormatted + " %dt".formatted(worldTimeTicks)).color(ChatColor.AQUA)
|
||||
.append(" " + offsetTimeFormatted + " %dt".formatted(offsetTimeTicks)).color(ChatColor.GRAY)
|
||||
.create();
|
||||
|
||||
sender.spigot().sendMessage(component);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
package eu.m724.realweather.commands;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.time.ZoneOffset;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import eu.m724.realweather.GlobalConstants;
|
||||
import eu.m724.realweather.weather.PlayerWeatherCache;
|
||||
import eu.m724.wtapi.object.Weather;
|
||||
|
||||
public class LocalWeatherCommand implements CommandExecutor {
|
||||
private final PlayerWeatherCache playerWeatherCache = GlobalConstants.getPlayerWeatherCache();
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!(sender instanceof Player player)) {
|
||||
sender.sendMessage("You must be a player to use this command");
|
||||
return true;
|
||||
}
|
||||
|
||||
Weather weather = playerWeatherCache.getWeather(player);
|
||||
|
||||
if (weather != null) {
|
||||
long lastUpdate = playerWeatherCache.getLastUpdate(player);
|
||||
colorize(sender, "\n&e" + weather.description);
|
||||
|
||||
if (weather.rainSeverity != null)
|
||||
colorize(sender, "&6Rain: &b%s", weather.rainSeverity.toString());
|
||||
if (weather.drizzleSeverity != null)
|
||||
colorize(sender, "&6Drizzle: &b%s", weather.drizzleSeverity.toString());
|
||||
if (weather.sleetSeverity != null)
|
||||
colorize(sender, "&6Sleet: &b%s", weather.sleetSeverity.toString());
|
||||
if (weather.snowSeverity != null)
|
||||
colorize(sender, "&6Snow: &b%s", weather.snowSeverity.toString());
|
||||
if (weather.thunderstormSeverity != null)
|
||||
colorize(sender, "&6Thunderstorm: &b%s", weather.thunderstormSeverity.toString());
|
||||
if (weather.shower)
|
||||
colorize(sender, "&6Shower");
|
||||
|
||||
colorize(sender, "&6Cloudiness: &b%f&7%%", weather.cloudiness * 100);
|
||||
colorize(sender, "&6Humidity: &b%f&7%%", weather.humidity * 100);
|
||||
colorize(sender, "&6Temperature: &b%f&7°C (feels like %f°C)", weather.temperature - 273.15, weather.temperatureApparent - 273.15);
|
||||
colorize(sender, "&6Wind: &b%f&7m/s (gust %fm/s)", weather.windSpeed, weather.windGust);
|
||||
colorize(sender, "&6Last update: &b%s UTC\n", formatTime(lastUpdate));
|
||||
|
||||
} else {
|
||||
colorize(sender, "&6No weather for you, try again in a second");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void colorize(CommandSender sender, String text, Object... format) {
|
||||
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', text.formatted(format)));
|
||||
}
|
||||
|
||||
private String formatTime(long timestamp) {
|
||||
return DateTimeFormatter.ofPattern("HH:mm:ss").format(Instant.ofEpochMilli(timestamp).atZone(ZoneOffset.UTC));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,77 @@
|
|||
package eu.m724.realweather.commands;
|
||||
|
||||
import java.nio.file.NoSuchFileException;
|
||||
import java.time.Instant;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import eu.m724.jarupdater.updater.Updater;
|
||||
import eu.m724.jarupdater.object.Version;
|
||||
|
||||
/**
|
||||
* not actually a command but deserves a separate file
|
||||
*/
|
||||
public class UpdateCommand {
|
||||
private final Updater updater;
|
||||
|
||||
public UpdateCommand(Updater updater) {
|
||||
this.updater = updater;
|
||||
}
|
||||
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!sender.hasPermission("realweather.admin.update")) return false;
|
||||
|
||||
sender.sendMessage("Please wait");
|
||||
CompletableFuture<Version> latestFuture = updater.getLatestVersion();
|
||||
|
||||
if (args.length == 0) {
|
||||
latestFuture.thenAccept(metadata -> {
|
||||
if (metadata != null) {
|
||||
sender.sendMessage("An update is available!");
|
||||
sender.sendMessage("RealWeather %s released %s".formatted(metadata.getLabel(), formatDate(metadata.getTimestamp())));
|
||||
sender.sendMessage("To download: /rwadmin update download");
|
||||
} else {
|
||||
sender.sendMessage("No new updates"); // TODO color
|
||||
}
|
||||
});
|
||||
} else {
|
||||
String action = args[1]; // remember this function is proxied
|
||||
|
||||
if (action.equals("download")) {
|
||||
sender.sendMessage("Started download");
|
||||
|
||||
updater.downloadLatestVersion().handle((file, ex) -> {
|
||||
sender.sendMessage("Download failed. See console for details.");
|
||||
ex.printStackTrace();
|
||||
return null;
|
||||
}).thenAccept(file -> {
|
||||
if (file != null)
|
||||
sender.sendMessage("Download finished, install with /rwadmin update install");
|
||||
});
|
||||
|
||||
} else if (action.equals("install")) {
|
||||
try {
|
||||
updater.installLatestVersion().handle((v, ex) -> {
|
||||
sender.sendMessage("Install failed. See console for details.");
|
||||
ex.printStackTrace();
|
||||
return null;
|
||||
}).thenAccept(v -> {
|
||||
sender.sendMessage("Installation completed, restart server to apply");
|
||||
});
|
||||
} catch (NoSuchFileException e) {
|
||||
sender.sendMessage("Download the update first");
|
||||
}
|
||||
} else return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private String formatDate(long timestamp) { // TODO move this
|
||||
return DateTimeFormatter.ofPattern("dd.MM.yyyy").format(Instant.ofEpochSecond(timestamp));
|
||||
}
|
||||
|
||||
}
|
11
src/main/java/eu/m724/realweather/exception/UserError.java
Normal file
11
src/main/java/eu/m724/realweather/exception/UserError.java
Normal file
|
@ -0,0 +1,11 @@
|
|||
package eu.m724.realweather.exception;
|
||||
|
||||
public class UserError extends Error {
|
||||
|
||||
private static final long serialVersionUID = 7152429719832602384L;
|
||||
|
||||
public UserError(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
}
|
103
src/main/java/eu/m724/realweather/mapper/Mapper.java
Normal file
103
src/main/java/eu/m724/realweather/mapper/Mapper.java
Normal file
|
@ -0,0 +1,103 @@
|
|||
package eu.m724.realweather.mapper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import eu.m724.realweather.Configs;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import eu.m724.wtapi.object.Coordinates;
|
||||
|
||||
public class Mapper {
|
||||
private final MapperConfig config = Configs.mapperConfig();
|
||||
private final List<World> worlds = new ArrayList<>();
|
||||
|
||||
private final List<Consumer<World>> worldLoadConsumers = new ArrayList<>();
|
||||
private final List<Consumer<World>> worldUnloadConsumers = new ArrayList<>();
|
||||
// TODO game rules, I think I meant handling by this class
|
||||
|
||||
/**
|
||||
* Registers a consumer which will be called on world load
|
||||
* @param consumer the consumer which will be called on world load
|
||||
*/
|
||||
public void registerWorldLoadConsumer(Consumer<World> consumer) {
|
||||
this.worldLoadConsumers.add(consumer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a consumer which will be called on world unload
|
||||
* @param consumer the consumer which will be called on world unload
|
||||
*/
|
||||
public void registerWorldUnloadConsumer(Consumer<World> consumer) {
|
||||
this.worldUnloadConsumers.add(consumer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers events handled by mapper.<br>
|
||||
* This should be called once on plugin load.
|
||||
* @param plugin the plugin to register events under
|
||||
*/
|
||||
public void registerEvents(Plugin plugin) {
|
||||
plugin.getServer().getPluginManager().registerEvents(new MapperEventHandler(this), plugin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a {@link Location} to {@link Coordinates}<br>
|
||||
* The result is scaled and wrapped
|
||||
*
|
||||
* @param location the location to convert
|
||||
* @return the coordinates
|
||||
*/
|
||||
public Coordinates locationToCoordinates(Location location) {
|
||||
// it's <-90, 90> (inclusive), but there's no point to make it that way here, because it's easier, and nice precision is enough
|
||||
double latitude = (-location.getZ() / config.scaleLatitude) % 90;
|
||||
// here it's <-180, 180) so it's correct, and we don't need excuses
|
||||
double longitude = (location.getX() / config.scaleLongitude) % 180;
|
||||
|
||||
return new Coordinates(latitude, longitude);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts {@link Coordinates} to a {@link Location}<br>
|
||||
* The result is scaled, but not wrapped to world border or anything
|
||||
*
|
||||
* @param world the world of the location
|
||||
* @param coordinates the coordinates to convert
|
||||
* @return the location in {@code world}
|
||||
*/
|
||||
public Location coordinatesToLocation(World world, Coordinates coordinates) {
|
||||
double x = coordinates.longitude * config.scaleLongitude;
|
||||
double z = -coordinates.latitude * config.scaleLatitude;
|
||||
|
||||
return new Location(world, x, 0, z);
|
||||
}
|
||||
|
||||
public Coordinates getPoint() {
|
||||
return config.point;
|
||||
}
|
||||
|
||||
public List<World> getWorlds() {
|
||||
return this.worlds;
|
||||
}
|
||||
|
||||
boolean loadWorld(World world) {
|
||||
boolean loaded = config.worlds.contains(world.getName()) ^ config.worldBlacklist;
|
||||
|
||||
if (loaded) {
|
||||
worlds.add(world);
|
||||
worldLoadConsumers.forEach(consumer -> consumer.accept(world));
|
||||
}
|
||||
|
||||
return loaded;
|
||||
}
|
||||
|
||||
void unloadWorld(World world) {
|
||||
if (worlds.remove(world)) {
|
||||
worldUnloadConsumers.forEach(consumer -> consumer.accept(world));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
33
src/main/java/eu/m724/realweather/mapper/MapperConfig.java
Normal file
33
src/main/java/eu/m724/realweather/mapper/MapperConfig.java
Normal file
|
@ -0,0 +1,33 @@
|
|||
package eu.m724.realweather.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import eu.m724.wtapi.object.Coordinates;
|
||||
|
||||
public class MapperConfig {
|
||||
public boolean worldBlacklist;
|
||||
public List<String> worlds;
|
||||
|
||||
public int scaleLatitude;
|
||||
public int scaleLongitude;
|
||||
|
||||
public Coordinates point;
|
||||
|
||||
public static MapperConfig fromConfiguration(ConfigurationSection configuration) {
|
||||
MapperConfig mapperConfig = new MapperConfig();
|
||||
|
||||
mapperConfig.worldBlacklist = configuration.getBoolean("worldBlacklist");
|
||||
mapperConfig.worlds = configuration.getStringList("worlds");
|
||||
|
||||
mapperConfig.scaleLatitude = configuration.getInt("dimensions.latitude");
|
||||
mapperConfig.scaleLongitude = configuration.getInt("dimensions.longitude");
|
||||
|
||||
mapperConfig.point = new Coordinates(
|
||||
configuration.getDouble("point.latitude"),
|
||||
configuration.getDouble("point.longitude"));
|
||||
|
||||
return mapperConfig;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package eu.m724.realweather.mapper;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.world.WorldLoadEvent;
|
||||
import org.bukkit.event.world.WorldUnloadEvent;
|
||||
|
||||
public class MapperEventHandler implements Listener {
|
||||
private final Mapper mapper;
|
||||
|
||||
public MapperEventHandler(Mapper mapper) {
|
||||
this.mapper = mapper;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onWorldLoad(WorldLoadEvent e) {
|
||||
mapper.loadWorld(e.getWorld());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onWorldUnload(WorldUnloadEvent e) {
|
||||
mapper.unloadWorld(e.getWorld());
|
||||
}
|
||||
}
|
23
src/main/java/eu/m724/realweather/thunder/ThunderConfig.java
Normal file
23
src/main/java/eu/m724/realweather/thunder/ThunderConfig.java
Normal file
|
@ -0,0 +1,23 @@
|
|||
package eu.m724.realweather.thunder;
|
||||
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param enabled is thunder module enabled
|
||||
* @param provider The provider name, may or may not exist, if it doesn't, an error is thrown later
|
||||
* @param refreshPeriod how often probe for strikes, in ticks
|
||||
*/
|
||||
public record ThunderConfig(
|
||||
boolean enabled,
|
||||
String provider,
|
||||
int refreshPeriod
|
||||
) {
|
||||
public static ThunderConfig fromConfiguration(ConfigurationSection configuration) {
|
||||
return new ThunderConfig(
|
||||
configuration.getBoolean("enabled"),
|
||||
configuration.getString("provider"),
|
||||
configuration.getInt("refreshPeriod")
|
||||
);
|
||||
}
|
||||
}
|
38
src/main/java/eu/m724/realweather/thunder/ThunderMaster.java
Normal file
38
src/main/java/eu/m724/realweather/thunder/ThunderMaster.java
Normal file
|
@ -0,0 +1,38 @@
|
|||
package eu.m724.realweather.thunder;
|
||||
|
||||
import eu.m724.realweather.Configs;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import eu.m724.realweather.DebugLogger;
|
||||
import eu.m724.wtapi.provider.Providers;
|
||||
import eu.m724.wtapi.provider.exception.NoSuchProviderException;
|
||||
import eu.m724.wtapi.provider.exception.ProviderException;
|
||||
import eu.m724.wtapi.provider.thunder.ThunderProvider;
|
||||
|
||||
public class ThunderMaster {
|
||||
private final ThunderConfig config = Configs.thunderConfig();
|
||||
private ThunderProvider provider;
|
||||
|
||||
/**
|
||||
* initializes, tests and starts
|
||||
* @throws ProviderException if provider initialization failed
|
||||
* @throws NoSuchProviderException config issue
|
||||
*/
|
||||
public void init(Plugin plugin) throws ProviderException, NoSuchProviderException {
|
||||
if (!config.enabled())
|
||||
return;
|
||||
|
||||
provider = Providers.getThunderProvider(config.provider(), null);
|
||||
provider.init();
|
||||
|
||||
ThunderTask thunderTask = new ThunderTask(provider);
|
||||
thunderTask.init();
|
||||
thunderTask.runTaskTimer(plugin, 0, config.refreshPeriod());
|
||||
|
||||
DebugLogger.info("thunder loaded", 1);
|
||||
}
|
||||
|
||||
public long getLatency() {
|
||||
return provider.getLatency();
|
||||
}
|
||||
}
|
57
src/main/java/eu/m724/realweather/thunder/ThunderTask.java
Normal file
57
src/main/java/eu/m724/realweather/thunder/ThunderTask.java
Normal file
|
@ -0,0 +1,57 @@
|
|||
package eu.m724.realweather.thunder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import eu.m724.realweather.DebugLogger;
|
||||
import eu.m724.realweather.GlobalConstants;
|
||||
import eu.m724.realweather.mapper.Mapper;
|
||||
import eu.m724.wtapi.provider.thunder.ThunderProvider;
|
||||
import eu.m724.wtapi.provider.thunder.impl.blitzortung.TimedStrike;
|
||||
|
||||
class ThunderTask extends BukkitRunnable {
|
||||
private final ThunderProvider thunderProvider;
|
||||
private final Mapper mapper = GlobalConstants.getMapper();
|
||||
private final ArrayList<TimedStrike> strikes = new ArrayList<>();
|
||||
|
||||
public ThunderTask(ThunderProvider thunderProvider) {
|
||||
this.thunderProvider = thunderProvider;
|
||||
}
|
||||
|
||||
public void init() {
|
||||
thunderProvider.registerStrikeHandler(coords -> {
|
||||
strikes.add(new TimedStrike(System.currentTimeMillis() + thunderProvider.getDelay(), coords));
|
||||
});
|
||||
thunderProvider.start();
|
||||
DebugLogger.info("thunderprovider started", 3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
DebugLogger.info("thundertask running", 3);
|
||||
thunderProvider.tick();
|
||||
|
||||
while (!strikes.isEmpty()) {
|
||||
TimedStrike strike = strikes.removeFirst();
|
||||
|
||||
DebugLogger.info("strike: %f %f", 2, strike.coordinates.latitude, strike.coordinates.longitude);
|
||||
|
||||
mapper.getWorlds().forEach(w -> {
|
||||
Location location = mapper.coordinatesToLocation(w, strike.coordinates);
|
||||
DebugLogger.info("in %s that converts to: %d %d", 2, w.getName(), location.getBlockX(), location.getBlockZ());
|
||||
|
||||
// World#isLoaded, Chunk#isLoaded and probably others using Chunk, load the chunk and always return true
|
||||
if (w.isChunkLoaded(location.getBlockX() / 16, location.getBlockZ() / 16)) {
|
||||
location.setY(w.getHighestBlockYAt(location) + 1);
|
||||
w.strikeLightning(location);
|
||||
DebugLogger.info("spawned lightning in %s on y level %d", 2, w.getName(), location.getBlockY());
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package eu.m724.realweather.time;
|
||||
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import eu.m724.realweather.DebugLogger;
|
||||
import eu.m724.realweather.GlobalConstants;
|
||||
import eu.m724.realweather.mapper.Mapper;
|
||||
import eu.m724.wtapi.object.Coordinates;
|
||||
|
||||
public class AsyncPlayerTimeTask extends BukkitRunnable {
|
||||
private final Server server = GlobalConstants.getPlugin().getServer();
|
||||
private final Mapper mapper = GlobalConstants.getMapper();
|
||||
|
||||
private final TimeConverter timeConverter;
|
||||
|
||||
AsyncPlayerTimeTask(TimeConverter timeConverter) {
|
||||
this.timeConverter = timeConverter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
for (Player player : server.getOnlinePlayers()) {
|
||||
if (!player.hasPermission("realweather.dynamic")) continue;
|
||||
if (!mapper.getWorlds().contains(player.getWorld())) continue;
|
||||
|
||||
Coordinates coordinates = mapper.locationToCoordinates(player.getLocation());
|
||||
|
||||
long time = timeConverter.calculateZoneOffset(coordinates.longitude);
|
||||
long ticks = timeConverter.millisToTicks(time);
|
||||
|
||||
player.setPlayerTime(ticks, true);
|
||||
DebugLogger.info("Time for %s: %d", 2, player.getName(), time);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package eu.m724.realweather.time;
|
||||
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import eu.m724.realweather.DebugLogger;
|
||||
import eu.m724.realweather.GlobalConstants;
|
||||
import eu.m724.realweather.mapper.Mapper;
|
||||
|
||||
/**
|
||||
* This does world time, player time is basically offset of this, like timezone +0
|
||||
*/
|
||||
public class SyncTimeUpdateTask extends BukkitRunnable {
|
||||
private final Mapper mapper = GlobalConstants.getMapper();
|
||||
|
||||
private final TimeConverter timeConverter;
|
||||
private final long zoneOffset;
|
||||
|
||||
SyncTimeUpdateTask(TimeConverter timeConverter, boolean dynamic) {
|
||||
this.timeConverter = timeConverter;
|
||||
this.zoneOffset = !dynamic ? timeConverter.calculateZoneOffset(mapper.getPoint().longitude) : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
long time = System.currentTimeMillis();
|
||||
time = timeConverter.scale(time);
|
||||
|
||||
long ticks = timeConverter.millisToTicks(time + zoneOffset);
|
||||
|
||||
DebugLogger.info("Updating time: %d", 2, ticks);
|
||||
|
||||
mapper.getWorlds().forEach(world -> world.setFullTime(ticks));
|
||||
// TODO add world handlers to mapper and don't calculate time each run
|
||||
}
|
||||
|
||||
}
|
23
src/main/java/eu/m724/realweather/time/TimeConfig.java
Normal file
23
src/main/java/eu/m724/realweather/time/TimeConfig.java
Normal file
|
@ -0,0 +1,23 @@
|
|||
package eu.m724.realweather.time;
|
||||
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param enabled is time module enabled
|
||||
* @param dynamic is time dynamic, that is per player
|
||||
* @param scale timescale, time goes Nx slower (0.5 - 2x faster)
|
||||
*/
|
||||
public record TimeConfig(
|
||||
boolean enabled,
|
||||
boolean dynamic,
|
||||
double scale
|
||||
) {
|
||||
public static TimeConfig fromConfiguration(ConfigurationSection configuration) {
|
||||
return new TimeConfig(
|
||||
configuration.getBoolean("enabled"),
|
||||
configuration.getBoolean("dynamic"),
|
||||
configuration.getDouble("scale")
|
||||
);
|
||||
}
|
||||
}
|
51
src/main/java/eu/m724/realweather/time/TimeConverter.java
Normal file
51
src/main/java/eu/m724/realweather/time/TimeConverter.java
Normal file
|
@ -0,0 +1,51 @@
|
|||
package eu.m724.realweather.time;
|
||||
|
||||
public class TimeConverter {
|
||||
public final double scale;
|
||||
|
||||
public TimeConverter(double scale) {
|
||||
this.scale = scale;
|
||||
}
|
||||
|
||||
/**
|
||||
* Divides time by predefined scale<br>
|
||||
* ...slowing it down
|
||||
*
|
||||
* @param time unix milliseconds
|
||||
* @return scaled unix milliseconds
|
||||
*/
|
||||
public long scale(long time) {
|
||||
return (long) (time / scale);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts unix timestamp to in game ticks
|
||||
*
|
||||
* @param time unix millis
|
||||
* @return in-game ticks
|
||||
*/
|
||||
public long millisToTicks(long time) {
|
||||
return Math.floorMod(time / 3600 - 6000, 24000);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates how often (or how rarely) we can update time<br>
|
||||
* That is, to not do stuff when we don't have to<br>
|
||||
* In ticks, because it's used with Bukkit scheduler
|
||||
*
|
||||
* @return update period IN TICKS
|
||||
*/
|
||||
public long calculateUpdatePeriod() {
|
||||
return (long) (72 / scale);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates time offset (in millis) for specified longitude
|
||||
*
|
||||
* @param longitude the longitude
|
||||
* @return milliseconds of offset from the center of the world (0)
|
||||
*/
|
||||
public long calculateZoneOffset(double longitude) {
|
||||
return (long) (longitude * 240000);
|
||||
}
|
||||
}
|
45
src/main/java/eu/m724/realweather/time/TimeMaster.java
Normal file
45
src/main/java/eu/m724/realweather/time/TimeMaster.java
Normal file
|
@ -0,0 +1,45 @@
|
|||
package eu.m724.realweather.time;
|
||||
|
||||
import eu.m724.realweather.Configs;
|
||||
import org.bukkit.GameRule;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import eu.m724.realweather.DebugLogger;
|
||||
import eu.m724.realweather.GlobalConstants;
|
||||
import eu.m724.realweather.mapper.Mapper;
|
||||
|
||||
public class TimeMaster {
|
||||
private final Mapper mapper = GlobalConstants.getMapper();
|
||||
private final Plugin plugin = GlobalConstants.getPlugin();
|
||||
private final TimeConfig timeConfig = Configs.timeConfig();
|
||||
|
||||
// TODO I don't want to initialize this here
|
||||
private final TimeConverter timeConverter = new TimeConverter(timeConfig.scale());
|
||||
|
||||
// TODO this is only used once
|
||||
public TimeConverter getTimeConverter() {
|
||||
return timeConverter;
|
||||
}
|
||||
|
||||
public void init() {
|
||||
if (!timeConfig.enabled())
|
||||
return;
|
||||
|
||||
long period = timeConverter.calculateUpdatePeriod();
|
||||
|
||||
if (timeConfig.scale() * period != 72.0) {
|
||||
// TODO log this properly
|
||||
DebugLogger.info("Warning: RealTime scale is not optimal. Time will be out of sync.", 0);
|
||||
}
|
||||
|
||||
new SyncTimeUpdateTask(timeConverter, timeConfig.dynamic()).runTaskTimer(plugin, 0, period);
|
||||
|
||||
if (timeConfig.dynamic())
|
||||
new AsyncPlayerTimeTask(timeConverter).runTaskTimerAsynchronously(plugin, 0, 60); // 5 seconds
|
||||
|
||||
mapper.registerWorldLoadConsumer(world -> world.setGameRule(GameRule.DO_DAYLIGHT_CYCLE, false));
|
||||
mapper.registerWorldUnloadConsumer(world -> world.setGameRule(GameRule.DO_DAYLIGHT_CYCLE, true));
|
||||
|
||||
DebugLogger.info("time loaded, update every %d ticks", 1, period);
|
||||
}
|
||||
}
|
58
src/main/java/eu/m724/realweather/updater/PluginUpdater.java
Normal file
58
src/main/java/eu/m724/realweather/updater/PluginUpdater.java
Normal file
|
@ -0,0 +1,58 @@
|
|||
package eu.m724.realweather.updater;
|
||||
|
||||
import eu.m724.jarupdater.environment.ConstantEnvironment;
|
||||
import eu.m724.jarupdater.updater.Updater;
|
||||
import eu.m724.jarupdater.verify.SignatureVerifier;
|
||||
import eu.m724.jarupdater.verify.Verifier;
|
||||
import eu.m724.realweather.Configs;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import eu.m724.jarupdater.download.Downloader;
|
||||
import eu.m724.jarupdater.download.SimpleDownloader;
|
||||
import eu.m724.jarupdater.environment.Environment;
|
||||
import eu.m724.jarupdater.live.GiteaMetadataDAO;
|
||||
import eu.m724.jarupdater.live.MetadataDAO;
|
||||
import eu.m724.jarupdater.live.MetadataFacade;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
public class PluginUpdater extends Updater {
|
||||
private final UpdaterConfig updaterConfig = Configs.updaterConfig();
|
||||
|
||||
final Plugin plugin;
|
||||
|
||||
PluginUpdater(Plugin plugin, Environment environment, MetadataFacade metadataProvider, Downloader downloader, Verifier verifier) {
|
||||
super(environment, metadataProvider, downloader, verifier);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public static PluginUpdater build(Plugin plugin, File file) {
|
||||
Environment environment = new ConstantEnvironment(
|
||||
plugin.getDescription().getVersion(),
|
||||
Configs.updaterConfig().channel(),
|
||||
file.toPath()
|
||||
);
|
||||
|
||||
MetadataDAO metadataDAO = new GiteaMetadataDAO("https://git.m724.eu/Minecon724/realweather-metadata", "master");
|
||||
MetadataFacade metadataFacade = new MetadataFacade(environment, metadataDAO);
|
||||
Downloader downloader = new SimpleDownloader("realweather");
|
||||
|
||||
SignatureVerifier verifier = new SignatureVerifier();
|
||||
try (InputStream inputStream = plugin.getResource("verifies_downloaded_jars.pem")) {
|
||||
verifier.loadPublicKey(inputStream);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
return new PluginUpdater(plugin, environment, metadataFacade, downloader, verifier);
|
||||
}
|
||||
|
||||
public void init() {
|
||||
if (!updaterConfig.alert()) return;
|
||||
|
||||
UpdateNotifier updateNotifier = new UpdateNotifier(this, (version) -> {});
|
||||
updateNotifier.register();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
package eu.m724.realweather.updater;
|
||||
|
||||
import java.util.concurrent.CompletionException;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import eu.m724.jarupdater.object.Version;
|
||||
import eu.m724.realweather.DebugLogger;
|
||||
|
||||
public class UpdateNotifier extends BukkitRunnable implements Listener { // TODO move this to jarupdater
|
||||
private final PluginUpdater updater;
|
||||
private final Consumer<Version> updateConsumer;
|
||||
private final Plugin plugin;
|
||||
|
||||
private Version latestVersion;
|
||||
|
||||
public UpdateNotifier(PluginUpdater updater, Consumer<Version> updateConsumer) {
|
||||
this.updater = updater;
|
||||
this.updateConsumer = updateConsumer;
|
||||
this.plugin = updater.plugin;
|
||||
}
|
||||
|
||||
public void register() {
|
||||
this.runTaskTimerAsynchronously(updater.plugin, 0, 432000); // 6h
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
DebugLogger.info("update task running", 2);
|
||||
|
||||
try {
|
||||
latestVersion = updater.getLatestVersion().join();
|
||||
} catch (CompletionException e) {
|
||||
Throwable ex = e.getCause();
|
||||
DebugLogger.info("Error trying to contact update server: %s", 0, ex.getMessage());
|
||||
|
||||
if (DebugLogger.getDebugLevel() >= 1)
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (latestVersion == null) return;
|
||||
DebugLogger.info("RealWeather is outdated. /rwadmin update", 0);
|
||||
|
||||
for (Player player : updater.plugin.getServer().getOnlinePlayers()) {
|
||||
if (player.hasPermission("realweather.update.notify")) {
|
||||
player.sendMessage("RealWeather is outdated. /rwadmin update");
|
||||
}
|
||||
}
|
||||
|
||||
updateConsumer.accept(latestVersion);
|
||||
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerJoin(PlayerJoinEvent e) {
|
||||
Player player = e.getPlayer();
|
||||
if (latestVersion != null && player.hasPermission("realweather.update.notify")) {
|
||||
player.sendMessage("RealWeather is outdated. /rwadmin update");
|
||||
}
|
||||
}
|
||||
}
|
20
src/main/java/eu/m724/realweather/updater/UpdaterConfig.java
Normal file
20
src/main/java/eu/m724/realweather/updater/UpdaterConfig.java
Normal file
|
@ -0,0 +1,20 @@
|
|||
package eu.m724.realweather.updater;
|
||||
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param alert alert admins about updates
|
||||
* @param channel update channel
|
||||
*/
|
||||
public record UpdaterConfig(
|
||||
boolean alert, // this is different because I can't use notify in records sadly
|
||||
String channel
|
||||
) {
|
||||
public static UpdaterConfig fromConfiguration(ConfigurationSection configuration) {
|
||||
return new UpdaterConfig(
|
||||
configuration.getBoolean("notify"),
|
||||
configuration.getString("channel")
|
||||
);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,137 @@
|
|||
package eu.m724.realweather.weather;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.CompletionException;
|
||||
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import eu.m724.realweather.DebugLogger;
|
||||
import eu.m724.realweather.GlobalConstants;
|
||||
import eu.m724.realweather.mapper.Mapper;
|
||||
import eu.m724.realweather.api.weather.AsyncWeatherUpdateEvent;
|
||||
import eu.m724.wtapi.object.Coordinates;
|
||||
import eu.m724.wtapi.object.Weather;
|
||||
import eu.m724.wtapi.provider.weather.WeatherProvider;
|
||||
|
||||
public class DynamicWeatherRetriever extends BukkitRunnable implements Listener {
|
||||
private final WeatherProvider weatherProvider;
|
||||
|
||||
private final Mapper mapper = GlobalConstants.getMapper();
|
||||
private final Plugin plugin = GlobalConstants.getPlugin();
|
||||
private final Server server = plugin.getServer();
|
||||
private final PlayerWeatherCache playerWeatherCache = GlobalConstants.getPlayerWeatherCache();
|
||||
|
||||
// when to next update all players
|
||||
private long nextUpdate = 0;
|
||||
// players that need update asap
|
||||
private final Set<Player> neededUpdate = new HashSet<>();
|
||||
|
||||
public DynamicWeatherRetriever(WeatherProvider weatherProvider) {
|
||||
this.weatherProvider = weatherProvider;
|
||||
}
|
||||
|
||||
private record CoordinatesResult(
|
||||
Map<Coordinates, Player[]> coordinatesPlayersMap,
|
||||
int coordinatesCount,
|
||||
int playerCount
|
||||
) {}
|
||||
|
||||
private CoordinatesResult makeCoordinates(Collection<? extends Player> players) {
|
||||
Map<Coordinates, Player[]> map = new HashMap<>();
|
||||
int coordinatesCount = 0;
|
||||
int playerCount = 0;
|
||||
|
||||
long now = System.currentTimeMillis();
|
||||
|
||||
for (Player player : players) {
|
||||
if (!player.hasPermission("realweather.dynamic")) continue;
|
||||
if (!mapper.getWorlds().contains(player.getWorld())) continue;
|
||||
|
||||
Long lastUpdate = playerWeatherCache.getLastUpdate(player);
|
||||
if (lastUpdate != null && now - lastUpdate < 10000) continue;
|
||||
|
||||
Coordinates coordinates = mapper.locationToCoordinates(player.getLocation());
|
||||
Coordinates closestCoordinates = null;
|
||||
|
||||
for (Coordinates potential : map.keySet()) {
|
||||
//double distance = Math.sqrt(Math.pow(potential.latitude - coordinates.latitude, 2) + Math.pow(potential.longitude - potential.latitude, 2));
|
||||
// TODO setup for "bundling" that is one request for close players
|
||||
}
|
||||
|
||||
if (closestCoordinates != null) {
|
||||
Player[] oldPlayerArray = map.get(coordinates);
|
||||
Player[] newPlayerArray = Arrays.copyOf(oldPlayerArray, oldPlayerArray.length + 1);
|
||||
newPlayerArray[oldPlayerArray.length] = player;
|
||||
map.put(coordinates, newPlayerArray);
|
||||
} else {
|
||||
map.put(coordinates, new Player[] { player });
|
||||
coordinatesCount++;
|
||||
}
|
||||
|
||||
playerCount++;
|
||||
}
|
||||
|
||||
return new CoordinatesResult(map, coordinatesCount, playerCount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
DebugLogger.info("Weather retrieval", 3);
|
||||
long now = System.currentTimeMillis();
|
||||
|
||||
CoordinatesResult coordinates;
|
||||
if (now > nextUpdate) {
|
||||
coordinates = makeCoordinates(server.getOnlinePlayers());
|
||||
// calculate acceptable request rate based on weather provider quota and active players
|
||||
float hourly = weatherProvider.getQuotaHourly() / (float)(weatherProvider.getBulkLimit() * coordinates.coordinatesCount());
|
||||
nextUpdate = now + Math.max(60000, (long) (3600000 / hourly));
|
||||
DebugLogger.info("Next update in %d", 3, nextUpdate);
|
||||
} else { // immediate update for those that need it right now
|
||||
if (neededUpdate.isEmpty()) return;
|
||||
DebugLogger.info("Players in need of update: %d", 2, neededUpdate.size());
|
||||
coordinates = makeCoordinates(neededUpdate);
|
||||
neededUpdate.clear();
|
||||
}
|
||||
Coordinates[] coordinatesArray = coordinates.coordinatesPlayersMap().keySet().toArray(Coordinates[]::new);
|
||||
|
||||
// TODO change to Collection in wtapi? but some ordered kind
|
||||
CompletableFuture<Weather[]> weathersFuture =
|
||||
weatherProvider.getWeatherBulk(coordinatesArray);
|
||||
|
||||
try {
|
||||
Weather[] weathers = weathersFuture.join();
|
||||
for (int i=0; i<weathers.length; i++) {
|
||||
Weather weather = weathers[i];
|
||||
for (Player player : coordinates.coordinatesPlayersMap().get(coordinatesArray[i])) {
|
||||
playerWeatherCache.put(player, weather, now);
|
||||
|
||||
AsyncWeatherUpdateEvent event =
|
||||
new AsyncWeatherUpdateEvent(player, weather);
|
||||
|
||||
server.getPluginManager().callEvent(event);
|
||||
}
|
||||
}
|
||||
} catch (CompletionException e) { // TODO handle finer exceptions
|
||||
DebugLogger.info("An error occurred trying to retrieve weather data", 0);
|
||||
|
||||
if (DebugLogger.getDebugLevel() > 0)
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
DebugLogger.info("dynamic retriever done", 3);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
neededUpdate.add(player);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package eu.m724.realweather.weather;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import eu.m724.wtapi.object.Weather;
|
||||
|
||||
/**
|
||||
* Stores player weathers and when they were last updated
|
||||
*/
|
||||
public class PlayerWeatherCache {
|
||||
HashMap<Player, Weather> weathers = new HashMap<>();
|
||||
HashMap<Player, Long> lastUpdates = new HashMap<>();
|
||||
|
||||
void put(Player player, Weather weather, Long lastUpdate) {
|
||||
weathers.put(player, weather);
|
||||
lastUpdates.put(player, lastUpdate);
|
||||
}
|
||||
|
||||
public Weather getWeather(Player player) {
|
||||
return weathers.get(player);
|
||||
}
|
||||
|
||||
public Long getLastUpdate(Player player) {
|
||||
return lastUpdates.get(player);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
package eu.m724.realweather.weather;
|
||||
|
||||
import eu.m724.realweather.DebugLogger;
|
||||
import eu.m724.realweather.GlobalConstants;
|
||||
import eu.m724.realweather.api.weather.AsyncWeatherUpdateEvent;
|
||||
import eu.m724.realweather.mapper.Mapper;
|
||||
import eu.m724.wtapi.object.Coordinates;
|
||||
import eu.m724.wtapi.object.Weather;
|
||||
import eu.m724.wtapi.provider.weather.WeatherProvider;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.CompletionException;
|
||||
|
||||
public class StaticWeatherRetriever extends BukkitRunnable {
|
||||
private final Plugin plugin = GlobalConstants.getPlugin();
|
||||
private final Mapper mapper = GlobalConstants.getMapper();
|
||||
|
||||
private final WeatherProvider weatherProvider;
|
||||
|
||||
public StaticWeatherRetriever(WeatherProvider weatherProvider) {
|
||||
this.weatherProvider = weatherProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Coordinates point = mapper.getPoint();
|
||||
CompletableFuture<Weather> weatherFuture = weatherProvider.getWeather(point);
|
||||
|
||||
try {
|
||||
Weather weather = weatherFuture.join();
|
||||
|
||||
AsyncWeatherUpdateEvent event =
|
||||
new AsyncWeatherUpdateEvent(null, weather);
|
||||
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
} catch (CompletionException e) { // TODO handle finer exceptions
|
||||
DebugLogger.info("An error occurred trying to retrieve weather data", 0);
|
||||
|
||||
if (DebugLogger.getDebugLevel() > 0)
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
DebugLogger.info("static weather retriever is done", 3);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
package eu.m724.realweather.weather;
|
||||
|
||||
import eu.m724.realweather.DebugLogger;
|
||||
import eu.m724.realweather.GlobalConstants;
|
||||
import eu.m724.realweather.api.weather.AsyncWeatherUpdateEvent;
|
||||
import eu.m724.realweather.mapper.Mapper;
|
||||
import eu.m724.wtapi.object.Weather;
|
||||
import org.bukkit.WeatherType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
// TODO make weather more comprehensive
|
||||
public class WeatherChanger implements Listener {
|
||||
private final Mapper mapper = GlobalConstants.getMapper();
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onWeatherUpdate(AsyncWeatherUpdateEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
Weather weather = event.getWeather();
|
||||
|
||||
if (player != null) { // dynamic mode
|
||||
DebugLogger.info("Changing weather for player %s", 2, player.getName());
|
||||
|
||||
if (weather.isThundering() || weather.isSnowing() || weather.isRaining()) {
|
||||
player.setPlayerWeather(WeatherType.DOWNFALL);
|
||||
} else {
|
||||
player.setPlayerWeather(WeatherType.CLEAR);
|
||||
}
|
||||
} else { // static mode
|
||||
DebugLogger.info("Changing weather static", 3);
|
||||
mapper.getWorlds().forEach(w -> {
|
||||
DebugLogger.info("Changing weather static in world %s", 2, w.getName());
|
||||
if (weather.isThundering()) {
|
||||
w.setClearWeatherDuration(0);
|
||||
w.setWeatherDuration(120000);
|
||||
w.setThunderDuration(120000);
|
||||
} else if (weather.isRaining() || weather.isSnowing()) {
|
||||
w.setClearWeatherDuration(0);
|
||||
w.setWeatherDuration(120000);
|
||||
w.setThunderDuration(0);
|
||||
} else {
|
||||
w.setClearWeatherDuration(120000);
|
||||
w.setWeatherDuration(0);
|
||||
w.setThunderDuration(0);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
27
src/main/java/eu/m724/realweather/weather/WeatherConfig.java
Normal file
27
src/main/java/eu/m724/realweather/weather/WeatherConfig.java
Normal file
|
@ -0,0 +1,27 @@
|
|||
package eu.m724.realweather.weather;
|
||||
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
/**
|
||||
* Configuration of the weather module
|
||||
*
|
||||
* @param enabled Is weather module enabled
|
||||
* @param provider The provider name, may or may not exist, if it doesn't, an error is thrown later
|
||||
* @param apiKey API key for the provider
|
||||
* @param dynamic dynamic mode, weather is per player or global
|
||||
*/
|
||||
public record WeatherConfig(
|
||||
boolean enabled,
|
||||
String provider,
|
||||
String apiKey, // TODO don't expose that, I mean it's only used in one place in init
|
||||
boolean dynamic
|
||||
) {
|
||||
public static WeatherConfig fromConfiguration(ConfigurationSection configuration) {
|
||||
return new WeatherConfig(
|
||||
configuration.getBoolean("enabled"),
|
||||
configuration.getString("provider"),
|
||||
configuration.getString("apiKey"),
|
||||
configuration.getBoolean("dynamic")
|
||||
);
|
||||
}
|
||||
}
|
49
src/main/java/eu/m724/realweather/weather/WeatherMaster.java
Normal file
49
src/main/java/eu/m724/realweather/weather/WeatherMaster.java
Normal file
|
@ -0,0 +1,49 @@
|
|||
package eu.m724.realweather.weather;
|
||||
|
||||
import eu.m724.realweather.Configs;
|
||||
import org.bukkit.GameRule;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import eu.m724.realweather.DebugLogger;
|
||||
import eu.m724.realweather.GlobalConstants;
|
||||
import eu.m724.realweather.mapper.Mapper;
|
||||
import eu.m724.wtapi.provider.Providers;
|
||||
import eu.m724.wtapi.provider.exception.NoSuchProviderException;
|
||||
import eu.m724.wtapi.provider.exception.ProviderException;
|
||||
import eu.m724.wtapi.provider.weather.WeatherProvider;
|
||||
|
||||
public class WeatherMaster {
|
||||
private final WeatherConfig config = Configs.weatherConfig();
|
||||
private final Mapper mapper = GlobalConstants.getMapper();
|
||||
|
||||
/**
|
||||
* initializes, tests and starts
|
||||
* @throws ProviderException if provider initialization failed
|
||||
* @throws NoSuchProviderException config issue
|
||||
*/
|
||||
public void init(Plugin plugin) throws ProviderException, NoSuchProviderException {
|
||||
if (!config.enabled()) {
|
||||
DebugLogger.info("weather module is disabled", 1);
|
||||
return;
|
||||
}
|
||||
|
||||
WeatherProvider provider = Providers.getWeatherProvider(config.provider(), config.apiKey());
|
||||
provider.init();
|
||||
|
||||
if (config.dynamic()) {
|
||||
DynamicWeatherRetriever retriever = new DynamicWeatherRetriever(provider);
|
||||
retriever.runTaskTimerAsynchronously(plugin,0, 1000);
|
||||
plugin.getServer().getPluginManager().registerEvents(retriever, plugin);
|
||||
} else {
|
||||
StaticWeatherRetriever retriever = new StaticWeatherRetriever(provider);
|
||||
retriever.runTaskTimerAsynchronously(plugin,0, 60000);
|
||||
}
|
||||
|
||||
plugin.getServer().getPluginManager().registerEvents(new WeatherChanger(), plugin);
|
||||
|
||||
mapper.registerWorldLoadConsumer(world -> world.setGameRule(GameRule.DO_WEATHER_CYCLE, false));
|
||||
mapper.registerWorldUnloadConsumer(world -> world.setGameRule(GameRule.DO_WEATHER_CYCLE, true));
|
||||
|
||||
DebugLogger.info("weather loaded", 1);
|
||||
}
|
||||
}
|
|
@ -1,60 +0,0 @@
|
|||
package pl.minecon724.realweather;
|
||||
|
||||
import com.maxmind.geoip2.WebServiceClient;
|
||||
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import pl.minecon724.realweather.map.WorldMap;
|
||||
import pl.minecon724.realweather.realtime.RealTimeCommander;
|
||||
import pl.minecon724.realweather.weather.WeatherCommander;
|
||||
import pl.minecon724.realweather.weather.exceptions.DisabledException;
|
||||
|
||||
public class RW extends JavaPlugin {
|
||||
FileConfiguration config;
|
||||
|
||||
WebServiceClient client = null;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
long start = System.currentTimeMillis();
|
||||
|
||||
saveDefaultConfig();
|
||||
config = getConfig();
|
||||
|
||||
SubLogger.init(
|
||||
getLogger(),
|
||||
config.getBoolean("logging", false)
|
||||
);
|
||||
|
||||
WorldMap.init(
|
||||
config.getConfigurationSection("map")
|
||||
);
|
||||
|
||||
WeatherCommander weatherCommander = new WeatherCommander(this);
|
||||
try {
|
||||
weatherCommander.init(
|
||||
config.getConfigurationSection("weather")
|
||||
);
|
||||
weatherCommander.start();
|
||||
} catch (DisabledException e) {
|
||||
getLogger().info("Weather module disabled");
|
||||
} catch (IllegalArgumentException e) {
|
||||
e.printStackTrace();
|
||||
getServer().getPluginManager().disablePlugin(this);
|
||||
}
|
||||
|
||||
RealTimeCommander realTimeCommander = new RealTimeCommander(this);
|
||||
try {
|
||||
realTimeCommander.init(
|
||||
config.getConfigurationSection("time")
|
||||
);
|
||||
realTimeCommander.start();
|
||||
} catch (DisabledException e) {
|
||||
getLogger().info("Time module disabled");
|
||||
}
|
||||
|
||||
long end = System.currentTimeMillis();
|
||||
this.getLogger().info( String.format( this.getName() + " enabled! (%s ms)", Long.toString( end-start ) ) );
|
||||
}
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
package pl.minecon724.realweather;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class SubLogger {
|
||||
private static Logger LOGGER;
|
||||
private static boolean ENABLED;
|
||||
private String name;
|
||||
|
||||
static void init(Logger logger, boolean enabled) {
|
||||
LOGGER = logger;
|
||||
ENABLED = enabled;
|
||||
}
|
||||
|
||||
public SubLogger(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public void log(Level level, String format, Object... args) {
|
||||
if (!ENABLED) return;
|
||||
|
||||
Object[] combinedArgs = new Object[args.length + 1];
|
||||
combinedArgs[0] = name;
|
||||
System.arraycopy(args, 0, combinedArgs, 1, args.length);
|
||||
|
||||
LOGGER.log(level, String.format("[%s] " + format, combinedArgs));
|
||||
}
|
||||
|
||||
public void info(String format, Object... args) {
|
||||
this.log(Level.INFO, format, args);
|
||||
}
|
||||
}
|
|
@ -1,48 +0,0 @@
|
|||
package pl.minecon724.realweather.map;
|
||||
|
||||
import com.maxmind.geoip2.record.Location;
|
||||
|
||||
public class Coordinates {
|
||||
public double latitude, longitude;
|
||||
|
||||
public Coordinates(double latitude, double longitude) {
|
||||
this.latitude = latitude;
|
||||
this.longitude = longitude;
|
||||
}
|
||||
|
||||
/**
|
||||
* converts Coordinates to double array
|
||||
* @return array in order of latitude, longitude
|
||||
*/
|
||||
public double[] toDoubleArray() {
|
||||
return new double[] {
|
||||
this.latitude,
|
||||
this.longitude
|
||||
};
|
||||
}
|
||||
|
||||
public Coordinates clamp() {
|
||||
this.latitude = Math.max(-90.0, Math.min(90.0, this.latitude));
|
||||
this.longitude = Math.max(-180.0, Math.min(180.0, this.longitude));
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public Coordinates wrap() {
|
||||
this.latitude = wrapDouble(-90.0, 90.0, this.latitude);
|
||||
this.longitude = wrapDouble(-180.0, 180.0, this.longitude);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
private static double wrapDouble(double min, double max, double val) {
|
||||
return min + (val - min) % (max - min);
|
||||
}
|
||||
|
||||
public static Coordinates fromGeoIpLocation(Location location) {
|
||||
return new Coordinates(
|
||||
location.getLatitude(),
|
||||
location.getLongitude()
|
||||
);
|
||||
}
|
||||
}
|
|
@ -1,68 +0,0 @@
|
|||
package pl.minecon724.realweather.map;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.maxmind.geoip2.WebServiceClient;
|
||||
import com.maxmind.geoip2.exception.GeoIp2Exception;
|
||||
|
||||
import pl.minecon724.realweather.map.exceptions.GeoIPException;
|
||||
|
||||
public class GeoLocator {
|
||||
private static GeoLocator INSTANCE = null;
|
||||
|
||||
private WebServiceClient client;
|
||||
private Map<InetAddress, Coordinates> cache;
|
||||
|
||||
public static void init(int accountId, String apiKey) {
|
||||
INSTANCE = new GeoLocator(
|
||||
new WebServiceClient.Builder(accountId, apiKey)
|
||||
.host("geolite.info").build());
|
||||
}
|
||||
|
||||
public GeoLocator(WebServiceClient client) {
|
||||
this.client = client;
|
||||
this.cache = new HashMap<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* get location by IP
|
||||
* @param address IP
|
||||
* @return geolocation in vector
|
||||
* @throws GeoIp2Exception
|
||||
* @throws IOException
|
||||
*/
|
||||
public static Coordinates getCoordinates(InetAddress address)
|
||||
throws GeoIPException {
|
||||
|
||||
GeoLocator instance = INSTANCE;
|
||||
|
||||
Coordinates coordinates = null;
|
||||
|
||||
coordinates = instance.lookup(address);
|
||||
if (coordinates != null)
|
||||
return coordinates;
|
||||
|
||||
try {
|
||||
coordinates = Coordinates.fromGeoIpLocation(
|
||||
instance.client.city(address).getLocation()
|
||||
);
|
||||
} catch (IOException | GeoIp2Exception e) {
|
||||
throw new GeoIPException(e.getMessage());
|
||||
}
|
||||
|
||||
instance.store(address, coordinates);
|
||||
|
||||
return coordinates;
|
||||
}
|
||||
|
||||
private Coordinates lookup(InetAddress address) {
|
||||
return this.cache.get(address);
|
||||
}
|
||||
|
||||
private void store(InetAddress address, Coordinates coordinates) {
|
||||
this.cache.put(address, coordinates);
|
||||
}
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
package pl.minecon724.realweather.map;
|
||||
|
||||
import org.bukkit.Location;
|
||||
|
||||
public class Globe {
|
||||
private static double[] SCALE;
|
||||
private static boolean WRAP;
|
||||
|
||||
public static void init(double scaleLatitude, double scaleLongitude, boolean wrap) {
|
||||
SCALE = new double[] { scaleLatitude, scaleLongitude };
|
||||
WRAP = wrap;
|
||||
}
|
||||
|
||||
public static Coordinates toCoordiates(Location loc) {
|
||||
Coordinates coordinates = new Coordinates(
|
||||
-loc.getZ() * SCALE[0],
|
||||
loc.getX() * SCALE[1]);
|
||||
|
||||
if (WRAP)
|
||||
coordinates.wrap();
|
||||
else
|
||||
coordinates.clamp();
|
||||
|
||||
return coordinates;
|
||||
}
|
||||
}
|
|
@ -1,96 +0,0 @@
|
|||
package pl.minecon724.realweather.map;
|
||||
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import pl.minecon724.realweather.map.exceptions.GeoIPException;
|
||||
|
||||
public class WorldMap {
|
||||
private static WorldMap INSTANCE;
|
||||
|
||||
private final Type type;
|
||||
|
||||
private Coordinates point;
|
||||
|
||||
public static WorldMap getInstance() {
|
||||
if (INSTANCE == null)
|
||||
throw new NullPointerException("No WorldMap");
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
public WorldMap(Type type,
|
||||
Coordinates point) {
|
||||
this.type = type;
|
||||
this.point = point;
|
||||
}
|
||||
|
||||
public static void init(ConfigurationSection config)
|
||||
throws IllegalArgumentException {
|
||||
|
||||
Type type;
|
||||
|
||||
try {
|
||||
type = Type.valueOf(config.getString("type").toUpperCase());
|
||||
} catch (NullPointerException e) {
|
||||
throw new IllegalArgumentException("Invalid type");
|
||||
}
|
||||
|
||||
Coordinates point = null;
|
||||
|
||||
if (type == Type.POINT) {
|
||||
point = new Coordinates(
|
||||
config.getDouble("point.latitude"),
|
||||
config.getDouble("point.longitude")
|
||||
);
|
||||
|
||||
} else if (type == Type.PLAYER) {
|
||||
GeoLocator.init(
|
||||
config.getInt("player.geolite2_accountId"),
|
||||
config.getString("player.geolite2_api_key")
|
||||
);
|
||||
|
||||
} else if (type == Type.GLOBE) {
|
||||
Globe.init(
|
||||
config.getDouble("globe.scale_latitude"),
|
||||
config.getDouble("globe.scale_longitude"),
|
||||
config.getBoolean("globe.wrap")
|
||||
);
|
||||
}
|
||||
|
||||
INSTANCE = new WorldMap(type, point);
|
||||
}
|
||||
|
||||
/**
|
||||
* get coordinates of player
|
||||
* @param player the player
|
||||
* @return Coordinates
|
||||
* @throws GeoIPException
|
||||
*/
|
||||
public Coordinates getCoordinates(Player player) throws GeoIPException {
|
||||
|
||||
switch (this.type) {
|
||||
case POINT:
|
||||
return point;
|
||||
case PLAYER:
|
||||
if (player.getAddress().getAddress().isAnyLocalAddress())
|
||||
throw new GeoIPException(player.getName() + "'s IP is local, check your proxy settings");
|
||||
|
||||
return GeoLocator.getCoordinates(
|
||||
player.getAddress().getAddress()
|
||||
);
|
||||
case GLOBE:
|
||||
return Globe.toCoordiates(player.getLocation());
|
||||
}
|
||||
|
||||
// this wont happen because we cover each type
|
||||
return null;
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public static enum Type {
|
||||
POINT, PLAYER, GLOBE
|
||||
}
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
package pl.minecon724.realweather.map.exceptions;
|
||||
|
||||
public class GeoIPException extends Exception {
|
||||
public GeoIPException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
|
@ -1,75 +0,0 @@
|
|||
package pl.minecon724.realweather.realtime;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import pl.minecon724.realweather.SubLogger;
|
||||
import pl.minecon724.realweather.map.Coordinates;
|
||||
import pl.minecon724.realweather.map.WorldMap;
|
||||
import pl.minecon724.realweather.map.exceptions.GeoIPException;
|
||||
|
||||
public class PlayerTimeSyncTask extends BukkitRunnable {
|
||||
private WorldMap worldMap = WorldMap.getInstance();
|
||||
private SubLogger subLogger = new SubLogger("playertime");
|
||||
|
||||
private double scale;
|
||||
private List<World> worlds;
|
||||
|
||||
public PlayerTimeSyncTask(double scale, List<World> worlds) {
|
||||
this.scale = scale;
|
||||
this.worlds = worlds;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
if (!worlds.contains(player.getWorld())) {
|
||||
subLogger.info("resetting %s's time as they're in an excluded world", player.getName());
|
||||
player.resetPlayerTime();
|
||||
continue;
|
||||
}
|
||||
|
||||
Coordinates coordinates;
|
||||
|
||||
try {
|
||||
coordinates = worldMap.getCoordinates(player);
|
||||
} catch (GeoIPException e) {
|
||||
subLogger.info("Unable to determine GeoIP for %s (%s)",
|
||||
player.getAddress().getHostString(), e.getMessage());
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
* reasoning here:
|
||||
* earth is divided into timezones each covering 15 deg longitude
|
||||
* so first we find how many hours to offset
|
||||
* a day is 24h (no way)
|
||||
* in minecraft its 24000 ticks
|
||||
* so, 1h in ticks: 24000t / 24h = 1000t
|
||||
* seconds in day: 24h * 3600s = 86400s
|
||||
* seconds to ticks: 86400s * 20t = 1728000t
|
||||
* day irl is 1728000t, in minecraft its 24000t
|
||||
* for each minecraft tick, ticks irl: 1728000t / 24000t = 72t
|
||||
* we divide offset by that to sync time
|
||||
* then multiply by scale, thats obvious
|
||||
*/
|
||||
|
||||
double offset = coordinates.longitude / 15;
|
||||
offset *= 1000;
|
||||
offset *= scale;
|
||||
|
||||
// why no modulo? because we also modify day
|
||||
|
||||
long time = (long) offset;
|
||||
|
||||
player.setPlayerTime(time, true);
|
||||
subLogger.info("%s's time is now off by %d ticks", player.getName(), time);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,92 +0,0 @@
|
|||
package pl.minecon724.realweather.realtime;
|
||||
|
||||
import java.time.ZoneId;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.GameRule;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.world.WorldLoadEvent;
|
||||
import org.bukkit.event.world.WorldUnloadEvent;
|
||||
|
||||
import pl.minecon724.realweather.RW;
|
||||
import pl.minecon724.realweather.weather.exceptions.DisabledException;
|
||||
|
||||
public class RealTimeCommander implements Listener {
|
||||
private RW plugin;
|
||||
|
||||
private List<String> worldNames;
|
||||
private double scale;
|
||||
private ZoneId timezone;
|
||||
private boolean perPlayer;
|
||||
|
||||
private volatile List<World> worlds = new ArrayList<>();
|
||||
private Map<World, Boolean> savedGamerule = new HashMap<>();
|
||||
|
||||
private RealTimeTask task;
|
||||
private PlayerTimeSyncTask playerTimeSyncTask;
|
||||
|
||||
public RealTimeCommander(RW plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public void init(ConfigurationSection config)
|
||||
throws DisabledException {
|
||||
|
||||
if (!config.getBoolean("enabled"))
|
||||
throw new DisabledException();
|
||||
|
||||
try {
|
||||
timezone = ZoneId.of(config.getString("timezone"));
|
||||
} catch (Exception e) {
|
||||
timezone = ZoneId.systemDefault();
|
||||
}
|
||||
|
||||
worldNames = config.getStringList("worlds");
|
||||
scale = config.getDouble("scale");
|
||||
perPlayer = config.getBoolean("per_player");
|
||||
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
}
|
||||
|
||||
public void start() {
|
||||
// to save processing, run only when necessary
|
||||
long period = (long) Math.ceil(72 / scale);
|
||||
period = Math.max(period, 1);
|
||||
|
||||
task = new RealTimeTask(scale, timezone, worlds);
|
||||
task.runTaskTimer(plugin, 0, period);
|
||||
|
||||
if (perPlayer) {
|
||||
playerTimeSyncTask = new PlayerTimeSyncTask(scale, worlds);
|
||||
playerTimeSyncTask.runTaskTimerAsynchronously(plugin, 0, 40);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onWorldLoad(WorldLoadEvent event) {
|
||||
World world = event.getWorld();
|
||||
|
||||
if (worldNames.contains(world.getName())) {
|
||||
worlds.add(world);
|
||||
|
||||
savedGamerule.put(world, world.getGameRuleValue(GameRule.DO_DAYLIGHT_CYCLE));
|
||||
world.setGameRule(GameRule.DO_DAYLIGHT_CYCLE, false);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onWorldUnload(WorldUnloadEvent event) {
|
||||
World world = event.getWorld();
|
||||
|
||||
worlds.remove(world);
|
||||
if (savedGamerule.containsKey(world)) {
|
||||
world.setGameRule(GameRule.DO_DAYLIGHT_CYCLE, savedGamerule.remove(world));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
package pl.minecon724.realweather.realtime;
|
||||
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import pl.minecon724.realweather.SubLogger;
|
||||
|
||||
public class RealTimeTask extends BukkitRunnable {
|
||||
private SubLogger subLogger = new SubLogger("timer");
|
||||
double scale;
|
||||
ZoneId timezone;
|
||||
List<World> worlds;
|
||||
|
||||
public RealTimeTask(double scale, ZoneId timezone, List<World> worlds) {
|
||||
this.scale = scale;
|
||||
this.timezone = timezone;
|
||||
this.worlds = worlds;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
double now = ZonedDateTime.now(timezone).toInstant().getEpochSecond();
|
||||
now /= 3600; // to hour
|
||||
|
||||
// explaination in PlayerTimeSyncTask line 47
|
||||
now *= 1000; // reallife s to mc ticks
|
||||
now -= 6000; // 0t is actually 6:00
|
||||
|
||||
now *= scale; // scale
|
||||
now %= 24000;
|
||||
|
||||
long time = (long) now;
|
||||
|
||||
for (World w : worlds) {
|
||||
w.setFullTime(time);
|
||||
subLogger.info("Updated time for %s (to %d)", w.getName(), time);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,100 +0,0 @@
|
|||
package pl.minecon724.realweather.weather;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import pl.minecon724.realweather.RW;
|
||||
import pl.minecon724.realweather.SubLogger;
|
||||
import pl.minecon724.realweather.map.Coordinates;
|
||||
import pl.minecon724.realweather.map.WorldMap;
|
||||
import pl.minecon724.realweather.map.WorldMap.Type;
|
||||
import pl.minecon724.realweather.map.exceptions.GeoIPException;
|
||||
import pl.minecon724.realweather.weather.WeatherState.State;
|
||||
import pl.minecon724.realweather.weather.events.WeatherSyncEvent;
|
||||
import pl.minecon724.realweather.weather.provider.Provider;
|
||||
|
||||
public class GetStateTask extends BukkitRunnable {
|
||||
|
||||
private SubLogger subLogger = new SubLogger("weather updater");
|
||||
|
||||
private RW plugin;
|
||||
private Provider provider;
|
||||
private WorldMap worldMap;
|
||||
|
||||
private State storedState;
|
||||
private Map<Player, State> playerStoredState = new HashMap<>();
|
||||
private PluginManager pluginManager = Bukkit.getPluginManager();
|
||||
|
||||
public GetStateTask(
|
||||
RW plugin,
|
||||
Provider provider,
|
||||
WorldMap worldMap
|
||||
) {
|
||||
this.plugin = plugin;
|
||||
this.provider = provider;
|
||||
this.worldMap = worldMap;
|
||||
}
|
||||
|
||||
private void callEvent(Player player, State storedState, State state) {
|
||||
new BukkitRunnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
pluginManager.callEvent(
|
||||
new WeatherSyncEvent(player, storedState, state)
|
||||
);
|
||||
}
|
||||
|
||||
}.runTask(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
if (worldMap.getType() == Type.POINT) {
|
||||
Coordinates coordinates;
|
||||
try {
|
||||
coordinates = worldMap.getCoordinates(null);
|
||||
} catch (GeoIPException e) { return; }
|
||||
State state = provider.request_state(coordinates);
|
||||
|
||||
if (!state.equals(storedState)) {
|
||||
callEvent(null, storedState, state);
|
||||
storedState = state;
|
||||
}
|
||||
|
||||
} else {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
Coordinates coordinates;
|
||||
|
||||
try {
|
||||
coordinates = worldMap.getCoordinates(player);
|
||||
} catch (GeoIPException e) {
|
||||
subLogger.info("GeoIP error for %s", player.getName());
|
||||
e.printStackTrace();
|
||||
continue;
|
||||
}
|
||||
|
||||
State state = provider.request_state(coordinates);
|
||||
|
||||
if (!state.equals(playerStoredState.get(player))) {
|
||||
callEvent(player,
|
||||
playerStoredState.get(player),
|
||||
state);
|
||||
|
||||
playerStoredState.put(player, state);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
subLogger.info("Error updating: %s", e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -1,32 +0,0 @@
|
|||
package pl.minecon724.realweather.weather;
|
||||
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import pl.minecon724.realweather.weather.provider.OpenWeatherMapProvider;
|
||||
import pl.minecon724.realweather.weather.provider.Provider;
|
||||
|
||||
public class Providers {
|
||||
/**
|
||||
* get Provider by name
|
||||
* @param name name of provider
|
||||
* @param config configuration of provider
|
||||
* @return subclass of Provider or null if invalid
|
||||
* @throws ProviderException
|
||||
* @see Provider
|
||||
*/
|
||||
public static Provider getByName(String name, ConfigurationSection config) {
|
||||
|
||||
switch (name) {
|
||||
case "openweathermap":
|
||||
return openWeatherMap(config);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static OpenWeatherMapProvider openWeatherMap(ConfigurationSection config) {
|
||||
|
||||
return new OpenWeatherMapProvider(
|
||||
config.getString("apiKey"));
|
||||
}
|
||||
}
|
|
@ -1,78 +0,0 @@
|
|||
package pl.minecon724.realweather.weather;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.GameRule;
|
||||
import org.bukkit.WeatherType;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.weather.WeatherChangeEvent;
|
||||
import org.bukkit.event.weather.WeatherEvent;
|
||||
import org.bukkit.event.world.WorldLoadEvent;
|
||||
import org.bukkit.event.world.WorldUnloadEvent;
|
||||
|
||||
import pl.minecon724.realweather.SubLogger;
|
||||
import pl.minecon724.realweather.weather.WeatherState.ConditionSimple;
|
||||
import pl.minecon724.realweather.weather.WeatherState.State;
|
||||
import pl.minecon724.realweather.weather.events.WeatherSyncEvent;
|
||||
|
||||
public class WeatherChanger implements Listener {
|
||||
private List<String> worldNames;
|
||||
private List<World> worlds = new ArrayList<>();
|
||||
private SubLogger subLogger = new SubLogger("weatherchanger");
|
||||
|
||||
public WeatherChanger(List<String> worldNames) {
|
||||
this.worldNames = worldNames;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onWorldLoad(WorldLoadEvent event) {
|
||||
World world = event.getWorld();
|
||||
subLogger.info("World %s is loading", world.getName());
|
||||
|
||||
if (worldNames.contains(world.getName())) {
|
||||
worlds.add(world);
|
||||
world.setGameRule(GameRule.DO_WEATHER_CYCLE, false);
|
||||
subLogger.info("World %s has been registered", world.getName());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onWorldUnload(WorldUnloadEvent event) {
|
||||
World world = event.getWorld();
|
||||
world.setGameRule(GameRule.DO_WEATHER_CYCLE, true);
|
||||
|
||||
worlds.remove(world);
|
||||
subLogger.info("World %s unloaded", world.getName());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onWeatherSync(WeatherSyncEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
State state = event.getState();
|
||||
|
||||
if (player != null) {
|
||||
subLogger.info("new weather for %s: %s %s", player.getName(), state.getCondition().name(), state.getLevel().name());
|
||||
|
||||
player.setPlayerWeather(
|
||||
state.getSimple() == ConditionSimple.CLEAR
|
||||
? WeatherType.CLEAR : WeatherType.DOWNFALL
|
||||
);
|
||||
|
||||
} else {
|
||||
subLogger.info("new weather: %s %s", state.getCondition().name(), state.getLevel().name());
|
||||
|
||||
worlds.forEach(w -> {
|
||||
w.setStorm(state.getSimple() != ConditionSimple.CLEAR);
|
||||
w.setThundering(state.getSimple() == ConditionSimple.THUNDER);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,79 +0,0 @@
|
|||
package pl.minecon724.realweather.weather;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import pl.minecon724.realweather.RW;
|
||||
import pl.minecon724.realweather.SubLogger;
|
||||
import pl.minecon724.realweather.map.Coordinates;
|
||||
import pl.minecon724.realweather.map.WorldMap;
|
||||
import pl.minecon724.realweather.weather.exceptions.DisabledException;
|
||||
import pl.minecon724.realweather.weather.provider.Provider;
|
||||
|
||||
public class WeatherCommander {
|
||||
private WorldMap worldMap = WorldMap.getInstance();
|
||||
private RW plugin;
|
||||
|
||||
private boolean enabled;
|
||||
private List<String> worldNames;
|
||||
private String providerName;
|
||||
private Provider provider;
|
||||
private ConfigurationSection providerConfig;
|
||||
|
||||
private GetStateTask getStateTask;
|
||||
|
||||
private SubLogger subLogger = new SubLogger("weather");
|
||||
|
||||
public WeatherCommander(RW plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize weather commander
|
||||
* @param config "weather" ConfigurationSection
|
||||
* @throws DisabledException if disabled in config
|
||||
* @throws ProviderException if invalid provider config
|
||||
*/
|
||||
public void init(ConfigurationSection config)
|
||||
throws DisabledException, IllegalArgumentException {
|
||||
|
||||
enabled = config.getBoolean("enabled");
|
||||
|
||||
if (!enabled)
|
||||
throw new DisabledException();
|
||||
|
||||
worldNames = config.getStringList("worlds");
|
||||
|
||||
providerName = config.getString("provider.choice");
|
||||
|
||||
// this can be null
|
||||
providerConfig = config.getConfigurationSection("provider")
|
||||
.getConfigurationSection(providerName);
|
||||
|
||||
provider = Providers.getByName(providerName, providerConfig);
|
||||
if (provider == null)
|
||||
throw new IllegalArgumentException("Invalid provider: " + providerName);
|
||||
provider.init();
|
||||
|
||||
try {
|
||||
provider.request_state(new Coordinates(0, 0));
|
||||
} catch (IOException e) {
|
||||
subLogger.info("Provider test failed, errors may occur", new Object[0]);
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
plugin.getServer().getPluginManager().registerEvents(
|
||||
new WeatherChanger(worldNames), plugin);
|
||||
|
||||
subLogger.info("done", new Object[0]);
|
||||
}
|
||||
|
||||
public void start() {
|
||||
getStateTask = new GetStateTask(plugin, provider, worldMap);
|
||||
|
||||
getStateTask.runTaskTimerAsynchronously(plugin, 0, 1200);
|
||||
subLogger.info("started", new Object[0]);
|
||||
}
|
||||
}
|
|
@ -1,69 +0,0 @@
|
|||
package pl.minecon724.realweather.weather;
|
||||
|
||||
public class WeatherState {
|
||||
|
||||
// Enums
|
||||
|
||||
public enum Condition { THUNDER, DRIZZLE, RAIN, SNOW, CLEAR, CLOUDY };
|
||||
public enum ConditionLevel { LIGHT, MODERATE, HEAVY, EXTREME };
|
||||
public enum ConditionSimple { THUNDER, RAIN, CLEAR };
|
||||
|
||||
// State class
|
||||
|
||||
public static class State {
|
||||
|
||||
// Variables
|
||||
|
||||
private Condition condition;
|
||||
private ConditionLevel level;
|
||||
private ConditionSimple simple;
|
||||
|
||||
// Constructor
|
||||
|
||||
public State(Condition condition,
|
||||
ConditionLevel level,
|
||||
ConditionSimple simple) {
|
||||
this.condition = condition;
|
||||
this.level = level;
|
||||
this.simple = simple;
|
||||
}
|
||||
|
||||
public State(Condition condition,
|
||||
ConditionLevel level) {
|
||||
this.condition = condition;
|
||||
this.level = level;
|
||||
this.simple = null;
|
||||
switch (condition) {
|
||||
case THUNDER:
|
||||
this.simple = ConditionSimple.THUNDER;
|
||||
break;
|
||||
case DRIZZLE:
|
||||
case RAIN:
|
||||
case SNOW:
|
||||
this.simple = ConditionSimple.RAIN;
|
||||
break;
|
||||
case CLEAR:
|
||||
case CLOUDY:
|
||||
this.simple = ConditionSimple.CLEAR;
|
||||
}
|
||||
}
|
||||
|
||||
public Condition getCondition() {
|
||||
return condition;
|
||||
}
|
||||
|
||||
public ConditionLevel getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
public ConditionSimple getSimple() {
|
||||
return simple;
|
||||
}
|
||||
|
||||
public boolean equals(State state) {
|
||||
return (state != null
|
||||
&& this.getCondition() == state.getCondition()
|
||||
&& this.getLevel() == state.getLevel());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
package pl.minecon724.realweather.weather.events;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
|
||||
import pl.minecon724.realweather.weather.WeatherState.State;
|
||||
|
||||
public class WeatherSyncEvent extends PlayerEvent {
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
|
||||
private State oldState;
|
||||
private State state;
|
||||
|
||||
public WeatherSyncEvent(Player player, State oldState, State state) {
|
||||
super(player);
|
||||
|
||||
this.oldState = oldState;
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
public State getOldState() {
|
||||
return oldState;
|
||||
}
|
||||
|
||||
public State getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
package pl.minecon724.realweather.weather.exceptions;
|
||||
|
||||
public class DisabledException extends Exception {
|
||||
|
||||
}
|
|
@ -1,171 +0,0 @@
|
|||
package pl.minecon724.realweather.weather.provider;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import pl.minecon724.realweather.map.Coordinates;
|
||||
import pl.minecon724.realweather.weather.WeatherState.*;
|
||||
|
||||
public class OpenWeatherMapProvider implements Provider {
|
||||
|
||||
URL endpoint;
|
||||
|
||||
String apiKey;
|
||||
|
||||
public OpenWeatherMapProvider(String apiKey) {
|
||||
this.apiKey = apiKey;
|
||||
}
|
||||
|
||||
public void init() {
|
||||
try {
|
||||
endpoint = new URL("https://api.openweathermap.org");
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public State request_state(Coordinates coordinates) throws IOException {
|
||||
JSONObject json = new JSONObject();
|
||||
|
||||
try {
|
||||
URL url = new URL(
|
||||
endpoint + String.format("/data/2.5/weather?lat=%s&lon=%s&appid=%s",
|
||||
Double.toString(coordinates.latitude), Double.toString(coordinates.longitude), apiKey
|
||||
));
|
||||
|
||||
InputStream is = url.openStream();
|
||||
BufferedReader rd = new BufferedReader( new InputStreamReader(is, Charset.forName("UTF-8")) );
|
||||
StringBuilder sb = new StringBuilder();
|
||||
int c;
|
||||
while ((c = rd.read()) != -1) {
|
||||
sb.append((char) c);
|
||||
}
|
||||
is.close();
|
||||
json = new JSONObject(sb.toString());
|
||||
} catch (Exception e) {
|
||||
throw new IOException("Couldn't contact openweathermap");
|
||||
}
|
||||
|
||||
int stateId;
|
||||
try {
|
||||
stateId = json.getJSONArray("weather")
|
||||
.getJSONObject(0).getInt("id");
|
||||
} catch (JSONException e) {
|
||||
throw new IOException("Invalid data from openweathermap");
|
||||
}
|
||||
|
||||
// Here comes the mess
|
||||
Condition condition = Condition.CLEAR;
|
||||
ConditionLevel level = ConditionLevel.LIGHT;
|
||||
if (stateId < 300) {
|
||||
condition = Condition.THUNDER;
|
||||
switch (stateId) {
|
||||
case 200:
|
||||
case 210:
|
||||
case 230:
|
||||
level = ConditionLevel.LIGHT;
|
||||
break;
|
||||
case 201:
|
||||
case 211:
|
||||
case 221:
|
||||
case 231:
|
||||
level = ConditionLevel.MODERATE;
|
||||
break;
|
||||
case 202:
|
||||
case 212:
|
||||
case 232:
|
||||
level = ConditionLevel.HEAVY;
|
||||
}
|
||||
} else if (stateId < 400) {
|
||||
condition = Condition.DRIZZLE;
|
||||
switch (stateId) {
|
||||
case 300:
|
||||
case 310:
|
||||
level = ConditionLevel.LIGHT;
|
||||
break;
|
||||
case 301:
|
||||
case 311:
|
||||
case 313:
|
||||
case 321:
|
||||
level = ConditionLevel.MODERATE;
|
||||
break;
|
||||
case 302:
|
||||
case 312:
|
||||
case 314:
|
||||
level = ConditionLevel.HEAVY;
|
||||
}
|
||||
} else if (stateId < 600) {
|
||||
condition = Condition.RAIN;
|
||||
switch (stateId) {
|
||||
case 500:
|
||||
case 520:
|
||||
level = ConditionLevel.LIGHT;
|
||||
break;
|
||||
case 501:
|
||||
case 511:
|
||||
case 521:
|
||||
case 531:
|
||||
level = ConditionLevel.MODERATE;
|
||||
break;
|
||||
case 502:
|
||||
case 522:
|
||||
level = ConditionLevel.HEAVY;
|
||||
break;
|
||||
case 503:
|
||||
case 504:
|
||||
level = ConditionLevel.EXTREME;
|
||||
}
|
||||
} else if (stateId < 700) {
|
||||
condition = Condition.SNOW;
|
||||
switch (stateId) {
|
||||
case 600:
|
||||
case 612:
|
||||
case 615:
|
||||
case 620:
|
||||
level = ConditionLevel.LIGHT;
|
||||
break;
|
||||
case 601:
|
||||
case 611:
|
||||
case 613:
|
||||
case 616:
|
||||
case 621:
|
||||
level = ConditionLevel.MODERATE;
|
||||
break;
|
||||
case 602:
|
||||
case 622:
|
||||
level = ConditionLevel.HEAVY;
|
||||
}
|
||||
} else if (stateId > 800) {
|
||||
condition = Condition.CLOUDY;
|
||||
switch (stateId) {
|
||||
case 801:
|
||||
level = ConditionLevel.LIGHT;
|
||||
break;
|
||||
case 802:
|
||||
level = ConditionLevel.MODERATE;
|
||||
break;
|
||||
case 803:
|
||||
level = ConditionLevel.HEAVY;
|
||||
break;
|
||||
case 804:
|
||||
level = ConditionLevel.EXTREME;
|
||||
}
|
||||
}
|
||||
|
||||
State state = new State(condition, level);
|
||||
return state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "OpenWeatherMap";
|
||||
}
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
package pl.minecon724.realweather.weather.provider;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import pl.minecon724.realweather.map.Coordinates;
|
||||
import pl.minecon724.realweather.weather.WeatherState;
|
||||
|
||||
public interface Provider {
|
||||
public void init();
|
||||
public WeatherState.State request_state(Coordinates coordinates) throws IOException;
|
||||
public String getName();
|
||||
}
|
|
@ -1,67 +1,23 @@
|
|||
weather:
|
||||
enabled: true
|
||||
############################
|
||||
### GENERAL SETTINGS ###
|
||||
############################
|
||||
|
||||
worlds:
|
||||
- world
|
||||
- second_world
|
||||
- third_world
|
||||
|
||||
provider:
|
||||
# Weather provider
|
||||
choice: openweathermap
|
||||
# Configure it here
|
||||
openweathermap:
|
||||
apiKey: 'd3d37fd3511ef1d4b44c7d574e9b56b8' # PLEASE get your own @ https://home.openweathermap.org/users/sign_up
|
||||
# More providers soon!
|
||||
|
||||
map:
|
||||
# "point" - static location
|
||||
# "player" - player's IP location (fake weather)
|
||||
# "globe" - world resembles a real-world globe
|
||||
type: point
|
||||
|
||||
point:
|
||||
latitude: 41.84201
|
||||
longitude: -89.485937
|
||||
|
||||
player:
|
||||
# Get your own @ https://www.maxmind.com/en/geolite2/signup
|
||||
geolite2_accountId: 710438
|
||||
geolite2_api_key: 'qLeseHp4QNQcqRGn'
|
||||
|
||||
globe:
|
||||
# Valid latitude range: -90 to 90
|
||||
# Valid longitude range: -180 to 180
|
||||
# 1 degree of latitude and longitude is about 111 km
|
||||
# The defaults here assume 1 block = ~1 km
|
||||
# 1 block = <scale> degrees
|
||||
scale_latitude: 0.009
|
||||
scale_longitude: 0.009
|
||||
|
||||
# What to do if player exceeds the range specified above
|
||||
# false - do nothing (clamp to nearest allowed value)
|
||||
# true - wrap the number
|
||||
# for example; if a player's position on map converts to 94 degrees (out of bounds), it becomes -86 degrees
|
||||
wrap: true
|
||||
|
||||
time:
|
||||
# warning: this removes sleep
|
||||
# Master switch
|
||||
enabled: false
|
||||
|
||||
worlds:
|
||||
- world
|
||||
updater:
|
||||
# Notify players and console about plugin updates
|
||||
# This also controls automatic checking
|
||||
# You can still update with /rwadmin update
|
||||
# Relevant permission node: realweather.update.notify
|
||||
notify: true
|
||||
# stable for stable releases
|
||||
# testing for latest builds (untested hence the name)
|
||||
# As there's no release yet, stable will just error
|
||||
channel: testing
|
||||
|
||||
# "auto" to use server's timezone
|
||||
# Alternatively choose one of these: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List
|
||||
# WARNING: it is purely cosmetical
|
||||
timezone: 'auto'
|
||||
|
||||
# x day cycles / 24 hrs
|
||||
# basically how many Minecraft days during a real day
|
||||
scale: 1.0
|
||||
|
||||
# time based on... time?
|
||||
# each player has time offset like timezones
|
||||
# uses timezone as base, unless auto
|
||||
# uses settings from map
|
||||
per_player: false
|
||||
# 0 - no debug
|
||||
# 1 - debug loading modules
|
||||
# 2 - also debug processing conditions
|
||||
# 3 - also log tasks running, this will spam
|
||||
debug: 0
|
24
src/main/resources/map.yml
Normal file
24
src/main/resources/map.yml
Normal file
|
@ -0,0 +1,24 @@
|
|||
############################
|
||||
### MAP SETTINGS ###
|
||||
############################
|
||||
|
||||
# true if the list below is a blacklist, false otherwise
|
||||
worldBlacklist: false
|
||||
worlds:
|
||||
- world
|
||||
|
||||
dimensions:
|
||||
# Blocks per 1 deg, can't be decimal
|
||||
# latitude = -Z, longitude = X (to match with F3)
|
||||
# The default (111000) assumes 1 block = 1 meter
|
||||
latitude: 111000 # -9990000 to 9990000 Z
|
||||
longitude: 111000 # -19980000 to 19980000 X
|
||||
|
||||
# To make it span world border to world border:
|
||||
# latitude: 333333
|
||||
# longitude: 166666
|
||||
|
||||
# For `static` mode
|
||||
point:
|
||||
latitude: 0
|
||||
longitude: 0
|
15
src/main/resources/modules/thunder.yml
Normal file
15
src/main/resources/modules/thunder.yml
Normal file
|
@ -0,0 +1,15 @@
|
|||
############################
|
||||
### THUNDER SETTINGS ###
|
||||
############################
|
||||
|
||||
enabled: false
|
||||
|
||||
# Currently only blitzortung
|
||||
provider: blitzortung
|
||||
|
||||
# How often should we poll for updates and spawn lightning
|
||||
# This is a synchronous task
|
||||
# Exaggerating, if you put it too low you'll have lag,
|
||||
# But if you put it too high you'll have lag spikes and weird lightning
|
||||
# In ticks, default 100 is 5 seconds so reduce if lightning seems weird, in my testing even 5 ticks is fine
|
||||
refreshPeriod: 100
|
21
src/main/resources/modules/time.yml
Normal file
21
src/main/resources/modules/time.yml
Normal file
|
@ -0,0 +1,21 @@
|
|||
############################
|
||||
### TIME SETTINGS ###
|
||||
############################
|
||||
|
||||
# Warning: this removes sleep
|
||||
# No, it's not a bug. It would de-synchronize, and can you skip time IRL?
|
||||
# Can you believe that I actually used to consider this a bug?
|
||||
|
||||
enabled: false
|
||||
|
||||
# How this plugin affects your world:
|
||||
# - static (false): time is the same across the world
|
||||
# - dynamic (true): static + local time for each player, however it's only cosmetic so it will not match mobs spawning etc
|
||||
# Settings for both are in map.yml
|
||||
dynamic: true
|
||||
|
||||
# x in game day cycles in 1 irl day cycle
|
||||
# 2.0 - time goes 2x SLOWER
|
||||
# 0.5 - time goes 2x FASTER
|
||||
# If modified, time will no longer be in sync with real life
|
||||
scale: 1.0
|
21
src/main/resources/modules/weather.yml
Normal file
21
src/main/resources/modules/weather.yml
Normal file
|
@ -0,0 +1,21 @@
|
|||
############################
|
||||
### WEATHER SETTINGS ###
|
||||
############################
|
||||
|
||||
# In Minecraft, it can only rain or not rain (or snow - but not both) and thunder or not thunder.
|
||||
# In real life, rain, thunder, snow can be heavy, moderate, light and in between and can coexist. That's excluding many other conditions.
|
||||
# For now, there's just rain and thunder
|
||||
# This plugin will improve in the future, but there's other stuff to work on currently. I hope you understand.
|
||||
|
||||
enabled: false
|
||||
|
||||
# Currently only OpenWeatherMap
|
||||
provider: openweathermap
|
||||
# put your OpenWeatherMap api key
|
||||
apiKey: REPLACE ME
|
||||
|
||||
# How this plugin affects your world:
|
||||
# - static (false): weather is the same across the world
|
||||
# - dynamic (true): weather is per player, however it's only cosmetic so it will not match mobs spawning etc
|
||||
# settings for both are in map.yml
|
||||
dynamic: true
|
|
@ -1,9 +1,63 @@
|
|||
name: RealWeather
|
||||
version: ${project.version}
|
||||
api-version: 1.16
|
||||
load: STARTUP
|
||||
|
||||
author: Minecon724
|
||||
main: pl.minecon724.realweather.RW
|
||||
website: https://www.spigotmc.org/resources/realweather-realtime.101599/
|
||||
|
||||
api-version: 1.19.4
|
||||
load: STARTUP
|
||||
main: eu.m724.realweather.RealWeatherPlugin
|
||||
|
||||
libraries:
|
||||
- org.json:json:20231013
|
||||
- com.maxmind.geoip2:geoip2:4.2.0
|
||||
- org.java-websocket:Java-WebSocket:1.5.7
|
||||
|
||||
commands:
|
||||
rwadmin:
|
||||
description: RealWeather admin command
|
||||
permission: realweather.admin
|
||||
permission-message: You do not have permission to use this command.
|
||||
|
||||
geo:
|
||||
description: Convert lat,lon <=> x,y,z
|
||||
permission: realweather.command.geo
|
||||
permission-message: You do not have permission to use this command.
|
||||
localtime:
|
||||
description: Get real time in current location
|
||||
permission: realweather.command.localtime
|
||||
permission-message: You do not have permission to use this command.
|
||||
localweather:
|
||||
description: Get weather in current location
|
||||
permission: realweather.command.localweather
|
||||
permission-message: You do not have permission to use this command.
|
||||
|
||||
permissions:
|
||||
# Commands
|
||||
|
||||
realweather.admin:
|
||||
description: Allows admin management with /rwadmin
|
||||
realweather.admin.update:
|
||||
description: Allows installing updates with /rwadmin update
|
||||
|
||||
realweather.command.geo:
|
||||
description: Allows /geo
|
||||
default: true
|
||||
realweather.command.localtime:
|
||||
description: Allows /localtime
|
||||
default: true
|
||||
realweather.command.localweather:
|
||||
description: Allows /localweather
|
||||
default: true
|
||||
|
||||
# Engine
|
||||
|
||||
realweather.dynamic:
|
||||
description: Includes player in dynamic conditions
|
||||
default: true
|
||||
|
||||
# Other
|
||||
|
||||
realweather.actionbar:
|
||||
description: Displays status on player's action bar
|
||||
|
||||
realweather.update.notify:
|
||||
description: Receive notifications for RealWeather updates
|
9
src/main/resources/verifies_downloaded_jars.pem
Normal file
9
src/main/resources/verifies_downloaded_jars.pem
Normal file
|
@ -0,0 +1,9 @@
|
|||
-----BEGIN PUBLIC KEY-----
|
||||
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxjjjayrwlo3cnv+rX1EX
|
||||
lJN9vHS9MNfvE7zFOHr2JEAx2fRosb2oRzNK0ssoHJFOgrwLWIqrLVS8bTHRujsF
|
||||
asck2Z1RY5UGe34vNQ5u5MZvm4G25LggC6+ei2kEptoAfgp9kjmeKVPiSnruLn7N
|
||||
YQc9U4nmr/vJg+SNmy00EkXFU5z3ZsLf8aCjx9rtogZzyZmVPXEDGY3ZjzZxOpv9
|
||||
TAvSQlmrc6qmLlY7XZmJMtbzCTq+qqemZBKp6WpNmEogpPgXamOrET434+oE7OCz
|
||||
+WCFKsVN8qbrQdFLf1HSjghvDoIjHcGfz6cP4nBonSKIfMcr+NziAVmimfqOiDxa
|
||||
nwIDAQAB
|
||||
-----END PUBLIC KEY-----
|
BIN
testkeystore.jks
Normal file
BIN
testkeystore.jks
Normal file
Binary file not shown.
Loading…
Reference in a new issue