diff --git a/randomteleport-plugin-hooks/pom.xml b/randomteleport-plugin-hooks/pom.xml index 83279bf..8802dc2 100644 --- a/randomteleport-plugin-hooks/pom.xml +++ b/randomteleport-plugin-hooks/pom.xml @@ -14,9 +14,14 @@ randomteleport-plugin-hooks pom + + worldguard-6 + worldguard-7 + + - ${parent.groupId} + de.themoep.randomteleport randomteleport-hook ${version} diff --git a/randomteleport-plugin-hooks/worldguard-6/pom.xml b/randomteleport-plugin-hooks/worldguard-6/pom.xml new file mode 100644 index 0000000..df6efea --- /dev/null +++ b/randomteleport-plugin-hooks/worldguard-6/pom.xml @@ -0,0 +1,31 @@ + + + + + randomteleport-plugin-hooks + de.themoep.randomteleport.pluginhook + 2.0-SNAPSHOT + + 4.0.0 + + worldguard-6 + + + + sk89q-repo + http://maven.sk89q.com/repo/ + + + + + + com.sk89q + worldguard + 6.1.1-SNAPSHOT + provided + + + + \ No newline at end of file diff --git a/randomteleport-plugin-hooks/worldguard-6/src/main/java/de/themoep/randomteleport/hook/plugin/WorldGuard6Hook.java b/randomteleport-plugin-hooks/worldguard-6/src/main/java/de/themoep/randomteleport/hook/plugin/WorldGuard6Hook.java new file mode 100644 index 0000000..85df5c7 --- /dev/null +++ b/randomteleport-plugin-hooks/worldguard-6/src/main/java/de/themoep/randomteleport/hook/plugin/WorldGuard6Hook.java @@ -0,0 +1,55 @@ +package de.themoep.randomteleport.hook.plugin; + +/* + * RandomTeleport - worldguard-6 - $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.sk89q.worldguard.bukkit.WorldGuardPlugin; +import de.themoep.randomteleport.hook.ProtectionHook; +import org.bukkit.Location; +import org.bukkit.World; +import org.bukkit.entity.Player; +import org.bukkit.plugin.Plugin; + +public class WorldGuard6Hook implements ProtectionHook { + + private final WorldGuardPlugin inst; + + public WorldGuard6Hook() { + inst = WorldGuardPlugin.inst(); + } + + @Override + public Plugin getPlugin() { + return inst; + } + + @Override + public String getPluginName() { + return inst.getName(); + } + + @Override + public boolean canBuild(Player player, Location location) { + return inst.canBuild(player, location); + } + + @Override + public boolean canBuild(Player player, World world, int chunkX, int chunkZ) { + return canBuild(player, new Location(world, (double) chunkX * 16 + 8, world.getSeaLevel(), (double) chunkZ * 16 + 8)); + } +} diff --git a/randomteleport-plugin-hooks/worldguard-7/pom.xml b/randomteleport-plugin-hooks/worldguard-7/pom.xml new file mode 100644 index 0000000..ee13edc --- /dev/null +++ b/randomteleport-plugin-hooks/worldguard-7/pom.xml @@ -0,0 +1,31 @@ + + + + + randomteleport-plugin-hooks + de.themoep.randomteleport.pluginhook + 2.0-SNAPSHOT + + 4.0.0 + + worldguard-7 + + + + sk89q-repo + http://maven.sk89q.com/repo/ + + + + + + com.sk89q.worldguard + worldguard-legacy + 7.0.0-SNAPSHOT + provided + + + + \ No newline at end of file diff --git a/randomteleport-plugin-hooks/worldguard-7/src/main/java/de/themoep/randomteleport/hook/plugin/WorldGuard7Hook.java b/randomteleport-plugin-hooks/worldguard-7/src/main/java/de/themoep/randomteleport/hook/plugin/WorldGuard7Hook.java new file mode 100644 index 0000000..2ac7c6a --- /dev/null +++ b/randomteleport-plugin-hooks/worldguard-7/src/main/java/de/themoep/randomteleport/hook/plugin/WorldGuard7Hook.java @@ -0,0 +1,65 @@ +package de.themoep.randomteleport.hook.plugin; + +/* + * RandomTeleport - worldguard-7 - $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.sk89q.worldedit.bukkit.BukkitAdapter; +import com.sk89q.worldedit.util.Location; +import com.sk89q.worldguard.LocalPlayer; +import com.sk89q.worldguard.WorldGuard; +import com.sk89q.worldguard.bukkit.WorldGuardPlugin; +import com.sk89q.worldguard.protection.flags.Flags; +import de.themoep.randomteleport.hook.ProtectionHook; +import org.bukkit.World; +import org.bukkit.entity.Player; +import org.bukkit.plugin.Plugin; + +public class WorldGuard7Hook implements ProtectionHook { + + private final WorldGuardPlugin inst; + + public WorldGuard7Hook() { + inst = WorldGuardPlugin.inst(); + } + + @Override + public Plugin getPlugin() { + return inst; + } + + @Override + public String getPluginName() { + return inst.getName(); + } + + @Override + public boolean canBuild(Player player, org.bukkit.Location location) { + return canBuild(WorldGuardPlugin.inst().wrapPlayer(player), BukkitAdapter.adapt(location)); + } + + @Override + public boolean canBuild(Player player, World world, int chunkX, int chunkZ) { + return canBuild(WorldGuardPlugin.inst().wrapPlayer(player), new Location( + BukkitAdapter.adapt(world), (double) chunkX * 16 + 8, world.getSeaLevel(), (double) chunkZ * 16 + 8) + ); + } + + private boolean canBuild(LocalPlayer player, Location location) { + return WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery().testBuild(location, player, Flags.BUILD); + } +}