diff options
author | nea <nea@nea.moe> | 2023-09-04 17:44:57 +0200 |
---|---|---|
committer | nea <nea@nea.moe> | 2023-09-04 17:44:57 +0200 |
commit | ee5591684dc6bcdea6c44a62806d537bbb7e0cee (patch) | |
tree | 6efb98480716a953a576d53f019cd91e1ea39e5e /src/main/java/moe | |
parent | 19231489adc73aa7aa41c89ff90eaff6d9dd7bd4 (diff) | |
download | Firmament-ee5591684dc6bcdea6c44a62806d537bbb7e0cee.tar.gz Firmament-ee5591684dc6bcdea6c44a62806d537bbb7e0cee.tar.bz2 Firmament-ee5591684dc6bcdea6c44a62806d537bbb7e0cee.zip |
Add support for case insensitive commands (/fIrM)
Diffstat (limited to 'src/main/java/moe')
-rw-r--r-- | src/main/java/moe/nea/firmament/mixins/MixinCommandNode.java | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/main/java/moe/nea/firmament/mixins/MixinCommandNode.java b/src/main/java/moe/nea/firmament/mixins/MixinCommandNode.java new file mode 100644 index 0000000..aa8e584 --- /dev/null +++ b/src/main/java/moe/nea/firmament/mixins/MixinCommandNode.java @@ -0,0 +1,29 @@ +/* + * SPDX-FileCopyrightText: 2023 Linnea Gräf <nea@nea.moe> + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +package moe.nea.firmament.mixins; + +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +import com.mojang.brigadier.tree.CommandNode; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; + +import java.util.Locale; +import java.util.Map; + +@Mixin(value = CommandNode.class, remap = false) +public class MixinCommandNode<S> { + @WrapOperation(method = "getRelevantNodes", at = @At(value = "INVOKE", target = "Ljava/util/Map;get(Ljava/lang/Object;)Ljava/lang/Object;"), remap = false) + public Object modify(Map map, Object text, Operation<Object> op) { + var original = op.call(map, text); + if (original == null) { + return map.get(((String) text).toLowerCase(Locale.ROOT)); + } + return original; + } + +} |