Skip to content

Commit

Permalink
Colorize output and add SuperChat only feature
Browse files Browse the repository at this point in the history
  • Loading branch information
Mason Frey authored and Mason Frey committed Jul 10, 2017
1 parent b7d9e5f commit 1b5cdbf
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
public class YouTubeChat {
public static final String MODID = "ytchat";
public static final String APPNAME = "YouTube Chat";
public static final String VERSION = "1.0.0";
public static final String VERSION = "1.2.0_1.8.9";
public static final String GUI_FACTORY =
"com.google.youtube.gaming.chat.YouTubeConfigurationGuiFactory";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommandSender;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.EnumChatFormatting;

import java.io.IOException;
import java.util.ArrayList;
Expand Down Expand Up @@ -108,7 +109,8 @@ private void showMessage(String message, ICommandSender sender) {
}

private void showStreamMessage(LiveChatMessageAuthorDetails author, String message, ICommandSender sender) {
sender.addChatMessage(new ChatComponentText(author.getDisplayName() + ": " + message));
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "[YTChat] " + (author.getIsChatModerator() ? EnumChatFormatting.BLUE : EnumChatFormatting.WHITE) +
(author.getIsChatOwner() ? EnumChatFormatting.GOLD : EnumChatFormatting.WHITE) + author.getDisplayName() + EnumChatFormatting.WHITE + ": " + message));
}

@Override
Expand All @@ -129,7 +131,10 @@ public void onMessageReceived(
LiveChatSuperChatDetails superChatDetails,
String message) {

showStreamMessage(author, message, Minecraft.getMinecraft().thePlayer);
if(!YouTubeConfiguration.getInstance().getSuperOnly()) {
showStreamMessage(author, message, Minecraft.getMinecraft().thePlayer);
}

if (superChatDetails != null
&& superChatDetails.getAmountMicros() != null
&& superChatDetails.getAmountMicros().longValue() > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public class YouTubeConfiguration {
private static Configuration config;
private String clientSecret;
private String videoId;
private boolean superOnly;

public static void initialize(File path) {
instance = new YouTubeConfiguration(path);
Expand Down Expand Up @@ -58,6 +59,9 @@ private void addGeneralConfig() {
config
.get(Configuration.CATEGORY_GENERAL, "videoId", "", "The id of the live video")
.getString();
superOnly =
config
.get(Configuration.CATEGORY_GENERAL, "superOnly", false, "Receive super chats only").getBoolean();
}

public void reset() {
Expand All @@ -78,4 +82,6 @@ public Configuration getConfig() {
public String getClientSecret() {
return clientSecret;
}

public boolean getSuperOnly() { return superOnly; }
}

0 comments on commit 1b5cdbf

Please sign in to comment.