Commands are now scanned from the global command
package com.matt.forgehax.mods.services;
-import com.matt.forgehax.util.command.Command;
import com.matt.forgehax.util.command.CommandStub;
import com.matt.forgehax.util.mod.ServiceMod;
import com.matt.forgehax.util.mod.loader.RegisterMod;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.InputEvent;
-import java.util.Collection;
-
-import static com.matt.forgehax.Helper.getModManager;
+import static com.matt.forgehax.Helper.getGlobalCommand;
/**
* Created on 6/14/2017 by fr1kin
@@ -22,18 +19,13 @@ public class BindEventService extends ServiceMod {
@SubscribeEvent
public void onKeyboardEvent(InputEvent.KeyInputEvent event) {
- getModManager().getMods().forEach(mod -> {
- Collection<Command> cmds = mod.getCommandStub().getChildrenDeep();
- cmds.add(mod.getCommandStub());
- cmds.forEach(c -> {
- if(c instanceof CommandStub) {
- CommandStub stub = (CommandStub) c;
- if (stub.getBind() != null) {
+ getGlobalCommand().getChildrenDeep().stream()
+ .filter(command -> command instanceof CommandStub)
+ .map(command -> (CommandStub)command)
+ .filter(stub -> stub.getBind() != null)
+ .forEach(stub -> {
if (stub.getBind().isPressed()) stub.onKeyPressed();
if (stub.getBind().isKeyDown()) stub.onKeyDown();
- }
- }
- });
});
}
}
