Skip to content

Commit

Permalink
Update docs for v2.6 (#373)
Browse files Browse the repository at this point in the history
* Fixup `/town relations` command syntax

* config: Add docs links to Settings, fix path

* config: Town relationships -> Town relations

* wars: Only allow PvP for active war participants

* docs: Update docs for Town Relations & Wars

* docs: add `/town relations` and `/town war` to commands
  • Loading branch information
WiIIiam278 authored Nov 25, 2023
1 parent 81880ae commit 3baa315
Show file tree
Hide file tree
Showing 15 changed files with 334 additions and 130 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ default void onEntityDamageEntity(@NotNull EntityDamageByEntityEvent e) {
}

// Allow PvP if the two towns are at war
if (getPlugin().getSettings().doTownWars() && damagedTown.isAtWarWith(damagerTown)) {
if (getPlugin().getSettings().doTownWars() && damagedTown.isAtWarWith(damagerTown) && damagedTown
.getCurrentWar().map(w -> w.isPlayerActive(damagingUser.getUuid())).orElse(false)) {
return;
}
}
Expand Down
2 changes: 1 addition & 1 deletion bukkit/src/main/resources/commodore/town.commodore
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ town {
town brigadier:string single_word;
}
relations {
view {
list {
town brigadier:string single_word;
}
set {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public TownCommand(@NotNull HuskTowns plugin) {
new MemberCommand(this, plugin, MemberCommand.Type.TRANSFER),
new DisbandCommand(this, plugin),
(ChildCommand) getDefaultExecutor()));
if (plugin.getSettings().doTownRelationships()) {
if (plugin.getSettings().doTownRelations()) {
children.add(new RelationsCommand(this, plugin));
if (plugin.getSettings().doTownWars()) {
children.add(new WarCommand(this, plugin));
Expand Down Expand Up @@ -949,12 +949,12 @@ public void execute(@NotNull CommandUser executor, @NotNull String[] args) {
private static class RelationsCommand extends ChildCommand implements TabProvider {

protected RelationsCommand(@NotNull Command parent, @NotNull HuskTowns plugin) {
super("relations", List.of(), parent, "[view (town)|set <ally|neutral|enemy> <other_town>]", plugin);
super("relations", List.of(), parent, "[list (town)|set <ally|neutral|enemy> <other_town>]", plugin);
}

@Override
public void execute(@NotNull CommandUser executor, @NotNull String[] args) {
final String operation = parseStringArg(args, 0).orElse("view").toLowerCase(Locale.ENGLISH);
final String operation = parseStringArg(args, 0).orElse("list").toLowerCase(Locale.ENGLISH);
if (!operation.equals("set")) {
plugin.getManager().towns().showTownRelations((OnlineUser) executor, parseStringArg(args, 1)
.orElse(null));
Expand All @@ -975,11 +975,13 @@ public void execute(@NotNull CommandUser executor, @NotNull String[] args) {
@Override
public List<String> suggest(@NotNull CommandUser user, @NotNull String[] args) {
return switch (args.length) {
case 0, 1 -> filter(List.of("set", "list"), args);
case 2 -> filter(List.of("ally", "neutral", "enemy"), args);
case 3 -> plugin.getTowns().stream()
.map(Town::getName)
.collect(Collectors.toList());
case 0, 1 -> List.of("set", "list");
case 2 -> args[0].equalsIgnoreCase("set")
? List.of("ally", "neutral", "enemy")
: plugin.getTowns().stream().map(Town::getName).toList();
case 3 -> args[0].equalsIgnoreCase("set")
? plugin.getTowns().stream().map(Town::getName).toList()
: List.of();
default -> List.of();
};
}
Expand Down
32 changes: 17 additions & 15 deletions common/src/main/java/net/william278/husktowns/config/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -262,38 +262,40 @@ public class Settings {


// Relationships & Wars settings
@YamlComment("Enable town relationships (alliances and enemies)")
@YamlKey("towns.relationships.enabled")
private boolean enableTownRelationships = true;

@YamlComment("Allow mutual enemy towns to agree to go to war. Requires town relationships to be enabled. " +
"Wars consist of a battle between members, to take place at the spawn of the defending town")
@YamlKey("towns.relationships.wars.enabled")
@YamlComment("Enable town relations (alliances and enemies). " +
"Docs: https://william278.net/docs/husktowns/town-relations/")
@YamlKey("towns.relations.enabled")
private boolean enableTownRelations = true;

@YamlComment("Allow mutual enemy towns to agree to go to war. Requires town relations to be enabled. " +
"Wars consist of a battle between members, to take place at the spawn of the defending town" +
"Docs: https://william278.net/docs/husktowns/town-wars/")
@YamlKey("towns.relations.wars.enabled")
private boolean enableTownWars = false;

@YamlComment("The number of hours before a town can be involved with another war after finishing one")
@YamlKey("towns.relationships.wars.cooldown")
@YamlKey("towns.relations.wars.cooldown")
private long warCooldown = 48;

@YamlComment("How long before pending declarations of war expire")
@YamlKey("town.relationships.wars.declaration_expiry")
@YamlKey("towns.relations.wars.declaration_expiry")
private long warDeclarationExpiry = 10;

@YamlComment("The minimum wager for a war. This is the amount of money each town must pay to participate in a war." +
" The winner of the war will receive both wagers.")
@YamlKey("towns.relationships.wars.minimum_wager")
@YamlKey("towns.relations.wars.minimum_wager")
private double warMinimumWager = 5000;

@YamlComment("The color of the boss bar displayed during a war")
@YamlKey("towns.relationships.wars.boss_bar_color")
@YamlKey("towns.relations.wars.boss_bar_color")
private BossBar.Color warBossBarColor = BossBar.Color.RED;

@YamlComment("The minimum number of members online in a town for it to be able to participate in a war (%).")
@YamlKey("towns.relationships.wars.required_online_membership")
@YamlKey("towns.relations.wars.required_online_membership")
private double warMinimumMembersOnline = 50.0;

@YamlComment("The radius around the defending town's spawn, in blocks, where battle can take place. (Min: 16)")
@YamlKey("towns.relationships.wars.war_zone_radius")
@YamlKey("towns.relations.wars.war_zone_radius")
private long warZoneRadius = 128;


Expand Down Expand Up @@ -543,8 +545,8 @@ public String getBoostParticle() {
return boostParticle;
}

public boolean doTownRelationships() {
return enableTownRelationships;
public boolean doTownRelations() {
return enableTownRelations;
}

public boolean doTownWars() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ private boolean cancelOperation(@NotNull Operation operation, @NotNull TownClaim
final Claim claim = townClaim.claim();

// Apply wartime flags if the town is at war
if (plugin.getSettings().doTownWars() && plugin.getSettings().doTownRelationships() &&
if (plugin.getSettings().doTownWars() && plugin.getSettings().doTownRelations() &&
town.getCurrentWar().map(war -> war.getDefending() == town.getId()).orElse(false)) {
return plugin.getRulePresets().getWarRules().cancelOperation(operation.getType(), plugin.getFlags());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public Manager(@NotNull HuskTowns plugin) {
this.towns = new TownsManager(plugin);
this.claims = new ClaimsManager(plugin);
this.admin = new AdminManager(plugin);
this.wars = plugin.getSettings().doTownRelationships() && plugin.getSettings().doTownWars()
this.wars = plugin.getSettings().doTownRelations() && plugin.getSettings().doTownWars()
? new WarManager(plugin) : null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ private Component getViewButtons() {
.append(plugin.getLocales().getLocale("town_button_claims",
town.getName(), town.getColorRgb())
.map(m -> m.toComponent().append(Component.space())).orElse(Component.empty())
.append(plugin.getSettings().doTownRelationships()
.append(plugin.getSettings().doTownRelations()
? plugin.getLocales().getLocale("town_button_relations", town.getName())
.map(MineDown::toComponent).orElse(Component.empty())
: Component.empty())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ default long pruneInactiveTowns(long daysInactive, @Nullable OnlineUser actor) {
* accordingly. The {@link Settings#doTownWars()} setting must be enabled for this to work.
*/
default void pruneLocalTownWars() {
if (!getPlugin().getSettings().doTownRelationships() || !getPlugin().getSettings().doTownWars()) {
if (!getPlugin().getSettings().doTownRelations() || !getPlugin().getSettings().doTownWars()) {
return;
}

Expand Down
2 changes: 2 additions & 0 deletions docs/Commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ The `/town` command (base permission: `husktowns.command.town`) is the entry poi
| `/town player` | View which town a player is a member of | `husktowns.command.town.player` |
| `/town deeds` | View a list of town claims on this server | `husktowns.command.town.deeds` |
| `/town census` | View a list of town members and their roles | `husktowns.command.town.census` |
| `/town relations` | Manage [[Town Relations]] if enabled | `husktowns.command.town.relations` |
| `/town war` | View and declare [[Town Wars]] if enabled | `husktowns.command.town.war` |
| `/town log` | View the town audit log | `husktowns.command.town.log` |
| `/town transfer` | Transfer ownership of the town to someone | `husktowns.command.town.transfer` |
| `/town disband` | Delete the town | `husktowns.command.town.disband` |
Expand Down
Loading

0 comments on commit 3baa315

Please sign in to comment.