Add RedProtect hook (Resolves #14)

This commit is contained in:
Phoenix616 2019-10-06 17:09:44 +01:00
parent b172ff83f0
commit 1c15f42a09
3 changed files with 100 additions and 0 deletions

View File

@ -18,6 +18,7 @@
<module>worldguard-6</module>
<module>worldguard-7</module>
<module>griefprevention</module>
<module>redprotect</module>
<module>worldborder</module>
</modules>

View File

@ -0,0 +1,37 @@
<?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>redprotect</artifactId>
<repositories>
<repository>
<id>redprotect-repo</id>
<url>https://raw.githubusercontent.com/FabioZumbi12/RedProtect/mvn-repo/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>br.net.fabiozumbi12.RedProtect</groupId>
<artifactId>RedProtect-Spigot</artifactId>
<version>7.6.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>1.13-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,62 @@
package de.themoep.randomteleport.hook.plugin;
/*
* RandomTeleport - RedProtect Hook
* 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 br.net.fabiozumbi12.RedProtect.Bukkit.RedProtect;
import br.net.fabiozumbi12.RedProtect.Bukkit.Region;
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 RedProtectHook implements ProtectionHook {
private final RedProtect inst;
public RedProtectHook() {
inst = RedProtect.get();
}
@Override
public Plugin getPlugin() {
return inst;
}
@Override
public String getPluginName() {
return inst.getName();
}
@Override
public boolean canBuild(Player player, Location location) {
Region region = inst.getAPI().getRegion(location);
return region == null || region.canBuild(player);
}
@Override
public boolean canBuild(Player player, World world, int chunkX, int chunkZ) {
for (Region region : inst.getAPI().getChunkRegions(world.getChunkAt(chunkX, chunkZ))) {
if (!region.canBuild(player)) {
return false;
}
}
return true;
}
}