mirror of
https://github.com/lukasabbe/VoiceChatGroupMsg.git
synced 2026-04-30 10:50:53 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 571262fd1d |
@@ -1,37 +0,0 @@
|
||||
# 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
|
||||
on: [pull_request, push]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
strategy:
|
||||
matrix:
|
||||
# Use these Java versions
|
||||
java: [
|
||||
21, # Current Java LTS
|
||||
]
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- name: checkout repository
|
||||
uses: actions/checkout@v4
|
||||
- name: validate gradle wrapper
|
||||
uses: gradle/wrapper-validation-action@v2
|
||||
- name: setup jdk ${{ matrix.java }}
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
java-version: ${{ matrix.java }}
|
||||
distribution: 'microsoft'
|
||||
- name: make gradle wrapper executable
|
||||
run: chmod +x ./gradlew
|
||||
- name: build
|
||||
run: ./gradlew build
|
||||
- name: capture build artifacts
|
||||
if: ${{ matrix.java == '21' }} # Only upload artifacts built from latest java
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: Artifacts
|
||||
path: build/libs/
|
||||
@@ -113,6 +113,7 @@ gradle-app.setting
|
||||
|
||||
# Common working directory
|
||||
run/
|
||||
runs/
|
||||
|
||||
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
|
||||
!gradle-wrapper.jar
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2024
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
@@ -1,5 +0,0 @@
|
||||
# Simple voice chat group message system
|
||||
It comes with a new command to write to other players in your voice chat group.
|
||||
|
||||
# Commands
|
||||
/msgvc <message>
|
||||
+25
-69
@@ -1,96 +1,52 @@
|
||||
plugins {
|
||||
id 'fabric-loom' version '1.6-SNAPSHOT'
|
||||
id 'maven-publish'
|
||||
id 'java'
|
||||
}
|
||||
|
||||
version = project.mod_version
|
||||
group = project.maven_group
|
||||
|
||||
base {
|
||||
archivesName = project.archives_base_name
|
||||
}
|
||||
group = 'me.lukasabbe'
|
||||
version = '1.0+1.21'
|
||||
|
||||
repositories {
|
||||
maven { url = 'https://maven.maxhenkel.de/repository/public' }
|
||||
mavenCentral()
|
||||
maven {
|
||||
name = "Modrinth"
|
||||
url = "https://api.modrinth.com/maven"
|
||||
content {
|
||||
includeGroup "maven.modrinth"
|
||||
name = "spigotmc-repo"
|
||||
url = "https://hub.spigotmc.org/nexus/content/repositories/snapshots/"
|
||||
}
|
||||
maven {
|
||||
name = "sonatype"
|
||||
url = "https://oss.sonatype.org/content/groups/public/"
|
||||
}
|
||||
maven { url = 'https://maven.maxhenkel.de/repository/public' }
|
||||
}
|
||||
|
||||
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}"
|
||||
modRuntimeOnly "maven.modrinth:simple-voice-chat:fabric-${voicechat_version}"
|
||||
compileOnly("org.spigotmc:spigot-api:1.21-R0.1-SNAPSHOT")
|
||||
implementation("de.maxhenkel.voicechat:voicechat-api:2.5.0")
|
||||
|
||||
// Fabric API. This is technically optional, but you probably want it anyway.
|
||||
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
|
||||
implementation "de.maxhenkel.voicechat:voicechat-api:${voicechat_api_version}"
|
||||
}
|
||||
|
||||
processResources {
|
||||
inputs.property "version", project.version
|
||||
inputs.property "minecraft_version", project.minecraft_version
|
||||
inputs.property "loader_version", project.loader_version
|
||||
inputs.property "voicechat_api_version", project.voicechat_api_version
|
||||
filteringCharset "UTF-8"
|
||||
|
||||
filesMatching("fabric.mod.json") {
|
||||
expand "version": project.version,
|
||||
"minecraft_version": project.minecraft_version,
|
||||
"loader_version": project.loader_version,
|
||||
"voicechat_api_version": project.voicechat_api_version
|
||||
}
|
||||
}
|
||||
|
||||
def targetJavaVersion = 21
|
||||
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"
|
||||
if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) {
|
||||
it.options.release.set(targetJavaVersion)
|
||||
}
|
||||
}
|
||||
|
||||
java {
|
||||
def javaVersion = JavaVersion.toVersion(targetJavaVersion)
|
||||
sourceCompatibility = javaVersion
|
||||
targetCompatibility = javaVersion
|
||||
if (JavaVersion.current() < javaVersion) {
|
||||
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()
|
||||
}
|
||||
|
||||
jar {
|
||||
from("LICENSE") {
|
||||
rename { "${it}_${project.archivesBaseName}"}
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
options.encoding = 'UTF-8'
|
||||
|
||||
if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) {
|
||||
options.release.set(targetJavaVersion)
|
||||
}
|
||||
}
|
||||
|
||||
// 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.
|
||||
processResources {
|
||||
def props = [version: version]
|
||||
inputs.properties props
|
||||
filteringCharset 'UTF-8'
|
||||
filesMatching('plugin.yml') {
|
||||
expand props
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
# Done to increase the memory available to gradle.
|
||||
org.gradle.jvmargs=-Xmx1G
|
||||
|
||||
# Fabric Properties
|
||||
# check these on https://modmuss50.me/fabric.html
|
||||
minecraft_version=1.21
|
||||
yarn_mappings=1.21+build.9
|
||||
loader_version=0.15.11
|
||||
|
||||
# Mod Properties
|
||||
mod_version = 1.0
|
||||
maven_group = me.lukasabbe
|
||||
archives_base_name = VoiceChatGroupMsg
|
||||
|
||||
#mod dev
|
||||
voicechat_version=1.21-2.5.17
|
||||
|
||||
# Dependencies
|
||||
# check this on https://modmuss50.me/fabric.html
|
||||
fabric_version=0.100.7+1.21
|
||||
voicechat_api_version=2.5.0
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
|
||||
@@ -55,7 +55,7 @@
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
|
||||
+1
-9
@@ -1,9 +1 @@
|
||||
pluginManagement {
|
||||
repositories {
|
||||
maven {
|
||||
name = 'Fabric'
|
||||
url = 'https://maven.fabricmc.net/'
|
||||
}
|
||||
gradlePluginPortal()
|
||||
}
|
||||
}
|
||||
rootProject.name = 'VoiceChatGroupMsgPlugin'
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package me.lukasabbe.voiceChatGroupMsgPlugin;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class MsgVCCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
|
||||
if(!(commandSender instanceof Player)){
|
||||
commandSender.sendMessage("only players can execute this command");
|
||||
return false;
|
||||
}
|
||||
if(strings.length == 0){
|
||||
commandSender.sendMessage("Make sure to write a message");
|
||||
return false;
|
||||
}
|
||||
final Player player = (Player) commandSender;
|
||||
if(!VoiceChatGroupMsgPlugin.isPlayerInGroup(player)){
|
||||
commandSender.sendMessage("You need to be in a voice chat group to use this command");
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package me.lukasabbe.voiceChatGroupMsgPlugin;
|
||||
|
||||
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 org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public final class VoiceChatGroupMsgPlugin extends JavaPlugin implements VoicechatPlugin {
|
||||
private static VoicechatServerApi API = null;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
this.getCommand("msgvc").setExecutor(new MsgVCCommand());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPluginId() {
|
||||
return "voice_chat_group_msg_plugin";
|
||||
}
|
||||
@Override
|
||||
public void registerEvents(EventRegistration registration) {
|
||||
registration.registerEvent(VoicechatServerStartedEvent.class, this::onServerStarted);
|
||||
}
|
||||
|
||||
public void onServerStarted(VoicechatServerStartedEvent event) {
|
||||
API = event.getVoicechat();
|
||||
}
|
||||
|
||||
public static boolean isPlayerInGroup(Player player){
|
||||
try{
|
||||
return API.getConnectionOf(player.getUniqueId()).isInGroup();
|
||||
}catch (NullPointerException ignore){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public static boolean isPlayerInGroup(Player player, UUID groupID){
|
||||
try{
|
||||
if(!API.getConnectionOf(player.getUniqueId()).isInGroup()) return false;
|
||||
return API.getConnectionOf(player.getUniqueId()).getGroup().getId().equals(groupID);
|
||||
|
||||
}catch (NullPointerException ignore){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public static Group getPlayerGroup(Player player){
|
||||
return API.getConnectionOf(player.getUniqueId()).getGroup();
|
||||
}
|
||||
public static List<Player> GroupPlayers(UUID groupUUID, World serverWorld){
|
||||
return serverWorld.getPlayers().stream().filter(p -> isPlayerInGroup(p, groupUUID)).toList();
|
||||
}
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
package me.lukasabbe.voicechatgroupmsg;
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import de.maxhenkel.voicechat.api.Group;
|
||||
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.server.command.CommandManager;
|
||||
import net.minecraft.server.command.ServerCommandSource;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Commands {
|
||||
public static void CreateGroupMsgCommand(CommandDispatcher<ServerCommandSource> dispatcher, CommandRegistryAccess commandRegistryAccess, CommandManager.RegistrationEnvironment registrationEnvironment) {
|
||||
dispatcher.register(
|
||||
CommandManager
|
||||
.literal("msgvc")
|
||||
.then(
|
||||
CommandManager
|
||||
.argument("message", MessageArgumentType.message())
|
||||
.executes(Commands::runCommand)));
|
||||
}
|
||||
|
||||
private static int runCommand(CommandContext<ServerCommandSource> ctx) throws CommandSyntaxException {
|
||||
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();
|
||||
if(!VoiceChatGroupMsg.isPlayerInGroup(player)){
|
||||
source.sendError(Text.literal("You need to be in a voice chat group to use this command"));
|
||||
return 0;
|
||||
}
|
||||
Group group = VoiceChatGroupMsg.getPlayerGroup(player);
|
||||
List<ServerPlayerEntity> players = VoiceChatGroupMsg.GroupPlayers(group.getId(), source.getWorld());
|
||||
MessageArgumentType.getSignedMessage(ctx, "message", signedMessage -> {
|
||||
player.sendChatMessage(SentMessage.of(signedMessage),true, MessageType.params(MessageType.TEAM_MSG_COMMAND_OUTGOING,source).withTargetName(Text.of(group.getName())));
|
||||
players.forEach(player1 -> {
|
||||
if(!player1.getUuid().equals(source.getPlayer().getUuid())){
|
||||
player1.sendChatMessage(SentMessage.of(signedMessage),true, MessageType.params(MessageType.TEAM_MSG_COMMAND_INCOMING,source).withTargetName(Text.of(group.getName())));
|
||||
}
|
||||
});
|
||||
});
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
package me.lukasabbe.voicechatgroupmsg;
|
||||
|
||||
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.fabricmc.api.DedicatedServerModInitializer;
|
||||
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class VoiceChatGroupMsg implements DedicatedServerModInitializer, VoicechatPlugin {
|
||||
public final static String MOD_ID = "voicechatgroupmsg";
|
||||
private static VoicechatServerApi API = null;
|
||||
@Override
|
||||
public void onInitializeServer() {
|
||||
CommandRegistrationCallback.EVENT.register(Commands::CreateGroupMsgCommand);
|
||||
}
|
||||
|
||||
@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));
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
{
|
||||
"schemaVersion": 1,
|
||||
"id": "voicechatgroupmsg",
|
||||
"version": "${version}",
|
||||
"name": "VoiceChatGroupMsg",
|
||||
"description": "",
|
||||
"authors": [],
|
||||
"contact": {
|
||||
"repo": "https://github.com/lukas/VoiceChatGroupMsg"
|
||||
},
|
||||
"license": "MIT",
|
||||
"icon": "assets/voicechatgroupmsg/icon.png",
|
||||
"environment": "server",
|
||||
"entrypoints": {
|
||||
"server": [
|
||||
"me.lukasabbe.voicechatgroupmsg.VoiceChatGroupMsg"
|
||||
],
|
||||
"voicechat": [
|
||||
"me.lukasabbe.voicechatgroupmsg.VoiceChatGroupMsg"
|
||||
]
|
||||
},
|
||||
"depends": {
|
||||
"fabricloader": ">=${loader_version}",
|
||||
"fabric": "*",
|
||||
"minecraft": "${minecraft_version}",
|
||||
"voicechat": ">=${minecraft_version}-${voicechat_api_version}"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
name: VoiceChatGroupMsgPlugin
|
||||
version: '1.0+1.21'
|
||||
main: me.lukasabbe.voiceChatGroupMsgPlugin.VoiceChatGroupMsgPlugin
|
||||
api-version: '1.21'
|
||||
authors: [ Lukasabbe ]
|
||||
depend: [ voicechat ]
|
||||
commands:
|
||||
msgvc:
|
||||
description: Send a msg to the voicechat group you are in
|
||||
usage: /<command> message
|
||||
Reference in New Issue
Block a user