当前位置: 首页>>代码示例>>Java>>正文


Java PlayerInteractEvent类代码示例

本文整理汇总了Java中org.bukkit.event.player.PlayerInteractEvent的典型用法代码示例。如果您正苦于以下问题:Java PlayerInteractEvent类的具体用法?Java PlayerInteractEvent怎么用?Java PlayerInteractEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


PlayerInteractEvent类属于org.bukkit.event.player包,在下文中一共展示了PlayerInteractEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onPlayerInteract

import org.bukkit.event.player.PlayerInteractEvent; //导入依赖的package包/类
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
    Player player = event.getPlayer();
    Location location = player.getLocation();
    ItemStack item = event.getItem();
    if (isBull(item) && event.getAction() == Action.RIGHT_CLICK_AIR | event.getAction() == Action.RIGHT_CLICK_BLOCK) {
        if (!FactionsXL.getInstance().getBoard().isAnnexable(location)) {
            ParsingUtil.sendMessage(player, FMessage.ERROR_LAND_NOT_FOR_SALE.getMessage());
            return;
        }
        FactionCache factions = FactionsXL.getInstance().getFactionCache();
        BookMeta meta = ((BookMeta) item.getItemMeta());
        String title = meta.getTitle().replace(" ", "-");
        if (factions.getByName(title) != null) {
            title += NumberUtil.generateRandomInt(0, 100);
        }
        FireworkUtil.spawnRandom(location);
        FactionsXL.getInstance().getFactionCache().create(player, title);
        player.getInventory().remove(item);
    }
}
 
开发者ID:DRE2N,项目名称:FactionsXL,代码行数:22,代码来源:FBull.java

示例2: onWalkieTalkieInteract

import org.bukkit.event.player.PlayerInteractEvent; //导入依赖的package包/类
@EventHandler
public void onWalkieTalkieInteract(PlayerInteractEvent e) {
	if (e.getPlayer().getInventory().getItemInMainHand().getType() != Material.REDSTONE_COMPARATOR)
		return;
	if (e.getHand() == EquipmentSlot.OFF_HAND)
		return;

	WalkieTalkie wt = new WalkieTalkie(main,
			main.getPlayerManager().getPlayer(e.getPlayer()).getCurrentWalkieTalkieFrequency());

	// Left click to tune frequency.
	if (e.getAction() == Action.LEFT_CLICK_AIR || e.getAction() == Action.LEFT_CLICK_BLOCK) {
		if (e.getPlayer().isSneaking()) {
			wt.decreaseFrequency(e.getPlayer());
		} else {
			wt.increaseFrequency(e.getPlayer());
		}
	}

}
 
开发者ID:kadeska,项目名称:MT_Communication,代码行数:21,代码来源:WalkieTalkieListener.java

示例3: onDamageSkull

import org.bukkit.event.player.PlayerInteractEvent; //导入依赖的package包/类
@EventHandler
public void onDamageSkull(PlayerInteractEvent e) {
	if (cm.isAntiDamageSkull) {
		if (Action.RIGHT_CLICK_BLOCK == e.getAction()) {
			if (e.getItem() != null) {
				Material type = e.getItem().getType();
				if (Material.LAVA_BUCKET == type || Material.WATER_BUCKET == type) {
					fixSkull(e.getClickedBlock().getRelative(BlockFace.UP));
				} else if (Material.ANVIL == type) {
					for (BlockFace face : BLOCKFACE) {
						fixSkull(e.getClickedBlock().getRelative(face));
					}
				}
			}
		}
	}
}
 
开发者ID:jiongjionger,项目名称:NeverLag,代码行数:18,代码来源:AntiDamageSkull.java

示例4: onPlayerInteract

import org.bukkit.event.player.PlayerInteractEvent; //导入依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onPlayerInteract(PlayerInteractEvent event) {
    if (event.hasItem() && event.getItem().getType() == Material.GOLDEN_CARROT) {
        Player player = event.getPlayer();
        if (plugin.getPvpClassManager().getEquippedClass(player) == this) {
            long timestamp = cooldowns.get(player.getUniqueId());
            long millis = System.currentTimeMillis();
            long remaining = timestamp == cooldowns.getNoEntryValue() ? 0L : timestamp - millis;
            if (remaining > 0L) {
                player.sendMessage(ChatColor.RED + "Cooldown still for " + DurationFormatUtils.formatDurationWords(remaining, true, true) + ".");
                return;
            }

            cooldowns.put(player.getUniqueId(), millis + 15000L);
            plugin.getEffectRestorer().setRestoreEffect(player, new PotionEffect(PotionEffectType.SPEED, 100, 4));
            plugin.getEffectRestorer().setRestoreEffect(player, new PotionEffect(PotionEffectType.INVISIBILITY, 100, 0));
        }
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:20,代码来源:AssassinClass.java

示例5: onInteract

import org.bukkit.event.player.PlayerInteractEvent; //导入依赖的package包/类
@EventHandler
public void onInteract(PlayerInteractEvent e) {
    if (!Utils.isInArena(e.getPlayer()))
        return;
    if (!SkillManager.getInstance().getSkillByShow(e.getPlayer().getItemInHand()).equals(this))
        return;
    Player p = e.getPlayer();
    if (!CooldownManager.getInstance().exists(p)) {
        launch(p, null);
    } else {
        long left = CooldownManager.getInstance().getLeft(p, 3000L);
        if (left == 0) {
            launch(p, null);
        } else {
            p.sendMessage(Messages.prefix + Messages.Cooldown.replace("%time%", String.valueOf(left)));
        }
    }
}
 
开发者ID:Soldier233,项目名称:ArchersBattle,代码行数:19,代码来源:FireBall.java

示例6: onPlayerInteract

import org.bukkit.event.player.PlayerInteractEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerInteract(PlayerInteractEvent event) {
    if (event.getAction() != Action.RIGHT_CLICK_BLOCK || event.useInteractedBlock() == Result.DENY)
        return;

    //For using a hoe for farming
    if (event.getItem() != null &&
            event.getItem().getType() != null &&
            (event.getMaterial() == Material.DIRT || event.getMaterial() == Material.GRASS) &&
            ((event.getItem().getType() == Material.WOOD_HOE) ||
                    (event.getItem().getType() == Material.IRON_HOE) ||
                    (event.getItem().getType() == Material.GOLD_HOE) ||
                    (event.getItem().getType() == Material.DIAMOND_HOE)))
    {
        BlockUpdate.Update(event.getClickedBlock());
    }
}
 
开发者ID:SamaGames,项目名称:AntiCheat,代码行数:18,代码来源:OrebfuscatorPlayerListener.java

示例7: init

import org.bukkit.event.player.PlayerInteractEvent; //导入依赖的package包/类
public static void init(MCLibrary plugin) {
    Bukkit.getPluginManager().registerEvents(new Listener() {
        @EventHandler
        @SuppressWarnings("deprecation")
        public void onInteract(PlayerInteractEvent event) {
            if (MCUtils.isOffHandSupport() && event.getHand() != EquipmentSlot.HAND)
                return;

            Player player = event.getPlayer();
            Block block = event.getClickedBlock();
            if (block == null || !INFO_LISTENERS.contains(player))
                return;

            Location loc = block.getLocation();
            CommandSenderWrapper wrapper = new CommandSenderWrapper(player);
            wrapper.sendMessage("---------------------------------------------");
            wrapper.sendMessage("&eworld: &f" + loc.getWorld().getName());
            wrapper.sendMessage(String.format("&ex: &f%s (%s)", loc.getBlockX(), loc.getX()));
            wrapper.sendMessage(String.format("&ey: &f%s (%s)", loc.getBlockY(), loc.getY()));
            wrapper.sendMessage(String.format("&ez: &f%s (%s)", loc.getBlockZ(), loc.getZ()));
            wrapper.sendMessage(String.format("&eblock: &f%s:%s (%s)", block.getTypeId(), block.getData(), block.getType().name()));
        }
    }, plugin);
}
 
开发者ID:EntryPointKR,项目名称:MCLibrary,代码行数:25,代码来源:LibraryCommand.java

示例8: Compass

import org.bukkit.event.player.PlayerInteractEvent; //导入依赖的package包/类
@EventHandler
public void Compass(PlayerInteractEvent event) {
	if (event.getItem() != null && event.getItem().getType() != Material.AIR && event.getItem().getType()==Material.COMPASS) {
		Player p = event.getPlayer();
		for (int i = 0; i < 500; i+=20) {
			List<Entity> entities = p.getNearbyEntities(i, 256, i);
			for (Entity e : entities) {
				if (e instanceof Player) {
					Player found = (Player) e;
					if (Team.getTeam(p)!=Team.getTeam(found)) {
						Chat.player(p, "&aCompass now points towards " + found.getDisplayName() + "&a!");
						p.setCompassTarget(e.getLocation());
						return;
					}
				}
			}
		}
		Chat.player(p, "&cNo enemy players found near you!");
	}
}
 
开发者ID:thekeenant,项目名称:mczone,代码行数:21,代码来源:Events.java

示例9: healWithPotion

import org.bukkit.event.player.PlayerInteractEvent; //导入依赖的package包/类
public static void healWithPotion(int amount, String name, Event event, Player p) {
    if (!(event instanceof PlayerInteractEvent))
        return;
    PlayerInteractEvent e = (PlayerInteractEvent) event;
    if (!(e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK))
        return;
    if (lastHealItem.containsKey(p.getName()) && System.currentTimeMillis() - lastHealItem.get(p.getName()) < 500) {
        return;
    }
    lastHealItem.put(p.getName(), System.currentTimeMillis());
    p.getEquipment().setItemInMainHand(new ItemStack(Material.AIR));
    PlayerDataRPG pd = plugin.getPD(p);
    pd.heal(amount, HealType.POTION);
    for (int k = 0; k < p.getInventory().getContents().length; k++) {
        if (ItemManager.isItem(p.getInventory().getItem(k), name)) {
            p.getEquipment().setItemInMainHand(p.getInventory().getItem(k));
            p.getInventory().setItem(k, new ItemStack(Material.AIR));
            break;
        }
    }
    RSound.playSound(p, Sound.ENTITY_GENERIC_DRINK);
}
 
开发者ID:edasaki,项目名称:ZentrelaRPG,代码行数:23,代码来源:EtcItem.java

示例10: onPlayerInteract

import org.bukkit.event.player.PlayerInteractEvent; //导入依赖的package包/类
/**
 * Give old player enchants on head eating
 *
 * @param event Event
 */
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event)
{
    if (event.getItem() == null || event.getItem().getType() != Material.SKULL_ITEM || event.getItem().getDurability() != 3
            || (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK))
        return;

    SkullMeta skullMeta = (SkullMeta)event.getItem().getItemMeta();
    List<PotionEffect> effectList = this.effects.get(skullMeta.getOwner());

    if (effectList != null)
    {
        effectList.forEach(event.getPlayer()::addPotionEffect);
        this.effects.remove(skullMeta.getOwner());
        event.getPlayer().getWorld().playSound(event.getPlayer().getLocation(), Sound.BURP, 1F, 1F);
    }
}
 
开发者ID:SamaGames,项目名称:SurvivalAPI,代码行数:23,代码来源:CookieHeadModule.java

示例11: jailDoorExit

import org.bukkit.event.player.PlayerInteractEvent; //导入依赖的package包/类
@EventHandler
public void jailDoorExit(PlayerInteractEvent e){
	jailLoc = new Location(Bukkit.getWorld("kaospvp"), 1106, 32, -236);
	jailLeaveLoc = new Location(Bukkit.getWorld("kaospvp"), 1103, 33, -238);
	Punished pj = Punished.isJailed(e.getPlayer().getUniqueId().toString());
	if(e.getClickedBlock() == null) return;
	Location cbl = e.getClickedBlock().getLocation(); // clicked block location
	boolean ird =  // is right door?
			cbl.getBlockX() == jailLeaveLoc.getBlockX() &&
			cbl.getBlockY() == jailLeaveLoc.getBlockY() &&
			cbl.getBlockZ() == jailLeaveLoc.getBlockZ();
	if(ird){
		if(pj.punished){
			e.getPlayer().sendMessage(
					tag + ChatColor.GRAY + "You still have " +
					ChatColor.RED + pj.expirySecs / (60*60*24) + ChatColor.GRAY + " days, " +
					ChatColor.RED + ((pj.expirySecs/HOUR)%24) + ChatColor.GRAY + " hours, " +
					ChatColor.RED + ((pj.expirySecs/MINUTE) % 60) + ChatColor.GRAY + " minutes!");
		}else{
			e.getPlayer().teleport(e.getPlayer().getWorld().getSpawnLocation());
			e.getPlayer().sendMessage(tag + ChatColor.GREEN + "You are free from jail!");
		}
	}
}
 
开发者ID:OverloadedCore,项目名称:kaosEssentials,代码行数:25,代码来源:Core.java

示例12: onPlayerInteract

import org.bukkit.event.player.PlayerInteractEvent; //导入依赖的package包/类
/**
 * Block Minecraft utilization
 *
 * @param event Event
 */
@SuppressWarnings("deprecation")
@EventHandler(ignoreCancelled = true)
public void onPlayerInteract(PlayerInteractEvent event)
{
    if (event.getPlayer().getItemInHand() != null && event.getPlayer().getItemInHand().getType() == (Material.MINECART))
    {
        if (event.getPlayer().getItemInHand().getType() == Material.MINECART)
        {
            event.getPlayer().sendMessage(ChatColor.RED + "L'utilisation de Minecart est bloqué.");
            event.setCancelled(true);
        }
        else if (event.getPlayer().getItemInHand().getType() == Material.FLINT_AND_STEEL && !this.game.isPvPActivated())
        {
            event.getPlayer().sendMessage(ChatColor.RED + "L'utilisation du briquet est interdit en phase de préparation.");
            event.setCancelled(true);
        }
    }
}
 
开发者ID:SamaGames,项目名称:SurvivalAPI,代码行数:24,代码来源:GameListener.java

示例13: onInteract

import org.bukkit.event.player.PlayerInteractEvent; //导入依赖的package包/类
@EventHandler (priority = EventPriority.HIGHEST, ignoreCancelled = false)
public void onInteract(PlayerInteractEvent event) {
	if(link.isEmpty())return;
	ItemStack stack = event.getItem();
	if(stack == null)
		return;
	NBTItem item = new NBTItem(stack);
	Integer cmdId = item.getInteger("cmd");
	if(cmdId == null)
		return;
	Link cmd = link.get(cmdId);
	if(cmd==null)
		return;
	VPPlayer sender = VanillaPlusCore.getPlayerManager().getPlayer(event.getPlayer());
	if(cmd.cmd.hasRequirement(sender)){
		cmd.onExecute(sender);
		event.setCancelled(cmd.cancel);
	}
}
 
开发者ID:dracnis,项目名称:VanillaPlus,代码行数:20,代码来源:CPManager.java

示例14: grenadeEvent

import org.bukkit.event.player.PlayerInteractEvent; //导入依赖的package包/类
@SuppressWarnings("deprecation")
@EventHandler
public void grenadeEvent(PlayerInteractEvent e){
	final Player p = e.getPlayer();
	if(e.getAction().equals(Action.RIGHT_CLICK_AIR) || e.getAction().equals(Action.RIGHT_CLICK_BLOCK)){
		if(p.getItemInHand().hasItemMeta()){
			if(p.getItemInHand().getItemMeta().getLore() == null) return;
			if(p.getItemInHand().getItemMeta().getLore().contains(ChatColor.GRAY + "Grenade I")){
				p.getItemInHand().setDurability((short) (p.getItemInHand().getDurability() - 4));
				final Item grenade = p.getWorld().dropItem(p.getEyeLocation(), new ItemStack(Material.CLAY_BALL));
				grenade.setVelocity(p.getEyeLocation().getDirection().normalize().multiply(0.8D));
				Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable(){
					public void run(){
						p.getWorld().createExplosion(grenade.getLocation().getX(), grenade.getLocation().getY(), 
								grenade.getLocation().getZ(), 3, false, false);
						grenade.remove();
					}
				},30L);
			}
		}
	}
}
 
开发者ID:OverloadedCore,项目名称:chaoticWeapons,代码行数:23,代码来源:Core.java

示例15: onClick

import org.bukkit.event.player.PlayerInteractEvent; //导入依赖的package包/类
@EventHandler
public void onClick(PlayerInteractEvent e) {
	Action act = e.getAction();
	if (!(act.equals(Action.RIGHT_CLICK_AIR) || act.equals(Action.RIGHT_CLICK_BLOCK)))
		return;
	ItemStack item = e.getItem();
	if (item == null)
		return;
	if (!item.hasItemMeta())
		return;
	if (!item.getItemMeta().hasDisplayName())
		return;
	if (!item.getItemMeta().getDisplayName().contains(ConfigManager.getInstance().getBackpackName()))
		return;
	Player p = e.getPlayer();
	String name = p.getName();
	if (BackpackCooldown.getInstance().isReady(name, 500)) {
		BackpackCooldown.getInstance().put(name);
	} else {
		e.setCancelled(true);
		p.closeInventory();
		p.sendMessage(Messages.getMessages().getNoQuickOpen().replace("&", "§"));
	}
}
 
开发者ID:Soldier233,项目名称:SlimefunBugFixer,代码行数:25,代码来源:Listeners.java


注:本文中的org.bukkit.event.player.PlayerInteractEvent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。