feat: allow path outside bot dir for funnies

This commit is contained in:
Chayapak 2024-11-03 14:05:35 +07:00
parent 0fcc68c7a2
commit 10ca2e4e06
Signed by: ChomeNS
SSH key fingerprint: SHA256:0YoxhdyXsgbc0nfeB2N6FYE60mxMU7DS4uCUMaw2mvA
2 changed files with 2 additions and 5 deletions

View file

@ -58,7 +58,7 @@ public class LocationArgumentType implements ArgumentType<Object> {
public Path parsePath (StringReader reader) throws CommandSyntaxException { public Path parsePath (StringReader reader) throws CommandSyntaxException {
final String pathString = reader.readString(); final String pathString = reader.readString();
final Path path = Path.of(root.toString(), pathString).toAbsolutePath().normalize(); final Path path = Path.of(root.toString(), pathString).toAbsolutePath().normalize();
if (!path.startsWith(root)) throw OOB_FILEPATH.create(); // if (!path.startsWith(root)) throw OOB_FILEPATH.create(); for the funnies
return path; return path;
} }

View file

@ -99,10 +99,7 @@ public class MusicCommand {
final Path path = getPath(context, "location"); final Path path = getPath(context, "location");
if (path != null) songPlayer.loadSong(path); if (path != null) songPlayer.loadSong(path);
else { else songPlayer.loadSong(getUrl(context, "location"));
source.sendOutput(Component.text("no").color(NamedTextColor.RED));
// songPlayer.loadSong(getUrl(context, "location"));
}
return 1; return 1;
} }