Search in sources :

Example 11 with Vehicle

use of me.legofreak107.vehicles.objects.Vehicle in project VehiclesPlus2.0 by legofreak107.

the class PlayerInteractAtEntity method onInteractEntity.

@EventHandler
public void onInteractEntity(PlayerInteractAtEntityEvent e) {
    if (e.getRightClicked().getCustomName() != null) {
        e.setCancelled(true);
    }
    if (plugin.vehicleInfo.containsKey(e.getRightClicked())) {
        e.setCancelled(true);
        if (e.getPlayer().getInventory().getItemInMainHand().hasItemMeta() && e.getPlayer().getInventory().getItemInMainHand().getItemMeta().getDisplayName().contains("key")) {
            Vehicle v = plugin.vehicleInfo.get(e.getRightClicked());
            String vpname = e.getPlayer().getInventory().getItemInMainHand().getItemMeta().getDisplayName().replace("�2", "").replace(" key", "");
            if (plugin.isValidVehicle(vpname)) {
                if (v.name.equalsIgnoreCase(vpname) && v.owner.contains(e.getPlayer().getName())) {
                    v.locked = !v.locked;
                    String str = "Locked";
                    if (v.locked) {
                        str = "locked";
                    } else {
                        str = "unlocked";
                    }
                    e.getPlayer().sendMessage("�2This vehicle is now: �6" + str);
                }
            }
        } else if (e.getPlayer().getInventory().getItemInMainHand().hasItemMeta() && !e.getPlayer().getInventory().getItemInMainHand().getItemMeta().getDisplayName().contains("Wrench") && !e.getPlayer().getInventory().getItemInMainHand().getItemMeta().getDisplayName().contains("Winch") && !e.getPlayer().getInventory().getItemInMainHand().getItemMeta().getDisplayName().contains("Oil") && !e.getPlayer().getInventory().getItemInMainHand().getItemMeta().getDisplayName().contains("Paint") && !e.getPlayer().getInventory().getItemInMainHand().getItemMeta().getDisplayName().contains("Key")) {
            Fuel fuel = new Fuel();
            fuel.name = "empty";
            for (Fuel f : plugin.fuelTypes) {
                if (f.item.getItemMeta().getDisplayName().contains(e.getPlayer().getInventory().getItemInMainHand().getItemMeta().getDisplayName())) {
                    fuel = f;
                }
            }
            Vehicle v = plugin.vehicleInfo.get(e.getRightClicked());
            if (v.fuelType.name.equals(fuel.name)) {
                if (v.fuel + fuel.fuelAmount <= v.maxFuel) {
                    v.fuel += fuel.fuelAmount;
                    e.getPlayer().getInventory().removeItem(e.getPlayer().getInventory().getItemInMainHand());
                    e.getPlayer().sendMessage("�2Vehicle fueled to: �6" + (int) (v.fuel / v.maxFuel * 100) + "�2%");
                } else {
                    if (v.fuel != v.maxFuel) {
                        v.fuel = v.maxFuel;
                        e.getPlayer().getInventory().removeItem(e.getPlayer().getInventory().getItemInMainHand());
                        e.getPlayer().sendMessage("�2Vehicle fueled to: �6" + (int) (v.fuel / v.maxFuel * 100) + "�2%");
                    }
                }
            } else {
                e.getPlayer().sendMessage("�cThis vehicle does not operate on this fuel!");
            }
        } else if (e.getPlayer().getInventory().getItemInMainHand().hasItemMeta() && e.getPlayer().getInventory().getItemInMainHand().getItemMeta().getDisplayName().contains("Winch")) {
            Vehicle v = plugin.vehicleInfo.get(e.getRightClicked());
            plugin.winching.put(e.getPlayer(), v);
            e.getPlayer().sendMessage("�2Selected vehicle to winch, click a trailer to lock it.");
        } else if (e.getPlayer().getInventory().getItemInMainHand().hasItemMeta() && e.getPlayer().getInventory().getItemInMainHand().getItemMeta().getDisplayName().contains("Refined Oil")) {
            Vehicle v = plugin.vehicleInfo.get(e.getRightClicked());
            e.getPlayer().sendMessage("�2Oil changed!");
            e.getPlayer().getInventory().removeItem(e.getPlayer().getInventory().getItemInMainHand());
        } else if (e.getPlayer().getInventory().getItemInMainHand().hasItemMeta() && e.getPlayer().getInventory().getItemInMainHand().getItemMeta().getDisplayName().contains("Paint")) {
            Vehicle v = plugin.vehicleInfo.get(e.getRightClicked());
            int r = Integer.parseInt(e.getPlayer().getInventory().getItemInMainHand().getItemMeta().getLore().get(0).replace("�8Red: ", ""));
            int g = Integer.parseInt(e.getPlayer().getInventory().getItemInMainHand().getItemMeta().getLore().get(1).replace("�8Green: ", ""));
            int b = Integer.parseInt(e.getPlayer().getInventory().getItemInMainHand().getItemMeta().getLore().get(2).replace("�8Blue: ", ""));
            ItemStack item = v.skinHolder.getHelmet();
            if (item.getType() == Material.LEATHER_BOOTS) {
                LeatherArmorMeta lm = (LeatherArmorMeta) item.getItemMeta();
                lm.setColor(Color.fromRGB(r, g, b));
                item.setItemMeta(lm);
                v.skinHolder.setHelmet(item);
                v.skin = item;
                e.getPlayer().sendMessage("�2Car painted!");
                e.getPlayer().getInventory().removeItem(e.getPlayer().getInventory().getItemInMainHand());
            }
        } else if (e.getPlayer().getInventory().getItemInMainHand().hasItemMeta() && e.getPlayer().getInventory().getItemInMainHand().getItemMeta().getDisplayName().contains("Wrench")) {
            Vehicle v = plugin.vehicleInfo.get(e.getRightClicked());
            plugin.openSelectMenu(e.getPlayer(), v);
        }
    }
    if (plugin.seatInfo.containsKey(e.getRightClicked())) {
        e.setCancelled(true);
        // Is seat
        if (e.getPlayer().isInsideVehicle()) {
            e.getPlayer().sendMessage("�2You can't switch seats. Please dismount your current seat first!");
        } else {
            Seat s = plugin.seatInfo.get(e.getRightClicked());
            Vehicle v = plugin.vehicleInfo.get(s.parent);
            if (v.locked) {
                if (e.getPlayer().getInventory().getItemInMainHand().hasItemMeta() && e.getPlayer().getInventory().getItemInMainHand().getItemMeta().getDisplayName().contains("key")) {
                    String vpname = e.getPlayer().getInventory().getItemInMainHand().getItemMeta().getDisplayName().replace("�2", "").replace(" key", "");
                    if (plugin.isValidVehicle(vpname)) {
                        if (v.name.equalsIgnoreCase(vpname) && v.owner.contains(e.getPlayer().getName())) {
                            if (s.steer) {
                                e.getPlayer().sendMessage("�2You entered a vehicle.");
                                s.seat.addPassenger(e.getPlayer());
                                e.getPlayer().sendMessage("�2You are in the drivers seat.");
                                e.getPlayer().sendMessage("�2You can control this vehicle with WASD (And space for planes).");
                                if (!v.running) {
                                    e.getPlayer().sendMessage("");
                                    e.getPlayer().sendMessage("�2This vehicle is not started yet...");
                                    e.getPlayer().sendMessage("�2Right click with the key to start it.");
                                }
                            } else {
                                e.getPlayer().sendMessage("�2This vehicle is locked!");
                                e.setCancelled(true);
                            }
                        }
                    }
                } else {
                    e.getPlayer().sendMessage("�2This vehicle is locked!");
                    e.setCancelled(true);
                }
            } else {
                e.getPlayer().sendMessage("�2You entered a vehicle.");
                s.seat.addPassenger(e.getPlayer());
                if (s.steer) {
                    e.getPlayer().sendMessage("�2You are in the drivers seat.");
                    e.getPlayer().sendMessage("�2You can control this vehicle with WASD (And space for planes).");
                    if (!v.running) {
                        e.getPlayer().sendMessage("");
                        e.getPlayer().sendMessage("�2This vehicle is not started yet...");
                        e.getPlayer().sendMessage("�2Right click with the key to start it.");
                    }
                } else {
                    e.getPlayer().sendMessage("�2You are in the passengers seat.");
                }
                e.setCancelled(true);
            }
        }
    }
}
Also used : Vehicle(me.legofreak107.vehicles.objects.Vehicle) Seat(me.legofreak107.vehicles.objects.Seat) Fuel(me.legofreak107.vehicles.objects.Fuel) LeatherArmorMeta(org.bukkit.inventory.meta.LeatherArmorMeta) ItemStack(org.bukkit.inventory.ItemStack) EventHandler(org.bukkit.event.EventHandler)

Example 12 with Vehicle

use of me.legofreak107.vehicles.objects.Vehicle in project VehiclesPlus2.0 by legofreak107.

the class PlayerJoin method onJoin.

@EventHandler
public void onJoin(PlayerJoinEvent e) {
    Player p = e.getPlayer();
    if (plugin.getCustomPlayerConfig("saved/" + p.getName() + ".yml", p).contains("SavedVehicles")) {
        if (plugin.getCustomPlayerConfig("saved/" + p.getName() + ".yml", p).contains("SavedVehicles." + p.getName())) {
            p.sendMessage("�2Loading in vehicles...");
            for (String s2 : plugin.getCustomPlayerConfig("saved/" + p.getName() + ".yml", p).getConfigurationSection("SavedVehicles." + p.getName()).getKeys(false)) {
                if (plugin.getCustomPlayerConfig("saved/" + p.getName() + ".yml", p).contains("SavedVehicles." + p.getName() + "." + s2 + ".forwardspeed")) {
                    if (plugin.getCustomPlayerConfig("saved/" + p.getName() + ".yml", p).contains("SavedVehicles." + p.getName() + "." + s2 + ".trunk.content")) {
                        Vehicle v = new Vehicle();
                        v.plugin = plugin;
                        VPPlayer pla = new VPPlayer();
                        pla.p = p;
                        v.p = pla;
                        v.owner = p.getName();
                        if (plugin.checkInt(s2.replace("id", ""))) {
                            v.id = Integer.parseInt(s2.replace("id", ""));
                        }
                        v.loadVehicle();
                        if (plugin.playerVehicles.containsKey(p)) {
                            List<Vehicle> vl = plugin.playerVehicles.get(p);
                            vl.add(v);
                            plugin.playerVehicles.put(p, vl);
                        } else {
                            List<Vehicle> vl = new ArrayList<Vehicle>();
                            vl.add(v);
                            plugin.playerVehicles.put(p, vl);
                        }
                    }
                    p.sendMessage("�2Done!");
                }
            }
        }
    }
}
Also used : Vehicle(me.legofreak107.vehicles.objects.Vehicle) VPPlayer(me.legofreak107.vehicles.objects.VPPlayer) VPPlayer(me.legofreak107.vehicles.objects.VPPlayer) Player(org.bukkit.entity.Player) ArrayList(java.util.ArrayList) EventHandler(org.bukkit.event.EventHandler)

Example 13 with Vehicle

use of me.legofreak107.vehicles.objects.Vehicle in project VehiclesPlus2.0 by legofreak107.

the class Plane method Plane.

public static void Plane(PacketPlayInSteerVehicle ppisv, Player p) {
    ArmorStand a2 = (ArmorStand) p.getVehicle();
    Seat s = plugin.seatInfo.get(a2);
    ArmorStand a = (ArmorStand) s.parent;
    Vehicle v = plugin.vehicleInfo.get(a);
    ArmorStand a3 = (ArmorStand) v.skinHolder;
    float forward = ppisv.b();
    float side = ppisv.a();
    boolean space = ppisv.c();
    v.fuelbar.setTitle("Fuel: " + (int) (v.fuel / v.maxFuel * 100) + "%");
    v.fuelbar.setProgress((v.fuel / v.maxFuel));
    if (v.fuelbar.getPlayers().contains(p)) {
    } else {
        v.fuelbar.addPlayer(p);
        v.fuelbar.setVisible(true);
    }
    if (v.fuel <= 0.5) {
        v.fuelbar.setTitle("Out of fuel!");
    } else {
        v.fuel -= v.fualUsage / 2;
        if (forward > 0) {
            // Forward[W]
            v.fuel -= v.fualUsage;
            if (v.curSpeed < v.fspeed) {
                v.curSpeed = v.curSpeed + v.acceleration / 20;
            }
            a.setVelocity(new Vector(a.getLocation().getDirection().multiply(0.5).getX(), 0, a.getLocation().getDirection().multiply(0.5).getZ()).multiply(v.curSpeed));
        } else if (forward == 0) {
            if (v.curSpeed > 0) {
                v.curSpeed = v.curSpeed - v.acceleration / 20;
            }
            a.setVelocity(new Vector(a.getLocation().getDirection().multiply(0.5).getX(), -0.1, a.getLocation().getDirection().multiply(0.5).getZ()).multiply(v.curSpeed));
        } else {
            if (v.curSpeed > 0) {
                v.curSpeed = v.curSpeed - v.acceleration / 20 * 3;
            }
            a.setVelocity(new Vector(a.getLocation().getDirection().multiply(0.5).getX(), -0.2, a.getLocation().getDirection().multiply(0.5).getZ()).multiply(v.curSpeed));
        }
        if (forward > 0 && space) {
            if (v.curSpeed > (v.fspeed / 5 * 2)) {
                a.setVelocity(new Vector(a.getLocation().getDirection().multiply(0.5).getX(), 0.2, a.getLocation().getDirection().multiply(0.5).getZ()).multiply(v.curSpeed));
            } else {
                if (v.curSpeed < v.fspeed) {
                    v.curSpeed = v.curSpeed + v.acceleration / 20;
                }
                a.setVelocity(new Vector(a.getLocation().getDirection().multiply(0.5).getX(), 0, a.getLocation().getDirection().multiply(0.5).getZ()).multiply(v.curSpeed));
            }
        } else {
            a3.setHeadPose(new EulerAngle(0, 0, 0));
        }
        if (side > 0 && forward > 0) {
            // Side[A]
            EntityArmorStand a1 = ((CraftArmorStand) a).getHandle();
            a1.setLocation(a.getLocation().getX(), a.getLocation().getY(), a.getLocation().getZ(), a.getLocation().getYaw() - v.turnSpeed, a.getLocation().getPitch());
            if (a.getLocation().getBlock().getRelative(BlockFace.DOWN).getType() == Material.AIR) {
                a3.setHeadPose(new EulerAngle(0, 0, 170));
            }
        } else if (side < 0 && forward > 0) {
            // Side[D]
            EntityArmorStand a1 = ((CraftArmorStand) a).getHandle();
            a1.setLocation(a.getLocation().getX(), a.getLocation().getY(), a.getLocation().getZ(), a.getLocation().getYaw() + v.turnSpeed, a.getLocation().getPitch());
            if (a.getLocation().getBlock().getRelative(BlockFace.DOWN).getType() == Material.AIR) {
                a3.setHeadPose(new EulerAngle(0, 0, -170));
            }
        } else {
            a3.setHeadPose(new EulerAngle(0, 0, 0));
        }
        if (side > 0) {
            // Side[A]
            EntityArmorStand a1 = ((CraftArmorStand) a).getHandle();
            a1.setLocation(a.getLocation().getX(), a.getLocation().getY(), a.getLocation().getZ(), a.getLocation().getYaw() - v.turnSpeed, a.getLocation().getPitch());
        } else if (side < 0) {
            // Side[D]
            EntityArmorStand a1 = ((CraftArmorStand) a).getHandle();
            a1.setLocation(a.getLocation().getX(), a.getLocation().getY(), a.getLocation().getZ(), a.getLocation().getYaw() + v.turnSpeed, a.getLocation().getPitch());
        }
        Location loc1 = new Location(a.getWorld(), a.getLocation().getBlockX() + 1, a.getLocation().getBlockY(), a.getLocation().getBlockZ());
        Location loc2 = new Location(a.getWorld(), a.getLocation().getBlockX() - 1, a.getLocation().getBlockY(), a.getLocation().getBlockZ());
        Location loc3 = new Location(a.getWorld(), a.getLocation().getBlockX(), a.getLocation().getBlockY(), a.getLocation().getBlockZ() + 1);
        Location loc4 = new Location(a.getWorld(), a.getLocation().getBlockX(), a.getLocation().getBlockY(), a.getLocation().getBlockZ() - 1);
        if ((loc1.getBlock().getType() != Material.AIR && loc1.getBlock().getType() != Material.LONG_GRASS && loc1.getBlock().getType() != Material.CHORUS_FLOWER && loc1.getBlock().getType() != Material.YELLOW_FLOWER && loc1.getBlock().getType() != Material.RED_ROSE && loc1.getBlock().getType() != Material.WHEAT) || (loc2.getBlock().getType() != Material.AIR && loc2.getBlock().getType() != Material.LONG_GRASS && loc2.getBlock().getType() != Material.CHORUS_FLOWER && loc2.getBlock().getType() != Material.YELLOW_FLOWER && loc2.getBlock().getType() != Material.RED_ROSE && loc2.getBlock().getType() != Material.WHEAT) || (loc3.getBlock().getType() != Material.AIR && loc3.getBlock().getType() != Material.LONG_GRASS && loc3.getBlock().getType() != Material.CHORUS_FLOWER && loc3.getBlock().getType() != Material.YELLOW_FLOWER && loc3.getBlock().getType() != Material.RED_ROSE && loc3.getBlock().getType() != Material.WHEAT) || (loc4.getBlock().getType() != Material.AIR && loc4.getBlock().getType() != Material.LONG_GRASS && loc4.getBlock().getType() != Material.CHORUS_FLOWER && loc4.getBlock().getType() != Material.YELLOW_FLOWER && loc4.getBlock().getType() != Material.RED_ROSE && loc4.getBlock().getType() != Material.WHEAT)) {
        }
    }
}
Also used : Vehicle(me.legofreak107.vehicles.objects.Vehicle) PacketPlayInSteerVehicle(net.minecraft.server.v1_12_R1.PacketPlayInSteerVehicle) Seat(me.legofreak107.vehicles.objects.Seat) CraftArmorStand(org.bukkit.craftbukkit.v1_12_R1.entity.CraftArmorStand) ArmorStand(org.bukkit.entity.ArmorStand) EntityArmorStand(net.minecraft.server.v1_12_R1.EntityArmorStand) CraftArmorStand(org.bukkit.craftbukkit.v1_12_R1.entity.CraftArmorStand) EntityArmorStand(net.minecraft.server.v1_12_R1.EntityArmorStand) EulerAngle(org.bukkit.util.EulerAngle) Vector(org.bukkit.util.Vector) Location(org.bukkit.Location)

Example 14 with Vehicle

use of me.legofreak107.vehicles.objects.Vehicle in project VehiclesPlus2.0 by legofreak107.

the class Helicopter method Helicopter.

public static void Helicopter(PacketPlayInSteerVehicle ppisv, Player p) {
    ArmorStand a2 = (ArmorStand) p.getVehicle();
    Seat s = plugin.seatInfo.get(a2);
    ArmorStand a = (ArmorStand) s.parent;
    Vehicle v = plugin.vehicleInfo.get(a);
    float forward = ppisv.b();
    float side = ppisv.a();
    boolean space = ppisv.c();
/*if(!Main.flyspeedlr.containsKey(p)){
        	Main.flyspeedlr.put(p, (float) 0);
        }
        if (!space && forward > 0 && Main.flyspeedlr.get(p) > 1.2){ //Forward[W]
        	if(Main.flyspeed.containsKey(p) && Main.flyspeed.get(p) < 1.5){
        		Main.flyspeed.put(p, (float) (Main.flyspeed.get(p) + 0.05));
            	a.setHeadPose(new EulerAngle(Math.toRadians(Main.flyspeed.get(p) * 30),0,0));
        	}else if(!Main.flyspeed.containsKey(p)){
        		Main.flyspeed.put(p, (float) 0);
        	}
        	if(Main.flyspeed.get(p) < 1){
                a.setVelocity(new Vector(a.getLocation().getDirection().multiply(0.5).getX(), 0.2, a.getLocation().getDirection().multiply(0.5).getZ()).multiply(Main.flyspeed.get(p)));
        	}else{
                a.setVelocity(new Vector(a.getLocation().getDirection().multiply(0.5).getX(), -0.1, a.getLocation().getDirection().multiply(0.5).getZ()).multiply(Main.flyspeed.get(p)));
        	}
        }else if(forward == 0){
        	if(Main.flyspeed.containsKey(p) && Main.flyspeed.get(p) > 0){
        		Main.flyspeed.put(p, (float) (Main.flyspeed.get(p) - 0.01));
        	}else if(Main.flyspeed.containsKey(p) && Main.flyspeed.get(p) < 0){
        		Main.flyspeed.put(p, (float) (Main.flyspeed.get(p) + 0.01));
        	}
        	if(Main.flyspeed.get(p) < 0.6 && Main.flyspeed.get(p) > -0.6){
        		a.setHeadPose(new EulerAngle(0,0,0));
        	}else{
        		a.setHeadPose(new EulerAngle(Math.toRadians(Main.flyspeed.get(p) * 30),0,0));
        	}
        		a.setVelocity(new Vector(a.getLocation().getDirection().multiply(Main.flyspeed.get(p)).getX(), Main.flyspeedlr.get(p) -1.3, a.getLocation().getDirection().multiply(Main.flyspeed.get(p)).getZ()));

        }else if(!space && forward < 0 && Main.flyspeedlr.get(p) > 1.2){
        	if(Main.flyspeed.containsKey(p) && Main.flyspeed.get(p) > -1.5){
        		Main.flyspeed.put(p, (float) (Main.flyspeed.get(p) - 0.05));
            	a.setHeadPose(new EulerAngle(Math.toRadians(Main.flyspeed.get(p) * 30),0,0));
        	}else if(!Main.flyspeed.containsKey(p)){
        		Main.flyspeed.put(p, (float) 0);
        	}
        	if(Main.flyspeed.get(p) < -1){
                a.setVelocity(new Vector(a.getLocation().getDirection().multiply(0.5).getX(), 0.2, a.getLocation().getDirection().multiply(0.5).getZ()).multiply(Main.flyspeed.get(p)));
        	}else{
                a.setVelocity(new Vector(a.getLocation().getDirection().multiply(0.5).getX(), -0.1, a.getLocation().getDirection().multiply(0.5).getZ()).multiply(Main.flyspeed.get(p)));
        	}
        }		
        
        if (side > 0){ //Side[A]
        	EntityArmorStand a1 = ((CraftArmorStand) a).getHandle();
        	a1.setLocation(a.getLocation().getX(), a.getLocation().getY(), a.getLocation().getZ(), a.getLocation().getYaw() - v.turnSpeed, a.getLocation().getPitch());
        } else if (side < 0){ //Side[D]
        	EntityArmorStand a1 = ((CraftArmorStand) a).getHandle();
        	a1.setLocation(a.getLocation().getX(), a.getLocation().getY(), a.getLocation().getZ(), a.getLocation().getYaw() + v.turnSpeed, a.getLocation().getPitch());
        }
        
        if(space && forward > 0){
        	if(Main.flyspeedlr.containsKey(p) && Main.flyspeedlr.get(p) < 1.5){	
        		Main.flyspeedlr.put(p, (float) (Main.flyspeedlr.get(p) + 0.01));					        					
        		a.setVelocity(new Vector(0, Main.flyspeedlr.get(p)-1.2, 0));

        	}else if(!Main.flyspeedlr.containsKey(p)){
        		Main.flyspeedlr.put(p, (float) 0);
        	}
        }
        if(space && forward < 0){
        	if(Main.flyspeedlr.containsKey(p) && Main.flyspeedlr.get(p) > 0){	
        		Main.flyspeedlr.put(p, (float) (Main.flyspeedlr.get(p) - 0.01));				
        		a.setVelocity(new Vector(0, Main.flyspeedlr.get(p)-1.2, 0));

        	}else if(!Main.flyspeedlr.containsKey(p)){
        		Main.flyspeedlr.put(p, (float) 0);
        	}
        }*/
}
Also used : Vehicle(me.legofreak107.vehicles.objects.Vehicle) PacketPlayInSteerVehicle(net.minecraft.server.v1_12_R1.PacketPlayInSteerVehicle) Seat(me.legofreak107.vehicles.objects.Seat) ArmorStand(org.bukkit.entity.ArmorStand)

Example 15 with Vehicle

use of me.legofreak107.vehicles.objects.Vehicle in project VehiclesPlus2.0 by legofreak107.

the class Main method getVehicle.

public Vehicle getVehicle(String s) {
    Vehicle isvalid = null;
    for (Vehicle t : vehicleTypeList) {
        if (t.name.equalsIgnoreCase(s)) {
            Vehicle v2 = new Vehicle();
            v2.p = t.p;
            v2.spawnLoc = t.spawnLoc;
            v2.plugin = t.plugin;
            v2.health = t.health;
            v2.acceleration = t.acceleration;
            v2.broken = t.broken;
            v2.bspeed = t.bspeed;
            v2.curSpeed = t.curSpeed;
            v2.fspeed = t.fspeed;
            v2.fualUsage = t.fualUsage;
            v2.fuel = t.fuel;
            v2.fuelbar = t.fuelbar;
            v2.holder = t.holder;
            v2.id = t.id;
            v2.locked = t.locked;
            v2.maxFuel = t.maxFuel;
            v2.name = t.name;
            v2.owner = t.owner;
            v2.parts = t.parts;
            v2.price = t.price;
            v2.inv = t.inv;
            v2.fuelType = t.fuelType;
            ArrayList<Seat> seats = new ArrayList<Seat>();
            for (Seat s2 : t.seats) {
                Seat seat = new Seat();
                seat.offset = s2.offset;
                seat.parent = s2.parent;
                seat.seat = s2.seat;
                seat.steer = s2.steer;
                seats.add(seat);
            }
            v2.seats = seats;
            v2.skin = t.skin;
            v2.skinHolder = t.skinHolder;
            v2.spawnLoc = t.spawnLoc;
            v2.steering = t.steering;
            v2.turnSpeed = t.turnSpeed;
            v2.type = t.type;
            v2.upDown = t.upDown;
            isvalid = v2;
        }
    }
    return isvalid;
}
Also used : PacketPlayInSteerVehicle(net.minecraft.server.v1_12_R1.PacketPlayInSteerVehicle) Vehicle(me.legofreak107.vehicles.objects.Vehicle) Seat(me.legofreak107.vehicles.objects.Seat) ArrayList(java.util.ArrayList)

Aggregations

Vehicle (me.legofreak107.vehicles.objects.Vehicle)19 Seat (me.legofreak107.vehicles.objects.Seat)12 PacketPlayInSteerVehicle (net.minecraft.server.v1_12_R1.PacketPlayInSteerVehicle)11 ArmorStand (org.bukkit.entity.ArmorStand)10 EventHandler (org.bukkit.event.EventHandler)7 Vector (org.bukkit.util.Vector)7 VPPlayer (me.legofreak107.vehicles.objects.VPPlayer)6 EntityArmorStand (net.minecraft.server.v1_12_R1.EntityArmorStand)6 CraftArmorStand (org.bukkit.craftbukkit.v1_12_R1.entity.CraftArmorStand)6 Player (org.bukkit.entity.Player)6 ItemStack (org.bukkit.inventory.ItemStack)6 ArrayList (java.util.ArrayList)5 Location (org.bukkit.Location)5 Fuel (me.legofreak107.vehicles.objects.Fuel)4 BossBar (org.bukkit.boss.BossBar)3 Entity (org.bukkit.entity.Entity)3 Inventory (org.bukkit.inventory.Inventory)3 PlayerInventory (org.bukkit.inventory.PlayerInventory)3 EulerAngle (org.bukkit.util.EulerAngle)3 PlayerInteractAtEntity (me.legofreak107.vehicles.events.PlayerInteractAtEntity)2