GoatedFactions 3rd Iteration
## GFactions Plugin Changelog
**Version 1.2.0**
**Date:** May 17, 2025
This changelog outlines the significant features, improvements, and bug fixes implemented for the GFactions plugin, reflecting the evolution from earlier designs to a more robust system.
### ✨ New Core Systems
* **Faction Home & Territory System (Formerly Spawnblock):**
* Factions now establish a central "Home Point" which is automatically set and its chunk claimed upon faction creation (`/f create`). This initial claim is free of power cost.
* Claiming new land (`/f claim`) requires adjacency to the faction's main home territory or one of its outpost territories. Connectivity to a spawn point (home or outpost) is crucial for maintaining territory integrity.
* If the chunk containing the faction's main home is lost (e.g., overclaimed), the home automatically attempts to relocate to another valid, claimed chunk within the faction's main territory. If no suitable main territory chunk exists, it may convert an outpost or, as a last resort, leave the faction without a set home.
* Disconnected claim groups (that are not designated outposts) generally cannot be expanded from, emphasizing strategic claiming around home or outposts.
* **Outpost System:**
* Introduced `/f outpost` subcommands for establishing and managing secondary claim areas, distinct from the main faction home territory.
* `/f outpost create`: Allows creation of an outpost in a wilderness chunk, establishing a new, independent claim anchor. This has a configurable power cost and a server-wide limit per faction.
* `/f outpost sethome [id]`: Designates or relocates the specific teleportation point (home) within an existing outpost's claimed territory. The target location must be within a chunk already claimed by that specific outpost.
* `/f outpost home [id]`: Allows faction members to teleport to the designated home point of a specified outpost.
* `/f outpost delete [id]`: Removes a specified outpost and unclaims all land specifically associated with it.
* **Territory Merging:** If an outpost's claimed territory becomes contiguous (adjacent) with the main faction home territory through new claims, the outpost is automatically disbanded, and its claims are seamlessly merged into the main faction territory.
* **Faction Chat:**
* Implemented `/f chat` (alias `/f c`) to toggle a private chat channel exclusively for faction members.
* Messages sent in faction chat are visible only to online members of that faction.
* Server operators with the `goatedfactions.admin.spy` permission can silently view all faction chat messages.
* The format of faction chat messages (e.g., prefix, colors) is configurable in `config.yml`.
* **Server Spawn Claim Protection:**
* Implemented a configurable system to prevent factions from claiming land or creating new factions (setting their initial home) within a defined radius of the server's main spawn point.
* This protection can be bypassed by players with the `goatedfactions.admin.bypassspawnprotection` permission.
* The protection radius is configurable in `config.yml`.
### Enhancements & Modifications
* **Claiming & Overclaiming:**
* Overclaiming a chunk from another faction now has a distinct, configurable power cost (`power.cost.overclaim_chunk`).
* Overclaiming is only possible if the target faction has zero power.
* Refined logic for claim adjacency: new claims must touch existing faction land (either main territory or an outpost's territory).
* The first claim during `/f create` is free. Subsequent claims via `/f claim` have a configurable power cost.
* **Territory Entry Notifications:**
* On-screen titles displayed when entering a new territory (Wilderness, own/allied/enemy/neutral faction land) now overwrite previous titles more effectively, providing clearer immediate feedback.
* Players also receive a private chat message upon entering Wilderness or a faction's territory. The format and content of these messages are configurable in `config.yml` (e.g., `messages.entering_wilderness`, `messages.entering_faction_territory`), allowing for dynamic color-coding based on relation.
* **Dynmap Integration:**
* Significantly reworked claim visualization on Dynmap. Contiguous claimed areas for a single faction are now rendered with merged borders, creating a cleaner and more unified visual representation rather than individual chunk outlines for connected territories.
* Added configurable `stroke_color` for the merged polygon borders and `neutral_claim_color` for factions that are not self, allied, or enemy.
* Dynmap updates are triggered more comprehensively and reliably after various faction actions, including claims, unclaims, disbands, relation changes, and outpost modifications.
* The popup info for faction areas on Dynmap includes more details like owner, power, member count, allies, enemies, total claims, and outpost count.
* **Faction Home Management:**
* `/f sethome` is now exclusively used to set or relocate the main faction home point within the faction's primary claimed territory (not outpost land).
* `/f unclaim` is prevented on the chunk containing the main faction home if it's the last piece of main territory land; the home must be relocated first using `/f sethome` in another valid chunk, or the faction disbanded. Similar protection exists for the last claim of an outpost's spawn chunk.
* **Configuration (`config.yml`):**
* Added new configuration options:
* `power.cost.create_outpost`: Power cost to create a new outpost.
* `faction_details.max_outposts`: Maximum number of outposts a faction can own.
* `faction_details.faction_chat_format`: Customizable format for faction chat messages.
* `claiming.prevent_claim_near_spawn` and `claiming.spawn_protection_radius`: For server spawn protection.
* `messages.entering_wilderness` and `messages.entering_faction_territory`: For customizable territory entry chat messages.
* Various Dynmap style options including `stroke_color` and `neutral_claim_color`.
* Reviewed and standardized default values for many existing settings.
* **Commands & User Experience:**
* `/f who [faction_name]` now displays information about a faction's outposts, including their IDs and locations.
* Improved tab-completion for `/f outpost` subcommands, suggesting outpost IDs where applicable.
* Standardized user-facing text to use "faction home" or "home point" consistently, moving away from "spawnblock."
* Help messages (`/f help`, `/f outpost help`) now include power costs for relevant commands.
### Bug Fixes & Code Refinements
* Addressed numerous "Cannot resolve method/symbol" errors across `FactionCommand.java`, `AdminFactionCommand.java`, and listener classes by ensuring correct method implementations, parameter matching, proper imports, and correct variable scoping (e.g., `Player player` casting in `FactionCommand`).
* Fixed issues where Dynmap updates were not consistently triggered after all types of claim operations (e.g., initial claim via `/f create`, outpost creation, unclaims), relation changes, or disbands. Ensured `updateFactionClaimsVisual` and `updateFactionRelations` are called appropriately.
* Resolved potential `NullPointerExceptions` in `PlayerClaimBoundaryListener` by ensuring default message strings are always loaded from config or hardcoded safely, and by adding null checks for world objects.
* Corrected logic in `FactionCommand.java` for handling the return values and side-effects of core plugin methods (e.g., ensuring power is deducted only on successful operations for faction creation, claiming, declaring relations).
* Improved `OfflinePlayer` name handling in commands like `/f who` and `/f list` to gracefully manage cases where a player's name might not be resolvable, using UUID fallbacks or "Unknown" placeholders.
* Refined data serialization and deserialization logic in `GFactionsPlugin.java` and `Outpost.java` to correctly save and load outpost data, including their specific claim sets and spawn locations.
* Addressed issues where `/f outpost delete` might not have fully cleaned up all associated claims from both the faction's internal list and the global claim map, or could error if an outpost was in an inconsistent state.
* Fixed string concatenation issues involving `ChatColor` objects and integers by ensuring explicit string conversion (e.g., `String.valueOf()`) in user-facing messages within `FactionCommand.java`.
* Ensured that `Faction.java`'s `broadcastMessage` method was correctly implemented and utilized by `FactionCommand.java`.
* Corrected logic for home relocation (`Faction#relocateHomeToRandomClaim`) to better handle scenarios with no remaining main territory and the conversion of outposts.
* Fixed logic in `Faction#removeClaim` to correctly handle consequences for home and outpost spawn chunks.
* Ensured `Faction#lateInitPluginReference` is consistently called after loading factions to correctly initialize transient plugin-dependent fields and re-validate data like outpost IDs and world references.
### Developer & Server Admin Notes
* The initial claim made during `/f create` (the faction's home chunk) is now explicitly free of any power cost. Subsequent claims incur costs as defined.
* The plugin's `onEnable` sequence in `GFactionsPlugin.java` now includes more detailed logging for each initialization step (config loading, spawn location, data loading, command/listener registration, tasks, Dynmap) to aid in diagnosing any startup issues.
* **Configuration Migration:** When upgrading from a significantly older version (pre-outposts/spawnblock changes), it is **highly recommended** to back up and then delete the old `config.yml` and `factions.yml` (or your faction data file). This allows the plugin to generate new files with all the current options and default values, preventing potential conflicts or missing settings, especially for new message formats, outpost configurations, and spawn protection.
* The Dynmap seamless border feature represents a significant visual improvement. However, for extremely complex or highly fragmented claim patterns across multiple non-contiguous areas (that aren't outposts), the polygon merging algorithm's output should be monitored. Fallback to individual chunk markers occurs if a valid polygon cannot be formed.
* The `PlayerClaimBoundaryListener` now uses a configurable cooldown (`titles.display_cooldown_seconds`) for sending on-screen titles to prevent spam, but chat messages for territory changes are still sent.