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

41 lines
1.2 KiB
Java
Raw Normal View History

2018-07-22 00:45:56 +00:00
package me.totalfreedom.totalfreedommod.command;
import java.util.ArrayList;
import java.util.List;
2018-07-22 00:45:56 +00:00
import me.totalfreedom.totalfreedommod.rank.Rank;
import org.apache.commons.lang.StringUtils;
2018-07-22 00:45:56 +00:00
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
@CommandParameters(description = "Eject players that are riding you.", usage = "/<command>")
2018-07-22 00:45:56 +00:00
public class Command_eject extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
List<String> names = new ArrayList<>();
2018-07-22 00:45:56 +00:00
for (Entity entity : playerSender.getPassengers())
{
names.add(entity.getName());
}
if (names.isEmpty())
{
msg("Nothing was ejected.", ChatColor.GREEN);
return true;
}
2018-07-22 00:45:56 +00:00
msg("Ejecting " + StringUtils.join(names, ", ") + ".", ChatColor.GREEN);
playerSender.eject();
return true;
}
}