Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
CreatureChat
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Jobs
Commits
Open sidebar
Public
CreatureChat
Commits
4073b524
Commit
4073b524
authored
Jul 12, 2024
by
Jonathan Thomas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed whitelist and blacklist commands to only output LivingEntity types in auto complete
parent
b3467522
Pipeline
#12668
passed with stages
in 2 minutes 6 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
8 deletions
+20
-8
CreatureChatCommands.java
...ain/java/com/owlmaddie/commands/CreatureChatCommands.java
+20
-8
No files found.
src/main/java/com/owlmaddie/commands/CreatureChatCommands.java
View file @
4073b524
...
...
@@ -11,7 +11,7 @@ import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
import
net.minecraft.command.CommandSource
;
import
net.minecraft.command.argument.IdentifierArgumentType
;
import
net.minecraft.entity.EntityType
;
import
net.minecraft.entity.
LivingEntity
;
import
net.minecraft.entity.
SpawnGroup
;
import
net.minecraft.registry.Registries
;
import
net.minecraft.server.command.CommandManager
;
import
net.minecraft.server.command.ServerCommandSource
;
...
...
@@ -72,11 +72,27 @@ public class CreatureChatCommands {
));
}
private
static
List
<
Identifier
>
getLivingEntityIds
()
{
List
<
Identifier
>
livingEntityIds
=
Registries
.
ENTITY_TYPE
.
getIds
().
stream
()
.
filter
(
id
->
{
EntityType
<?>
entityType
=
Registries
.
ENTITY_TYPE
.
get
(
id
);
return
entityType
!=
null
&&
entityType
.
getSpawnGroup
()
!=
SpawnGroup
.
MISC
;
})
.
collect
(
Collectors
.
toList
());
return
livingEntityIds
;
}
private
static
List
<
String
>
getLivingEntityTypeNames
()
{
return
getLivingEntityIds
().
stream
()
.
map
(
Identifier:
:
toString
)
.
collect
(
Collectors
.
toList
());
}
private
static
LiteralArgumentBuilder
<
ServerCommandSource
>
registerWhitelistCommand
()
{
return
CommandManager
.
literal
(
"whitelist"
)
.
requires
(
source
->
source
.
hasPermissionLevel
(
4
))
.
then
(
CommandManager
.
argument
(
"entityType"
,
IdentifierArgumentType
.
identifier
())
.
suggests
((
context
,
builder
)
->
CommandSource
.
suggestIdentifiers
(
Registries
.
ENTITY_TYPE
.
get
Ids
(),
builder
))
.
suggests
((
context
,
builder
)
->
CommandSource
.
suggestIdentifiers
(
getLivingEntity
Ids
(),
builder
))
.
then
(
addConfigArgs
((
context
,
useServerConfig
)
->
modifyList
(
context
,
"whitelist"
,
IdentifierArgumentType
.
getIdentifier
(
context
,
"entityType"
).
toString
(),
useServerConfig
)))
.
executes
(
context
->
modifyList
(
context
,
"whitelist"
,
IdentifierArgumentType
.
getIdentifier
(
context
,
"entityType"
).
toString
(),
false
)))
.
then
(
CommandManager
.
literal
(
"all"
)
...
...
@@ -91,7 +107,7 @@ public class CreatureChatCommands {
return
CommandManager
.
literal
(
"blacklist"
)
.
requires
(
source
->
source
.
hasPermissionLevel
(
4
))
.
then
(
CommandManager
.
argument
(
"entityType"
,
IdentifierArgumentType
.
identifier
())
.
suggests
((
context
,
builder
)
->
CommandSource
.
suggestIdentifiers
(
Registries
.
ENTITY_TYPE
.
get
Ids
(),
builder
))
.
suggests
((
context
,
builder
)
->
CommandSource
.
suggestIdentifiers
(
getLivingEntity
Ids
(),
builder
))
.
then
(
addConfigArgs
((
context
,
useServerConfig
)
->
modifyList
(
context
,
"blacklist"
,
IdentifierArgumentType
.
getIdentifier
(
context
,
"entityType"
).
toString
(),
useServerConfig
)))
.
executes
(
context
->
modifyList
(
context
,
"blacklist"
,
IdentifierArgumentType
.
getIdentifier
(
context
,
"entityType"
).
toString
(),
false
)))
.
then
(
CommandManager
.
literal
(
"all"
)
...
...
@@ -175,11 +191,7 @@ public class CreatureChatCommands {
ServerCommandSource
source
=
context
.
getSource
();
ConfigurationHandler
configHandler
=
new
ConfigurationHandler
(
source
.
getServer
());
ConfigurationHandler
.
Config
config
=
configHandler
.
loadConfig
();
List
<
String
>
entityTypes
=
Registries
.
ENTITY_TYPE
.
stream
()
.
filter
(
entityType
->
LivingEntity
.
class
.
isAssignableFrom
(
entityType
.
getBaseClass
()))
.
map
(
EntityType:
:
getId
)
.
map
(
Identifier:
:
toString
)
.
collect
(
Collectors
.
toList
());
List
<
String
>
entityTypes
=
getLivingEntityTypeNames
();
try
{
if
(
"all"
.
equals
(
action
))
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment