Skip to content
This repository has been archived by the owner on Aug 8, 2024. It is now read-only.

Feature/path finder #358

Draft
wants to merge 1 commit into
base: development
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
buildscript {
repositories {
jcenter()
maven { url "https://plugins.gradle.org/m2/" }
maven { url = "https://maven.minecraftforge.net" }
}
}

plugins {
id "java"
id "idea"
Expand All @@ -6,6 +14,20 @@ plugins {
id "com.github.johnrengelman.shadow" version "7.1.0"
}

test {
useJUnitPlatform()
}

dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'
}

apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'com.github.johnrengelman.shadow'
apply plugin: 'java'
apply plugin: 'idea'

def versionObj = new Version(major: 1, minor: 11, revision: 0)

version = versionObj.toString()
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/wynntils/modules/map/MapModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.wynntils.modules.map.commands.CommandDetection;
import com.wynntils.modules.map.commands.CommandLocate;
import com.wynntils.modules.map.commands.CommandLootRun;
import com.wynntils.modules.map.commands.CommandPathFinder;
import com.wynntils.modules.map.configs.MapConfig;
import com.wynntils.modules.map.events.ClientEvents;
import com.wynntils.modules.map.instances.MapProfile;
Expand Down Expand Up @@ -67,6 +68,7 @@ public void onEnable() {
registerCommand(new CommandLootRun());
registerCommand(new CommandLocate());
registerCommand(new CommandDetection());
registerCommand(new CommandPathFinder());

registerKeyBinding("New Waypoint", Keyboard.KEY_B, "Wynntils", KeyConflictContext.IN_GAME, true, () -> {
if (Reference.onWorld)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
package com.wynntils.modules.map.commands;

import static net.minecraft.util.text.TextFormatting.GOLD;
import static net.minecraft.util.text.TextFormatting.GREEN;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Locale;

import net.minecraft.command.CommandBase;
import net.minecraft.command.CommandException;
import net.minecraft.command.ICommandSender;
import net.minecraft.command.WrongUsageException;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.TextComponentString;
import net.minecraftforge.client.IClientCommand;

public class CommandPathFinder extends CommandBase implements IClientCommand {

@Override
public boolean allowUsageWithoutPrefix (final ICommandSender sender, final String message) {
return false;
}

@Override
public String getName () {
return "pathfinder";
}

@Override
public List<String> getAliases () {
return Arrays.asList("pf", "path");
}

@Override
public String getUsage (final ICommandSender sender) {
return "pathfinder <to/find/help>";
}

@Override
public int getRequiredPermissionLevel () {
return 0;
}

@Override
public void execute (final MinecraftServer server, final ICommandSender sender, final String[] args)
throws CommandException {
if (args.length == 0) {
throw new WrongUsageException("/" + this.getUsage(sender));
}

switch (args[0].toLowerCase(Locale.ROOT)) {
case "to":
// TODO: command "to"
break;
case "find":
// TODO: command "find"
break;
case "help":
default:
sender.sendMessage(new TextComponentString(String.join("\n",
CommandPathFinder.formatCommandHelp("to", Arrays.asList("town", "island", "dungeon", "raid"),
""),
CommandPathFinder.formatCommandHelp("to <x> <y> <z>", null,
"Get directions to the given coordinates."),
CommandPathFinder.formatCommandHelp("to <x> <z>", null,
"Get directions to the given coordinates - height is filled in by the nearest path."),
CommandPathFinder.formatCommandHelp("find",
Arrays.asList("bank", "emerald", "liquid", "identifier", "blacksmith", "armouring",
"tailoring", "weaponsmithing", "jeweling", "alchemism", "scribing", "cooking"),
"Finds the nearest entity of the given type."))));
break;
}
}

@Override
public List<String> getTabCompletions (final MinecraftServer server, final ICommandSender sender,
final String[] args, final BlockPos targetPos) {
if (args.length == 1) {
return CommandBase.getListOfStringsMatchingLastWord(args, "to", "find", "help");
} else if (args.length == 2 && args[0].equals("find")) {
return CommandBase.getListOfStringsMatchingLastWord(args, "bank", "emerald", "liquid", "identifier",
"blacksmith", "armouring", "tailoring", "weaponsmithing", "jeweling", "alchemism", "scribing",
"cooking");
}
return Collections.emptyList();
}

private static String formatCommandHelp (final String command, final Iterable<String> args, final String help) {
final String argsString = args == null ? "" : String.join(",", args);
return GOLD + command + (argsString.isEmpty() ? " " : (" <" + argsString + "> ")) + GREEN + help;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,14 @@ public static boolean loadFromFile(String lootRunName) {
activePathName = lootRunName;
return true;
}

static void loadManagedLootRun(LootRunPath path, String name) {
if (path != null && name != null) {
activePath = path;
activePathName = name;
updateMapPath();
}
}

public static boolean saveToFile(String lootRunName) {
try {
Expand Down
Loading