-
-
Notifications
You must be signed in to change notification settings - Fork 348
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Reworked debug tracking, now also allows tracking path jobs by type and can add players to a specific pathresult for direct tracking
- Loading branch information
Showing
12 changed files
with
364 additions
and
159 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
src/main/java/com/minecolonies/core/commands/citizencommands/CommandTrackType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package com.minecolonies.core.commands.citizencommands; | ||
|
||
import com.minecolonies.core.commands.commandTypes.IMCCommand; | ||
import com.minecolonies.core.commands.commandTypes.IMCOPCommand; | ||
import com.minecolonies.core.entity.pathfinding.PathfindingUtils; | ||
import com.mojang.brigadier.arguments.StringArgumentType; | ||
import com.mojang.brigadier.builder.LiteralArgumentBuilder; | ||
import com.mojang.brigadier.context.CommandContext; | ||
import net.minecraft.commands.CommandSourceStack; | ||
import net.minecraft.network.chat.Component; | ||
|
||
/** | ||
* Displays information about a chosen citizen in a chosen colony. | ||
*/ | ||
public class CommandTrackType implements IMCOPCommand | ||
{ | ||
/** | ||
* What happens when the command is executed after preConditions are successful. | ||
* | ||
* @param context the context of the command execution | ||
*/ | ||
@Override | ||
public int onExecute(final CommandContext<CommandSourceStack> context) | ||
{ | ||
if (!context.getSource().isPlayer()) | ||
{ | ||
return 1; | ||
} | ||
|
||
final String className = StringArgumentType.getString(context, "pathjobname"); | ||
if (className.equals("clear")) | ||
{ | ||
PathfindingUtils.trackByType.entrySet().removeIf(entry -> entry.getValue().equals(context.getSource().getPlayer().getUUID())); | ||
context.getSource().sendSystemMessage(Component.literal("Removed tracking for player")); | ||
return 1; | ||
} | ||
|
||
PathfindingUtils.trackByType.put(className, context.getSource().getPlayer().getUUID()); | ||
context.getSource().sendSystemMessage(Component.literal("Tracking enabled for pathjobs containing: " + className)); | ||
return 1; | ||
} | ||
|
||
/** | ||
* Name string of the command. | ||
*/ | ||
@Override | ||
public String getName() | ||
{ | ||
return "trackPathType"; | ||
} | ||
|
||
@Override | ||
public LiteralArgumentBuilder<CommandSourceStack> build() | ||
{ | ||
return IMCCommand.newLiteral(getName()) | ||
.then(IMCCommand.newArgument("pathjobname", StringArgumentType.word()).suggests((context, builder) -> { | ||
builder.suggest("clear"); | ||
return builder.buildFuture(); | ||
}).executes(this::checkPreConditionAndExecute)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.