88 lines
3.0 KiB
Java
88 lines
3.0 KiB
Java
package net.mindoverflow.kissplugin.commands;
|
|
|
|
import net.mindoverflow.kissplugin.Main;
|
|
import org.bukkit.Effect;
|
|
import org.bukkit.Location;
|
|
import org.bukkit.Particle;
|
|
import org.bukkit.Sound;
|
|
import org.bukkit.command.Command;
|
|
import org.bukkit.command.CommandExecutor;
|
|
import org.bukkit.command.CommandSender;
|
|
import org.bukkit.entity.Entity;
|
|
import org.bukkit.entity.Player;
|
|
import org.bukkit.util.Vector;
|
|
|
|
public class KissCommand implements CommandExecutor
|
|
{
|
|
|
|
private Main plugin;
|
|
public KissCommand(Main plugin)
|
|
{
|
|
this.plugin = plugin;
|
|
}
|
|
|
|
@Override
|
|
public boolean onCommand(CommandSender commandSender, Command command, String label, String[] args) {
|
|
|
|
if(commandSender instanceof Player)
|
|
{
|
|
Player sender = (Player)commandSender;
|
|
|
|
for(Entity e : sender.getNearbyEntities(3, 3, 3))
|
|
{
|
|
if(e instanceof Player)
|
|
{
|
|
Player nearPlayer = (Player)e;
|
|
|
|
sendKiss(sender, nearPlayer, true, true, true, true, 5, 5, 10);
|
|
|
|
return true;
|
|
}
|
|
}
|
|
|
|
commandSender.sendMessage("§7There is no one to kiss around you! =(");
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
commandSender.sendMessage("§cOnly players can kiss other people!");
|
|
}
|
|
return true;
|
|
}
|
|
|
|
|
|
public static void sendKiss(Player sender, Player nearPlayer, boolean sendMessage, boolean playSound, boolean sendTitle, boolean spawnParticle, int titleFadeIn, int titleFadeOut, int particleCount)
|
|
{
|
|
if(sendMessage)
|
|
{
|
|
sender.sendMessage("§7You kissed §c" + nearPlayer.getName() + "§7!");
|
|
nearPlayer.sendMessage("§c" + sender.getName() + " §7kissed you!");
|
|
}
|
|
|
|
if(sendTitle)
|
|
{
|
|
sender.sendTitle("", "§c❤ §7You kissed §c" + nearPlayer.getName() + "§7! §c❤", titleFadeIn, 20, titleFadeOut);
|
|
nearPlayer.sendTitle("", "§c❤ §c" + sender.getName() + " §7kissed you! §c❤", titleFadeIn, 20, titleFadeOut);
|
|
}
|
|
|
|
|
|
if(spawnParticle)
|
|
{
|
|
sender.spawnParticle(Particle.HEART, nearPlayer.getEyeLocation(), particleCount, 0.3, 0.2, 0.3);
|
|
nearPlayer.spawnParticle(Particle.HEART, sender.getEyeLocation(), particleCount, 0.3, 0.2, 0.3);
|
|
}
|
|
|
|
if(playSound)
|
|
{
|
|
sender.playSound(sender.getLocation(), Sound.BLOCK_NOTE_BLOCK_PLING, 0.3f, 0.6f);
|
|
sender.playSound(sender.getLocation(), Sound.BLOCK_NOTE_BLOCK_PLING, 0.3f, 0.8f);
|
|
sender.playSound(sender.getLocation(), Sound.BLOCK_NOTE_BLOCK_PLING, 0.3f, 1f);
|
|
|
|
nearPlayer.playSound(nearPlayer.getLocation(), Sound.BLOCK_NOTE_BLOCK_PLING, 0.3f, 0.6f);
|
|
nearPlayer.playSound(nearPlayer.getLocation(), Sound.BLOCK_NOTE_BLOCK_PLING, 0.3f, 0.8f);
|
|
nearPlayer.playSound(nearPlayer.getLocation(), Sound.BLOCK_NOTE_BLOCK_PLING, 0.3f, 1f);
|
|
}
|
|
}
|
|
|
|
}
|