use of org.bukkit.potion.PotionEffect in project MyPet by xXKeyleXx.
the class EntityMyPet method onLivingUpdate.
public void onLivingUpdate() {
if (hasRider) {
if (this.passenger == null || !(this.passenger instanceof EntityPlayer)) {
hasRider = false;
// climb height -> halfslab
this.S = 0.5F;
Location playerLoc = getOwner().getPlayer().getLocation();
Location petLoc = getBukkitEntity().getLocation();
petLoc.setYaw(playerLoc.getYaw());
petLoc.setPitch(playerLoc.getPitch());
getOwner().getPlayer().teleport(petLoc);
}
} else {
if (this.passenger != null) {
if (this.passenger instanceof EntityPlayer) {
if (getOwner().equals(this.passenger)) {
hasRider = true;
// climb height -> 1 block
this.S = 1.0F;
petTargetSelector.finish();
petPathfinderSelector.finish();
} else {
// just the owner can ride a pet
this.passenger.mount(null);
}
} else {
this.passenger.mount(null);
}
}
}
if (sitPathfinder.isSitting() && sitCounter-- <= 0) {
MyPetApi.getPlatformHelper().playParticleEffect(getOwner().getPlayer(), this.getBukkitEntity().getLocation().add(0, getHeadHeight() + 1, 0), "BARRIER", 0F, 0F, 0F, 5F, 1, 32);
sitCounter = 60;
}
Player p = myPet.getOwner().getPlayer();
if (p != null && p.isOnline() && !p.isDead()) {
if (p.isSneaking() != isSneaking()) {
this.setSneaking(!isSneaking());
}
if (Configuration.Misc.INVISIBLE_LIKE_OWNER) {
if (!isInvisible && p.hasPotionEffect(PotionEffectType.INVISIBILITY)) {
isInvisible = true;
getBukkitEntity().addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 1, false));
} else if (isInvisible && !p.hasPotionEffect(PotionEffectType.INVISIBILITY)) {
getBukkitEntity().removePotionEffect(PotionEffectType.INVISIBILITY);
isInvisible = false;
}
}
if (!this.isInvisible() && getOwner().getDonationRank() != DonateCheck.DonationRank.None && donatorParticleCounter-- <= 0) {
donatorParticleCounter = 20 + getRandom().nextInt(10);
MyPetApi.getPlatformHelper().playParticleEffect(this.getBukkitEntity().getLocation().add(0, 1, 0), "VILLAGER_HAPPY", 0.4F, 0.4F, 0.4F, 0.4F, 5, 10);
}
}
}
use of org.bukkit.potion.PotionEffect in project MyPet by xXKeyleXx.
the class EntityMyPet method onLivingUpdate.
public void onLivingUpdate() {
if (hasRider) {
if (!isVehicle()) {
hasRider = false;
// climb height -> halfslab
this.P = 0.5F;
Location playerLoc = getOwner().getPlayer().getLocation();
Location petLoc = getBukkitEntity().getLocation();
petLoc.setYaw(playerLoc.getYaw());
petLoc.setPitch(playerLoc.getPitch());
getOwner().getPlayer().teleport(petLoc);
}
} else {
if (isVehicle()) {
for (Entity e : passengers) {
if (e instanceof EntityPlayer && getOwner().equals(e)) {
hasRider = true;
// climb height -> 1 block
this.P = 1.0F;
petTargetSelector.finish();
petPathfinderSelector.finish();
} else {
// just the owner can ride a pet
e.stopRiding();
}
}
}
}
if (sitPathfinder.isSitting() && sitCounter-- <= 0) {
MyPetApi.getPlatformHelper().playParticleEffect(getOwner().getPlayer(), this.getBukkitEntity().getLocation().add(0, getHeadHeight() + 1, 0), "BARRIER", 0F, 0F, 0F, 5F, 1, 32);
sitCounter = 60;
}
Player p = myPet.getOwner().getPlayer();
if (p != null && p.isOnline() && !p.isDead()) {
if (p.isSneaking() != isSneaking()) {
this.setSneaking(!isSneaking());
}
if (Configuration.Misc.INVISIBLE_LIKE_OWNER) {
if (!isInvisible && p.hasPotionEffect(PotionEffectType.INVISIBILITY)) {
isInvisible = true;
getBukkitEntity().addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 1, false));
} else if (isInvisible && !p.hasPotionEffect(PotionEffectType.INVISIBILITY)) {
getBukkitEntity().removePotionEffect(PotionEffectType.INVISIBILITY);
isInvisible = false;
}
}
if (!this.isInvisible() && getOwner().getDonationRank() != DonateCheck.DonationRank.None && donatorParticleCounter-- <= 0) {
donatorParticleCounter = 20 + getRandom().nextInt(10);
MyPetApi.getPlatformHelper().playParticleEffect(this.getBukkitEntity().getLocation().add(0, 1, 0), "VILLAGER_HAPPY", 0.4F, 0.4F, 0.4F, 0.4F, 5, 10);
}
}
}
use of org.bukkit.potion.PotionEffect in project MyPet by xXKeyleXx.
the class EntityMyPet method onLivingUpdate.
public void onLivingUpdate() {
if (hasRider) {
if (!isVehicle()) {
hasRider = false;
// climb height -> halfslab
this.P = 0.5F;
Location playerLoc = getOwner().getPlayer().getLocation();
Location petLoc = getBukkitEntity().getLocation();
petLoc.setYaw(playerLoc.getYaw());
petLoc.setPitch(playerLoc.getPitch());
getOwner().getPlayer().teleport(petLoc);
}
} else {
if (isVehicle()) {
for (Entity e : passengers) {
if (e instanceof EntityPlayer && getOwner().equals(e)) {
hasRider = true;
// climb height -> 1 block
this.P = 1.0F;
petTargetSelector.finish();
petPathfinderSelector.finish();
} else {
// just the owner can ride a pet
e.stopRiding();
}
}
}
}
if (sitPathfinder.isSitting() && sitCounter-- <= 0) {
MyPetApi.getPlatformHelper().playParticleEffect(getOwner().getPlayer(), this.getBukkitEntity().getLocation().add(0, getHeadHeight() + 1, 0), "BARRIER", 0F, 0F, 0F, 5F, 1, 32);
sitCounter = 60;
}
Player p = myPet.getOwner().getPlayer();
if (p != null && p.isOnline() && !p.isDead()) {
if (p.isSneaking() != isSneaking()) {
this.setSneaking(!isSneaking());
}
if (Configuration.Misc.INVISIBLE_LIKE_OWNER) {
if (!isInvisible && p.hasPotionEffect(PotionEffectType.INVISIBILITY)) {
isInvisible = true;
getBukkitEntity().addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 1, false));
} else if (isInvisible && !p.hasPotionEffect(PotionEffectType.INVISIBILITY)) {
getBukkitEntity().removePotionEffect(PotionEffectType.INVISIBILITY);
isInvisible = false;
}
}
if (!this.isInvisible() && getOwner().getDonationRank() != DonateCheck.DonationRank.None && donatorParticleCounter-- <= 0) {
donatorParticleCounter = 20 + getRandom().nextInt(10);
MyPetApi.getPlatformHelper().playParticleEffect(this.getBukkitEntity().getLocation().add(0, 1, 0), "VILLAGER_HAPPY", 0.4F, 0.4F, 0.4F, 0.4F, 5, 10);
}
}
}
use of org.bukkit.potion.PotionEffect in project MyPet by xXKeyleXx.
the class EntityMyPet method onLivingUpdate.
public void onLivingUpdate() {
if (hasRider) {
if (!isVehicle()) {
hasRider = false;
// climb height -> halfslab
this.P = 0.5F;
Location playerLoc = getOwner().getPlayer().getLocation();
Location petLoc = getBukkitEntity().getLocation();
petLoc.setYaw(playerLoc.getYaw());
petLoc.setPitch(playerLoc.getPitch());
getOwner().getPlayer().teleport(petLoc);
}
} else {
if (isVehicle()) {
for (Entity e : passengers) {
if (e instanceof EntityPlayer && getOwner().equals(e)) {
hasRider = true;
// climb height -> 1 block
this.P = 1.0F;
petTargetSelector.finish();
petPathfinderSelector.finish();
} else {
// just the owner can ride a pet
e.stopRiding();
}
}
}
}
if (sitPathfinder.isSitting() && sitCounter-- <= 0) {
MyPetApi.getPlatformHelper().playParticleEffect(getOwner().getPlayer(), this.getBukkitEntity().getLocation().add(0, getHeadHeight() + 1, 0), "BARRIER", 0F, 0F, 0F, 5F, 1, 32);
sitCounter = 60;
}
Player p = myPet.getOwner().getPlayer();
if (p != null && p.isOnline() && !p.isDead()) {
if (p.isSneaking() != isSneaking()) {
this.setSneaking(!isSneaking());
}
if (Configuration.Misc.INVISIBLE_LIKE_OWNER) {
if (!isInvisible && p.hasPotionEffect(PotionEffectType.INVISIBILITY)) {
isInvisible = true;
getBukkitEntity().addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 1, false));
} else if (isInvisible && !p.hasPotionEffect(PotionEffectType.INVISIBILITY)) {
getBukkitEntity().removePotionEffect(PotionEffectType.INVISIBILITY);
isInvisible = false;
}
}
if (!this.isInvisible() && getOwner().getDonationRank() != DonateCheck.DonationRank.None && donatorParticleCounter-- <= 0) {
donatorParticleCounter = 20 + getRandom().nextInt(10);
MyPetApi.getPlatformHelper().playParticleEffect(this.getBukkitEntity().getLocation().add(0, 1, 0), "VILLAGER_HAPPY", 0.4F, 0.4F, 0.4F, 0.4F, 5, 10);
}
}
}
use of org.bukkit.potion.PotionEffect in project MyPet by xXKeyleXx.
the class Beacon method schedule.
public void schedule() {
if (myPet.getStatus() == MyPet.PetState.Here && isActive() && active && selectedBuffs.size() != 0 && --beaconTimer <= 0) {
beaconTimer = 2;
double range = this.range;
if (Configuration.HungerSystem.USE_HUNGER_SYSTEM && Configuration.HungerSystem.AFFECT_BEACON_RANGE) {
range *= (Math.log10(myPet.getSaturation()) / 2);
}
if (range < 0.7) {
return;
}
range = range * range;
if (selectedBuffs.size() > selectableBuffs) {
int usableBuff = 0;
for (int buff : selectedBuffs) {
if (buffLevel.get(buff) > 0) {
usableBuff = buff;
}
}
selectedBuffs.clear();
if (usableBuff != 0) {
selectedBuffs.add(usableBuff);
}
}
if (selectedBuffs.size() == 0) {
return;
}
MyPetApi.getPlatformHelper().playParticleEffect(myPet.getLocation().get().add(0, 1, 0), "SPELL_WITCH", 0.2F, 0.2F, 0.2F, 0.1F, 5, 20);
List<Player> members = null;
if (Configuration.Skilltree.Skill.Beacon.PARTY_SUPPORT && receiver == BeaconReceiver.Party) {
members = MyPetApi.getHookHelper().getPartyMembers(getMyPet().getOwner().getPlayer());
}
int duration = this.duration * 20;
List<PotionEffect> potionEffects = new ArrayList<>();
for (int buff : selectedBuffs) {
int amplification = buffLevel.get(buff) - 1;
PotionEffect effect = new PotionEffect(PotionEffectType.getById(buff), duration, amplification, true, true);
potionEffects.add(effect);
}
Location myPetLocation = this.myPet.getLocation().get();
targetLoop: for (Player player : myPetLocation.getWorld().getPlayers()) {
if (MyPetApi.getPlatformHelper().distanceSquared(player.getLocation(), myPetLocation) > range) {
continue;
}
switch(receiver) {
case Owner:
if (!myPet.getOwner().equals(player)) {
continue targetLoop;
} else {
for (PotionEffect effect : potionEffects) {
player.addPotionEffect(effect, true);
}
MyPetApi.getPlatformHelper().playParticleEffect(player.getLocation().add(0, 1, 0), "SPELL_INSTANT", 0.2F, 0.2F, 0.2F, 0.1F, 5, 20);
break targetLoop;
}
case Everyone:
for (PotionEffect effect : potionEffects) {
player.addPotionEffect(effect, true);
}
MyPetApi.getPlatformHelper().playParticleEffect(player.getLocation().add(0, 1, 0), "SPELL_INSTANT", 0.2F, 0.2F, 0.2F, 0.1F, 5, 20);
break;
case Party:
if (Configuration.Skilltree.Skill.Beacon.PARTY_SUPPORT && members != null) {
if (members.contains(player)) {
for (PotionEffect effect : potionEffects) {
player.addPotionEffect(effect, true);
}
MyPetApi.getPlatformHelper().playParticleEffect(player.getLocation().add(0, 1, 0), "SPELL_INSTANT", 0.2F, 0.2F, 0.2F, 0.1F, 5, 20);
}
break;
} else {
receiver = BeaconReceiver.Owner;
break targetLoop;
}
}
}
if (Configuration.HungerSystem.USE_HUNGER_SYSTEM && Configuration.Skilltree.Skill.Beacon.HUNGER_DECREASE_TIME > 0 && hungerDecreaseTimer-- < 0) {
myPet.decreaseSaturation(1);
hungerDecreaseTimer = Configuration.Skilltree.Skill.Beacon.HUNGER_DECREASE_TIME;
}
}
}
Aggregations