本文整理汇总了Java中org.bukkit.event.entity.EntityShootBowEvent.setCancelled方法的典型用法代码示例。如果您正苦于以下问题:Java EntityShootBowEvent.setCancelled方法的具体用法?Java EntityShootBowEvent.setCancelled怎么用?Java EntityShootBowEvent.setCancelled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.event.entity.EntityShootBowEvent
的用法示例。
在下文中一共展示了EntityShootBowEvent.setCancelled方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onEntityShootBowEvent
import org.bukkit.event.entity.EntityShootBowEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onEntityShootBowEvent(EntityShootBowEvent event) {
if ((event.getBow().hasItemMeta() && event.getBow().getItemMeta().getDisplayName().equals("Ender bow")) || event
.getBow() instanceof EnderBowPlugin.EnderBow) {
// Create custom event
EntityShootEnderBowEvent entityShootEnderBowEvent = new EntityShootEnderBowEvent(event);
// Call the custom event
EnderBowPlugin.getInstance().getServer().getPluginManager().callEvent(entityShootEnderBowEvent);
// Do the following, if it wasn't cancelled
if (!entityShootEnderBowEvent.isCancelled()) {
// Fire an ender pearl
event.getEntity().launchProjectile(EnderPearl.class).setVelocity(event.getProjectile().getVelocity());
// Play the 'ENDERMAN_TELEPORT' sound
event.getEntity().getWorld().playSound(event.getEntity().getLocation(), Sound.ENDERMAN_TELEPORT, 1, 1);
}
// Cancel the original Event, so no arrows are fired
event.setCancelled(true);
}
}
示例2: onShootBow
import org.bukkit.event.entity.EntityShootBowEvent; //导入方法依赖的package包/类
@EventHandler
public void onShootBow(EntityShootBowEvent e){
if (e.isCancelled() || !(e.getEntity() instanceof Player)){
return;
}
Player p = (Player) e.getEntity();
Entity proj = e.getProjectile();
List<String> Pots = RPConfig.getStringList("server-protection.deny-potions");
if (proj != null && (proj instanceof TippedArrow)){
TippedArrow arr = (TippedArrow) proj;
if (Pots.contains(arr.getBasePotionData().getType().name())){
RPLang.sendMessage(p, "playerlistener.denypotion");
e.setCancelled(true);
}
}
}
示例3: onSkeletonShoot
import org.bukkit.event.entity.EntityShootBowEvent; //导入方法依赖的package包/类
@EventHandler
public void onSkeletonShoot(EntityShootBowEvent event){
if(event.getEntity() instanceof Skeleton){
Skeleton s = (Skeleton) event.getEntity();
if(DroneShocktroop.isPossiblyShocktroop(s)){
DroneShocktroop troop = getShocktroop(s);
if(troop == null){
s.remove();
//System.out.println("troop for named skeleton is null, removing!");
event.setCancelled(true);
} else {
//System.out.println("Allowed fire!");
}
}
}
}
示例4: onShoot
import org.bukkit.event.entity.EntityShootBowEvent; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
public void onShoot(EntityShootBowEvent event)
{
if ((event.getEntity() instanceof Player)) {
Player archer = (Player)event.getEntity();
if (archer.getAllowFlight()) {
if ((archer.isFlying()) && (!archer.hasPermission("Fly.damage")) &&
(archer.getGameMode() != GameMode.CREATIVE)) {
event.setCancelled(true);
archer.updateInventory();
}
if (!archer.isFlying() && archer.getGameMode() != GameMode.CREATIVE) {
archer.setFlying(false);
archer.setAllowFlight(false);
archer.sendMessage(ChatColor.GOLD + "You were put out of fly mode.");
}
}
}
}
示例5: onArrowShoot
import org.bukkit.event.entity.EntityShootBowEvent; //导入方法依赖的package包/类
@EventHandler
public void onArrowShoot(EntityShootBowEvent event){
if(Minigame.getCurrentMinigame()!=null){
switch(Minigame.getCurrentMinigame().getMap().getType()){
case CIRCLE_OF_BOOM:
if(Team.getTeam((Player)event.getEntity()).equals(Minigame.getObservers())){
event.setCancelled(true);
}
break;
case KEY_QUEST:
break;
case WATER_THE_MONUMENT:
break;
default:
break;
}
}
}
示例6: onEntityShootBow
import org.bukkit.event.entity.EntityShootBowEvent; //导入方法依赖的package包/类
@EventHandler
public void onEntityShootBow(EntityShootBowEvent event) {
if (event.getEntity() instanceof Player) {
if (plugin.getMaterial("Harp").isMaterial(event.getBow())) {
event.setCancelled(true);
for (Player player : event.getEntity().getWorld().getPlayers()) {
if (player.getLocation().distanceSquared(event.getEntity().getLocation()) <= 64) {
try {
File musicDirectory = new File(plugin.getDataFolder(), "music");
plugin.getJingleNoteManager().play(plugin, player.getName(), new MidiJingleSequencer(new File(musicDirectory, "canon.mid"), false));
} catch (MidiUnavailableException | InvalidMidiDataException | IOException exception) {
exception.printStackTrace();
}
}
}
}
}
}
示例7: onShootWithoutArrows
import org.bukkit.event.entity.EntityShootBowEvent; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
@EventHandler
public void onShootWithoutArrows(EntityShootBowEvent event)
{
if(event.getEntity() instanceof Player)
{
Player player = (Player)event.getEntity();
if(player.getInventory().getItemInMainHand().getType() == event.getBow().getType())
{
if
(
player.getInventory().getItemInOffHand().getType() == Material.ARROW
|| player.getInventory().getItemInOffHand().getType() == Material.SPECTRAL_ARROW
|| player.getInventory().getItemInOffHand().getType() == Material.TIPPED_ARROW
)
{
event.setCancelled(false);
}
else
{
event.setCancelled(true);
player.sendMessage(ChatColor.RED + Survival.Words.get("Must load Arrows on off hand"));
player.updateInventory();
}
}
else
{
event.setCancelled(true);
player.sendMessage(ChatColor.RED + Survival.Words.get("Must use a Bow with main hand"));
player.updateInventory();
}
}
}
示例8: onEntityShootBow
import org.bukkit.event.entity.EntityShootBowEvent; //导入方法依赖的package包/类
/**
* Stop frozen players from firing bows
*/
@EventHandler
public void onEntityShootBow(EntityShootBowEvent event) {
if (event.getEntity() instanceof Player) {
Player player = (Player) event.getEntity();
if (shouldFreeze(player)) {
event.setCancelled(true);
}
}
}
示例9: checkBowRestriction
import org.bukkit.event.entity.EntityShootBowEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void checkBowRestriction(EntityShootBowEvent event) {
if (!(event.getEntity() instanceof Player)) {
return;
}
if (!LoreAttributes.loreManager.canUse((Player) event.getEntity(), event.getBow()))
event.setCancelled(true);
}
示例10: onShootBow
import org.bukkit.event.entity.EntityShootBowEvent; //导入方法依赖的package包/类
@EventHandler
public void onShootBow(EntityShootBowEvent event) {
if ((event.getEntity() instanceof Player)) {
Player player = (Player) event.getEntity();
if ((event.getBow().getEnchantmentLevel(Enchantment.ARROW_INFINITE) == 2) || (event.getBow().getEnchantmentLevel(Enchantment.ARROW_INFINITE) == 3)) {
if (player.hasPermission(PermLib.USE_ENDERBOW)) {
if (player.getInventory().contains(Material.ENDER_PEARL)) {
if (event.getBow().getEnchantmentLevel(Enchantment.ARROW_INFINITE) == 2) {
event.setCancelled(true);
player.getInventory().removeItem(new ItemStack[] { new ItemStack(Material.ENDER_PEARL, 1)});
((EnderPearl) player.launchProjectile(EnderPearl.class)).setVelocity(event.getProjectile().getVelocity().multiply(1.1D));
player.playSound(player.getLocation(), Sound.ENDERMAN_TELEPORT, 1.0F, 1.0F);
} else if (event.getBow().getEnchantmentLevel(Enchantment.ARROW_INFINITE) == 3) {
event.setCancelled(true);
((EnderPearl) player.launchProjectile(EnderPearl.class)).setVelocity(event.getProjectile().getVelocity().multiply(1.1D));
player.playSound(player.getLocation(), Sound.ENDERMAN_TELEPORT, 1.0F, 1.0F);
event.getBow().setDurability((short) 384);
}
} else {
event.setCancelled(true);
}
} else {
player.sendMessage(ChatLib.NO_PERMS_ENDERBOW);
}
} else {}
}
}
示例11: on
import org.bukkit.event.entity.EntityShootBowEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true)
public void on(EntityShootBowEvent event) {
Entity entity = event.getEntity();
if (entity instanceof Player && freezer.isCurrentlyFrozen(entity.getUniqueId())) {
event.setCancelled(true);
}
}
示例12: onShoot
import org.bukkit.event.entity.EntityShootBowEvent; //导入方法依赖的package包/类
public void onShoot(EntityShootBowEvent event) {
if ((event.getEntity() instanceof Player)) {
Player archer = (Player) event.getEntity();
if (isGod(archer)) {
if (!archer.getWorld().getName().equals("EventWorld")) {
if (archer.getGameMode() == GameMode.SURVIVAL) {
event.setCancelled(true);
toggleGod(archer, true);
}
} else {
toggleGod(archer, true);
}
}
}
}
示例13: onShoot
import org.bukkit.event.entity.EntityShootBowEvent; //导入方法依赖的package包/类
@EventHandler
public void onShoot(EntityShootBowEvent event)
{
if(event.getEntity() instanceof Player)
{
Player player = (Player)event.getEntity();
ItemStack mainItem = event.getBow();
if(mainItem.getItemMeta().getLore() != null)
{
Random rand = new Random();
if(event.getForce() >= 1.0F)
{
final Entity arrow = event.getProjectile();
final Vector velocity = player.getLocation().getDirection().add(new Vector(0, 0.025, 0)).multiply(4);
arrow.setVelocity(velocity);
player.getWorld().playSound(player.getLocation(), Sound.BLOCK_LEVER_CLICK, 1.0F, rand.nextFloat() * 0.4F + 0.8F);
player.getWorld().playSound(player.getLocation(), Sound.ENTITY_SHULKER_BULLET_HURT, 0.5F, rand.nextFloat() * 0.4F + 0.8F);
final Runnable task = new Runnable()
{
int times = 4;
public void run()
{
if(!arrow.isOnGround())
{
arrow.setVelocity(velocity);
if(times-- > 0)
Bukkit.getScheduler().scheduleSyncDelayedTask(Survival.instance, this, 5);
}
}
};
Bukkit.getScheduler().scheduleSyncDelayedTask(Survival.instance, task, -1);
}
else
{
event.setCancelled(true);
player.getWorld().playSound(player.getLocation(), Sound.BLOCK_LEVER_CLICK, 0.5F, rand.nextFloat() * 0.4F + 0.8F);
}
}
}
}
示例14: onShootBow
import org.bukkit.event.entity.EntityShootBowEvent; //导入方法依赖的package包/类
@EventHandler
public void onShootBow(EntityShootBowEvent event) {
event.setCancelled(true);
}
示例15: onEntityShootBow
import org.bukkit.event.entity.EntityShootBowEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onEntityShootBow(EntityShootBowEvent event) {
if (this.isObserving(event.getEntity())) {
event.setCancelled(true);
}
}