mirror of
https://github.com/Phoenix616/RandomTeleport.git
synced 2024-11-22 10:36:00 +01:00
Add hooks for Worldguard 6 and 7
This commit is contained in:
parent
ff4106253b
commit
69686dd43f
@ -14,9 +14,14 @@
|
|||||||
<artifactId>randomteleport-plugin-hooks</artifactId>
|
<artifactId>randomteleport-plugin-hooks</artifactId>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
|
<modules>
|
||||||
|
<module>worldguard-6</module>
|
||||||
|
<module>worldguard-7</module>
|
||||||
|
</modules>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>${parent.groupId}</groupId>
|
<groupId>de.themoep.randomteleport</groupId>
|
||||||
<artifactId>randomteleport-hook</artifactId>
|
<artifactId>randomteleport-hook</artifactId>
|
||||||
<version>${version}</version>
|
<version>${version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
31
randomteleport-plugin-hooks/worldguard-6/pom.xml
Normal file
31
randomteleport-plugin-hooks/worldguard-6/pom.xml
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<parent>
|
||||||
|
<artifactId>randomteleport-plugin-hooks</artifactId>
|
||||||
|
<groupId>de.themoep.randomteleport.pluginhook</groupId>
|
||||||
|
<version>2.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<artifactId>worldguard-6</artifactId>
|
||||||
|
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>sk89q-repo</id>
|
||||||
|
<url>http://maven.sk89q.com/repo/</url>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.sk89q</groupId>
|
||||||
|
<artifactId>worldguard</artifactId>
|
||||||
|
<version>6.1.1-SNAPSHOT</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
</project>
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
}
|
31
randomteleport-plugin-hooks/worldguard-7/pom.xml
Normal file
31
randomteleport-plugin-hooks/worldguard-7/pom.xml
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<parent>
|
||||||
|
<artifactId>randomteleport-plugin-hooks</artifactId>
|
||||||
|
<groupId>de.themoep.randomteleport.pluginhook</groupId>
|
||||||
|
<version>2.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<artifactId>worldguard-7</artifactId>
|
||||||
|
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>sk89q-repo</id>
|
||||||
|
<url>http://maven.sk89q.com/repo/</url>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.sk89q.worldguard</groupId>
|
||||||
|
<artifactId>worldguard-legacy</artifactId>
|
||||||
|
<version>7.0.0-SNAPSHOT</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
</project>
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user