本文整理汇总了Java中org.bukkit.entity.Projectile.remove方法的典型用法代码示例。如果您正苦于以下问题:Java Projectile.remove方法的具体用法?Java Projectile.remove怎么用?Java Projectile.remove使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.entity.Projectile
的用法示例。
在下文中一共展示了Projectile.remove方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onProjectileHit
import org.bukkit.entity.Projectile; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOW)
public void onProjectileHit(ProjectileHitEvent event)
{
if(event.getEntityType() != EntityType.ARROW && event.getEntityType() != EntityType.SNOWBALL) return;
Projectile arrow = event.getEntity();
ProjectileSource source = arrow.getShooter();
if(source == null || !(source instanceof Player)) return;
Player player = (Player)source;
if(player.getGameMode() == GameMode.CREATIVE) return;
Flag flag = this.GetFlagInstanceAtLocation(arrow.getLocation(), player);
if(flag == null) return;
PlayerInventory inventory = player.getInventory();
ItemMeta meta = inventory.getItemInMainHand().getItemMeta();
if(meta != null && meta.hasEnchant(Enchantment.ARROW_INFINITE)) return;
arrow.remove();
inventory.addItem(new ItemStack(Material.ARROW));
}
示例2: onProjectileLaunch
import org.bukkit.entity.Projectile; //导入方法依赖的package包/类
@EventHandler
public void onProjectileLaunch(ProjectileLaunchEvent event) {
Projectile entity = event.getEntity();
if (!(entity instanceof ThrownPotion)) {
return;
}
ProjectileSource shooter = entity.getShooter();
if (!(shooter instanceof Player)) {
return;
}
Location l = BukkitUtil.getLocation(entity);
if (!PS.get().hasPlotArea(l.getWorld())) {
return;
}
PlotPlayer pp = BukkitUtil.getPlayer((Player) shooter);
Plot plot = l.getOwnedPlot();
if (plot != null && !plot.isAdded(pp.getUUID())) {
entity.remove();
event.setCancelled(true);
}
}
示例3: onProjectileHitEvent
import org.bukkit.entity.Projectile; //导入方法依赖的package包/类
@EventHandler
public void onProjectileHitEvent(ProjectileHitEvent event) {
final Projectile projectile = event.getEntity();
final ProjectileDefinition projectileDefinition = Projectiles.getProjectileDefinition(projectile);
if(projectileDefinition == null) return;
final Filter filter = projectileDefinition.destroyFilter();
if(filter == null) return;
final BlockIterator blockIterator = new BlockIterator(projectile.getWorld(), projectile.getLocation().toVector(), projectile.getVelocity().normalize(), 0d, 2);
Block hitBlock = null;
while(blockIterator.hasNext()) {
hitBlock = blockIterator.next();
if(hitBlock.getType() != Material.AIR) break;
}
if(hitBlock != null) {
final MatchPlayer shooter = projectile.getShooter() instanceof Player ? getMatch().getPlayer((Player) projectile.getShooter()) : null;
final IQuery query = shooter != null ? new PlayerBlockEventQuery(shooter, event, hitBlock.getState())
: new BlockEventQuery(event, hitBlock);
if(filter.query(query).isAllowed()) {
final BlockTransformEvent bte = new BlockTransformEvent(event, hitBlock, Material.AIR);
match.callEvent(bte);
if(!bte.isCancelled()) {
hitBlock.setType(Material.AIR);
projectile.remove();
}
}
}
}
示例4: onTNTPrimed
import org.bukkit.entity.Projectile; //导入方法依赖的package包/类
/**
* Trap TNT being primed by flaming arrows
* @param e
*/
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onTNTPrimed(final EntityChangeBlockEvent e) {
if (DEBUG) {
plugin.getLogger().info(e.getEventName());
plugin.getLogger().info("DEBUG: block = " + e.getBlock().getType());
plugin.getLogger().info("DEBUG: entity = " + e.getEntityType());
plugin.getLogger().info("DEBUG: material changing to " + e.getTo());
}
if (actionAllowed(e.getEntity().getLocation(), SettingsFlag.FIRE)) {
return;
}
if (e.getBlock() == null) {
return;
}
// Check for TNT
if (!e.getBlock().getType().equals(Material.TNT)) {
//plugin.getLogger().info("DEBUG: not tnt");
return;
}
// Check world
if (!Util.inWorld(e.getBlock())) {
return;
}
// Check if this is on an island
Island island = plugin.getIslands().getIslandAt(e.getBlock().getLocation());
if (island == null || island.isSpawn()) {
return;
}
// Stop TNT from being damaged if it is being caused by a visitor with a flaming arrow
if (e.getEntity() instanceof Projectile) {
//plugin.getLogger().info("DEBUG: projectile");
Projectile projectile = (Projectile) e.getEntity();
// Find out who fired it
if (projectile.getShooter() instanceof Player) {
//plugin.getLogger().info("DEBUG: player shot arrow. Fire ticks = " + projectile.getFireTicks());
if (projectile.getFireTicks() > 0) {
//plugin.getLogger().info("DEBUG: arrow on fire");
Player shooter = (Player)projectile.getShooter();
if (!plugin.getIslands().locationIsAtHome(shooter, true, e.getBlock().getLocation())) {
//plugin.getLogger().info("DEBUG: shooter is not at home");
// Only say it once a second
// Debounce event (it can be called twice for the same action)
if (!tntBlocks.contains(e.getBlock().getLocation())) {
Util.sendMessage(shooter, plugin.getLocale(shooter.getUniqueId()).get("island.protected"));
tntBlocks.add(e.getBlock().getLocation());
plugin.getServer().getScheduler().runTaskLater(plugin, () -> tntBlocks.remove(e.getBlock().getLocation()), 20L);
}
// Remove the arrow
projectile.remove();
e.setCancelled(true);
}
}
}
}
}
示例5: onProjectileHit
import org.bukkit.entity.Projectile; //导入方法依赖的package包/类
@EventHandler
public void onProjectileHit(ProjectileHitEvent event) {
Projectile entity = (Projectile) event.getEntity();
Location loc = BukkitUtil.getLocation(entity);
if (!PlotSquared.isPlotWorld(loc.getWorld())) {
return;
}
Plot plot = MainUtil.getPlot(loc);
if (!MainUtil.isPlotArea(loc)) {
return;
}
ProjectileSource shooter = entity.getShooter();
if (shooter instanceof BlockProjectileSource) {
if (plot == null) {
entity.remove();
return;
}
Location sLoc = BukkitUtil.getLocation(((BlockProjectileSource) shooter).getBlock().getLocation());
Plot sPlot = MainUtil.getPlot(sLoc);
if (sPlot == null || !PlotHandler.sameOwners(plot, sPlot)) {
entity.remove();
return;
}
}
else if ((shooter instanceof Player)) {
PlotPlayer pp = BukkitUtil.getPlayer((Player) shooter);
if (plot == null) {
if (!pp.hasPermission("plots.projectile.unowned")) {
entity.remove();
}
return;
}
if (plot.isAdded(pp.getUUID())) {
return;
}
if (pp.hasPermission("plots.projectile.other")) {
return;
}
entity.remove();
}
}
示例6: onTNTPrimed
import org.bukkit.entity.Projectile; //导入方法依赖的package包/类
/**
* Trap TNT being primed by flaming arrows
* @param e
*/
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onTNTPrimed(final EntityChangeBlockEvent e) {
if (DEBUG) {
plugin.getLogger().info(e.getEventName());
plugin.getLogger().info("DEBUG: block = " + e.getBlock().getType());
plugin.getLogger().info("DEBUG: entity = " + e.getEntityType());
plugin.getLogger().info("DEBUG: material changing to " + e.getTo());
}
if (actionAllowed(e.getEntity().getLocation(), SettingsFlag.FIRE)) {
return;
}
if (e.getBlock() == null) {
return;
}
// Check for TNT
if (!e.getBlock().getType().equals(Material.TNT)) {
//plugin.getLogger().info("DEBUG: not tnt");
return;
}
// Check world
if (!inWorld(e.getBlock())) {
return;
}
// Check if this is on an island
Island island = plugin.getGrid().getIslandAt(e.getBlock().getLocation());
if (island == null || island.isSpawn()) {
return;
}
// Stop TNT from being damaged if it is being caused by a visitor with a flaming arrow
if (e.getEntity() instanceof Projectile) {
//plugin.getLogger().info("DEBUG: projectile");
Projectile projectile = (Projectile) e.getEntity();
// Find out who fired it
if (projectile.getShooter() instanceof Player) {
//plugin.getLogger().info("DEBUG: player shot arrow. Fire ticks = " + projectile.getFireTicks());
if (projectile.getFireTicks() > 0) {
//plugin.getLogger().info("DEBUG: arrow on fire");
Player shooter = (Player)projectile.getShooter();
if (!plugin.getGrid().locationIsAtHome(shooter, true, e.getBlock().getLocation())) {
//plugin.getLogger().info("DEBUG: shooter is not at home");
// Only say it once a second
// Debounce event (it can be called twice for the same action)
if (!tntBlocks.contains(e.getBlock().getLocation())) {
Util.sendMessage(shooter, ChatColor.RED + plugin.myLocale(shooter.getUniqueId()).islandProtected);
tntBlocks.add(e.getBlock().getLocation());
plugin.getServer().getScheduler().runTaskLater(plugin, new Runnable() {
@Override
public void run() {
tntBlocks.remove(e.getBlock().getLocation());
}}, 20L);
}
// Remove the arrow
projectile.remove();
e.setCancelled(true);
return;
}
}
}
}
}
示例7: onProjectileHit
import org.bukkit.entity.Projectile; //导入方法依赖的package包/类
@EventHandler
public boolean onProjectileHit(ProjectileHitEvent event) {
Projectile entity = event.getEntity();
Location loc = BukkitUtil.getLocation(entity);
if (!PS.get().hasPlotArea(loc.getWorld())) {
return true;
}
PlotArea area = loc.getPlotArea();
if (area == null) {
return true;
}
Plot plot = area.getPlot(loc);
ProjectileSource shooter = entity.getShooter();
if (shooter instanceof Player) {
PlotPlayer pp = BukkitUtil.getPlayer((Player) shooter);
if (plot == null) {
if (!Permissions.hasPermission(pp, C.PERMISSION_PROJECTILE_UNOWNED)) {
entity.remove();
return false;
}
return true;
}
if (plot.isAdded(pp.getUUID()) || Permissions.hasPermission(pp, C.PERMISSION_PROJECTILE_OTHER)) {
return true;
}
entity.remove();
return false;
}
if (!(shooter instanceof Entity) && shooter != null) {
if (plot == null) {
entity.remove();
return false;
}
Location sLoc = BukkitUtil.getLocation(((BlockProjectileSource) shooter).getBlock().getLocation());
if (!area.contains(sLoc.getX(), sLoc.getZ())) {
entity.remove();
return false;
}
Plot sPlot = area.getOwnedPlotAbs(sLoc);
if (sPlot == null || !PlotHandler.sameOwners(plot, sPlot)) {
entity.remove();
return false;
}
}
return true;
}
示例8: onEntityDamageByEntity
import org.bukkit.entity.Projectile; //导入方法依赖的package包/类
@EventHandler
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
if (event.getDamager() instanceof Projectile) {
Projectile projectile = (Projectile) event.getDamager();
if (projectile.hasMetadata("damage")) {
double damage = 0;
boolean anyDamage = false;
List<MetadataValue> values = projectile.getMetadata("damage");
for (MetadataValue value : values) {
if (value.getOwningPlugin() == SQPowerTools.getPluginMain()) {
damage = Double.parseDouble(value.value().toString());
anyDamage = true;
}
}
if (anyDamage) {
event.setDamage(damage);
}
projectile.remove();
}
}
}