Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion AdvancedTeleport-Bukkit/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ repositories {
name = "PlayerParticles"
content { includeGroup("dev.esophose") }
}

maven("https://ci.ender.zone/plugin/repository/everything/") {
name = "FactionsUUID"
}
}

dependencies {
Expand Down Expand Up @@ -114,6 +118,7 @@ dependencies {
compileOnly(libs.hook.playerparticles)
compileOnly(libs.hook.worldguard)
compileOnly(libs.hook.squaremap)
compileOnly(libs.hook.factionsuuid)
compileOnly(libs.hook.dynmap) {
artifact { // Uses wrong jar if not specified
name = "dynmap-api"
Expand Down Expand Up @@ -246,7 +251,7 @@ bukkit {
main = "io.github.niestrat99.advancedteleport.CoreClass"
load = BukkitPluginDescription.PluginLoadOrder.POSTWORLD

softDepend = listOf("Vault", "Ultimate_Economy", "ConfigurationMaster", "WorldBorder", "ChunkyBorder", "floodgate", "Lands", "WorldGuard", "GriefProtection", "dynmap", "squaremap", "PlayerParticles")
softDepend = listOf("Vault", "Ultimate_Economy", "ConfigurationMaster", "WorldBorder", "ChunkyBorder", "floodgate", "Lands", "WorldGuard", "GriefProtection", "dynmap", "squaremap", "PlayerParticles", "Factions")
loadBefore = listOf("Essentials", "EssentialsSpawn")

commands {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import io.github.niestrat99.advancedteleport.config.CustomMessages;
import io.github.niestrat99.advancedteleport.config.MainConfig;

import io.github.niestrat99.advancedteleport.managers.PluginHookManager;
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;

import org.bukkit.OfflinePlayer;
Expand All @@ -32,6 +33,13 @@ public boolean onCommand(
final var player = (Player) sender;
final var atPlayer = ATPlayer.getPlayer(player);

// If the player can't set a home here, tell them
if (!PluginHookManager.get().canAccess(player, player.getLocation())
&& !player.hasPermission("at.admin.sethome.bypass.location")) {
CustomMessages.sendMessage(sender, "Error.cantSetHomeLoc");
return true;
}

// If no arguments have been specified, just use the information from that
if (args.length == 0) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import io.github.niestrat99.advancedteleport.config.CustomMessages;
import io.github.niestrat99.advancedteleport.config.MainConfig;

import io.github.niestrat99.advancedteleport.managers.PluginHookManager;
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;

import org.bukkit.Location;
Expand All @@ -30,6 +31,13 @@ public boolean onCommand(

Player player = (Player) sender;

// If the player can't set a home here, tell them
if (!PluginHookManager.get().canAccess(player, player.getLocation())
&& !player.hasPermission("at.admin.setwarp.bypass.location")) {
CustomMessages.sendMessage(sender, "Error.cantSetWarpLoc");
return true;
}

if (args.length == 0) {
ATPlayer atPlayer = ATPlayer.getPlayer(player);
if (atPlayer instanceof ATFloodgatePlayer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,11 +264,15 @@ If you prefer to use the Legacy Code format (i.e. &a, &b, etc.) then you can sti
addDefault(
"Error.homeAlreadySet",
"<prefix> <gray>You already have a home called <aqua><home></aqua>!");
addDefault("Error.cantSetHomeLoc",
"<prefix> <gray>You can't set a home here!");
addDefault("Error.noWarpInput", "<prefix> <gray>You have to include the warp's name!");
addDefault("Error.noSuchWarp", "<prefix> <gray>That warp doesn't exist!");
addDefault(
"Error.warpAlreadySet",
"<prefix> <gray>There is already a warp called <aqua><warp></aqua>!");
addDefault("Error.cantSetWarpLoc",
"<prefix> <gray>You can't set a warp here!");
addDefault("Error.noSuchWorld", "<prefix> <gray>That world doesn't exist!");
addDefault("Error.worldUnloaded",
"<prefix> <gray>Sorry, the destination world either doesn't exist or isn't loaded. Please tell a server admin!");
Expand All @@ -293,6 +297,9 @@ If you prefer to use the Legacy Code format (i.e. &a, &b, etc.) then you can sti
addDefault(
"Error.cantTPToWorldLim",
"<prefix> <gray>You can't teleport to <aqua><world></aqua>!");
addDefault(
"Error.cantTPToLoc",
"<prefix> <gray>You can't teleport to that location!");
addDefault("Error.tooFewArguments", "<prefix> <gray>Too few arguments!");
addDefault("Error.invalidArgs", "<prefix> <gray>Invalid arguments!");
addDefault("Error.noOthersToTP", "<prefix> <gray>There are no players for you to teleport!");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
Expand All @@ -27,4 +28,6 @@ public boolean canUse(@NotNull final World world) {
}

public abstract boolean isClaimed(@NotNull final Location location);

public abstract boolean canAccess(final @NotNull Player player, final @NotNull Location location);
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.github.niestrat99.advancedteleport.hooks;

import io.github.niestrat99.advancedteleport.CoreClass;
import org.bukkit.Bukkit;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.RegisteredServiceProvider;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package io.github.niestrat99.advancedteleport.hooks.claims;

import com.massivecraft.factions.*;
import com.massivecraft.factions.perms.Relation;
import io.github.niestrat99.advancedteleport.hooks.ClaimPlugin;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.jetbrains.annotations.NotNull;

public class FactionsUUIDClaimHook extends ClaimPlugin<Plugin, FactionsPlugin> {

public FactionsUUIDClaimHook() {
super("Factions", FactionsPlugin.class);
}

@Override
public boolean isClaimed(@NotNull Location location) {

// Check if there's a faction
final FLocation fLocation = new FLocation(location);
final Faction faction = Board.getInstance().getFactionAt(fLocation);
return faction != null;
}

@Override
public boolean canAccess(@NotNull Player player, @NotNull Location location) {

// Check if there's a faction
final FLocation fLocation = new FLocation(location);
final Faction faction = Board.getInstance().getFactionAt(fLocation);
if (faction == null) return true;
if (faction.isWilderness() || faction.isSafeZone() || faction.isWarZone()) return true;

// Check if the player has access
final FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player);
final Relation relation = faction.getRelationTo(fPlayer);

return relation.isMember() || relation.isAlly() || relation.isTruce();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

import io.github.niestrat99.advancedteleport.hooks.ClaimPlugin;

import me.ryanhamshire.GriefPrevention.ClaimPermission;
import me.ryanhamshire.GriefPrevention.GriefPrevention;

import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -38,4 +40,13 @@ public boolean canUse(@NotNull final World world) {
public boolean isClaimed(@NotNull final Location location) {
return griefPrevention.dataStore.getClaimAt(location, false, null) != null;
}

@Override
public boolean canAccess(@NotNull Player player, @NotNull Location location) {
final var claim = griefPrevention.dataStore.getClaimAt(location, false, null);
if (claim == null) return true;
final var result = claim.checkPermission(player, ClaimPermission.Access, null);
if (result == null) return true;
return result.get() == null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -42,4 +43,13 @@ public boolean isClaimed(@NotNull final Location location) {
Math.floorDiv(location.getBlockX(), 16),
Math.floorDiv(location.getBlockZ(), 16)) != null;
}

@Override
public boolean canAccess(@NotNull Player player, @NotNull Location location) {
final var chunk = location.getChunk();
final var land = lands.getLandByChunk(chunk.getWorld(), chunk.getX(), chunk.getZ());
if (land == null) return true;

return land.isTrusted(player.getUniqueId());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@

import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldguard.WorldGuard;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import com.sk89q.worldguard.protection.flags.Flags;
import com.sk89q.worldguard.protection.regions.RegionContainer;
import com.sk89q.worldguard.protection.regions.RegionQuery;

import io.github.niestrat99.advancedteleport.hooks.ClaimPlugin;

import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
Expand All @@ -35,14 +38,8 @@ public boolean canUse(@NotNull final World world) {
// Ensures claim avoidance is enabled
if (!super.canUse(world)) return false;

// Ensures the container is available in the world.
return this.provider()
.map(
provider -> {
container = provider.getPlatform().getRegionContainer();
return container.get(BukkitAdapter.adapt(world)) != null;
})
.orElse(false);
container = WorldGuard.getInstance().getPlatform().getRegionContainer();
return container.get(BukkitAdapter.adapt(world)) != null;
}

@Override
Expand All @@ -51,4 +48,10 @@ public boolean isClaimed(@NotNull final Location location) {
RegionQuery query = container.createQuery();
return query.getApplicableRegions(BukkitAdapter.adapt(location)).size() > 0;
}

@Override
public boolean canAccess(@NotNull Player player, @NotNull Location location) {
RegionQuery query = container.createQuery();
return query.testState(BukkitAdapter.adapt(location), WorldGuardPlugin.inst().wrapPlayer(player), Flags.ENTRY);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import io.github.niestrat99.advancedteleport.hooks.borders.ChunkyBorderHook;
import io.github.niestrat99.advancedteleport.hooks.borders.VanillaBorderHook;
import io.github.niestrat99.advancedteleport.hooks.borders.WorldBorderHook;
import io.github.niestrat99.advancedteleport.hooks.claims.FactionsUUIDClaimHook;
import io.github.niestrat99.advancedteleport.hooks.claims.GriefPreventionClaimHook;
import io.github.niestrat99.advancedteleport.hooks.claims.LandsClaimHook;
import io.github.niestrat99.advancedteleport.hooks.claims.WorldGuardClaimHook;
Expand All @@ -22,6 +23,7 @@

import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
Expand Down Expand Up @@ -61,6 +63,7 @@ public void init() {
loadPlugin("worldguard", WorldGuardClaimHook.class);
loadPlugin("lands", LandsClaimHook.class);
loadPlugin("griefprevention", GriefPreventionClaimHook.class);
loadPlugin("factionsuuid", FactionsUUIDClaimHook.class);

loadPlugin("squaremap", SquaremapHook.class);
loadPlugin("dynmap", DynmapHook.class);
Expand Down Expand Up @@ -156,6 +159,15 @@ public boolean isClaimed(@NotNull final Location location) {
});
}

@Contract(pure = true)
public boolean canAccess(final @NotNull Player player, final @NotNull Location location) {
return getPluginHooks(ClaimPlugin.class, true)
.filter(plugin -> plugin.canUse(location.getWorld()))
.filter(hook -> !hook.canAccess(player, location))
.toList()
.isEmpty();
}

@Contract(pure = true)
public boolean floodgateEnabled() {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import io.github.niestrat99.advancedteleport.config.MainConfig;
import io.github.niestrat99.advancedteleport.limitations.LimitationsManager;

import io.github.niestrat99.advancedteleport.managers.PluginHookManager;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Player;
Expand Down Expand Up @@ -76,6 +77,13 @@ public class ConditionChecker {
+ " using command "
+ command);

// Check if the player can teleport to that location if it's claimed
if (!teleportingPlayer.hasPermission("at.admin.bypass.claims")) {
if (MainConfig.get().MONITOR_ALL_TELEPORTS_LIMITS.get() || command != null) {
if (!PluginHookManager.get().canAccess(teleportingPlayer, toLoc)) return "Error.canTPToLoc";
}
}

// Check if the player is too far away
if (MainConfig.get().ENABLE_DISTANCE_LIMITATIONS.get()
&& !teleportingPlayer.hasPermission("at.admin.bypass.distance-limit")
Expand Down
3 changes: 3 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ hangar = "0.0.5"
slimjar = "1.6.1"
shadow = "7.1.2"
pluginYML = "0.6.0"
factionsuuid = "1.6.9.5-U0.6.40"

[libraries]
paperlib = { module = "io.papermc:paperlib", version.ref = "paperlib" }
Expand Down Expand Up @@ -53,6 +54,8 @@ hook-worldguard = { module = "com.sk89q.worldguard:worldguard-bukkit", version.r
hook-squaremap = { module = "xyz.jpenilla:squaremap-api", version.ref = "squaremap" }
hook-dynmap = { module = "us.dynmap:dynmap-api", version.ref = "dynmap" }
hook-slimjar = { module = "dev.racci.slimjar:slimjar", version.ref = "slimjar" }
hook-factionsuuid = { module = "com.massivecraft:Factions", version.ref = "factionsuuid" }


[plugins]
hangar = { id = "io.papermc.hangar-publish-plugin", version.ref = "hangar" }
Expand Down
Loading