@@ -2,30 +2,59 @@ package com.lambda.client.command.commands
2
2
3
3
import com.lambda.client.command.ClientCommand
4
4
import com.lambda.client.module.modules.render.Search
5
+ import com.lambda.client.util.items.shulkerList
6
+ import com.lambda.client.util.items.signsList
5
7
import com.lambda.client.util.text.MessageSendHelper
6
8
import com.lambda.client.util.text.formatValue
9
+ import net.minecraft.init.Blocks
7
10
8
11
// TODO: Remove once GUI has List
9
12
object SearchCommand : ClientCommand(
10
13
name = " search" ,
11
14
description = " Manage search blocks"
12
15
) {
13
- private val warningBlocks = arrayOf(" minecraft:grass" , " minecraft:end_stone" , " minecraft:lava" , " minecraft:bedrock" , " minecraft:netherrack" , " minecraft:dirt" , " minecraft:water" , " minecraft:stone" )
16
+ private val warningBlocks = hashSetOf(Blocks .GRASS , Blocks .END_STONE , Blocks .LAVA , Blocks .FLOWING_LAVA ,
17
+ Blocks .BEDROCK , Blocks .NETHERRACK , Blocks .DIRT , Blocks .WATER , Blocks .FLOWING_WATER , Blocks .STONE )
14
18
15
19
init {
16
20
literal(" add" , " +" ) {
21
+ literal(" shulker_box" ) {
22
+ execute(" Add all shulker box types to search" ) {
23
+ Search .blockSearchList.editValue { searchList -> shulkerList.map { it.registryName.toString() }.forEach { searchList.add(it) } }
24
+ MessageSendHelper .sendChatMessage(" All shulker boxes have been added to block search" )
25
+ }
26
+ }
27
+ literal(" sign" ) {
28
+ execute(" Add all signs to search" ) {
29
+ Search .blockSearchList.editValue { searchList -> signsList.map { it.registryName.toString() }.forEach { searchList.add(it) } }
30
+ MessageSendHelper .sendChatMessage(" All signs have been added to block search" )
31
+ }
32
+ }
17
33
block(" block" ) { blockArg ->
18
34
literal(" force" ) {
19
35
execute(" Force add a block to search list" ) {
20
36
val blockName = blockArg.value.registryName.toString()
21
37
addBlock(blockName)
22
38
}
23
39
}
24
-
40
+ int(" dimension" ) { dimArg ->
41
+ execute(" Add a block to dimension filter" ) {
42
+ val blockName = blockArg.value.registryName.toString()
43
+ val dim = dimArg.value
44
+ val dims = Search .blockSearchDimensionFilter.value.find { dimFilter -> dimFilter.searchKey == blockName }?.dim
45
+ if (dims != null && ! dims.contains(dim)) {
46
+ dims.add(dim)
47
+ } else {
48
+ Search .blockSearchDimensionFilter.value.add(Search .DimensionFilter (blockName, linkedSetOf(dim)))
49
+ }
50
+ MessageSendHelper .sendChatMessage(" Block search filter added for $blockName in dimension ${dimArg.value} " )
51
+ }
52
+ }
25
53
execute(" Add a block to search list" ) {
54
+ val block = blockArg.value
26
55
val blockName = blockArg.value.registryName.toString()
27
56
28
- if (warningBlocks.contains(blockName )) {
57
+ if (warningBlocks.contains(block )) {
29
58
MessageSendHelper .sendWarningMessage(" Your world contains lots of ${formatValue(blockName)} , " +
30
59
" it might cause extreme lag to add it. " +
31
60
" If you are sure you want to add it run ${formatValue(" $prefixName add $blockName force" )} "
@@ -35,50 +64,148 @@ object SearchCommand : ClientCommand(
35
64
}
36
65
}
37
66
}
67
+ entity(" entity" ) { entityArg ->
68
+ int(" dimension" ) {dimArg ->
69
+ execute(" Add an entity to dimension filter" ) {
70
+ val entityName = entityArg.value
71
+ val dim = dimArg.value
72
+ val dims = Search .entitySearchDimensionFilter.value.find { dimFilter -> dimFilter.searchKey == entityName }?.dim
73
+ if (dims != null && ! dims.contains(dim)) {
74
+ dims.add(dim)
75
+ } else {
76
+ Search .entitySearchDimensionFilter.value.add(Search .DimensionFilter (entityName, linkedSetOf(dim)))
77
+ }
78
+ MessageSendHelper .sendChatMessage(" Entity search filter added for $entityName in dimension ${dimArg.value} " )
79
+ }
80
+ }
81
+
82
+ execute(" Add an entity to search list" ) {
83
+ val entityName = entityArg.value
84
+ if (Search .entitySearchList.contains(entityName)) {
85
+ MessageSendHelper .sendChatMessage(" $entityName is already added to search list" )
86
+ return @execute
87
+ }
88
+ Search .entitySearchList.editValue { it.add(entityName) }
89
+ MessageSendHelper .sendChatMessage(" $entityName has been added to search list" )
90
+ }
91
+ }
38
92
}
39
93
40
94
literal(" remove" , " -" ) {
95
+ literal(" shulker_box" ) {
96
+ execute(" Remove all shulker boxes from search" ) {
97
+ Search .blockSearchList.editValue { searchList -> shulkerList.map { it.registryName.toString() }.forEach { searchList.remove(it) } }
98
+ MessageSendHelper .sendChatMessage(" Removed all shulker boxes from block search" )
99
+ }
100
+ }
101
+ literal(" sign" ) {
102
+ execute(" Remove all signs from search" ) {
103
+ Search .blockSearchList.editValue { searchList -> signsList.map { it.registryName.toString() }.forEach { searchList.remove(it) } }
104
+ MessageSendHelper .sendChatMessage(" Removed all signs from block search" )
105
+ }
106
+ }
41
107
block(" block" ) { blockArg ->
108
+ int(" dimension" ) {dimArg ->
109
+ execute(" Remove a block from dimension filter" ) {
110
+ val blockName = blockArg.value.registryName.toString()
111
+ val dim = dimArg.value
112
+ val dims = Search .blockSearchDimensionFilter.value.find { dimFilter -> dimFilter.searchKey == blockName }?.dim
113
+ if (dims != null ) {
114
+ dims.remove(dim)
115
+ if (dims.isEmpty()) {
116
+ Search .blockSearchDimensionFilter.value.removeIf { it.searchKey == blockName }
117
+ }
118
+ }
119
+ MessageSendHelper .sendChatMessage(" Block search filter removed for $blockName in dimension ${dimArg.value} " )
120
+ }
121
+ }
42
122
execute(" Remove a block from search list" ) {
43
123
val blockName = blockArg.value.registryName.toString()
44
124
45
- if (! Search .searchList.remove (blockName)) {
125
+ if (! Search .blockSearchList.contains (blockName)) {
46
126
MessageSendHelper .sendErrorMessage(" You do not have ${formatValue(blockName)} added to search block list" )
47
127
} else {
128
+ Search .blockSearchList.editValue { it.remove(blockName) }
48
129
MessageSendHelper .sendChatMessage(" Removed ${formatValue(blockName)} from search block list" )
49
130
}
50
131
}
51
132
}
133
+ entity(" entity" ) {entityArg ->
134
+ int(" dimension" ) {dimArg ->
135
+ execute(" Remove an entity from dimension filter" ) {
136
+ val entityName = entityArg.value
137
+ val dim = dimArg.value
138
+ val dims = Search .entitySearchDimensionFilter.value.find { dimFilter -> dimFilter.searchKey == entityName }?.dim
139
+ if (dims != null ) {
140
+ dims.remove(dim)
141
+ if (dims.isEmpty()) {
142
+ Search .entitySearchDimensionFilter.value.removeIf { it.searchKey == entityName }
143
+ }
144
+ }
145
+ MessageSendHelper .sendChatMessage(" Entity search filter removed for $entityName in dimension ${dimArg.value} " )
146
+ }
147
+ }
148
+ execute(" Remove an entity from search list" ) {
149
+ val entityName = entityArg.value
150
+ Search .entitySearchList.editValue { it.remove(entityName) }
151
+ MessageSendHelper .sendChatMessage(" Removed $entityName from search list" )
152
+ }
153
+ }
52
154
}
53
155
54
156
literal(" set" , " =" ) {
55
157
block(" block" ) { blockArg ->
56
158
execute(" Set the search list to one block" ) {
57
159
val blockName = blockArg.value.registryName.toString()
58
160
59
- Search .searchList.clear()
60
- Search .searchList.add(blockName)
161
+ Search .blockSearchList.editValue {
162
+ it.clear()
163
+ it.add(blockName)
164
+ }
61
165
MessageSendHelper .sendChatMessage(" Set the search block list to ${formatValue(blockName)} " )
62
166
}
63
167
}
168
+ entity(" entity" ) { entityArg ->
169
+ execute(" Sets the search list to one entity" ) {
170
+ val entityName = entityArg.value
171
+ Search .entitySearchList.editValue {
172
+ it.clear()
173
+ it.add(entityName)
174
+ }
175
+ MessageSendHelper .sendChatMessage(" Set the entity search list to $entityName " )
176
+ }
177
+ }
64
178
}
65
179
66
180
literal(" reset" , " default" ) {
67
181
execute(" Reset the search list to defaults" ) {
68
- Search .searchList.resetValue()
69
- MessageSendHelper .sendChatMessage(" Reset the search block list to defaults" )
182
+ Search .blockSearchList.resetValue()
183
+ Search .entitySearchList.resetValue()
184
+ Search .blockSearchDimensionFilter.resetValue()
185
+ Search .entitySearchDimensionFilter.resetValue()
186
+ MessageSendHelper .sendChatMessage(" Reset the search list to defaults" )
70
187
}
71
188
}
72
189
73
190
literal(" list" ) {
74
191
execute(" Print search list" ) {
75
- MessageSendHelper .sendChatMessage(Search .searchList.joinToString())
192
+ MessageSendHelper .sendChatMessage(" Blocks: ${Search .blockSearchList.joinToString()} " )
193
+ if (Search .blockSearchDimensionFilter.value.isNotEmpty()) {
194
+ MessageSendHelper .sendChatMessage(" Block dimension filter: ${Search .blockSearchDimensionFilter.value} " )
195
+ }
196
+ MessageSendHelper .sendChatMessage(" Entities ${Search .entitySearchList.joinToString()} " )
197
+ if (Search .entitySearchDimensionFilter.value.isNotEmpty()) {
198
+ MessageSendHelper .sendChatMessage(" Entity dimension filter: ${Search .entitySearchDimensionFilter.value} " )
199
+ }
76
200
}
77
201
}
78
202
79
203
literal(" clear" ) {
80
204
execute(" Set the search list to nothing" ) {
81
- Search .searchList.clear()
205
+ Search .blockSearchList.editValue { it.clear() }
206
+ Search .entitySearchList.editValue { it.clear() }
207
+ Search .blockSearchDimensionFilter.editValue { it.clear() }
208
+ Search .entitySearchDimensionFilter.editValue { it.clear() }
82
209
MessageSendHelper .sendChatMessage(" Cleared the search block list" )
83
210
}
84
211
}
@@ -97,9 +224,10 @@ object SearchCommand : ClientCommand(
97
224
return
98
225
}
99
226
100
- if (! Search .searchList.add (blockName)) {
227
+ if (Search .blockSearchList.contains (blockName)) {
101
228
MessageSendHelper .sendErrorMessage(" ${formatValue(blockName)} is already added to the search block list" )
102
229
} else {
230
+ Search .blockSearchList.editValue { it.add(blockName) }
103
231
MessageSendHelper .sendChatMessage(" ${formatValue(blockName)} has been added to the search block list" )
104
232
}
105
233
}
0 commit comments