refactor: improve the server has command function in ServerUtilities

This commit is contained in:
Chayapak Supasakul 2025-03-03 16:04:38 +07:00
parent 3a5e4490ee
commit 11d89993b2
Signed by: ChomeNS
SSH key fingerprint: SHA256:0YoxhdyXsgbc0nfeB2N6FYE60mxMU7DS4uCUMaw2mvA

View file

@ -1,7 +1,5 @@
package land.chipmunk.chipmunkmod.util;
import com.mojang.brigadier.tree.CommandNode;
import com.mojang.brigadier.tree.LiteralCommandNode;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.ClientPlayNetworkHandler;
@ -12,12 +10,6 @@ public class ServerUtilities {
if (networkHandler == null) return false;
for (CommandNode node : networkHandler.getCommandDispatcher().getRoot().getChildren()) {
if (!(node instanceof LiteralCommandNode literal)) continue;
if (literal.getLiteral().equals(name)) return true;
}
return false;
return networkHandler.getCommandDispatcher().getRoot().getChild(name) != null;
}
}