Skip to content

Commit

Permalink
Resolve issue introduced in last change
Browse files Browse the repository at this point in the history
  • Loading branch information
Mindgamesnl committed May 31, 2024
1 parent b185ac1 commit a1961d3
Showing 1 changed file with 6 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,32 +35,29 @@ public void onExecute(User sender, String[] args) {

args[1] = args[1].toLowerCase();

int volume = 100;
int duration = 100;
if (args.length == 4) {
try {
volume = Integer.parseInt(args[3]);
duration = Integer.parseInt(args[3]);
} catch (NumberFormatException e) {
message(sender, ChatColor.RED + "ERROR! Volume must be a number!");
return;
throw new CommandError("Duration must be a number!");
}
}

if (volume < 0 || volume > 100) {
message(sender, ChatColor.RED + "The volume must be between 0 and 100");
if (duration < 1) {
message(sender, ChatColor.RED + "The duration must at least be one");
return;
}

if (Validation.isStringInvalid(args[2])) {
throw new CommandError("Invalid source url.");
}

int duration = Integer.parseInt(args[3]);

try {
WorldApi.getInstance().registerTempRegion(
sender.getWorld(),
args[1],
new RegionMediaOptions(args[2], volume),
new RegionMediaOptions(args[2], 100),
duration
);
} catch (UnknownWorldException e) {
Expand Down

0 comments on commit a1961d3

Please sign in to comment.