Search in sources :

Example 6 with InvalidStructure

use of eelfloat.replcraft.exceptions.InvalidStructure in project replcraft by LeeFlemingRepl.

the class Client method notifyChangeAndRevalidateStructureAt.

/**
 * Forces the client to re-verify its structure if the given location is adjacent to any of its structural blocks
 */
public void notifyChangeAndRevalidateStructureAt(Location location) {
    HashSet<Location> locations = this.structure == null ? this.invalidated_structure_locations : this.structure.frameBlocks;
    for (BlockFace face : BlockFace.values()) {
        if (!face.isCartesian())
            continue;
        if (locations.contains(location.getBlock().getRelative(face).getLocation())) {
            try {
                ReplCraft.plugin.logger.info(String.format("Revalidating structure %s due to block change at %s", this.structure, location));
                this.structure = StructureUtil.verifyToken(this.authentication);
                this.invalidated = false;
                return;
            } catch (InvalidStructure e) {
                ReplCraft.plugin.logger.info(String.format("Revalidation failed: %s", e));
                if (this.structure != null) {
                    this.invalidated_structure_locations = this.structure.frameBlocks;
                    this.structure = null;
                }
                this.invalidated = true;
            }
        }
    }
}
Also used : InvalidStructure(eelfloat.replcraft.exceptions.InvalidStructure) BlockFace(org.bukkit.block.BlockFace) Location(org.bukkit.Location)

Aggregations

InvalidStructure (eelfloat.replcraft.exceptions.InvalidStructure)6 Structure (eelfloat.replcraft.Structure)3 ApiError (eelfloat.replcraft.exceptions.ApiError)3 Claims (io.jsonwebtoken.Claims)3 JwtException (io.jsonwebtoken.JwtException)2 org.bukkit (org.bukkit)2 Block (org.bukkit.block.Block)2 BlockFace (org.bukkit.block.BlockFace)2 BlockState (org.bukkit.block.BlockState)2 BlockData (org.bukkit.block.data.BlockData)2 WallSign (org.bukkit.block.data.type.WallSign)2 ReplCraft (eelfloat.replcraft.ReplCraft)1 StructureMaterial (eelfloat.replcraft.StructureMaterial)1 Jwts (io.jsonwebtoken.Jwts)1 java.util (java.util)1 UUID (java.util.UUID)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 Predicate (java.util.function.Predicate)1 Collectors (java.util.stream.Collectors)1 Location (org.bukkit.Location)1