Skip to content

Commit

Permalink
Added a way to send a team-private-message using /t <msg>.
Browse files Browse the repository at this point in the history
  • Loading branch information
AmauryCarrade committed Jul 28, 2014
1 parent fde2954 commit 37d3b99
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/main/java/me/azenet/UHPlugin/UHPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ public void onEnable() {
getCommand("uh").setExecutor(commandManager);
getCommand("uh").setTabCompleter(new UHTabCompleter(this));

getCommand("t").setExecutor(commandManager);

getServer().getPluginManager().registerEvents(new UHPluginListener(this), this);

addRecipes();
Expand Down
44 changes: 43 additions & 1 deletion src/main/java/me/azenet/UHPlugin/UHPluginCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,15 @@ public UHPluginCommand(UHPlugin p) {
@SuppressWarnings("rawtypes")
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!command.getName().equalsIgnoreCase("uh")) {
if (!command.getName().equalsIgnoreCase("uh") && !command.getName().equalsIgnoreCase("t")) {
return false;
}

if(command.getName().equalsIgnoreCase("t")) { // Special case for /t command
doTeamMessage(sender, command, label, args);
return true;
}

if(args.length == 0) {
help(sender, false);
return true;
Expand Down Expand Up @@ -832,6 +837,43 @@ else if(distance > 25) {
}


/**
* This command, /t <message>, is used to send a team-message.
*
* @param sender
* @param command
* @param label
* @param args
*/
private void doTeamMessage(CommandSender sender, Command command, String label, String[] args) {
if(!(sender instanceof Player)) {
sender.sendMessage(i.t("team.message.noConsole"));
return;
}

if(args.length == 0) { // /t
sender.sendMessage(i.t("team.message.usage"));
return;
}

UHTeam team = p.getTeamManager().getTeamForPlayer((Player) sender);

if(team == null) {
sender.sendMessage(i.t("team.message.noTeam"));
return;
}

String message = "";
for(Integer i = 0; i < args.length; i++) {
message += args[i] + " ";
}

for(final Player player : team.getPlayers()) {
player.sendMessage(i.t("team.message.format", ((Player) sender).getDisplayName(), message));
}
}



public ArrayList<String> getCommands() {
return commands;
Expand Down
9 changes: 8 additions & 1 deletion src/main/resources/i18n/en_US.yml
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,14 @@ keys:

reset:
success: "{cs}All teams where removed."


message:
noConsole: "{ce}You can't send a team-message from the console."
noTeam: "{ce}You are not in a team!"
usage: "{ce}Usage: /t <message>"

format: "{gold}[{0}{gold} -> his team] {reset}{1}"

shift:
consoleName: "the console"
cantNotStarted: "{ce}You can't shift the current episode because the game is not started."
Expand Down
7 changes: 7 additions & 0 deletions src/main/resources/i18n/fr_FR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,13 @@ keys:

reset:
success: "{cs}Toutes les équipes ont été supprimées."

message:
noConsole: "{ce}Vous ne pouvez envoyer un message d'équipe depuis la console."
noTeam: "{ce}Vous n'êtes pas dans une équipe !"
usage: "{ce}Utilisation : /t <message>"

format: "{gold}[{0}{gold} -> son équipe] {reset}{1}"

shift:
consoleName: "la console"
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ commands:
uh:
description: Ultra Harcore base command
usage: /uh <subcommand> - see /uh for available subcommands.
t:
description: Allows an user to send a message to his team.
usage: /t <message>

permissions:
uh.*:
Expand Down

0 comments on commit 37d3b99

Please sign in to comment.