Skip to content

Commit

Permalink
Fixed players riding another player being kicked off if they are bann…
Browse files Browse the repository at this point in the history
…ed from a claim.
  • Loading branch information
Baktus79 committed Feb 15, 2024
1 parent c41b13f commit 3cf7123
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
import no.vestlandetmc.BanFromClaim.config.ClaimData;
import no.vestlandetmc.BanFromClaim.config.Config;
import no.vestlandetmc.BanFromClaim.config.Messages;
import no.vestlandetmc.BanFromClaim.handler.LocationFinder;
import no.vestlandetmc.BanFromClaim.handler.MessageHandler;
import no.vestlandetmc.BanFromClaim.handler.ParticleHandler;
import no.vestlandetmc.BanFromClaim.utils.LocationFinder;
import no.vestlandetmc.BanFromClaim.utils.PlayerRidePlayer;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
Expand Down Expand Up @@ -44,17 +45,22 @@ public void onPlayerEnterClaim(PlayerMoveEvent e) {
final ParticleHandler ph = new ParticleHandler(e.getTo());

if (locFrom.getBlockX() != locTo.getBlockX() || locFrom.getBlockZ() != locTo.getBlockZ()) {
if (player.hasPermission("bfc.bypass") || player.getGameMode().equals(GameMode.SPECTATOR)) {
return;
}

if (!claimTo.isWilderness()) {
final UUID ownerUUID = claimTo.getOwnerUniqueId();
final Player target = PlayerRidePlayer.getPassenger(player);
boolean hasAttacked = false;

if (target != null && (claimData.isAllBanned(claimTo.getUniqueId().toString()) || playerBanned(target, claimTo) || playerBanned(player, claimTo))) {
target.teleport(player.getLocation().add(0, 4, 0));
}

if (CombatMode.attackerContains(player.getUniqueId()))
hasAttacked = CombatMode.getAttacker(player.getUniqueId()).equals(ownerUUID);

if (player.hasPermission("bfc.bypass") || player.getGameMode().equals(GameMode.SPECTATOR)) {
return;
}

if ((claimData.isAllBanned(claimTo.getUniqueId().toString()) || playerBanned(player, claimTo)) && !hasAttacked && !hasTrust(player.getUniqueId(), claimTo)) {
if (!claimFrom.isWilderness()) {
if (playerBanned(player, claimFrom)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
import no.vestlandetmc.BanFromClaim.config.ClaimData;
import no.vestlandetmc.BanFromClaim.config.Config;
import no.vestlandetmc.BanFromClaim.config.Messages;
import no.vestlandetmc.BanFromClaim.handler.LocationFinder;
import no.vestlandetmc.BanFromClaim.handler.MessageHandler;
import no.vestlandetmc.BanFromClaim.handler.ParticleHandler;
import no.vestlandetmc.BanFromClaim.utils.LocationFinder;
import no.vestlandetmc.BanFromClaim.utils.PlayerRidePlayer;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
Expand Down Expand Up @@ -36,18 +37,23 @@ public void onPlayerEnterClaim(PlayerMoveEvent e) {
final Claim claim = GriefPrevention.instance.dataStore.getClaimAt(locTo, true, null);
final ParticleHandler ph = new ParticleHandler(e.getTo());

if (player.hasPermission("bfc.bypass") || player.getGameMode().equals(GameMode.SPECTATOR)) {
return;
}

if (claim != null) {
final UUID ownerUUID = claim.ownerID;
final String claimID = claim.getID().toString();
final Player target = PlayerRidePlayer.getPassenger(player);
boolean hasAttacked = false;

if (target != null && (claimData.isAllBanned(claimID) || playerBanned(target, claimID) || playerBanned(player, claimID))) {
target.teleport(player.getLocation().add(0, 4, 0));
}

if (CombatMode.attackerContains(player.getUniqueId()))
hasAttacked = CombatMode.getAttacker(player.getUniqueId()).equals(ownerUUID);

if (player.hasPermission("bfc.bypass") || player.getGameMode().equals(GameMode.SPECTATOR)) {
return;
}

if ((claimData.isAllBanned(claimID) || playerBanned(player, claimID)) && !hasAttacked && !hasTrust(player, claim)) {
if (claim.contains(locFrom, true, false)) {
if (playerBanned(player, claimID) || claimData.isAllBanned(claimID)) {
Expand Down

0 comments on commit 3cf7123

Please sign in to comment.