Skip to content

Commit

Permalink
Made Accept/Decline buttons, tooltip and prompt translatable
Browse files Browse the repository at this point in the history
  • Loading branch information
WiIIiam278 committed Feb 6, 2021
1 parent 83611e4 commit f475637
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,20 @@ public static TextComponent createButton(String buttonText, net.md_5.bungee.api.
}

public static void sendTpAcceptDenyButtons(Player p) {
// Send the "Accept" or "Decline" response buttons to the player who has recieved a request
// Send the "Accept" or "Decline" response buttons to the player who has received a request
// Options text
TextComponent options = new TextComponent("Click an option: ");
TextComponent options = new TextComponent(messageManager.getRawMessage("tpa_request_option_select"));
options.setColor(net.md_5.bungee.api.ChatColor.GRAY);

TextComponent separator = new TextComponent(" • ");
TextComponent separator = new TextComponent(messageManager.getRawMessage("list_item_divider"));
separator.setColor(net.md_5.bungee.api.ChatColor.GRAY);

// Build the components together
ComponentBuilder teleportResponses = new ComponentBuilder();
teleportResponses.append(options);
teleportResponses.append(createButton("[Accept]", net.md_5.bungee.api.ChatColor.GREEN, ClickEvent.Action.RUN_COMMAND, "/tpaccept", "Accept the teleport request (/tpaccept)", net.md_5.bungee.api.ChatColor.GRAY, false));
teleportResponses.append(createButton(messageManager.getRawMessage("tpa_accept_button"), net.md_5.bungee.api.ChatColor.GREEN, ClickEvent.Action.RUN_COMMAND, "/tpaccept", messageManager.getRawMessage("tpa_accept_button_tooltip"), net.md_5.bungee.api.ChatColor.GRAY, false));
teleportResponses.append(separator);
teleportResponses.append(createButton("[Decline]", net.md_5.bungee.api.ChatColor.RED, ClickEvent.Action.RUN_COMMAND, "/tpdeny", "Decline the teleport request (/tpdeny)", net.md_5.bungee.api.ChatColor.GRAY, false));
teleportResponses.append(createButton(messageManager.getRawMessage("tpa_decline_button"), net.md_5.bungee.api.ChatColor.RED, ClickEvent.Action.RUN_COMMAND, "/tpdeny", messageManager.getRawMessage("tpa_decline_button_tooltip"), net.md_5.bungee.api.ChatColor.GRAY, false));

// Create and send the message
p.spigot().sendMessage(teleportResponses.create());
Expand Down
5 changes: 5 additions & 0 deletions src/main/resources/Languages/en-gb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ error_spawn_undefined: '&4Error: &cThere is no spawn location defined on this se
error_tpa_no_pending_request: '&4Error: &cYou do not have a pending teleport request.'
error_player_not_found: '&4Error: &cCould not find the player %1%.'
return_by_death: '&7Return to where you died?:'
tpa_request_option_select: 'Click an option: '
tpa_accept_button: '[Accept]'
tpa_accept_button_tooltip: 'Accept the teleport request (/tpaccept)'
tpa_decline_button: '[Decline]'
tpa_decline_button_tooltip: 'Decline the teleport request (/tpdeny)'
tpa_you_accepted: '&aYou accepted %1%''s teleport request'
tpa_you_declined: '&cYou declined %1%''s teleport request'
tpa_has_accepted: '&a%1% accepted your teleport request'
Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/Languages/zh-tw.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ error_spawn_undefined: '&4Error: &cThere is no spawn location defined on this se
error_tpa_no_pending_request: '&4錯誤: &c你并沒有等待中的傳送請求.'
error_player_not_found: '&4錯誤: &c找不到玩家->%1%.'
return_by_death: '返回到你死去的地方?:'
tpa_accept_button: '[Accept]'
tpa_accept_button_tooltip: 'Accept the teleport request (/tpaccept)'
tpa_decline_button: '[Decline]'
tpa_decline_button_tooltip: 'Decline the teleport request (/tpdeny)'
tpa_you_accepted: '&a你已接受 %1% 的傳送請求'
tpa_you_declined: '&c你已拒絕 %1% 的傳送請求'
tpa_has_accepted: '&a%1% 接受了你的傳送請求'
Expand Down

0 comments on commit f475637

Please sign in to comment.