Merge pull request #1216 from FTC55/master
Fixed a rather obnoxious bug that would require a full restart of the client.
This commit is contained in:
commit
a0014fda12
@ -1,61 +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.command.defaults;
|
|
||||||
|
|
||||||
import baritone.api.IBaritone;
|
|
||||||
import baritone.api.command.Command;
|
|
||||||
import baritone.api.command.exception.CommandException;
|
|
||||||
import baritone.api.command.argument.IArgConsumer;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
public class CancelCommand extends Command {
|
|
||||||
|
|
||||||
public CancelCommand(IBaritone baritone) {
|
|
||||||
super(baritone, "cancel", "stop");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void execute(String label, IArgConsumer args) throws CommandException {
|
|
||||||
args.requireMax(0);
|
|
||||||
baritone.getPathingBehavior().cancelEverything();
|
|
||||||
logDirect("ok canceled");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Stream<String> tabComplete(String label, IArgConsumer args) {
|
|
||||||
return Stream.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getShortDesc() {
|
|
||||||
return "Cancel what Baritone is currently doing";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<String> getLongDesc() {
|
|
||||||
return Arrays.asList(
|
|
||||||
"The cancel command tells Baritone to stop whatever it's currently doing.",
|
|
||||||
"",
|
|
||||||
"Usage:",
|
|
||||||
"> cancel"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -24,52 +24,53 @@ import java.util.*;
|
|||||||
|
|
||||||
public final class DefaultCommands {
|
public final class DefaultCommands {
|
||||||
|
|
||||||
private DefaultCommands() {}
|
private DefaultCommands() {
|
||||||
|
}
|
||||||
|
|
||||||
public static List<ICommand> createAll(IBaritone baritone) {
|
public static List<ICommand> createAll(IBaritone baritone) {
|
||||||
Objects.requireNonNull(baritone);
|
Objects.requireNonNull(baritone);
|
||||||
List<ICommand> commands = new ArrayList<>(Arrays.asList(
|
List<ICommand> commands = new ArrayList<>(Arrays.asList(
|
||||||
new HelpCommand(baritone),
|
new HelpCommand(baritone),
|
||||||
new SetCommand(baritone),
|
new SetCommand(baritone),
|
||||||
new CommandAlias(baritone, Arrays.asList("modified", "mod", "baritone", "modifiedsettings"), "List modified settings", "set modified"),
|
new CommandAlias(baritone, Arrays.asList("modified", "mod", "baritone", "modifiedsettings"), "List modified settings", "set modified"),
|
||||||
new CommandAlias(baritone, "reset", "Reset all settings or just one", "set reset"),
|
new CommandAlias(baritone, "reset", "Reset all settings or just one", "set reset"),
|
||||||
new GoalCommand(baritone),
|
new GoalCommand(baritone),
|
||||||
new GotoCommand(baritone),
|
new GotoCommand(baritone),
|
||||||
new PathCommand(baritone),
|
new PathCommand(baritone),
|
||||||
new ProcCommand(baritone),
|
new ProcCommand(baritone),
|
||||||
new VersionCommand(baritone),
|
new VersionCommand(baritone),
|
||||||
new RepackCommand(baritone),
|
new RepackCommand(baritone),
|
||||||
new BuildCommand(baritone),
|
new BuildCommand(baritone),
|
||||||
new SchematicaCommand(baritone),
|
new SchematicaCommand(baritone),
|
||||||
new ComeCommand(baritone),
|
new ComeCommand(baritone),
|
||||||
new AxisCommand(baritone),
|
new AxisCommand(baritone),
|
||||||
new CancelCommand(baritone),
|
new ForceCancelCommand(baritone),
|
||||||
new ForceCancelCommand(baritone),
|
new GcCommand(baritone),
|
||||||
new GcCommand(baritone),
|
new InvertCommand(baritone),
|
||||||
new InvertCommand(baritone),
|
new TunnelCommand(baritone),
|
||||||
new TunnelCommand(baritone),
|
new RenderCommand(baritone),
|
||||||
new RenderCommand(baritone),
|
new FarmCommand(baritone),
|
||||||
new FarmCommand(baritone),
|
new ChestsCommand(baritone),
|
||||||
new ChestsCommand(baritone),
|
new FollowCommand(baritone),
|
||||||
new FollowCommand(baritone),
|
new ExploreFilterCommand(baritone),
|
||||||
new ExploreFilterCommand(baritone),
|
new ReloadAllCommand(baritone),
|
||||||
new ReloadAllCommand(baritone),
|
new SaveAllCommand(baritone),
|
||||||
new SaveAllCommand(baritone),
|
new ExploreCommand(baritone),
|
||||||
new ExploreCommand(baritone),
|
new BlacklistCommand(baritone),
|
||||||
new BlacklistCommand(baritone),
|
new FindCommand(baritone),
|
||||||
new FindCommand(baritone),
|
new MineCommand(baritone),
|
||||||
new MineCommand(baritone),
|
new ClickCommand(baritone),
|
||||||
new ClickCommand(baritone),
|
new ThisWayCommand(baritone),
|
||||||
new ThisWayCommand(baritone),
|
new WaypointsCommand(baritone),
|
||||||
new WaypointsCommand(baritone),
|
new CommandAlias(baritone, "sethome", "Sets your home waypoint", "waypoints save home"),
|
||||||
new CommandAlias(baritone, "sethome", "Sets your home waypoint", "waypoints save home"),
|
new CommandAlias(baritone, "home", "Set goal to your home waypoint", "waypoints goal home"),
|
||||||
new CommandAlias(baritone, "home", "Set goal to your home waypoint", "waypoints goal home"),
|
new SelCommand(baritone)
|
||||||
new SelCommand(baritone)
|
|
||||||
));
|
));
|
||||||
PauseResumeCommands prc = new PauseResumeCommands(baritone);
|
ExecutionControlCommands prc = new ExecutionControlCommands(baritone);
|
||||||
commands.add(prc.pauseCommand);
|
commands.add(prc.pauseCommand);
|
||||||
commands.add(prc.resumeCommand);
|
commands.add(prc.resumeCommand);
|
||||||
commands.add(prc.pausedCommand);
|
commands.add(prc.pausedCommand);
|
||||||
|
commands.add(prc.cancelCommand);
|
||||||
return Collections.unmodifiableList(commands);
|
return Collections.unmodifiableList(commands);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,13 +18,13 @@
|
|||||||
package baritone.command.defaults;
|
package baritone.command.defaults;
|
||||||
|
|
||||||
import baritone.api.IBaritone;
|
import baritone.api.IBaritone;
|
||||||
|
import baritone.api.command.Command;
|
||||||
|
import baritone.api.command.argument.IArgConsumer;
|
||||||
|
import baritone.api.command.exception.CommandException;
|
||||||
|
import baritone.api.command.exception.CommandInvalidStateException;
|
||||||
import baritone.api.process.IBaritoneProcess;
|
import baritone.api.process.IBaritoneProcess;
|
||||||
import baritone.api.process.PathingCommand;
|
import baritone.api.process.PathingCommand;
|
||||||
import baritone.api.process.PathingCommandType;
|
import baritone.api.process.PathingCommandType;
|
||||||
import baritone.api.command.Command;
|
|
||||||
import baritone.api.command.exception.CommandException;
|
|
||||||
import baritone.api.command.exception.CommandInvalidStateException;
|
|
||||||
import baritone.api.command.argument.IArgConsumer;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -37,13 +37,14 @@ import java.util.stream.Stream;
|
|||||||
* TO USE THIS to pause and resume Baritone. Make your own process that returns {@link PathingCommandType#REQUEST_PAUSE
|
* TO USE THIS to pause and resume Baritone. Make your own process that returns {@link PathingCommandType#REQUEST_PAUSE
|
||||||
* REQUEST_PAUSE} as needed.
|
* REQUEST_PAUSE} as needed.
|
||||||
*/
|
*/
|
||||||
public class PauseResumeCommands {
|
public class ExecutionControlCommands {
|
||||||
|
|
||||||
Command pauseCommand;
|
Command pauseCommand;
|
||||||
Command resumeCommand;
|
Command resumeCommand;
|
||||||
Command pausedCommand;
|
Command pausedCommand;
|
||||||
|
Command cancelCommand;
|
||||||
|
|
||||||
public PauseResumeCommands(IBaritone baritone) {
|
public ExecutionControlCommands(IBaritone baritone) {
|
||||||
// array for mutability, non-field so reflection can't touch it
|
// array for mutability, non-field so reflection can't touch it
|
||||||
final boolean[] paused = {false};
|
final boolean[] paused = {false};
|
||||||
baritone.getPathingControlManager().registerProcess(
|
baritone.getPathingControlManager().registerProcess(
|
||||||
@ -64,7 +65,8 @@ public class PauseResumeCommands {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLostControl() {}
|
public void onLostControl() {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double priority() {
|
public double priority() {
|
||||||
@ -169,5 +171,36 @@ public class PauseResumeCommands {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
cancelCommand = new Command(baritone, "cancel", "stop") {
|
||||||
|
@Override
|
||||||
|
public void execute(String label, IArgConsumer args) throws CommandException {
|
||||||
|
args.requireMax(0);
|
||||||
|
if (paused[0]) {
|
||||||
|
paused[0] = false;
|
||||||
|
}
|
||||||
|
baritone.getPathingBehavior().cancelEverything();
|
||||||
|
logDirect("ok canceled");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Stream<String> tabComplete(String label, IArgConsumer args) {
|
||||||
|
return Stream.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getShortDesc() {
|
||||||
|
return "Cancel what Baritone is currently doing";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getLongDesc() {
|
||||||
|
return Arrays.asList(
|
||||||
|
"The cancel command tells Baritone to stop whatever it's currently doing.",
|
||||||
|
"",
|
||||||
|
"Usage:",
|
||||||
|
"> cancel"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user