|
1 | 1 | # SimpleFactions |
2 | 2 |
|
3 | | -Organisation documentation: [TF-Minecraft/Docs](https://github.com/TF-Minecraft/Docs/blob/main/projects/SimpleFactions/README.md). |
| 3 | +> Nations, diplomacy, and political strategy for TF-Minecraft. |
4 | 4 |
|
5 | | -The name stems from its original concept of a simple nation system, but it has since grown far beyond that. |
| 5 | +SimpleFactions turns groups of players into nations with territory, rulers, economies, and relationships. Its name comes from an early, simpler nation system; the project has grown into a broad political simulation inspired by Paradox Interactive's strategy games. |
6 | 6 |
|
7 | | -This plugin adds factions (nations) to the game that can interact with each other through a complex diplomacy and economy system. |
8 | | - |
9 | | -**Full docs:** [docs/README.md](docs/README.md) - wars, installations, settlements, map export, vehicles, and dev config. |
10 | | - |
11 | | -You will not be able to run this as a standalone program, as it depends on other plugins and the Spigot server environment. |
12 | | - |
13 | | -## Why This Project Is Interesting |
14 | | -This plugin implements strategy-game-style diplomacy between nations and a fully original map/border system using a REST connection to a Python program I wrote myself: |
15 | | -[ProvinceSystem](https://github.com/Drefvelin/ProvinceSystem) |
16 | | - |
17 | | -Highlights include: |
18 | | - |
19 | | -- **Nested Relationships** -- Factions can have subjects, and those subjects can have their own subjects. |
20 | | -- **Tax Simulation** -- When a player (or faction) earns money, their faction (or overlord) can automatically tax their income. |
21 | | - |
22 | | -I drew heavy inspiration from strategy games by Paradox Interactive and leveraged my experience with object-oriented programming to implement parts of their systems. The project contains many interconnected classes that must remain consistent to avoid desynchronization. |
23 | | - |
24 | | -This project also demonstrates cross-language integration through **ProvinceSystem**, requiring careful planning to keep server state synchronized between the Java plugin and the Python backend. |
| 7 | +Players shape a world of provinces and titles, organise settlements and guilds, and navigate alliances, subjects, taxation, and war. Their nations also appear on the connected web map, making changes to the political landscape visible beyond the game. |
25 | 8 |
|
26 | 9 | ## Features |
27 | | -- Faction objects that function as nations in-game |
28 | | - ([Faction.java](src/main/java/me/Plugins/SimpleFactions/Objects/Faction.java)) |
29 | | -- Faction relationships |
30 | | - ([RelationManager.java](src/main/java/me/Plugins/SimpleFactions/Managers/RelationManager.java)) |
31 | | -- **Automated campaign wars**, installations (forts/ports/airports), settlements, and map export to tfminecraft.net |
32 | | - ([docs/wars.md](docs/wars.md), [docs/installations.md](docs/installations.md), [docs/map-export.md](docs/map-export.md)) |
33 | | -- Titles (Kingdom, Duchy, etc.) connected with the REST server and the TitleManager |
34 | | - ([ProvinceSystem](https://github.com/Drefvelin/ProvinceSystem), |
35 | | - [TitleManager.java](src/main/java/me/Plugins/SimpleFactions/Managers/TitleManager.java)) |
36 | | - |
37 | | -## Technical Overview |
38 | | -- Java 17, Spigot API 1.20 |
39 | | -- Built using Maven |
40 | | - |
41 | | -### Architecture |
42 | | -- The main class initializes managers and overall plugin setup |
43 | | - ([SimpleFactions.java](src/main/java/me/Plugins/SimpleFactions/SimpleFactions.java)) |
44 | | -- Configuration files (and titles from JSON) are loaded and stored via the Loader classes |
45 | | - ([Loaders](src/main/java/me/Plugins/SimpleFactions/Loaders/)) |
46 | | -- `FactionManager` handles faction creation, lookups, member/leader queries, and database calls |
47 | | - ([FactionManager.java](src/main/java/me/Plugins/SimpleFactions/Managers/FactionManager.java)) |
48 | | -- The `Inventory` package contains the extensive GUI classes players interact with |
49 | | - ([Inventory](src/main/java/me/Plugins/SimpleFactions/Managers/Inventory/)) |
50 | | -- `MapSystem` is the primary interface for REST communication, while `RestServer` manages the actual requests and responses |
51 | | - ([MapSystem.java](src/main/java/me/Plugins/SimpleFactions/Map/MapSystem.java), |
52 | | - [RestServer.java](src/main/java/me/Plugins/SimpleFactions/REST/RestServer.java)) |
53 | | - |
54 | | -## Key Challenges Solved |
55 | | - |
56 | | -### Map System |
57 | | -Most Minecraft plugins that work with territory rely on the game's built-in region system (chunks). Chunks are small, perfectly square units, which makes borders look artificial. Since our world uses a fixed 4096×4096 coordinate grid, I realized I could generate an image of the same resolution and map each world coordinate directly to a pixel. |
58 | | - |
59 | | -By drawing irregular “blobs” of unique RGB colors on this image, I created natural-looking provinces where: |
60 | | - |
61 | | -> **province = the color of the pixel at your current coordinate** |
62 | | -
|
63 | | -The Minecraft plugin handles the coordinate and faction logic, while the external Python service (**ProvinceSystem**) processes the image and exposes province/border data on our website: |
64 | | -https://www.tfminecraft.net/ |
65 | | - |
66 | | -A major challenge was keeping both systems synchronized efficiently. The Python service can take several minutes to redraw the full map, so regenerating unchanged regions was wasteful. To solve this, I implemented a queued update system that tracks exactly which provinces or borders changed in the Minecraft server state, and sends only incremental updates to the Python service. This dramatically reduced processing time and ensured consistent, near-real-time synchronization between the two systems. |
67 | | - |
68 | | ---- |
69 | | - |
70 | | -### Money Flow and Taxation |
71 | | -Introducing a virtual economy requires strong guarantees against exploits (e.g., infinite money loops). One of the biggest challenges was implementing **nested taxation**: |
72 | | - |
73 | | -- A faction can tax its members. |
74 | | -- A faction can be a subject to an overlord, which may also have its own overlord. |
75 | | -- Foreign income can be taxed depending on diplomatic relations. |
76 | | - |
77 | | -The system needed to propagate tax values through these nested relationships without ever allowing the combined tax rate to exceed 100% - otherwise it would generate money that never existed. I solved this by implementing a clamped, hierarchical taxation model that guarantees consistency and prevents exploitable edge cases. |
78 | | - |
79 | | -## AI Tools |
80 | | -I used **ChatGPT** primarily for troubleshooting and generating small amounts of code, such as the logic for loading titles from JSON. |
81 | | - |
82 | | -For architecture, class design, and the overall structure of the plugin, I relied on my own judgment. In my experience, AI struggles to maintain coherent object-oriented structure in larger projects, so all high-level design, class relationships, and system architecture were created and implemented manually. |
83 | | - |
84 | | -Most of the plugin was written without AI assistance to maintain control over the design and ensure consistency. **ChatGPT** was also used to help format and refine this README. |
85 | | - |
86 | | - |
87 | | -## TLibs build dependency |
88 | | - |
89 | | -TLibs is a versioned Maven `provided` dependency. From this repository, prepare |
90 | | -it once with the shared installer, then build as usual: |
91 | 10 |
|
92 | | -```sh |
93 | | -python3 ../tlibs/tools/install-dependency.py --pom pom.xml |
94 | | -mvn clean verify |
95 | | -``` |
| 11 | +- **Provinces and titles** — govern territories with natural-shaped borders and titles such as duchies and kingdoms. |
| 12 | +- **Layered diplomacy** — form alliances, establish subject and overlord relationships, negotiate treaties, and impose trade embargoes. |
| 13 | +- **National economies** — manage wealth and taxation, including income moving through relationships between members, nations, and overlords. |
| 14 | +- **Settlements and guilds** — establish named cities and capitals and organise groups within a nation. |
| 15 | +- **Military infrastructure** — construct forts, ports, and airports that support the nation's military presence. |
| 16 | +- **Campaign warfare** — pursue war goals through scheduled battles, player voting, warband participation, and campaign progression. |
96 | 17 |
|
97 | | -See [TLibs dependency setup](https://github.com/TF-Minecraft/TLibs/blob/5da8e77d0e0696bbff7d7064a2644072da9c6428/DEPENDENCIES.md) |
98 | | -for public release installation, offline builds and rollback. |
99 | | -Other declared build dependencies still need their usual preparation. |
100 | | -Use JDK 25 for this TLibs binary; the server must also run Java 25. |
| 18 | +## A shared political world |
101 | 19 |
|
102 | | -Builds and server runtime require Java 25. Local builds default to [TLibs 1.1.0](https://github.com/TF-Minecraft/TLibs/releases/tag/v1.1.0); CI resolves the latest published stable TLibs release for each build, verifies its checksum, and uses its exact version throughout that job. |
| 20 | +[ProvinceSystem](https://github.com/TF-Minecraft/ProvinceSystem) presents the world map, borders, settlements, and military activity on the website. |
103 | 21 |
|
104 | | -## Shared plugin dependencies |
| 22 | +## Project background |
105 | 23 |
|
106 | | -Build and release workflows install checksum-verified plugin releases through |
107 | | -[TLibs' shared installer](https://github.com/TF-Minecraft/TLibs/blob/main/DEPENDENCIES.md). |
108 | | -CI selects the latest published versions; local builds use the explicit Maven |
109 | | -version properties. Shared plugins use `provided` scope and remain separate |
110 | | -server plugins. Each build records exact versions and checksums in |
111 | | -`.build/plugin-dependencies.json` alongside its JAR. |
| 24 | +Created by Drefvelin, with inspiration from Paradox Interactive. The original project notes credit ChatGPT for troubleshooting, some code assistance, and README editing. |
112 | 25 |
|
113 | | -From this checkout, with the TLibs repository next to it: |
| 26 | +## Documentation |
114 | 27 |
|
115 | | -```sh |
116 | | -python3 ../tlibs/tools/install-plugins.py --pom pom.xml |
117 | | -``` |
| 28 | +[Project documentation](https://github.com/TF-Minecraft/Docs/blob/main/projects/SimpleFactions/README.md) |
118 | 29 |
|
119 | | -Prepare any remaining third-party inputs with `.github/scripts/prepare-release.sh` |
120 | | -before running Maven. Any source-unavailable inputs remain private and checksum-pinned wherever declared; see the installer |
121 | | -documentation for authentication and reproducible rebuilds. |
| 30 | +Technical documentation is maintained in [TF-Minecraft/Docs](https://github.com/TF-Minecraft/Docs). |
0 commit comments