diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6f18e3a --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +/nbproject/private/ +/out/ +/lib/ +/build/ +/dist/ +/store/ +/target/ diff --git a/Cron.iml b/Cron.iml deleted file mode 100644 index 5c7842e..0000000 --- a/Cron.iml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/dependency-reduced-pom.xml b/dependency-reduced-pom.xml new file mode 100644 index 0000000..4080b3b --- /dev/null +++ b/dependency-reduced-pom.xml @@ -0,0 +1,194 @@ + + + 4.0.0 + com.github.crashdemons + Cron + 0.0.4 + + + Mozilla Public License 2.0 + http://mozilla.org/MPL/2.0/ + repo + + + + crashdemons + https://github.com/AztecMC + + + + + true + ${basedir}/src/main/resources + + + ${project.name}-${project.version} + + + + org.eclipse.m2e + lifecycle-mapping + 1.0.0 + + + + + + org.codehaus.mojo + versions-maven-plugin + [2.2,) + + use-latest-versions + + + + + + + + + + + + + + + org.codehaus.mojo + versions-maven-plugin + 2.2 + + + versions + validate + + use-latest-versions + + + true + + + + + + org.bukkit + org.spigotmc + + + + + maven-jar-plugin + 3.0.2 + + + + Maven + ${project.name} + ${project.version} + ${project.groupId} + ${project.organization.name} + + + + + + maven-compiler-plugin + 3.5.1 + + 1.8 + 1.8 + -Xlint:all + + + + maven-antrun-plugin + 1.8 + + + package + + run + + + + + + + + + + + maven-shade-plugin + 3.2.0 + + + package + + shade + + + + + joda-time:joda-time:jar: + + + + + org.joda.time + org.aztecmc.plugins.cron.joda-time + + + + + + + + + + + mojang + Mojang's Repository + https://libraries.minecraft.net/ + + + spigot-repo + https://hub.spigotmc.org/nexus/content/repositories/snapshots/ + + + md_5-releases + http://repo.md-5.net/content/repositories/releases/ + + + spigot-group-repo + https://hub.spigotmc.org/nexus/content/groups/public/ + + + + + org.spigotmc + spigot-api + 1.17-R0.1-SNAPSHOT + compile + + + fr.neatmonster + ncpplugin + static + compile + + + bukkit + org.bukkit + + + craftbukkit + org.bukkit + + + + + + 1.8 + UTF-8 + 1.8 + + diff --git a/lib/joda-time-2.8.1.jar b/lib/joda-time-2.8.1.jar deleted file mode 100644 index 94be659..0000000 Binary files a/lib/joda-time-2.8.1.jar and /dev/null differ diff --git a/nb-configuration.xml b/nb-configuration.xml new file mode 100644 index 0000000..a65c451 --- /dev/null +++ b/nb-configuration.xml @@ -0,0 +1,18 @@ + + + + + + JDK_1.8 + + diff --git a/out/artifacts/Cron_jar/Cron.jar b/out/artifacts/Cron_jar/Cron.jar deleted file mode 100644 index c471dba..0000000 Binary files a/out/artifacts/Cron_jar/Cron.jar and /dev/null differ diff --git a/out/production/Cron/config.yml b/out/production/Cron/config.yml deleted file mode 100644 index f145cf0..0000000 --- a/out/production/Cron/config.yml +++ /dev/null @@ -1,9 +0,0 @@ -cron-poll-resolution: 600 -cron-timezone: "US/Eastern" -crons: -- name: Purge CoreProtect - time: T00:30 - period: PT8H - commands: - - 'co purge t:72h' - - 'helpop purging coreprotect' \ No newline at end of file diff --git a/out/production/Cron/org/aztecmc/plugins/cron/CronDef.class b/out/production/Cron/org/aztecmc/plugins/cron/CronDef.class deleted file mode 100644 index 9494b1c..0000000 Binary files a/out/production/Cron/org/aztecmc/plugins/cron/CronDef.class and /dev/null differ diff --git a/out/production/Cron/org/aztecmc/plugins/cron/CronPlugin$1.class b/out/production/Cron/org/aztecmc/plugins/cron/CronPlugin$1.class deleted file mode 100644 index ec825e6..0000000 Binary files a/out/production/Cron/org/aztecmc/plugins/cron/CronPlugin$1.class and /dev/null differ diff --git a/out/production/Cron/org/aztecmc/plugins/cron/CronPlugin.class b/out/production/Cron/org/aztecmc/plugins/cron/CronPlugin.class deleted file mode 100644 index ccbacfe..0000000 Binary files a/out/production/Cron/org/aztecmc/plugins/cron/CronPlugin.class and /dev/null differ diff --git a/out/production/Cron/org/aztecmc/plugins/cron/test/Main$1$1.class b/out/production/Cron/org/aztecmc/plugins/cron/test/Main$1$1.class deleted file mode 100644 index 99c4c1d..0000000 Binary files a/out/production/Cron/org/aztecmc/plugins/cron/test/Main$1$1.class and /dev/null differ diff --git a/out/production/Cron/org/aztecmc/plugins/cron/test/Main$1.class b/out/production/Cron/org/aztecmc/plugins/cron/test/Main$1.class deleted file mode 100644 index 026a484..0000000 Binary files a/out/production/Cron/org/aztecmc/plugins/cron/test/Main$1.class and /dev/null differ diff --git a/out/production/Cron/org/aztecmc/plugins/cron/test/Main.class b/out/production/Cron/org/aztecmc/plugins/cron/test/Main.class deleted file mode 100644 index 8804b82..0000000 Binary files a/out/production/Cron/org/aztecmc/plugins/cron/test/Main.class and /dev/null differ diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..47fcebe --- /dev/null +++ b/pom.xml @@ -0,0 +1,210 @@ + + + 4.0.0 + com.github.crashdemons + Cron + 0.0.4 + jar + + UTF-8 + 1.8 + 1.8 + + + + crashdemons + https://github.com/AztecMC + + + + + Mozilla Public License 2.0 + http://mozilla.org/MPL/2.0/ + repo + + + + + + + mojang + Mojang's Repository + https://libraries.minecraft.net/ + + + spigot-repo + https://hub.spigotmc.org/nexus/content/repositories/snapshots/ + + + md_5-releases + http://repo.md-5.net/content/repositories/releases/ + + + spigot-group-repo + https://hub.spigotmc.org/nexus/content/groups/public/ + + + + + + + joda-time + joda-time + 2.10.9 + + + + org.spigotmc + spigot-api + 1.17-R0.1-SNAPSHOT + + + fr.neatmonster + ncpplugin + static + + + org.bukkit + bukkit + + + org.bukkit + craftbukkit + + + + + + + ${project.name}-${project.version} + + + ${basedir}/src/main/resources + true + + + + + org.codehaus.mojo + versions-maven-plugin + 2.2 + + + org.bukkit + org.spigotmc + + + + + versions + validate + + true + + + use-latest-versions + + + + + + maven-jar-plugin + 3.0.2 + + + + Maven + ${project.name} + ${project.version} + ${project.groupId} + ${project.organization.name} + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.5.1 + + 1.8 + 1.8 + -Xlint:all + + + + maven-antrun-plugin + 1.8 + + + package + + + + + + + run + + + + + + org.apache.maven.plugins + maven-shade-plugin + 3.2.0 + + + package + + shade + + + + + joda-time:joda-time:jar: + + + + + org.joda.time + org.aztecmc.plugins.cron.joda-time + + + + + + + + + + + + org.eclipse.m2e + lifecycle-mapping + 1.0.0 + + + + + + org.codehaus.mojo + versions-maven-plugin + [2.2,) + + use-latest-versions + + + + + + + + + + + + + + \ No newline at end of file diff --git a/pom.xml.versionsBackup b/pom.xml.versionsBackup new file mode 100644 index 0000000..d3edc17 --- /dev/null +++ b/pom.xml.versionsBackup @@ -0,0 +1,210 @@ + + + 4.0.0 + com.github.crashdemons + Cron + 0.0.4 + jar + + UTF-8 + 1.8 + 1.8 + + + + crashdemons + https://github.com/AztecMC + + + + + Mozilla Public License 2.0 + http://mozilla.org/MPL/2.0/ + repo + + + + + + + mojang + Mojang's Repository + https://libraries.minecraft.net/ + + + spigot-repo + https://hub.spigotmc.org/nexus/content/repositories/snapshots/ + + + md_5-releases + http://repo.md-5.net/content/repositories/releases/ + + + spigot-group-repo + https://hub.spigotmc.org/nexus/content/groups/public/ + + + + + + + joda-time + joda-time + 2.10.9 + + + + org.spigotmc + spigot-api + 1.16.4-R0.1-SNAPSHOT + + + fr.neatmonster + ncpplugin + static + + + org.bukkit + bukkit + + + org.bukkit + craftbukkit + + + + + + + ${project.name}-${project.version} + + + ${basedir}/src/main/resources + true + + + + + org.codehaus.mojo + versions-maven-plugin + 2.2 + + + org.bukkit + org.spigotmc + + + + + versions + validate + + true + + + use-latest-versions + + + + + + maven-jar-plugin + 3.0.2 + + + + Maven + ${project.name} + ${project.version} + ${project.groupId} + ${project.organization.name} + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.5.1 + + 1.8 + 1.8 + -Xlint:all + + + + maven-antrun-plugin + 1.8 + + + package + + + + + + + run + + + + + + org.apache.maven.plugins + maven-shade-plugin + 3.2.0 + + + package + + shade + + + + + joda-time:joda-time:jar: + + + + + org.joda.time + org.aztecmc.plugins.cron.joda-time + + + + + + + + + + + + org.eclipse.m2e + lifecycle-mapping + 1.0.0 + + + + + + org.codehaus.mojo + versions-maven-plugin + [2.2,) + + use-latest-versions + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/org/aztecmc/plugins/cron/CronDef.java b/src/main/java/org/aztecmc/plugins/cron/CronDef.java similarity index 98% rename from src/org/aztecmc/plugins/cron/CronDef.java rename to src/main/java/org/aztecmc/plugins/cron/CronDef.java index 6e5987c..033b4ce 100644 --- a/src/org/aztecmc/plugins/cron/CronDef.java +++ b/src/main/java/org/aztecmc/plugins/cron/CronDef.java @@ -1,6 +1,6 @@ package org.aztecmc.plugins.cron; -import javafx.util.Pair; +import org.aztecmc.plugins.cron.util.Pair; import org.joda.time.*; import java.io.PrintWriter; diff --git a/src/org/aztecmc/plugins/cron/CronPlugin.java b/src/main/java/org/aztecmc/plugins/cron/CronPlugin.java similarity index 93% rename from src/org/aztecmc/plugins/cron/CronPlugin.java rename to src/main/java/org/aztecmc/plugins/cron/CronPlugin.java index 5f82a0c..029f458 100644 --- a/src/org/aztecmc/plugins/cron/CronPlugin.java +++ b/src/main/java/org/aztecmc/plugins/cron/CronPlugin.java @@ -25,7 +25,7 @@ public void onEnable() { } private void wireCrons() { - final String timezone = getConfig().getString("bukkitRunnable-timezone", "America/Los_Angeles"); + final String timezone = getConfig().getString("cron-timezone", "America/Los_Angeles"); final List cronDefs = CronDef.getFromConfig( timezone, getConfig().getMapList("crons"), @@ -53,7 +53,7 @@ public void run() { } }; bukkitRunnable.runTaskTimer(this, 0L, - getConfig().getLong("bukkitRunnable-poll-resolution", 20L)); + getConfig().getLong("cron-poll-resolution", 20L)); } @Override diff --git a/src/org/aztecmc/plugins/cron/test/Main.java b/src/main/java/org/aztecmc/plugins/cron/test/Main.java similarity index 97% rename from src/org/aztecmc/plugins/cron/test/Main.java rename to src/main/java/org/aztecmc/plugins/cron/test/Main.java index 7d4f607..182b9fa 100644 --- a/src/org/aztecmc/plugins/cron/test/Main.java +++ b/src/main/java/org/aztecmc/plugins/cron/test/Main.java @@ -1,43 +1,43 @@ -package org.aztecmc.plugins.cron.test; - -import org.aztecmc.plugins.cron.CronDef; -import org.joda.time.DateTimeZone; -import org.joda.time.LocalTime; - -import java.util.*; - -public class Main { - public static void main(String[] args) { - try { - //cron(args); - testCrons(); - } - catch(Exception e) { - e.printStackTrace(); - } - } - - private static void testCrons() throws Exception { - List> crons = new ArrayList>() {{ - add(new HashMap() - {{ - put("name", "foo"); - put("time", "T04:00"); - put("period", "PT1H"); - put("commands", Arrays.asList("FOO")); - }}); - }}; - - List cronDefs = CronDef.getFromConfig( - crons, new LocalTime(0, 0, 0).toDateTimeToday(DateTimeZone.forID("America/New_York")), - (s) -> System.out.println("LOG: " + s)); - - for(CronDef cron : cronDefs) System.out.println("CRON: " + cron.name + "(" + cron.getNext() + ")"); - - CronDef.runCrons(cronDefs, - new LocalTime(1, 0, 0).toDateTimeToday(DateTimeZone.forID("America/New_York")), - (s) -> System.out.println("CMD: " + s.getValue() + "(" + s.getKey().name + ")")); - - for(CronDef cron : cronDefs) System.out.println("CRON: " + cron.name + "(" + cron.getNext() + ")"); - } -} +package org.aztecmc.plugins.cron.test; + +import org.aztecmc.plugins.cron.CronDef; +import org.joda.time.DateTimeZone; +import org.joda.time.LocalTime; + +import java.util.*; + +public class Main { + public static void main(String[] args) { + try { + //cron(args); + testCrons(); + } + catch(Exception e) { + e.printStackTrace(); + } + } + + private static void testCrons() throws Exception { + List> crons = new ArrayList>() {{ + add(new HashMap() + {{ + put("name", "foo"); + put("time", "T04:00"); + put("period", "PT1H"); + put("commands", Arrays.asList("FOO")); + }}); + }}; + + List cronDefs = CronDef.getFromConfig( + crons, new LocalTime(0, 0, 0).toDateTimeToday(DateTimeZone.forID("America/New_York")), + (s) -> System.out.println("LOG: " + s)); + + for(CronDef cron : cronDefs) System.out.println("CRON: " + cron.name + "(" + cron.getNext() + ")"); + + CronDef.runCrons(cronDefs, + new LocalTime(1, 0, 0).toDateTimeToday(DateTimeZone.forID("America/New_York")), + (s) -> System.out.println("CMD: " + s.getValue() + "(" + s.getKey().name + ")")); + + for(CronDef cron : cronDefs) System.out.println("CRON: " + cron.name + "(" + cron.getNext() + ")"); + } +} diff --git a/src/main/java/org/aztecmc/plugins/cron/util/Pair.java b/src/main/java/org/aztecmc/plugins/cron/util/Pair.java new file mode 100644 index 0000000..f2f5c50 --- /dev/null +++ b/src/main/java/org/aztecmc/plugins/cron/util/Pair.java @@ -0,0 +1,115 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package org.aztecmc.plugins.cron.util; + +import java.util.Map; + +/** + * Defines a container holding a pair of two objects + * + * Note: this is only semantic sugar for Map.Entry with some added methods + * + * @author crash + * @param The type of the first object to hold (the key) + * @param The type of the second object to hold (the value) + */ +public class Pair implements Map.Entry{ + public K a; + public V b; + + /** + * Construct a pair from two objects + * @param first the first object in the pair (the key) + * @param second the second object in the pair (the value) + */ + public Pair(K first, V second){ + this.a=first; + this.b=second; + } + + /** + * Construct a pair from a Map.Entry holding two objects + * + * The key of the entry will become the first object in the pair, the value will be the second. + * + * @param entry a map entry that holds two objects + */ + public Pair(Map.Entry entry){ + a=entry.getKey(); + b=entry.getValue(); + } + + /** + * Get an object by index from the pair container + * @param i an index in the inclusive range [0,1] + * @return if the input was 0: the key (first) object, if the input was 1: the value (second) object + * @throws IndexOutOfBoundsException if the index was neither 0 nor 1 + */ + public Object get(int i){ + switch (i) { + case 0: + return a; + case 1: + return b; + default: + throw new IndexOutOfBoundsException("Pair indexes may only be 0 or 1, not "+i);// or return null ?? + } + } + + /** + * Set an object by index from the pair container + * @param i an index in the inclusive range [0,1] + * @param v the object to set at the index + * @throws IndexOutOfBoundsException if the index was neither 0 nor 1 + */ + @SuppressWarnings("unchecked") + public void set(int i,Object v){ + switch (i) { + case 0: + a = (K) v; + break; + case 1: + b = (V) v; + break; + default: + throw new IndexOutOfBoundsException("Pair indexes may only be 0 or 1, not "+i); + } + } + + /** + * @return the key + */ + @Override + public K getKey() { + return a; + } + + /** + * @param first the key to set + */ + public void setKey(K first) { + this.a = first; + } + + /** + * @return the value + */ + @Override + public V getValue() { + return b; + } + + /** + * @param second the value to set + * @return the previous value held + */ + @Override + public V setValue(V second) { + V old = this.b; + this.b = second; + return old; + } +} diff --git a/src/config.yml b/src/main/resources/config.yml similarity index 95% rename from src/config.yml rename to src/main/resources/config.yml index f145cf0..4454ba3 100644 --- a/src/config.yml +++ b/src/main/resources/config.yml @@ -1,9 +1,9 @@ -cron-poll-resolution: 600 -cron-timezone: "US/Eastern" -crons: -- name: Purge CoreProtect - time: T00:30 - period: PT8H - commands: - - 'co purge t:72h' +cron-poll-resolution: 600 +cron-timezone: "US/Eastern" +crons: +- name: Purge CoreProtect + time: T00:30 + period: PT8H + commands: + - 'co purge t:72h' - 'helpop purging coreprotect' \ No newline at end of file diff --git a/out/production/Cron/plugin.yml b/src/main/resources/plugin.yml similarity index 92% rename from out/production/Cron/plugin.yml rename to src/main/resources/plugin.yml index bddf71f..fa39028 100644 --- a/out/production/Cron/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,18 +1,19 @@ -name: CronPlugin -version: 0.0.1 -author: AztecMC -main: org.aztecmc.plugins.cron.CronPlugin -commands: - cron: - description: reload the config and crons - permission: cron.reload - usage: / reload - -permissions: - cron.*: - description: gives access to all cron commands - children: - cron.reload: true - cron.reload: - description: reload the config and crons +name: CronPlugin +version: 0.0.3 +author: AztecMC +main: org.aztecmc.plugins.cron.CronPlugin +api-version: 1.13 +commands: + cron: + description: reload the config and crons + permission: cron.reload + usage: / reload + +permissions: + cron.*: + description: gives access to all cron commands + children: + cron.reload: true + cron.reload: + description: reload the config and crons default: op \ No newline at end of file diff --git a/src/plugin.yml b/src/plugin.yml deleted file mode 100644 index bddf71f..0000000 --- a/src/plugin.yml +++ /dev/null @@ -1,18 +0,0 @@ -name: CronPlugin -version: 0.0.1 -author: AztecMC -main: org.aztecmc.plugins.cron.CronPlugin -commands: - cron: - description: reload the config and crons - permission: cron.reload - usage: / reload - -permissions: - cron.*: - description: gives access to all cron commands - children: - cron.reload: true - cron.reload: - description: reload the config and crons - default: op \ No newline at end of file