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

59 lines
1.8 KiB
Java
Raw Normal View History

2018-07-22 00:45:56 +00:00
package me.totalfreedom.totalfreedommod.command;
2019-12-10 00:59:17 +00:00
import me.totalfreedom.totalfreedommod.playerverification.VPlayer;
2018-07-22 00:45:56 +00:00
import me.totalfreedom.totalfreedommod.rank.Rank;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
2019-12-10 00:59:17 +00:00
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
2018-07-22 00:45:56 +00:00
@CommandParameters(description = "Make other people your bitch.", usage = "/<command> <playername>")
public class Command_ride extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length < 1)
{
return false;
}
2019-12-10 00:59:17 +00:00
if (args[0].equalsIgnoreCase("toggle"))
{
VPlayer vPlayerSender = plugin.pv.getVerificationPlayer(playerSender);
vPlayerSender.setRideToggle(!vPlayerSender.isRideToggle());
plugin.pv.saveVerificationData(vPlayerSender);
msg("Other players n" + (vPlayerSender.isRideToggle() ? "ow" : "o longer") + " have the ability to ride you.");
return true;
}
2018-07-22 00:45:56 +00:00
final Player player = getPlayer(args[0]);
if (player == null)
{
msg(PLAYER_NOT_FOUND);
return true;
}
2019-12-10 00:59:17 +00:00
final VPlayer vPlayer = plugin.pv.getVerificationPlayer(player);
2018-07-22 00:45:56 +00:00
if (player == playerSender)
{
msg("You can't ride yourself. smh.", ChatColor.RED);
return true;
}
2019-12-10 00:59:17 +00:00
if (!vPlayer.isRideToggle() && !isAdmin(sender))
{
msg("That player cannot be ridden.", ChatColor.RED);
return true;
}
2018-07-22 00:45:56 +00:00
player.addPassenger(playerSender);
return true;
}
}