Skip to content

Commit

Permalink
Make directors vulnerable to raycasts
Browse files Browse the repository at this point in the history
  • Loading branch information
TylerS1066 committed Jul 25, 2024
1 parent 3cbc191 commit 611ea0e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
2 changes: 2 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ repositories {
mavenCentral()
maven("https://repo.papermc.io/repository/maven-public/")
maven { githubPackage("apdevteam/movecraft")(this) }
maven { githubPackage("apdevteam/movecraft-combat")(this) }
maven { githubPackage("apdevteam/movecraft-worldguard")(this) }
maven("https://jitpack.io")
maven("https://maven.enginehub.org/repo/")
Expand All @@ -20,6 +21,7 @@ dependencies {
api("org.jetbrains:annotations-java5:24.1.0")
paperweight.paperDevBundle("1.18.2-R0.1-SNAPSHOT")
compileOnly("net.countercraft:movecraft:+")
compileOnly("net.countercraft.movecraft.combat:movecraft-combat:+")
compileOnly("net.countercraft.movecraft.worldguard:movecraft-worldguard:+")
compileOnly("com.sk89q.worldguard:worldguard-bukkit:7.0.7")
compileOnly("com.github.MilkBowl:VaultAPI:1.7.1")
Expand Down
23 changes: 19 additions & 4 deletions src/main/java/com/snowleopard1863/APTurrets/TurretManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
import com.sk89q.worldguard.protection.flags.Flags;
import com.snowleopard1863.APTurrets.config.Config;
import com.snowleopard1863.APTurrets.exception.ArrowLaunchException;
import net.countercraft.movecraft.combat.features.directors.Directors;
import net.countercraft.movecraft.craft.CraftManager;
import net.countercraft.movecraft.worldguard.MovecraftWorldGuard;
import net.countercraft.movecraft.worldguard.utils.WorldGuardUtils;
import net.countercraft.movecraft.worldguard.utils.WorldGuardUtils.State;

import net.minecraft.server.level.ServerLevel;
Expand Down Expand Up @@ -37,12 +39,13 @@
import org.jetbrains.annotations.Nullable;

import java.util.HashSet;
import java.util.Set;

import static com.snowleopard1863.APTurrets.TurretsMain.PREFIX;

public class TurretManager {
private final HashSet<Player> onTurrets = new HashSet<>();
private final HashSet<Player> reloading = new HashSet<>();
private final Set<Player> onTurrets = new HashSet<>();
private final Set<Player> reloading = new HashSet<>();

public void disable() {
for (Player p : onTurrets) {
Expand Down Expand Up @@ -205,8 +208,20 @@ private boolean runRaycast(@NotNull Player shooter) {
continue;

// Check for WG PVP flag
if (MovecraftWorldGuard.getInstance().getWGUtils().getState(null, p.getLocation(), Flags.PVP) == State.DENY)
continue;
WorldGuardUtils wgUtils = MovecraftWorldGuard.getInstance().getWGUtils();
if (wgUtils.getState(null, p.getLocation(), Flags.PVP) == State.DENY) {
// PVP flag is denied, check if they are a member, if so, exit
Set<String> regionNames = wgUtils.getRegions(p.getLocation());
boolean isMember = regionNames.stream().map(regionName -> wgUtils.isMember(regionName, p.getLocation().getWorld(), p)).reduce(Boolean.FALSE, Boolean::logicalOr);
if (isMember)
continue;

// Player is not a member, time to check if they are a director
if(!Directors.isAnyDirector(p))
continue;

// Player is a director, let them be hit!
}

// Check for block directly between
Block targetBlock = shooter.getTargetBlock(null, Config.RaycastRange);
Expand Down

0 comments on commit 611ea0e

Please sign in to comment.