Do not allow to claim near admin claims
This commit is contained in:
parent
e2dccaad95
commit
61823e98fb
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
package me.ryanhamshire.GriefPrevention;
|
||||
|
||||
import me.ryanhamshire.GriefPrevention.alttd.config.Config;
|
||||
import me.ryanhamshire.GriefPrevention.util.BoundingBox;
|
||||
import me.ryanhamshire.GriefPrevention.events.ClaimPermissionCheckEvent;
|
||||
import org.bukkit.Bukkit;
|
||||
|
|
@ -25,11 +26,7 @@ import org.bukkit.Chunk;
|
|||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.WorldBorder;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
|
@ -747,7 +744,7 @@ public class Claim
|
|||
return DataStore.getChunkHashes(this);
|
||||
}
|
||||
|
||||
public boolean canCleaimNear(Player player, int howNear) {
|
||||
public boolean canClaimNear(Player player, int howNear) {
|
||||
Location location = player.getLocation();
|
||||
Claim claim = new Claim
|
||||
(new Location(this.lesserBoundaryCorner.getWorld(), this.lesserBoundaryCorner.getBlockX() - howNear, this.lesserBoundaryCorner.getBlockY(), this.lesserBoundaryCorner.getBlockZ() - howNear),
|
||||
|
|
@ -757,13 +754,17 @@ public class Claim
|
|||
// if(!claim.contains(location, false, true)) return true;
|
||||
ArrayList<Claim> claims = GriefPrevention.instance.dataStore.claims;
|
||||
for (Claim claim2 : claims) {
|
||||
if (claim2.isAdminClaim()) {
|
||||
player.sendMiniMessage(Config.claimNearAdminClaim, null);
|
||||
return false;
|
||||
}
|
||||
if(claim2.parent != null) continue;
|
||||
if(!claim2.overlaps(claim)) continue;
|
||||
|
||||
Supplier<String> canClaimTrust = claim2.checkPermission(player, ClaimPermission.Claim, null);
|
||||
if (canClaimTrust == null) continue;
|
||||
|
||||
player.sendMiniMessage("<red>You can't claim this close to " + claim2.getOwnerName() + "'s claim.", null); // TODO MINIMESSAG + CONFIG
|
||||
player.sendMiniMessage("<red>You can't claim this close to " + claim2.getOwnerName() + "'s claim.", null); // TODO placeholders
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -26,10 +26,8 @@ import me.ryanhamshire.GriefPrevention.events.ClaimDeletedEvent;
|
|||
import me.ryanhamshire.GriefPrevention.events.ClaimExtendEvent;
|
||||
import me.ryanhamshire.GriefPrevention.events.ClaimTransferEvent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
|
|
@ -39,7 +37,6 @@ import org.bukkit.entity.Entity;
|
|||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Tameable;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
|
|
@ -49,7 +46,6 @@ import java.io.FileWriter;
|
|||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
|
|
@ -975,7 +971,7 @@ public abstract class DataStore
|
|||
}
|
||||
}
|
||||
|
||||
if (creatingPlayer != null && !newClaim.canCleaimNear(creatingPlayer, 100) && newClaim.parent == null) {
|
||||
if (creatingPlayer != null && !newClaim.canClaimNear(creatingPlayer, 100) && newClaim.parent == null) {
|
||||
result.succeeded = false;
|
||||
result.claim = null;
|
||||
return result;
|
||||
|
|
|
|||
|
|
@ -197,8 +197,12 @@ public class Config extends AbstractConfig {
|
|||
}
|
||||
|
||||
public static String claimCreatedOutsideBorder = "<red>You can't create a claim outside of the world border.";
|
||||
public static String claimNearAdminClaim = "<red>You can't claim this close to an admin claim.";
|
||||
public static String claimNearPlayerClaim = "<red>You can't claim this close to <otherclaimowner>'s claim.";
|
||||
private static void messages() {
|
||||
claimCreatedOutsideBorder = config.getString("messages.claim-outside-border", claimCreatedOutsideBorder);
|
||||
claimNearAdminClaim = config.getString("messages.claim-near-admin", claimNearAdminClaim);
|
||||
claimNearPlayerClaim = config.getString("messages.claim-near-player", claimNearPlayerClaim);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user