Add support for GriefPrevention Protection

Refactored the YardWatch.java file to check if the GriefPrevention plugin is enabled. If enabled, GriefPrevention Protection is registered. Additionally, a new class GriefPreventionProtection.java was added which checks if a location is protected, if a player can break/place a block, interact with a block or entity, or damage an entity based on GriefPrevention's claims. Moreover, added a new dependency for GriefPrevention in pom.xml.
This commit is contained in:
2024-03-21 23:25:48 +01:00
parent 137ef21410
commit 7405f15510
3 changed files with 84 additions and 6 deletions
@@ -1,6 +1,8 @@
package me.youhavetrouble.yardwatch;
import me.youhavetrouble.yardwatch.hooks.GriefPreventionProtection;
import me.youhavetrouble.yardwatch.hooks.WorldGuardProtection;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.ServicePriority;
import org.bukkit.plugin.java.JavaPlugin;
@@ -8,13 +10,19 @@ public final class YardWatch extends JavaPlugin {
@Override
public void onEnable() {
PluginManager pluginManager = getServer().getPluginManager();
if (getServer().getPluginManager().isPluginEnabled("WorldGuard")) {
getServer().getServicesManager().register(
Protection.class, new WorldGuardProtection(this), this, ServicePriority.Normal
);
}
if (pluginManager.isPluginEnabled("WorldGuard")) {
getServer().getServicesManager().register(
Protection.class, new WorldGuardProtection(this), this, ServicePriority.Normal
);
}
if (pluginManager.isPluginEnabled("GriefPrevention")) {
getServer().getServicesManager().register(
Protection.class, new GriefPreventionProtection(this), this, ServicePriority.Normal
);
}
}
}