almost there...

This commit is contained in:
ayunami2000 2022-04-21 11:41:14 -04:00
parent c003a83b17
commit e2e0cc12a6
2 changed files with 25 additions and 12 deletions

View File

@ -16,6 +16,7 @@ public class Main extends JavaPlugin implements CommandExecutor, Listener {
private VideoMapPacketCodecBukkit videoMapCodec = null; private VideoMapPacketCodecBukkit videoMapCodec = null;
private Vector audioLoc = new Vector(0, 100, 0); private Vector audioLoc = new Vector(0, 100, 0);
private String url = ""; private String url = "";
private boolean urlChanged = true;
@Override @Override
public void onEnable(){ public void onEnable(){
@ -31,23 +32,19 @@ public class Main extends JavaPlugin implements CommandExecutor, Listener {
@Override @Override
public void onDisable(){ public void onDisable(){
videoMapCodec.disableVideoBukkit(); sendToAllPlayers(videoMapCodec.disableVideoBukkit());
} }
private void syncToPlayer(Player player) { private void syncToPlayer(Player player) {
VideoMapPacketCodecBukkit.nativeSendPacketToPlayer(player, videoMapCodec.syncPlaybackWithPlayersBukkit()); videoMapCodec.syncPlaybackWithPlayersBukkit().send(player);
} }
private void syncToAllPlayers() { private void syncToAllPlayers() {
for (Player player : this.getServer().getOnlinePlayers()) { videoMapCodec.syncPlaybackWithPlayersBukkit().send(this.getServer().getOnlinePlayers());
syncToPlayer(player);
}
} }
private void sendToAllPlayers(VideoMapPacketCodecBukkit.VideoMapPacket p) { private void sendToAllPlayers(VideoMapPacketCodecBukkit.VideoMapPacket p) {
for (Player player : this.getServer().getOnlinePlayers()) { p.send(this.getServer().getOnlinePlayers());
VideoMapPacketCodecBukkit.nativeSendPacketToPlayer(player, p);
}
} }
private void setSize(int width, int height) { private void setSize(int width, int height) {
@ -82,9 +79,15 @@ public class Main extends JavaPlugin implements CommandExecutor, Listener {
this.getConfig().set("url", args[1]); this.getConfig().set("url", args[1]);
this.saveConfig(); this.saveConfig();
url = args[1]; url = args[1];
sendToAllPlayers(videoMapCodec.beginPlaybackBukkit(url, true, Integer.MAX_VALUE / 1000.0f)); urlChanged = true;
sender.sendMessage("seturl"); sender.sendMessage("seturl");
break; break;
case "a":
case "aud":
case "audio":
case "audloc":
case "audioloc":
case "audiolocation":
case "l": case "l":
case "loc": case "loc":
case "location": case "location":
@ -109,15 +112,25 @@ public class Main extends JavaPlugin implements CommandExecutor, Listener {
audioLoc.setY(y); audioLoc.setY(y);
audioLoc.setZ(z); audioLoc.setZ(z);
} }
syncToAllPlayers(); this.getConfig().set("audio.x", audioLoc.getX());
this.getConfig().set("audio.y", audioLoc.getY());
this.getConfig().set("audio.z", audioLoc.getZ());
this.saveConfig();
float ct = videoMapCodec.getPlaybackTime();
sendToAllPlayers(videoMapCodec.moveAudioSourceBukkit(audioLoc.getX(), audioLoc.getY(), audioLoc.getZ(), 0.5f));
sendToAllPlayers(videoMapCodec.setPlaybackTimeBukkit(ct));
sender.sendMessage("set location of audio"); sender.sendMessage("set location of audio");
break; break;
case "p": case "p":
case "play": case "play":
case "pause": case "pause":
sender.sendMessage("resuming & loading if needed, or pausing"); sender.sendMessage("resuming & loading if needed, or pausing");
if (videoMapCodec.isPaused()) { if (urlChanged || videoMapCodec.isPaused()) {
sendToAllPlayers(videoMapCodec.beginPlaybackBukkit(url, true, Integer.MAX_VALUE / 1000.0f)); if (urlChanged) {
urlChanged = false;
sendToAllPlayers(videoMapCodec.beginPlaybackBukkit(url, true, Integer.MAX_VALUE / 1000.0f));
}
sendToAllPlayers(videoMapCodec.setPausedBukkit(false));
} else { } else {
sendToAllPlayers(videoMapCodec.setPausedBukkit(true)); sendToAllPlayers(videoMapCodec.setPausedBukkit(true));
} }