Skip to content

Commit

Permalink
Add skytils copy chat compat
Browse files Browse the repository at this point in the history
Add option to only have copy chat when clicking ctrl
  • Loading branch information
Wyvest committed Jul 29, 2024
1 parent 60b1a6d commit e77e87e
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ private void mouseClicked(int mouseX, int mouseY, int mouseButton, CallbackInfo
if (hook.chatting$isHovering()) {
boolean copy = ChattingConfig.INSTANCE.getChatCopy();
int right = (int) ((hook.chatting$getRight() + ModCompatHooks.getXOffset() + 1 + hud.getPaddingX() * (ChattingConfig.INSTANCE.getExtendBG() ? 1f : 2f)) * hud.getScale() + (int) hud.position.getX()) * scale;
if (copy && x > right && x < right + 9 * hud.getScale() * scale || (mouseButton == 1 && ChattingConfig.INSTANCE.getRightClickCopy())) {
if (copy && x > right && x < right + 9 * hud.getScale() * scale || (mouseButton == 1 && ChattingConfig.INSTANCE.getRightClickCopy() && (!ChattingConfig.INSTANCE.getRightClickCopyCtrl() || UKeyboard.isCtrlKeyDown()))) {
Transferable message = hook.chatting$getChattingChatComponent(Mouse.getY());
if (message == null) return;
try {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.polyfrost.chatting.mixin;
package org.polyfrost.chatting.mixin.compat;

import cc.polyfrost.oneconfig.utils.Notifications;
import org.polyfrost.chatting.config.ChattingConfig;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package org.polyfrost.chatting.mixin.compat;

import cc.polyfrost.oneconfig.utils.Notifications;
import net.minecraft.client.gui.GuiScreen;
import org.polyfrost.chatting.config.ChattingConfig;
import org.spongepowered.asm.mixin.Dynamic;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Pseudo;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;

@Pseudo
@Mixin(targets = "gg.skytils.skytilsmod.features.impl.handlers.ChatTabs")
public class ChatTabsMixin_SkytilsCopyChat {

@Unique
private static long chatting$lastNotify = System.currentTimeMillis();

@Dynamic("Skytils")
@Redirect(method = "onAttemptCopy", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiScreen;isCtrlKeyDown()Z"))
private boolean onAttemptCopy() {
boolean isCtrlKeyDown = GuiScreen.isCtrlKeyDown();
if (!ChattingConfig.INSTANCE.getRightClickCopy() && isCtrlKeyDown) {
if (System.currentTimeMillis() - chatting$lastNotify >= 1000) {
Notifications.INSTANCE.send("Chatting", "Skytils' Copy Chat has been replaced by Chatting. You can configure this via OneConfig, by clicking the right shift key on your keyboard, or by typing /chatting in your chat.");
chatting$lastNotify = System.currentTimeMillis();
}
}
return false;
}

@Dynamic("Skytils")
@Redirect(method = "onAttemptCopy", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiScreen;isShiftKeyDown()Z"))
private boolean onAttemptCopyShift() {
boolean isShiftKeyDown = GuiScreen.isShiftKeyDown();
if (!ChattingConfig.INSTANCE.getRightClickCopy() && isShiftKeyDown) {
if (System.currentTimeMillis() - chatting$lastNotify >= 1000) {
Notifications.INSTANCE.send("Chatting", "Skytils' Copy Chat has been replaced by Chatting. You can configure this via OneConfig, by clicking the right shift key on your keyboard, or by typing /chatting in your chat.");
chatting$lastNotify = System.currentTimeMillis();
}
}
return false;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.polyfrost.chatting.mixin;
package org.polyfrost.chatting.mixin.compat;

import cc.polyfrost.oneconfig.utils.Notifications;
import org.polyfrost.chatting.config.ChattingConfig;
Expand Down
17 changes: 16 additions & 1 deletion src/main/kotlin/org/polyfrost/chatting/config/ChattingConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,12 @@ object ChattingConfig : Config(
)
var rightClickCopy = false

@Switch(
name = "Only Click Copy Chat Message when Holding CTRL", category = "Buttons",
description = "Only allow right clicking on a chat message to copy it when holding CTRL."
)
var rightClickCopyCtrl = true

@Switch(
name = "Delete Chat Message Button", category = "Buttons",
description = "Enable deleting individual chat messages via a button."
Expand Down Expand Up @@ -253,13 +259,21 @@ object ChattingConfig : Config(
*/

@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.",
text = "If Chatting detects a public chat message that seems like spam, and the probability is higher than this, it will hide it.",
size = 2,
category = "Player Chats",
type = InfoType.INFO
)
var ignored = false

@Info(
text = "Made for Hypixel Skyblock. Set to 100% to disable. 95% is a reasonable threshold to use it at. May not be accurate.",
size = 2,
category = "Player Chats",
type = InfoType.INFO
)
var ignored1 = false

@Slider(
min = 80F, max = 100F, name = "Spam Blocker Threshold", category = "Player Chats"
)
Expand Down Expand Up @@ -388,6 +402,7 @@ object ChattingConfig : Config(
}
} catch (_: ClassNotFoundException) {}

addDependency("rightClickCopyCtrl", "rightClickCopy")
addDependency("fadeTime", "fade")
addDependency("offsetNonPlayerMessages", "showChatHeads")
addDependency("hideChatHeadOnConsecutiveMessages", "showChatHeads")
Expand Down
11 changes: 5 additions & 6 deletions src/main/resources/mixins.chatting.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"verbose": true,
"client": [
"ChatLineMixin",
"ChatStyleMixin",
"ClientCommandHandlerMixin",
"EntityPlayerSPMixin",
"EntityRendererMixin",
Expand All @@ -27,11 +28,9 @@
"GuiTextFieldMixin",
"GuiUtilsMixin",
"HUDUtilsMixin",
"InventoryPlayerMixin"
],
"mixins": [
"ChatPeekMixin_SkyHanni",
"ChatStyleMixin",
"EssentialKeybindingRegistryMixin"
"InventoryPlayerMixin",
"compat.ChatPeekMixin_SkyHanni",
"compat.ChatTabsMixin_SkytilsCopyChat",
"compat.EssentialKeybindingRegistryMixin"
]
}

0 comments on commit e77e87e

Please sign in to comment.