finish messages

This commit is contained in:
ayunami2000 2022-04-21 15:11:07 -04:00
parent c5e4c01f8a
commit f450a2de5b
3 changed files with 40 additions and 18 deletions

View File

@ -14,6 +14,7 @@ import org.bukkit.util.Vector;
public class Main extends JavaPlugin implements CommandExecutor, Listener { public class Main extends JavaPlugin implements CommandExecutor, Listener {
//todo: add queue command + store audio loc world & dont send to players in other worlds??? //todo: add queue command + store audio loc world & dont send to players in other worlds???
//todo: also when holding video map play audio at player location for that player //todo: also when holding video map play audio at player location for that player
//todo: reload config command
public static Main plugin; public static Main plugin;
@ -22,6 +23,9 @@ public class Main extends JavaPlugin implements CommandExecutor, Listener {
private String url = ""; private String url = "";
private boolean urlChanged = true; private boolean urlChanged = true;
private int syncTask = -1; private int syncTask = -1;
private final int[] mapSize = {1, 1};
private int mapSizeCap = 10;
private int mapOffset = 0;
@Override @Override
public void onLoad(){ public void onLoad(){
@ -35,7 +39,9 @@ public class Main extends JavaPlugin implements CommandExecutor, Listener {
audioLoc.setX(this.getConfig().getDouble("audio.x")); audioLoc.setX(this.getConfig().getDouble("audio.x"));
audioLoc.setY(this.getConfig().getDouble("audio.y")); audioLoc.setY(this.getConfig().getDouble("audio.y"));
audioLoc.setZ(this.getConfig().getDouble("audio.z")); audioLoc.setZ(this.getConfig().getDouble("audio.z"));
setSize(this.getConfig().getInt("width"), this.getConfig().getInt("width")); 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"); url = this.getConfig().getString("url");
syncTask = this.getServer().getScheduler().scheduleSyncRepeatingTask(this, this::syncToAllPlayers, 10000, 10000); // sync every 10 seconds syncTask = this.getServer().getScheduler().scheduleSyncRepeatingTask(this, this::syncToAllPlayers, 10000, 10000); // sync every 10 seconds
this.getCommand("ayunvid").setExecutor(this); this.getCommand("ayunvid").setExecutor(this);
@ -61,8 +67,14 @@ public class Main extends JavaPlugin implements CommandExecutor, Listener {
} }
private void setSize(int width, int height) { private void setSize(int width, int height) {
if (mapSizeCap > 0) {
width = Math.min(width, mapSizeCap);
height = Math.min(height, mapSizeCap);
}
mapSize[0] = width;
mapSize[1] = height;
int[][] mapIds = new int[height][width]; int[][] mapIds = new int[height][width];
int offset = this.getConfig().getInt("offset"); int offset = mapOffset;
for (int y = 0; y < mapIds.length; y++) { for (int y = 0; y < mapIds.length; y++) {
for (int x = 0; x < mapIds[y].length; x++) { for (int x = 0; x < mapIds[y].length; x++) {
mapIds[y][x] = offset++; mapIds[y][x] = offset++;
@ -123,7 +135,7 @@ public class Main extends JavaPlugin implements CommandExecutor, Listener {
offendingIndex++; offendingIndex++;
z = Double.parseDouble(args[3]); z = Double.parseDouble(args[3]);
} catch(NumberFormatException e) { } catch(NumberFormatException e) {
MessageHandler.sendPrefixedMessage(sender, "notANumber", args[offendingIndex]); MessageHandler.sendPrefixedMessage(sender, "notANumber", args[offendingIndex], MessageHandler.getMessage("double"));
break; break;
} }
audioLoc.setX(x + 0.5); audioLoc.setX(x + 0.5);
@ -159,28 +171,30 @@ public class Main extends JavaPlugin implements CommandExecutor, Listener {
case "s": case "s":
case "size": case "size":
if (args.length < 3) { if (args.length < 3) {
sender.sendMessage("must specify width & height to set! current vals are..."); MessageHandler.sendPrefixedMessage(sender, "currentSize", mapSize[0], mapSize[1], mapSize[0] * mapSize[1]);
break; break;
} }
int width; int width;
int height; int height;
int offendingIndex = 1;
try { try {
width = Math.max(1, Integer.parseInt(args[1])); width = Math.max(1, Integer.parseInt(args[1]));
offendingIndex++;
height = Math.max(1, Integer.parseInt(args[2])); height = Math.max(1, Integer.parseInt(args[2]));
} catch(NumberFormatException e) { } catch(NumberFormatException e) {
sender.sendMessage(""); MessageHandler.sendPrefixedMessage(sender, "notANumber", args[offendingIndex], MessageHandler.getMessage("integer"));
break; break;
} }
this.getConfig().set("width", width);
this.getConfig().set("height", height);
this.saveConfig();
sendToAllPlayers(videoMapCodec.disableVideoBukkit()); sendToAllPlayers(videoMapCodec.disableVideoBukkit());
setSize(width, height); setSize(width, height);
syncToAllPlayers(); syncToAllPlayers();
sender.sendMessage("set width & height"); this.getConfig().set("width", mapSize[0]);
this.getConfig().set("height", mapSize[1]);
this.saveConfig();
MessageHandler.sendPrefixedMessage(sender, "setSize", mapSize[0], mapSize[1], mapSize[0] * mapSize[1]);
break; break;
default: default:
sender.sendMessage("invalid"); MessageHandler.sendPrefixedMessage(sender, "invalidUsage");
} }
return true; return true;
} }

View File

@ -1,8 +1,11 @@
# URL of video to play # URL of video to play
url: "" url: ""
# screen size # screen size, in maps
width: 3 size:
height: 2 width: 1
height: 1
# maximum width/height accepted internally (set to 0 or less to disable)
cap: 10
# map ID offset # map ID offset
offset: 0 offset: 0
# audio location # audio location

View File

@ -2,16 +2,21 @@ prefix: "&9&l[&b&l&oayun&d&lEVM&9&l] &r"
usage: usage:
- "&3&nUsage:" - "&3&nUsage:"
- "&7&o/ayunvid [h|help] &3- Show this message." - "&7&o/ayunvid [h|help] &3- Show this message."
- "&7&o/ayunvid <u|url> <url> &3- Specify the video URL to use. (Must be CORS-compatible!)" - "&7&o/ayunvid <u|url> [url] &3- Specify the video URL to use, or get the current one. &l(Must be CORS-compatible!)"
- "&7&o/ayunvid <l|loc|location> [x y z] &3- Specify the location that the audio will come from." - "&7&o/ayunvid <l|loc|location> [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 <p|play|pause> &3- Toggle playback of the video." - "&7&o/ayunvid <p|play|pause> &3- Toggle playback of the video. This also loads the new video after the video URL is changed."
- "&7&o/ayunvid <s|size> <width> <height>&3- Set 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 <s|size> [<width> <height>]&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."
currentUrl: "&3Current URL: {0}" currentUrl: "&3Current URL: {0}"
setUrl: "&3Successfully set URL." setUrl: "&3Successfully set URL."
locFromConsole: "&cError: You must specify the coordinates when running this command from the console!" locFromConsole: "&cError: You must specify the coordinates when running this command from the console!"
locCurrent: "&3Using current location..." locCurrent: "&3Using current location..."
notANumber: "&cError: \"{0}\" is not a valid number!" notANumber: "&cError: \"{0}\" is not a valid {1}!"
double: "number"
integer: "integer"
locSet: "&3Successfully set audio location. ({0})" locSet: "&3Successfully set audio location. ({0})"
playing: "&3Loading and playing video..." playing: "&3Loading and playing video..."
resuming: "&3Resuming video..." resuming: "&3Resuming video..."
pausing: "&3Pausing 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."