diff --git a/src/main/java/me/ayunami2000/ayunEagVidMap/Main.java b/src/main/java/me/ayunami2000/ayunEagVidMap/Main.java index d076b28..7337544 100644 --- a/src/main/java/me/ayunami2000/ayunEagVidMap/Main.java +++ b/src/main/java/me/ayunami2000/ayunEagVidMap/Main.java @@ -13,8 +13,8 @@ import org.bukkit.util.Vector; public class Main extends JavaPlugin implements CommandExecutor, Listener { //todo: add queue command + store audio loc world & dont send to players in other worlds??? + //todo: or like detect where map is placed in world via entities and then per player play audio from the nearest one to them?? //todo: also when holding video map play audio at player location for that player - //todo: reload config command public static Main plugin; @@ -36,13 +36,7 @@ public class Main extends JavaPlugin implements CommandExecutor, Listener { public void onEnable(){ MessageHandler.initMessages(); this.saveDefaultConfig(); - audioLoc.setX(this.getConfig().getDouble("audio.x")); - audioLoc.setY(this.getConfig().getDouble("audio.y")); - audioLoc.setZ(this.getConfig().getDouble("audio.z")); - mapSizeCap = this.getConfig().getInt("size.cap"); - mapOffset = this.getConfig().getInt("offset"); - setSize(this.getConfig().getInt("size.width"), this.getConfig().getInt("size.height")); - url = this.getConfig().getString("url"); + this.rlConfig(); syncTask = this.getServer().getScheduler().scheduleSyncRepeatingTask(this, this::syncToAllPlayers, 10000, 10000); // sync every 10 seconds this.getCommand("ayunvid").setExecutor(this); this.getServer().getPluginManager().registerEvents(this, this); @@ -54,6 +48,16 @@ public class Main extends JavaPlugin implements CommandExecutor, Listener { sendToAllPlayers(videoMapCodec.disableVideoBukkit()); } + private void rlConfig() { + audioLoc.setX(this.getConfig().getDouble("audio.x")); + audioLoc.setY(this.getConfig().getDouble("audio.y")); + audioLoc.setZ(this.getConfig().getDouble("audio.z")); + mapSizeCap = this.getConfig().getInt("size.cap"); + mapOffset = this.getConfig().getInt("offset"); + setSize(this.getConfig().getInt("size.width"), this.getConfig().getInt("size.height")); + url = this.getConfig().getString("url"); + } + private void syncToPlayer(Player player) { videoMapCodec.syncPlaybackWithPlayersBukkit().send(player); } @@ -95,6 +99,12 @@ public class Main extends JavaPlugin implements CommandExecutor, Listener { return true; } switch (args[0].toLowerCase()) { + case "rl": + case "reload": + this.reloadConfig(); + this.rlConfig(); + MessageHandler.sendPrefixedMessage(sender, "reloaded"); + break; case "h": case "help": MessageHandler.sendPrefixedMessage(sender, "usage"); diff --git a/src/main/resources/messages.yml b/src/main/resources/messages.yml index 238fa70..a689af2 100644 --- a/src/main/resources/messages.yml +++ b/src/main/resources/messages.yml @@ -5,7 +5,8 @@ usage: - "&7&o/ayunvid [url] &3- Specify the video URL to use, or get the current one. &l(Must be CORS-compatible!)" - "&7&o/ayunvid [x y z] &3- Specify the location that the audio will come from. If no arguments are supplied, this will default to the sender's position." - "&7&o/ayunvid &3- Toggle playback of the video. This also loads the new video after the video URL is changed." - - "&7&o/ayunvid [ ]&3- Sets or gets the size of video, in maps. E.g., a width of 2 and a height of 3 would result in a video using 6 maps." + - "&7&o/ayunvid [ ] &3- Sets or gets the size of video, in maps. E.g., a width of 2 and a height of 3 would result in a video using 6 maps." + - "&7&o/ayunvid &3- Reloads the configuration file." currentUrl: "&3Current URL: {0}" setUrl: "&3Successfully set URL." locFromConsole: "&cError: You must specify the coordinates when running this command from the console!" @@ -19,4 +20,5 @@ resuming: "&3Resuming video..." pausing: "&3Pausing video..." currentSize: "&3Current size: {0} maps wide by {1} maps tall ({2} maps total)" setSize: "&3Set size to {0} maps wide by {1} maps tall ({2} maps total)" -invalidUsage: "&cError: That is not a valid subcommand! Try &n/ayunvid&c help for usage." \ No newline at end of file +invalidUsage: "&cError: That is not a valid subcommand! Try &n/ayunvid&c help for usage." +reloaded: "&3Successfully reloaded configuration!" \ No newline at end of file diff --git a/target/ayunEagVidMap-1.0-SNAPSHOT.jar b/target/ayunEagVidMap-1.0-SNAPSHOT.jar index b187d2a..89c2d20 100644 Binary files a/target/ayunEagVidMap-1.0-SNAPSHOT.jar and b/target/ayunEagVidMap-1.0-SNAPSHOT.jar differ