aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin.java67
-rw-r--r--src/main/kotlin/cc/woverflow/chatting/Chatting.kt82
-rw-r--r--src/main/kotlin/cc/woverflow/chatting/chat/ChatSearchingManager.kt6
-rw-r--r--src/main/kotlin/cc/woverflow/chatting/chat/ChatSpamBlock.kt4
-rw-r--r--src/main/kotlin/cc/woverflow/chatting/chat/ChatTabs.kt128
-rw-r--r--src/main/kotlin/cc/woverflow/chatting/command/ChattingCommand.kt16
-rw-r--r--src/main/kotlin/cc/woverflow/chatting/config/ChattingConfig.kt209
-rw-r--r--src/main/kotlin/cc/woverflow/chatting/gui/components/CleanButton.kt48
-rw-r--r--src/main/kotlin/cc/woverflow/chatting/utils/ImageTransferable.kt22
-rw-r--r--src/main/kotlin/cc/woverflow/chatting/utils/ModCompatHooks.kt40
-rw-r--r--src/main/kotlin/cc/woverflow/chatting/utils/RenderUtils.kt (renamed from src/main/kotlin/cc/woverflow/chatting/utils/renderutils.kt)12
11 files changed, 330 insertions, 304 deletions
diff --git a/src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin.java b/src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin.java
index 1052593..fe76b29 100644
--- a/src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin.java
+++ b/src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin.java
@@ -1,5 +1,6 @@
package cc.woverflow.chatting.mixin;
+import cc.polyfrost.oneconfig.config.core.OneColor;
import cc.woverflow.chatting.Chatting;
import cc.woverflow.chatting.chat.ChatSearchingManager;
import cc.woverflow.chatting.chat.ChatTabs;
@@ -12,7 +13,10 @@ import gg.essential.universal.UMouse;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.*;
import net.minecraft.client.renderer.GlStateManager;
-import net.minecraft.util.*;
+import net.minecraft.util.EnumChatFormatting;
+import net.minecraft.util.IChatComponent;
+import net.minecraft.util.MathHelper;
+import net.minecraft.util.ResourceLocation;
import org.objectweb.asm.Opcodes;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
@@ -23,39 +27,52 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import org.spongepowered.asm.mixin.injection.invoke.arg.Args;
-import java.awt.*;
import java.awt.datatransfer.StringSelection;
import java.awt.datatransfer.Transferable;
import java.awt.image.BufferedImage;
-import java.text.SimpleDateFormat;
-import java.util.Date;
import java.util.List;
import java.util.Locale;
@Mixin(value = GuiNewChat.class, priority = Integer.MIN_VALUE)
public abstract class GuiNewChatMixin extends Gui implements GuiNewChatHook {
- @Unique private int chatting$right = 0;
- @Unique private boolean chatting$shouldCopy;
- @Unique private boolean chatting$chatCheck;
- @Unique private int chatting$textOpacity;
- @Shadow @Final private Minecraft mc;
- @Shadow @Final private List<ChatLine> drawnChatLines;
+ @Unique
+ private int chatting$right = 0;
+ @Unique
+ private boolean chatting$shouldCopy;
+ @Unique
+ private boolean chatting$chatCheck;
+ @Unique
+ private int chatting$textOpacity;
+ @Shadow
+ @Final
+ private Minecraft mc;
+ @Shadow
+ @Final
+ private List<ChatLine> drawnChatLines;
@SuppressWarnings({"FieldCanBeLocal", "unused"})
private float percentComplete;
private String chatting$previousText = "";
- @Shadow public abstract boolean getChatOpen();
+ @Shadow
+ public abstract boolean getChatOpen();
- @Shadow public abstract float getChatScale();
+ @Shadow
+ public abstract float getChatScale();
- @Shadow public abstract int getLineCount();
+ @Shadow
+ public abstract int getLineCount();
- @Shadow private int scrollPos;
- @Shadow @Final private List<ChatLine> chatLines;
+ @Shadow
+ private int scrollPos;
+ @Shadow
+ @Final
+ private List<ChatLine> chatLines;
- @Shadow public abstract void deleteChatLine(int id);
+ @Shadow
+ public abstract void deleteChatLine(int id);
- @Unique private static final ResourceLocation COPY = new ResourceLocation("chatting:copy.png");
+ @Unique
+ private static final ResourceLocation COPY = new ResourceLocation("chatting:copy.png");
@Inject(method = "printChatMessageWithOptionalDeletion", at = @At("HEAD"), cancellable = true)
private void handlePrintChatMessage(IChatComponent chatComponent, int chatLineId, CallbackInfo ci) {
@@ -93,7 +110,7 @@ public abstract class GuiNewChatMixin extends Gui implements GuiNewChatHook {
}
@ModifyVariable(method = "drawChat", at = @At("HEAD"), argsOnly = true)
- private int setUpdateCounterWhjenYes(int updateCounter) {
+ private int setUpdateCounterWhenYes(int updateCounter) {
return Chatting.INSTANCE.getDoTheThing() ? 0 : updateCounter;
}
@@ -114,8 +131,8 @@ public abstract class GuiNewChatMixin extends Gui implements GuiNewChatHook {
float f = this.getChatScale();
int mouseX = MathHelper.floor_double(UMouse.getScaledX()) - 3;
int mouseY = MathHelper.floor_double(UMouse.getScaledY()) - 27 + ModCompatHooks.getYOffset() - ModCompatHooks.getChatPosition();
- mouseX = MathHelper.floor_float((float)mouseX / f);
- mouseY = -(MathHelper.floor_float((float)mouseY / f)); //WHY DO I NEED TO DO THIS
+ mouseX = MathHelper.floor_float((float) mouseX / f);
+ mouseY = -(MathHelper.floor_float((float) mouseY / f)); //WHY DO I NEED TO DO THIS
if (mouseX >= (left + ModCompatHooks.getXOffset()) && mouseY < bottom && mouseX < (right + 11 + ModCompatHooks.getXOffset()) && mouseY >= top) {
chatting$shouldCopy = true;
drawCopyChatBox(right, top);
@@ -126,10 +143,10 @@ public abstract class GuiNewChatMixin extends Gui implements GuiNewChatHook {
args.set(4, changeChatBackgroundColor(ChattingConfig.INSTANCE.getChatBackgroundColor(), args.get(4)));
}
- private int changeChatBackgroundColor(Color color, int alphaColor) {
+ private int changeChatBackgroundColor(OneColor color, int alphaColor) {
return (((alphaColor >> 24) & 0xFF) << 24) |
((color.getRed() & 0xFF) << 16) |
- ((color.getGreen() & 0xFF) << 8) |
+ ((color.getGreen() & 0xFF) << 8) |
((color.getBlue() & 0xFF));
}
@@ -183,7 +200,8 @@ public abstract class GuiNewChatMixin extends Gui implements GuiNewChatHook {
@Inject(method = "getChatHeight", at = @At("HEAD"), cancellable = true)
private void customHeight_getChatHeight(CallbackInfoReturnable<Integer> cir) {
- if (ChattingConfig.INSTANCE.getCustomChatHeight()) cir.setReturnValue(Chatting.INSTANCE.getChatHeight(this.getChatOpen()));
+ if (ChattingConfig.INSTANCE.getCustomChatHeight())
+ cir.setReturnValue(Chatting.INSTANCE.getChatHeight(this.getChatOpen()));
}
@Override
@@ -205,8 +223,7 @@ public abstract class GuiNewChatMixin extends Gui implements GuiNewChatHook {
}
if (!displayOnly) {
chatLines.add(0, new ChatLine(updateCounter, chatComponent, chatLineId));
- while (this.chatLines.size() > (100 + ModCompatHooks.getExtendedChatLength()))
- {
+ while (this.chatLines.size() > (100 + ModCompatHooks.getExtendedChatLength())) {
this.chatLines.remove(this.chatLines.size() - 1);
}
}
diff --git a/src/main/kotlin/cc/woverflow/chatting/Chatting.kt b/src/main/kotlin/cc/woverflow/chatting/Chatting.kt
index ea3c12e..3b7eb8b 100644
--- a/src/main/kotlin/cc/woverflow/chatting/Chatting.kt
+++ b/src/main/kotlin/cc/woverflow/chatting/Chatting.kt
@@ -1,9 +1,12 @@
package cc.woverflow.chatting
+import cc.polyfrost.oneconfig.libs.universal.UResolution
+import cc.polyfrost.oneconfig.utils.commands.CommandManager
import cc.woverflow.chatting.chat.ChatSearchingManager
import cc.woverflow.chatting.chat.ChatShortcuts
import cc.woverflow.chatting.chat.ChatSpamBlock
import cc.woverflow.chatting.chat.ChatTabs
+import cc.woverflow.chatting.command.ChattingCommand
import cc.woverflow.chatting.config.ChattingConfig
import cc.woverflow.chatting.hook.GuiNewChatHook
import cc.woverflow.chatting.mixin.GuiNewChatAccessor
@@ -11,9 +14,6 @@ import cc.woverflow.chatting.utils.ModCompatHooks
import cc.woverflow.chatting.utils.copyToClipboard
import cc.woverflow.chatting.utils.createBindFramebuffer
import cc.woverflow.chatting.utils.screenshot
-import cc.woverflow.onecore.utils.*
-import gg.essential.universal.UDesktop
-import gg.essential.universal.UResolution
import net.minecraft.client.Minecraft
import net.minecraft.client.gui.*
import net.minecraft.client.renderer.GlStateManager
@@ -67,17 +67,12 @@ object Chatting {
@Mod.EventHandler
fun onFMLPreInitialization(event: FMLPreInitializationEvent) {
if (!modDir.exists()) modDir.mkdirs()
- Updater.addToUpdater(event.sourceFile, NAME, ID, VER, "W-OVERFLOW/${ID}")
}
@Mod.EventHandler
fun onInitialization(event: FMLInitializationEvent) {
- ChattingConfig.preload()
- command("chatting") {
- main {
- ChattingConfig.openScreen()
- }
- }
+ ChattingConfig.initialize()
+ CommandManager.INSTANCE.registerCommand(ChattingCommand.Companion::class.java)
ClientRegistry.registerKeyBinding(keybind)
EVENT_BUS.register(this)
EVENT_BUS.register(ChatSpamBlock)
@@ -97,9 +92,9 @@ object Chatting {
fun onForgeLoad(event: FMLLoadCompleteEvent) {
if (ChattingConfig.informForAlternatives) {
if (isHychat) {
- sendBrandedNotification(NAME, "Hychat can be removed as it is replaced by Chatting. Click here for more information.", action = {
- UDesktop.browseURL("https://microcontrollersdev.github.io/Alternatives/1.8.9/hychat")
- })
+ //sendBrandedNotification(NAME, "Hychat can be removed as it is replaced by Chatting. Click here for more information.", action = {
+ // UDesktop.browseURL("https://microcontrollersdev.github.io/Alternatives/1.8.9/hychat")
+ //})
}
if (isSkytils) {
try {
@@ -121,24 +116,23 @@ object Chatting {
val chatTabs = skytilsClass.getDeclaredField("chatTabs")
chatTabs.isAccessible = true
if (chatTabs.getBoolean(instance)) {
- sendBrandedNotification(NAME, "Skytils' chat tabs can be disabled as it is replace by Chatting.\nClick here to automatically do this.", 6F, action = {
- chatTabs.setBoolean(instance, false)
- ChattingConfig.chatTabs = true
- ChattingConfig.hypixelOnlyChatTabs = true
- ChattingConfig.markDirty()
- ChattingConfig.writeData()
- skytilsClass.getMethod("markDirty").invoke(instance)
- skytilsClass.getMethod("writeData").invoke(instance)
- })
+ //sendBrandedNotification(NAME, "Skytils' chat tabs can be disabled as it is replace by Chatting.\nClick here to automatically do this.", 6F, action = {
+ // chatTabs.setBoolean(instance, false)
+ // ChattingConfig.chatTabs = true
+ // ChattingConfig.hypixelOnlyChatTabs = true
+ // ChattingConfig.save()
+ // skytilsClass.getMethod("markDirty").invoke(instance)
+ // skytilsClass.getMethod("writeData").invoke(instance)
+ //})
}
val copyChat = skytilsClass.getDeclaredField("chatTabs")
copyChat.isAccessible = true
if (copyChat.getBoolean(instance)) {
- sendBrandedNotification(NAME, "Skytils' copy chat messages can be disabled as it is replace by Chatting.\nClick here to automatically do this.", 6F, action = {
- copyChat.setBoolean(instance, false)
- skytilsClass.getMethod("markDirty").invoke(instance)
- skytilsClass.getMethod("writeData").invoke(instance)
- })
+ //sendBrandedNotification(NAME, "Skytils' copy chat messages can be disabled as it is replace by Chatting.\nClick here to automatically do this.", 6F, action = {
+ // copyChat.setBoolean(instance, false)
+ // skytilsClass.getMethod("markDirty").invoke(instance)
+ // skytilsClass.getMethod("writeData").invoke(instance)
+ //})
}
}
@@ -166,7 +160,15 @@ object Chatting {
val hud = Minecraft.getMinecraft().ingameGUI
val chat = hud.chatGUI
val i = MathHelper.floor_float(chat.chatWidth / chat.chatScale)
- return screenshot(GuiUtilRenderComponents.splitText(line.chatComponent, i, Minecraft.getMinecraft().fontRendererObj, false, false).map { it.formattedText }.reversed())
+ return screenshot(
+ GuiUtilRenderComponents.splitText(
+ line.chatComponent,
+ i,
+ Minecraft.getMinecraft().fontRendererObj,
+ false,
+ false
+ ).map { it.formattedText }.reversed()
+ )
}
private fun screenshotChat() {
@@ -177,8 +179,14 @@ object Chatting {
val hud = Minecraft.getMinecraft().ingameGUI
val chat = hud.chatGUI
val chatLines = ArrayList<String>()
- ChatSearchingManager.filterMessages((chat as GuiNewChatHook).prevText, (chat as GuiNewChatAccessor).drawnChatLines)?.let { drawnLines ->
- val chatHeight = if (ChattingConfig.customChatHeight) getChatHeight(true) / 9 else GuiNewChat.calculateChatboxHeight(Minecraft.getMinecraft().gameSettings.chatHeightFocused / 9)
+ ChatSearchingManager.filterMessages(
+ (chat as GuiNewChatHook).prevText,
+ (chat as GuiNewChatAccessor).drawnChatLines
+ )?.let { drawnLines ->
+ val chatHeight =
+ if (ChattingConfig.customChatHeight) getChatHeight(true) / 9 else GuiNewChat.calculateChatboxHeight(
+ Minecraft.getMinecraft().gameSettings.chatHeightFocused / 9
+ )
for (i in scrollPos until drawnLines.size.coerceAtMost(scrollPos + chatHeight)) {
chatLines.add(drawnLines[i].chatComponent.formattedText)
}
@@ -189,11 +197,11 @@ object Chatting {
private fun screenshot(messages: List<String>): BufferedImage? {
if (messages.isEmpty()) {
- sendBrandedNotification("Chatting", "Chat window is empty.")
+ //sendBrandedNotification("Chatting", "Chat window is empty.")
return null
}
if (!OpenGlHelper.isFramebufferEnabled()) {
- sendBrandedNotification("Chatting", "Screenshot failed, please disable “Fast Render” in OptiFine’s “Performance” tab.")
+ //sendBrandedNotification("Chatting", "Screenshot failed, please disable “Fast Render” in OptiFine’s “Performance” tab.")
return null
}
@@ -212,11 +220,11 @@ object Chatting {
val image = fb.screenshot(file)
Minecraft.getMinecraft().entityRenderer.setupOverlayRendering()
Minecraft.getMinecraft().framebuffer.bindFramebuffer(true)
- sendBrandedNotification("Chatting", "Chat screenshotted successfully." + (if (ChattingConfig.copyMode != 1) "\nClick to open." else ""), action = {
- if (!UDesktop.open(file)) {
- sendBrandedNotification("Chatting", "Could not browse!")
- }
- })
+ //sendBrandedNotification("Chatting", "Chat screenshotted successfully." + (if (ChattingConfig.copyMode != 1) "\nClick to open." else ""), action = {
+ // if (!UDesktop.open(file)) {
+ // sendBrandedNotification("Chatting", "Could not browse!")
+ // }
+ // })
return image
}
}
diff --git a/src/main/kotlin/cc/woverflow/chatting/chat/ChatSearchingManager.kt b/src/main/kotlin/cc/woverflow/chatting/chat/ChatSearchingManager.kt
index 1e08719..25d479a 100644
--- a/src/main/kotlin/cc/woverflow/chatting/chat/ChatSearchingManager.kt
+++ b/src/main/kotlin/cc/woverflow/chatting/chat/ChatSearchingManager.kt
@@ -1,9 +1,9 @@
package cc.woverflow.chatting.chat
+import cc.polyfrost.oneconfig.libs.caffeine.cache.Cache
+import cc.polyfrost.oneconfig.libs.caffeine.cache.Caffeine
+import cc.polyfrost.oneconfig.libs.universal.wrappers.message.UTextComponent
import cc.woverflow.chatting.hook.GuiNewChatHook
-import gg.essential.lib.caffeine.cache.Cache
-import gg.essential.lib.caffeine.cache.Caffeine
-import gg.essential.universal.wrappers.message.UTextComponent
import net.minecraft.client.Minecraft
import net.minecraft.client.gui.ChatLine
import java.util.concurrent.LinkedBlockingQueue
diff --git a/src/main/kotlin/cc/woverflow/chatting/chat/ChatSpamBlock.kt b/src/main/kotlin/cc/woverflow/chatting/chat/ChatSpamBlock.kt
index 91ea6b5..471eec8 100644
--- a/src/main/kotlin/cc/woverflow/chatting/chat/ChatSpamBlock.kt
+++ b/src/main/kotlin/cc/woverflow/chatting/chat/ChatSpamBlock.kt
@@ -37,7 +37,7 @@ object ChatSpamBlock {
if (!ChattingConfig.customChatFormatting) {
newMessage += rank
}
- newMessage += "$player${EnumChatFormatting.DARK_GRAY.toString()}: $content"
+ newMessage += "$player${EnumChatFormatting.DARK_GRAY}: $content"
event.message = ChatComponentText(newMessage)
}
return
@@ -67,7 +67,7 @@ object ChatSpamBlock {
}
if (message.replace(Regex("[\\w\\s]"), "").length > 2) {
tokens.add("SPECIAL_CHARS")
- } else if (message.replace(Regex("[\\w\\s]"), "").length > 0) {
+ } else if (message.replace(Regex("[\\w\\s]"), "").isNotEmpty()) {
tokens.add("SPECIAL_CHAR")
} else {
tokens.add("LOW_SPECIAL_CHARS")
diff --git a/src/main/kotlin/cc/woverflow/chatting/chat/ChatTabs.kt b/src/main/kotlin/cc/woverflow/chatting/chat/ChatTabs.kt
index cdec672..62c2760 100644
--- a/src/main/kotlin/cc/woverflow/chatting/chat/ChatTabs.kt
+++ b/src/main/kotlin/cc/woverflow/chatting/chat/ChatTabs.kt
@@ -135,31 +135,31 @@ object ChatTabs {
val all = ChatTab(
true,
"ALL",
- false,
- false,
- null,
- null,
- null,
- null,
- null,
- null,
- null,
- null,
- null,
- null,
- TabButton.color,
- TabButton.hoveredColor,
- TabButton.selectedColor,
- ""
+ unformatted = false,
+ lowercase = false,
+ startsWith = null,
+ contains = null,
+ endsWith = null,
+ equals = null,
+ uncompiledRegex = null,
+ ignoreStartsWith = null,
+ ignoreContains = null,
+ ignoreEndsWith = null,
+ ignoreEquals = null,
+ uncompiledIgnoreRegex = null,
+ color = TabButton.color,
+ hoveredColor = TabButton.hoveredColor,
+ selectedColor = TabButton.selectedColor,
+ prefix = ""
)
val party = ChatTab(
true,
"PARTY",
- false,
- false,
- listOf("§r§9Party §8> ", "§r§9P §8> ", "§eThe party was transferred to §r", "§eKicked §r"),
- null,
- listOf(
+ unformatted = false,
+ lowercase = false,
+ startsWith = listOf("§r§9Party §8> ", "§r§9P §8> ", "§eThe party was transferred to §r", "§eKicked §r"),
+ contains = null,
+ endsWith = listOf(
"§r§ehas invited you to join their party!",
"§r§eto the party! They have §r§c60 §r§eseconds to accept.§r",
"§r§ehas disbanded the party!§r",
@@ -169,8 +169,8 @@ object ChatTabs {
" §r§ehas been removed from the party.§r",
"§r§e because they were offline.§r"
),
- listOf("§cThe party was disbanded because all invites expired and the party was empty§r"),
- listOf( //regexes from https://github.com/kwevin/Hychat-Tabs/blob/main/tabs/re-add%20prefixes%20%26%20fix%20shortened%20tags/chat.json cause i cant write regex
+ equals = listOf("§cThe party was disbanded because all invites expired and the party was empty§r"),
+ uncompiledRegex = listOf( //regexes from https://github.com/kwevin/Hychat-Tabs/blob/main/tabs/re-add%20prefixes%20%26%20fix%20shortened%20tags/chat.json cause i cant write regex
"(§r)*(§9Party §8\u003e)+(.*)",
"(?:(?:§[a-zA-Z0-9])*\\[(?:(?:VIP)|(?:VIP§r§6\\+)|(?:MVP)|(?:MVP(?:§r)?(?:§[a-zA-Z0-9])\\+)|(?:MVP(?:§r)?(?:§[a-zA-Z0-9])\\+\\+)|(?:(?:§r)?§fYOUTUBE))(?:§r)?(?:(?:§[a-zA-Z0-9]))?\\] [a-zA-Z0-9_]+|§7[a-zA-Z0-9_]+) §r§einvited §r(?:(?:§[a-zA-Z0-9])*\\[(?:(?:VIP)|(?:VIP§r§6\\+)|(?:MVP)|(?:MVP(?:§r)?(?:§[a-zA-Z0-9])\\+)|(?:MVP(?:§r)?(?:§[a-zA-Z0-9])\\+\\+)|(?:(?:§r)?§fYOUTUBE))(?:§r)?(?:(?:§[a-zA-Z0-9]))?\\] [a-zA-Z0-9_]+|§7[a-zA-Z0-9_]+) §r§eto the party! They have §r§c60 §r§eseconds to accept\\.§r",
"(?:(?:§[a-zA-Z0-9])*\\[(?:(?:VIP)|(?:VIP§r§6\\+)|(?:MVP)|(?:MVP(?:§r)?(?:§[a-zA-Z0-9])\\+)|(?:MVP(?:§r)?(?:§[a-zA-Z0-9])\\+\\+)|(?:(?:§r)?§fYOUTUBE))(?:§r)?(?:(?:§[a-zA-Z0-9]))?\\] [a-zA-Z0-9_]+|§7[a-zA-Z0-9_]+) §r§ehas left the party\\.§r",
@@ -211,55 +211,55 @@ object ChatTabs {
"§cThis party is currently muted\\.§r",
"(§r)*(§9P §8\u003e)+(.*)"
),
- null,
- null,
- null,
- null,
- null,
- TabButton.color,
- TabButton.hoveredColor,
- TabButton.selectedColor,
- "/pc "
+ ignoreStartsWith = null,
+ ignoreContains = null,
+ ignoreEndsWith = null,
+ ignoreEquals = null,
+ uncompiledIgnoreRegex = null,
+ color = TabButton.color,
+ hoveredColor = TabButton.hoveredColor,
+ selectedColor = TabButton.selectedColor,
+ prefix = "/pc "
)
val guild = ChatTab(
true,
"GUILD",
- true,
- false,
- listOf("Guild >", "G >"),
- null,
- null,
- null,
- null,
- null,
- null,
- null,
- null,
- null,
- TabButton.color,
- TabButton.hoveredColor,
- TabButton.selectedColor,
- "/gc "
+ unformatted = true,
+ lowercase = false,
+ startsWith = listOf("Guild >", "G >"),
+ contains = null,
+ endsWith = null,
+ equals = null,
+ uncompiledRegex = null,
+ ignoreStartsWith = null,
+ ignoreContains = null,
+ ignoreEndsWith = null,
+ ignoreEquals = null,
+ uncompiledIgnoreRegex = null,
+ color = TabButton.color,
+ hoveredColor = TabButton.hoveredColor,
+ selectedColor = TabButton.selectedColor,
+ prefix = "/gc "
)
val pm = ChatTab(
true,
"PM",
- true,
- false,
- listOf("To ", "From "),
- null,
- null,
- null,
- null,
- null,
- null,
- null,
- null,
- null,
- TabButton.color,
- TabButton.hoveredColor,
- TabButton.selectedColor,
- "/r "
+ unformatted = true,
+ lowercase = false,
+ startsWith = listOf("To ", "From "),
+ contains = null,
+ endsWith = null,
+ equals = null,
+ uncompiledRegex = null,
+ ignoreStartsWith = null,
+ ignoreContains = null,
+ ignoreEndsWith = null,
+ ignoreEquals = null,
+ uncompiledIgnoreRegex = null,
+ color = TabButton.color,
+ hoveredColor = TabButton.hoveredColor,
+ selectedColor = TabButton.selectedColor,
+ prefix = "/r "
)
tabs.add(all)
tabs.add(party)
diff --git a/src/main/kotlin/cc/woverflow/chatting/command/ChattingCommand.kt b/src/main/kotlin/cc/woverflow/chatting/command/ChattingCommand.kt
new file mode 100644
index 0000000..0ba8bd7
--- /dev/null
+++ b/src/main/kotlin/cc/woverflow/chatting/command/ChattingCommand.kt
@@ -0,0 +1,16 @@
+package cc.woverflow.chatting.command
+
+import cc.polyfrost.oneconfig.utils.commands.annotations.Command
+import cc.polyfrost.oneconfig.utils.commands.annotations.Main
+import cc.woverflow.chatting.Chatting
+import cc.woverflow.chatting.config.ChattingConfig
+
+@Command(value = Chatting.ID, description = "Access the " + Chatting.NAME + " GUI.")
+class ChattingCommand {
+ companion object {
+ @Main
+ fun main() {
+ ChattingConfig.openGui()
+ }
+ }
+} \ No newline at end of file
diff --git a/src/main/kotlin/cc/woverflow/chatting/config/ChattingConfig.kt b/src/main/kotlin/cc/woverflow/chatting/config/ChattingConfig.kt
index 3041af8..9704e29 100644
--- a/src/main/kotlin/cc/woverflow/chatting/config/ChattingConfig.kt
+++ b/src/main/kotlin/cc/woverflow/chatting/config/ChattingConfig.kt
@@ -1,84 +1,75 @@
package cc.woverflow.chatting.config
+import cc.polyfrost.oneconfig.config.Config
+import cc.polyfrost.oneconfig.config.annotations.Button
+import cc.polyfrost.oneconfig.config.annotations.Checkbox
+import cc.polyfrost.oneconfig.config.annotations.Dropdown
+import cc.polyfrost.oneconfig.config.annotations.Info
+import cc.polyfrost.oneconfig.config.annotations.Slider
+import cc.polyfrost.oneconfig.config.annotations.Switch
+import cc.polyfrost.oneconfig.config.core.OneColor
+import cc.polyfrost.oneconfig.config.data.InfoType
+import cc.polyfrost.oneconfig.config.data.Mod
+import cc.polyfrost.oneconfig.config.data.ModType
+import cc.polyfrost.oneconfig.config.migration.VigilanceMigrator
+import cc.polyfrost.oneconfig.utils.dsl.openScreen
+import cc.polyfrost.oneconfig.utils.hypixel.HypixelUtils
import cc.woverflow.chatting.Chatting
import cc.woverflow.chatting.chat.ChatShortcuts
import cc.woverflow.chatting.chat.ChatTab
import cc.woverflow.chatting.chat.ChatTabs
import cc.woverflow.chatting.gui.ChatShortcutViewGui
import cc.woverflow.chatting.gui.components.TabButton
-import cc.woverflow.onecore.utils.openScreen
-import gg.essential.api.EssentialAPI
-import gg.essential.vigilance.Vigilant
-import gg.essential.vigilance.data.Category
-import gg.essential.vigilance.data.Property
-import gg.essential.vigilance.data.PropertyType
-import gg.essential.vigilance.data.SortingBehavior
-import java.awt.Color
+
import java.io.File
object ChattingConfig :
- Vigilant(
- File(Chatting.modDir, "${Chatting.ID}.toml"),
- Chatting.NAME,
- sortingBehavior = ConfigSorting
+ Config(
+ Mod(Chatting.NAME, ModType.UTIL_QOL, VigilanceMigrator(File(Chatting.modDir, Chatting.ID + ".toml").toPath().toString())),
+ "chatting.json"
) {
- @Property(
- type = PropertyType.SELECTOR,
+ @Dropdown(
name = "Text Render Type",
- description = "Choose the type of rendering for the text.",
category = "General",
options = ["No Shadow", "Shadow", "Full Shadow"]
)
var textRenderType = 1
- @Property(
- type = PropertyType.SWITCH,
+ @Switch(
name = "Remove Tooltip Background",
- description = "Remove the tooltip background.",
category = "General"
)
var removeTooltipBackground = false
- @Property(
- type = PropertyType.SWITCH,
+ @Switch(
name = "Remove Scroll Bar",
- description = "Remove the scroll bar.",
category = "General"
)
var removeScrollBar = false
- @Property(
- type = PropertyType.COLOR,
+ @cc.polyfrost.oneconfig.config.annotations.Color(
name = "Chat Background Color",
- description = "Change the color of the chat background.",
category = "General",
allowAlpha = false
)
- var chatBackgroundColor = Color(0, 0, 0, 128)
+ var chatBackgroundColor = OneColor(0, 0, 0, 128)
- @Property(
- type = PropertyType.COLOR,
+ @cc.polyfrost.oneconfig.config.annotations.Color(
name = "Copy Chat Message Background Color",
- description = "Change the color of chat messages that are ready to copy.",
category = "General",
allowAlpha = false
)
- var hoveredChatBackgroundColor = Color(80, 80, 80, 128)
+ var hoveredChatBackgroundColor = OneColor(80, 80, 80, 128)
- @Property(
- type = PropertyType.SWITCH,
+ @Switch(
name = "Compact Input Box",
- description = "Make the width of the input box the same size as the chat box.",
category = "General"
)
var compactInputBox = false
- @Property(
- type = PropertyType.SWITCH,
- name = "Inform for Alternatives",
- description =
- "Inform the user if a mod they are using can be replaced by a feature in Chatting.",
+ @Switch(
+ name = "Inform Outdated Mods",
category = "General"
)
var informForAlternatives = true
@@ -102,167 +93,141 @@ object ChattingConfig :
*/
- @Property(
- type = PropertyType.SLIDER,
- min = 80,
- max = 100,
- name = "Spam Blocker Threshold",
- description =
- "If Chatting detects a public chat message that seems like spam, and the probability is higher than this, it will hide it.\n" +
+ @Info(
+ text = "If Chatting detects a public chat message that seems like spam, and the probability is higher than this, it will hide it.\n" +
"Made for Hypixel Skyblock. Set to 100% to disable. 95% is a reasonable threshold to use it at.\n" +
"Note that this is not and never will be 100% accurate; however, it's pretty much guaranteed to block most spam.",
+ size = 2, category = "Player Chats",
+ type = InfoType.INFO
+ )
+ var ignored = false
+
+ @Slider(
+ min = 80F,
+ max = 100F,
+ name = "Spam Blocker Threshold",
category = "Player Chats"
)
var spamThreshold = 100
- @Property(
- type = PropertyType.SWITCH,
- name = "Custom Chat Formatting",
- description =
- "Reformat all Skyblock chat messages. Example:\n" +
- "§a[VIP] Person§f: Message\n§7Person2: Message\n" +
- "§eBecomes:\n" +
- "§aPerson§f: Message\n§7Person2§f: Message",
+ @Switch(
+ name = "Custom SkyBlock Chat Formatting (remove ranks)",
category = "Player Chats"
)
var customChatFormatting = false
- @Property(
- type = PropertyType.SWITCH,
- name = "Hide Spam",
- description =
- "When Chatting detects spam (if it's enabled), hide it instead of just graying it out.",
+ @Switch(
+ name = "Completely Hide Spam",
category = "Player Chats"
)
var hideSpam = false
- @Property(
- type = PropertyType.SWITCH,
+ @Switch(
name = "Custom Chat Height",
- description = "Allows you to change the height of chat to heights greater than before.",
category = "Chat Window"
)
var customChatHeight = true
- @Property(
- type = PropertyType.SLIDER,
- min = 180,
- max = 2160,
- name = "Focused Height",
- description = "Height in pixels.",
+ @Slider(
+ min = 180F,
+ max = 2160F,
+ name = "Focused Height (px)",
category = "Chat Window"
)
var focusedHeight = 180
- @Property(
- type = PropertyType.SLIDER,
- min = 180,
- max = 2160,
- name = "Unfocused Height",
- description = "Height in pixels.",
+ @Slider(
+ min = 180F,
+ max = 2160F,
+ name = "Unfocused Height (px)",
category = "Chat Window"
)
var unfocusedHeight = 180
- @Property(
- type = PropertyType.SELECTOR,
+ @Dropdown(
name = "Screenshot Mode",
- description = "The mode in which screenshotting will work.",
category = "Screenshotting",
options = ["Save To System", "Add To Clipboard", "Both"]
)
var copyMode = 0
- @Property(
- type = PropertyType.SWITCH,
+ @Checkbox(
name = "Chat Searching",
- description = "Add a chat search bar.",
category = "Searching"
)
var chatSearch = true
- @Property(
- type = PropertyType.SWITCH,
+ @Switch(
name = "Chat Tabs",
- description = "Add chat tabs.",
category = "Tabs"
)
var chatTabs = true
get() {
if (!field) return false
return if (hypixelOnlyChatTabs) {
- EssentialAPI.getMinecraftUtil().isHypixel()
+ HypixelUtils.INSTANCE.isHypixel
} else {
true
}
}
- @Property(
- type = PropertyType.SWITCH,
+ @Checkbox(
name = "Enable Tabs Only on Hypixel",
- description = "Enable chat tabs only in Hypixel.",
category = "Tabs"
)
var hypixelOnlyChatTabs = true
- @Property(
- type = PropertyType.SWITCH,
+ @Switch(
name = "Chat Shortcuts",
- description = "Add chat shortcuts.",
category = "Shortcuts"
)
var chatShortcuts = false
get() {
if (!field) return false
return if (hypixelOnlyChatShortcuts) {
- EssentialAPI.getMinecraftUtil().isHypixel()
+ HypixelUtils.INSTANCE.isHypixel
} else {
true
}
}
- @Property(
- type = PropertyType.SWITCH,
+ @Checkbox(
name = "Enable Shortcuts Only on Hypixel",
- description = "Enable chat shortcuts only in Hypixel.",
category = "Shortcuts"
)
var hypixelOnlyChatShortcuts = true
- @Property(
- type = PropertyType.BUTTON,
- name = "Edit Chat Shortcuts",
- description = "Edit chat shortcuts.",
- category = "Shortcuts"
+ @Button(
+ name = "Open Chat Shortcuts Editor GUI",
+ category = "Shortcuts", text = "Open"
)
- fun openChatShortcutsGUI() = ChatShortcutViewGui().openScreen()
+ var openChatShortcutsGUI = Runnable { ChatShortcutViewGui().openScreen() }
init {
initialize()
- registerListener("chatTabs") { funny: Boolean ->
- chatTabs = funny
+ addListener("chatTabs") {
ChatTabs.initialize()
- if (!funny) {
+ if (!chatTabs) {
val dummy =
ChatTab(
true,
"ALL",
- false,
- false,
- null,
- null,
- null,
- null,
- null,
- null,
- null,
- null,
- null,
- null,
- TabButton.color,
- TabButton.hoveredColor,
- TabButton.selectedColor,
- ""
+ unformatted = false,
+ lowercase = false,
+ startsWith = null,
+ contains = null,
+ endsWith = null,
+ equals = null,
+ uncompiledRegex = null,
+ ignoreStartsWith = null,
+ ignoreContains = null,
+ ignoreEndsWith = null,
+ ignoreEquals = null,
+ uncompiledIgnoreRegex = null,
+ color = TabButton.color,
+ hoveredColor = TabButton.hoveredColor,
+ selectedColor = TabButton.selectedColor,
+ prefix = ""
)
dummy.initialize()
ChatTabs.currentTab = dummy
@@ -270,17 +235,9 @@ object ChattingConfig :
ChatTabs.currentTab = ChatTabs.tabs[0]
}
}
- registerListener("chatShortcuts") { funny: Boolean ->
- chatShortcuts = funny
+ addListener("chatShortcuts") {
ChatShortcuts.initialize()
}
// addDependency("showTimestampHover", "showTimestamp")
}
-
- private object ConfigSorting : SortingBehavior() {
- override fun getCategoryComparator(): Comparator<in Category> = Comparator { o1, o2 ->
- if (o1.name == "General") return@Comparator -1
- if (o2.name == "General") return@Comparator 1 else compareValuesBy(o1, o2) { it.name }
- }
- }
}
diff --git a/src/main/kotlin/cc/woverflow/chatting/gui/components/CleanButton.kt b/src/main/kotlin/cc/woverflow/chatting/gui/components/CleanButton.kt
index 1d8d8ce..de69bab 100644
--- a/src/main/kotlin/cc/woverflow/chatting/gui/components/CleanButton.kt
+++ b/src/main/kotlin/cc/woverflow/chatting/gui/components/CleanButton.kt
@@ -2,7 +2,7 @@ package cc.woverflow.chatting.gui.components
import cc.woverflow.chatting.Chatting
import cc.woverflow.chatting.hook.GuiNewChatHook
-import cc.woverflow.onecore.utils.drawBorderedString
+import cc.woverflow.chatting.utils.ModCompatHooks.drawBorderedString
import club.sk1er.patcher.config.PatcherConfig
import net.minecraft.client.Minecraft
import net.minecraft.client.gui.GuiButton
@@ -14,17 +14,26 @@ import java.awt.Color
* https://github.com/P0keDev/ChatShortcuts/blob/master/LICENSE
* @author P0keDev
*/
-open class CleanButton(buttonId: Int, private val x: () -> Int, private val y: () -> Int, widthIn: Int, heightIn: Int, name: String, private val renderType: () -> RenderType, private val textColor: (packedFGColour: Int, enabled: Boolean, hovered: Boolean) -> Int = { packedFGColour: Int, enabled: Boolean, hovered: Boolean ->
- var j = 14737632
- if (packedFGColour != 0) {
- j = packedFGColour
- } else if (!enabled) {
- j = 10526880
- } else if (hovered) {
- j = 16777120
+open class CleanButton(
+ buttonId: Int,
+ private val x: () -> Int,
+ private val y: () -> Int,
+ widthIn: Int,
+ heightIn: Int,
+ name: String,
+ private val renderType: () -> RenderType,
+ private val textColor: (packedFGColour: Int, enabled: Boolean, hovered: Boolean) -> Int = { packedFGColour: Int, enabled: Boolean, hovered: Boolean ->
+ var j = 14737632
+ if (packedFGColour != 0) {
+ j = packedFGColour
+ } else if (!enabled) {
+ j = 10526880
+ } else if (hovered) {
+ j = 16777120
+ }
+ j
}
- j
-}) :
+) :
GuiButton(buttonId, x.invoke(), 0, widthIn, heightIn, name) {
open fun isEnabled(): Boolean {
@@ -66,10 +75,23 @@ open class CleanButton(buttonId: Int, private val x: () -> Int, private val y: (
val j = textColor(packedFGColour, enabled, hovered)
when (renderType()) {
RenderType.NONE, RenderType.SHADOW -> {
- drawCenteredString(fontrenderer, displayString, xPosition + width / 2, yPosition + (height - 8) / 2, j)
+ drawCenteredString(
+ fontrenderer,
+ displayString,
+ xPosition + width / 2,
+ yPosition + (height - 8) / 2,
+ j
+ )
}
+
RenderType.FULL -> {
- fontrenderer.drawBorderedString(displayString, (xPosition + width / 2) - (fontrenderer.getStringWidth(displayString) / 2), yPosition + (height - 8) / 2, j, (Minecraft.getMinecraft().ingameGUI.chatGUI as GuiNewChatHook).textOpacity)
+ fontrenderer.drawBorderedString(
+ displayString,
+ (xPosition + width / 2) - (fontrenderer.getStringWidth(displayString) / 2),
+ yPosition + (height - 8) / 2,
+ j,
+ (Minecraft.getMinecraft().ingameGUI.chatGUI as GuiNewChatHook).textOpacity
+ )
}
}
}
diff --git a/src/main/kotlin/cc/woverflow/chatting/utils/ImageTransferable.kt b/src/main/kotlin/cc/woverflow/chatting/utils/ImageTransferable.kt
deleted file mode 100644
index 563f17a..0000000
--- a/src/main/kotlin/cc/woverflow/chatting/utils/ImageTransferable.kt
+++ /dev/null
@@ -1,22 +0,0 @@
-package cc.woverflow.chatting.utils
-
-import java.awt.Image
-import java.awt.datatransfer.DataFlavor
-import java.awt.datatransfer.Transferable
-import java.awt.datatransfer.UnsupportedFlavorException
-
-data class ImageTransferable(private val image: Image) : Transferable {
-
- override fun getTransferDataFlavors(): Array<DataFlavor> {
- return arrayOf(DataFlavor.imageFlavor)
- }
-
- override fun isDataFlavorSupported(flavor: DataFlavor?): Boolean {
- return DataFlavor.imageFlavor.equals(flavor)
- }
-
- override fun getTransferData(flavor: DataFlavor?): Any {
- if (isDataFlavorSupported(flavor)) return image
- throw UnsupportedFlavorException(flavor)
- }
-} \ No newline at end of file
diff --git a/src/main/kotlin/cc/woverflow/chatting/utils/ModCompatHooks.kt b/src/main/kotlin/cc/woverflow/chatting/utils/ModCompatHooks.kt
index 39455ae..fd337de 100644
--- a/src/main/kotlin/cc/woverflow/chatting/utils/ModCompatHooks.kt
+++ b/src/main/kotlin/cc/woverflow/chatting/utils/ModCompatHooks.kt
@@ -4,7 +4,6 @@ import cc.woverflow.chatting.Chatting.isBetterChat
import cc.woverflow.chatting.Chatting.isPatcher
import cc.woverflow.chatting.config.ChattingConfig.textRenderType
import cc.woverflow.chatting.hook.GuiNewChatHook
-import cc.woverflow.onecore.utils.drawBorderedString
import club.sk1er.patcher.config.PatcherConfig
import com.llamalad7.betterchat.BetterChat
import net.minecraft.client.Minecraft
@@ -36,8 +35,45 @@ object ModCompatHooks {
fun redirectDrawString(text: String, x: Float, y: Float, color: Int): Int {
return when (textRenderType) {
0 -> fontRenderer.drawString(text, x, y, color, false)
- 2 -> fontRenderer.drawBorderedString(text, x.toInt(), y.toInt(), color, (Minecraft.getMinecraft().ingameGUI.chatGUI as GuiNewChatHook).textOpacity)
+ 2 -> fontRenderer.drawBorderedString(
+ text,
+ x.toInt(),
+ y.toInt(),
+ color,
+ (Minecraft.getMinecraft().ingameGUI.chatGUI as GuiNewChatHook).textOpacity
+ )
+
else -> fontRenderer.drawString(text, x, y, color, true)
}
}
+
+
+ private val regex = Regex("(?i)\\u00A7[0-9a-f]")
+ private var bypassNameHighlight = false
+ fun FontRenderer.drawBorderedString(
+ text: String, x: Int, y: Int, color: Int, opacity: Int
+ ): Int {
+ val noColors = text.replace(regex, "\u00A7r")
+ var yes = 0
+ if (opacity > 3) {
+ bypassNameHighlight = true
+ for (xOff in -2..2) {
+ for (yOff in -2..2) {
+ if (xOff * xOff != yOff * yOff) {
+ yes +=
+ drawString(
+ noColors, (xOff / 2f) + x, (yOff / 2f) + y, (opacity) shl 24, false
+ )
+
+ }
+ }
+ }
+ bypassNameHighlight = false
+ }
+ yes +=
+ //#if MODERN==0
+ drawString(text, x, y, color)
+
+ return yes
+ }
}
diff --git a/src/main/kotlin/cc/woverflow/chatting/utils/renderutils.kt b/src/main/kotlin/cc/woverflow/chatting/utils/RenderUtils.kt
index 19835ac..12051cf 100644
--- a/src/main/kotlin/cc/woverflow/chatting/utils/renderutils.kt
+++ b/src/main/kotlin/cc/woverflow/chatting/utils/RenderUtils.kt
@@ -2,18 +2,11 @@
package cc.woverflow.chatting.utils
+import cc.polyfrost.oneconfig.utils.IOUtils
import cc.woverflow.chatting.config.ChattingConfig
-import cc.woverflow.chatting.mixin.GuiNewChatAccessor
-import cc.woverflow.chatting.utils.ModCompatHooks.fontRenderer
-import gg.essential.universal.ChatColor
-import gg.essential.universal.UMouse
-import net.minecraft.client.Minecraft
-import net.minecraft.client.gui.ChatLine
-import net.minecraft.client.gui.ScaledResolution
import net.minecraft.client.renderer.GlStateManager
import net.minecraft.client.renderer.texture.TextureUtil
import net.minecraft.client.shader.Framebuffer
-import net.minecraft.util.MathHelper
import org.apache.commons.lang3.SystemUtils
import org.lwjgl.BufferUtils
import org.lwjgl.opengl.GL11
@@ -28,7 +21,6 @@ import java.lang.reflect.Method
import java.nio.ByteBuffer
import java.nio.ByteOrder
import javax.imageio.ImageIO
-import kotlin.math.roundToInt
/**
* Taken from https://github.com/Moulberry/HyChat
@@ -178,7 +170,7 @@ fun BufferedImage.copyToClipboard() {
newImage.setRGB(0, 0, newImage.width, newImage.height, pixels, 0, newImage.width)
try {
- Toolkit.getDefaultToolkit().systemClipboard.setContents(ImageTransferable(this), null)
+ IOUtils.copyImageToClipboard(this)
} catch (e: Exception) {
e.printStackTrace()
}