Added teamchat
This commit is contained in:
@@ -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);
|
Player player = playerGroup.getByID(id);
|
||||||
if(name == null || player == null) return null;
|
if(name == null || player == null) return null;
|
||||||
return "[#" + player.color.toString().toUpperCase() + "]" + name;
|
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++){
|
for(int i = commandsPerPage * page; i < Math.min(commandsPerPage * (page + 1), clientCommands.getCommandList().size); i++){
|
||||||
Command command = clientCommands.getCommandList().get(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());
|
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
|
//duration of a a kick in seconds
|
||||||
int kickDuration = 10 * 60;
|
int kickDuration = 10 * 60;
|
||||||
|
|
||||||
@@ -263,7 +267,7 @@ public class NetServer implements ApplicationListener{
|
|||||||
//current kick sessions
|
//current kick sessions
|
||||||
ObjectMap<Player, VoteSession> currentlyKicking = new ObjectMap<>();
|
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){
|
if(playerGroup.size() < 3){
|
||||||
player.sendMessage("[scarlet]At least 3 players are needed to start a votekick.");
|
player.sendMessage("[scarlet]At least 3 players are needed to start a votekick.");
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import io.anuke.arc.util.*;
|
|||||||
import io.anuke.arc.util.pooling.Pools;
|
import io.anuke.arc.util.pooling.Pools;
|
||||||
import io.anuke.mindustry.Vars;
|
import io.anuke.mindustry.Vars;
|
||||||
import io.anuke.mindustry.content.*;
|
import io.anuke.mindustry.content.*;
|
||||||
|
import io.anuke.mindustry.core.*;
|
||||||
import io.anuke.mindustry.entities.*;
|
import io.anuke.mindustry.entities.*;
|
||||||
import io.anuke.mindustry.entities.traits.*;
|
import io.anuke.mindustry.entities.traits.*;
|
||||||
import io.anuke.mindustry.game.*;
|
import io.anuke.mindustry.game.*;
|
||||||
@@ -775,8 +776,29 @@ public class Player extends Unit implements BuilderMinerTrait, ShooterTrait{
|
|||||||
//region utility methods
|
//region utility methods
|
||||||
|
|
||||||
public void sendMessage(String text){
|
public void sendMessage(String text){
|
||||||
|
if(isLocal){
|
||||||
|
if(Vars.ui != null){
|
||||||
|
Log.info("add " + text);
|
||||||
|
Vars.ui.chatfrag.addMessage(text, null);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
Call.sendMessage(con.id, text, null, null);
|
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. */
|
/** Resets all values of the player. */
|
||||||
public void reset(){
|
public void reset(){
|
||||||
|
|||||||
Reference in New Issue
Block a user