Skip to content
This repository was archived by the owner on May 26, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
\.idea/
\build/
\libs/
out/
\out/
16 changes: 8 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ subprojects {
mavenLocal()
mavenCentral()
//Mixer's Maven repo was down, so I'm removing it for now.
//maven {
// name = "mixer-snapshots"
// url = "https://maven.mixer.com/content/repositories/snapshots"
//}
//maven {
// name = "mixer-releases"
// url = "https://maven.mixer.com/content/repositories/releases/"
//}
maven {
name = "mixer-snapshots"
url = "https://maven.mixer.com/content/repositories/snapshots"
}
maven {
name = "mixer-releases"
url = "https://maven.mixer.com/content/repositories/releases/"
}
}

dependencies{
Expand Down
5 changes: 2 additions & 3 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#Thu Apr 12 15:43:11 EDT 2018
#Sat Jul 20 10:54:44 CST 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-bin.zip

distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-all.zip
12 changes: 10 additions & 2 deletions mixer-common/src/main/java/pro/kdray/funniray/mixer/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,17 @@ public class Config {
public static String DBUsername = "unused";
public static String DBPassword = "unused";

public static String subscriberCommand;
public static String resubscriberCommand;
public static String subscribeCommand;
public static String resubscribeCommand;
public static String followCommand;

public static List<String> bannedWords;

public static String messagesPrefix = "&6Mixer &8| ";
public static String messagesChatConnect = "&cChat Connected!";
public static String messagesConnectInteractive = "&aInteractive connected!";
public static String messagesDisableInteractive = "&cInteractive has been successfully disabled!";
public static String messagesEstablishedNotConnected = "&cConnection was established but isn't connected!";
public static String messagesPause = "Buttons have been paused";
public static String messagesResume = "Buttons have been resumed";
}
11 changes: 7 additions & 4 deletions mixer-common/src/main/java/pro/kdray/funniray/mixer/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@

import java.util.concurrent.ExecutionException;

import static pro.kdray.funniray.mixer.Config.messagesDisableInteractive;
import static pro.kdray.funniray.mixer.Config.messagesPrefix;

public class Main {

private Interactive interactive;
Expand Down Expand Up @@ -43,7 +46,7 @@ public void setAPIKey(String key) {
}

public void startChat() throws ExecutionException, InterruptedException {
MixerAPI mixer = new MixerAPI(clientID, APIKey);
MixerAPI mixer = new MixerAPI(APIKey, clientID);

MixerUser user = mixer.use(UsersService.class).getCurrent().get();
MixerChat chat = mixer.use(ChatService.class).findOne(user.channel.id).get();
Expand All @@ -53,15 +56,15 @@ public void startChat() throws ExecutionException, InterruptedException {
}

public void startInteractive() throws ExecutionException, InterruptedException {
MixerAPI mixer = new MixerAPI(clientID, APIKey);
MixerAPI mixer = new MixerAPI(APIKey, clientID);

MixerUser user = mixer.use(UsersService.class).getCurrent().get();

interactive = new Interactive(mixer, user, APIKey, eventHandler);
}

public void startAll() throws ExecutionException, InterruptedException {
MixerAPI mixer = new MixerAPI(clientID, APIKey);
MixerAPI mixer = new MixerAPI(APIKey, clientID);

MixerUser user = mixer.use(UsersService.class).getCurrent().get();
MixerChat chat = mixer.use(ChatService.class).findOne(user.channel.id).get();
Expand Down Expand Up @@ -89,7 +92,7 @@ public void stopInteractive() {
public void shutdown(){
this.stopChat();
this.stopInteractive();
eventHandler.sendMessage("&9&l[Mixer]&r&9 Successfully disabled interactive.");
eventHandler.sendMessage(messagesPrefix + messagesDisableInteractive);
}

public Interactive getInteractive() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ public static String getColorFromRank(List<MixerUser.Role> roles){
String color = "&4";

if (roles.contains(MixerUser.Role.OWNER)) {
color = "&f";
color = "&c";
}else if (roles.contains(MixerUser.Role.FOUNDER) || roles.contains(MixerUser.Role.STAFF) || roles.contains(MixerUser.Role.GLOBAL_MOD)){
color = "&4";
color = "&3";
}else if (roles.contains(MixerUser.Role.MOD)) {
color = "&a";
color = "&2";
}else if (roles.contains(MixerUser.Role.SUBSCRIBER)){
color = "&6";
}else if (roles.contains(MixerUser.Role.PRO)){
color = "&5";
color = "&d";
}else if (roles.contains(MixerUser.Role.USER)){
color = "&9";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public class InteractiveButton {
private String NBT;
private String switchWindow;
private String runCommand;
private String[] runCommands;
private boolean runAsServer = false;
private boolean resetScene = false;
//TODO: private String move;
Expand Down Expand Up @@ -61,6 +62,9 @@ public InteractiveButton(ButtonControl control, Interactive handler) {
case "runCommand":
this.runCommand = meta.get("action").getAsJsonObject().get("value").getAsString();
break;
case "runCommands":
this.runCommand = meta.get("action").getAsJsonObject().get("value").getAsString();
break;
case "runCommandAsServer":
this.runCommand = meta.get("action").getAsJsonObject().get("value").getAsString();
this.runAsServer = true;
Expand All @@ -74,6 +78,9 @@ public InteractiveButton(ButtonControl control, Interactive handler) {
if (meta.get("runCommand") != null)
this.runCommand = meta.get("runCommand").getAsJsonObject().get("value").getAsString();

if (meta.get("runCommands") != null)
this.runCommands = meta.get("runCommands").getAsJsonObject().get("value").getAsString().split("\\n");

if (meta.get("runCommandAsServer") != null) {
this.runCommand = meta.get("runCommandAsServer").getAsJsonObject().get("value").getAsString();
this.runAsServer = true;
Expand Down Expand Up @@ -200,6 +207,23 @@ public boolean onClick(InteractiveParticipant participant){
}
}

if (this.runCommands != null) {
for (String tempCommands : runCommands){
String command = tempCommands
.replace("%CSL%", CSL)
.replace("%SSL%", SSL)
.replace("%HRL%", HRL)
.replace("%presser%", participant.getUsername());
if (this.runAsServer) {
this.handler.getEventHandler().runCommandAsConsole(command);
didAction = true;
}else{
this.handler.getEventHandler().runCommand(command);
didAction = true;
}
}
}

if (this.summon != null){
if (this.NBT != null) {
this.handler.getEventHandler().summon((this.summon + " ~ ~ ~ " + this.NBT)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
import pro.kdray.funniray.mixer.MixerEvents;
import pro.kdray.funniray.mixer.Utils;

import static pro.kdray.funniray.mixer.Config.messagesChatConnect;
import static pro.kdray.funniray.mixer.Config.messagesPrefix;

public class Chat {

private MixerChatConnectable chatConnectable;
Expand All @@ -23,7 +26,7 @@ public Chat(MixerAPI mixer, MixerUser user, MixerChat chat, MixerEvents eventHan
if (chatConnectable.connect()) {
chatConnectable.send(AuthenticateMessage.from(user.channel, user, chat.authkey), new ReplyHandler<AuthenticationReply>() {
public void onSuccess(AuthenticationReply reply) {
eventHandler.sendMessage("&9&l[Mixer]&r&9 Chat Connected!");
eventHandler.sendMessage(messagesPrefix + messagesChatConnect);
}
public void onFailure(Throwable e) {
e.printStackTrace();
Expand All @@ -34,19 +37,16 @@ public void onFailure(Throwable e) {
chatConnectable.on(IncomingMessageEvent.class, event -> {
if (event.data.message.isWhisper())
return;
StringBuilder finishedMessage = new StringBuilder("&9&l[Mixer] " + Utils.getColorFromRank(event.data.userRoles) + event.data.userName + "&9&l: &r&7");
StringBuilder finishedMessage = new StringBuilder(messagesPrefix + Utils.getColorFromRank(event.data.userRoles) + event.data.userName + "&9&l: &r&7");
for (MessageComponent.MessageTextComponent message : event.data.message.message){
finishedMessage.append(message.text.replace("§", "§§").replace("&", "&&7"));
}
boolean shouldShow = true;
for (String word : Config.bannedWords) {
if (finishedMessage.toString().contains(word)){
shouldShow = false;
if (!finishedMessage.toString().contains(word)){
eventHandler.sendMessage(finishedMessage.toString());
break;
}
}
if (shouldShow)
eventHandler.sendMessage(finishedMessage.toString());
});

this.chatConnectable = chatConnectable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
import java.util.ArrayList;
import java.util.Random;

import static pro.kdray.funniray.mixer.Config.messagesPrefix;

public class Constellation {

private MixerConstellationConnectable constellationConnectable;
Expand Down Expand Up @@ -57,21 +59,20 @@ public void onFailure(Throwable e) {
break;
case "subscribed":
eventHandler.sendTitle(actionUser+" subscribed!", "");
eventHandler.sendMessage("&9&l[Mixer] &r&9"+actionUser+" subscribed!");
eventHandler.runCommandAsConsole(Config.subscriberCommand.replace("%user%", actionUser));
eventHandler.sendMessage(messagesPrefix+actionUser+" subscribed!");
eventHandler.runCommandAsConsole(Config.subscribeCommand.replace("%user%", actionUser));
break;
case "resubscribed":
eventHandler.sendTitle(actionUser+" resubscribed!", "");
eventHandler.sendMessage("&9&l[Mixer] &r&9"+actionUser+" resubscribed!");
eventHandler.runCommandAsConsole(Config.resubscriberCommand.replace("%user%", actionUser).replace("%totalMonths%", "" + event.data.payload.get("totalMonths").getAsInt()));
eventHandler.sendMessage(messagesPrefix+actionUser+" resubscribed!");
eventHandler.runCommandAsConsole(Config.resubscribeCommand.replace("%user%", actionUser).replace("%totalMonths%", "" + event.data.payload.get("totalMonths").getAsInt()));
break;
case "update":
eventHandler.sendTitle("&bMixer Title &7has been updated to:", "&7" + event.data.payload.get("name").getAsString());
eventHandler.sendMessage(messagesPrefix+"&aTitle has been updated to: " + event.data.payload.get("name").getAsString());
break;
//case "update":
// message = "&9Channel update, new title is "+event.data.payload.get("name").getAsString();
// eventHandler.sendTitle(message, "");
// eventHandler.sendMessage("&9&l[Mixer] &r"+message);
// break;
default:
eventHandler.sendMessage("&9&l[Mixer]&r&c >>> Unhandled Contellation Event: "+event.toString());
eventHandler.sendMessage(messagesPrefix+"&cUnhandled Constellation Event: "+event.toString());
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import java.util.concurrent.ExecutionException;

import static com.mixer.interactive.GameClient.GROUP_SERVICE_PROVIDER;
import static pro.kdray.funniray.mixer.Config.*;

public class Interactive {

Expand Down Expand Up @@ -75,10 +76,10 @@ public void onParticipantLeave(ParticipantLeaveEvent event){
@Subscribe
public void onConnectionEsablished(ConnectionEstablishedEvent event){
try {
if (!client.isConnected()) {
this.eventHandler.sendMessage("&9&l[Mixer]&r&4 Connection was established but isn't connected!");
if (client.isConnected()) {
this.eventHandler.sendMessage(messagesPrefix + messagesConnectInteractive);
}else{
this.eventHandler.sendMessage("&9&l[Mixer]&r&9 Interactive connected!");
this.eventHandler.sendMessage(messagesPrefix + messagesEstablishedNotConnected);
}

Set<InteractiveScene> scenes = new SceneServiceProvider(client).getScenes().get();
Expand Down Expand Up @@ -121,7 +122,7 @@ public void onKeyDown(ControlInputEvent event){
try {
event.getTransaction().capture(this.client).get();
} catch (InterruptedException | ExecutionException e) {
//Honestly who cares? //e.printStackTrace();
//e.printStackTrace();
}
});
}
Expand All @@ -133,7 +134,7 @@ public void updateControl(ButtonControl control){
try {
client.using(GameClient.CONTROL_SERVICE_PROVIDER).update(control).get();
} catch (InterruptedException | ExecutionException e) {
//I don't really care what happens here
//e.printStackTrace();
}
});
}
Expand All @@ -143,7 +144,7 @@ public void updateControls(Collection<InteractiveControl> controls){
try {
client.using(GameClient.CONTROL_SERVICE_PROVIDER).update(controls).get();
} catch (InterruptedException | ExecutionException e) {
//I don't really care what happens here
//e.printStackTrace();
}
});
}
Expand Down Expand Up @@ -206,10 +207,10 @@ public boolean isPaused(){
public void pause(){
if (this.isPause){
switchAllScenes("default");
eventHandler.sendMessage("&9&l[Mixer]&r&9 Buttons have been unpaused");
eventHandler.sendMessage(messagesPrefix + messagesResume);
}else{
switchAllScenes("pause");
eventHandler.sendMessage("&9&l[Mixer]&r&9 Buttons have been paused");
eventHandler.sendMessage(messagesPrefix + messagesPause);
}
this.isPause = !this.isPause;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ private static void syncConfig(boolean loadConfigFromFile) {
//Put SQL data here

Property followCommandProp = configuration.get(Configuration.CATEGORY_GENERAL, "followCommand","command");
Property subscriberCommandProp = configuration.get(Configuration.CATEGORY_GENERAL, "subscriberCommand","command");
Property subscriberCommandProp = configuration.get(Configuration.CATEGORY_GENERAL, "subscribeCommand","command");
Property resubscriberCommandProp = configuration.get(Configuration.CATEGORY_GENERAL, "resubscriberCommand","command");

Property bannedWordsProp = configuration.get(Configuration.CATEGORY_GENERAL,"bannedWords",new String[]{"put multiple","words to remove from chat here"});
Expand All @@ -74,8 +74,8 @@ private static void syncConfig(boolean loadConfigFromFile) {
Config.projectID = projectIDProp.getInt();

Config.followCommand = followCommandProp.getString();
Config.subscriberCommand = subscriberCommandProp.getString();
Config.resubscriberCommand = resubscriberCommandProp.getString();
Config.subscribeCommand = subscriberCommandProp.getString();
Config.resubscribeCommand = resubscriberCommandProp.getString();

Config.bannedWords = Arrays.asList(bannedWordsProp.getStringList());

Expand All @@ -86,8 +86,8 @@ private static void syncConfig(boolean loadConfigFromFile) {
projectIDProp.set(Config.projectID);

followCommandProp.set(Config.followCommand);
subscriberCommandProp.set(Config.subscriberCommand);
resubscriberCommandProp.set(Config.resubscriberCommand);
subscriberCommandProp.set(Config.subscribeCommand);
resubscriberCommandProp.set(Config.resubscribeCommand);

bannedWordsProp.set(bannedWordsProp.getStringList());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ public static void load() {
Config.clientID = CONFIG.clientIDValue.get();
Config.shareCode = CONFIG.shareCodeValue.get();
Config.projectID = CONFIG.projectIDValue.get();
Config.subscriberCommand = CONFIG.subscriberCommandValue.get();
Config.resubscriberCommand = CONFIG.resubscriberCommandValue.get();
Config.subscribeCommand = CONFIG.subscriberCommandValue.get();
Config.resubscribeCommand = CONFIG.resubscriberCommandValue.get();
Config.followCommand = CONFIG.followCommandValue.get();
Config.bannedWords = CONFIG.bannedWordsValue.get();
}
Expand Down Expand Up @@ -67,7 +67,7 @@ public static class ServerConfig {
builder.push("Constellation");
subscriberCommandValue = builder
.comment("Command to be ran when someone subscribes. Replaces %user% with the subscriber's username")
.define("subscriberCommand","say %user% has subscribed");
.define("subscribeCommand","say %user% has subscribed");
resubscriberCommandValue = builder
.comment("Command to be ran when someone resubscribes. Replaces %user% with the subscriber's " +
"username. Replaces %totalMonths% with the months they have been subscribed for")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ public static void loadConfig() {
Config.projectID = configuration.getInt("projectID");

Config.followCommand = configuration.getString("followCommand");
Config.subscriberCommand = configuration.getString("subscriberCommand");
Config.resubscriberCommand = configuration.getString("resubscriberCommand");
Config.subscribeCommand = configuration.getString("subscribeCommand");
Config.resubscribeCommand = configuration.getString("resubscriberCommand");

Config.bannedWords = configuration.getStringList("bannedWords");

Expand Down
2 changes: 1 addition & 1 deletion mixer-spigot/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ repositories {

dependencies {
compile project(':mixer-common')
compile name: "spigot-1.14.3"
compile name: "spigot-1.14.4"
compile name: "spigot-1.13.2"
compile name: "spigot-1.13"
compile name: "spigot-1.12.2"
Expand Down
Loading