mirror of https://github.com/kami-blue/client
Converted chat modules to Kotlin
This commit is contained in:
parent
7e94c12184
commit
0ca0281401
|
@ -13,7 +13,7 @@ import static me.zeroeightsix.kami.util.MessageSendHelper.*;
|
|||
*/
|
||||
public class AutoReplyCommand extends Command {
|
||||
public AutoReplyCommand() {
|
||||
super("autoreply", new ChunkBuilder().append("message").append("=listener").append("-replyCommand").build(), "reply");
|
||||
super("autoreply", new ChunkBuilder().append("message").build(), "reply");
|
||||
setDescription("Allows you to customize AutoReply's settings");
|
||||
}
|
||||
|
||||
|
@ -24,37 +24,15 @@ public class AutoReplyCommand extends Command {
|
|||
sendErrorMessage("&cThe AutoReply module is not available for some reason. Make sure the name you're calling is correct and that you have the module installed!!");
|
||||
return;
|
||||
}
|
||||
if (!autoReply.isEnabled()) {
|
||||
sendWarningMessage("&6Warning: The AutoReply module is not enabled!");
|
||||
|
||||
if (args[0] == null) return;
|
||||
|
||||
autoReply.message.setValue(args[0]);
|
||||
sendChatMessage("Set the AutoReply message to '&7" + args[0] + "&f'");
|
||||
|
||||
if (!autoReply.customMessage.getValue()) {
|
||||
sendWarningMessage("&6Warning:&f You don't have '&7Custom Message&f' enabled in AutoReply!");
|
||||
sendWarningMessage("The command will still work, but will not visibly do anything.");
|
||||
}
|
||||
for (String s : args) {
|
||||
if (s == null)
|
||||
continue;
|
||||
if (s.startsWith("=")) {
|
||||
String sT = s.replace("=" ,"");
|
||||
autoReply.listener.setValue(sT);
|
||||
sendChatMessage("Set the AutoReply listener to <" + sT + ">");
|
||||
if (!autoReply.customListener.getValue()) {
|
||||
sendWarningMessage("&6Warning: You don't have Custom Listener enabled in AutoReply!");
|
||||
sendWarningMessage("The command will still work, but will not visibly do anything.");
|
||||
}
|
||||
} else if (s.startsWith("-")) {
|
||||
String sT = s.replace("-" ,"");
|
||||
autoReply.replyCommand.setValue(sT);
|
||||
sendChatMessage("Set the AutoReply reply command to <" + sT + ">");
|
||||
if (!autoReply.customReplyCommand.getValue()) {
|
||||
sendWarningMessage("&6Warning: You don't have Custom Reply Command enabled in AutoReply!");
|
||||
sendWarningMessage("The command will still work, but will not visibly do anything.");
|
||||
}
|
||||
} else {
|
||||
autoReply.message.setValue(s);
|
||||
sendChatMessage("Set the AutoReply message to <" + s + ">");
|
||||
if (!autoReply.customMessage.getValue()) {
|
||||
sendWarningMessage("&6Warning: You don't have Custom Message enabled in AutoReply!");
|
||||
sendWarningMessage("The command will still work, but will not visibly do anything.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,347 +0,0 @@
|
|||
package me.zeroeightsix.kami.module.modules.chat;
|
||||
|
||||
import me.zero.alpine.listener.EventHandler;
|
||||
import me.zero.alpine.listener.Listener;
|
||||
import me.zeroeightsix.kami.KamiMod;
|
||||
import me.zeroeightsix.kami.module.Module;
|
||||
import me.zeroeightsix.kami.setting.Setting;
|
||||
import me.zeroeightsix.kami.setting.Settings;
|
||||
import net.minecraftforge.client.event.ClientChatReceivedEvent;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static me.zeroeightsix.kami.util.MessageDetectionHelper.isDirect;
|
||||
import static me.zeroeightsix.kami.util.MessageDetectionHelper.isDirectOther;
|
||||
import static me.zeroeightsix.kami.util.MessageSendHelper.sendChatMessage;
|
||||
|
||||
/**
|
||||
* @author hub
|
||||
* @author dominikaaaa
|
||||
* Created 19 November 2019 by hub
|
||||
* Updated 12 January 2020 by hub
|
||||
* Updated 19 February 2020 by aUniqueUser
|
||||
* Updated by dominikaaaa on 19/04/20
|
||||
*/
|
||||
@Module.Info(
|
||||
name = "AntiSpam",
|
||||
category = Module.Category.CHAT,
|
||||
description = "Removes spam and advertising from the chat",
|
||||
showOnArray = Module.ShowOnArray.OFF
|
||||
)
|
||||
public class AntiSpam extends Module {
|
||||
|
||||
private Setting<Page> p = register(Settings.e("Page", Page.ONE));
|
||||
/* Page One */
|
||||
private Setting<Boolean> discordLinks = register(Settings.booleanBuilder("Discord Links").withValue(true).withVisibility(v -> p.getValue().equals(Page.ONE)).build());
|
||||
private Setting<Boolean> announcers = register(Settings.booleanBuilder("Announcers").withValue(true).withVisibility(v -> p.getValue().equals(Page.ONE)).build());
|
||||
private Setting<Boolean> spammers = register(Settings.booleanBuilder("Spammers").withValue(true).withVisibility(v -> p.getValue().equals(Page.ONE)).build());
|
||||
private Setting<Boolean> insulters = register(Settings.booleanBuilder("Insulters").withValue(true).withVisibility(v -> p.getValue().equals(Page.ONE)).build());
|
||||
private Setting<Boolean> greeters = register(Settings.booleanBuilder("Greeters").withValue(true).withVisibility(v -> p.getValue().equals(Page.ONE)).build());
|
||||
private Setting<Boolean> ips = register(Settings.booleanBuilder("Server Ips").withValue(true).withVisibility(v -> p.getValue().equals(Page.ONE)).build());
|
||||
private Setting<Boolean> specialCharEnding = register(Settings.booleanBuilder("Special Ending").withValue(true).withVisibility(v -> p.getValue().equals(Page.ONE)).build());
|
||||
private Setting<Boolean> specialCharBegin = register(Settings.booleanBuilder("Special Begin").withValue(true).withVisibility(v -> p.getValue().equals(Page.ONE)).build());
|
||||
private Setting<Boolean> iJustThanksTo = register(Settings.booleanBuilder("I just...thanks to").withValue(true).withVisibility(v -> p.getValue().equals(Page.ONE)).build());
|
||||
/* I can't get settings to work in non static context for filter */
|
||||
// private Setting<Integer> characters = register(Settings.integerBuilder("Characters").withValue(15).withVisibility(v -> wordsLongerThen.getValue() && p.getValue().equals(Page.ONE)).build());
|
||||
|
||||
/* Page Two */
|
||||
private Setting<Boolean> ownsMeAndAll = register(Settings.booleanBuilder("Owns Me And All").withValue(true).withVisibility(v -> p.getValue().equals(Page.TWO)).build());
|
||||
private Setting<Boolean> greenText = register(Settings.booleanBuilder("Green Text").withValue(false).withVisibility(v -> p.getValue().equals(Page.TWO)).build());
|
||||
private Setting<Boolean> numberSuffix = register(Settings.booleanBuilder("Number Ending").withValue(false).withVisibility(v -> p.getValue().equals(Page.TWO)).build());
|
||||
private Setting<Boolean> numberPrefix = register(Settings.booleanBuilder("Number Begin").withValue(false).withVisibility(v -> p.getValue().equals(Page.TWO)).build());
|
||||
private Setting<Boolean> duplicates = register(Settings.booleanBuilder("Duplicates").withValue(true).withVisibility(v -> p.getValue().equals(Page.TWO)).build());
|
||||
private Setting<Integer> duplicatesTimeout = register(Settings.integerBuilder("Duplicates Timeout").withMinimum(1).withValue(30).withMaximum(600).withVisibility(v -> duplicates.getValue() && p.getValue().equals(Page.TWO)).build());
|
||||
private Setting<Boolean> webLinks = register(Settings.booleanBuilder("Web Links").withValue(false).withVisibility(v -> p.getValue().equals(Page.TWO)).build());
|
||||
private Setting<Boolean> filterOwn = register(Settings.booleanBuilder("Filter Own").withValue(false).withVisibility(v -> p.getValue().equals(Page.TWO)).build());
|
||||
private Setting<Boolean> filterDMs = register(Settings.booleanBuilder("Filter DMs").withValue(false).withVisibility(v -> p.getValue().equals(Page.TWO)).build());
|
||||
private Setting<ShowBlocked> showBlocked = register(Settings.enumBuilder(ShowBlocked.class).withName("Show Blocked").withValue(ShowBlocked.LOG_FILE).withVisibility(v -> p.getValue().equals(Page.TWO)).build());
|
||||
|
||||
private ConcurrentHashMap<String, Long> messageHistory;
|
||||
private enum Page { ONE, TWO }
|
||||
private enum ShowBlocked { NONE, LOG_FILE, CHAT }
|
||||
|
||||
@EventHandler
|
||||
public Listener<ClientChatReceivedEvent> listener = new Listener<>(event -> {
|
||||
if (mc.player == null) return;
|
||||
|
||||
/* leijurv's sexy lambda to remove older entries in messageHistory */
|
||||
messageHistory.entrySet()
|
||||
.stream()
|
||||
.filter(entry -> entry.getValue() < System.currentTimeMillis() - 10 * 60 * 1000) // 10 is delay in minutes
|
||||
.collect(Collectors.toList())
|
||||
.forEach(entry -> messageHistory.remove(entry.getKey()));
|
||||
|
||||
if (isSpam(event.getMessage().getUnformattedText())) {
|
||||
event.setCanceled(true);
|
||||
}
|
||||
});
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
messageHistory = new ConcurrentHashMap<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
messageHistory = null;
|
||||
}
|
||||
|
||||
private boolean isSpam(String message) {
|
||||
/* Quick bandaid fix for mc.player being null when the module is being registered, so don't register it with the map */
|
||||
final String OWN_MESSAGE = "^<" + mc.player.getName() + "> ";
|
||||
if ((!filterOwn.getValue() && isOwn(OWN_MESSAGE, message)) || isDirect(filterDMs.getValue(), message) || isDirectOther(filterDMs.getValue(), message)) {
|
||||
return false;
|
||||
} else {
|
||||
return detectSpam(removeUsername(message));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private String removeUsername(String username) {
|
||||
return username.replaceAll("<[^>]*> ", "");
|
||||
}
|
||||
|
||||
private boolean detectSpam(String message) {
|
||||
|
||||
for (Map.Entry<Setting<Boolean>, String[]> entry : settingMap.entrySet()) {
|
||||
if (entry.getKey().getValue() && findPatterns(entry.getValue(), message)) {
|
||||
sendResult(entry.getKey().getName(), message);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (duplicates.getValue()) {
|
||||
if (messageHistory == null) messageHistory = new ConcurrentHashMap<>();
|
||||
boolean isDuplicate = false;
|
||||
|
||||
if (messageHistory.containsKey(message) && (System.currentTimeMillis() - messageHistory.get(message)) / 1000 < duplicatesTimeout.getValue())
|
||||
isDuplicate = true;
|
||||
|
||||
messageHistory.put(message, System.currentTimeMillis());
|
||||
if (isDuplicate) {
|
||||
if (showBlocked.getValue().equals(ShowBlocked.CHAT))
|
||||
sendChatMessage(getChatName() + "Duplicate: " + message);
|
||||
else if (showBlocked.getValue().equals(ShowBlocked.LOG_FILE))
|
||||
KamiMod.log.info(getChatName() + "Duplicate: " + message);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isOwn(String ownFilter, String message) {
|
||||
return Pattern.compile(ownFilter, Pattern.CASE_INSENSITIVE).matcher(message).find();
|
||||
}
|
||||
|
||||
private boolean findPatterns(String[] patterns, String string) {
|
||||
string = string.replaceAll("<[^>]*> ", ""); // remove username first
|
||||
for (String pattern : patterns) {
|
||||
if (Pattern.compile(pattern, Pattern.CASE_INSENSITIVE).matcher(string).find()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private Map<Setting<Boolean>, String[]> settingMap = new HashMap<Setting<Boolean>, String[]>() {{
|
||||
put(greenText, FilterPatterns.GREEN_TEXT);
|
||||
put(specialCharBegin, FilterPatterns.SPECIAL_BEGINNING);
|
||||
put(specialCharEnding, FilterPatterns.SPECIAL_ENDING);
|
||||
put(specialCharBegin, FilterPatterns.SPECIAL_BEGINNING);
|
||||
put(ownsMeAndAll, FilterPatterns.OWNS_ME_AND_ALL);
|
||||
put(iJustThanksTo, FilterPatterns.I_JUST_THANKS_TO);
|
||||
put(numberSuffix, FilterPatterns.NUMBER_SUFFIX);
|
||||
put(numberPrefix, FilterPatterns.NUMBER_PREFIX);
|
||||
put(discordLinks, FilterPatterns.DISCORD);
|
||||
put(webLinks, FilterPatterns.WEB_LINK);
|
||||
put(ips, FilterPatterns.IP_ADDR);
|
||||
put(announcers, FilterPatterns.ANNOUNCER);
|
||||
put(spammers, FilterPatterns.SPAMMER);
|
||||
put(insulters, FilterPatterns.INSULTER);
|
||||
put(greeters, FilterPatterns.GREETER);
|
||||
}};
|
||||
|
||||
private static class FilterPatterns {
|
||||
private static final String[] ANNOUNCER = {
|
||||
// RusherHack b8
|
||||
"I just walked .+ feet!",
|
||||
"I just placed a .+!",
|
||||
"I just attacked .+ with a .+!",
|
||||
"I just dropped a .+!",
|
||||
"I just opened chat!",
|
||||
"I just opened my console!",
|
||||
"I just opened my GUI!",
|
||||
"I just went into full screen mode!",
|
||||
"I just paused my game!",
|
||||
"I just opened my inventory!",
|
||||
"I just looked at the player list!",
|
||||
"I just took a screen shot!",
|
||||
"I just swaped hands!",
|
||||
"I just ducked!",
|
||||
"I just changed perspectives!",
|
||||
"I just jumped!",
|
||||
"I just ate a .+!",
|
||||
"I just crafted .+ .+!",
|
||||
"I just picked up a .+!",
|
||||
"I just smelted .+ .+!",
|
||||
"I just respawned!",
|
||||
// RusherHack b11
|
||||
"I just attacked .+ with my hands",
|
||||
"I just broke a .+!",
|
||||
// WWE
|
||||
"I recently walked .+ blocks",
|
||||
"I just droped a .+ called, .+!",
|
||||
"I just placed a block called, .+!",
|
||||
"Im currently breaking a block called, .+!",
|
||||
"I just broke a block called, .+!",
|
||||
"I just opened chat!",
|
||||
"I just opened chat and typed a slash!",
|
||||
"I just paused my game!",
|
||||
"I just opened my inventory!",
|
||||
"I just looked at the player list!",
|
||||
"I just changed perspectives, now im in .+!",
|
||||
"I just crouched!",
|
||||
"I just jumped!",
|
||||
"I just attacked a entity called, .+ with a .+",
|
||||
"Im currently eatting a peice of food called, .+!",
|
||||
"Im currently using a item called, .+!",
|
||||
"I just toggled full screen mode!",
|
||||
"I just took a screen shot!",
|
||||
"I just swaped hands and now theres a .+ in my main hand and a .+ in my off hand!",
|
||||
"I just used pick block on a block called, .+!",
|
||||
"Ra just completed his blazing ark",
|
||||
"Its a new day yes it is",
|
||||
// DotGod.CC
|
||||
"I just placed .+ thanks to (http:\\/\\/)?DotGod\\.CC!",
|
||||
"I just flew .+ meters like a butterfly thanks to (http:\\/\\/)?DotGod\\.CC!",
|
||||
};
|
||||
|
||||
private static final String[] SPAMMER = {
|
||||
//WWE
|
||||
"WWE Client's spammer",
|
||||
"Lol get gud",
|
||||
"Future client is bad",
|
||||
"WWE > Future",
|
||||
"WWE > Impact",
|
||||
"Default Message",
|
||||
"IKnowImEZ is a god",
|
||||
"THEREALWWEFAN231 is a god",
|
||||
"WWE Client made by IKnowImEZ/THEREALWWEFAN231",
|
||||
"WWE Client was the first public client to have Path Finder/New Chunks",
|
||||
"WWE Client was the first public client to have color signs",
|
||||
"WWE Client was the first client to have Teleport Finder",
|
||||
"WWE Client was the first client to have Tunneller & Tunneller Back Fill",
|
||||
};
|
||||
|
||||
private static final String[] INSULTER = {
|
||||
// WWE
|
||||
".+ Download WWE utility mod, Its free!",
|
||||
".+ 4b4t is da best mintscreft serber",
|
||||
".+ dont abouse",
|
||||
".+ you cuck",
|
||||
".+ https://www.youtube.com/channel/UCJGCNPEjvsCn0FKw3zso0TA",
|
||||
".+ is my step dad",
|
||||
".+ again daddy!",
|
||||
"dont worry .+ it happens to every one",
|
||||
".+ dont buy future it's crap, compared to WWE!",
|
||||
"What are you, fucking gay, .+?",
|
||||
"Did you know? .+ hates you, .+",
|
||||
"You are literally 10, .+",
|
||||
".+ finally lost their virginity, sadly they lost it to .+... yeah, that's unfortunate.",
|
||||
".+, don't be upset, it's not like anyone cares about you, fag.",
|
||||
".+, see that rubbish bin over there? Get your ass in it, or I'll get .+ to whoop your ass.",
|
||||
".+, may I borrow that dirt block? that guy named .+ needs it...",
|
||||
"Yo, .+, btfo you virgin",
|
||||
"Hey .+ want to play some High School RP with me and .+?",
|
||||
".+ is an Archon player. Why is he on here? Fucking factions player.",
|
||||
"Did you know? .+ just joined The Vortex Coalition!",
|
||||
".+ has successfully conducted the cactus dupe and duped a itemhand!",
|
||||
".+, are you even human? You act like my dog, holy shit.",
|
||||
".+, you were never loved by your family.",
|
||||
"Come on .+, you hurt .+'s feelings. You meany.",
|
||||
"Stop trying to meme .+, you can't do that. kek",
|
||||
".+, .+ is gay. Don't go near him.",
|
||||
"Whoa .+ didn't mean to offend you, .+.",
|
||||
".+ im not pvping .+, im WWE'ing .+.",
|
||||
"Did you know? .+ just joined The Vortex Coalition!",
|
||||
".+, are you even human? You act like my dog, holy shit.",
|
||||
};
|
||||
|
||||
private static final String[] GREETER = {
|
||||
// WWE
|
||||
"Bye, Bye .+",
|
||||
"Farwell, .+",
|
||||
// Others(?)
|
||||
"See you next time, .+",
|
||||
"Catch ya later, .+",
|
||||
"Bye, .+",
|
||||
"Welcome, .+",
|
||||
"Hey, .+",
|
||||
// Vanilla MC / Essentials MC
|
||||
".+ joined the game",
|
||||
".+ has joined",
|
||||
".+ joined the lobby",
|
||||
"Welcome .+",
|
||||
".+ left the game",
|
||||
};
|
||||
|
||||
private static final String[] DISCORD = {
|
||||
"discord.gg",
|
||||
"discordapp.com",
|
||||
"discord.io",
|
||||
"invite.gg",
|
||||
};
|
||||
|
||||
private static final String[] NUMBER_SUFFIX = {
|
||||
".+\\d{3,}$",
|
||||
};
|
||||
|
||||
private static final String[] NUMBER_PREFIX = {
|
||||
"\\d{3,}.*$",
|
||||
};
|
||||
|
||||
private static final String[] GREEN_TEXT = {
|
||||
"^>.+$",
|
||||
};
|
||||
|
||||
private static final String[] WEB_LINK = {
|
||||
"http:\\/\\/",
|
||||
"https:\\/\\/",
|
||||
"www.",
|
||||
};
|
||||
|
||||
private static final String[] IP_ADDR = {
|
||||
"\\b\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\:\\d{1,5}\\b",
|
||||
"\\b\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}",
|
||||
"^(?:http(?:s)?:\\/\\/)?(?:[^\\.]+\\.)?.*\\..*\\..*$",
|
||||
".*\\..*\\:\\d{1,5}$",
|
||||
};
|
||||
|
||||
private static final String[] OWNS_ME_AND_ALL = {
|
||||
"owns me and all",
|
||||
};
|
||||
|
||||
private static final String[] I_JUST_THANKS_TO = {
|
||||
"i just.*thanks to",
|
||||
"i just.*using",
|
||||
};
|
||||
|
||||
private static final String[] SPECIAL_BEGINNING = {
|
||||
"^[.,/?!()\\[\\]{}<>|\\-+=\\\\]", // the <> don't filter as the player name is removed when matching
|
||||
};
|
||||
|
||||
private static final String[] SPECIAL_ENDING = {
|
||||
"[/@#^()\\[\\]{}<>|\\-+=\\\\]$",
|
||||
};
|
||||
}
|
||||
|
||||
private void sendResult(String name, String message) {
|
||||
if (showBlocked.getValue().equals(ShowBlocked.CHAT)) sendChatMessage(getChatName() + name + ": " + message);
|
||||
else if (showBlocked.getValue().equals(ShowBlocked.LOG_FILE))
|
||||
KamiMod.log.info(getChatName() + name + ": " + message);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,303 @@
|
|||
package me.zeroeightsix.kami.module.modules.chat
|
||||
|
||||
import me.zero.alpine.listener.EventHandler
|
||||
import me.zero.alpine.listener.EventHook
|
||||
import me.zero.alpine.listener.Listener
|
||||
import me.zeroeightsix.kami.KamiMod
|
||||
import me.zeroeightsix.kami.module.Module
|
||||
import me.zeroeightsix.kami.setting.Setting
|
||||
import me.zeroeightsix.kami.setting.Settings
|
||||
import me.zeroeightsix.kami.util.MessageDetectionHelper
|
||||
import me.zeroeightsix.kami.util.MessageSendHelper
|
||||
import net.minecraftforge.client.event.ClientChatReceivedEvent
|
||||
import java.util.*
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
import java.util.function.Consumer
|
||||
import java.util.regex.Pattern
|
||||
import java.util.stream.Collectors
|
||||
|
||||
/**
|
||||
* @author hub
|
||||
* @author dominikaaaa
|
||||
* Created 19 November 2019 by hub
|
||||
* Updated 12 January 2020 by hub
|
||||
* Updated 19 February 2020 by aUniqueUser
|
||||
* Updated by dominikaaaa on 19/04/20
|
||||
*/
|
||||
@Module.Info(
|
||||
name = "AntiSpam",
|
||||
category = Module.Category.CHAT,
|
||||
description = "Removes spam and advertising from the chat",
|
||||
showOnArray = Module.ShowOnArray.OFF
|
||||
)
|
||||
class AntiSpam : Module() {
|
||||
private val p = register(Settings.e<Page>("Page", Page.ONE))
|
||||
|
||||
/* Page One */
|
||||
private val discordLinks = register(Settings.booleanBuilder("Discord Links").withValue(true).withVisibility { p.value == Page.ONE }.build())
|
||||
private val announcers = register(Settings.booleanBuilder("Announcers").withValue(true).withVisibility { p.value == Page.ONE }.build())
|
||||
private val spammers = register(Settings.booleanBuilder("Spammers").withValue(true).withVisibility { p.value == Page.ONE }.build())
|
||||
private val insulters = register(Settings.booleanBuilder("Insulters").withValue(true).withVisibility { p.value == Page.ONE }.build())
|
||||
private val greeters = register(Settings.booleanBuilder("Greeters").withValue(true).withVisibility { p.value == Page.ONE }.build())
|
||||
private val ips = register(Settings.booleanBuilder("Server Ips").withValue(true).withVisibility { p.value == Page.ONE }.build())
|
||||
private val specialCharEnding = register(Settings.booleanBuilder("Special Ending").withValue(true).withVisibility { p.value == Page.ONE }.build())
|
||||
private val specialCharBegin = register(Settings.booleanBuilder("Special Begin").withValue(true).withVisibility { p.value == Page.ONE }.build())
|
||||
private val iJustThanksTo = register(Settings.booleanBuilder("I just...thanks to").withValue(true).withVisibility { p.value == Page.ONE }.build())
|
||||
|
||||
/* Page Two */
|
||||
private val ownsMeAndAll = register(Settings.booleanBuilder("Owns Me And All").withValue(true).withVisibility { p.value == Page.TWO }.build())
|
||||
private val greenText = register(Settings.booleanBuilder("Green Text").withValue(false).withVisibility { p.value == Page.TWO }.build())
|
||||
private val numberSuffix = register(Settings.booleanBuilder("Number Ending").withValue(false).withVisibility { p.value == Page.TWO }.build())
|
||||
private val numberPrefix = register(Settings.booleanBuilder("Number Begin").withValue(false).withVisibility { p.value == Page.TWO }.build())
|
||||
private val duplicates = register(Settings.booleanBuilder("Duplicates").withValue(true).withVisibility { p.value == Page.TWO }.build())
|
||||
private val duplicatesTimeout = register(Settings.integerBuilder("Duplicates Timeout").withMinimum(1).withValue(30).withMaximum(600).withVisibility { duplicates.value && p.value == Page.TWO }.build())
|
||||
private val webLinks = register(Settings.booleanBuilder("Web Links").withValue(false).withVisibility { p.value == Page.TWO }.build())
|
||||
private val filterOwn = register(Settings.booleanBuilder("Filter Own").withValue(false).withVisibility { p.value == Page.TWO }.build())
|
||||
private val filterDMs = register(Settings.booleanBuilder("Filter DMs").withValue(false).withVisibility { p.value == Page.TWO }.build())
|
||||
private val showBlocked = register(Settings.enumBuilder(ShowBlocked::class.java).withName("Show Blocked").withValue(ShowBlocked.LOG_FILE).withVisibility { p.value == Page.TWO }.build())
|
||||
private var messageHistory: ConcurrentHashMap<String, Long>? = null
|
||||
|
||||
private enum class Page {
|
||||
ONE, TWO
|
||||
}
|
||||
|
||||
private enum class ShowBlocked {
|
||||
NONE, LOG_FILE, CHAT
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
var listener = Listener(EventHook { event: ClientChatReceivedEvent ->
|
||||
if (mc.player == null) return@EventHook
|
||||
|
||||
/* leijurv's sexy lambda to remove older entries in messageHistory */
|
||||
messageHistory!!.entries
|
||||
.stream()
|
||||
.filter { entry: Map.Entry<String, Long> -> entry.value < System.currentTimeMillis() - 10 * 60 * 1000 } // 10 is delay in minutes
|
||||
.collect(Collectors.toList())
|
||||
.forEach(Consumer { entry: Map.Entry<String, Long> -> messageHistory!!.remove(entry.key) })
|
||||
if (isSpam(event.message.unformattedText)) {
|
||||
event.isCanceled = true
|
||||
}
|
||||
})
|
||||
|
||||
public override fun onEnable() {
|
||||
messageHistory = ConcurrentHashMap()
|
||||
}
|
||||
|
||||
public override fun onDisable() {
|
||||
messageHistory = null
|
||||
}
|
||||
|
||||
private fun isSpam(message: String): Boolean {
|
||||
/* Quick bandaid fix for mc.player being null when the module is being registered, so don't register it with the map */
|
||||
val ownMessage = "^<" + mc.player.name + "> "
|
||||
return if (!filterOwn.value && isOwn(ownMessage, message) || MessageDetectionHelper.isDirect(filterDMs.value, message) || MessageDetectionHelper.isDirectOther(filterDMs.value, message)) {
|
||||
false
|
||||
} else {
|
||||
detectSpam(removeUsername(message))
|
||||
}
|
||||
}
|
||||
|
||||
private fun removeUsername(username: String): String {
|
||||
return username.replace("<[^>]*> ".toRegex(), "")
|
||||
}
|
||||
|
||||
private fun detectSpam(message: String): Boolean {
|
||||
for ((key, value) in settingMap) {
|
||||
if (key.value && findPatterns(value, message)) {
|
||||
sendResult(key.name, message)
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
if (duplicates.value) {
|
||||
if (messageHistory == null) messageHistory = ConcurrentHashMap()
|
||||
var isDuplicate = false
|
||||
|
||||
if (messageHistory!!.containsKey(message) && (System.currentTimeMillis() - messageHistory!![message]!!) / 1000 < duplicatesTimeout.value) isDuplicate = true
|
||||
messageHistory!![message] = System.currentTimeMillis()
|
||||
|
||||
if (isDuplicate) {
|
||||
if (showBlocked.value == ShowBlocked.CHAT) MessageSendHelper.sendChatMessage(chatName + "Duplicate: " + message) else if (showBlocked.value == ShowBlocked.LOG_FILE) KamiMod.log.info(chatName + "Duplicate: " + message)
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
private fun isOwn(ownFilter: String, message: String): Boolean {
|
||||
return Pattern.compile(ownFilter, Pattern.CASE_INSENSITIVE).matcher(message).find()
|
||||
}
|
||||
|
||||
private fun findPatterns(patterns: Array<String>, string: String): Boolean {
|
||||
var cString = string
|
||||
cString = cString.replace("<[^>]*> ".toRegex(), "") // remove username first
|
||||
for (pattern in patterns) {
|
||||
if (Pattern.compile(pattern, Pattern.CASE_INSENSITIVE).matcher(cString).find()) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
private val settingMap: HashMap<Setting<Boolean>, Array<String>> = object : HashMap<Setting<Boolean>, Array<String>>() {
|
||||
init {
|
||||
put(greenText, FilterPatterns.GREEN_TEXT)
|
||||
put(specialCharBegin, FilterPatterns.SPECIAL_BEGINNING)
|
||||
put(specialCharEnding, FilterPatterns.SPECIAL_ENDING)
|
||||
put(specialCharBegin, FilterPatterns.SPECIAL_BEGINNING)
|
||||
put(ownsMeAndAll, FilterPatterns.OWNS_ME_AND_ALL)
|
||||
put(iJustThanksTo, FilterPatterns.I_JUST_THANKS_TO)
|
||||
put(numberSuffix, FilterPatterns.NUMBER_SUFFIX)
|
||||
put(numberPrefix, FilterPatterns.NUMBER_PREFIX)
|
||||
put(discordLinks, FilterPatterns.DISCORD)
|
||||
put(webLinks, FilterPatterns.WEB_LINK)
|
||||
put(ips, FilterPatterns.IP_ADDR)
|
||||
put(announcers, FilterPatterns.ANNOUNCER)
|
||||
put(spammers, FilterPatterns.SPAMMER)
|
||||
put(insulters, FilterPatterns.INSULTER)
|
||||
put(greeters, FilterPatterns.GREETER)
|
||||
}
|
||||
}
|
||||
|
||||
private object FilterPatterns {
|
||||
val ANNOUNCER = arrayOf( // RusherHack b8
|
||||
"I just walked .+ feet!",
|
||||
"I just placed a .+!",
|
||||
"I just attacked .+ with a .+!",
|
||||
"I just dropped a .+!",
|
||||
"I just opened chat!",
|
||||
"I just opened my console!",
|
||||
"I just opened my GUI!",
|
||||
"I just went into full screen mode!",
|
||||
"I just paused my game!",
|
||||
"I just opened my inventory!",
|
||||
"I just looked at the player list!",
|
||||
"I just took a screen shot!",
|
||||
"I just swaped hands!",
|
||||
"I just ducked!",
|
||||
"I just changed perspectives!",
|
||||
"I just jumped!",
|
||||
"I just ate a .+!",
|
||||
"I just crafted .+ .+!",
|
||||
"I just picked up a .+!",
|
||||
"I just smelted .+ .+!",
|
||||
"I just respawned!", // RusherHack b11
|
||||
"I just attacked .+ with my hands",
|
||||
"I just broke a .+!", // WWE
|
||||
"I recently walked .+ blocks",
|
||||
"I just droped a .+ called, .+!",
|
||||
"I just placed a block called, .+!",
|
||||
"Im currently breaking a block called, .+!",
|
||||
"I just broke a block called, .+!",
|
||||
"I just opened chat!",
|
||||
"I just opened chat and typed a slash!",
|
||||
"I just paused my game!",
|
||||
"I just opened my inventory!",
|
||||
"I just looked at the player list!",
|
||||
"I just changed perspectives, now im in .+!",
|
||||
"I just crouched!",
|
||||
"I just jumped!",
|
||||
"I just attacked a entity called, .+ with a .+",
|
||||
"Im currently eatting a peice of food called, .+!",
|
||||
"Im currently using a item called, .+!",
|
||||
"I just toggled full screen mode!",
|
||||
"I just took a screen shot!",
|
||||
"I just swaped hands and now theres a .+ in my main hand and a .+ in my off hand!",
|
||||
"I just used pick block on a block called, .+!",
|
||||
"Ra just completed his blazing ark",
|
||||
"Its a new day yes it is", // DotGod.CC
|
||||
"I just placed .+ thanks to (http:\\/\\/)?DotGod\\.CC!",
|
||||
"I just flew .+ meters like a butterfly thanks to (http:\\/\\/)?DotGod\\.CC!")
|
||||
val SPAMMER = arrayOf( //WWE
|
||||
"WWE Client's spammer",
|
||||
"Lol get gud",
|
||||
"Future client is bad",
|
||||
"WWE > Future",
|
||||
"WWE > Impact",
|
||||
"Default Message",
|
||||
"IKnowImEZ is a god",
|
||||
"THEREALWWEFAN231 is a god",
|
||||
"WWE Client made by IKnowImEZ/THEREALWWEFAN231",
|
||||
"WWE Client was the first public client to have Path Finder/New Chunks",
|
||||
"WWE Client was the first public client to have color signs",
|
||||
"WWE Client was the first client to have Teleport Finder",
|
||||
"WWE Client was the first client to have Tunneller & Tunneller Back Fill")
|
||||
val INSULTER = arrayOf( // WWE
|
||||
".+ Download WWE utility mod, Its free!",
|
||||
".+ 4b4t is da best mintscreft serber",
|
||||
".+ dont abouse",
|
||||
".+ you cuck",
|
||||
".+ https://www.youtube.com/channel/UCJGCNPEjvsCn0FKw3zso0TA",
|
||||
".+ is my step dad",
|
||||
".+ again daddy!",
|
||||
"dont worry .+ it happens to every one",
|
||||
".+ dont buy future it's crap, compared to WWE!",
|
||||
"What are you, fucking gay, .+?",
|
||||
"Did you know? .+ hates you, .+",
|
||||
"You are literally 10, .+",
|
||||
".+ finally lost their virginity, sadly they lost it to .+... yeah, that's unfortunate.",
|
||||
".+, don't be upset, it's not like anyone cares about you, fag.",
|
||||
".+, see that rubbish bin over there? Get your ass in it, or I'll get .+ to whoop your ass.",
|
||||
".+, may I borrow that dirt block? that guy named .+ needs it...",
|
||||
"Yo, .+, btfo you virgin",
|
||||
"Hey .+ want to play some High School RP with me and .+?",
|
||||
".+ is an Archon player. Why is he on here? Fucking factions player.",
|
||||
"Did you know? .+ just joined The Vortex Coalition!",
|
||||
".+ has successfully conducted the cactus dupe and duped a itemhand!",
|
||||
".+, are you even human? You act like my dog, holy shit.",
|
||||
".+, you were never loved by your family.",
|
||||
"Come on .+, you hurt .+'s feelings. You meany.",
|
||||
"Stop trying to meme .+, you can't do that. kek",
|
||||
".+, .+ is gay. Don't go near him.",
|
||||
"Whoa .+ didn't mean to offend you, .+.",
|
||||
".+ im not pvping .+, im WWE'ing .+.",
|
||||
"Did you know? .+ just joined The Vortex Coalition!",
|
||||
".+, are you even human? You act like my dog, holy shit.")
|
||||
val GREETER = arrayOf( // WWE
|
||||
"Bye, Bye .+",
|
||||
"Farwell, .+", // Others(?)
|
||||
"See you next time, .+",
|
||||
"Catch ya later, .+",
|
||||
"Bye, .+",
|
||||
"Welcome, .+",
|
||||
"Hey, .+", // Vanilla MC / Essentials MC
|
||||
".+ joined the game",
|
||||
".+ has joined",
|
||||
".+ joined the lobby",
|
||||
"Welcome .+",
|
||||
".+ left the game")
|
||||
val DISCORD = arrayOf(
|
||||
"discord.gg",
|
||||
"discordapp.com",
|
||||
"discord.io",
|
||||
"invite.gg")
|
||||
val NUMBER_SUFFIX = arrayOf(
|
||||
".+\\d{3,}$")
|
||||
val NUMBER_PREFIX = arrayOf(
|
||||
"\\d{3,}.*$")
|
||||
val GREEN_TEXT = arrayOf(
|
||||
"^>.+$")
|
||||
val WEB_LINK = arrayOf(
|
||||
"http:\\/\\/",
|
||||
"https:\\/\\/",
|
||||
"www.")
|
||||
val IP_ADDR = arrayOf(
|
||||
"\\b\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\:\\d{1,5}\\b",
|
||||
"\\b\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}",
|
||||
"^(?:http(?:s)?:\\/\\/)?(?:[^\\.]+\\.)?.*\\..*\\..*$",
|
||||
".*\\..*\\:\\d{1,5}$")
|
||||
val OWNS_ME_AND_ALL = arrayOf(
|
||||
"owns me and all")
|
||||
val I_JUST_THANKS_TO = arrayOf(
|
||||
"i just.*thanks to",
|
||||
"i just.*using")
|
||||
val SPECIAL_BEGINNING = arrayOf(
|
||||
"^[.,/?!()\\[\\]{}<>|\\-+=\\\\]")
|
||||
val SPECIAL_ENDING = arrayOf(
|
||||
"[/@#^()\\[\\]{}<>|\\-+=\\\\]$")
|
||||
}
|
||||
|
||||
private fun sendResult(name: String, message: String) {
|
||||
if (showBlocked.value == ShowBlocked.CHAT) MessageSendHelper.sendChatMessage("$chatName$name: $message") else if (showBlocked.value == ShowBlocked.LOG_FILE) KamiMod.log.info("$chatName$name: $message")
|
||||
}
|
||||
}
|
|
@ -1,77 +0,0 @@
|
|||
package me.zeroeightsix.kami.module.modules.chat;
|
||||
|
||||
import me.zeroeightsix.kami.module.Module;
|
||||
import me.zeroeightsix.kami.setting.Setting;
|
||||
import me.zeroeightsix.kami.setting.Settings;
|
||||
import net.minecraft.network.play.client.CPacketChatMessage;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
import static me.zeroeightsix.kami.util.MessageSendHelper.sendChatMessage;
|
||||
import static me.zeroeightsix.kami.util.MessageSendHelper.sendWarningMessage;
|
||||
|
||||
/**
|
||||
* @author dominikaaaa
|
||||
* Updated by d1gress/Qther on 5/12/2019
|
||||
* Updated by dominikaaaa on 26/03/20
|
||||
*/
|
||||
@Module.Info(
|
||||
name = "AutoQMain",
|
||||
description = "Automatically does '/queue main' on servers",
|
||||
category = Module.Category.CHAT,
|
||||
showOnArray = Module.ShowOnArray.OFF
|
||||
)
|
||||
public class AutoQMain extends Module {
|
||||
|
||||
private Setting<Boolean> showWarns = register(Settings.b("Show Warnings", true));
|
||||
private Setting<Boolean> connectionWarning = register(Settings.b("Connection Warning", true));
|
||||
private Setting<Boolean> dimensionWarning = register(Settings.b("Dimension Warning", true));
|
||||
private Setting<Double> delay = register(Settings.doubleBuilder("Wait time").withMinimum(0.2).withValue(7.1).withMaximum(10.0).build());
|
||||
|
||||
private double delayTime;
|
||||
private double oldDelay = 0;
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
if (mc.player == null) return;
|
||||
if (oldDelay == 0) oldDelay = delay.getValue();
|
||||
else if (oldDelay != delay.getValue()) {
|
||||
delayTime = delay.getValue();
|
||||
oldDelay = delay.getValue();
|
||||
}
|
||||
|
||||
if (delayTime <= 0) {
|
||||
delayTime = (int) (delay.getValue() * 2400);
|
||||
} else if (delayTime > 0) {
|
||||
delayTime--;
|
||||
return;
|
||||
}
|
||||
|
||||
if (mc.getCurrentServerData() == null && connectionWarning.getValue()) {
|
||||
sendMessage("&l&6Error: &r&6You are in singleplayer");
|
||||
return;
|
||||
}
|
||||
if (!mc.getCurrentServerData().serverIP.equalsIgnoreCase("2b2t.org") && connectionWarning.getValue()) {
|
||||
sendMessage("&l&6Warning: &r&6You are not connected to 2b2t.org");
|
||||
return;
|
||||
}
|
||||
if (mc.player.dimension != 1 && dimensionWarning.getValue()) {
|
||||
sendMessage("&l&6Warning: &r&6You are not in the end. Not running &b/queue main&7.");
|
||||
return;
|
||||
}
|
||||
sendQueueMain();
|
||||
}
|
||||
|
||||
private void sendQueueMain() {
|
||||
SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss");
|
||||
Date date = new Date(System.currentTimeMillis());
|
||||
System.out.println(formatter.format(date));
|
||||
sendChatMessage("&7Run &b/queue main&7 at " + (formatter.format(date)));
|
||||
mc.playerController.connection.sendPacket(new CPacketChatMessage("/queue main"));
|
||||
}
|
||||
|
||||
private void sendMessage(String message) { if (showWarns.getValue()) sendWarningMessage(getChatName() + message); }
|
||||
|
||||
public void onDisable() { delayTime = 0; }
|
||||
}
|
|
@ -0,0 +1,76 @@
|
|||
package me.zeroeightsix.kami.module.modules.chat
|
||||
|
||||
import me.zeroeightsix.kami.module.Module
|
||||
import me.zeroeightsix.kami.setting.Settings
|
||||
import me.zeroeightsix.kami.util.MessageSendHelper
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
* @author dominikaaaa
|
||||
* Updated by d1gress/Qther on 5/12/2019
|
||||
* Updated by dominikaaaa on 26/03/20
|
||||
*/
|
||||
@Module.Info(
|
||||
name = "AutoQMain",
|
||||
description = "Automatically does '/queue main' on servers",
|
||||
category = Module.Category.CHAT,
|
||||
showOnArray = Module.ShowOnArray.OFF
|
||||
)
|
||||
class AutoQMain : Module() {
|
||||
private val showWarns = register(Settings.b("Show Warnings", true))
|
||||
private val connectionWarning = register(Settings.b("Connection Warning", true))
|
||||
private val dimensionWarning = register(Settings.b("Dimension Warning", true))
|
||||
private val delay = register(Settings.doubleBuilder("Wait time").withMinimum(0.2).withValue(7.1).withMaximum(10.0).build())
|
||||
|
||||
private var delayTime = 0.0
|
||||
private var oldDelay = 0.0
|
||||
|
||||
override fun onUpdate() {
|
||||
if (mc.player == null) return
|
||||
|
||||
if (oldDelay == 0.0) oldDelay = delay.value else if (oldDelay != delay.value) {
|
||||
delayTime = delay.value
|
||||
oldDelay = delay.value
|
||||
}
|
||||
|
||||
if (delayTime <= 0) {
|
||||
delayTime = delay.value * 2400
|
||||
} else if (delayTime > 0) {
|
||||
delayTime--
|
||||
return
|
||||
}
|
||||
|
||||
if (mc.getCurrentServerData() == null && connectionWarning.value) {
|
||||
sendMessage("&l&6Error: &r&6You are in singleplayer")
|
||||
return
|
||||
}
|
||||
|
||||
if (!mc.getCurrentServerData()!!.serverIP.equals("2b2t.org", ignoreCase = true) && connectionWarning.value) {
|
||||
sendMessage("&l&6Warning: &r&6You are not connected to 2b2t.org")
|
||||
return
|
||||
}
|
||||
|
||||
if (mc.player.dimension != 1 && dimensionWarning.value) {
|
||||
sendMessage("&l&6Warning: &r&6You are not in the end. Not running &b/queue main&7.")
|
||||
return
|
||||
}
|
||||
sendQueueMain()
|
||||
}
|
||||
|
||||
private fun sendQueueMain() {
|
||||
val formatter = SimpleDateFormat("HH:mm:ss")
|
||||
val date = Date(System.currentTimeMillis())
|
||||
|
||||
MessageSendHelper.sendChatMessage("&7Run &b/queue main&7 at " + formatter.format(date))
|
||||
MessageSendHelper.sendServerMessage("/queue main")
|
||||
}
|
||||
|
||||
private fun sendMessage(message: String) {
|
||||
if (showWarns.value) MessageSendHelper.sendWarningMessage(chatName + message)
|
||||
}
|
||||
|
||||
public override fun onToggle() {
|
||||
delayTime = 0.0
|
||||
}
|
||||
}
|
|
@ -1,69 +0,0 @@
|
|||
package me.zeroeightsix.kami.module.modules.chat;
|
||||
|
||||
import me.zero.alpine.listener.EventHandler;
|
||||
import me.zero.alpine.listener.Listener;
|
||||
import me.zeroeightsix.kami.command.Command;
|
||||
import me.zeroeightsix.kami.event.events.PacketEvent;
|
||||
import me.zeroeightsix.kami.module.Module;
|
||||
import me.zeroeightsix.kami.module.modules.misc.AntiAFK;
|
||||
import me.zeroeightsix.kami.setting.Setting;
|
||||
import me.zeroeightsix.kami.setting.Settings;
|
||||
import net.minecraft.network.play.server.SPacketChat;
|
||||
|
||||
import static me.zeroeightsix.kami.KamiMod.MODULE_MANAGER;
|
||||
import static me.zeroeightsix.kami.util.MessageSendHelper.sendServerMessage;
|
||||
import static me.zeroeightsix.kami.util.MessageSendHelper.sendWarningMessage;
|
||||
|
||||
/**
|
||||
* @author Diamarald
|
||||
* Updated by dominikaaaa on 03/03/20
|
||||
*/
|
||||
@Module.Info(
|
||||
name = "AutoReply",
|
||||
description = "Automatically replies to messages",
|
||||
category = Module.Category.CHAT
|
||||
)
|
||||
public class AutoReply extends Module {
|
||||
public Setting<Boolean> customMessage = register(Settings.b("Custom Message", false));
|
||||
public Setting<String> message = register(Settings.stringBuilder("Custom Text").withValue("Use &7" + Command.getCommandPrefix() + "autoreply&r to modify this").withConsumer((old, value) -> {}).withVisibility(v -> customMessage.getValue()).build());
|
||||
public Setting<Boolean> customListener = register(Settings.b("Custom Listener", false));
|
||||
public Setting<String> listener = register(Settings.stringBuilder("Custom Listener Name").withValue("unchanged").withConsumer((old, value) -> {}).withVisibility(v -> customListener.getValue()).build());
|
||||
public Setting<Boolean> customReplyCommand = register(Settings.b("Custom Reply Command", false));
|
||||
public Setting<String> replyCommand = register(Settings.stringBuilder("Custom Reply Command").withValue("unchanged").withConsumer((old, value) -> {}).withVisibility(v -> customReplyCommand.getValue()).build());
|
||||
|
||||
private String listenerDefault = "whispers:";
|
||||
private String replyCommandDefault = "r";
|
||||
|
||||
@EventHandler
|
||||
public Listener<PacketEvent.Receive> receiveListener = new Listener<>(event -> {
|
||||
if (MODULE_MANAGER.isModuleEnabled(AntiAFK.class) && MODULE_MANAGER.getModuleT(AntiAFK.class).autoReply.getValue()) return;
|
||||
if (event.getPacket() instanceof SPacketChat && ((SPacketChat) event.getPacket()).getChatComponent().getUnformattedText().contains(listenerDefault) && !((SPacketChat) event.getPacket()).getChatComponent().getUnformattedText().contains(mc.player.getName())) {
|
||||
if (customMessage.getValue()) {
|
||||
sendServerMessage("/" + replyCommandDefault + " " + message.getValue());
|
||||
} else {
|
||||
sendServerMessage("/" + replyCommandDefault + " I just automatically replied, thanks to KAMI Blue's AutoReply module!");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
private static long startTime = 0;
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
if (customListener.getValue()) listenerDefault = listener.getValue();
|
||||
else listenerDefault = "whispers:";
|
||||
|
||||
if (customReplyCommand.getValue()) replyCommandDefault = replyCommand.getName();
|
||||
else replyCommandDefault = "r";
|
||||
|
||||
if (startTime == 0) startTime = System.currentTimeMillis();
|
||||
if (startTime + 5000 <= System.currentTimeMillis()) { // 5 seconds in milliseconds
|
||||
if (customListener.getValue() && listener.getValue().equalsIgnoreCase("unchanged") && mc.player != null) {
|
||||
sendWarningMessage(getChatName() + " Warning: In order to use the custom listener, please run the &7" + Command.getCommandPrefix() + "autoreply&r =LISTENERNAME command to change it");
|
||||
}
|
||||
if (customReplyCommand.getValue() && replyCommand.getValue().equalsIgnoreCase("unchanged") && mc.player != null) {
|
||||
sendWarningMessage(getChatName() + " Warning: In order to use the custom reply command, please run the &7" + Command.getCommandPrefix() + "autoreply&r -REPLYCOMMAND command to change it");
|
||||
}
|
||||
startTime = System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
package me.zeroeightsix.kami.module.modules.chat
|
||||
|
||||
import me.zero.alpine.listener.EventHandler
|
||||
import me.zero.alpine.listener.EventHook
|
||||
import me.zero.alpine.listener.Listener
|
||||
import me.zeroeightsix.kami.KamiMod
|
||||
import me.zeroeightsix.kami.command.Command
|
||||
import me.zeroeightsix.kami.event.events.PacketEvent
|
||||
import me.zeroeightsix.kami.module.Module
|
||||
import me.zeroeightsix.kami.module.modules.misc.AntiAFK
|
||||
import me.zeroeightsix.kami.setting.Setting
|
||||
import me.zeroeightsix.kami.setting.Settings
|
||||
import me.zeroeightsix.kami.util.MessageDetectionHelper
|
||||
import me.zeroeightsix.kami.util.MessageSendHelper
|
||||
import net.minecraft.network.play.server.SPacketChat
|
||||
|
||||
/**
|
||||
* @author dominikaaaa
|
||||
* Updated by dominikaaaa on 07/05/20
|
||||
*/
|
||||
@Module.Info(
|
||||
name = "AutoReply",
|
||||
description = "Automatically reply to direct messages",
|
||||
category = Module.Category.CHAT
|
||||
)
|
||||
class AutoReply : Module() {
|
||||
@JvmField
|
||||
var customMessage: Setting<Boolean> = register(Settings.b("Custom Message", false))
|
||||
@JvmField
|
||||
var message: Setting<String> = register(Settings.stringBuilder("Custom Text").withValue("Use &7" + Command.getCommandPrefix() + "autoreply&r to modify this").withConsumer { _: String?, _: String? -> }.withVisibility { customMessage.value }.build())
|
||||
|
||||
@EventHandler
|
||||
var receiveListener = Listener(EventHook { event: PacketEvent.Receive ->
|
||||
if (KamiMod.MODULE_MANAGER.isModuleEnabled(AntiAFK::class.java) && KamiMod.MODULE_MANAGER.getModuleT(AntiAFK::class.java).autoReply.value) return@EventHook
|
||||
|
||||
if (event.packet is SPacketChat && MessageDetectionHelper.isDirect(true, (event.packet as SPacketChat).getChatComponent().unformattedText)) {
|
||||
if (customMessage.value) {
|
||||
MessageSendHelper.sendServerMessage("/r " + message.value)
|
||||
} else {
|
||||
MessageSendHelper.sendServerMessage("/r I just automatically replied, thanks to KAMI Blue's AutoReply module!")
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
package me.zeroeightsix.kami.module.modules.chat;
|
||||
|
||||
import me.zero.alpine.listener.EventHandler;
|
||||
import me.zero.alpine.listener.Listener;
|
||||
import me.zeroeightsix.kami.event.events.PacketEvent;
|
||||
import me.zeroeightsix.kami.module.Module;
|
||||
import me.zeroeightsix.kami.setting.Setting;
|
||||
import me.zeroeightsix.kami.setting.Settings;
|
||||
import me.zeroeightsix.kami.util.Friends;
|
||||
import net.minecraft.network.play.server.SPacketChat;
|
||||
|
||||
import static me.zeroeightsix.kami.util.MessageSendHelper.sendServerMessage;
|
||||
|
||||
/*
|
||||
* By Katatje 8 Dec 2019
|
||||
* Updated by dominikaaaa on 12/04/20
|
||||
*/
|
||||
@Module.Info(
|
||||
name = "AutoTPA",
|
||||
description = "Automatically decline or accept TPA requests",
|
||||
category = Module.Category.CHAT
|
||||
)
|
||||
public class AutoTPA extends Module {
|
||||
private Setting<Boolean> friends = register(Settings.b("Always accept friends", true));
|
||||
private Setting<mode> mod = register(Settings.e("Response", mode.DENY));
|
||||
|
||||
@EventHandler
|
||||
public Listener<PacketEvent.Receive> receiveListener = new Listener<>(event -> {
|
||||
if (event.getPacket() instanceof SPacketChat && ((SPacketChat) event.getPacket()).getChatComponent().getUnformattedText().contains(" has requested to teleport to you.")) {
|
||||
/* I tested that getting the first word is compatible with chat timestamp, and it as, as this is Receive and chat timestamp is after Receive */
|
||||
String firstWord = ((SPacketChat) event.getPacket()).getChatComponent().getUnformattedText().split("\\s+")[0];
|
||||
if (friends.getValue() && Friends.isFriend(firstWord)) {
|
||||
sendServerMessage("/tpaccept");
|
||||
return;
|
||||
}
|
||||
switch (mod.getValue()) {
|
||||
case ACCEPT:
|
||||
sendServerMessage("/tpaccept");
|
||||
break;
|
||||
case DENY:
|
||||
sendServerMessage("/tpdeny");
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
public enum mode {
|
||||
ACCEPT, DENY
|
||||
}
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
package me.zeroeightsix.kami.module.modules.chat
|
||||
|
||||
import me.zero.alpine.listener.EventHandler
|
||||
import me.zero.alpine.listener.EventHook
|
||||
import me.zero.alpine.listener.Listener
|
||||
import me.zeroeightsix.kami.event.events.PacketEvent
|
||||
import me.zeroeightsix.kami.module.Module
|
||||
import me.zeroeightsix.kami.setting.Settings
|
||||
import me.zeroeightsix.kami.util.Friends
|
||||
import me.zeroeightsix.kami.util.MessageDetectionHelper
|
||||
import me.zeroeightsix.kami.util.MessageSendHelper
|
||||
import net.minecraft.network.play.server.SPacketChat
|
||||
|
||||
/*
|
||||
* @author dominikaaaa
|
||||
* Updated by dominikaaaa on 07/05/20
|
||||
*/
|
||||
@Module.Info(
|
||||
name = "AutoTPA",
|
||||
description = "Automatically accept or decline /TPAs",
|
||||
category = Module.Category.CHAT
|
||||
)
|
||||
class AutoTPA : Module() {
|
||||
private val friends = register(Settings.b("Always accept friends", true))
|
||||
private val mode = register(Settings.e<Mode>("Response", Mode.DENY))
|
||||
|
||||
@EventHandler
|
||||
var receiveListener = Listener(EventHook { event: PacketEvent.Receive ->
|
||||
if (event.packet is SPacketChat && MessageDetectionHelper.isTPA(true, (event.packet as SPacketChat).getChatComponent().unformattedText)) {
|
||||
/* I tested that getting the first word is compatible with chat timestamp, and it as, as this is Receive and chat timestamp is after Receive */
|
||||
val firstWord = (event.packet as SPacketChat).getChatComponent().unformattedText.split("\\s+").toTypedArray()[0]
|
||||
|
||||
if (friends.value && Friends.isFriend(firstWord)) {
|
||||
MessageSendHelper.sendServerMessage("/tpaccept")
|
||||
return@EventHook
|
||||
}
|
||||
|
||||
when (mode.value) {
|
||||
Mode.ACCEPT -> MessageSendHelper.sendServerMessage("/tpaccept")
|
||||
Mode.DENY -> MessageSendHelper.sendServerMessage("/tpdeny")
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
enum class Mode {
|
||||
ACCEPT, DENY
|
||||
}
|
||||
}
|
|
@ -38,7 +38,6 @@ public class ChatFilter extends Module {
|
|||
private static List<String> tempLines = new ArrayList<>();
|
||||
private static String[] chatFilter;
|
||||
|
||||
|
||||
@EventHandler
|
||||
public Listener<ClientChatReceivedEvent> listener = new Listener<>(event -> {
|
||||
if (mc.player == null) return;
|
||||
|
@ -78,7 +77,7 @@ public class ChatFilter extends Module {
|
|||
String line;
|
||||
tempLines.clear();
|
||||
while ((line = bufferedReader.readLine()) != null) {
|
||||
while (customMatch("[ ]$", line)) { /* remove trailing spaces */
|
||||
while (customMatch("[ ]$", line) || customMatch("^[ ]", line)) { /* remove trailing spaces */
|
||||
line = line.substring(0, line.length() - 1);
|
||||
}
|
||||
tempLines.add(line);
|
||||
|
@ -93,6 +92,8 @@ public class ChatFilter extends Module {
|
|||
}
|
||||
if (isDisabled()) return;
|
||||
|
||||
sendChatMessage(getChatName() + "Found '&7chat_filter.txt&f'!");
|
||||
|
||||
if (!hasRunInfo.getValue()) {
|
||||
sendChatMessage(getChatName() + "Tip: this supports &lregex&r if you know how to use those. This also uses &lword boundaries&r meaning it will match whole words, not part of a word. Eg if your filter has 'hell' then 'hello' will not be filtered.");
|
||||
hasRunInfo.setValue(true);
|
||||
|
|
|
@ -1,49 +0,0 @@
|
|||
package me.zeroeightsix.kami.module.modules.chat;
|
||||
|
||||
import me.zero.alpine.listener.EventHandler;
|
||||
import me.zero.alpine.listener.Listener;
|
||||
import me.zeroeightsix.kami.module.Module;
|
||||
import me.zeroeightsix.kami.setting.Setting;
|
||||
import me.zeroeightsix.kami.setting.Settings;
|
||||
import me.zeroeightsix.kami.util.ColourTextFormatting;
|
||||
import me.zeroeightsix.kami.util.TimeUtil;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraftforge.client.event.ClientChatReceivedEvent;
|
||||
|
||||
import static me.zeroeightsix.kami.util.ColourTextFormatting.toTextMap;
|
||||
|
||||
/**
|
||||
* @author dominikaaaa
|
||||
* Updated by dominikaaaa on 19/04/20
|
||||
*/
|
||||
@Module.Info(
|
||||
name = "ChatTimestamp",
|
||||
category = Module.Category.CHAT,
|
||||
description = "Shows the time a message was sent beside the message",
|
||||
showOnArray = Module.ShowOnArray.OFF
|
||||
)
|
||||
public class ChatTimestamp extends Module {
|
||||
private Setting<ColourTextFormatting.ColourCode> firstColour = register(Settings.e("First Colour", ColourTextFormatting.ColourCode.GRAY));
|
||||
private Setting<ColourTextFormatting.ColourCode> secondColour = register(Settings.e("Second Colour", ColourTextFormatting.ColourCode.GRAY));
|
||||
private Setting<TimeUtil.TimeType> timeTypeSetting = register(Settings.e("Time Format", TimeUtil.TimeType.HHMM));
|
||||
private Setting<TimeUtil.TimeUnit> timeUnitSetting = register(Settings.e("Time Unit", TimeUtil.TimeUnit.H24));
|
||||
private Setting<Boolean> doLocale = register(Settings.b("Show AMPM", true));
|
||||
|
||||
@EventHandler
|
||||
public Listener<ClientChatReceivedEvent> listener = new Listener<>(event -> {
|
||||
if (mc.player == null) return;
|
||||
TextComponentString prefix = new TextComponentString(
|
||||
getFormattedTime()
|
||||
);
|
||||
event.setMessage(prefix.appendSibling(event.getMessage()));
|
||||
});
|
||||
|
||||
public String getFormattedTime() {
|
||||
return "<" + TimeUtil.getFinalTime(setToText(secondColour.getValue()), setToText(firstColour.getValue()), timeUnitSetting.getValue(), timeTypeSetting.getValue(), doLocale.getValue()) + TextFormatting.RESET + "> ";
|
||||
}
|
||||
|
||||
private TextFormatting setToText(ColourTextFormatting.ColourCode colourCode) {
|
||||
return toTextMap.get(colourCode);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
package me.zeroeightsix.kami.module.modules.chat
|
||||
|
||||
import me.zero.alpine.listener.EventHandler
|
||||
import me.zero.alpine.listener.EventHook
|
||||
import me.zero.alpine.listener.Listener
|
||||
import me.zeroeightsix.kami.module.Module
|
||||
import me.zeroeightsix.kami.setting.Settings
|
||||
import me.zeroeightsix.kami.util.ColourTextFormatting
|
||||
import me.zeroeightsix.kami.util.ColourTextFormatting.ColourCode
|
||||
import me.zeroeightsix.kami.util.TimeUtil
|
||||
import net.minecraft.util.text.TextComponentString
|
||||
import net.minecraft.util.text.TextFormatting
|
||||
import net.minecraftforge.client.event.ClientChatReceivedEvent
|
||||
|
||||
/**
|
||||
* @author dominikaaaa
|
||||
* Updated by dominikaaaa on 19/04/20
|
||||
*/
|
||||
@Module.Info(
|
||||
name = "ChatTimestamp",
|
||||
category = Module.Category.CHAT,
|
||||
description = "Shows the time a message was sent beside the message",
|
||||
showOnArray = Module.ShowOnArray.OFF
|
||||
)
|
||||
class ChatTimestamp : Module() {
|
||||
private val firstColour = register(Settings.e<ColourCode>("First Colour", ColourCode.GRAY))
|
||||
private val secondColour = register(Settings.e<ColourCode>("Second Colour", ColourCode.GRAY))
|
||||
private val timeTypeSetting = register(Settings.e<TimeUtil.TimeType>("Time Format", TimeUtil.TimeType.HHMM))
|
||||
private val timeUnitSetting = register(Settings.e<TimeUtil.TimeUnit>("Time Unit", TimeUtil.TimeUnit.H24))
|
||||
private val doLocale = register(Settings.b("Show AMPM", true))
|
||||
|
||||
@EventHandler
|
||||
var listener = Listener(EventHook { event: ClientChatReceivedEvent ->
|
||||
if (mc.player == null) return@EventHook
|
||||
val prefix = TextComponentString(
|
||||
formattedTime
|
||||
)
|
||||
event.message = prefix.appendSibling(event.message)
|
||||
})
|
||||
|
||||
val formattedTime: String
|
||||
get() = "<" + TimeUtil.getFinalTime(setToText(secondColour.value), setToText(firstColour.value), timeUnitSetting.value, timeTypeSetting.value, doLocale.value) + TextFormatting.RESET + "> "
|
||||
|
||||
private fun setToText(colourCode: ColourCode): TextFormatting? {
|
||||
return ColourTextFormatting.toTextMap[colourCode]
|
||||
}
|
||||
}
|
|
@ -1,84 +0,0 @@
|
|||
package me.zeroeightsix.kami.module.modules.chat;
|
||||
|
||||
import me.zero.alpine.listener.EventHandler;
|
||||
import me.zero.alpine.listener.Listener;
|
||||
import me.zeroeightsix.kami.command.Command;
|
||||
import me.zeroeightsix.kami.event.events.PacketEvent;
|
||||
import me.zeroeightsix.kami.module.Module;
|
||||
import me.zeroeightsix.kami.setting.Setting;
|
||||
import me.zeroeightsix.kami.setting.Settings;
|
||||
import net.minecraft.network.play.client.CPacketChatMessage;
|
||||
|
||||
import static me.zeroeightsix.kami.KamiMod.separator;
|
||||
import static me.zeroeightsix.kami.util.MessageSendHelper.sendWarningMessage;
|
||||
|
||||
/**
|
||||
* Created by 086 on 8/04/2018.
|
||||
* Updated by dominikaaaa on 12/03/20
|
||||
*/
|
||||
@Module.Info(
|
||||
name = "CustomChat",
|
||||
category = Module.Category.CHAT,
|
||||
description = "Add a custom suffix to the end of your message!",
|
||||
showOnArray = Module.ShowOnArray.OFF
|
||||
)
|
||||
public class CustomChat extends Module {
|
||||
public Setting<TextMode> textMode = register(Settings.e("Message", TextMode.JAPANESE));
|
||||
private Setting<DecoMode> decoMode = register(Settings.e("Separator", DecoMode.NONE));
|
||||
private Setting<Boolean> commands = register(Settings.b("Commands", false));
|
||||
public Setting<String> customText = register(Settings.stringBuilder("Custom Text").withValue("unchanged").withConsumer((old, value) -> {}).build());
|
||||
|
||||
private enum DecoMode { SEPARATOR, CLASSIC, NONE }
|
||||
public enum TextMode { NAME, ON_TOP, WEBSITE, JAPANESE, CUSTOM }
|
||||
public static String[] cmdCheck = new String[]{"/", ",", ".", "-", ";", "?", "*", "^", "&", "%", "#", "$", Command.getCommandPrefix(), ChatEncryption.delimiterValue.getValue()};
|
||||
|
||||
private String getText(TextMode t) {
|
||||
switch (t) {
|
||||
case NAME: return "\u1d0b\u1d00\u1d0d\u026a \u0299\u029f\u1d1c\u1d07";
|
||||
case ON_TOP: return "\u1d0b\u1d00\u1d0d\u026a \u0299\u029f\u1d1c\u1d07 \u1d0f\u0274 \u1d1b\u1d0f\u1d18";
|
||||
case WEBSITE: return "\u0299\u029f\u1d1c\u1d07\u002e\u0299\u1d07\u029f\u029f\u1d00\u002e\u1d21\u1d1b\u0493";
|
||||
case JAPANESE: return "\u4e0a\u306b\u30ab\u30df\u30d6\u30eb\u30fc";
|
||||
case CUSTOM: return customText.getValue();
|
||||
default: return "";
|
||||
}
|
||||
}
|
||||
|
||||
private String getFull(DecoMode d) {
|
||||
switch (d) {
|
||||
case NONE: return " " + getText(textMode.getValue());
|
||||
case CLASSIC: return " \u00ab " + getText(textMode.getValue()) + " \u00bb";
|
||||
case SEPARATOR: return " " + separator + " " + getText(textMode.getValue());
|
||||
default: return "";
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public Listener<PacketEvent.Send> listener = new Listener<>(event -> {
|
||||
if (event.getPacket() instanceof CPacketChatMessage) {
|
||||
String s = ((CPacketChatMessage) event.getPacket()).getMessage();
|
||||
if (!commands.getValue() && isCommand(s)) return;
|
||||
s += getFull(decoMode.getValue());
|
||||
if (s.length() >= 256) s = s.substring(0, 256);
|
||||
((CPacketChatMessage) event.getPacket()).message = s;
|
||||
}
|
||||
});
|
||||
|
||||
private boolean isCommand(String s) {
|
||||
for (String value : cmdCheck) {
|
||||
if (s.startsWith(value)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static long startTime = 0;
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
if (startTime == 0) startTime = System.currentTimeMillis();
|
||||
if (startTime + 5000 <= System.currentTimeMillis()) { // 5 seconds in milliseconds
|
||||
if (textMode.getValue().equals(TextMode.CUSTOM) && customText.getValue().equalsIgnoreCase("unchanged") && mc.player != null) {
|
||||
sendWarningMessage(getChatName() + " Warning: In order to use the custom " + getName() + ", please run the &7" + Command.getCommandPrefix() + "customchat&r command to change it");
|
||||
}
|
||||
startTime = System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,93 @@
|
|||
package me.zeroeightsix.kami.module.modules.chat
|
||||
|
||||
import me.zero.alpine.listener.EventHandler
|
||||
import me.zero.alpine.listener.EventHook
|
||||
import me.zero.alpine.listener.Listener
|
||||
import me.zeroeightsix.kami.KamiMod
|
||||
import me.zeroeightsix.kami.command.Command
|
||||
import me.zeroeightsix.kami.event.events.PacketEvent
|
||||
import me.zeroeightsix.kami.module.Module
|
||||
import me.zeroeightsix.kami.setting.Setting
|
||||
import me.zeroeightsix.kami.setting.Settings
|
||||
import me.zeroeightsix.kami.util.MessageSendHelper
|
||||
import net.minecraft.network.play.client.CPacketChatMessage
|
||||
|
||||
/**
|
||||
* Created by 086 on 8/04/2018.
|
||||
* Updated by dominikaaaa on 12/03/20
|
||||
*/
|
||||
@Module.Info(
|
||||
name = "CustomChat",
|
||||
category = Module.Category.CHAT,
|
||||
description = "Add a custom ending to your message!",
|
||||
showOnArray = Module.ShowOnArray.OFF
|
||||
)
|
||||
class CustomChat : Module() {
|
||||
@JvmField
|
||||
var textMode: Setting<TextMode> = register(Settings.e("Message", TextMode.JAPANESE))
|
||||
private val decoMode = register(Settings.e<DecoMode>("Separator", DecoMode.NONE))
|
||||
private val commands = register(Settings.b("Commands", false))
|
||||
@JvmField
|
||||
var customText: Setting<String> = register(Settings.s("Custom Text", "unchanged"))
|
||||
|
||||
private enum class DecoMode {
|
||||
SEPARATOR, CLASSIC, NONE
|
||||
}
|
||||
|
||||
enum class TextMode {
|
||||
NAME, ON_TOP, WEBSITE, JAPANESE, CUSTOM
|
||||
}
|
||||
|
||||
private fun getText(t: TextMode): String {
|
||||
return when (t) {
|
||||
TextMode.NAME -> "\u1d0b\u1d00\u1d0d\u026a \u0299\u029f\u1d1c\u1d07"
|
||||
TextMode.ON_TOP -> "\u1d0b\u1d00\u1d0d\u026a \u0299\u029f\u1d1c\u1d07 \u1d0f\u0274 \u1d1b\u1d0f\u1d18"
|
||||
TextMode.WEBSITE -> "\u0299\u029f\u1d1c\u1d07\u002e\u0299\u1d07\u029f\u029f\u1d00\u002e\u1d21\u1d1b\u0493"
|
||||
TextMode.JAPANESE -> "\u4e0a\u306b\u30ab\u30df\u30d6\u30eb\u30fc"
|
||||
TextMode.CUSTOM -> customText.value
|
||||
}
|
||||
}
|
||||
|
||||
private fun getFull(d: DecoMode): String {
|
||||
return when (d) {
|
||||
DecoMode.NONE -> " " + getText(textMode.value)
|
||||
DecoMode.CLASSIC -> " \u00ab " + getText(textMode.value) + " \u00bb"
|
||||
DecoMode.SEPARATOR -> " " + KamiMod.separator + " " + getText(textMode.value)
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
var listener = Listener(EventHook { event: PacketEvent.Send ->
|
||||
if (event.packet is CPacketChatMessage) {
|
||||
var s = (event.packet as CPacketChatMessage).getMessage()
|
||||
if (!commands.value && isCommand(s)) return@EventHook
|
||||
s += getFull(decoMode.value)
|
||||
|
||||
if (s.length >= 256) s = s.substring(0, 256)
|
||||
(event.packet as CPacketChatMessage).message = s
|
||||
}
|
||||
})
|
||||
|
||||
private fun isCommand(s: String): Boolean {
|
||||
for (value in cmdCheck) {
|
||||
if (s.startsWith(value)) return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
override fun onUpdate() {
|
||||
if (startTime == 0L) startTime = System.currentTimeMillis()
|
||||
if (startTime + 5000 <= System.currentTimeMillis()) { // 5 seconds in milliseconds
|
||||
if (textMode.value == TextMode.CUSTOM && customText.value.equals("unchanged", ignoreCase = true) && mc.player != null) {
|
||||
MessageSendHelper.sendWarningMessage(chatName + " Warning: In order to use the custom " + name + ", please run the &7" + Command.getCommandPrefix() + "customchat&r command to change it")
|
||||
}
|
||||
startTime = System.currentTimeMillis()
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmField
|
||||
var cmdCheck = arrayOf("/", ",", ".", "-", ";", "?", "*", "^", "&", "%", "#", "$", Command.getCommandPrefix(), ChatEncryption.delimiterValue.value)
|
||||
private var startTime: Long = 0
|
||||
}
|
||||
}
|
|
@ -1,139 +0,0 @@
|
|||
package me.zeroeightsix.kami.module.modules.chat;
|
||||
|
||||
import me.zero.alpine.listener.EventHandler;
|
||||
import me.zero.alpine.listener.Listener;
|
||||
import me.zeroeightsix.kami.event.events.PacketEvent;
|
||||
import me.zeroeightsix.kami.module.Module;
|
||||
import me.zeroeightsix.kami.setting.Setting;
|
||||
import me.zeroeightsix.kami.setting.Settings;
|
||||
import net.minecraft.network.play.client.CPacketChatMessage;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import static me.zeroeightsix.kami.util.MathsUtils.isNumberEven;
|
||||
|
||||
/**
|
||||
* @author dominikaaaa
|
||||
* Updated by dominikaaaa on 12/03/20
|
||||
*/
|
||||
@Module.Info(
|
||||
name = "FancyChat",
|
||||
category = Module.Category.CHAT,
|
||||
description = "Makes messages you send fancy",
|
||||
showOnArray = Module.ShowOnArray.OFF
|
||||
)
|
||||
public class FancyChat extends Module {
|
||||
private Setting<Boolean> uwu = register(Settings.b("uwu", true));
|
||||
private Setting<Boolean> leet = register(Settings.b("1337", false));
|
||||
private Setting<Boolean> mock = register(Settings.b("mOcK", false));
|
||||
private Setting<Boolean> green = register(Settings.b(">", false));
|
||||
private Setting<Boolean> randomSetting = register(Settings.booleanBuilder("Random Case").withValue(true).withVisibility(v -> mock.getValue()).build());
|
||||
private Setting<Boolean> commands = register(Settings.b("Commands", false));
|
||||
|
||||
private static Random random = new Random();
|
||||
|
||||
private String getText(String s) {
|
||||
if (uwu.getValue()) s = uwuConverter(s);
|
||||
if (leet.getValue()) s = leetConverter(s);
|
||||
if (mock.getValue()) s = mockingConverter(s);
|
||||
if (green.getValue()) s = greenConverter(s);
|
||||
return s;
|
||||
}
|
||||
|
||||
private String greenConverter(String input) {
|
||||
return "> " + input;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public Listener<PacketEvent.Send> listener = new Listener<>(event -> {
|
||||
if (event.getPacket() instanceof CPacketChatMessage) {
|
||||
String s = ((CPacketChatMessage) event.getPacket()).getMessage();
|
||||
if (!commands.getValue() && isCommand(s)) return;
|
||||
s = getText(s);
|
||||
if (s.length() >= 256) s = s.substring(0, 256);
|
||||
((CPacketChatMessage) event.getPacket()).message = s;
|
||||
}
|
||||
});
|
||||
|
||||
@Override
|
||||
public String getHudInfo() {
|
||||
StringBuilder returned = new StringBuilder();
|
||||
if (uwu.getValue()) {
|
||||
returned.append("uwu");
|
||||
}
|
||||
if (leet.getValue()) {
|
||||
returned.append(" 1337");
|
||||
}
|
||||
if (mock.getValue()) {
|
||||
returned.append(" mOcK");
|
||||
}
|
||||
if (green.getValue()) {
|
||||
returned.append(" >");
|
||||
}
|
||||
return returned.toString();
|
||||
}
|
||||
|
||||
private boolean isCommand(String s) {
|
||||
for (String value : CustomChat.cmdCheck) {
|
||||
if (s.startsWith(value)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private String leetConverter(String input) {
|
||||
StringBuilder message = new StringBuilder();
|
||||
for (int i = 0 ; i < input.length() ; i++) {
|
||||
String inputChar = input.charAt(i) + "";
|
||||
inputChar = inputChar.toLowerCase();
|
||||
inputChar = leetSwitch(inputChar);
|
||||
message.append(inputChar);
|
||||
}
|
||||
return message.toString();
|
||||
}
|
||||
|
||||
private String mockingConverter(String input) {
|
||||
StringBuilder message = new StringBuilder();
|
||||
for (int i = 0 ; i < input.length() ; i++) {
|
||||
String inputChar = input.charAt(i) + "";
|
||||
|
||||
int rand = 0;
|
||||
if (randomSetting.getValue()) rand = random.nextBoolean() ? 1 : 0;
|
||||
|
||||
if (!isNumberEven(i + rand)) inputChar = inputChar.toUpperCase();
|
||||
else inputChar = inputChar.toLowerCase();
|
||||
message.append(inputChar);
|
||||
}
|
||||
return message.toString();
|
||||
}
|
||||
|
||||
private String uwuConverter(String input) {
|
||||
input = input.replace("ove", "uv");
|
||||
input = input.replace("the", "da");
|
||||
input = input.replace("is", "ish");
|
||||
input = input.replace("r", "w");
|
||||
input = input.replace("ve", "v");
|
||||
input = input.replace("l", "w");
|
||||
return input;
|
||||
}
|
||||
|
||||
private String leetSwitch(String i) {
|
||||
switch (i) {
|
||||
case "a":
|
||||
return "4";
|
||||
case "e":
|
||||
return "3";
|
||||
case "g":
|
||||
return "6";
|
||||
case "l":
|
||||
case "i":
|
||||
return "1";
|
||||
case "o":
|
||||
return "0";
|
||||
case "s":
|
||||
return "$";
|
||||
case "t":
|
||||
return "7";
|
||||
default: return i;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,131 @@
|
|||
package me.zeroeightsix.kami.module.modules.chat
|
||||
|
||||
import me.zero.alpine.listener.EventHandler
|
||||
import me.zero.alpine.listener.EventHook
|
||||
import me.zero.alpine.listener.Listener
|
||||
import me.zeroeightsix.kami.event.events.PacketEvent
|
||||
import me.zeroeightsix.kami.module.Module
|
||||
import me.zeroeightsix.kami.setting.Settings
|
||||
import me.zeroeightsix.kami.util.MathsUtils
|
||||
import net.minecraft.network.play.client.CPacketChatMessage
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
* @author dominikaaaa
|
||||
* Updated by dominikaaaa on 12/03/20
|
||||
*/
|
||||
@Module.Info(
|
||||
name = "FancyChat",
|
||||
category = Module.Category.CHAT,
|
||||
description = "Makes messages you send fancy",
|
||||
showOnArray = Module.ShowOnArray.OFF
|
||||
)
|
||||
class FancyChat : Module() {
|
||||
private val uwu = register(Settings.b("uwu", true))
|
||||
private val leet = register(Settings.b("1337", false))
|
||||
private val mock = register(Settings.b("mOcK", false))
|
||||
private val green = register(Settings.b(">", false))
|
||||
private val randomSetting = register(Settings.booleanBuilder("Random Case").withValue(true).withVisibility { mock.value }.build())
|
||||
private val commands = register(Settings.b("Commands", false))
|
||||
|
||||
private fun getText(s: String): String {
|
||||
var string = s
|
||||
if (uwu.value) string = uwuConverter(string)
|
||||
if (leet.value) string = leetConverter(string)
|
||||
if (mock.value) string = mockingConverter(string)
|
||||
if (green.value) string = greenConverter(string)
|
||||
return string
|
||||
}
|
||||
|
||||
private fun greenConverter(input: String): String {
|
||||
return "> $input"
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
var listener = Listener(EventHook { event: PacketEvent.Send ->
|
||||
if (event.packet is CPacketChatMessage) {
|
||||
var s = (event.packet as CPacketChatMessage).getMessage()
|
||||
|
||||
if (!commands.value && isCommand(s)) return@EventHook
|
||||
s = getText(s)
|
||||
|
||||
if (s.length >= 256) s = s.substring(0, 256)
|
||||
(event.packet as CPacketChatMessage).message = s
|
||||
}
|
||||
})
|
||||
|
||||
override fun getHudInfo(): String {
|
||||
val returned = StringBuilder()
|
||||
if (uwu.value) {
|
||||
returned.append("uwu")
|
||||
}
|
||||
if (leet.value) {
|
||||
returned.append(" 1337")
|
||||
}
|
||||
if (mock.value) {
|
||||
returned.append(" mOcK")
|
||||
}
|
||||
if (green.value) {
|
||||
returned.append(" >")
|
||||
}
|
||||
return returned.toString()
|
||||
}
|
||||
|
||||
private fun isCommand(s: String): Boolean {
|
||||
for (value in CustomChat.cmdCheck) {
|
||||
if (s.startsWith(value)) return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
private fun leetConverter(input: String): String {
|
||||
val message = StringBuilder()
|
||||
for (element in input) {
|
||||
var inputChar = element.toString() + ""
|
||||
inputChar = inputChar.toLowerCase()
|
||||
inputChar = leetSwitch(inputChar)
|
||||
message.append(inputChar)
|
||||
}
|
||||
return message.toString()
|
||||
}
|
||||
|
||||
private fun mockingConverter(input: String): String {
|
||||
val message = StringBuilder()
|
||||
for (i in input.indices) {
|
||||
var inputChar = input[i].toString() + ""
|
||||
var rand = 0
|
||||
if (randomSetting.value) rand = if (random.nextBoolean()) 1 else 0
|
||||
inputChar = if (!MathsUtils.isNumberEven(i + rand)) inputChar.toUpperCase() else inputChar.toLowerCase()
|
||||
message.append(inputChar)
|
||||
}
|
||||
return message.toString()
|
||||
}
|
||||
|
||||
private fun uwuConverter(input: String): String {
|
||||
var lInput = input
|
||||
lInput = lInput.replace("ove", "uv")
|
||||
lInput = lInput.replace("the", "da")
|
||||
lInput = lInput.replace("is", "ish")
|
||||
lInput = lInput.replace("r", "w")
|
||||
lInput = lInput.replace("ve", "v")
|
||||
lInput = lInput.replace("l", "w")
|
||||
return lInput
|
||||
}
|
||||
|
||||
private fun leetSwitch(i: String): String {
|
||||
return when (i) {
|
||||
"a" -> "4"
|
||||
"e" -> "3"
|
||||
"g" -> "6"
|
||||
"l", "i" -> "1"
|
||||
"o" -> "0"
|
||||
"s" -> "$"
|
||||
"t" -> "7"
|
||||
else -> i
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val random = Random()
|
||||
}
|
||||
}
|
|
@ -1,49 +0,0 @@
|
|||
package me.zeroeightsix.kami.module.modules.chat;
|
||||
|
||||
import me.zero.alpine.listener.EventHandler;
|
||||
import me.zero.alpine.listener.Listener;
|
||||
import me.zeroeightsix.kami.KamiMod;
|
||||
import me.zeroeightsix.kami.event.events.PacketEvent;
|
||||
import me.zeroeightsix.kami.module.Module;
|
||||
import me.zeroeightsix.kami.util.Wrapper;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.network.play.client.CPacketChatMessage;
|
||||
|
||||
import static me.zeroeightsix.kami.util.MessageSendHelper.sendWarningMessage;
|
||||
|
||||
/**
|
||||
* Created on 16 December by 0x2E | PretendingToCode
|
||||
*/
|
||||
|
||||
@Module.Info(
|
||||
name = "FormatChat",
|
||||
description = "Add colour and linebreak support to upstream chat packets",
|
||||
category = Module.Category.CHAT
|
||||
)
|
||||
public class FormatChat extends Module {
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
if (Minecraft.getMinecraft().getCurrentServerData() == null) {
|
||||
sendWarningMessage(getChatName() + " &6&lWarning: &r&6This does not work in singleplayer");
|
||||
disable();
|
||||
}
|
||||
else {
|
||||
sendWarningMessage(getChatName() + " &6&lWarning: &r&6This will kick you on most servers!");
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public Listener<PacketEvent.Send> sendListener = new Listener<>(event -> {
|
||||
if (event.getPacket() instanceof CPacketChatMessage) {
|
||||
String message = ((CPacketChatMessage) event.getPacket()).message;
|
||||
if (message.contains("&") || message.contains("#n")) {
|
||||
message = message.replaceAll("&", KamiMod.colour + "");
|
||||
message = message.replaceAll("#n", "\n");
|
||||
|
||||
Wrapper.getPlayer().connection.sendPacket(new CPacketChatMessage(message));
|
||||
event.cancel();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
package me.zeroeightsix.kami.module.modules.chat
|
||||
|
||||
import me.zero.alpine.listener.EventHandler
|
||||
import me.zero.alpine.listener.EventHook
|
||||
import me.zero.alpine.listener.Listener
|
||||
import me.zeroeightsix.kami.KamiMod
|
||||
import me.zeroeightsix.kami.event.events.PacketEvent
|
||||
import me.zeroeightsix.kami.module.Module
|
||||
import me.zeroeightsix.kami.util.MessageSendHelper
|
||||
import me.zeroeightsix.kami.util.Wrapper
|
||||
import net.minecraft.client.Minecraft
|
||||
import net.minecraft.network.play.client.CPacketChatMessage
|
||||
|
||||
/**
|
||||
* Created on 16 December by 0x2E | PretendingToCode
|
||||
*/
|
||||
@Module.Info(
|
||||
name = "FormatChat",
|
||||
description = "Add colour and linebreak support to upstream chat packets",
|
||||
category = Module.Category.CHAT
|
||||
)
|
||||
class FormatChat : Module() {
|
||||
public override fun onEnable() {
|
||||
if (Minecraft.getMinecraft().getCurrentServerData() == null) {
|
||||
MessageSendHelper.sendWarningMessage("$chatName &6&lWarning: &r&6This does not work in singleplayer")
|
||||
disable()
|
||||
} else {
|
||||
MessageSendHelper.sendWarningMessage("$chatName &6&lWarning: &r&6This will kick you on most servers!")
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
var sendListener = Listener(EventHook { event: PacketEvent.Send ->
|
||||
if (event.packet is CPacketChatMessage) {
|
||||
var message = (event.packet as CPacketChatMessage).message
|
||||
|
||||
if (message.contains("&") || message.contains("#n")) {
|
||||
message = message.replace("&".toRegex(), KamiMod.colour.toString() + "")
|
||||
message = message.replace("#n".toRegex(), "\n")
|
||||
Wrapper.getPlayer().connection.sendPacket(CPacketChatMessage(message))
|
||||
event.cancel()
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
|
@ -1,62 +0,0 @@
|
|||
package me.zeroeightsix.kami.module.modules.chat;
|
||||
|
||||
import me.zero.alpine.listener.EventHandler;
|
||||
import me.zero.alpine.listener.Listener;
|
||||
import me.zeroeightsix.kami.module.Module;
|
||||
import me.zeroeightsix.kami.setting.Setting;
|
||||
import me.zeroeightsix.kami.setting.Settings;
|
||||
import me.zeroeightsix.kami.util.ColourTextFormatting;
|
||||
import me.zeroeightsix.kami.util.Friends;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraftforge.client.event.ClientChatReceivedEvent;
|
||||
|
||||
import static me.zeroeightsix.kami.util.ColourTextFormatting.toTextMap;
|
||||
import static me.zeroeightsix.kami.util.MessageSendHelper.sendErrorMessage;
|
||||
|
||||
@Module.Info(
|
||||
name = "FriendHighlight",
|
||||
description = "Highlights your friends names in chat",
|
||||
category = Module.Category.CHAT,
|
||||
showOnArray = Module.ShowOnArray.OFF
|
||||
)
|
||||
public class FriendHighlight extends Module {
|
||||
private Setting<Boolean> bold = register(Settings.b("Bold", true));
|
||||
private Setting<ColourTextFormatting.ColourCode> colour = register(Settings.e("Colour", ColourTextFormatting.ColourCode.GRAY));
|
||||
|
||||
public void onEnable() {
|
||||
if (Friends.friends.getValue().size() > 100) {
|
||||
sendErrorMessage(getChatName() + "Your friends list is bigger then 100, disabling as it would cause too much of a performance impact.");
|
||||
disable();
|
||||
}
|
||||
noFriendsCheck();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public Listener<ClientChatReceivedEvent> listener = new Listener<>(event -> {
|
||||
if (mc.player == null || noFriendsCheck()) return;
|
||||
final String[] converted = {""};
|
||||
Friends.friends.getValue().forEach(friend -> converted[0] = event.getMessage().getFormattedText().replaceAll("(?i)" + friend.getUsername(), colour() + bold() + friend.getUsername() + TextFormatting.RESET.toString()));
|
||||
TextComponentString message = new TextComponentString(converted[0]);
|
||||
event.setMessage(message);
|
||||
});
|
||||
|
||||
private boolean noFriendsCheck() {
|
||||
if (Friends.friends.getValue().size() == 0) {
|
||||
sendErrorMessage(getChatName() + "You don't have any friends added, silly! Go add some friends before using the module");
|
||||
disable();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private String bold() {
|
||||
if (!bold.getValue()) return "";
|
||||
return TextFormatting.BOLD.toString();
|
||||
}
|
||||
|
||||
private String colour() {
|
||||
return toTextMap.get(colour.getValue()).toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
package me.zeroeightsix.kami.module.modules.chat
|
||||
|
||||
import me.zero.alpine.listener.EventHandler
|
||||
import me.zero.alpine.listener.EventHook
|
||||
import me.zero.alpine.listener.Listener
|
||||
import me.zeroeightsix.kami.module.Module
|
||||
import me.zeroeightsix.kami.setting.Settings
|
||||
import me.zeroeightsix.kami.util.ColourTextFormatting
|
||||
import me.zeroeightsix.kami.util.ColourTextFormatting.ColourCode
|
||||
import me.zeroeightsix.kami.util.Friends
|
||||
import me.zeroeightsix.kami.util.Friends.Friend
|
||||
import me.zeroeightsix.kami.util.MessageSendHelper
|
||||
import net.minecraft.util.text.TextComponentString
|
||||
import net.minecraft.util.text.TextFormatting
|
||||
import net.minecraftforge.client.event.ClientChatReceivedEvent
|
||||
import java.util.function.Consumer
|
||||
|
||||
@Module.Info(
|
||||
name = "FriendHighlight",
|
||||
description = "Highlights your friends names in chat",
|
||||
category = Module.Category.CHAT,
|
||||
showOnArray = Module.ShowOnArray.OFF
|
||||
)
|
||||
class FriendHighlight : Module() {
|
||||
private val bold = register(Settings.b("Bold", true))
|
||||
private val colour = register(Settings.e<ColourCode>("Colour", ColourCode.GRAY))
|
||||
|
||||
public override fun onEnable() {
|
||||
if (Friends.friends.value.size > 100) {
|
||||
MessageSendHelper.sendErrorMessage(chatName + "Your friends list is bigger then 100, disabling as it would cause too much of a performance impact.")
|
||||
disable()
|
||||
}
|
||||
noFriendsCheck()
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
var listener = Listener(EventHook { event: ClientChatReceivedEvent ->
|
||||
if (mc.player == null || noFriendsCheck()) return@EventHook
|
||||
val converted = arrayOf("")
|
||||
Friends.friends.value.forEach(Consumer { friend: Friend -> converted[0] = event.message.formattedText.replace("(?i)" + friend.username.toRegex(), colour() + bold() + friend.username + TextFormatting.RESET.toString()) })
|
||||
val message = TextComponentString(converted[0])
|
||||
event.message = message
|
||||
})
|
||||
|
||||
private fun noFriendsCheck(): Boolean {
|
||||
if (Friends.friends.value.size == 0) {
|
||||
MessageSendHelper.sendErrorMessage(chatName + "You don't have any friends added, silly! Go add some friends before using the module")
|
||||
disable()
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
private fun bold(): String {
|
||||
return if (!bold.value) "" else TextFormatting.BOLD.toString()
|
||||
}
|
||||
|
||||
private fun colour(): String {
|
||||
return ColourTextFormatting.toTextMap[colour.value].toString()
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
package me.zeroeightsix.kami.module.modules.chat;
|
||||
package me.zeroeightsix.kami.module.modules.chat
|
||||
|
||||
import me.zeroeightsix.kami.module.Module;
|
||||
import me.zeroeightsix.kami.module.Module
|
||||
|
||||
/**
|
||||
* Created by 086 on 12/12/2017.
|
||||
|
@ -13,5 +13,4 @@ import me.zeroeightsix.kami.module.Module;
|
|||
description = "Allows you to open GUIs in portals",
|
||||
showOnArray = Module.ShowOnArray.OFF
|
||||
)
|
||||
public class PortalChat extends Module {
|
||||
}
|
||||
class PortalChat : Module()
|
|
@ -25,6 +25,10 @@ public class MessageDetectionHelper {
|
|||
return directSent && Pattern.compile("^to ([0-9A-z_])+:.*").matcher(message).find();
|
||||
}
|
||||
|
||||
public static boolean isTPA(boolean tpa, String message) {
|
||||
return tpa && Pattern.compile("^([0-9A-z_])+ has requested to teleport to you\\..*").matcher(message).find();
|
||||
}
|
||||
|
||||
public static boolean isQueue(boolean queue, String message) {
|
||||
if (queue && message.contains("Position in queue:")) return true;
|
||||
else return queue && message.contains("2b2t is full");
|
||||
|
|
Loading…
Reference in New Issue