TotalFreedomMod/src/main/java/me/totalfreedom/totalfreedommod/command/Command_bird.java

34 lines
1.2 KiB
Java
Raw Normal View History

2019-02-22 23:16:08 +00:00
package me.totalfreedom.totalfreedommod.command;
import java.util.Arrays;
import java.util.List;
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)
@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);
SplittableRandom random = new SplittableRandom();
2019-02-22 23:16:08 +00:00
return fishTypes.get(random.nextInt(fishTypes.size()));
}
}