move default commands to main module

This commit is contained in:
Logan Darklock
2019-09-04 11:17:36 -07:00
parent daa0d0c859
commit 69e3481a32
40 changed files with 42 additions and 93 deletions
@@ -29,7 +29,7 @@ public class ReplaceSchematic extends MaskSchematic {
public ReplaceSchematic(IBaritone baritone, ISchematic schematic, BlockOptionalMetaLookup filter) { public ReplaceSchematic(IBaritone baritone, ISchematic schematic, BlockOptionalMetaLookup filter) {
super(baritone, schematic); super(baritone, schematic);
this.filter = filter; this.filter = filter;
this.cache = new boolean[lengthZ()][heightY()][widthX()]; this.cache = new boolean[widthX()][heightY()][lengthZ()];
} }
protected boolean partOfMask(int x, int y, int z, IBlockState currentState) { protected boolean partOfMask(int x, int y, int z, IBlockState currentState) {
@@ -1,49 +0,0 @@
/*
* This file is part of Baritone.
*
* Baritone is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Baritone is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/
package baritone.api.utils.command.defaults;
import baritone.api.Settings;
import baritone.api.utils.command.Command;
import baritone.api.utils.command.helpers.arguments.ArgConsumer;
import java.util.Collections;
import java.util.List;
import java.util.stream.Stream;
public class ExcCommand extends Command {
public ExcCommand() {
super("exc", "Throw an unhandled exception");
}
@Override
protected void executed(String label, ArgConsumer args, Settings settings) {
args.requireMax(0);
throw new RuntimeException("HI THERE");
}
@Override
protected Stream<String> tabCompleted(String label, ArgConsumer args, Settings settings) {
return Stream.empty();
}
@Override
public List<String> getLongDesc() {
return Collections.emptyList();
}
}
@@ -19,7 +19,6 @@ package baritone.api.utils.command.manager;
import baritone.api.utils.command.Command; import baritone.api.utils.command.Command;
import baritone.api.utils.command.argument.CommandArgument; import baritone.api.utils.command.argument.CommandArgument;
import baritone.api.utils.command.defaults.DefaultCommands;
import baritone.api.utils.command.execution.CommandExecution; import baritone.api.utils.command.execution.CommandExecution;
import baritone.api.utils.command.helpers.tabcomplete.TabCompleteHelper; import baritone.api.utils.command.helpers.tabcomplete.TabCompleteHelper;
import baritone.api.utils.command.registry.Registry; import baritone.api.utils.command.registry.Registry;
@@ -35,10 +34,6 @@ import static java.util.Objects.nonNull;
public class CommandManager { public class CommandManager {
public static final Registry<Command> REGISTRY = new Registry<>(); public static final Registry<Command> REGISTRY = new Registry<>();
static {
DefaultCommands.commands.forEach(REGISTRY::register);
}
/** /**
* @param name The command name to search for. * @param name The command name to search for.
* @return The command, if found. * @return The command, if found.
+4
View File
@@ -24,12 +24,14 @@ import baritone.api.event.listener.IEventBus;
import baritone.api.utils.command.BaritoneChatControl; import baritone.api.utils.command.BaritoneChatControl;
import baritone.api.utils.Helper; import baritone.api.utils.Helper;
import baritone.api.utils.IPlayerContext; import baritone.api.utils.IPlayerContext;
import baritone.api.utils.command.manager.CommandManager;
import baritone.behavior.*; import baritone.behavior.*;
import baritone.cache.WorldProvider; import baritone.cache.WorldProvider;
import baritone.event.GameEventHandler; import baritone.event.GameEventHandler;
import baritone.process.*; import baritone.process.*;
import baritone.selection.SelectionManager; import baritone.selection.SelectionManager;
import baritone.utils.*; import baritone.utils.*;
import baritone.utils.command.defaults.DefaultCommands;
import baritone.utils.player.PrimaryPlayerContext; import baritone.utils.player.PrimaryPlayerContext;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
@@ -111,6 +113,8 @@ public class Baritone implements IBaritone {
memoryBehavior = new MemoryBehavior(this); memoryBehavior = new MemoryBehavior(this);
inventoryBehavior = new InventoryBehavior(this); inventoryBehavior = new InventoryBehavior(this);
inputOverrideHandler = new InputOverrideHandler(this); inputOverrideHandler = new InputOverrideHandler(this);
DefaultCommands.commands.forEach(CommandManager.REGISTRY::register);
new BaritoneChatControl(this); new BaritoneChatControl(this);
} }
@@ -15,7 +15,7 @@
* along with Baritone. If not, see <https://www.gnu.org/licenses/>. * along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/ */
package baritone.api.utils.command.defaults; package baritone.utils.command.defaults;
import baritone.api.Settings; import baritone.api.Settings;
import baritone.api.pathing.goals.Goal; import baritone.api.pathing.goals.Goal;
@@ -15,7 +15,7 @@
* along with Baritone. If not, see <https://www.gnu.org/licenses/>. * along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/ */
package baritone.api.utils.command.defaults; package baritone.utils.command.defaults;
import baritone.api.Settings; import baritone.api.Settings;
import baritone.api.process.IGetToBlockProcess; import baritone.api.process.IGetToBlockProcess;
@@ -15,7 +15,7 @@
* along with Baritone. If not, see <https://www.gnu.org/licenses/>. * along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/ */
package baritone.api.utils.command.defaults; package baritone.utils.command.defaults;
import baritone.api.Settings; import baritone.api.Settings;
import baritone.api.utils.BetterBlockPos; import baritone.api.utils.BetterBlockPos;
@@ -15,7 +15,7 @@
* along with Baritone. If not, see <https://www.gnu.org/licenses/>. * along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/ */
package baritone.api.utils.command.defaults; package baritone.utils.command.defaults;
import baritone.api.Settings; import baritone.api.Settings;
import baritone.api.utils.command.Command; import baritone.api.utils.command.Command;
@@ -15,7 +15,7 @@
* along with Baritone. If not, see <https://www.gnu.org/licenses/>. * along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/ */
package baritone.api.utils.command.defaults; package baritone.utils.command.defaults;
import baritone.api.Settings; import baritone.api.Settings;
import baritone.api.cache.IRememberedInventory; import baritone.api.cache.IRememberedInventory;
@@ -15,7 +15,7 @@
* along with Baritone. If not, see <https://www.gnu.org/licenses/>. * along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/ */
package baritone.api.utils.command.defaults; package baritone.utils.command.defaults;
import baritone.api.Settings; import baritone.api.Settings;
import baritone.api.pathing.goals.Goal; import baritone.api.pathing.goals.Goal;
@@ -15,7 +15,7 @@
* along with Baritone. If not, see <https://www.gnu.org/licenses/>. * along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/ */
package baritone.api.utils.command.defaults; package baritone.utils.command.defaults;
import baritone.api.Settings; import baritone.api.Settings;
import baritone.api.utils.command.Command; import baritone.api.utils.command.Command;
@@ -15,7 +15,7 @@
* along with Baritone. If not, see <https://www.gnu.org/licenses/>. * along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/ */
package baritone.api.utils.command.defaults; package baritone.utils.command.defaults;
import baritone.api.Settings; import baritone.api.Settings;
import baritone.api.pathing.goals.GoalBlock; import baritone.api.pathing.goals.GoalBlock;
@@ -15,7 +15,7 @@
* along with Baritone. If not, see <https://www.gnu.org/licenses/>. * along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/ */
package baritone.api.utils.command.defaults; package baritone.utils.command.defaults;
import baritone.api.Settings; import baritone.api.Settings;
import baritone.api.utils.command.Command; import baritone.api.utils.command.Command;
@@ -15,9 +15,10 @@
* along with Baritone. If not, see <https://www.gnu.org/licenses/>. * along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/ */
package baritone.api.utils.command.defaults; package baritone.utils.command.defaults;
import baritone.api.utils.command.Command; import baritone.api.utils.command.Command;
import baritone.api.utils.command.manager.CommandManager;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
@@ -30,7 +31,6 @@ public class DefaultCommands {
new SetCommand(), new SetCommand(),
new CommandAlias(asList("modified", "mod", "baritone", "modifiedsettings"), "List modified settings", "set modified"), new CommandAlias(asList("modified", "mod", "baritone", "modifiedsettings"), "List modified settings", "set modified"),
new CommandAlias("reset", "Reset all settings or just one", "set reset"), new CommandAlias("reset", "Reset all settings or just one", "set reset"),
new ExcCommand(), // TODO: remove this debug command... eventually
new GoalCommand(), new GoalCommand(),
new PathCommand(), new PathCommand(),
new ProcCommand(), new ProcCommand(),
@@ -15,10 +15,9 @@
* along with Baritone. If not, see <https://www.gnu.org/licenses/>. * along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/ */
package baritone.api.utils.command.defaults; package baritone.utils.command.defaults;
import baritone.api.Settings; import baritone.api.Settings;
import baritone.api.utils.Helper;
import baritone.api.utils.command.Command; import baritone.api.utils.command.Command;
import baritone.api.utils.command.helpers.arguments.ArgConsumer; import baritone.api.utils.command.helpers.arguments.ArgConsumer;
@@ -15,7 +15,7 @@
* along with Baritone. If not, see <https://www.gnu.org/licenses/>. * along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/ */
package baritone.api.utils.command.defaults; package baritone.utils.command.defaults;
import baritone.api.Settings; import baritone.api.Settings;
import baritone.api.pathing.goals.GoalXZ; import baritone.api.pathing.goals.GoalXZ;
@@ -15,7 +15,7 @@
* along with Baritone. If not, see <https://www.gnu.org/licenses/>. * along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/ */
package baritone.api.utils.command.defaults; package baritone.utils.command.defaults;
import baritone.api.Settings; import baritone.api.Settings;
import baritone.api.utils.command.Command; import baritone.api.utils.command.Command;
@@ -15,7 +15,7 @@
* along with Baritone. If not, see <https://www.gnu.org/licenses/>. * along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/ */
package baritone.api.utils.command.defaults; package baritone.utils.command.defaults;
import baritone.api.Settings; import baritone.api.Settings;
import baritone.api.utils.command.Command; import baritone.api.utils.command.Command;
@@ -15,7 +15,7 @@
* along with Baritone. If not, see <https://www.gnu.org/licenses/>. * along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/ */
package baritone.api.utils.command.defaults; package baritone.utils.command.defaults;
import baritone.api.Settings; import baritone.api.Settings;
import baritone.api.utils.BetterBlockPos; import baritone.api.utils.BetterBlockPos;
@@ -15,7 +15,7 @@
* along with Baritone. If not, see <https://www.gnu.org/licenses/>. * along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/ */
package baritone.api.utils.command.defaults; package baritone.utils.command.defaults;
import baritone.api.Settings; import baritone.api.Settings;
import baritone.api.utils.command.Command; import baritone.api.utils.command.Command;
@@ -15,7 +15,7 @@
* along with Baritone. If not, see <https://www.gnu.org/licenses/>. * along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/ */
package baritone.api.utils.command.defaults; package baritone.utils.command.defaults;
import baritone.api.Settings; import baritone.api.Settings;
import baritone.api.behavior.IPathingBehavior; import baritone.api.behavior.IPathingBehavior;
@@ -15,7 +15,7 @@
* along with Baritone. If not, see <https://www.gnu.org/licenses/>. * along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/ */
package baritone.api.utils.command.defaults; package baritone.utils.command.defaults;
import baritone.api.Settings; import baritone.api.Settings;
import baritone.api.utils.command.Command; import baritone.api.utils.command.Command;
@@ -15,7 +15,7 @@
* along with Baritone. If not, see <https://www.gnu.org/licenses/>. * along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/ */
package baritone.api.utils.command.defaults; package baritone.utils.command.defaults;
import baritone.api.Settings; import baritone.api.Settings;
import baritone.api.pathing.goals.Goal; import baritone.api.pathing.goals.Goal;
@@ -15,7 +15,7 @@
* along with Baritone. If not, see <https://www.gnu.org/licenses/>. * along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/ */
package baritone.api.utils.command.defaults; package baritone.utils.command.defaults;
import baritone.api.Settings; import baritone.api.Settings;
import baritone.api.utils.command.Command; import baritone.api.utils.command.Command;
@@ -15,7 +15,7 @@
* along with Baritone. If not, see <https://www.gnu.org/licenses/>. * along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/ */
package baritone.api.utils.command.defaults; package baritone.utils.command.defaults;
import baritone.api.Settings; import baritone.api.Settings;
import baritone.api.pathing.goals.Goal; import baritone.api.pathing.goals.Goal;
@@ -15,7 +15,7 @@
* along with Baritone. If not, see <https://www.gnu.org/licenses/>. * along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/ */
package baritone.api.utils.command.defaults; package baritone.utils.command.defaults;
import baritone.api.Settings; import baritone.api.Settings;
import baritone.api.utils.BlockOptionalMeta; import baritone.api.utils.BlockOptionalMeta;
@@ -15,7 +15,7 @@
* along with Baritone. If not, see <https://www.gnu.org/licenses/>. * along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/ */
package baritone.api.utils.command.defaults; package baritone.utils.command.defaults;
import baritone.api.Settings; import baritone.api.Settings;
import baritone.api.pathing.goals.Goal; import baritone.api.pathing.goals.Goal;
@@ -15,7 +15,7 @@
* along with Baritone. If not, see <https://www.gnu.org/licenses/>. * along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/ */
package baritone.api.utils.command.defaults; package baritone.utils.command.defaults;
import baritone.api.BaritoneAPI; import baritone.api.BaritoneAPI;
import baritone.api.Settings; import baritone.api.Settings;
@@ -15,7 +15,7 @@
* along with Baritone. If not, see <https://www.gnu.org/licenses/>. * along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/ */
package baritone.api.utils.command.defaults; package baritone.utils.command.defaults;
import baritone.api.Settings; import baritone.api.Settings;
import baritone.api.pathing.calc.IPathingControlManager; import baritone.api.pathing.calc.IPathingControlManager;
@@ -15,7 +15,7 @@
* along with Baritone. If not, see <https://www.gnu.org/licenses/>. * along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/ */
package baritone.api.utils.command.defaults; package baritone.utils.command.defaults;
import baritone.api.Settings; import baritone.api.Settings;
import baritone.api.utils.command.Command; import baritone.api.utils.command.Command;
@@ -15,7 +15,7 @@
* along with Baritone. If not, see <https://www.gnu.org/licenses/>. * along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/ */
package baritone.api.utils.command.defaults; package baritone.utils.command.defaults;
import baritone.api.Settings; import baritone.api.Settings;
import baritone.api.utils.BetterBlockPos; import baritone.api.utils.BetterBlockPos;
@@ -15,7 +15,7 @@
* along with Baritone. If not, see <https://www.gnu.org/licenses/>. * along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/ */
package baritone.api.utils.command.defaults; package baritone.utils.command.defaults;
import baritone.api.Settings; import baritone.api.Settings;
import baritone.api.cache.ICachedWorld; import baritone.api.cache.ICachedWorld;
@@ -15,7 +15,7 @@
* along with Baritone. If not, see <https://www.gnu.org/licenses/>. * along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/ */
package baritone.api.utils.command.defaults; package baritone.utils.command.defaults;
import baritone.api.Settings; import baritone.api.Settings;
import baritone.api.utils.command.Command; import baritone.api.utils.command.Command;
@@ -15,7 +15,7 @@
* along with Baritone. If not, see <https://www.gnu.org/licenses/>. * along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/ */
package baritone.api.utils.command.defaults; package baritone.utils.command.defaults;
import baritone.api.Settings; import baritone.api.Settings;
import baritone.api.utils.command.Command; import baritone.api.utils.command.Command;
@@ -15,7 +15,7 @@
* along with Baritone. If not, see <https://www.gnu.org/licenses/>. * along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/ */
package baritone.api.utils.command.defaults; package baritone.utils.command.defaults;
import baritone.api.Settings; import baritone.api.Settings;
import baritone.api.event.events.RenderEvent; import baritone.api.event.events.RenderEvent;
@@ -15,7 +15,7 @@
* along with Baritone. If not, see <https://www.gnu.org/licenses/>. * along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/ */
package baritone.api.utils.command.defaults; package baritone.utils.command.defaults;
import baritone.api.Settings; import baritone.api.Settings;
import baritone.api.utils.SettingsUtil; import baritone.api.utils.SettingsUtil;
@@ -15,7 +15,7 @@
* along with Baritone. If not, see <https://www.gnu.org/licenses/>. * along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/ */
package baritone.api.utils.command.defaults; package baritone.utils.command.defaults;
import baritone.api.Settings; import baritone.api.Settings;
import baritone.api.pathing.goals.GoalXZ; import baritone.api.pathing.goals.GoalXZ;
@@ -15,7 +15,7 @@
* along with Baritone. If not, see <https://www.gnu.org/licenses/>. * along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/ */
package baritone.api.utils.command.defaults; package baritone.utils.command.defaults;
import baritone.api.Settings; import baritone.api.Settings;
import baritone.api.pathing.goals.Goal; import baritone.api.pathing.goals.Goal;
@@ -15,7 +15,7 @@
* along with Baritone. If not, see <https://www.gnu.org/licenses/>. * along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/ */
package baritone.api.utils.command.defaults; package baritone.utils.command.defaults;
import baritone.api.Settings; import baritone.api.Settings;
import baritone.api.utils.command.Command; import baritone.api.utils.command.Command;
@@ -15,7 +15,7 @@
* along with Baritone. If not, see <https://www.gnu.org/licenses/>. * along with Baritone. If not, see <https://www.gnu.org/licenses/>.
*/ */
package baritone.api.utils.command.defaults; package baritone.utils.command.defaults;
import baritone.api.Settings; import baritone.api.Settings;
import baritone.api.cache.IWaypoint; import baritone.api.cache.IWaypoint;