So I'm trying to make boats faster on land like cars and so far I got this. I was told to delay the setting of the velocity 1 tick but I'm getting errors... If anyone could help I would be very thankful Spoiler (Move your mouse to the spoiler area to reveal the content) Show Spoiler Hide Spoiler Code: package customplugin.fr; import org.bukkit.entity.Boat; import org.bukkit.entity.Player; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.vehicle.VehicleDamageEvent; import org.bukkit.Bukkit; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.scheduler.BukkitScheduler; public final class BoatKart extends JavaPlugin { final FrostKart plugin; public BoatKart(FrostKart instance) { plugin=instance;} public void onVehicleDamage(VehicleDamageEvent event) { if(event.getVehicle() instanceof Boat) { if(event.getVehicle().getPassengers() instanceof Player) { event.setCancelled(true); } } BukkitScheduler scheduler = getServer().getScheduler(); scheduler.scheduleSyncDelayedTask(this, new Runnable() { @Override public void run() { public void onPlayerMove(PlayerMoveEvent event) { //This is where it creates problems. It says errors at tokens ( and ) replace with ; Player player = event.getPlayer(); if(player.getVehicle() != null && player.getVehicle() instanceof Boat) { Boat boat = (Boat) player.getVehicle(); boat.setVelocity(boat.getVelocity().multiply(2.3));} } } }, 1L); } }
You know one tick is like a fraction of a second which would probably eventually crash the server. Try setting it to 20 which is a second or atleast 10 which is half a second And just saying that you are extending java plugin which should only be in the main class. You also don't have an onEnable and you're using a listener without even implementing it and adding @EventHandler I would suggest learning a bit of Java before attempting to make plugins as it will really benefit you. Sent from my Pixel using Tapatalk
I updated my code a bit but it doesn't work for some reason Spoiler (Move your mouse to the spoiler area to reveal the content) Show Spoiler Hide Spoiler Code: @EventHandler public void onPlayerMove(PlayerMoveEvent event) { Player player = event.getPlayer(); if(player.getVehicle() != null && player.getVehicle() instanceof Boat) { Boat boat = (Boat) player.getVehicle(); plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() { public void run() { boat.setVelocity(boat.getVelocity().multiply(10));} }, 10,20); I forgot that detail. I was trying to get it working that I must added java plugin by accident EDIT by Moderator: merged posts, please use the edit button instead of double posting.
Cancel all velocity without the runnable, does the player stay still? What if you give the velocity to the player?
I cancelled the velocity and I could still move. And I tried to put player.getvelocity for the his velocity but nothing changed I fear,