Setspawn plugin with random teleport?

ai
- in Plugins
6

I'm currently working on a Minecraft plugin that should look like this:

An admin sets e.g. Via teleport 4 possible spawns. If a player dies now, they should be teleported randomly to one of the possible spawns. So far I have the basics, so a set spawn and teleport to spawn. Random teleporting is missing and setspawns apply to all players on the server.

Di

Unfortunately I don't know how it works with a plugin but I know how to do it differently.

ai

And how?

an

Location [] spawnLocation = new Location [4];

// Your code where you specify the spawn locations, ie "with teleport" or however you want to do it. Simply set spawnLocation [0] to spawnLocation [3] and so.

@EventHandler
public void onRespawn (PlayerRespawnEvent event)
{
Player player = event.getPlayer ();

int randomzied = (int) (Math.random () * spawnLocation.length); // random number which then indicates which random spawn is used
{
event.setRespawnLocation (spawnLocation [randomized]);
}
}

Di

Under the spawn is a pressure plate that starts a random generator and then executes a command. TheJoCraft built such a random generator for its organ, only you have to use command blocks instead of note blocks in your case

an

Give me feedback if it works - just program mods normally, have no idea about plugins.

Di

How so?