1 Commits

Author SHA1 Message Date
lukasabbe 571262fd1d start on plugin 2024-10-31 00:55:29 +01:00
16 changed files with 128 additions and 315 deletions
-44
View File
@@ -1,44 +0,0 @@
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/
- 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
+1
View File
@@ -113,6 +113,7 @@ gradle-app.setting
# Common working directory # Common working directory
run/ run/
runs/
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) # Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
!gradle-wrapper.jar !gradle-wrapper.jar
-21
View File
@@ -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.
-5
View File
@@ -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>
+30 -48
View File
@@ -1,70 +1,52 @@
plugins { plugins {
id 'net.fabricmc.fabric-loom' version '1.15-SNAPSHOT' id 'java'
id 'maven-publish'
} }
version = project.mod_version group = 'me.lukasabbe'
group = project.maven_group version = '1.0+1.21'
base {
archivesName = project.archives_base_name
}
repositories { repositories {
maven { url = 'https://maven.maxhenkel.de/repository/public' } mavenCentral()
maven { maven {
name = "Modrinth" name = "spigotmc-repo"
url = "https://api.modrinth.com/maven" url = "https://hub.spigotmc.org/nexus/content/repositories/snapshots/"
content {
includeGroup "maven.modrinth"
}
} }
maven {
name = "sonatype"
url = "https://oss.sonatype.org/content/groups/public/"
}
maven { url = 'https://maven.maxhenkel.de/repository/public' }
} }
dependencies { dependencies {
// To change the versions see the gradle.properties file compileOnly("org.spigotmc:spigot-api:1.21-R0.1-SNAPSHOT")
minecraft "com.mojang:minecraft:${project.minecraft_version}" implementation("de.maxhenkel.voicechat:voicechat-api:2.5.0")
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}"
runtimeOnly "maven.modrinth:simple-voice-chat:fabric-${voicechat_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 = 25
tasks.withType(JavaCompile).configureEach {
it.options.encoding = "UTF-8"
if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) {
it.options.release.set(targetJavaVersion)
}
} }
def targetJavaVersion = 21
java { java {
def javaVersion = JavaVersion.toVersion(targetJavaVersion) def javaVersion = JavaVersion.toVersion(targetJavaVersion)
sourceCompatibility = javaVersion
targetCompatibility = javaVersion
if (JavaVersion.current() < javaVersion) { if (JavaVersion.current() < javaVersion) {
toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion) toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion)
} }
withSourcesJar()
} }
jar { tasks.withType(JavaCompile).configureEach {
from("LICENSE") { options.encoding = 'UTF-8'
rename { "${it}_${project.archives_base_name}"}
if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) {
options.release.set(targetJavaVersion)
}
}
processResources {
def props = [version: version]
inputs.properties props
filteringCharset 'UTF-8'
filesMatching('plugin.yml') {
expand props
} }
} }
-21
View File
@@ -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=26.1
loader_version=0.18.5
# Mod Properties
mod_version = 1.1+26.1
maven_group = me.lukasabbe
archives_base_name = VoiceChatGroupMsg
#mod dev
voicechat_version=2.6.12+26.1
# Dependencies
# check this on https://modmuss50.me/fabric.html
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
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.8-bin.zip
networkTimeout=10000 networkTimeout=10000
validateDistributionUrl=true validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
Vendored
+1 -1
View File
@@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop. # Darwin, MinGW, and NonStop.
# #
# (3) This script is generated from the Groovy template # (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. # within the Gradle project.
# #
# You can find Gradle at https://github.com/gradle/gradle/. # You can find Gradle at https://github.com/gradle/gradle/.
+1 -9
View File
@@ -1,9 +1 @@
pluginManagement { rootProject.name = 'VoiceChatGroupMsgPlugin'
repositories {
maven {
name = 'Fabric'
url = 'https://maven.fabricmc.net/'
}
gradlePluginPortal()
}
}
@@ -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,19 +0,0 @@
package me.lukasabbe.voicechatgroupmsg;
import me.lukasabbe.voicechatgroupmsg.command.MsgVcCommand;
import net.fabricmc.api.DedicatedServerModInitializer;
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
public class VoiceChatGroupMsg implements DedicatedServerModInitializer {
public final static String MOD_ID = "voicechatgroupmsg";
@Override
public void onInitializeServer() {
registerCommands();
}
private static void registerCommands() {
CommandRegistrationCallback.EVENT.register(MsgVcCommand::CreateGroupMsgCommand);
}
}
@@ -1,64 +0,0 @@
package me.lukasabbe.voicechatgroupmsg.command;
import com.mojang.brigadier.CommandDispatcher;
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.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<CommandSourceStack> dispatcher, CommandBuildContext commandRegistryAccess, Commands.CommandSelection registrationEnvironment) {
dispatcher.register(
Commands
.literal("msgvc")
.requires(CommandSourceStack::isPlayer)
.then(
Commands
.argument("message", MessageArgument.message())
.executes(MsgVcCommand::runCommand)));
}
private static int runCommand(CommandContext<CommandSourceStack> ctx) throws CommandSyntaxException {
final CommandSourceStack source = ctx.getSource();
final ServerPlayer player = source.getPlayer();
if(!VoiceChatUtil.isPlayerInGroup(player)){
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<ServerPlayer> players = VoiceChatUtil.GroupPlayers(group.getId(), source.getLevel());
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, ChatType.TEAM_MSG_COMMAND_INCOMING, source, group);
});
});
return 1;
}
private static void sendMessage(ServerPlayer player, PlayerChatMessage signedMessage, ResourceKey<ChatType> teamMsgCommandOutgoing, CommandSourceStack source, Group group) {
player.sendChatMessage(
OutgoingChatMessage.create(signedMessage),
true,
ChatType.bind(teamMsgCommandOutgoing, source)
.withTargetName(Component.nullToEmpty(group.getName()))
);
}
}
@@ -1,56 +0,0 @@
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.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
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(ServerPlayer player){
try{
return API.getConnectionOf(player.getUUID()).isInGroup();
}catch (NullPointerException ignore){
return false;
}
}
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);
}catch (NullPointerException ignore){
return false;
}
}
public static Group getPlayerGroup(ServerPlayer player){
return API.getConnectionOf(player.getUUID()).getGroup();
}
public static List<ServerPlayer> GroupPlayers(UUID groupUUID, ServerLevel serverWorld){
return serverWorld.getPlayers(player -> isPlayerInGroup(player, groupUUID));
}
}
-26
View File
@@ -1,26 +0,0 @@
{
"schemaVersion": 1,
"id": "voicechatgroupmsg",
"version": "${version}",
"name": "Voice Chat Group Msg",
"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": ["Lukasabbe"],
"contact": {
"repo": "https://github.com/lukasabbe/VoiceChatGroupMsg"
},
"license": "MIT",
"icon": "assets/voicechatgroupmsg/icon.png",
"environment": "server",
"entrypoints": {
"server": [
"me.lukasabbe.voicechatgroupmsg.VoiceChatGroupMsg"
],
"voicechat": [
"me.lukasabbe.voicechatgroupmsg.util.VoiceChatUtil"
]
},
"depends": {
"fabricloader": ">=${loader_version}",
"minecraft": ">=${minecraft_version}"
}
}
+10
View File
@@ -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