Add FactionsUUID support to YardWatch Plugin

The YardWatch Plugin now supports FactionsUUID. The plugin's functionality has been implemented and added to the list of dependencies in the pom.xml file. Also, FactionsUUID has been included in the soft dependencies category in the plugin.yml file and in the options for bug reports.
This commit is contained in:
2024-03-22 15:05:28 +01:00
parent 35e17834e2
commit 7f9d40aafe
6 changed files with 104 additions and 4 deletions
+1
View File
@@ -9,6 +9,7 @@ body:
label: "Plugin name" label: "Plugin name"
multiple: false multiple: false
options: options:
- "FactionsUUID"
- "GriefPrevention" - "GriefPrevention"
- "WorldGuard" - "WorldGuard"
- "LWCX" - "LWCX"
+10
View File
@@ -72,6 +72,10 @@
<id>codemc-repo</id> <id>codemc-repo</id>
<url>https://repo.codemc.io/repository/maven-public/</url> <url>https://repo.codemc.io/repository/maven-public/</url>
</repository> </repository>
<repository>
<id>ender-zone</id>
<url>https://ci.ender.zone/plugin/repository/everything/</url>
</repository>
</repositories> </repositories>
<dependencies> <dependencies>
@@ -111,5 +115,11 @@
<version>2.2.9-dev</version> <version>2.2.9-dev</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency>
<groupId>com.massivecraft</groupId>
<artifactId>Factions</artifactId>
<version>1.6.9.5-U0.6.33</version>
<scope>provided</scope>
</dependency>
</dependencies> </dependencies>
</project> </project>
+1
View File
@@ -15,6 +15,7 @@ If you're a developer looking for information how to implement YardWatchAPI in y
- GriefPrevention (v16+) - GriefPrevention (v16+)
- WorldGuard (7.0.0+) - WorldGuard (7.0.0+)
- LWCX - LWCX
- FactionsUUID
## Plugin you're using is not implementing YardWatchAPI? ## Plugin you're using is not implementing YardWatchAPI?
Contact the plugin developer and send them [here](https://github.com/YouHaveTrouble/YardWatchAPI/blob/master/readme.md)! Contact the plugin developer and send them [here](https://github.com/YouHaveTrouble/YardWatchAPI/blob/master/readme.md)!
@@ -1,5 +1,6 @@
package me.youhavetrouble.yardwatch; package me.youhavetrouble.yardwatch;
import me.youhavetrouble.yardwatch.hooks.FactionsUUIDProtection;
import me.youhavetrouble.yardwatch.hooks.GriefPreventionProtection; import me.youhavetrouble.yardwatch.hooks.GriefPreventionProtection;
import me.youhavetrouble.yardwatch.hooks.LWCXProtection; import me.youhavetrouble.yardwatch.hooks.LWCXProtection;
import me.youhavetrouble.yardwatch.hooks.WorldGuardProtection; import me.youhavetrouble.yardwatch.hooks.WorldGuardProtection;
@@ -33,6 +34,12 @@ public final class YardWatch extends JavaPlugin {
); );
} }
if (shouldRegisterService("Factions")) {
getServer().getServicesManager().register(
Protection.class, new FactionsUUIDProtection(this), this, ServicePriority.Normal
);
}
} }
/** /**
@@ -0,0 +1,80 @@
package me.youhavetrouble.yardwatch.hooks;
import com.massivecraft.factions.Board;
import com.massivecraft.factions.FLocation;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.FactionsPlugin;
import com.massivecraft.factions.listeners.FactionsBlockListener;
import com.massivecraft.factions.listeners.FactionsEntityListener;
import com.massivecraft.factions.listeners.FactionsPlayerListener;
import com.massivecraft.factions.perms.PermissibleActions;
import me.youhavetrouble.yardwatch.Protection;
import me.youhavetrouble.yardwatch.YardWatch;
import org.bukkit.Location;
import org.bukkit.block.BlockState;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
public class FactionsUUIDProtection implements Protection {
private final YardWatch plugin;
public FactionsUUIDProtection(YardWatch plugin) {
this.plugin = plugin;
}
@Override
public boolean isEnabled() {
return plugin.getServer().getPluginManager().isPluginEnabled("Factions");
}
@Override
public boolean isProtected(Location location) {
if (!isEnabled()) return false;
if (!FactionsPlugin.getInstance().worldUtil().isEnabled(location.getWorld())) return false;
FLocation fLocation = new FLocation(location);
Faction faction = Board.getInstance().getFactionAt(fLocation);
return faction != null;
}
@Override
public boolean canBreakBlock(Player player, BlockState blockState) {
if (!isEnabled()) return true;
return FactionsBlockListener.playerCanBuildDestroyBlock(
player,
blockState.getLocation(),
PermissibleActions.DESTROY,
true
);
}
@Override
public boolean canPlaceBlock(Player player, Location location) {
if (!isEnabled()) return true;
return FactionsBlockListener.playerCanBuildDestroyBlock(
player,
location,
PermissibleActions.BUILD,
true
);
}
@Override
public boolean canInteract(Player player, BlockState blockState) {
if (!isEnabled()) return true;
return FactionsPlayerListener.canInteractHere(player, blockState.getLocation());
}
@Override
public boolean canInteract(Player player, Entity target) {
if (!isEnabled()) return true;
return FactionsEntityListener.canInteractHere(player, target.getLocation());
}
@Override
public boolean canDamage(Entity damager, Entity target) {
if (!isEnabled()) return true;
return FactionsEntityListener.canDamage(damager, target, false);
}
}
+5 -4
View File
@@ -3,11 +3,12 @@ version: '${project.version}'
main: me.youhavetrouble.yardwatch.YardWatch main: me.youhavetrouble.yardwatch.YardWatch
api-version: '1.16' api-version: '1.16'
folia-supported: true folia-supported: true
softdepend:
- "WorldGuard"
- "GriefPrevention"
- "Towny"
authors: authors:
- "YouHaveTrouble" - "YouHaveTrouble"
description: '${project.description}' description: '${project.description}'
website: '${project.url}' website: '${project.url}'
softdepend:
- "WorldGuard"
- "GriefPrevention"
- "Towny"
- "Factions"