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;
}
}
}
}
Aggregations