Skip to content
Snippets Groups Projects
Commit 169816f4 authored by Miniontoby's avatar Miniontoby :writing_hand_tone1:
Browse files

Updated to java

parent 61bfa0dc
No related branches found
No related tags found
No related merge requests found
IRC Mod for Mindustry
MindustrIRC -> IRC mod
apply plugin: "java"
version '1.0'
//compile java 16 code, targeting java 8
targetCompatibility = 8
sourceCompatibility = JavaVersion.VERSION_16
sourceSets.main.java.srcDirs = ["src"]
repositories{
mavenCentral()
maven{ url 'https://www.jitpack.io' }
}
ext{
//the build number that this mod is made for
mindustryVersion = 'v131'
jabelVersion = "0.6.0"
sdkRoot = System.getenv("ANDROID_HOME") ?: System.getenv("ANDROID_SDK_ROOT")
}
//java 8 backwards compatibility flag
allprojects{
tasks.withType(JavaCompile){
options.compilerArgs.addAll(['--release', '8'])
}
}
dependencies{
compileOnly "com.github.Anuken.Arc:arc-core:$mindustryVersion"
compileOnly "com.github.Anuken.Mindustry:core:$mindustryVersion"
annotationProcessor "com.github.Anuken:jabel:$jabelVersion"
}
task jarAndroid{
dependsOn "jar"
doLast{
if(!sdkRoot || !new File(sdkRoot).exists()) throw new GradleException("No valid Android SDK found. Ensure that ANDROID_HOME is set to your Android SDK directory.");
def platformRoot = new File("$sdkRoot/platforms/").listFiles().sort().reverse().find{ f -> new File(f, "android.jar").exists()}
if(!platformRoot) throw new GradleException("No android.jar found. Ensure that you have an Android platform installed.")
//collect dependencies needed for desugaring
def dependencies = (configurations.compileClasspath.asList() + configurations.runtimeClasspath.asList() + [new File(platformRoot, "android.jar")]).collect{ "--classpath $it.path" }.join(" ")
//dex and desugar files - this requires d8 in your PATH
"d8 $dependencies --min-api 14 --output ${project.archivesBaseName}Android.jar ${project.archivesBaseName}Desktop.jar"
.execute(null, new File("$buildDir/libs")).waitForProcessOutput(System.out, System.err)
}
}
jar{
archiveFileName = "${project.archivesBaseName}Desktop.jar"
from{
configurations.runtimeClasspath.collect{ it.isDirectory() ? it : zipTree(it) }
}
from(rootDir){
include "mod.hjson"
}
from("assets/"){
include "**"
}
}
task deploy(type: Jar){
dependsOn jarAndroid
dependsOn jar
archiveFileName = "${project.archivesBaseName}.jar"
from{ [zipTree("$buildDir/libs/${project.archivesBaseName}Desktop.jar"), zipTree("$buildDir/libs/${project.archivesBaseName}Android.jar")] }
doLast{
delete{
delete "$buildDir/libs/${project.archivesBaseName}Desktop.jar"
delete "$buildDir/libs/${project.archivesBaseName}Android.jar"
}
}
}
File added
File added
File added
Manifest-Version: 1.0
name: "mindustrirc"
#the mod name as displayed in-game
displayName: "MindustrIRC"
author: Miniontoby
#the internal name of your mod
name: "mindustrIRC"
#your name
author: "Miniontoby"
#the fully qualified main class of the mod
main: "com.miniontoby.MindustrIRC"
#the mod description as seen in the mod dialog
description: "IRC Mod for Mindustry"
version: "1.0"
minGameVersion: 122
dependencies: [ ]
hidden: false
#the mod version
version: 1.0
#the minimum game build required to run this mod
minGameVersion: 129
#this is a java mod
java: true
const myDialog = new BaseDialog("Dialog Title");
myDialog.addCloseButton();
myDialog.cont.add("Goodbye.");
myDialog.show();
let ws = null;
var options = {
server: "wss://miniontoby.coconut.ircnow.org:8188/webirc/websocket/",
nick: "MindustrIRC",
channel: "#ircforever"
};
function connectToIRC(){
print "Starting up!\n";
ws = new WebSocket(options.server, "base64");
ws.onopen = function() {
retries = 0;
send( 'NICK '+options.nick+' \n');
send( 'USER '+options.nick+' * * :MindustrIRC Mod\n');
inlogcheck = false;
};
ws.onmessage = function(content) {
var messageOutput6 = strToUTF8Arr(content.data);
var messageOutput7 = base64EncArr(messageOutput6);
var messageoutput = content.data;
var array = messageoutput.split(" ");
var server = array[0];
var nickname = array[0].split("!")[0].replace(":", "");
var action = array[1];
var userchannel = array[2];
if(array[3] != undefined) {
var param = array[3].substr(1,array[3].length) + " ";
for(var i = 4;i<array.length;i++) {
param += array[i] + " ";
}
}
var e = window.atob(messageOutput7);
if ( e.match( /^PING (\S*)/i ) ) {
send( 'PONG ' + RegExp.$1 + '\n' );
}
if(e.indexOf("Found your hostname") != -1 || e.indexOf("No Ident response") != -1) {
if(inlogcheck) {
send( 'NICK '+options.nick+' \n');
send( 'USER '+options.nick+' * * :MindustrIRC Mod\n');
inlogcheck = false;
}
}
if(param != undefined && param.indexOf("MODE "+options.nick+" :+i") != -1) {
send( 'JOIN ' + options.channel +'\n' );
}
if(action == "JOIN" && nickname == options.nick) {
mejoin(e);
} else if(action == "JOIN" && nickname != options.nick) {
status( nickname + " joined " + options.channel,false);
}
if(action == "PART" && nickname != options.nick) {
if(param != undefined) {
status(nickname + " lefted " +options.channel+": "+param, false);
} else {
status(nickname + " lefted " + options.channel, false);
}
}
if(action == "PRIVMSG") {
privmsg(nickname, param);
}
if (e.indexOf("is your displayed hostname now") != -1){
send( 'JOIN ' + options.channel + '\n' );
}
};
ws.onclose = function() { retryOpeningWebSocket(); };
if (timer) clearTimeout(timer);
timer = setInterval( ping, 100000 );
}
function send(data) {
ws.send(data);
}
connectToIRC();
Events.on(GameOverEvent, event => {
console.log(event);
})
Events.on(LoseEvent, event => {
console.log(event);
})
Events.on(PlayerChatEvent, event => {
console.log(event);
})
Events.on(PlayerLeaveEvent, event => {
console.log(event);
})
Events.on(PlayerJoinEvent, event => {
console.log(event);
})
Events.on(WinEvent, event => {
console.log(event);
})
require("irc");
package com.miniontoby;
import arc.*;
import arc.util.*;
import mindustry.*;
import mindustry.content.*;
import mindustry.game.EventType.*;
import mindustry.gen.*;
import mindustry.mod.*;
import mindustry.ui.dialogs.*;
public class MindustrIRC extends Mod {
public MindustrIRC(){
Log.info("Loaded ExampleJavaMod constructor.");
Events.on(PlayerChatEvent.class, e -> {
});
}
@Override
public void loadContent(){
Log.info("Loading some example content.");
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment