Skip to content

Commit

Permalink
- New Commands: /town set title {resident} {title} & /town set surname
Browse files Browse the repository at this point in the history
{resident} {title}
    - Exactly like the King ability to set titles and surnames.
    - This is being made available to mayors so that mayors can better
role play their own townmembers.
    - Permission nodes: towny.command.town.set.title &
towny.command.town.set.surname are child nodes of
towny.command.town.set.*
    - Closes ticket #3439
  - New Permission node: towny.command.town.set.title
    - Child node of towny.command.town.set.*
  - New Permission node: towny.command.town.set.surname
    - Child node of towny.command.town.set.*
  • Loading branch information
LlmDl committed Oct 27, 2019
1 parent cc279c3 commit ef4aadc
Show file tree
Hide file tree
Showing 15 changed files with 105 additions and 11 deletions.
11 changes: 10 additions & 1 deletion resources/ChangeLog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3708,4 +3708,13 @@ v0.92.0.11:
- Change to '[^a-zA-Z0-9&._\[\]-]'
- This allows colours to be used in the title/surname options.
- The default config will have the &, if you don't want colour codes used in titles/surnames you can skip this.
- Closes ticket #3172
- Closes ticket #3172
- New Commands: /town set title {resident} {title} & /town set surname {resident} {title}
- Exactly like the King ability to set titles and surnames.
- This is being made available to mayors so that mayors can better role play their own townmembers.
- Permission nodes: towny.command.town.set.title & towny.command.town.set.surname are child nodes of towny.command.town.set.*
- Closes ticket #3439
- New Permission node: towny.command.town.set.title
- Child node of towny.command.town.set.*
- New Permission node: towny.command.town.set.surname
- Child node of towny.command.town.set.*
3 changes: 2 additions & 1 deletion resources/chinese.yml
Original file line number Diff line number Diff line change
Expand Up @@ -972,4 +972,5 @@ msg_err_cannot_afford_to_set_outpost: 'Your town does not have enough funds to s
msg_too_close2: 'This area is too close to another town''s %s.'
homeblock: 'homeblock'
townblock: 'townblock'
outpost: 'outpost'
outpost: 'outpost'
msg_err_not_same_town: '&b%s doesn''t belong to your town.'
3 changes: 2 additions & 1 deletion resources/english.yml
Original file line number Diff line number Diff line change
Expand Up @@ -968,4 +968,5 @@ msg_err_cannot_afford_to_set_outpost: 'Your town does not have enough funds to s
msg_too_close2: 'This area is too close to another town''s %s.'
homeblock: 'homeblock'
townblock: 'townblock'
outpost: 'outpost'
outpost: 'outpost'
msg_err_not_same_town: '&b%s doesn''t belong to your town.'
3 changes: 2 additions & 1 deletion resources/es-mx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -956,4 +956,5 @@ msg_err_cannot_afford_to_set_outpost: 'Your town does not have enough funds to s
msg_too_close2: 'This area is too close to another town''s %s.'
homeblock: 'homeblock'
townblock: 'townblock'
outpost: 'outpost'
outpost: 'outpost'
msg_err_not_same_town: '&b%s doesn''t belong to your town.'
3 changes: 2 additions & 1 deletion resources/french.yml
Original file line number Diff line number Diff line change
Expand Up @@ -968,4 +968,5 @@ msg_err_cannot_afford_to_set_outpost: 'Your town does not have enough funds to s
msg_too_close2: 'This area is too close to another town''s %s.'
homeblock: 'homeblock'
townblock: 'townblock'
outpost: 'outpost'
outpost: 'outpost'
msg_err_not_same_town: '&b%s doesn''t belong to your town.'
1 change: 1 addition & 0 deletions resources/german.yml
Original file line number Diff line number Diff line change
Expand Up @@ -972,3 +972,4 @@ msg_too_close2: 'Dieser Ort ist zu Nahe an einer anderen Stadt''s %s.'
homeblock: 'Heimatblock'
townblock: 'Stadtblock'
outpost: 'Aussenposten'
msg_err_not_same_town: '&b%s doesn''t belong to your town.'
3 changes: 2 additions & 1 deletion resources/italian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -970,4 +970,5 @@ msg_err_cannot_afford_to_set_outpost: 'Your town does not have enough funds to s
msg_too_close2: 'This area is too close to another town''s %s.'
homeblock: 'homeblock'
townblock: 'townblock'
outpost: 'outpost'
outpost: 'outpost'
msg_err_not_same_town: '&b%s doesn''t belong to your town.'
3 changes: 2 additions & 1 deletion resources/korean.yml
Original file line number Diff line number Diff line change
Expand Up @@ -881,4 +881,5 @@ msg_err_cannot_afford_to_set_outpost: 'Your town does not have enough funds to s
msg_too_close2: 'This area is too close to another town''s %s.'
homeblock: 'homeblock'
townblock: 'townblock'
outpost: 'outpost'
outpost: 'outpost'
msg_err_not_same_town: '&b%s doesn''t belong to your town.'
3 changes: 2 additions & 1 deletion resources/norwegian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -968,4 +968,5 @@ msg_err_cannot_afford_to_set_outpost: 'Your town does not have enough funds to s
msg_too_close2: 'This area is too close to another town''s %s.'
homeblock: 'homeblock'
townblock: 'townblock'
outpost: 'outpost'
outpost: 'outpost'
msg_err_not_same_town: '&b%s doesn''t belong to your town.'
2 changes: 2 additions & 0 deletions resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,8 @@ permissions:
towny.command.town.set.plottax: true
towny.command.town.set.shoptax: true
towny.command.town.set.embassytax: true
towny.command.town.set.title: true
towny.command.town.set.surname: true

towny.command.town.toggle.*:
description: User can toggle all town settings.
Expand Down
3 changes: 2 additions & 1 deletion resources/russian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -968,4 +968,5 @@ msg_err_cannot_afford_to_set_outpost: 'Your town does not have enough funds to s
msg_too_close2: 'This area is too close to another town''s %s.'
homeblock: 'homeblock'
townblock: 'townblock'
outpost: 'outpost'
outpost: 'outpost'
msg_err_not_same_town: '&b%s doesn''t belong to your town.'
3 changes: 2 additions & 1 deletion resources/spanish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -968,4 +968,5 @@ msg_err_cannot_afford_to_set_outpost: 'Your town does not have enough funds to s
msg_too_close2: 'This area is too close to another town''s %s.'
homeblock: 'homeblock'
townblock: 'townblock'
outpost: 'outpost'
outpost: 'outpost'
msg_err_not_same_town: '&b%s doesn''t belong to your town.'
Original file line number Diff line number Diff line change
Expand Up @@ -2052,8 +2052,8 @@ else if (split[1].equalsIgnoreCase("clear")) {
if (split.length < 2)
TownyMessaging.sendErrorMsg(player, "Eg: /nation set title bilbo Jester ");
else

resident = townyUniverse.getDataSource().getResident(split[1]);

if (resident.hasNation()) {
if (resident.getTown().getNation() != townyUniverse.getDataSource().getResident(player.getName()).getTown().getNation()) {
TownyMessaging.sendErrorMsg(player, String.format(TownySettings.getLangString("msg_err_not_same_nation"), resident.getName()));
Expand Down
71 changes: 71 additions & 0 deletions src/com/palmergames/bukkit/towny/command/TownCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -1420,6 +1420,7 @@ public static void townSet(Player player, String[] split, boolean admin, Town to
player.sendMessage(ChatTools.formatCommand("", "/town set", "spawncost [$]", ""));
player.sendMessage(ChatTools.formatCommand("", "/town set", "name [name]", ""));
player.sendMessage(ChatTools.formatCommand("", "/town set", "tag [upto 4 letters] or clear", ""));
player.sendMessage(ChatTools.formatCommand("", "/town set", "title/surname [resident] [text]", ""));
} else {
Resident resident;

Expand Down Expand Up @@ -1459,6 +1460,76 @@ public static void townSet(Player player, String[] split, boolean admin, Town to
town.setTownBoard(line);
TownyMessaging.sendTownBoard(player, town);
}
} else if (split[0].equalsIgnoreCase("title")) {

if (!townyUniverse.getPermissionSource().testPermission(player, PermissionNodes.TOWNY_COMMAND_TOWN_SET_TITLE.getNode()))
throw new TownyException(TownySettings.getLangString("msg_err_command_disable"));

// Give the resident a title
if (split.length < 2)
TownyMessaging.sendErrorMsg(player, "Eg: /town set title bilbo Jester ");
else
resident = townyUniverse.getDataSource().getResident(split[1]);

if (resident.hasTown()) {
if (resident.getTown() != townyUniverse.getDataSource().getResident(player.getName()).getTown()) {
TownyMessaging.sendErrorMsg(player, String.format(TownySettings.getLangString("msg_err_not_same_town"), resident.getName()));
return;
}
} else {
TownyMessaging.sendErrorMsg(player, String.format(TownySettings.getLangString("msg_err_not_same_town"), resident.getName()));
return;
}
split = StringMgmt.remArgs(split, 2);
if (StringMgmt.join(split).length() > TownySettings.getMaxTitleLength()) {
TownyMessaging.sendErrorMsg(player, TownySettings.getLangString("msg_err_input_too_long"));
return;
}

String title = StringMgmt.join(NameValidation.checkAndFilterArray(split));
resident.setTitle(title + " ");
townyUniverse.getDataSource().saveResident(resident);

if (resident.hasTitle())
TownyMessaging.sendTownMessage(town, String.format(TownySettings.getLangString("msg_set_title"), resident.getName(), resident.getTitle()));
else
TownyMessaging.sendTownMessage(town, String.format(TownySettings.getLangString("msg_clear_title_surname"), "Title", resident.getName()));

} else if (split[0].equalsIgnoreCase("surname")) {

if (!townyUniverse.getPermissionSource().testPermission(player, PermissionNodes.TOWNY_COMMAND_TOWN_SET_SURNAME.getNode()))
throw new TownyException(TownySettings.getLangString("msg_err_command_disable"));

// Give the resident a title
if (split.length < 2)
TownyMessaging.sendErrorMsg(player, "Eg: /town set surname bilbo the dwarf ");
else

resident = townyUniverse.getDataSource().getResident(split[1]);
if (resident.hasTown()) {
if (resident.getTown() != townyUniverse.getDataSource().getResident(player.getName()).getTown()) {
TownyMessaging.sendErrorMsg(player, String.format(TownySettings.getLangString("msg_err_not_same_town"), resident.getName()));
return;
}
} else {
TownyMessaging.sendErrorMsg(player, String.format(TownySettings.getLangString("msg_err_not_same_town"), resident.getName()));
return;
}
split = StringMgmt.remArgs(split, 2);
if (StringMgmt.join(split).length() > TownySettings.getMaxTitleLength()) {
TownyMessaging.sendErrorMsg(player, TownySettings.getLangString("msg_err_input_too_long"));
return;
}

String surname = StringMgmt.join(NameValidation.checkAndFilterArray(split));
resident.setSurname(" " + surname);
townyUniverse.getDataSource().saveResident(resident);

if (resident.hasSurname())
TownyMessaging.sendTownMessage(town, String.format(TownySettings.getLangString("msg_set_surname"), resident.getName(), resident.getSurname()));
else
TownyMessaging.sendTownMessage(town, String.format(TownySettings.getLangString("msg_clear_title_surname"), "Surname", resident.getName()));


} else {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ public enum PermissionNodes {
TOWNY_COMMAND_TOWN_SET_NAME("towny.command.town.set.name"),
TOWNY_COMMAND_TOWN_SET_TAG("towny.command.town.set.tag"),
TOWNY_COMMAND_TOWN_SET_JAIL("towny.command.town.set.jail"),
TOWNY_COMMAND_TOWN_SET_TITLE("towny.command.town.set.title"),
TOWNY_COMMAND_TOWN_SET_SURNAME("towny.command.town.set.surname"),

TOWNY_COMMAND_TOWN_BUY("towny.command.town.buy"),
TOWNY_COMMAND_TOWN_JAIL("towny.command.town.jail"),
Expand Down

0 comments on commit ef4aadc

Please sign in to comment.