From b1242021759191b94fbd9355b4c1e532f2bbefcf Mon Sep 17 00:00:00 2001 From: Etzelia Date: Thu, 27 Sep 2018 00:02:49 -0500 Subject: [PATCH] Version 1.3 Updated EtzCore to 1.2 Added Maven annotations Cleaned up shaded jar (less than half the size) --- pom.xml | 47 ++++--------------- src/main/java/xyz/etztech/qol/QoL.java | 37 +++++++-------- .../listeners/CommandPreprocessListener.java | 2 +- .../xyz/etztech/qol/other/TPSRunnable.java | 2 +- 4 files changed, 28 insertions(+), 60 deletions(-) diff --git a/pom.xml b/pom.xml index 911ef55..592f269 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ xyz.etztech QoL - 1.2 + 1.3 jar @@ -12,31 +12,6 @@ A compilation plugin of various utilities. http://www.etztech.xyz - - - Zlib License - http://opensource.org/licenses/Zlib - Copyright (c) 2017 EtzTech - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - - 3. This notice may not be removed or altered from any source - distribution. - - @@ -57,31 +32,37 @@ org.spigotmc spigot-api 1.13.1-R0.1-SNAPSHOT + provided xyz.etztech EtzCore - 1.0 + 1.2 + compile net.ess3 Essentials 2.14-SNAPSHOT + provided us.dynmap dynmap-api 1.9.4 + provided commons-lang commons-lang 2.6 + provided org.apache.httpcomponents httpclient 4.5.5 + provided @@ -145,8 +126,8 @@ maven-compiler-plugin 3.1 - 1.7 - 1.7 + 8 + 8 @@ -177,14 +158,6 @@ - - org.apache.maven.plugins - maven-compiler-plugin - - 8 - 8 - - \ No newline at end of file diff --git a/src/main/java/xyz/etztech/qol/QoL.java b/src/main/java/xyz/etztech/qol/QoL.java index 73189a2..3b4cd21 100644 --- a/src/main/java/xyz/etztech/qol/QoL.java +++ b/src/main/java/xyz/etztech/qol/QoL.java @@ -1,28 +1,29 @@ package xyz.etztech.qol; -import com.earth2me.essentials.Essentials; -import net.ess3.api.IEssentials; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; -import org.bukkit.plugin.java.JavaPlugin; +import xyz.etztech.core.maven.MavenLibrary; +import xyz.etztech.core.maven.MavenPlugin; import xyz.etztech.qol.commands.*; import xyz.etztech.qol.listeners.*; import xyz.etztech.qol.other.LinkCommand; import xyz.etztech.qol.other.TPSRunnable; -import org.dynmap.DynmapAPI; import java.util.ArrayList; import java.util.List; -import java.util.UUID; import java.util.logging.Logger; -public class QoL extends JavaPlugin { +@MavenLibrary(group = "org.apache.httpcomponents", artifact = "httpclient", version = "4.5.5") +@MavenLibrary(group = "net.ess3", artifact = "Essentials", version = "2.13.1", repository = "http://repo.ess3.net/content/groups/essentials") +@MavenLibrary(group = "us.dynmap", artifact = "dynmap-api", version = "1.9.4", repository = "http://repo.mikeprimm.com/") +@MavenLibrary(group = "commons-lang", artifact = "commons-lang", version = "2.6") +public class QoL extends MavenPlugin { private static QoL instance; - private static IEssentials essentials = null; - private static DynmapAPI dynmap = null; + private Object essentials = null; + private Object dynmap = null; public static FileConfiguration config; private Logger log = Logger.getLogger( "Minecraft" ); @@ -34,7 +35,7 @@ public class QoL extends JavaPlugin { private static List links = new ArrayList<>(); @Override - public void onEnable() { + public void enable() { instance = this; saveDefaultConfig(); reloadConfig(); @@ -43,13 +44,13 @@ public class QoL extends JavaPlugin { //Essentials hook if (Bukkit.getPluginManager().isPluginEnabled("Essentials")) { log("Hooked into Essentials for TPS alert."); - essentials = (Essentials) Bukkit.getPluginManager().getPlugin("Essentials"); + essentials = Bukkit.getPluginManager().getPlugin("Essentials"); } //Dynmap hook if (Bukkit.getPluginManager().isPluginEnabled("dynmap")) { log("Hooked into Dynmap."); - dynmap = (DynmapAPI) Bukkit.getPluginManager().getPlugin("dynmap"); + dynmap = Bukkit.getPluginManager().getPlugin("dynmap"); } if( isEnabled() ) { @@ -188,9 +189,8 @@ public class QoL extends JavaPlugin { } } - @Override - public void onDisable() { + public void disable() { } public void disablePlugin() { @@ -251,18 +251,13 @@ public class QoL extends JavaPlugin { return links; } - public static IEssentials getEssentials() { return essentials; } + public Object getEssentials() { return essentials; } - public static DynmapAPI getDynmap() { return dynmap; } + public Object getDynmap() { return dynmap; } private void runTask(final String command) { - Bukkit.getScheduler().runTask(QoL.instance, new Runnable() { - @Override - public void run() { - Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command); - } - }); + Bukkit.getScheduler().runTask(QoL.instance, () -> Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command)); } diff --git a/src/main/java/xyz/etztech/qol/listeners/CommandPreprocessListener.java b/src/main/java/xyz/etztech/qol/listeners/CommandPreprocessListener.java index f5b2fca..798055b 100644 --- a/src/main/java/xyz/etztech/qol/listeners/CommandPreprocessListener.java +++ b/src/main/java/xyz/etztech/qol/listeners/CommandPreprocessListener.java @@ -37,7 +37,7 @@ public class CommandPreprocessListener implements Listener { String base = command.split(" ")[0].substring(1).toLowerCase(); // Strip the slash Player sender = event.getPlayer(); - DynmapAPI dynmap = plugin.getDynmap(); + DynmapAPI dynmap = (DynmapAPI) plugin.getDynmap(); // Spec dynmap hide if (base.equals("spec") && sender.hasPermission("SafeSpectate.spectate") && dynmap != null) { diff --git a/src/main/java/xyz/etztech/qol/other/TPSRunnable.java b/src/main/java/xyz/etztech/qol/other/TPSRunnable.java index 0d1c130..18be712 100644 --- a/src/main/java/xyz/etztech/qol/other/TPSRunnable.java +++ b/src/main/java/xyz/etztech/qol/other/TPSRunnable.java @@ -18,7 +18,7 @@ public class TPSRunnable implements Runnable { @Override public void run() { - IEssentials essentials = QoL.getEssentials(); + IEssentials essentials = (IEssentials) plugin.getEssentials(); if (essentials != null) { double tps = essentials.getTimer().getAverageTPS(); int threshold = plugin.getConfig().getInt("tps.threshold", 0);