Skip to content

Commit 339f89b

Browse files
committed
Merge branch '1.21.11' into feature/betterchat
2 parents 3e26528 + 4c392e9 commit 339f89b

File tree

6 files changed

+236
-87
lines changed

6 files changed

+236
-87
lines changed

.github/workflows/build.yml

Lines changed: 0 additions & 69 deletions
This file was deleted.
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: Nightly Build
2+
3+
on:
4+
push:
5+
6+
jobs:
7+
build:
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.ref }}
10+
cancel-in-progress: true
11+
12+
name: Build Lambda
13+
runs-on: ubuntu-latest
14+
15+
permissions:
16+
contents: write
17+
18+
env:
19+
SEGMENT_DOWNLOAD_TIMEOUT_MINS: '5'
20+
21+
steps:
22+
- name: Checkout Repository
23+
uses: actions/checkout@v4
24+
25+
- name: Get short commit hash
26+
id: vars
27+
run: echo "COMMIT_HASH=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
28+
29+
- name: Set-Up JDK
30+
uses: actions/setup-java@v4
31+
with:
32+
distribution: 'oracle'
33+
java-version: '21'
34+
architecture: x64
35+
cache: 'gradle'
36+
37+
- name: Read Gradle Properties
38+
uses: BrycensRanch/read-properties-action@v1.0.4
39+
id: all
40+
with:
41+
file: gradle.properties
42+
all: true
43+
44+
- name: Publish snapshot to maven
45+
# if: github.event_name == 'push'
46+
id: upload-maven
47+
run: ./gradlew publish -PmavenType=snapshots -PmavenUsername=${{ secrets.MAVEN_USER }} -PmavenPassword=${{ secrets.MAVEN_TOKEN }}
48+
49+
# - name: Generate Summary
50+
# if: steps.upload.conclusion == 'success' && github.event_name == 'push'
51+
# run: |
52+
# cat << EOF >> $GITHUB_STEP_SUMMARY
53+
# ### [Lambda ${{ steps.all.outputs.modVersion }} ${{ steps.all.outputs.minecraftVersion }} (${{ env.COMMIT_HASH }})](https://maven.lambda-client.org/snapshots/com/lambda/lambda/${{ steps.all.outputs.modVersion }}+${{ steps.all.outputs.minecraftVersion }}-${{ env.COMMIT_HASH }}/lambda-${{ steps.all.outputs.modVersion }}+${{ steps.all.outputs.minecraftVersion }}-${{ env.COMMIT_HASH }}.jar)
54+
# EOF
55+
56+
- name: Rename jar
57+
# if: steps.upload.conclusion == 'failure' || github.event_name == 'pull_request'
58+
run: mv build/libs/lambda-${{ steps.all.outputs.modVersion }}+${{ steps.all.outputs.minecraftVersion }}.jar build/libs/lambda-${{ steps.all.outputs.modVersion }}+${{ steps.all.outputs.minecraftVersion }}-${{ env.COMMIT_HASH }}.jar
59+
60+
- name: Upload
61+
# if: steps.upload.conclusion == 'failure' || github.event_name == 'pull_request'
62+
uses: actions/upload-artifact@v4
63+
id: upload-git
64+
with:
65+
name: lambda-nightly
66+
path: |
67+
build/libs/lambda-${{ steps.all.outputs.modVersion }}+${{ steps.all.outputs.minecraftVersion }}-${{ env.COMMIT_HASH }}.jar
68+
69+
- name: Get latest version
70+
if: steps.upload-maven.conclusion == 'success' || steps.upload-git.conclusion == 'success'
71+
run: |
72+
COMMIT_MESSAGE=$(git log --pretty=format:'- \`%h\` %s' -1 --reverse)
73+
LATEST_VERSION=$(curl -s "https://maven.lambda-client.org/snapshots/com/lambda/lambda/maven-metadata.xml" | grep -oP '(?<=<latest>).*?(?=</latest>)')
74+
LATEST_MAVEN_METADATA=$(curl -s "https://maven.lambda-client.org/snapshots/com/lambda/lambda/${LATEST_VERSION}/maven-metadata.xml")
75+
TIMESTAMP=$(echo "$LATEST_MAVEN_METADATA" | grep -oP '(?<=<timestamp>).*?(?=</timestamp>)')
76+
BUILD_NUMBER=$(echo "$LATEST_MAVEN_METADATA" | grep -oP '(?<=<buildNumber>).*?(?=</buildNumber>)')
77+
LATEST_SNAPSHOT="lambda-${{ steps.all.outputs.modVersion }}+${{ steps.all.outputs.minecraftVersion }}-${TIMESTAMP}-${BUILD_NUMBER}"
78+
79+
echo "COMMIT_MESSAGE=${COMMIT_MESSAGE}" >> $GITHUB_ENV
80+
echo "LATEST_VERSION=${LATEST_VERSION}" >> $GITHUB_ENV
81+
echo "LATEST_SNAPSHOT=lambda-${{ steps.all.outputs.modVersion }}+${{ steps.all.outputs.minecraftVersion }}-${TIMESTAMP}-${BUILD_NUMBER}" >> $GITHUB_ENV
82+
83+
- name: Send Discord build message
84+
if: steps.upload-maven.conclusion == 'success' || steps.upload-git.conclusion == 'success'
85+
run: |
86+
curl "${{ secrets.WEBHOOK }}" -sS -H "Content-Type:application/json" -X POST -d "{\"content\":null,\"embeds\":[{\"title\":\"Build ${{ github.run_number }}\",\"description\":\"**Branch:** ${{ github.ref_name }}\\n**Changes:**\\n${{ env.COMMIT_MESSAGE }}\",\"url\":\"${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}\",\"color\":1487872,\"fields\":[{\"name\":\"Artifacts:\",\"value\":\"- [${{ env.LATEST_SNAPSHOT }}.jar](https://maven.lambda-client.org/snapshots/com/lambda/lambda/${{ env.LATEST_VERSION }}/${{ env.LATEST_SNAPSHOT }}.jar)\"}],\"footer\":{\"text\":\"$GITHUB_REPOSITORY\"},\"thumbnail\":{\"url\":\"https://raw.githubusercontent.com/lambda-client/assets/refs/heads/main/lambda%20logo%20banner%20transparent.png\"}}],\"username\":\"Github Actions\",\"avatar_url\":\"https://raw.githubusercontent.com/lambda-client/assets/refs/heads/main/lambda.png\"}"
87+

src/main/kotlin/com/lambda/config/Configurable.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import com.lambda.config.settings.complex.Bind
3636
import com.lambda.config.settings.complex.BlockPosSetting
3737
import com.lambda.config.settings.complex.BlockSetting
3838
import com.lambda.config.settings.complex.ColorSetting
39-
import com.lambda.config.settings.complex.KeybindSettingCore
39+
import com.lambda.config.settings.complex.KeybindSetting
4040
import com.lambda.config.settings.complex.Vec3dSetting
4141
import com.lambda.config.settings.numeric.DoubleSetting
4242
import com.lambda.config.settings.numeric.FloatSetting
@@ -229,14 +229,14 @@ abstract class Configurable(
229229
defaultValue: Bind,
230230
description: String = "",
231231
visibility: () -> Boolean = { true },
232-
) = Setting(name, description, KeybindSettingCore(defaultValue), this, visibility).register()
232+
) = Setting(name, description, KeybindSetting(defaultValue), this, visibility).register()
233233

234234
fun setting(
235235
name: String,
236236
defaultValue: KeyCode,
237237
description: String = "",
238238
visibility: () -> Boolean = { true },
239-
) = Setting(name, description, KeybindSettingCore(defaultValue), this, visibility).register()
239+
) = Setting(name, description, KeybindSetting(defaultValue), this, visibility).register()
240240

241241
fun setting(
242242
name: String,

src/main/kotlin/com/lambda/config/settings/complex/KeybindSetting.kt

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ import org.lwjgl.glfw.GLFW.GLFW_MOD_NUM_LOCK
4848
import org.lwjgl.glfw.GLFW.GLFW_MOD_SHIFT
4949
import org.lwjgl.glfw.GLFW.GLFW_MOD_SUPER
5050

51-
class KeybindSettingCore(defaultValue: Bind) : SettingCore<Bind>(
51+
class KeybindSetting(defaultValue: Bind) : SettingCore<Bind>(
5252
defaultValue,
5353
TypeToken.get(Bind::class.java).type
5454
) {
@@ -66,7 +66,7 @@ class KeybindSettingCore(defaultValue: Bind) : SettingCore<Bind>(
6666
if (listening) "Press any key…"
6767
else bind.name
6868

69-
withId("##Bind-${this@KeybindSettingCore.hashCode()}") {
69+
withId("##Bind-${this@KeybindSetting.hashCode()}") {
7070
if (listening) {
7171
withStyleColor(ImGuiCol.Button, 0.20f, 0.50f, 1.00f, 1.00f) {
7272
withStyleColor(ImGuiCol.ButtonHovered, 0.25f, 0.60f, 1.00f, 1.00f) {
@@ -90,9 +90,11 @@ class KeybindSettingCore(defaultValue: Bind) : SettingCore<Bind>(
9090
}
9191

9292
sameLine()
93-
withId("##Unbind-${this@KeybindSettingCore.hashCode()}") {
94-
value = Bind.EMPTY
95-
listening = false
93+
withId("##Unbind-${this@KeybindSetting.hashCode()}") {
94+
smallButton("Unbind") {
95+
value = Bind.EMPTY
96+
listening = false
97+
}
9698
}
9799
onItemHover(ImGuiHoveredFlags.Stationary) {
98100
lambdaTooltip("Clear binding")

src/main/kotlin/com/lambda/module/modules/chat/AntiSpam.kt

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import com.lambda.util.ChatUtils.slurs
3535
import com.lambda.util.ChatUtils.swears
3636
import com.lambda.util.ChatUtils.toAscii
3737
import com.lambda.util.NamedEnum
38-
import com.lambda.util.text.DirectMessage
38+
import com.lambda.util.text.MessageDirection
3939
import com.lambda.util.text.MessageParser
4040
import com.lambda.util.text.MessageType
4141
import net.minecraft.text.Text
@@ -45,9 +45,13 @@ object AntiSpam : Module(
4545
description = "Keeps your chat clean",
4646
tag = ModuleTag.CHAT,
4747
) {
48-
private val ignoreSelf by setting("Ignore Self", true)
49-
private val ignoreFriends by setting("Ignore Friends", true)
5048
private val fancyChats by setting("Replace Fancy Chat", false)
49+
50+
private val filterSelf by setting("Ignore Self", true)
51+
private val filterFriends by setting("Ignore Friends", true)
52+
private val filterSystem by setting("Filter System Messages", false)
53+
private val filterDms by setting("Filter DMs", true)
54+
5155
private val ignoreSystem by setting("Ignore System", false)
5256
private val ignoreDms by setting("Ignore DMs", false)
5357

@@ -75,15 +79,13 @@ object AntiSpam : Module(
7579
}
7680

7781
init {
78-
listen<ChatEvent.Receive> { event ->
82+
listen<ChatEvent.Message> { event ->
7983
var raw = event.message.string
8084
val author = MessageParser.playerName(raw)
8185

8286
if (
83-
ignoreSystem && !MessageType.Both.matches(raw) && !DirectMessage.Both.matches(raw) ||
84-
ignoreDms && DirectMessage.Receive.matches(raw) ||
85-
ignoreFriends && author?.let { FriendManager.isFriend(it) } == true ||
86-
ignoreSelf && MessageType.Self.matches(raw)
87+
ignoreSystem && !MessageType.Both.matches(raw) && !MessageDirection.Both.matches(raw) ||
88+
ignoreDms && MessageDirection.Receive.matches(raw)
8789
) return@listen
8890

8991
val slurMatches = slurs.takeIf { detectSlurs.enabled }.orEmpty().flatMap { it.findAll(raw).toList().reversed() }
@@ -98,7 +100,13 @@ object AntiSpam : Module(
98100
var hasMatches = false
99101

100102
fun doMatch(replace: ReplaceConfig, matches: Sequence<MatchResult>) {
101-
if (cancelled) return
103+
if (
104+
cancelled ||
105+
filterSystem && !MessageType.Both.matches(raw) && !MessageDirection.Both.matches(raw) ||
106+
filterDms && MessageDirection.Receive.matches(raw) ||
107+
filterFriends && author?.let { FriendManager.isFriend(it) } == true ||
108+
filterSelf && MessageType.Self.matches(raw)
109+
) return
102110

103111
when (replace.action) {
104112
ReplaceConfig.ActionStrategy.Hide -> matches.firstOrNull()?.let { event.cancel(); cancelled = true } // If there's one detection, nuke the whole damn thang

0 commit comments

Comments
 (0)