From f0ed0105d1ba1907ba8fb1b6e8844e805e05fd4b Mon Sep 17 00:00:00 2001 From: Phoenix616 Date: Wed, 23 Jan 2019 00:19:08 +0100 Subject: [PATCH] Add hook for WorldBorder plugin --- randomteleport-plugin-hooks/pom.xml | 1 + .../worldborder/pom.xml | 31 ++++++++++ .../hook/plugin/WorldBorderHook.java | 56 +++++++++++++++++++ 3 files changed, 88 insertions(+) create mode 100644 randomteleport-plugin-hooks/worldborder/pom.xml create mode 100644 randomteleport-plugin-hooks/worldborder/src/main/java/de/themoep/randomteleport/hook/plugin/WorldBorderHook.java diff --git a/randomteleport-plugin-hooks/pom.xml b/randomteleport-plugin-hooks/pom.xml index 8802dc2..22da68f 100644 --- a/randomteleport-plugin-hooks/pom.xml +++ b/randomteleport-plugin-hooks/pom.xml @@ -17,6 +17,7 @@ worldguard-6 worldguard-7 + worldborder diff --git a/randomteleport-plugin-hooks/worldborder/pom.xml b/randomteleport-plugin-hooks/worldborder/pom.xml new file mode 100644 index 0000000..3fc2077 --- /dev/null +++ b/randomteleport-plugin-hooks/worldborder/pom.xml @@ -0,0 +1,31 @@ + + + + 4.0.0 + + randomteleport-plugin-hooks + de.themoep.randomteleport.pluginhook + 2.0-SNAPSHOT + + + worldborder + + + + jitpack.io + https://jitpack.io + + + + + + com.github.Brettflan + WorldBorder + master-c5df3417c8-1 + provided + + + + \ No newline at end of file diff --git a/randomteleport-plugin-hooks/worldborder/src/main/java/de/themoep/randomteleport/hook/plugin/WorldBorderHook.java b/randomteleport-plugin-hooks/worldborder/src/main/java/de/themoep/randomteleport/hook/plugin/WorldBorderHook.java new file mode 100644 index 0000000..8c1111c --- /dev/null +++ b/randomteleport-plugin-hooks/worldborder/src/main/java/de/themoep/randomteleport/hook/plugin/WorldBorderHook.java @@ -0,0 +1,56 @@ +package de.themoep.randomteleport.hook.plugin; + +/* + * RandomTeleport - worldborder - $project.description + * Copyright (c) 2019 Max Lee aka Phoenix616 (mail@moep.tv) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +import com.wimbli.WorldBorder.BorderData; +import com.wimbli.WorldBorder.WorldBorder; +import de.themoep.randomteleport.hook.WorldborderHook; +import org.bukkit.Location; +import org.bukkit.World; +import org.bukkit.plugin.Plugin; + +public class WorldBorderHook implements WorldborderHook { + private final WorldBorder plugin; + + public WorldBorderHook() { + plugin = WorldBorder.plugin; + } + + @Override + public Location getCenter(World world) { + BorderData data = plugin.getWorldBorder(world.getName()); + return data == null ? null : new Location(world, data.getX(), 0, data.getZ()); + } + + @Override + public double getBorderRadius(World world) { + BorderData data = plugin.getWorldBorder(world.getName()); + return data == null ? -1 : Math.min(data.getRadiusX(), data.getRadiusZ()); + } + + @Override + public Plugin getPlugin() { + return plugin; + } + + @Override + public String getPluginName() { + return plugin.getName(); + } +}