From c3b42035543ed1e3028ee1c8925c8587c0f55378 Mon Sep 17 00:00:00 2001 From: Emma Stone Date: Wed, 11 Jan 2017 22:57:53 +0000 Subject: [PATCH] [FEATURE] Added Library To The Client #requiresJar() should be changed. --- pom.xml | 2 +- .../core/lib/jpushbullet/JPushBullet.java | 71 +++++++++++++++++++ 2 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 src/main/java/org/parabot/core/lib/jpushbullet/JPushBullet.java diff --git a/pom.xml b/pom.xml index 0f5810a..4944707 100755 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ org.parabot client - 2.6.2 + 2.6.3 jar diff --git a/src/main/java/org/parabot/core/lib/jpushbullet/JPushBullet.java b/src/main/java/org/parabot/core/lib/jpushbullet/JPushBullet.java new file mode 100644 index 0000000..6f0242b --- /dev/null +++ b/src/main/java/org/parabot/core/lib/jpushbullet/JPushBullet.java @@ -0,0 +1,71 @@ +package org.parabot.core.lib.jpushbullet; + +import org.parabot.core.Core; +import org.parabot.core.Directories; +import org.parabot.core.build.BuildPath; +import org.parabot.core.lib.Library; + +import java.io.File; +import java.net.URL; + +/** + * @author EmmaStone + */ +public class JPushBullet extends Library { + private static boolean valid; + + @Override + public void init() { + if (!hasJar()) { + System.err.println("Failed to load jpushbullet... [jar missing]"); + return; + } + Core.verbose("Adding jpushbullet jar file to build path: " + + getJarFileURL().getPath()); + BuildPath.add(getJarFileURL()); + + try { + Class.forName("com.shakethat.jpushbullet.net.PushbulletClient"); + valid = true; + } catch (ClassNotFoundException e) { + System.err + .println("Failed to add jpushbullet to build path, or incorrupt download"); + } + + Core.verbose("JPushBullet initialized."); + } + + @Override + public boolean isAdded() { + return valid; + } + + @Override + public File getJarFile() { + return new File(Directories.getCachePath(), "jpushbullet.jar"); + } + + @Override + public URL getDownloadLink() { + try { + return new URL("https://github.com/silk8192/jpushbullet/releases/download/1.0/jpushbullet-1.0.jar"); + } catch (Throwable t) { + t.printStackTrace(); + } + return null; + } + + @Override + public boolean requiresJar() { + return false; + } + + @Override + public String getLibraryName() { + return "JPushBullet"; + } + + public static boolean isValid() { + return valid; + } +}