diff --git a/core/src/io/anuke/mindustry/core/NetClient.java b/core/src/io/anuke/mindustry/core/NetClient.java index fa1e4075ec..a7d8a9d54f 100644 --- a/core/src/io/anuke/mindustry/core/NetClient.java +++ b/core/src/io/anuke/mindustry/core/NetClient.java @@ -183,7 +183,7 @@ public class NetClient implements ApplicationListener{ } } - private static String colorizeName(int id, String name){ + public static String colorizeName(int id, String name){ Player player = playerGroup.getByID(id); if(name == null || player == null) return null; return "[#" + player.color.toString().toUpperCase() + "]" + name; diff --git a/core/src/io/anuke/mindustry/core/NetServer.java b/core/src/io/anuke/mindustry/core/NetServer.java index 5da463a344..ca95cd39fd 100644 --- a/core/src/io/anuke/mindustry/core/NetServer.java +++ b/core/src/io/anuke/mindustry/core/NetServer.java @@ -219,11 +219,15 @@ public class NetServer implements ApplicationListener{ for(int i = commandsPerPage * page; i < Math.min(commandsPerPage * (page + 1), clientCommands.getCommandList().size); i++){ Command command = clientCommands.getCommandList().get(i); - result.append("[orange] ").append(command.text).append("[white] ").append(command.paramText).append("[lightgray] - ").append(command.description).append("\n"); + result.append("[orange] /").append(command.text).append("[white] ").append(command.paramText).append("[lightgray] - ").append(command.description).append("\n"); } player.sendMessage(result.toString()); }); + clientCommands.register("t", "", "Send a message only to your teammates.", (args, player) -> { + playerGroup.all().each(p -> p.getTeam() == player.getTeam(), o -> o.sendMessage(args[0], player, "[#" + player.getTeam().color.toString() + "]" + NetClient.colorizeName(player.id, player.name))); + }); + //duration of a a kick in seconds int kickDuration = 10 * 60; @@ -263,7 +267,7 @@ public class NetServer implements ApplicationListener{ //current kick sessions ObjectMap currentlyKicking = new ObjectMap<>(); - clientCommands.register("votekick", "[player]", "Vote to kick a player, with a cooldown.", (args, player) -> { + clientCommands.register("votekick", "[player...]", "Vote to kick a player, with a cooldown.", (args, player) -> { if(playerGroup.size() < 3){ player.sendMessage("[scarlet]At least 3 players are needed to start a votekick."); return; diff --git a/core/src/io/anuke/mindustry/entities/type/Player.java b/core/src/io/anuke/mindustry/entities/type/Player.java index 6642030b8b..0b481a6105 100644 --- a/core/src/io/anuke/mindustry/entities/type/Player.java +++ b/core/src/io/anuke/mindustry/entities/type/Player.java @@ -14,6 +14,7 @@ import io.anuke.arc.util.*; import io.anuke.arc.util.pooling.Pools; import io.anuke.mindustry.Vars; import io.anuke.mindustry.content.*; +import io.anuke.mindustry.core.*; import io.anuke.mindustry.entities.*; import io.anuke.mindustry.entities.traits.*; import io.anuke.mindustry.game.*; @@ -775,7 +776,28 @@ public class Player extends Unit implements BuilderMinerTrait, ShooterTrait{ //region utility methods public void sendMessage(String text){ - Call.sendMessage(con.id, text, null, null); + if(isLocal){ + if(Vars.ui != null){ + Log.info("add " + text); + Vars.ui.chatfrag.addMessage(text, null); + } + }else{ + Call.sendMessage(con.id, text, null, null); + } + } + + public void sendMessage(String text, Player from){ + sendMessage(text, from, NetClient.colorizeName(from.id, from.name)); + } + + public void sendMessage(String text, Player from, String fromName){ + if(isLocal){ + if(Vars.ui != null){ + Vars.ui.chatfrag.addMessage(text, fromName); + } + }else{ + Call.sendMessage(con.id, text, fromName, from); + } } /** Resets all values of the player. */