mirror of
https://github.com/lukasabbe/VoiceChatGroupMsg.git
synced 2026-04-30 10:50:53 +00:00
26.1
This commit is contained in:
+5
-6
@@ -1,5 +1,5 @@
|
||||
plugins {
|
||||
id 'fabric-loom' version '1.14-SNAPSHOT'
|
||||
id 'net.fabricmc.fabric-loom' version '1.15-SNAPSHOT'
|
||||
id 'maven-publish'
|
||||
}
|
||||
|
||||
@@ -24,13 +24,12 @@ repositories {
|
||||
dependencies {
|
||||
// To change the versions see the gradle.properties file
|
||||
minecraft "com.mojang:minecraft:${project.minecraft_version}"
|
||||
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
|
||||
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
|
||||
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
|
||||
implementation "net.fabricmc:fabric-loader:${project.loader_version}"
|
||||
implementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
|
||||
|
||||
// Simple Voice chat
|
||||
implementation "de.maxhenkel.voicechat:voicechat-api:${voicechat_api_version}"
|
||||
modRuntimeOnly "maven.modrinth:simple-voice-chat:fabric-${voicechat_version}"
|
||||
runtimeOnly "maven.modrinth:simple-voice-chat:fabric-${voicechat_version}"
|
||||
}
|
||||
|
||||
processResources {
|
||||
@@ -48,7 +47,7 @@ processResources {
|
||||
}
|
||||
}
|
||||
|
||||
def targetJavaVersion = 21
|
||||
def targetJavaVersion = 25
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
it.options.encoding = "UTF-8"
|
||||
if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) {
|
||||
|
||||
+5
-6
@@ -3,20 +3,19 @@ org.gradle.jvmargs=-Xmx1G
|
||||
|
||||
# Fabric Properties
|
||||
# check these on https://modmuss50.me/fabric.html
|
||||
minecraft_version=1.21.11
|
||||
yarn_mappings=1.21.11+build.1
|
||||
loader_version=0.18.2
|
||||
minecraft_version=26.1
|
||||
loader_version=0.18.5
|
||||
|
||||
# Mod Properties
|
||||
mod_version = 1.1+1.21.11
|
||||
mod_version = 1.1+26.1
|
||||
maven_group = me.lukasabbe
|
||||
archives_base_name = VoiceChatGroupMsg
|
||||
|
||||
#mod dev
|
||||
voicechat_version=1.21.11-2.6.6
|
||||
voicechat_version=2.6.12+26.1
|
||||
|
||||
# Dependencies
|
||||
# check this on https://modmuss50.me/fabric.html
|
||||
fabric_version=0.139.4+1.21.11
|
||||
fabric_version=0.144.3+26.1
|
||||
#https://maven.maxhenkel.de/#/releases/de/maxhenkel/voicechat/voicechat-api
|
||||
voicechat_api_version=2.6.0
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.0-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.1-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
|
||||
@@ -5,60 +5,60 @@ import com.mojang.brigadier.context.CommandContext;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import de.maxhenkel.voicechat.api.Group;
|
||||
import me.lukasabbe.voicechatgroupmsg.util.VoiceChatUtil;
|
||||
import net.minecraft.command.CommandRegistryAccess;
|
||||
import net.minecraft.command.argument.MessageArgumentType;
|
||||
import net.minecraft.network.message.MessageType;
|
||||
import net.minecraft.network.message.SentMessage;
|
||||
import net.minecraft.network.message.SignedMessage;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.server.command.CommandManager;
|
||||
import net.minecraft.server.command.ServerCommandSource;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.commands.CommandBuildContext;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.commands.arguments.MessageArgument;
|
||||
import net.minecraft.network.chat.ChatType;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.OutgoingChatMessage;
|
||||
import net.minecraft.network.chat.PlayerChatMessage;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class MsgVcCommand {
|
||||
public static void CreateGroupMsgCommand(CommandDispatcher<ServerCommandSource> dispatcher, CommandRegistryAccess commandRegistryAccess, CommandManager.RegistrationEnvironment registrationEnvironment) {
|
||||
public static void CreateGroupMsgCommand(CommandDispatcher<CommandSourceStack> dispatcher, CommandBuildContext commandRegistryAccess, Commands.CommandSelection registrationEnvironment) {
|
||||
dispatcher.register(
|
||||
CommandManager
|
||||
Commands
|
||||
.literal("msgvc")
|
||||
.requires(ServerCommandSource::isExecutedByPlayer)
|
||||
.requires(CommandSourceStack::isPlayer)
|
||||
.then(
|
||||
CommandManager
|
||||
.argument("message", MessageArgumentType.message())
|
||||
Commands
|
||||
.argument("message", MessageArgument.message())
|
||||
.executes(MsgVcCommand::runCommand)));
|
||||
}
|
||||
|
||||
private static int runCommand(CommandContext<ServerCommandSource> ctx) throws CommandSyntaxException {
|
||||
final ServerCommandSource source = ctx.getSource();
|
||||
private static int runCommand(CommandContext<CommandSourceStack> ctx) throws CommandSyntaxException {
|
||||
final CommandSourceStack source = ctx.getSource();
|
||||
|
||||
final ServerPlayerEntity player = source.getPlayer();
|
||||
final ServerPlayer player = source.getPlayer();
|
||||
if(!VoiceChatUtil.isPlayerInGroup(player)){
|
||||
source.sendError(Text.literal("You need to be in a voice chat group to use this command"));
|
||||
source.sendFailure(Component.literal("You need to be in a voice chat group to use this command"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
Group group = VoiceChatUtil.getPlayerGroup(player);
|
||||
|
||||
List<ServerPlayerEntity> players = VoiceChatUtil.GroupPlayers(group.getId(), source.getWorld());
|
||||
List<ServerPlayer> players = VoiceChatUtil.GroupPlayers(group.getId(), source.getLevel());
|
||||
|
||||
MessageArgumentType.getSignedMessage(ctx, "message", signedMessage -> {
|
||||
sendMessage(player, signedMessage, MessageType.TEAM_MSG_COMMAND_OUTGOING, source, group);
|
||||
MessageArgument.resolveChatMessage(ctx, "message", signedMessage -> {
|
||||
sendMessage(player, signedMessage, ChatType.TEAM_MSG_COMMAND_OUTGOING, source, group);
|
||||
players.forEach(voiceChatMember -> {
|
||||
if(voiceChatMember.getUuid().equals(player.getUuid())) return;
|
||||
sendMessage(voiceChatMember, signedMessage, MessageType.TEAM_MSG_COMMAND_INCOMING, source, group);
|
||||
if(voiceChatMember.getUUID().equals(player.getUUID())) return;
|
||||
sendMessage(voiceChatMember, signedMessage, ChatType.TEAM_MSG_COMMAND_INCOMING, source, group);
|
||||
});
|
||||
});
|
||||
return 1;
|
||||
}
|
||||
|
||||
private static void sendMessage(ServerPlayerEntity player, SignedMessage signedMessage, RegistryKey<MessageType> teamMsgCommandOutgoing, ServerCommandSource source, Group group) {
|
||||
private static void sendMessage(ServerPlayer player, PlayerChatMessage signedMessage, ResourceKey<ChatType> teamMsgCommandOutgoing, CommandSourceStack source, Group group) {
|
||||
player.sendChatMessage(
|
||||
SentMessage.of(signedMessage),
|
||||
OutgoingChatMessage.create(signedMessage),
|
||||
true,
|
||||
MessageType.params(teamMsgCommandOutgoing, source)
|
||||
.withTargetName(Text.of(group.getName()))
|
||||
ChatType.bind(teamMsgCommandOutgoing, source)
|
||||
.withTargetName(Component.nullToEmpty(group.getName()))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,8 +5,8 @@ import de.maxhenkel.voicechat.api.VoicechatPlugin;
|
||||
import de.maxhenkel.voicechat.api.VoicechatServerApi;
|
||||
import de.maxhenkel.voicechat.api.events.EventRegistration;
|
||||
import de.maxhenkel.voicechat.api.events.VoicechatServerStartedEvent;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
@@ -31,26 +31,26 @@ public class VoiceChatUtil implements VoicechatPlugin {
|
||||
API = event.getVoicechat();
|
||||
}
|
||||
|
||||
public static boolean isPlayerInGroup(ServerPlayerEntity player){
|
||||
public static boolean isPlayerInGroup(ServerPlayer player){
|
||||
try{
|
||||
return API.getConnectionOf(player.getUuid()).isInGroup();
|
||||
return API.getConnectionOf(player.getUUID()).isInGroup();
|
||||
}catch (NullPointerException ignore){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public static boolean isPlayerInGroup(ServerPlayerEntity player, UUID groupID){
|
||||
public static boolean isPlayerInGroup(ServerPlayer player, UUID groupID){
|
||||
try{
|
||||
if(!API.getConnectionOf(player.getUuid()).isInGroup()) return false;
|
||||
return API.getConnectionOf(player.getUuid()).getGroup().getId().equals(groupID);
|
||||
if(!API.getConnectionOf(player.getUUID()).isInGroup()) return false;
|
||||
return API.getConnectionOf(player.getUUID()).getGroup().getId().equals(groupID);
|
||||
|
||||
}catch (NullPointerException ignore){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public static Group getPlayerGroup(ServerPlayerEntity player){
|
||||
return API.getConnectionOf(player.getUuid()).getGroup();
|
||||
public static Group getPlayerGroup(ServerPlayer player){
|
||||
return API.getConnectionOf(player.getUUID()).getGroup();
|
||||
}
|
||||
public static List<ServerPlayerEntity> GroupPlayers(UUID groupUUID, ServerWorld serverWorld){
|
||||
public static List<ServerPlayer> GroupPlayers(UUID groupUUID, ServerLevel serverWorld){
|
||||
return serverWorld.getPlayers(player -> isPlayerInGroup(player, groupUUID));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,8 +21,6 @@
|
||||
},
|
||||
"depends": {
|
||||
"fabricloader": ">=${loader_version}",
|
||||
"fabric": "*",
|
||||
"minecraft": ">=${minecraft_version}",
|
||||
"voicechat": ">=${minecraft_version}-${voicechat_api_version}"
|
||||
"minecraft": ">=${minecraft_version}"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user