Merge branch 'master' into dewy/baritone

This commit is contained in:
Dewy REDACTED 2020-04-19 16:00:58 +01:00
commit 9a49e13c0d
No known key found for this signature in database
GPG Key ID: 0CAA84A783228505
2 changed files with 58 additions and 42 deletions

View File

@ -27,7 +27,7 @@ import static me.zeroeightsix.kami.util.MessageSendHelper.sendRawChatMessage;
* Created 19 November 2019 by hub
* Updated 12 January 2020 by hub
* Updated 19 February 2020 by aUniqueUser
* Updated by dominikaaaa on 18/04/20
* Updated by dominikaaaa on 19/04/20
*/
@Module.Info(
name = "AntiSpam",
@ -45,7 +45,6 @@ public class AntiSpam extends Module {
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> wordsLongerThen = register(Settings.booleanBuilder("11+ long words").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());
@ -55,11 +54,8 @@ public class AntiSpam extends Module {
/* 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(true).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> tradeChat = register(Settings.booleanBuilder("Trade Chat").withValue(true).withVisibility(v -> p.getValue().equals(Page.TWO)).build());
private Setting<Boolean> hypixelShills = register(Settings.booleanBuilder("Hypixel Shills").withValue(true).withVisibility(v -> p.getValue().equals(Page.TWO)).build());
private Setting<Boolean> ipsAgr = register(Settings.booleanBuilder("Ips Aggressive").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());
@ -129,7 +125,7 @@ public class AntiSpam extends Module {
private boolean detectSpam(String message) {
for (Map.Entry<Setting<Boolean>, String[]> entry : settingMap.entrySet()) {
if (entry.getKey().getValue() && findPatterns(entry.getValue(), message, true)) {
if (entry.getKey().getValue() && findPatterns(entry.getValue(), message)) {
sendResult(entry.getKey().getName(), message);
return true;
}
@ -158,10 +154,8 @@ public class AntiSpam extends Module {
return Pattern.compile(ownFilter, Pattern.CASE_INSENSITIVE).matcher(message).find();
}
private boolean findPatterns(String[] patterns, String string, boolean removeUsername) {
if (removeUsername) {
string = string.replaceAll("<[^>]*> ", ""); // remove username first
}
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;
@ -171,7 +165,6 @@ public class AntiSpam extends Module {
}
private Map<Setting<Boolean>, String[]> settingMap = new HashMap<Setting<Boolean>, String[]>() {{
put(wordsLongerThen, FilterPatterns.LONG_WORD);
put(greenText, FilterPatterns.GREEN_TEXT);
put(specialCharBegin, FilterPatterns.SPECIAL_BEGINNING);
put(specialCharEnding, FilterPatterns.SPECIAL_ENDING);
@ -183,13 +176,10 @@ public class AntiSpam extends Module {
put(discordLinks, FilterPatterns.DISCORD);
put(webLinks, FilterPatterns.WEB_LINK);
put(ips, FilterPatterns.IP_ADDR);
put(ipsAgr, FilterPatterns.IP_ADDR_AGR);
put(announcers, FilterPatterns.ANNOUNCER);
put(spammers, FilterPatterns.SPAMMER);
put(insulters, FilterPatterns.INSULTER);
put(greeters, FilterPatterns.GREETER);
put(hypixelShills, FilterPatterns.HYPIXEL_SHILLS);
put(tradeChat, FilterPatterns.TRADE_CHAT);
}};
private static class FilterPatterns {
@ -316,13 +306,6 @@ public class AntiSpam extends Module {
".+ left the game",
};
private static final String[] HYPIXEL_SHILLS = {
"/p join",
"/party join",
"road to",
"private games"
};
private static final String[] DISCORD = {
"discord.gg",
"discordapp.com",
@ -342,11 +325,6 @@ public class AntiSpam extends Module {
"^>.+$",
};
private static final String[] TRADE_CHAT = {
"buy",
"sell",
};
private static final String[] WEB_LINK = {
"http:\\/\\/",
"https:\\/\\/",
@ -360,15 +338,6 @@ public class AntiSpam extends Module {
".*\\..*\\:\\d{1,5}$",
};
private static final String[] IP_ADDR_AGR = {
".*\\..*$",
};
private static final String[] LONG_WORD = {
// "\\b\\w{" + getCharacters() + ",256}\\b",
"\\b\\w{11,256}\\b",
};
private static final String[] OWNS_ME_AND_ALL = {
"owns me and all",
};
@ -383,15 +352,10 @@ public class AntiSpam extends Module {
};
private static final String[] SPECIAL_ENDING = {
"[/@#^()\\[\\]{}<>|\\-+=\\\\]",
"[/@#^()\\[\\]{}<>|\\-+=\\\\]$",
};
}
// private static Integer getCharacters() {
// AntiSpam antiSpam = ((AntiSpam) ModuleManager.getModuleByName("AntiSpam"));
// return antiSpam.characters.getValue();
// }
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))

View File

@ -0,0 +1,52 @@
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.MessageSendHelper;
import net.minecraft.network.play.server.SPacketChat;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
@Module.Info(
name = "LoginMessage",
description = "Sends a given message to public chat on login.",
category = Module.Category.CHAT
)
public class LoginMessage extends Module {
private String loginMessage;
private boolean sent = false;
@Override
protected void onEnable() {
BufferedReader reader;
try {
MessageSendHelper.sendChatMessage(getChatName() + "Finding login message from loginmsg.txt...");
reader = new BufferedReader(new FileReader("loginmsg.txt"));
loginMessage = reader.readLine();
reader.close();
} catch (FileNotFoundException e) {
MessageSendHelper.sendErrorMessage(getChatName() + "The file '&7loginmsg.txt&f' was not found in your .minecraft folder. Create it and add a message to enable this module.");
disable();
} catch (IOException e) {
KamiMod.log.error(e);
}
}
@EventHandler
public Listener<PacketEvent.Receive> serverConnectedEventListener = new Listener<>(event -> {
if (event.getPacket() instanceof SPacketChat && !sent) {
mc.player.sendChatMessage(loginMessage);
sent = true;
}
});
}