mirror of
https://github.com/raws/minecraft-forge-mattercraft.git
synced 2025-09-22 11:54:39 -04:00
Serialize outgoing messages as JSON
* Add dependency on Gson 2.8.0. * Clean up build.gradle.
This commit is contained in:
parent
0478b69a6b
commit
46f0605718
31
build.gradle
31
build.gradle
@ -9,11 +9,12 @@ buildscript {
|
||||
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '3.+', changing: true
|
||||
}
|
||||
}
|
||||
|
||||
apply plugin: 'net.minecraftforge.gradle'
|
||||
apply plugin: 'eclipse'
|
||||
apply plugin: 'maven-publish'
|
||||
|
||||
version = '0.1'
|
||||
version = '1.16.4-0.0.1.0'
|
||||
group = 'com.rosspaffett.mattercraft'
|
||||
archivesBaseName = 'mattercraft'
|
||||
|
||||
@ -22,8 +23,6 @@ sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = co
|
||||
|
||||
minecraft {
|
||||
mappings channel: 'snapshot', version: '20201028-1.16.3'
|
||||
|
||||
// accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
|
||||
|
||||
runs {
|
||||
client {
|
||||
@ -33,7 +32,7 @@ minecraft {
|
||||
property 'forge.logging.console.level', 'debug'
|
||||
|
||||
mods {
|
||||
examplemod {
|
||||
mattercraft {
|
||||
source sourceSets.main
|
||||
}
|
||||
}
|
||||
@ -46,7 +45,7 @@ minecraft {
|
||||
property 'forge.logging.console.level', 'debug'
|
||||
|
||||
mods {
|
||||
examplemod {
|
||||
mattercraft {
|
||||
source sourceSets.main
|
||||
}
|
||||
}
|
||||
@ -62,7 +61,7 @@ minecraft {
|
||||
file('src/main/resources/')
|
||||
|
||||
mods {
|
||||
examplemod {
|
||||
mattercraft {
|
||||
source sourceSets.main
|
||||
}
|
||||
}
|
||||
@ -72,30 +71,16 @@ minecraft {
|
||||
|
||||
dependencies {
|
||||
minecraft 'net.minecraftforge:forge:1.16.4-35.1.32'
|
||||
implementation 'com.google.code.gson:gson:2.8.0'
|
||||
}
|
||||
|
||||
jar {
|
||||
manifest {
|
||||
attributes([
|
||||
"Implementation-Title": project.name,
|
||||
"Implementation-Version": "${version}",
|
||||
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
|
||||
'Implementation-Title': project.name,
|
||||
'Implementation-Version': project.version
|
||||
])
|
||||
}
|
||||
}
|
||||
|
||||
jar.finalizedBy('reobfJar')
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
mavenJava(MavenPublication) {
|
||||
artifact jar
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
url "file:///${project.projectDir}/mcmodsrepo"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,9 +16,4 @@ public class ChatMessage {
|
||||
public String getUsername() {
|
||||
return this.username;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "<" + getUsername() + "> " + getBody();
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,14 @@
|
||||
package com.rosspaffett.mattercraft;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.rosspaffett.mattercraft.matterbridge.SendMessageRequestBody;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
|
||||
public class ChatMessageSender implements Runnable {
|
||||
private static final Gson GSON = new Gson();
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
private final ConcurrentLinkedQueue<ChatMessage> messageQueue;
|
||||
@ -32,8 +35,10 @@ public class ChatMessageSender implements Runnable {
|
||||
}
|
||||
|
||||
private void sendMessageToMatterbridge(ChatMessage message) {
|
||||
// TODO Send message to Matterbridge
|
||||
LOGGER.info("Sending message to Matterbridge: " + message.toString());
|
||||
SendMessageRequestBody requestBody = new SendMessageRequestBody("test", message.getUsername(),
|
||||
message.getBody());
|
||||
|
||||
LOGGER.info("Sending message to Matterbridge: " + GSON.toJson(requestBody));
|
||||
}
|
||||
|
||||
private boolean shouldContinueRunning() {
|
||||
|
@ -0,0 +1,13 @@
|
||||
package com.rosspaffett.mattercraft.matterbridge;
|
||||
|
||||
public class SendMessageRequestBody {
|
||||
public final String gateway;
|
||||
public final String text;
|
||||
public final String username;
|
||||
|
||||
public SendMessageRequestBody(String gateway, String username, String text) {
|
||||
this.gateway = gateway;
|
||||
this.text = text;
|
||||
this.username = username;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user