use of org.bukkit.projectiles.ProjectileSource in project modules-extra by CubeEngine.
the class ListenerHanging method onItemRemove.
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onItemRemove(EntityDamageByEntityEvent event) {
Entity frame = event.getEntity();
if (frame instanceof ItemFrame) {
Entity causer;
if (event.getDamager() instanceof Projectile) {
ProjectileSource shooter = ((Projectile) event.getDamager()).getShooter();
if (shooter instanceof Entity) {
causer = (Entity) shooter;
} else {
// TODO other ProjectileSources
return;
}
} else {
causer = event.getDamager();
}
if (causer instanceof Player) {
ItemFrameItemRemove action = this.newAction(ItemFrameItemRemove.class, frame.getWorld());
if (action != null) {
action.setLocation(frame.getLocation());
action.setHanging(frame);
action.setPlayer((Player) causer);
action.item = ((ItemFrame) frame).getItem();
this.logAction(action);
}
} else {
// TODO
}
}
}
use of org.bukkit.projectiles.ProjectileSource in project askyblock by tastybento.
the class IslandGuard1_9 method EndCrystalDamage.
/**
* Handle end crystal damage by visitors
* @param e - event
*/
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void EndCrystalDamage(EntityDamageByEntityEvent e) {
if (e.getEntity() == null || !IslandGuard.inWorld(e.getEntity())) {
return;
}
if (!(e.getEntity() instanceof EnderCrystal)) {
return;
}
Player p = null;
if (e.getDamager() instanceof Player) {
p = (Player) e.getDamager();
} else if (e.getDamager() instanceof Projectile) {
// Get the shooter
Projectile projectile = (Projectile) e.getDamager();
ProjectileSource shooter = projectile.getShooter();
if (shooter instanceof Player) {
p = (Player) shooter;
}
}
if (p != null) {
if (p.isOp() || VaultHelper.checkPerm(p, Settings.PERMPREFIX + "mod.bypassprotect")) {
return;
}
// Check if on island
if (plugin.getGrid().playerIsOnIsland(p)) {
return;
}
// Check island
Island island = plugin.getGrid().getIslandAt(e.getEntity().getLocation());
if (island == null && Settings.defaultWorldSettings.get(SettingsFlag.BREAK_BLOCKS)) {
return;
}
if (island != null && island.getIgsFlag(SettingsFlag.BREAK_BLOCKS)) {
return;
}
Util.sendMessage(p, ChatColor.RED + plugin.myLocale(p.getUniqueId()).islandProtected);
e.setCancelled(true);
}
}
use of org.bukkit.projectiles.ProjectileSource in project AuthMeReloaded by AuthMe.
the class EntityListener method onProjectileLaunch.
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onProjectileLaunch(ProjectileLaunchEvent event) {
final Projectile projectile = event.getEntity();
ProjectileSource shooter = projectile.getShooter();
if (shooter instanceof Player && listenerService.shouldCancelEvent((Player) shooter)) {
event.setCancelled(true);
}
}
use of org.bukkit.projectiles.ProjectileSource in project Glowstone by GlowstoneMC.
the class AreaEffectCloudStore method save.
@Override
public void save(GlowAreaEffectCloud entity, CompoundTag tag) {
super.save(entity, tag);
tag.putInt("Age", entity.getTicksLived());
Color color = entity.getColor();
if (color != null) {
tag.putInt(COLOR, color.asRGB());
}
tag.putInt(DURATION, entity.getDuration());
tag.putInt(REAPPLICATION_DELAY, entity.getReapplicationDelay());
tag.putInt(WAIT_TIME, entity.getWaitTime());
ProjectileSource source = entity.getSource();
if (source instanceof Entity) {
UUID uuid = ((Entity) source).getUniqueId();
tag.putLong(OWNER_UUID_LEAST, uuid.getLeastSignificantBits());
tag.putLong(OWNER_UUID_MOST, uuid.getMostSignificantBits());
}
tag.putInt(DURATION_ON_USE, entity.getDurationOnUse());
tag.putFloat(RADIUS, entity.getRadius());
tag.putFloat(RADIUS_ON_USE, entity.getRadiusOnUse());
tag.putFloat(RADIUS_PER_TICK, entity.getRadiusPerTick());
Particle particle = entity.getParticle();
if (particle != null) {
tag.putString(PARTICLE, particle.toString());
}
PotionData potion = entity.getBasePotionData();
if (potion != null) {
tag.putString(POTION, GlowMetaPotion.dataToString(potion));
}
tag.putCompoundList(EFFECTS, entity.getCustomEffects().stream().map(GlowMetaPotion::toNbt).collect(Collectors.toList()));
// TODO: Are ParticleParam1 and ParticleParam2 unused?
}
use of org.bukkit.projectiles.ProjectileSource in project Glowstone by GlowstoneMC.
the class GlowFishingHook method setShooter.
@Override
public void setShooter(ProjectileSource shooter) {
ProjectileSource oldShooter = getShooter();
if (oldShooter == shooter) {
return;
}
// Shooter is immutable client-side (a situation peculiar to fishing hooks), so if it
// changes then all clients who can see this fishing hook must be told that this hook has
// despawned and a new one has spawned.
super.setShooter(shooter);
World world = location.getWorld();
if (world instanceof GlowWorld) {
List<Message> respawnMessages = new LinkedList<>();
DestroyEntitiesMessage destroyOldCopy = new DestroyEntitiesMessage(Collections.singletonList(getObjectId()));
respawnMessages.add(destroyOldCopy);
respawnMessages.addAll(createSpawnMessage(getShooterId()));
((GlowWorld) world).getRawPlayers().stream().filter(player -> !Objects.equal(player, shooter)).filter(player -> player.canSeeEntity(this)).forEach(player -> player.getSession().sendAll(respawnMessages.toArray(EMPTY_MESSAGE_ARRAY)));
if (shooter instanceof GlowPlayer) {
GlowSession session = ((GlowPlayer) shooter).getSession();
session.send(destroyOldCopy);
session.sendAll(createSpawnMessage(getEntityId()).toArray(EMPTY_MESSAGE_ARRAY));
}
}
}
Aggregations