Prevent usage inside vehicle

This commit is contained in:
Cola
2022-10-11 15:22:39 +01:00
parent b8bae78578
commit c0b240378a

View File

@@ -6,6 +6,8 @@ import co.aikar.commands.annotation.CommandCompletion;
import co.aikar.commands.annotation.Description;
import co.aikar.commands.annotation.Optional;
import co.aikar.commands.annotation.Syntax;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.entity.Player;
@@ -20,6 +22,11 @@ public class CardinalCommand extends BaseCommand {
Player player = (Player) commandSender;
Location currLocation = player.getLocation();
if (player.isInsideVehicle()) {
player.sendMessage(Component.text("You cannot run this command from inside a vehicle!", NamedTextColor.RED));
return;
}
if(targetDirection == null){
double newYaw = Math.rint(currLocation.getYaw() / 45) * 45;
player.teleport(new Location(player.getWorld(), currLocation.getX(), currLocation.getY(),