Repair Command #30

Closed
opened 2020-10-13 23:58:50 +00:00 by reflexLabs · 5 comments
reflexLabs commented 2020-10-13 23:58:50 +00:00 (Migrated from github.com)

I would love to see a repair command which based permission for players
and command such /v repair [player] and it will repair the vehicle player driving in.

Thanks! :)

I would love to see a repair command which based permission for players and command such /v repair [player] and it will repair the vehicle player driving in. Thanks! :)
reflexLabs commented 2020-10-14 01:05:02 +00:00 (Migrated from github.com)

Also, how about downgrade vehicle tuning such steering and acceleration through the main vehicle gui

Also, how about downgrade vehicle tuning such steering and acceleration through the main vehicle gui
Collinvh commented 2020-12-25 22:00:44 +00:00 (Migrated from github.com)

You could code this yourself;

import collin.yourplugin.manager.general.VPPMain;
import me.legofreak107.vehiclesplus.vehicles.vehicles.objects.SpawnedVehicle;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

public class RepairVehicle implements CommandExecutor {
    @Override
    public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
        if(commandSender instanceof Player) {
            if(commandSender.hasPermission("vpp.repair")) {
                SpawnedVehicle vehicle = VPPMain.getDriverFromUUID(((Player) commandSender).getUniqueId());
                vehicle.getStorageVehicle().getVehicleStats().setBroken(false);
                vehicle.getStorageVehicle().getVehicleStats().setHealth(vehicle.getBaseVehicle().getHealth());
            }
        }
        return true;
    }
}

Create this class

import me.legofreak107.vehiclesplus.vehicles.api.events.VehicleEnterEvent;
import me.legofreak107.vehiclesplus.vehicles.api.events.VehicleLeaveEvent;
import me.legofreak107.vehiclesplus.vehicles.vehicles.objects.SpawnedVehicle;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;

import java.util.HashMap;
import java.util.UUID;

public class VPPMain implements Listener {
    private static final HashMap<UUID, SpawnedVehicle> drivers = new HashMap<>();

    @EventHandler
    public static void onVehicleEnter(VehicleEnterEvent event) {
        if(event.getDriver() != null) {
            drivers.put(event.getDriver().getUniqueId(), event.getVehicle());
        }
    }

    @EventHandler
    public static void onVehicleExit(VehicleLeaveEvent event) {
        if(event.getDriver() != null) {
            drivers.remove(event.getDriver().getUniqueId());
        }
    }

    public static SpawnedVehicle getDriverFromUUID(UUID uuid) {
        return drivers.get(uuid);
    }
}

Create this class
Please do note you have the right imports!

    @Override
    public void onEnable() {
        this.getCommand("repair").setExecutor(new RepairVehicle());
        Bukkit.getPluginManager().registerEvents(new VPPMain(), UltimateRacing.getInstance());
    }

Add this in the onEnable

You could code this yourself; ``` import collin.yourplugin.manager.general.VPPMain; import me.legofreak107.vehiclesplus.vehicles.vehicles.objects.SpawnedVehicle; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; public class RepairVehicle implements CommandExecutor { @Override public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) { if(commandSender instanceof Player) { if(commandSender.hasPermission("vpp.repair")) { SpawnedVehicle vehicle = VPPMain.getDriverFromUUID(((Player) commandSender).getUniqueId()); vehicle.getStorageVehicle().getVehicleStats().setBroken(false); vehicle.getStorageVehicle().getVehicleStats().setHealth(vehicle.getBaseVehicle().getHealth()); } } return true; } } ``` Create this class ``` import me.legofreak107.vehiclesplus.vehicles.api.events.VehicleEnterEvent; import me.legofreak107.vehiclesplus.vehicles.api.events.VehicleLeaveEvent; import me.legofreak107.vehiclesplus.vehicles.vehicles.objects.SpawnedVehicle; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import java.util.HashMap; import java.util.UUID; public class VPPMain implements Listener { private static final HashMap<UUID, SpawnedVehicle> drivers = new HashMap<>(); @EventHandler public static void onVehicleEnter(VehicleEnterEvent event) { if(event.getDriver() != null) { drivers.put(event.getDriver().getUniqueId(), event.getVehicle()); } } @EventHandler public static void onVehicleExit(VehicleLeaveEvent event) { if(event.getDriver() != null) { drivers.remove(event.getDriver().getUniqueId()); } } public static SpawnedVehicle getDriverFromUUID(UUID uuid) { return drivers.get(uuid); } } ``` Create this class Please do note you have the right imports! ``` @Override public void onEnable() { this.getCommand("repair").setExecutor(new RepairVehicle()); Bukkit.getPluginManager().registerEvents(new VPPMain(), UltimateRacing.getInstance()); } ``` Add this in the onEnable
stale[bot] commented 2021-06-04 17:33:46 +00:00 (Migrated from github.com)

This issue has been automatically closed because there has been no response to our request for more information from the original author. With only the information that is currently in the issue, we don't have enough information to take action. Please reach out if you have or find the answers we need so that we can investigate further.

This issue has been automatically closed because there has been no response to our request for more information from the original author. With only the information that is currently in the issue, we don't have enough information to take action. Please reach out if you have or find the answers we need so that we can investigate further.
stijnb1234 commented 2021-06-04 17:42:20 +00:00 (Migrated from github.com)

Will be added in the recode.

Will be added in the recode.
stijnb1234 commented 2022-03-14 16:25:14 +00:00 (Migrated from github.com)

Added in the v3 recode!

/vp repair <Player>
Will repair the vehicle that player is in.

Added in the v3 recode! `/vp repair <Player>` Will repair the vehicle that player is in.
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: SBDevelopment/VehiclesPlus#30
No description provided.