15 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
lukasabbe dd8cf78b93 Fixed up the code a bit 2025-04-22 19:37:13 +02:00
Lukas 9dcededc87 Merge pull request #3 from lukasabbe/1.21.5
1.21.5
2025-04-22 18:37:03 +02:00
lukasabbe 82b94c78ee 1.21.5 2025-04-22 18:37:59 +02:00
Lukas 74a0712878 Merge pull request #2 from lukasabbe/1.21.5
1.21.5
2025-03-25 21:27:10 +01:00
lukasabbe 7075963597 1.21.4 2024-11-29 22:47:12 +01:00
lukasabbe 1c487409a1 1.21.2 version 2024-10-22 19:22:07 +02:00
Lukas da64223e29 Merge pull request #1 from lukasabbe/1.21.2
1.21.2
2024-10-22 19:18:03 +02:00
Lukas e3141bef06 1.21.2-pre4 2024-10-15 18:23:01 +02:00
Lukas 2b650b5e89 Gradle wrapper 2024-10-14 10:27:25 +02:00
Lukas 7633b6918d Loom bump 2024-10-14 10:26:21 +02:00
Lukas 434e07e62e 1.21.2-pre3 2024-10-14 10:24:40 +02:00
lukasabbe c3116f0f6f fixed so it works with newers versions 2024-08-08 22:05:54 +02:00
lukasabbe 0e084d7e7c check on code, fixed some cursed formating 2024-08-07 21:00:51 +02:00
8 changed files with 125 additions and 114 deletions
+12 -5
View File
@@ -1,8 +1,3 @@
# Automatically build the project and run any configured tests for every push
# and submitted pull request. This can help catch issues that only occur on
# certain platforms or Java versions, and provides a first line of defence
# against bad commits.
name: build name: build
on: [pull_request, push] on: [pull_request, push]
@@ -35,3 +30,15 @@ jobs:
with: with:
name: Artifacts name: Artifacts
path: build/libs/ path: build/libs/
- name: Read values from gradle properties file
id: read_property
uses: christian-draeger/read-properties@1.1.1
with:
path: "./gradle.properties"
properties: "mod_version minecraft_version archives_base_name"
- name: Upload artifacts to discord
uses: tsickert/discord-webhook@v6.0.0
with:
webhook-url: ${{ secrets.WEBHOOK_URL }}
content: "Git hub action build. **THIS MAY NOT BE A FUNCTIONAL BUILD**\nMod: ${{steps.read_property.outputs.archives_base_name}}\nMCVersion: ${{steps.read_property.outputs.minecraft_version}}\nMod version: ${{steps.read_property.outputs.mod_version}}"
filename: build/libs/${{ steps.read_property.outputs.archives_base_name }}-${{steps.read_property.outputs.mod_version}}.jar
+5 -30
View File
@@ -1,5 +1,5 @@
plugins { plugins {
id 'fabric-loom' version '1.6-SNAPSHOT' id 'fabric-loom' version '1.10-SNAPSHOT'
id 'maven-publish' id 'maven-publish'
} }
@@ -26,11 +26,11 @@ dependencies {
minecraft "com.mojang:minecraft:${project.minecraft_version}" minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
modRuntimeOnly "maven.modrinth:simple-voice-chat:fabric-${voicechat_version}"
// Fabric API. This is technically optional, but you probably want it anyway.
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
// Simple Voice chat
implementation "de.maxhenkel.voicechat:voicechat-api:${voicechat_api_version}" implementation "de.maxhenkel.voicechat:voicechat-api:${voicechat_api_version}"
modRuntimeOnly "maven.modrinth:simple-voice-chat:fabric-${voicechat_version}"
} }
processResources { processResources {
@@ -48,12 +48,8 @@ processResources {
} }
} }
def targetJavaVersion = 21 def targetJavaVersion = 17
tasks.withType(JavaCompile).configureEach { tasks.withType(JavaCompile).configureEach {
// ensure that the encoding is set to UTF-8, no matter what the system default is
// this fixes some edge cases with special characters not displaying correctly
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
// If Javadoc is generated, this must be specified in that task too.
it.options.encoding = "UTF-8" it.options.encoding = "UTF-8"
if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) { if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) {
it.options.release.set(targetJavaVersion) it.options.release.set(targetJavaVersion)
@@ -65,9 +61,6 @@ java {
if (JavaVersion.current() < javaVersion) { if (JavaVersion.current() < javaVersion) {
toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion) toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion)
} }
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this line, sources will not be generated.
withSourcesJar() withSourcesJar()
} }
@@ -76,21 +69,3 @@ jar {
rename { "${it}_${project.archivesBaseName}"} rename { "${it}_${project.archivesBaseName}"}
} }
} }
// configure the maven publication
publishing {
publications {
create("mavenJava", MavenPublication) {
artifactId = project.archives_base_name
from components.java
}
}
// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
repositories {
// Add repositories to publish to here.
// Notice: This block does NOT have the same function as the block in the top level.
// The repositories here will be used for publishing your artifact, not for
// retrieving dependencies.
}
}
+9 -7
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=1.21 minecraft_version=1.19.2
yarn_mappings=1.21+build.9 yarn_mappings=1.19.2+build.28
loader_version=0.15.11 loader_version=0.14.14
loom_version=1.10-SNAPSHOT
# Mod Properties # Mod Properties
mod_version = 1.0 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=1.21-2.5.17 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.100.7+1.21 fabric_version=0.77.0+1.19.2
voicechat_api_version=2.5.0 #https://maven.maxhenkel.de/#/releases/de/maxhenkel/voicechat/voicechat-api
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-8.7-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
@@ -1,60 +1,19 @@
package me.lukasabbe.voicechatgroupmsg; package me.lukasabbe.voicechatgroupmsg;
import de.maxhenkel.voicechat.api.Group; import me.lukasabbe.voicechatgroupmsg.command.MsgVcCommand;
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.fabricmc.api.DedicatedServerModInitializer; import net.fabricmc.api.DedicatedServerModInitializer;
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback; import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerWorld;
import java.util.List; public class VoiceChatGroupMsg implements DedicatedServerModInitializer {
import java.util.UUID;
public class VoiceChatGroupMsg implements DedicatedServerModInitializer, VoicechatPlugin {
public final static String MOD_ID = "voicechatgroupmsg"; public final static String MOD_ID = "voicechatgroupmsg";
private static VoicechatServerApi API = null;
@Override @Override
public void onInitializeServer() { public void onInitializeServer() {
CommandRegistrationCallback.EVENT.register(Commands::CreateGroupMsgCommand); registerCommands();
} }
@Override private static void registerCommands() {
public String getPluginId() { CommandRegistrationCallback.EVENT.register(MsgVcCommand::CreateGroupMsgCommand);
return MOD_ID;
}
@Override
public void registerEvents(EventRegistration registration) {
registration.registerEvent(VoicechatServerStartedEvent.class, this::onServerStarted);
}
public void onServerStarted(VoicechatServerStartedEvent event) {
API = event.getVoicechat();
}
public static boolean isPlayerInGroup(ServerPlayerEntity player){
try{
return API.getConnectionOf(player.getUuid()).isInGroup();
}catch (NullPointerException ignore){
return false;
}
}
public static boolean isPlayerInGroup(ServerPlayerEntity player, UUID groupID){
try{
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 List<ServerPlayerEntity> GroupPlayers(UUID groupUUID, ServerWorld serverWorld){
return serverWorld.getPlayers(player -> isPlayerInGroup(player, groupUUID));
} }
} }
@@ -1,13 +1,16 @@
package me.lukasabbe.voicechatgroupmsg; package me.lukasabbe.voicechatgroupmsg.command;
import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.context.CommandContext; 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 net.minecraft.command.CommandRegistryAccess; import net.minecraft.command.CommandRegistryAccess;
import net.minecraft.command.argument.MessageArgumentType; import net.minecraft.command.argument.MessageArgumentType;
import net.minecraft.network.message.MessageType; import net.minecraft.network.message.MessageType;
import net.minecraft.network.message.SentMessage; import net.minecraft.network.message.SentMessage;
import net.minecraft.network.message.SignedMessage;
import net.minecraft.util.registry.RegistryKey;
import net.minecraft.server.command.CommandManager; import net.minecraft.server.command.CommandManager;
import net.minecraft.server.command.ServerCommandSource; import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.network.ServerPlayerEntity;
@@ -15,38 +18,47 @@ import net.minecraft.text.Text;
import java.util.List; import java.util.List;
public class Commands { public class MsgVcCommand {
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")
.requires(ServerCommandSource::isExecutedByPlayer)
.then( .then(
CommandManager CommandManager
.argument("message", MessageArgumentType.message()) .argument("message", MessageArgumentType.message())
.executes(Commands::runCommand))); .executes(MsgVcCommand::runCommand)));
} }
private static int runCommand(CommandContext<ServerCommandSource> ctx) throws CommandSyntaxException { private static int runCommand(CommandContext<ServerCommandSource> ctx) throws CommandSyntaxException {
final ServerCommandSource source = ctx.getSource(); final ServerCommandSource source = ctx.getSource();
if(!source.isExecutedByPlayer()) {
source.sendError(Text.literal("You can't send msgvc as the console"));
return 0;
}
final ServerPlayerEntity player = source.getPlayer(); final ServerPlayerEntity player = source.getPlayer();
if(!VoiceChatGroupMsg.isPlayerInGroup(player)){ if(!VoiceChatUtil.isPlayerInGroup(player)){
source.sendError(Text.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 = VoiceChatGroupMsg.getPlayerGroup(player);
List<ServerPlayerEntity> players = VoiceChatGroupMsg.GroupPlayers(group.getId(), source.getWorld()); Group group = VoiceChatUtil.getPlayerGroup(player);
MessageArgumentType.getSignedMessage(ctx, "message", signedMessage -> {
player.sendChatMessage(SentMessage.of(signedMessage),true, MessageType.params(MessageType.TEAM_MSG_COMMAND_OUTGOING,source).withTargetName(Text.of(group.getName()))); List<ServerPlayerEntity> players = VoiceChatUtil.GroupPlayers(group.getId(), source.getWorld());
players.forEach(player1 -> {
if(!player1.getUuid().equals(source.getPlayer().getUuid())){ SignedMessage signedMessage = MessageArgumentType.getSignedMessage(ctx, "message").signedArgument();
player1.sendChatMessage(SentMessage.of(signedMessage),true, MessageType.params(MessageType.TEAM_MSG_COMMAND_INCOMING,source).withTargetName(Text.of(group.getName())));
} sendMessage(player, signedMessage, MessageType.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);
}); });
return 1; return 1;
} }
private static void sendMessage(ServerPlayerEntity player, SignedMessage signedMessage, RegistryKey<MessageType> teamMsgCommandOutgoing, ServerCommandSource source, Group group) {
player.sendChatMessage(
SentMessage.of(signedMessage),
true,
MessageType.params(teamMsgCommandOutgoing, source)
.withTargetName(Text.of(group.getName()))
);
}
} }
@@ -0,0 +1,56 @@
package me.lukasabbe.voicechatgroupmsg.util;
import de.maxhenkel.voicechat.api.Group;
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 java.util.List;
import java.util.UUID;
import static me.lukasabbe.voicechatgroupmsg.VoiceChatGroupMsg.MOD_ID;
public class VoiceChatUtil implements VoicechatPlugin {
private static VoicechatServerApi API = null;
@Override
public String getPluginId() {
return MOD_ID;
}
@Override
public void registerEvents(EventRegistration registration) {
registration.registerEvent(VoicechatServerStartedEvent.class, this::onServerStarted);
}
public void onServerStarted(VoicechatServerStartedEvent event) {
API = event.getVoicechat();
}
public static boolean isPlayerInGroup(ServerPlayerEntity player){
try{
return API.getConnectionOf(player.getUuid()).isInGroup();
}catch (NullPointerException ignore){
return false;
}
}
public static boolean isPlayerInGroup(ServerPlayerEntity player, UUID groupID){
try{
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 List<ServerPlayerEntity> GroupPlayers(UUID groupUUID, ServerWorld serverWorld){
return serverWorld.getPlayers(player -> isPlayerInGroup(player, groupUUID));
}
}
+6 -6
View File
@@ -2,11 +2,11 @@
"schemaVersion": 1, "schemaVersion": 1,
"id": "voicechatgroupmsg", "id": "voicechatgroupmsg",
"version": "${version}", "version": "${version}",
"name": "VoiceChatGroupMsg", "name": "Voice Chat Group Msg",
"description": "", "description": "Adds a way to message a whole group if you don't have a microphone. When you are in a group you can now use /msgvc <message>",
"authors": [], "authors": ["Lukasabbe"],
"contact": { "contact": {
"repo": "https://github.com/lukas/VoiceChatGroupMsg" "repo": "https://github.com/lukasabbe/VoiceChatGroupMsg"
}, },
"license": "MIT", "license": "MIT",
"icon": "assets/voicechatgroupmsg/icon.png", "icon": "assets/voicechatgroupmsg/icon.png",
@@ -16,13 +16,13 @@
"me.lukasabbe.voicechatgroupmsg.VoiceChatGroupMsg" "me.lukasabbe.voicechatgroupmsg.VoiceChatGroupMsg"
], ],
"voicechat": [ "voicechat": [
"me.lukasabbe.voicechatgroupmsg.VoiceChatGroupMsg" "me.lukasabbe.voicechatgroupmsg.util.VoiceChatUtil"
] ]
}, },
"depends": { "depends": {
"fabricloader": ">=${loader_version}", "fabricloader": ">=${loader_version}",
"fabric": "*", "fabric": "*",
"minecraft": "${minecraft_version}", "minecraft": ">=${minecraft_version}",
"voicechat": ">=${minecraft_version}-${voicechat_api_version}" "voicechat": ">=${minecraft_version}-${voicechat_api_version}"
} }
} }