Implements Hooks for GriefDefender & ChunkyBorder. (#49)

* Added griefdefender support

* Added info command

* Fixed info command not executing

oops

* Implemented hook for chunkyborder

* Removed --info command

You can get this info in the logs.

* Update plugin.yml

* Added missing GriefDefender hook artifact
This commit is contained in:
Omer Oreg 2022-05-22 02:23:34 +03:00 committed by GitHub
parent 4a77bf1519
commit 61c32c5995
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 181 additions and 3 deletions

View File

@ -40,7 +40,7 @@
</repository>
<repository>
<id>paper-repo</id>
<url>https://papermc.io/repo/content/groups/public</url>
<url>https://papermc.io/repo/repository/maven-public/</url>
</repository>
<repository>
<id>minebench-repo</id>
@ -58,7 +58,7 @@
<dependency>
<groupId>io.papermc</groupId>
<artifactId>paperlib</artifactId>
<version>1.0.2</version>
<version>1.0.6</version>
<scope>compile</scope>
</dependency>
<dependency>

View File

@ -0,0 +1,44 @@
<?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>chunkyborder</artifactId>
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
<repository>
<id>codemc</id>
<url>https://repo.codemc.io/repository/maven-public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.popcraft</groupId>
<artifactId>chunkyborder</artifactId>
<version>1.0.43</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.popcraft</groupId>
<artifactId>chunky-bukkit</artifactId>
<version>1.2.93</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,45 @@
package de.themoep.randomteleport.hook.plugin;
import de.themoep.randomteleport.hook.WorldborderHook;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.plugin.Plugin;
import org.popcraft.chunkyborder.BorderData;
import org.popcraft.chunkyborder.ChunkyBorder;
public class ChunkyBorderHook implements WorldborderHook {
private final ChunkyBorder plugin;
public ChunkyBorderHook() {
this.plugin = (ChunkyBorder) Bukkit.getPluginManager().getPlugin("ChunkyBorder");
}
@Override
public Plugin getPlugin() {
return this.plugin;
}
@Override
public Location getCenter(World world) {
BorderData borderData = plugin.getBorders().get(world.getName());
return new Location(world, borderData.getCenterX(),0D,borderData.getCenterZ());
}
@Override
public double getBorderRadius(World world) {
BorderData borderData = plugin.getBorders().get(world.getName());
return borderData.getRadiusX();
}
@Override
public boolean isInsideBorder(Location location) {
BorderData borderData = plugin.getBorders().get(location.getWorld().getName());
return borderData.getBorder().isBounding(location.getBlockX(),location.getBlockZ());
}
@Override
public String getPluginName() {
return plugin.getName();
}
}

View File

@ -0,0 +1,39 @@
<?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>griefdefender</artifactId>
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.github.bloodmc</groupId>
<artifactId>GriefDefenderAPI</artifactId>
<version>-dd5aa2224c-1</version>
<exclusions>
<exclusion>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
</exclusion>
</exclusions>
</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,36 @@
package de.themoep.randomteleport.hook.plugin;
import com.griefdefender.api.GriefDefender;
import com.griefdefender.api.claim.ClaimTypes;
import de.themoep.randomteleport.hook.ProtectionHook;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
public class GriefDefenderHook implements ProtectionHook {
@Override
public Plugin getPlugin() {
return Bukkit.getPluginManager().getPlugin("GriefDefender");
}
@Override
public String getPluginName() {
return "GriefDefender";
}
@Override
public boolean canBuild(Player player, Location location) {
return GriefDefender.getCore().getClaimManager(location.getWorld().getUID()).getClaimAt(location.getBlockX(), location.getBlockY(), location.getBlockZ()).getType() == ClaimTypes.WILDERNESS;
}
@Override
public boolean canBuild(Player player, World world, int chunkX, int chunkZ) {
if(GriefDefender.getCore().isEnabled(world.getUID())) {
return GriefDefender.getCore().getClaimManager(world.getUID()).getClaimAt(chunkX,0,chunkZ).isTrusted(player.getUniqueId());
}
return true;
}
}

View File

@ -18,10 +18,12 @@
<module>worldguard-6</module>
<module>worldguard-7</module>
<module>griefprevention</module>
<module>griefdefender</module>
<module>redprotect</module>
<module>factions</module>
<module>factions-uuid</module>
<module>worldborder</module>
<module>chunkyborder</module>
</modules>
<dependencies>

View File

@ -42,6 +42,18 @@
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>${project.groupId}.pluginhook</groupId>
<artifactId>chunkyborder</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>${project.groupId}.pluginhook</groupId>
<artifactId>griefdefender</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>

View File

@ -57,7 +57,7 @@ public class RandomTeleportCommand implements CommandExecutor {
}
} else {
try {
if (sender.hasPermission("randomteleport.manual")){
if (sender.hasPermission("randomteleport.manual")) {
plugin.parseAndRun(sender, getLocation(sender), args);
return true;
} else {