Compare commits

...

2 Commits

Author SHA1 Message Date
Phoenix616 34fc5c3439
Add ability to select random preset 2023-03-16 16:48:59 +01:00
Phoenix616 f934071367
Add ability to select random world in -world parameter 2023-03-16 16:36:49 +01:00
4 changed files with 10 additions and 7 deletions

View File

@ -16,7 +16,7 @@ Permission: `randomteleport.use`
Usage | Description
--------------------------------------------|-------------------------------
`/rtp` | uses the default preset
`/rtp <preset> [<playername>]` | uses a specific preset
`/rtp <preset1,...> [<playername>]` | uses a specific or random preset
`/rtp <minRange> <maxRange> [<options>]` | `minRange` - minimum distance to the center point (square shaped) <br> `maxRange` - maximum distance to the center point (square shaped)
`/rtp --stat` | shows a statistic of the teleports since the last restart
`/rtp --reload` | reloads the config
@ -24,7 +24,7 @@ Usage | Description
Option | Description
--------------------------------|-------------------------------------------
`-p,-player <playername>` | teleports other players
`-w,-world <worldname>` | teleports the player in a specific world
`-w,-world <world1,world2,...>` | teleports the player in a specific or random world
`-b,-biome <biomename...>` | only teleport to this biome (multiple allowed, Bukkit biome names!)
`-x,-xPos <x value>` | x axis of the center point, if not set the player's x axis is used
`-z,-zPos <z value>` | z axis of the center point, if not set the player's z axis is used

View File

@ -183,9 +183,11 @@ public class RandomTeleport extends JavaPlugin implements RandomTeleportAPI {
}));
addOptionParser(new SimpleOptionParser(array("w", "world"), (searcher, args) -> {
if (args.length > 0) {
World world = getServer().getWorld(args[0]);
String[] worldNames = args[0].split(",");
String worldName = worldNames[searcher.getRandom().nextInt(worldNames.length)];
World world = getServer().getWorld(worldName);
if (world == null) {
throw new WorldNotFoundException(args[0]);
throw new WorldNotFoundException(worldName);
}
searcher.setWorld(world);
return true;

View File

@ -78,7 +78,8 @@ public class RandomTeleportCommand implements CommandExecutor {
plugin.sendMessage(sender, "error.player-not-found", "what", args[1]);
return true;
}
runPreset(args[0].toLowerCase(), sender, target, target.getLocation());
String[] presets = args[0].split(",");
runPreset(presets[RandomTeleport.RANDOM.nextInt(presets.length)].toLowerCase(), sender, target, target.getLocation());
return true;
}
sender.sendMessage(e.getMessage());

View File

@ -14,13 +14,13 @@ commands:
permission: randomteleport.use
usage: |
/<command> - uses the default preset
/<command> <preset> [<playername>] - uses a specific preset
/<command> <preset1,...> [<playername>] - uses a specific or random preset
/<command> <minRange> <maxRange> [-p, -w, -x, -z, -c, -f]
minRange - minimum distance to the center point (square shaped)
maxRange - maximum distance to the center point (square shaped)
Options:
> -p,-player <playername> - teleports other players
> -w,-world <worldname> - teleports the player in a specific world
> -w,-world <world1,...> - teleports the player in a specific or random world
> -b,-biome <biomename> [<biome 2> ...] - only teleport to this biome (multiple allowed, Bukkit biome names!)
> -x,-xPos <x value> - x axis of the center point, if not set the player's x axis is used
> -z,-zPos <z value> - z axis of the center point, if not set the player's z axis is used