mirror of
https://github.com/lukasabbe/VoiceChatGroupMsg.git
synced 2026-04-30 10:50:53 +00:00
check on code, fixed some cursed formating
This commit is contained in:
@@ -17,13 +17,11 @@ import java.util.List;
|
|||||||
|
|
||||||
public class Commands {
|
public class Commands {
|
||||||
public static void CreateGroupMsgCommand(CommandDispatcher<ServerCommandSource> dispatcher, CommandRegistryAccess commandRegistryAccess, CommandManager.RegistrationEnvironment registrationEnvironment) {
|
public static void CreateGroupMsgCommand(CommandDispatcher<ServerCommandSource> dispatcher, CommandRegistryAccess commandRegistryAccess, CommandManager.RegistrationEnvironment registrationEnvironment) {
|
||||||
dispatcher.register(
|
dispatcher.register(CommandManager
|
||||||
CommandManager
|
.literal("msgvc")
|
||||||
.literal("msgvc")
|
.then(CommandManager
|
||||||
.then(
|
.argument("message", MessageArgumentType.message())
|
||||||
CommandManager
|
.executes(Commands::runCommand)));
|
||||||
.argument("message", MessageArgumentType.message())
|
|
||||||
.executes(Commands::runCommand)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int runCommand(CommandContext<ServerCommandSource> ctx) throws CommandSyntaxException {
|
private static int runCommand(CommandContext<ServerCommandSource> ctx) throws CommandSyntaxException {
|
||||||
@@ -40,10 +38,16 @@ public class Commands {
|
|||||||
Group group = VoiceChatGroupMsg.getPlayerGroup(player);
|
Group group = VoiceChatGroupMsg.getPlayerGroup(player);
|
||||||
List<ServerPlayerEntity> players = VoiceChatGroupMsg.GroupPlayers(group.getId(), source.getWorld());
|
List<ServerPlayerEntity> players = VoiceChatGroupMsg.GroupPlayers(group.getId(), source.getWorld());
|
||||||
MessageArgumentType.getSignedMessage(ctx, "message", signedMessage -> {
|
MessageArgumentType.getSignedMessage(ctx, "message", signedMessage -> {
|
||||||
player.sendChatMessage(SentMessage.of(signedMessage),true, MessageType.params(MessageType.TEAM_MSG_COMMAND_OUTGOING,source).withTargetName(Text.of(group.getName())));
|
player.sendChatMessage(
|
||||||
|
SentMessage.of(signedMessage),
|
||||||
|
true,
|
||||||
|
MessageType.params(MessageType.TEAM_MSG_COMMAND_OUTGOING,source).withTargetName(Text.of(group.getName())));
|
||||||
players.forEach(player1 -> {
|
players.forEach(player1 -> {
|
||||||
if(!player1.getUuid().equals(source.getPlayer().getUuid())){
|
if(!player1.getUuid().equals(player.getUuid())){
|
||||||
player1.sendChatMessage(SentMessage.of(signedMessage),true, MessageType.params(MessageType.TEAM_MSG_COMMAND_INCOMING,source).withTargetName(Text.of(group.getName())));
|
player1.sendChatMessage(
|
||||||
|
SentMessage.of(signedMessage),
|
||||||
|
true,
|
||||||
|
MessageType.params(MessageType.TEAM_MSG_COMMAND_INCOMING,source).withTargetName(Text.of(group.getName())));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ public class VoiceChatGroupMsg implements DedicatedServerModInitializer, Voicech
|
|||||||
}
|
}
|
||||||
public static boolean isPlayerInGroup(ServerPlayerEntity player, UUID groupID){
|
public static boolean isPlayerInGroup(ServerPlayerEntity player, UUID groupID){
|
||||||
try{
|
try{
|
||||||
if(!API.getConnectionOf(player.getUuid()).isInGroup())return false;
|
if(!API.getConnectionOf(player.getUuid()).isInGroup()) return false;
|
||||||
return API.getConnectionOf(player.getUuid()).getGroup().getId().equals(groupID);
|
return API.getConnectionOf(player.getUuid()).getGroup().getId().equals(groupID);
|
||||||
|
|
||||||
}catch (NullPointerException ignore){
|
}catch (NullPointerException ignore){
|
||||||
|
|||||||
Reference in New Issue
Block a user