-
-
Save MelanX/11082ec5a01c6c0d0808863e5dba7209 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
buildscript { | |
repositories { | |
maven { url = 'https://files.minecraftforge.net/maven' } | |
maven { url "https://plugins.gradle.org/m2/" } | |
jcenter() | |
mavenCentral() | |
} | |
dependencies { | |
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '3.+', changing: true | |
} | |
} | |
apply plugin: 'net.minecraftforge.gradle' | |
apply plugin: 'eclipse' | |
version = mod_version | |
group = "de.melanx.byestack" | |
archivesBaseName = "byestack-${mc_version}" | |
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' | |
minecraft { | |
mappings channel: 'snapshot', version: mappings_version | |
accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') | |
runs { | |
client { | |
workingDirectory project.file('run') | |
property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP' | |
property 'forge.logging.console.level', 'debug' | |
mods { | |
byestack { | |
source sourceSets.main | |
} | |
} | |
} | |
server { | |
workingDirectory project.file('run_server') | |
property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP' | |
property 'forge.logging.console.level', 'debug' | |
mods { | |
byestack { | |
source sourceSets.main | |
} | |
} | |
} | |
data { | |
workingDirectory project.file('run_data') | |
// Recommended logging data for a userdev environment | |
property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP' | |
// Recommended logging level for the console | |
property 'forge.logging.console.level', 'debug' | |
args '--mod', 'byestack', '--all', '--output', '"' + file('src/generated/resources/') + '"', '--existing', '"' + file('src/main/resources/') + '"' | |
mods { | |
byestack { | |
source sourceSets.main | |
} | |
} | |
} | |
} | |
} | |
sourceSets.main.resources { | |
srcDir 'src/generated/resources' | |
} | |
repositories { | |
maven { | |
// location of the maven that hosts JEI files | |
name = "Progwml6 maven" | |
url = "https://dvs1.progwml6.com/files/maven/" | |
} | |
mavenCentral() | |
jcenter() | |
maven { url 'https://jitpack.io' } | |
maven { url "https://oss.jfrog.org/artifactory/libs-release"} | |
} | |
configurations { | |
shade | |
compile.extendsFrom shade | |
} | |
configurations.compile.extendsFrom(configurations.shade) | |
dependencies { | |
minecraft "net.minecraftforge:forge:${mc_version}-${forge_version}" | |
runtimeOnly fg.deobf("mezz.jei:jei-1.15.2:6.0.0.2") | |
shade 'com.github.pircbotx:pircbotx:2.2' | |
shade group: 'io.socket', name: 'socket.io-client', version: '1.0.0' | |
shade group: 'com.github.twitch4j', name: 'twitch4j', version: '1.0.0-alpha.20' | |
} | |
jar { | |
manifest { | |
attributes([ | |
"Specification-Title" : "byestack", | |
"Specification-Vendor" : "byestack", | |
"Specification-Version" : "1", // We are version 1 of ourselves | |
"Implementation-Title" : project.name, | |
"Implementation-Version" : "${version}", | |
"Implementation-Vendor" : "byestack", | |
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ") | |
]) | |
} | |
configurations.shade.each { dependency -> | |
from(project.zipTree(dependency)) { | |
exclude 'META-INF', 'META-INF/**' | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package de.melanx.byestack.twitch; | |
import com.github.twitch4j.helix.TwitchHelix; | |
import com.github.twitch4j.helix.TwitchHelixBuilder; | |
import com.github.twitch4j.helix.domain.StreamList; | |
import com.github.twitch4j.kraken.TwitchKraken; | |
import com.github.twitch4j.kraken.TwitchKrakenBuilder; | |
import com.netflix.hystrix.exception.HystrixRuntimeException; | |
import java.util.Collections; | |
import java.util.concurrent.atomic.AtomicReference; | |
public class TitleChange { | |
private final TwitchKraken kraken; | |
private final TwitchHelix helix; | |
AtomicReference<String> title = new AtomicReference<>(""); | |
private boolean isLive; | |
public TitleChange() { | |
String client_id = "djaslkj92387498dhj927349"; | |
TwitchKrakenBuilder krakenBuilder = TwitchKrakenBuilder.builder(); | |
TwitchHelixBuilder helixBuilder = TwitchHelixBuilder.builder(); | |
kraken = krakenBuilder.withClientId(client_id).withTimeout(120 * 1000).build(); | |
helix = helixBuilder.withClientId(client_id).withTimeout(120 * 1000).build(); | |
} | |
public void changeTitle(boolean on) { | |
String oauth = "oauth:ljaslkj12089sdaolkj02eufdasjjloj9823u4e98"; | |
String streamer = "ExampleStreamer"; | |
String channel_id = "123456789"; | |
try { | |
StreamList streamList = helix.getStreams(oauth, "", null, null, null, null, null, null, Collections.singletonList(streamer)).execute(); | |
streamList.getStreams().forEach(stream -> { | |
if (stream.getGameId().equals("27471")) { | |
title.set(stream.getTitle()); | |
isLive = true; | |
} | |
}); | |
if (streamList.getStreams().isEmpty()) { | |
isLive = false; | |
} | |
} catch (HystrixRuntimeException e) { | |
e.printStackTrace(); | |
} | |
if (isLive) { | |
title.set(title.get().replace(getPostfix(!on), "")); | |
kraken.updateTitle(oauth, channel_id, title + getPostfix(on)).execute(); | |
} | |
} | |
private String getPostfix(boolean on) { | |
return on ? " | Rewards on" : " | Rewards off"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment