mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-03-09 20:29:06 +07:00
Added teamchat
This commit is contained in:
parent
ddca5ef25a
commit
233ae99d3f
@ -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;
|
||||
|
@ -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.<Player>register("t", "<message...>", "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() + "]<T>" + 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<Player, VoteSession> currentlyKicking = new ObjectMap<>();
|
||||
|
||||
clientCommands.<Player>register("votekick", "[player]", "Vote to kick a player, with a cooldown.", (args, player) -> {
|
||||
clientCommands.<Player>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;
|
||||
|
@ -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. */
|
||||
|
Loading…
Reference in New Issue
Block a user