mabe fix music

This commit is contained in:
Chayapak 2023-10-01 09:58:08 +07:00
parent f1765a6658
commit fb28000394

View file

@ -20,10 +20,9 @@ import net.kyori.adventure.text.event.ClickEvent;
import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.format.NamedTextColor;
import net.kyori.adventure.text.format.TextColor; import net.kyori.adventure.text.format.TextColor;
import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.URL; import java.net.URI;
import java.nio.file.*; import java.nio.file.*;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@ -103,15 +102,15 @@ public class MusicCommand extends Command {
path = Path.of(root.toString(), _path); path = Path.of(root.toString(), _path);
if (path.toString().contains("http")) player.loadSong(new URL(_path), context.sender); if (path.toString().contains("http")) player.loadSong(new URI(_path).toURL(), context.sender);
else { else {
// among us protection!!!11 // among us protection!!!11
if (!path.normalize().startsWith(root.toString())) throw new CommandException(Component.text("no")); if (!path.normalize().startsWith(root.toString())) throw new CommandException(Component.text("no"));
// ignore my ohio code for autocomplete // ignore my ohio code for autocomplete
final String separator = File.separator; // how do i do this with the new Files? final String separator = FileSystems.getDefault().getSeparator();
if (_path.contains(separator) && !_path.equals("")) { if (_path.contains(separator) && !_path.isEmpty()) {
final String[] pathSplitted = _path.split(separator); final String[] pathSplitted = _path.split(separator);
final List<String> pathSplittedClone = new ArrayList<>(Arrays.stream(pathSplitted.clone()).toList()); final List<String> pathSplittedClone = new ArrayList<>(Arrays.stream(pathSplitted.clone()).toList());