forked from ChomeNS/chomens-bot-java
fix core to make music work + fix other stuff
This commit is contained in:
parent
1f36cd9959
commit
350e6c314e
4 changed files with 12 additions and 6 deletions
|
@ -126,7 +126,7 @@ public class Bot {
|
|||
public void run() {
|
||||
reconnect();
|
||||
}
|
||||
}, 1, reconnectDelay);
|
||||
}, reconnectDelay);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -14,6 +14,8 @@ import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
|||
import com.github.steveice10.opennbt.tag.builtin.StringTag;
|
||||
import com.github.steveice10.opennbt.tag.builtin.Tag;
|
||||
import com.github.steveice10.packetlib.Session;
|
||||
import com.github.steveice10.packetlib.event.session.DisconnectedEvent;
|
||||
import com.github.steveice10.packetlib.event.session.SessionAdapter;
|
||||
import com.nukkitx.math.vector.Vector3i;
|
||||
import lombok.Getter;
|
||||
import me.chayapak1.chomens_bot.Bot;
|
||||
|
@ -38,6 +40,13 @@ public class CorePlugin extends PositionPlugin.PositionListener {
|
|||
this.bot = bot;
|
||||
|
||||
bot.position().addListener(this);
|
||||
|
||||
bot.addListener(new SessionAdapter() {
|
||||
@Override
|
||||
public void disconnected (DisconnectedEvent event) {
|
||||
ready = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void run (String command) {
|
||||
|
|
|
@ -69,7 +69,7 @@ public class MusicPlayerPlugin extends SessionAdapter {
|
|||
|
||||
public void loadSong (URL location) {
|
||||
if (loaderThread != null) {
|
||||
bot.chat().tellraw(Component.translatable("Already loading a song, can't load another", NamedTextColor.RED));
|
||||
bot.chat().tellraw(Component.translatable("Already loading a song", NamedTextColor.RED));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -24,14 +24,12 @@ public class SongLoaderThread extends Thread {
|
|||
public SongLoaderThread (URL location, Bot bot) throws SongLoaderException {
|
||||
this.bot = bot;
|
||||
isUrl = true;
|
||||
System.out.println("its url");
|
||||
songUrl = location;
|
||||
}
|
||||
|
||||
public SongLoaderThread (Path location, Bot bot) throws SongLoaderException {
|
||||
this.bot = bot;
|
||||
isUrl = false;
|
||||
System.out.println("its path");
|
||||
songPath = location.toFile();
|
||||
}
|
||||
|
||||
|
@ -47,7 +45,6 @@ public class SongLoaderThread extends Thread {
|
|||
name = songPath.getName();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println("WHAT THE SUS EXCEPTION YUP ! !! %@%$");
|
||||
e.printStackTrace();
|
||||
exception = new SongLoaderException(Component.text(e.getMessage()), e);
|
||||
return;
|
||||
|
@ -66,7 +63,7 @@ public class SongLoaderThread extends Thread {
|
|||
}
|
||||
|
||||
if (song == null) {
|
||||
exception = new SongLoaderException(Component.translatable("Invalid song format"));
|
||||
exception = new SongLoaderException(Component.translatable("Invalid format"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue