From 0fe1fe33cc94fd6d3b671e9b790a92280701454c Mon Sep 17 00:00:00 2001 From: Matthew Miller Date: Fri, 12 Oct 2018 16:09:52 +1000 Subject: [PATCH] Replace BukkitImplementationTester with paperLib --- worldedit-bukkit/build.gradle | 5 + .../bukkit/BukkitImplementationTester.java | 91 ------------------- .../worldedit/bukkit/WorldEditPlugin.java | 3 - 3 files changed, 5 insertions(+), 94 deletions(-) delete mode 100644 worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitImplementationTester.java diff --git a/worldedit-bukkit/build.gradle b/worldedit-bukkit/build.gradle index 3fbad53e5..f833afb19 100644 --- a/worldedit-bukkit/build.gradle +++ b/worldedit-bukkit/build.gradle @@ -5,6 +5,7 @@ apply plugin: 'maven' repositories { maven { url "https://hub.spigotmc.org/nexus/content/groups/public" } maven { url "https://jitpack.io" } + maven { url 'https://papermc.io/repo/repository/maven-public/' } } dependencies { @@ -12,6 +13,7 @@ dependencies { compile 'com.sk89q:dummypermscompat:1.8' compile 'org.bukkit:bukkit:1.13-R0.1-SNAPSHOT' // zzz compile 'org.bstats.bStats-Metrics:bstats-bukkit:1.3' + compile "io.papermc:paperlib:1.0.1" testCompile 'org.mockito:mockito-core:1.9.0-rc1' } @@ -39,6 +41,9 @@ shadowJar { relocate ("org.bstats", "com.sk89q.worldedit.bukkit.bstats") { include(dependency("org.bstats.bStats-Metrics:bstats-bukkit:1.3")) } + relocate ("io.papermc.lib", "com.sk89q.worldedit.bukkit.paperlib") { + include(dependency("io.papermc:paperlib:1.0.1")) + } } } diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitImplementationTester.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitImplementationTester.java deleted file mode 100644 index 1345f6a81..000000000 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitImplementationTester.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * WorldEdit, a Minecraft world manipulation toolkit - * Copyright (C) sk89q - * Copyright (C) WorldEdit team and contributors - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the - * Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . - */ - -package com.sk89q.worldedit.bukkit; - -/** - * Adds methods to test if different API methods are possible based on implementation. - */ -public class BukkitImplementationTester { - - private BukkitImplementationTester() { - } - - /** - * Known Bukkit implementations - */ - public enum BukkitImplementation { - CRAFTBUKKIT, - SPIGOT, - PAPER, - } - - private static final String implementationMessage = "************************************************" + - "* Note: PaperMC (https://papermc.io/) is *" + - "* recommended for optimal performance with *" + - "* WorldEdit, WorldGuard, or CraftBook. *" + - "************************************************"; - - private static BukkitImplementation implementation; - - /** - * Gets the implementation currently in use on the server. - * - * @return The server implementation - */ - public static BukkitImplementation getImplementation() { - if (implementation == null) { - try { - Class.forName("com.destroystokyo.paper.PaperConfig"); - implementation = BukkitImplementation.PAPER; - } catch (Exception e) { - try { - Class.forName("org.spigotmc.SpigotConfig"); - implementation = BukkitImplementation.SPIGOT; - } catch (Exception e2) { - implementation = BukkitImplementation.CRAFTBUKKIT; - } - } - - if (implementation != BukkitImplementation.PAPER) { -// Bukkit.getServer().getConsoleSender().sendMessage(implementationMessage); // TODO Decide if good idea. - } - } - - return implementation; - } - - /** - * Check if this implementation is compatible with Spigot APIs - * - * @return If compatible with Spigot APIs - */ - public static boolean isSpigotCompatible() { - return getImplementation() == BukkitImplementation.SPIGOT || getImplementation() == BukkitImplementation.PAPER; - } - - /** - * Check if this implementation is compatible with Paper APIs - * - * @return If compatible with Paper APIs - */ - public static boolean isPaperCompatible() { - return getImplementation() == BukkitImplementation.PAPER; - } -} diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java index 8cc6f544b..c4b017e83 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java @@ -104,9 +104,6 @@ public class WorldEditPlugin extends JavaPlugin implements TabCompleter { // platforms to be worried about... at the current time of writing WorldEdit.getInstance().getEventBus().post(new PlatformReadyEvent()); - // Setup the BukkitImplementationTester. - BukkitImplementationTester.getImplementation(); - // Enable metrics new Metrics(this); }