use of me.legofreak107.vehicles.objects.Vehicle in project VehiclesPlus2.0 by legofreak107.
the class EntityDamage method onDamage.
@EventHandler
public void onDamage(EntityDamageByEntityEvent e) {
if (e.getEntity() instanceof ArmorStand && plugin.seatInfo.containsKey(e.getEntity())) {
Vehicle v = plugin.vehicleInfo.get(plugin.seatInfo.get(e.getEntity()).parent);
e.setCancelled(true);
v.damage(10);
}
}
use of me.legofreak107.vehicles.objects.Vehicle in project VehiclesPlus2.0 by legofreak107.
the class SaveAndLoad method loadVehicles.
public Vehicle loadVehicles(String name) {
Vehicle v = new Vehicle();
ItemStack item = new ItemStack(Material.AIR, 1, (Short) Short.parseShort(plugin.getConfig().get("Vehicles." + name + ".skin.data").toString()));
item.setTypeId((int) plugin.getConfig().get("Vehicles." + name + ".skin.material"));
item.getItemMeta().setUnbreakable(plugin.getConfig().getBoolean("Vehicles." + name + ".skin.unbreakable"));
v.skin = item;
v.name = name;
v.fspeed = Float.parseFloat(plugin.getConfig().get("Vehicles." + name + ".forwardspeed").toString());
v.bspeed = Float.parseFloat(plugin.getConfig().get("Vehicles." + name + ".backwardspeed").toString());
v.acceleration = Float.parseFloat(plugin.getConfig().get("Vehicles." + name + ".acceleration").toString());
v.maxFuel = Float.parseFloat(plugin.getConfig().get("Vehicles." + name + ".maxFuel").toString());
v.fualUsage = Float.parseFloat(plugin.getConfig().get("Vehicles." + name + ".fuelUsage").toString());
v.turnSpeed = Float.parseFloat(plugin.getConfig().get("Vehicles." + name + ".turnSpeed").toString());
v.type = plugin.getType((String) plugin.getConfig().get("Vehicles." + name + ".type"));
v.locked = false;
v.price = plugin.getConfig().getInt("Vehicles." + name + ".price");
v.maxHealth = plugin.getConfig().getInt("Vehicles." + name + ".maxHealth");
Fuel f = plugin.getFuel((String) plugin.getConfig().get("Vehicles." + name + ".fuelType"));
if (f != null) {
v.fuelType = f;
} else {
Bukkit.broadcastMessage("Error loading fuel!");
}
Inventory inv = Bukkit.createInventory(null, plugin.getConfig().getInt("Vehicles." + name + ".trunk.size"), "�2" + v.name);
v.inv = inv;
ArrayList<Seat> si = new ArrayList<Seat>();
for (int i = 0; i < plugin.getConfig().getInt("Vehicles." + name + ".seats"); i++) {
Seat s = new Seat();
s.offset = new Vector(Float.parseFloat(plugin.getConfig().get("Vehicles." + name + ".seat" + i + ".offsetX").toString()), Float.parseFloat(plugin.getConfig().get("Vehicles." + name + ".seat" + i + ".offsetY").toString()), Float.parseFloat(plugin.getConfig().get("Vehicles." + name + ".seat" + i + ".offsetZ").toString()));
s.steer = (Boolean) plugin.getConfig().get("Vehicles." + name + ".seat" + i + ".steer");
si.add(s);
}
v.seats = si;
return v;
}
use of me.legofreak107.vehicles.objects.Vehicle in project VehiclesPlus2.0 by legofreak107.
the class ChunkUnload method onChunkUnload.
@EventHandler
public void onChunkUnload(ChunkUnloadEvent e) {
for (Entity en : e.getChunk().getEntities()) {
if (en instanceof ArmorStand) {
if (plugin.vehicleInfo.containsKey(en)) {
Vehicle v = plugin.vehicleInfo.get(en);
v.p.p.getInventory().removeItem(plugin.keys.get(v));
v.remove();
v.holder.remove();
v.holder = null;
}
}
}
}
use of me.legofreak107.vehicles.objects.Vehicle in project VehiclesPlus2.0 by legofreak107.
the class EntityDismount method onLeave.
@EventHandler
public void onLeave(EntityDismountEvent e) {
if (e.getDismounted() instanceof ArmorStand) {
if (plugin.seatInfo.containsKey(e)) {
if (e.getDismounted().getLocation().getBlock().getType() == Material.STATIONARY_WATER)
e.getDismounted().addPassenger(e.getEntity());
}
}
if (plugin.seatInfo.containsKey(e.getDismounted())) {
Vehicle v = plugin.vehicleInfo.get(plugin.seatInfo.get(e.getDismounted()).parent);
Seat s = plugin.seatInfo.get(e.getDismounted());
if (v.locked) {
if (((Player) e.getEntity()).getInventory().getItemInMainHand().hasItemMeta() && ((Player) e.getEntity()).getInventory().getItemInMainHand().getItemMeta().getDisplayName().contains("key")) {
String vpname = ((Player) e.getEntity()).getInventory().getItemInMainHand().getItemMeta().getDisplayName().replace("�2", "").replace(" key", "");
if (plugin.isValidVehicle(vpname)) {
if (v.name.equalsIgnoreCase(vpname) && v.owner.contains(e.getEntity().getName())) {
} else {
s.seat.addPassenger(e.getEntity());
}
} else {
s.seat.addPassenger(e.getEntity());
}
} else {
s.seat.addPassenger(e.getEntity());
}
} else {
if (v.fuelbar != null && v.fuelbar.getPlayers().contains(e.getEntity())) {
v.fuelbar.removePlayer((Player) e.getEntity());
v.fuelbar.removeAll();
v.fuelbar.setVisible(false);
}
}
}
}
Aggregations