Skip to content

Commit c6a70e0

Browse files
committed
first commit
0 parents  commit c6a70e0

15 files changed

+1682
-0
lines changed

.editorconfig

+1,043
Large diffs are not rendered by default.

.github/workflows/build.yml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: LabyAddon Build
2+
3+
on:
4+
push:
5+
branches: [ "master", "main" ]
6+
pull_request:
7+
branches: [ "master", "main" ]
8+
workflow_dispatch:
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v3
15+
- name: Set up JDK 17
16+
uses: actions/setup-java@v3
17+
with:
18+
distribution: 'corretto'
19+
java-version: '17'
20+
- name: Grant execute permission for gradlew
21+
run: chmod +x gradlew
22+
- name: Build with Gradle
23+
run: ./gradlew build --full-stacktrace
24+
- name: Upload Artifact
25+
uses: actions/upload-artifact@v3
26+
with:
27+
name: Artifacts
28+
path: build/libs/*-release.jar

.gitignore

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# Created by .ignore support plugin (hsz.mobi)
2+
### Java template
3+
# Compiled class file
4+
*.class
5+
6+
# Log file
7+
*.log
8+
9+
# BlueJ files
10+
*.ctxt
11+
12+
# Mobile Tools for Java (J2ME)
13+
.mtj.tmp/
14+
15+
# Package Files #
16+
*.jar
17+
*.war
18+
*.nar
19+
*.ear
20+
*.zip
21+
*.tar.gz
22+
*.rar
23+
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
24+
hs_err_pid*
25+
26+
### JetBrains template
27+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
28+
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
29+
30+
# User-specific stuff
31+
/.idea/
32+
run/**
33+
34+
# CMake
35+
cmake-build-*/
36+
37+
# File-based project format
38+
*.iws
39+
40+
# IntelliJ
41+
out/
42+
43+
# mpeltonen/sbt-idea plugin
44+
.idea_modules/
45+
46+
# JIRA plugin
47+
atlassian-ide-plugin.xml
48+
49+
# Crashlytics plugin (for Android Studio and IntelliJ)
50+
com_crashlytics_export_strings.xml
51+
crashlytics.properties
52+
crashlytics-build.properties
53+
fabric.properties
54+
55+
### Gradle template
56+
.gradle
57+
/**/build/
58+
59+
# Ignore Gradle GUI config
60+
gradle-app.setting
61+
62+
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
63+
!gradle-wrapper.jar
64+
65+
# Cache of project
66+
.gradletasknamecache
67+
68+
docs/generated/
69+
70+
# Project
71+
run/
72+
73+
# LabyGradle | Addon Plugin
74+
build-data.txt
75+
.assetsroot
76+
77+
# Don't ignore libraries
78+
!libs/*.jar

api/build.gradle.kts

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
version = "0.1.0"
2+
3+
plugins {
4+
id("java-library")
5+
}
6+
7+
dependencies {
8+
labyApi("api")
9+
}
10+
11+
labyModProcessor {
12+
referenceType = net.labymod.gradle.core.processor.ReferenceType.INTERFACE
13+
}
14+
15+
java {
16+
sourceCompatibility = JavaVersion.VERSION_17
17+
targetCompatibility = JavaVersion.VERSION_17
18+
}

build.gradle.kts

+96
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
plugins {
2+
id("java-library")
3+
id("net.labymod.gradle")
4+
id("net.labymod.gradle.addon")
5+
}
6+
7+
group = "de.lebaasti"
8+
version = "1.0.0"
9+
10+
java.toolchain.languageVersion.set(JavaLanguageVersion.of(17))
11+
12+
labyMod {
13+
defaultPackageName = "de.lebaasti" //change this to your main package name (used by all modules)
14+
addonInfo {
15+
namespace = "antichatspam"
16+
displayName = "AntiChatSpam"
17+
author = "LeBaasti"
18+
description = "You can define after how many duplicate messages, it should be stacked to one message." +
19+
"It´s getting reseted if you switch a server or sub-server."
20+
minecraftVersion = "*"
21+
version = System.getenv().getOrDefault("VERSION", "0.0.1")
22+
}
23+
24+
minecraft {
25+
registerVersions(
26+
"1.8.9",
27+
"1.12.2",
28+
"1.16.5",
29+
"1.17.1",
30+
"1.18.2",
31+
"1.19.2",
32+
"1.19.3",
33+
"1.19.4",
34+
"1.20.1",
35+
"1.20.2",
36+
"1.20.4"
37+
) { version, provider ->
38+
configureRun(provider, version)
39+
}
40+
41+
subprojects.forEach {
42+
if (it.name != "game-runner") {
43+
filter(it.name)
44+
}
45+
}
46+
}
47+
48+
addonDev {
49+
productionRelease()
50+
}
51+
}
52+
53+
subprojects {
54+
plugins.apply("java-library")
55+
plugins.apply("net.labymod.gradle")
56+
plugins.apply("net.labymod.gradle.addon")
57+
58+
repositories {
59+
maven("https://libraries.minecraft.net/")
60+
maven("https://repo.spongepowered.org/repository/maven-public/")
61+
}
62+
}
63+
64+
fun configureRun(provider: net.labymod.gradle.core.minecraft.provider.VersionProvider, gameVersion: String) {
65+
provider.runConfiguration {
66+
mainClass = "net.minecraft.launchwrapper.Launch"
67+
jvmArgs("-Dnet.labymod.running-version=${gameVersion}")
68+
jvmArgs("-Dmixin.debug=true")
69+
jvmArgs("-Dnet.labymod.debugging.all=true")
70+
jvmArgs("-Dmixin.env.disableRefMap=true")
71+
72+
args("--tweakClass", "net.labymod.core.loader.vanilla.launchwrapper.LabyModLaunchWrapperTweaker")
73+
args("--labymod-dev-environment", "true")
74+
args("--addon-dev-environment", "true")
75+
}
76+
77+
provider.javaVersion = when (gameVersion) {
78+
else -> {
79+
JavaVersion.VERSION_17
80+
}
81+
}
82+
83+
provider.mixin {
84+
val mixinMinVersion = when (gameVersion) {
85+
"1.8.9", "1.12.2", "1.16.5" -> {
86+
"0.6.6"
87+
}
88+
89+
else -> {
90+
"0.8.2"
91+
}
92+
}
93+
94+
minVersion = mixinMinVersion
95+
}
96+
}

core/build.gradle.kts

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
version = "0.1.0"
2+
3+
plugins {
4+
id("java-library")
5+
}
6+
7+
dependencies {
8+
api(project(":api"))
9+
}
10+
11+
labyModProcessor {
12+
referenceType = net.labymod.gradle.core.processor.ReferenceType.DEFAULT
13+
}
14+
15+
java {
16+
sourceCompatibility = JavaVersion.VERSION_17
17+
targetCompatibility = JavaVersion.VERSION_17
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package de.lebaasti.core;
2+
3+
import net.labymod.api.addon.LabyAddon;
4+
import net.labymod.api.client.chat.ChatMessage;
5+
import net.labymod.api.client.component.Component;
6+
import net.labymod.api.event.Subscribe;
7+
import net.labymod.api.event.client.chat.ChatReceiveEvent;
8+
import net.labymod.api.event.client.network.server.ServerJoinEvent;
9+
import net.labymod.api.event.client.network.server.SubServerSwitchEvent;
10+
import net.labymod.api.models.addon.annotation.AddonMain;
11+
import java.util.ArrayList;
12+
import java.util.HashMap;
13+
14+
@AddonMain
15+
public class AntiChatSpam extends LabyAddon<Configuration> {
16+
17+
@Override
18+
protected void enable() {
19+
this.registerSettingCategory();
20+
21+
this.logger().info("Enabled AntiChatSpam Addon");
22+
}
23+
24+
@Override
25+
protected Class<Configuration> configurationClass() {
26+
return Configuration.class;
27+
}
28+
29+
private final HashMap<String, ArrayList<ChatMessage>> duplicateMessages = new HashMap<>();
30+
private final HashMap<String, Integer> duplicateMessageCount = new HashMap<>();
31+
32+
@Subscribe
33+
public void onSubServerSwitch(SubServerSwitchEvent event) {
34+
duplicateMessages.clear();
35+
duplicateMessageCount.clear();
36+
}
37+
38+
@Subscribe
39+
public void onServerJoin(ServerJoinEvent event) {
40+
duplicateMessages.clear();
41+
duplicateMessageCount.clear();
42+
}
43+
44+
@Subscribe
45+
public void onChatReceive(ChatReceiveEvent event) {
46+
String originalPlainText = event.chatMessage().getOriginalPlainText();
47+
ArrayList<ChatMessage> duplicates = duplicateMessages.computeIfAbsent(originalPlainText, key -> new ArrayList<>());
48+
int count = duplicateMessageCount.compute(originalPlainText, (key, value) -> value == null ? 1 : value + 1);
49+
50+
if (count >= configuration().amount().get()) {
51+
duplicates.forEach(ChatMessage::delete);
52+
duplicates.clear();
53+
event.chatMessage().component().append(Component.text(" [x" + count + "]"));
54+
}
55+
56+
duplicates.add(event.chatMessage());
57+
}
58+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package de.lebaasti.core;
2+
3+
import net.labymod.api.addon.AddonConfig;
4+
import net.labymod.api.client.gui.screen.widget.widgets.input.SliderWidget.SliderSetting;
5+
import net.labymod.api.client.gui.screen.widget.widgets.input.SwitchWidget.SwitchSetting;
6+
import net.labymod.api.configuration.loader.annotation.ConfigName;
7+
import net.labymod.api.configuration.loader.property.ConfigProperty;
8+
9+
@ConfigName("settings")
10+
public class Configuration extends AddonConfig {
11+
12+
@SwitchSetting
13+
private final ConfigProperty<Boolean> enabled = new ConfigProperty<>(true);
14+
15+
@SliderSetting(min = 2, max = 50)
16+
private final ConfigProperty<Integer> amount = new ConfigProperty<>(2);
17+
18+
@Override
19+
public ConfigProperty<Boolean> enabled() {
20+
return this.enabled;
21+
}
22+
23+
public ConfigProperty<Integer> amount() { return this.amount; }
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"antichatspam": {
3+
"settings": {
4+
"name": "AntiChatSpam",
5+
"enabled": {
6+
"name": "Enabled"
7+
},
8+
"amount": {
9+
"name": "Amount",
10+
"description": "Amount when duplicate messages should be stacked"
11+
}
12+
}
13+
}
14+
}

gradle.properties

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
org.gradle.jvmargs=-Xmx4096m

gradle/wrapper/gradle-wrapper.jar

57.8 KB
Binary file not shown.
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
4+
zipStoreBase=GRADLE_USER_HOME
5+
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)