mirror of
https://github.com/raws/minecraft-forge-mattercraft.git
synced 2025-09-22 19:59:56 -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
|
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '3.+', changing: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
apply plugin: 'net.minecraftforge.gradle'
|
apply plugin: 'net.minecraftforge.gradle'
|
||||||
apply plugin: 'eclipse'
|
apply plugin: 'eclipse'
|
||||||
apply plugin: 'maven-publish'
|
apply plugin: 'maven-publish'
|
||||||
|
|
||||||
version = '0.1'
|
version = '1.16.4-0.0.1.0'
|
||||||
group = 'com.rosspaffett.mattercraft'
|
group = 'com.rosspaffett.mattercraft'
|
||||||
archivesBaseName = 'mattercraft'
|
archivesBaseName = 'mattercraft'
|
||||||
|
|
||||||
@ -23,8 +24,6 @@ sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = co
|
|||||||
minecraft {
|
minecraft {
|
||||||
mappings channel: 'snapshot', version: '20201028-1.16.3'
|
mappings channel: 'snapshot', version: '20201028-1.16.3'
|
||||||
|
|
||||||
// accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
|
|
||||||
|
|
||||||
runs {
|
runs {
|
||||||
client {
|
client {
|
||||||
workingDirectory project.file('run')
|
workingDirectory project.file('run')
|
||||||
@ -33,7 +32,7 @@ minecraft {
|
|||||||
property 'forge.logging.console.level', 'debug'
|
property 'forge.logging.console.level', 'debug'
|
||||||
|
|
||||||
mods {
|
mods {
|
||||||
examplemod {
|
mattercraft {
|
||||||
source sourceSets.main
|
source sourceSets.main
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -46,7 +45,7 @@ minecraft {
|
|||||||
property 'forge.logging.console.level', 'debug'
|
property 'forge.logging.console.level', 'debug'
|
||||||
|
|
||||||
mods {
|
mods {
|
||||||
examplemod {
|
mattercraft {
|
||||||
source sourceSets.main
|
source sourceSets.main
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -62,7 +61,7 @@ minecraft {
|
|||||||
file('src/main/resources/')
|
file('src/main/resources/')
|
||||||
|
|
||||||
mods {
|
mods {
|
||||||
examplemod {
|
mattercraft {
|
||||||
source sourceSets.main
|
source sourceSets.main
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -72,30 +71,16 @@ minecraft {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
minecraft 'net.minecraftforge:forge:1.16.4-35.1.32'
|
minecraft 'net.minecraftforge:forge:1.16.4-35.1.32'
|
||||||
|
implementation 'com.google.code.gson:gson:2.8.0'
|
||||||
}
|
}
|
||||||
|
|
||||||
jar {
|
jar {
|
||||||
manifest {
|
manifest {
|
||||||
attributes([
|
attributes([
|
||||||
"Implementation-Title": project.name,
|
'Implementation-Title': project.name,
|
||||||
"Implementation-Version": "${version}",
|
'Implementation-Version': project.version
|
||||||
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
|
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
jar.finalizedBy('reobfJar')
|
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() {
|
public String getUsername() {
|
||||||
return this.username;
|
return this.username;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "<" + getUsername() + "> " + getBody();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,14 @@
|
|||||||
package com.rosspaffett.mattercraft;
|
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.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||||
|
|
||||||
public class ChatMessageSender implements Runnable {
|
public class ChatMessageSender implements Runnable {
|
||||||
|
private static final Gson GSON = new Gson();
|
||||||
private static final Logger LOGGER = LogManager.getLogger();
|
private static final Logger LOGGER = LogManager.getLogger();
|
||||||
|
|
||||||
private final ConcurrentLinkedQueue<ChatMessage> messageQueue;
|
private final ConcurrentLinkedQueue<ChatMessage> messageQueue;
|
||||||
@ -32,8 +35,10 @@ public class ChatMessageSender implements Runnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void sendMessageToMatterbridge(ChatMessage message) {
|
private void sendMessageToMatterbridge(ChatMessage message) {
|
||||||
// TODO Send message to Matterbridge
|
SendMessageRequestBody requestBody = new SendMessageRequestBody("test", message.getUsername(),
|
||||||
LOGGER.info("Sending message to Matterbridge: " + message.toString());
|
message.getBody());
|
||||||
|
|
||||||
|
LOGGER.info("Sending message to Matterbridge: " + GSON.toJson(requestBody));
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean shouldContinueRunning() {
|
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