2019-02-22 23:16:08 +00:00
|
|
|
package me.totalfreedom.totalfreedommod.command;
|
|
|
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
import java.util.List;
|
2020-12-25 20:57:10 +00:00
|
|
|
import java.util.SplittableRandom;
|
2019-02-22 23:16:08 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
|
|
|
import org.bukkit.Location;
|
|
|
|
import org.bukkit.command.Command;
|
|
|
|
import org.bukkit.command.CommandSender;
|
|
|
|
import org.bukkit.entity.EntityType;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
|
|
|
|
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
2020-03-30 23:43:57 +00:00
|
|
|
@CommandParameters(description = "Spawns a random type of fish at your location.", usage = "/<command>")
|
2019-02-22 23:16:08 +00:00
|
|
|
public class Command_bird extends FreedomCommand
|
|
|
|
{
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
|
|
|
{
|
|
|
|
Location location = playerSender.getTargetBlock(null, 15).getLocation().add(0, 1, 0);
|
|
|
|
playerSender.getWorld().spawnEntity(location, getRandomFish());
|
|
|
|
msg(":goodbird:");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public EntityType getRandomFish()
|
|
|
|
{
|
|
|
|
List<EntityType> fishTypes = Arrays.asList(EntityType.COD, EntityType.SALMON, EntityType.PUFFERFISH, EntityType.TROPICAL_FISH);
|
2020-12-25 20:57:10 +00:00
|
|
|
SplittableRandom random = new SplittableRandom();
|
2019-02-22 23:16:08 +00:00
|
|
|
return fishTypes.get(random.nextInt(fishTypes.size()));
|
|
|
|
}
|
|
|
|
}
|