use of net.minecraft.server.v1_12_R1.Entity in project VehiclesPlus2.0 by legofreak107.
the class Main method onEnable.
@Override
public void onEnable() {
ChunkUnload cu = new ChunkUnload(this);
EntityDamage ed = new EntityDamage(this);
EntityDismount edi = new EntityDismount(this);
InventoryClick ic = new InventoryClick(this);
InventoryClose icl = new InventoryClose(this, ic);
PlayerDropItem pdi = new PlayerDropItem(this);
PlayerInteract pi = new PlayerInteract(this);
PlayerInteractAtEntity piae = new PlayerInteractAtEntity(this);
PlayerJoin pj = new PlayerJoin(this);
PlayerQuit pq = new PlayerQuit(this);
SignChange sc = new SignChange(this);
VehicleExit ve = new VehicleExit(this);
Bukkit.getPluginManager().registerEvents(cu, this);
Bukkit.getPluginManager().registerEvents(ed, this);
Bukkit.getPluginManager().registerEvents(edi, this);
Bukkit.getPluginManager().registerEvents(ic, this);
Bukkit.getPluginManager().registerEvents(icl, this);
Bukkit.getPluginManager().registerEvents(pdi, this);
Bukkit.getPluginManager().registerEvents(pi, this);
Bukkit.getPluginManager().registerEvents(piae, this);
Bukkit.getPluginManager().registerEvents(pj, this);
Bukkit.getPluginManager().registerEvents(pq, this);
Bukkit.getPluginManager().registerEvents(sc, this);
Bukkit.getPluginManager().registerEvents(ve, this);
if (getCustomSettingsConfig().contains("Garage.maxCarsSpawnedPerPlayer")) {
maxCars = getCustomSettingsConfig().getInt("Garage.maxCarsSpawnedPerPlayer");
} else {
getCustomSettingsConfig().set("Garage.maxCarsSpawnedPerPlayer", 3);
saveCustomSettingsConfig();
}
if (getCustomSettingsConfig().contains("Items.upgrades")) {
repairMenuItem = genItem(getCustomSettingsConfig().getInt("Items.upgrades.repairMenuItem.id"), Short.parseShort(getCustomSettingsConfig().get("Items.upgrades.repairMenuItem.data").toString()), getCustomSettingsConfig().getBoolean("Items.upgrades.repairMenuItem.unbreakable"));
upgradeMenuItem = genItem(getCustomSettingsConfig().getInt("Items.upgrades.upgradeMenuItem.id"), Short.parseShort(getCustomSettingsConfig().get("Items.upgrades.upgradeMenuItem.data").toString()), getCustomSettingsConfig().getBoolean("Items.upgrades.upgradeMenuItem.unbreakable"));
engineUpgradeItem = genItem(getCustomSettingsConfig().getInt("Items.upgrades.engineUpgradeItem.id"), Short.parseShort(getCustomSettingsConfig().get("Items.upgrades.engineUpgradeItem.data").toString()), getCustomSettingsConfig().getBoolean("Items.upgrades.engineUpgradeItem.unbreakable"));
steeringUpgradeItem = genItem(getCustomSettingsConfig().getInt("Items.upgrades.steeringUpgradeItem.id"), Short.parseShort(getCustomSettingsConfig().get("Items.upgrades.steeringUpgradeItem.data").toString()), getCustomSettingsConfig().getBoolean("Items.upgrades.steeringUpgradeItem.unbreakable"));
gearboxUpgradeItem = genItem(getCustomSettingsConfig().getInt("Items.upgrades.gearboxUpgradeItem.id"), Short.parseShort(getCustomSettingsConfig().get("Items.upgrades.gearboxUpgradeItem.data").toString()), getCustomSettingsConfig().getBoolean("Items.upgrades.gearboxUpgradeItem.unbreakable"));
fuelUpgradeItem = genItem(getCustomSettingsConfig().getInt("Items.upgrades.fuelUpgradeItem.id"), Short.parseShort(getCustomSettingsConfig().get("Items.upgrades.fuelUpgradeItem.data").toString()), getCustomSettingsConfig().getBoolean("Items.upgrades.fuelUpgradeItem.unbreakable"));
engineRepairItem = genItem(getCustomSettingsConfig().getInt("Items.upgrades.engineRepairItem.id"), Short.parseShort(getCustomSettingsConfig().get("Items.upgrades.engineRepairItem.data").toString()), getCustomSettingsConfig().getBoolean("Items.upgrades.engineRepairItem.unbreakable"));
wheelRepairItem = genItem(getCustomSettingsConfig().getInt("Items.upgrades.wheelRepairItem.id"), Short.parseShort(getCustomSettingsConfig().get("Items.upgrades.wheelRepairItem.data").toString()), getCustomSettingsConfig().getBoolean("Items.upgrades.wheelRepairItem.unbreakable"));
} else {
getCustomSettingsConfig().set("Items.upgrades.repairMenuItem.id", 1);
getCustomSettingsConfig().set("Items.upgrades.repairMenuItem.data", 0);
getCustomSettingsConfig().set("Items.upgrades.repairMenuItem.unbreakable", false);
getCustomSettingsConfig().set("Items.upgrades.upgradeMenuItem.id", 1);
getCustomSettingsConfig().set("Items.upgrades.upgradeMenuItem.data", 0);
getCustomSettingsConfig().set("Items.upgrades.upgradeMenuItem.unbreakable", false);
getCustomSettingsConfig().set("Items.upgrades.engineUpgradeItem.id", 1);
getCustomSettingsConfig().set("Items.upgrades.engineUpgradeItem.data", 0);
getCustomSettingsConfig().set("Items.upgrades.engineUpgradeItem.unbreakable", false);
getCustomSettingsConfig().set("Items.upgrades.steeringUpgradeItem.id", 1);
getCustomSettingsConfig().set("Items.upgrades.steeringUpgradeItem.data", 0);
getCustomSettingsConfig().set("Items.upgrades.steeringUpgradeItem.unbreakable", false);
getCustomSettingsConfig().set("Items.upgrades.gearboxUpgradeItem.id", 1);
getCustomSettingsConfig().set("Items.upgrades.gearboxUpgradeItem.data", 0);
getCustomSettingsConfig().set("Items.upgrades.gearboxUpgradeItem.unbreakable", false);
getCustomSettingsConfig().set("Items.upgrades.fuelUpgradeItem.id", 1);
getCustomSettingsConfig().set("Items.upgrades.fuelUpgradeItem.data", 0);
getCustomSettingsConfig().set("Items.upgrades.fuelUpgradeItem.unbreakable", false);
getCustomSettingsConfig().set("Items.upgrades.engineRepairItem.id", 1);
getCustomSettingsConfig().set("Items.upgrades.engineRepairItem.data", 0);
getCustomSettingsConfig().set("Items.upgrades.engineRepairItem.unbreakable", false);
getCustomSettingsConfig().set("Items.upgrades.wheelRepairItem.id", 1);
getCustomSettingsConfig().set("Items.upgrades.wheelRepairItem.data", 0);
getCustomSettingsConfig().set("Items.upgrades.wheelRepairItem.unbreakable", false);
repairMenuItem = new ItemStack(Material.STONE, 1);
upgradeMenuItem = new ItemStack(Material.STONE, 1);
engineUpgradeItem = new ItemStack(Material.STONE, 1);
steeringUpgradeItem = new ItemStack(Material.STONE, 1);
gearboxUpgradeItem = new ItemStack(Material.STONE, 1);
fuelUpgradeItem = new ItemStack(Material.STONE, 1);
engineRepairItem = new ItemStack(Material.STONE, 1);
wheelRepairItem = new ItemStack(Material.STONE, 1);
saveCustomSettingsConfig();
}
Bukkit.getPluginManager().registerEvents(this, this);
if (!setupEconomy()) {
this.getLogger().severe("Disabled due to no Vault dependency found!");
Bukkit.getPluginManager().disablePlugin(this);
return;
}
ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager();
Bike.plugin = this;
Plane.plugin = this;
Car.plugin = this;
Helicopter.plugin = this;
Boat.plugin = this;
sal.plugin = this;
enable();
protocolManager.addPacketListener(new PacketAdapter(this, ListenerPriority.LOWEST, PacketType.Play.Client.STEER_VEHICLE) {
@Override
public void onPacketReceiving(PacketEvent event) {
if (event.getPacketType().equals(PacketType.Play.Client.STEER_VEHICLE)) {
PacketPlayInSteerVehicle ppisv = (PacketPlayInSteerVehicle) event.getPacket().getHandle();
for (Seat s2 : seatInfo.values()) {
ArmorStand vp = s2.parent;
Location locvp = vp.getLocation().clone();
Location fbvp = locvp.add(locvp.getDirection().setY(0).normalize().multiply(s2.offset.getX()));
float zvp = (float) (fbvp.getZ() + (s2.offset.getZ() * Math.sin(Math.toRadians(fbvp.getYaw() + 90 * 0))));
float xvp = (float) (fbvp.getX() + (s2.offset.getZ() * Math.cos(Math.toRadians(fbvp.getYaw() + 90 * 0))));
Vehicle v = vehicleInfo.get(vp);
EntityArmorStand seat = ((CraftArmorStand) s2.seat).getHandle();
seat.setLocation(xvp, vp.getLocation().getY() + s2.offset.getY(), zvp, fbvp.getYaw(), fbvp.getPitch());
EntityArmorStand s3 = ((CraftArmorStand) v.skinHolder).getHandle();
s3.setLocation(vp.getLocation().getX(), vp.getLocation().getY(), vp.getLocation().getZ(), fbvp.getYaw(), fbvp.getPitch());
}
Player p = event.getPlayer();
if (p.getVehicle() instanceof ArmorStand) {
ArmorStand a = (ArmorStand) p.getVehicle();
if (seatInfo.containsKey(a)) {
Seat s = seatInfo.get(a);
if (s.steer) {
ArmorStand a2 = s.parent;
Vehicle v = vehicleInfo.get(a2);
if (v.type == VehicleType.CAR) {
Car.Car(ppisv, p);
} else if (v.type == VehicleType.PLANE) {
Plane.Plane(ppisv, p);
} else if (v.type == VehicleType.BIKE) {
Bike.Bike(ppisv, p);
} else if (v.type == VehicleType.HELICOPTER) {
Helicopter.Helicopter(ppisv, p);
} else if (v.type == VehicleType.BOAT) {
Boat.Boat(ppisv, p);
}
}
}
}
}
}
});
Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
public void run() {
for (Vehicle v : vehicleInfo.values()) {
if (v.type == VehicleType.CAR) {
for (Seat s : v.seats) {
for (Entity e : s.seat.getPassengers()) {
if (e instanceof Player) {
return;
}
}
}
Car.CarNonDriveable(v);
}
}
for (Seat s2 : seatInfo.values()) {
ArmorStand vp = s2.parent;
Location locvp = vp.getLocation().clone();
Location fbvp = locvp.add(locvp.getDirection().setY(0).normalize().multiply(s2.offset.getX()));
float zvp = (float) (fbvp.getZ() + (s2.offset.getZ() * Math.sin(Math.toRadians(fbvp.getYaw() + 90 * 0))));
float xvp = (float) (fbvp.getX() + (s2.offset.getZ() * Math.cos(Math.toRadians(fbvp.getYaw() + 90 * 0))));
EntityArmorStand seat = ((CraftArmorStand) s2.seat).getHandle();
seat.setLocation(xvp, vp.getLocation().getY() + s2.offset.getY(), zvp, fbvp.getYaw(), fbvp.getPitch());
Vehicle v = vehicleInfo.get(vp);
if (v.holder.getLocation().getBlock().getType() == Material.STATIONARY_WATER && v.type != VehicleType.BOAT) {
v.setHealth(0);
} else if (v.holder.getLocation().getBlock().getType() == Material.STATIONARY_WATER && v.type == VehicleType.BOAT) {
v.holder.setGravity(false);
}
EntityArmorStand s3 = ((CraftArmorStand) v.skinHolder).getHandle();
s3.setLocation(vp.getLocation().getX(), vp.getLocation().getY(), vp.getLocation().getZ(), fbvp.getYaw(), fbvp.getPitch());
}
}
}, 0L, 1L);
}
use of net.minecraft.server.v1_12_R1.Entity in project solinia3-core by mixxit.
the class SoliniaActiveSpell method applyCurrentHpOnceSpellEffect.
private void applyCurrentHpOnceSpellEffect(SpellEffect spellEffect, ISoliniaSpell soliniaSpell, int caster_level) {
if (getLivingEntity().isDead())
return;
if (Bukkit.getEntity(getSourceUuid()) == null)
return;
Entity sourceEntity = Bukkit.getEntity(getSourceUuid());
if (sourceEntity == null)
return;
if (!(sourceEntity instanceof LivingEntity))
return;
LivingEntity sourceLivingEntity = (LivingEntity) sourceEntity;
int instrument_mod = 0;
try {
ISoliniaLivingEntity sourceSoliniaLivingEntity = SoliniaLivingEntityAdapter.Adapt(sourceLivingEntity);
if (sourceSoliniaLivingEntity != null) {
instrument_mod = sourceSoliniaLivingEntity.getInstrumentMod(this.getSpell());
}
} catch (CoreStateInitException e) {
// just skip it
}
// HP spells also get calculated based on the caster and the recipient
int hpToAdd = soliniaSpell.calcSpellEffectValue(spellEffect, sourceLivingEntity, getLivingEntity(), caster_level, getTicksLeft(), instrument_mod);
// hpToRemove should really be called hpToAdd
if (hpToAdd < 0) {
// Criticals
try {
ISoliniaLivingEntity sourceSoliniaLivingEntity = SoliniaLivingEntityAdapter.Adapt(sourceLivingEntity);
ISoliniaLivingEntity targetSoliniaLivingEntity = SoliniaLivingEntityAdapter.Adapt(getLivingEntity());
if (sourceSoliniaLivingEntity != null && targetSoliniaLivingEntity != null) {
// reverse to positive then pass it back reversed
hpToAdd = (sourceSoliniaLivingEntity.getActSpellDamage(soliniaSpell, (hpToAdd * -1), spellEffect, targetSoliniaLivingEntity) * -1);
}
} catch (CoreStateInitException e) {
// just carry on without the crit bonus
}
hpToAdd = hpToAdd * -1;
EntityDamageSource source = new EntityDamageSource("thorns", ((CraftEntity) Bukkit.getEntity(getSourceUuid())).getHandle());
source.setMagic();
source.ignoresArmor();
((CraftEntity) getLivingEntity()).getHandle().damageEntity(source, hpToAdd);
// getLivingEntity().damage(hpToRemove, Bukkit.getEntity(getSourceUuid()));
if (soliniaSpell.isLifetapSpell()) {
if (!(sourceEntity instanceof LivingEntity))
return;
int amount = (int) Math.round(sourceLivingEntity.getHealth()) + hpToAdd;
if (amount > sourceLivingEntity.getMaxHealth()) {
amount = (int) Math.round(sourceLivingEntity.getMaxHealth());
}
if (amount < 0)
amount = 0;
sourceLivingEntity.setHealth(amount);
}
} else // Heal
{
// Criticals
try {
ISoliniaLivingEntity sourceSoliniaLivingEntity = SoliniaLivingEntityAdapter.Adapt(sourceLivingEntity);
ISoliniaLivingEntity targetSoliniaLivingEntity = SoliniaLivingEntityAdapter.Adapt(getLivingEntity());
if (sourceSoliniaLivingEntity != null && targetSoliniaLivingEntity != null) {
hpToAdd = sourceSoliniaLivingEntity.getActSpellHealing(soliniaSpell, hpToAdd, spellEffect, targetSoliniaLivingEntity);
}
} catch (CoreStateInitException e) {
// just carry on without the crit bonus
}
int amount = (int) Math.round(getLivingEntity().getHealth()) + hpToAdd;
if (amount > getLivingEntity().getMaxHealth()) {
amount = (int) Math.round(getLivingEntity().getMaxHealth());
}
if (amount < 0)
amount = 0;
getLivingEntity().setHealth(amount);
}
}
use of net.minecraft.server.v1_12_R1.Entity in project solinia3-core by mixxit.
the class SoliniaActiveSpell method apply.
public void apply(Plugin plugin) {
try {
ISoliniaSpell soliniaSpell = StateManager.getInstance().getConfigurationManager().getSpell(getSpellId());
if (soliniaSpell == null) {
System.out.print("Spell not found");
return;
}
Entity sourceEntity = Bukkit.getEntity(this.getSourceUuid());
if (sourceEntity == null || (!(sourceEntity instanceof LivingEntity)))
return;
ISoliniaLivingEntity solsource = SoliniaLivingEntityAdapter.Adapt((LivingEntity) sourceEntity);
if (solsource == null)
return;
if (isFirstRun) {
if (soliniaSpell.getCastOnYou() != null && !soliniaSpell.getCastOnYou().equals("") && isOwnerPlayer) {
Player player = Bukkit.getPlayer(getOwnerUuid());
player.sendMessage("* " + ChatColor.GRAY + soliniaSpell.getCastOnYou());
}
if (soliniaSpell.getCastOnOther() != null && !soliniaSpell.getCastOnOther().equals(""))
SoliniaLivingEntityAdapter.Adapt((LivingEntity) Bukkit.getEntity(getOwnerUuid())).emote(ChatColor.GRAY + "* " + this.getLivingEntity().getName() + soliniaSpell.getCastOnOther());
}
for (ActiveSpellEffect spellEffect : getActiveSpellEffects()) {
applySpellEffect(plugin, spellEffect, soliniaSpell, isFirstRun, solsource.getLevel());
}
} catch (CoreStateInitException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
use of net.minecraft.server.v1_12_R1.Entity in project solinia3-core by mixxit.
the class SoliniaActiveSpell method applySenseAnimal.
private void applySenseAnimal(SpellEffect spellEffect, ISoliniaSpell soliniaSpell, int casterLevel) {
try {
for (Entity e : this.getLivingEntity().getNearbyEntities(100, 100, 100)) {
if (!(e instanceof LivingEntity))
continue;
ISoliniaLivingEntity solEntity = SoliniaLivingEntityAdapter.Adapt((LivingEntity) e);
if (!solEntity.isAnimal())
continue;
Vector dir = ((LivingEntity) e).getLocation().clone().subtract(getLivingEntity().getEyeLocation()).toVector();
Location loc = getLivingEntity().getLocation().setDirection(dir);
getLivingEntity().teleport(loc);
return;
}
} catch (CoreStateInitException e) {
}
}
use of net.minecraft.server.v1_12_R1.Entity in project solinia3-core by mixxit.
the class SoliniaActiveSpell method applyMezSpellEffect.
private void applyMezSpellEffect(SpellEffect spellEffect, ISoliniaSpell soliniaSpell, int casterLevel) {
if (!(getLivingEntity() instanceof LivingEntity))
return;
try {
LocalDateTime datetime = LocalDateTime.now();
Timestamp expiretimestamp = Timestamp.valueOf(datetime.plus(6, ChronoUnit.SECONDS));
StateManager.getInstance().getEntityManager().addMezzed(getLivingEntity(), expiretimestamp);
if (getLivingEntity() instanceof Creature) {
Creature creature = (Creature) getLivingEntity();
creature.setTarget(null);
}
Utils.dismountEntity(getLivingEntity());
Entity vehicle = getLivingEntity().getVehicle();
if (vehicle != null) {
vehicle.eject();
}
Utils.AddPotionEffect(getLivingEntity(), PotionEffectType.SLOW, 10);
Utils.AddPotionEffect(getLivingEntity(), PotionEffectType.CONFUSION, 1);
} catch (CoreStateInitException e) {
return;
}
}
Aggregations