2 Commits

Author SHA1 Message Date
Lukas f88beaf5e1 Merge pull request #4 from laura-ig1/laura/1.19.2-upstreaming
Port to 1.19.2
2025-09-03 16:36:41 +02:00
laura_ig 1465403036 Port to 1.19.2 2025-08-16 07:17:19 +02:00
6 changed files with 64 additions and 59 deletions
+7 -6
View File
@@ -1,5 +1,5 @@
plugins { plugins {
id 'net.fabricmc.fabric-loom' version '1.15-SNAPSHOT' id 'fabric-loom' version '1.10-SNAPSHOT'
id 'maven-publish' id 'maven-publish'
} }
@@ -24,12 +24,13 @@ repositories {
dependencies { dependencies {
// To change the versions see the gradle.properties file // To change the versions see the gradle.properties file
minecraft "com.mojang:minecraft:${project.minecraft_version}" minecraft "com.mojang:minecraft:${project.minecraft_version}"
implementation "net.fabricmc:fabric-loader:${project.loader_version}" mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
implementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
// Simple Voice chat // Simple Voice chat
implementation "de.maxhenkel.voicechat:voicechat-api:${voicechat_api_version}" implementation "de.maxhenkel.voicechat:voicechat-api:${voicechat_api_version}"
runtimeOnly "maven.modrinth:simple-voice-chat:fabric-${voicechat_version}" modRuntimeOnly "maven.modrinth:simple-voice-chat:fabric-${voicechat_version}"
} }
processResources { processResources {
@@ -47,7 +48,7 @@ processResources {
} }
} }
def targetJavaVersion = 25 def targetJavaVersion = 17
tasks.withType(JavaCompile).configureEach { tasks.withType(JavaCompile).configureEach {
it.options.encoding = "UTF-8" it.options.encoding = "UTF-8"
if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) { if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) {
@@ -65,6 +66,6 @@ java {
jar { jar {
from("LICENSE") { from("LICENSE") {
rename { "${it}_${project.archives_base_name}"} rename { "${it}_${project.archivesBaseName}"}
} }
} }
+8 -6
View File
@@ -3,19 +3,21 @@ org.gradle.jvmargs=-Xmx1G
# Fabric Properties # Fabric Properties
# check these on https://modmuss50.me/fabric.html # check these on https://modmuss50.me/fabric.html
minecraft_version=26.1 minecraft_version=1.19.2
loader_version=0.18.5 yarn_mappings=1.19.2+build.28
loader_version=0.14.14
loom_version=1.10-SNAPSHOT
# Mod Properties # Mod Properties
mod_version = 1.1+26.1 mod_version = 1.1+1.19.2
maven_group = me.lukasabbe maven_group = me.lukasabbe
archives_base_name = VoiceChatGroupMsg archives_base_name = VoiceChatGroupMsg
#mod dev #mod dev
voicechat_version=2.6.12+26.1 voicechat_version=1.19.2-2.5.29
# Dependencies # Dependencies
# check this on https://modmuss50.me/fabric.html # check this on https://modmuss50.me/fabric.html
fabric_version=0.144.3+26.1 fabric_version=0.77.0+1.19.2
#https://maven.maxhenkel.de/#/releases/de/maxhenkel/voicechat/voicechat-api #https://maven.maxhenkel.de/#/releases/de/maxhenkel/voicechat/voicechat-api
voicechat_api_version=2.6.0 voicechat_api_version=2.5.27
+1 -1
View File
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.1-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip
networkTimeout=10000 networkTimeout=10000
validateDistributionUrl=true validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
@@ -5,60 +5,60 @@ import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException; import com.mojang.brigadier.exceptions.CommandSyntaxException;
import de.maxhenkel.voicechat.api.Group; import de.maxhenkel.voicechat.api.Group;
import me.lukasabbe.voicechatgroupmsg.util.VoiceChatUtil; import me.lukasabbe.voicechatgroupmsg.util.VoiceChatUtil;
import net.minecraft.commands.CommandBuildContext; import net.minecraft.command.CommandRegistryAccess;
import net.minecraft.commands.CommandSourceStack; import net.minecraft.command.argument.MessageArgumentType;
import net.minecraft.commands.Commands; import net.minecraft.network.message.MessageType;
import net.minecraft.commands.arguments.MessageArgument; import net.minecraft.network.message.SentMessage;
import net.minecraft.network.chat.ChatType; import net.minecraft.network.message.SignedMessage;
import net.minecraft.network.chat.Component; import net.minecraft.util.registry.RegistryKey;
import net.minecraft.network.chat.OutgoingChatMessage; import net.minecraft.server.command.CommandManager;
import net.minecraft.network.chat.PlayerChatMessage; import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.resources.ResourceKey; import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.level.ServerPlayer; import net.minecraft.text.Text;
import java.util.List; import java.util.List;
public class MsgVcCommand { public class MsgVcCommand {
public static void CreateGroupMsgCommand(CommandDispatcher<CommandSourceStack> dispatcher, CommandBuildContext commandRegistryAccess, Commands.CommandSelection registrationEnvironment) { public static void CreateGroupMsgCommand(CommandDispatcher<ServerCommandSource> dispatcher, CommandRegistryAccess commandRegistryAccess, CommandManager.RegistrationEnvironment registrationEnvironment) {
dispatcher.register( dispatcher.register(
Commands CommandManager
.literal("msgvc") .literal("msgvc")
.requires(CommandSourceStack::isPlayer) .requires(ServerCommandSource::isExecutedByPlayer)
.then( .then(
Commands CommandManager
.argument("message", MessageArgument.message()) .argument("message", MessageArgumentType.message())
.executes(MsgVcCommand::runCommand))); .executes(MsgVcCommand::runCommand)));
} }
private static int runCommand(CommandContext<CommandSourceStack> ctx) throws CommandSyntaxException { private static int runCommand(CommandContext<ServerCommandSource> ctx) throws CommandSyntaxException {
final CommandSourceStack source = ctx.getSource(); final ServerCommandSource source = ctx.getSource();
final ServerPlayer player = source.getPlayer(); final ServerPlayerEntity player = source.getPlayer();
if(!VoiceChatUtil.isPlayerInGroup(player)){ if(!VoiceChatUtil.isPlayerInGroup(player)){
source.sendFailure(Component.literal("You need to be in a voice chat group to use this command")); source.sendError(Text.literal("You need to be in a voice chat group to use this command"));
return 0; return 0;
} }
Group group = VoiceChatUtil.getPlayerGroup(player); Group group = VoiceChatUtil.getPlayerGroup(player);
List<ServerPlayer> players = VoiceChatUtil.GroupPlayers(group.getId(), source.getLevel()); List<ServerPlayerEntity> players = VoiceChatUtil.GroupPlayers(group.getId(), source.getWorld());
MessageArgument.resolveChatMessage(ctx, "message", signedMessage -> { SignedMessage signedMessage = MessageArgumentType.getSignedMessage(ctx, "message").signedArgument();
sendMessage(player, signedMessage, ChatType.TEAM_MSG_COMMAND_OUTGOING, source, group);
sendMessage(player, signedMessage, MessageType.TEAM_MSG_COMMAND_OUTGOING, source, group);
players.forEach(voiceChatMember -> { players.forEach(voiceChatMember -> {
if(voiceChatMember.getUUID().equals(player.getUUID())) return; if(voiceChatMember.getUuid().equals(player.getUuid())) return;
sendMessage(voiceChatMember, signedMessage, ChatType.TEAM_MSG_COMMAND_INCOMING, source, group); sendMessage(voiceChatMember, signedMessage, MessageType.TEAM_MSG_COMMAND_INCOMING, source, group);
});
}); });
return 1; return 1;
} }
private static void sendMessage(ServerPlayer player, PlayerChatMessage signedMessage, ResourceKey<ChatType> teamMsgCommandOutgoing, CommandSourceStack source, Group group) { private static void sendMessage(ServerPlayerEntity player, SignedMessage signedMessage, RegistryKey<MessageType> teamMsgCommandOutgoing, ServerCommandSource source, Group group) {
player.sendChatMessage( player.sendChatMessage(
OutgoingChatMessage.create(signedMessage), SentMessage.of(signedMessage),
true, true,
ChatType.bind(teamMsgCommandOutgoing, source) MessageType.params(teamMsgCommandOutgoing, source)
.withTargetName(Component.nullToEmpty(group.getName())) .withTargetName(Text.of(group.getName()))
); );
} }
} }
@@ -5,8 +5,8 @@ import de.maxhenkel.voicechat.api.VoicechatPlugin;
import de.maxhenkel.voicechat.api.VoicechatServerApi; import de.maxhenkel.voicechat.api.VoicechatServerApi;
import de.maxhenkel.voicechat.api.events.EventRegistration; import de.maxhenkel.voicechat.api.events.EventRegistration;
import de.maxhenkel.voicechat.api.events.VoicechatServerStartedEvent; import de.maxhenkel.voicechat.api.events.VoicechatServerStartedEvent;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.world.ServerWorld;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
@@ -31,26 +31,26 @@ public class VoiceChatUtil implements VoicechatPlugin {
API = event.getVoicechat(); API = event.getVoicechat();
} }
public static boolean isPlayerInGroup(ServerPlayer player){ public static boolean isPlayerInGroup(ServerPlayerEntity player){
try{ try{
return API.getConnectionOf(player.getUUID()).isInGroup(); return API.getConnectionOf(player.getUuid()).isInGroup();
}catch (NullPointerException ignore){ }catch (NullPointerException ignore){
return false; return false;
} }
} }
public static boolean isPlayerInGroup(ServerPlayer 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){
return false; return false;
} }
} }
public static Group getPlayerGroup(ServerPlayer player){ public static Group getPlayerGroup(ServerPlayerEntity player){
return API.getConnectionOf(player.getUUID()).getGroup(); return API.getConnectionOf(player.getUuid()).getGroup();
} }
public static List<ServerPlayer> GroupPlayers(UUID groupUUID, ServerLevel serverWorld){ public static List<ServerPlayerEntity> GroupPlayers(UUID groupUUID, ServerWorld serverWorld){
return serverWorld.getPlayers(player -> isPlayerInGroup(player, groupUUID)); return serverWorld.getPlayers(player -> isPlayerInGroup(player, groupUUID));
} }
} }
+3 -1
View File
@@ -21,6 +21,8 @@
}, },
"depends": { "depends": {
"fabricloader": ">=${loader_version}", "fabricloader": ">=${loader_version}",
"minecraft": ">=${minecraft_version}" "fabric": "*",
"minecraft": ">=${minecraft_version}",
"voicechat": ">=${minecraft_version}-${voicechat_api_version}"
} }
} }