java类org.bukkit.event.player.PlayerInteractEvent的实例源码

FBull.java 文件源码 项目:FactionsXL 阅读 23 收藏 0 点赞 0 评论 0
@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);
    }
}
WalkieTalkieListener.java 文件源码 项目:MT_Communication 阅读 24 收藏 0 点赞 0 评论 0
@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());
        }
    }

}
AntiDamageSkull.java 文件源码 项目:NeverLag 阅读 22 收藏 0 点赞 0 评论 0
@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));
                    }
                }
            }
        }
    }
}
AssassinClass.java 文件源码 项目:HCFCore 阅读 22 收藏 0 点赞 0 评论 0
@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));
        }
    }
}
FireBall.java 文件源码 项目:ArchersBattle 阅读 23 收藏 0 点赞 0 评论 0
@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)));
        }
    }
}
OrebfuscatorPlayerListener.java 文件源码 项目:AntiCheat 阅读 26 收藏 0 点赞 0 评论 0
@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());
    }
}
LibraryCommand.java 文件源码 项目:MCLibrary 阅读 24 收藏 0 点赞 0 评论 0
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);
}
Events.java 文件源码 项目:mczone 阅读 24 收藏 0 点赞 0 评论 0
@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!");
    }
}
EtcItem.java 文件源码 项目:ZentrelaRPG 阅读 26 收藏 0 点赞 0 评论 0
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);
}
CookieHeadModule.java 文件源码 项目:SurvivalAPI 阅读 25 收藏 0 点赞 0 评论 0
/**
 * 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);
    }
}
Core.java 文件源码 项目:kaosEssentials 阅读 22 收藏 0 点赞 0 评论 0
@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!");
        }
    }
}
GameListener.java 文件源码 项目:SurvivalAPI 阅读 26 收藏 0 点赞 0 评论 0
/**
 * 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);
        }
    }
}
CPManager.java 文件源码 项目:VanillaPlus 阅读 22 收藏 0 点赞 0 评论 0
@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);
    }
}
Core.java 文件源码 项目:chaoticWeapons 阅读 23 收藏 0 点赞 0 评论 0
@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);
            }
        }
    }
}
Listeners.java 文件源码 项目:SlimefunBugFixer 阅读 25 收藏 0 点赞 0 评论 0
@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("&", "§"));
    }
}
SignPlaceholders.java 文件源码 项目:VoxelGamesLibv2 阅读 28 收藏 0 点赞 0 评论 0
@EventHandler
public void handleInteract(@Nonnull PlayerInteractEvent event) {
    if (event.getAction() == org.bukkit.event.block.Action.RIGHT_CLICK_BLOCK && event.getClickedBlock() != null) {
        if (event.getClickedBlock().getState() instanceof Sign) {
            Sign sign = (Sign) event.getClickedBlock().getState();
            if (sign.hasMetadata("UpdateCooldown")) {
                long cooldown = sign.getMetadata("UpdateCooldown").get(0).asLong();
                if (cooldown > System.currentTimeMillis() - 1 * 1000) {
                    return;
                }
            }
            sign.update();
            sign.setMetadata("UpdateCooldown", new FixedMetadataValue(voxelGamesLib, System.currentTimeMillis()));
        }
    }
}
BagBase.java 文件源码 项目:Bags2 阅读 24 收藏 0 点赞 0 评论 0
@Override
public void onInteract(PlayerInteractEvent e, EquipmentSlot es)
{
    ItemStack stack = es.equals(EquipmentSlot.HAND) ? e.getPlayer().getInventory().getItemInMainHand() : e.getPlayer().getInventory().getItemInOffHand();
    if(stack.hasItemMeta() ? !stack.getItemMeta().getDisplayName().equals(Translation.get(name)) : false)
    {
        if(stack.getItemMeta().getDisplayName().startsWith(ChatColor.RESET.toString()))
        {

            ItemMeta im = stack.getItemMeta();
            if(!im.getDisplayName().startsWith(ChatColor.ITALIC.toString()))
            im.setDisplayName(ChatColor.RESET + Translation.get(name));
            stack.setItemMeta(im);
            if(es.equals(EquipmentSlot.HAND))
            e.getPlayer().getInventory().setItemInMainHand(stack);
            else
            e.getPlayer().getInventory().setItemInOffHand(stack);
        }
    }
    super.onInteract(e, es);
}
ModeratorMode.java 文件源码 项目:HCFCore 阅读 20 收藏 0 点赞 0 评论 0
@EventHandler
public void onRecord(PlayerInteractEvent e)
{
  Player p = e.getPlayer();
  if ((modMode.contains(p.getName())) && (p.getItemInHand().getType() == Material.EYE_OF_ENDER) && (e.getAction().toString().contains("RIGHT")))
  { 
    Player random = Bukkit.getOnlinePlayers()[new java.util.Random().nextInt(Bukkit.getOnlinePlayers().length)];
    if (Bukkit.getOnlinePlayers().length == 1)
      p.sendMessage(ChatColor.RED + "§6§ §rOops, seems like there are not enough players to use this.");
      e.setCancelled(true);
    if (Bukkit.getOnlinePlayers().length > 1) {
      if (p != random) {
        p.teleport(random);
        p.sendMessage(ChatColor.YELLOW + " §6§ §rYou were teleported randomly to §c" + random.getName() + "§r.");
        e.setCancelled(true);
      }
      if (p == random) {
        p.sendMessage(ChatColor.YELLOW + "§6§ §rOops, seems like we accidently found you. Please try again!");
        e.setCancelled(true);
      }
    }
  }
}
PearlGlitchListener.java 文件源码 项目:HCFCore 阅读 20 收藏 0 点赞 0 评论 0
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
public void onPlayerInteract(PlayerInteractEvent event) {
    if (event.getAction() == Action.RIGHT_CLICK_BLOCK && event.hasItem() && event.getItem().getType() == Material.ENDER_PEARL) {
        Block block = event.getClickedBlock();
        // Don't prevent opening chests, etc, as these won't throw the Enderpearls anyway
        if (block.getType().isSolid() && !(block.getState() instanceof InventoryHolder)) {
            Faction factionAt = HCF.getPlugin().getFactionManager().getFactionAt(block.getLocation());
            if (!(factionAt instanceof ClaimableFaction)) {
                return;
            }

            event.setCancelled(true);
            Player player = event.getPlayer();
            player.setItemInHand(event.getItem()); // required to update Enderpearl count
        }
    }
}
SubstanceListener.java 文件源码 项目:Locked 阅读 18 收藏 0 点赞 0 评论 0
@EventHandler
public void playerInteract(PlayerInteractEvent event) {
    Player player = event.getPlayer();
    ItemStack item = event.getItem();
    if (item != null) {
        ItemStack itemR = new ItemStack(item.getType(), 1);
        itemR.setItemMeta(item.getItemMeta());
        for (AbstractSubstance d : AbstractSubstance.getSubstances()) {
            if (d.getItemStack().getType().equals(item.getType())) {
                d.effect(player);
                if (!player.getGameMode().equals(GameMode.CREATIVE)) {
                    player.getInventory().removeItem(itemR);
                    player.updateInventory();
                }
                return;
            }
        }
    }
}
LauncherGizmo.java 文件源码 项目:ProjectAres 阅读 20 收藏 0 点赞 0 评论 0
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
    Player player = event.getPlayer();

    if (!(Gizmos.gizmoMap.get(player) instanceof LauncherGizmo)) return;

    if (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.RIGHT_CLICK_AIR) return;
    if (player.getItemInHand().getType() != this.getIcon()) return;

    Firework oldFirework = this.launchedPlayers.get(player);
    if (oldFirework == null || oldFirework.isDead()) {
        Firework firework = this.buildFirework(player.getLocation());
        firework.setPassenger(player);
        this.launchedPlayers.put(player, firework);
    }
}
ButtonManager.java 文件源码 项目:ProjectAres 阅读 26 收藏 0 点赞 0 评论 0
@EventHandler(priority = EventPriority.LOW)
public void onInteract(PlayerInteractEvent event) {
    if(!event.hasItem()) return;

    final ClickType click;
    switch(event.getAction()) {
        case LEFT_CLICK_AIR:
        case LEFT_CLICK_BLOCK:
            click = ClickType.LEFT;
            break;

        case RIGHT_CLICK_AIR:
        case RIGHT_CLICK_BLOCK:
            click = ClickType.RIGHT;
            break;

        default:
            return;
    }

    if(onButtonClick(event.getItem(), event.getActor(), click, event)) {
        event.setUseItemInHand(Event.Result.DENY);
        event.setUseInteractedBlock(Event.Result.DENY);
    }
}
CocoaEffectsModule.java 文件源码 项目:SurvivalAPI 阅读 18 收藏 0 点赞 0 评论 0
/**
 * Give speed 1 & strenght 1 effect to all players, then give them slowness & weakness after 30sec.
 * @param event Event
 */
@EventHandler
public void onInteract(PlayerInteractEvent event)
{
    if (event.getItem() != null && event.getItem().isSimilar(this.cocoa))
    {
        event.getPlayer().addPotionEffect(PotionEffectType.SPEED.createEffect(this.bonusTime * 20, 1));
        event.getPlayer().addPotionEffect(PotionEffectType.INCREASE_DAMAGE.createEffect(this.bonusTime * 20, 1));

        this.plugin.getServer().getScheduler().runTaskLater(this.plugin, () ->
        {
            event.getPlayer().addPotionEffect(PotionEffectType.SLOW.createEffect(this.penaltyTime * 20, 1));
            event.getPlayer().addPotionEffect(PotionEffectType.WEAKNESS.createEffect(this.penaltyTime * 20, 1));
        }, this.bonusTime * 20);

        if (event.getItem().getAmount() > 1)
            event.getItem().setAmount(event.getItem().getAmount() - 1);
        else
            event.getPlayer().setItemInHand(new ItemStack(Material.AIR));

        event.setCancelled(true);
    }
}
ItemDrawKnife.java 文件源码 项目:Recreator 阅读 21 收藏 0 点赞 0 评论 0
@SuppressWarnings("deprecation")
@Override
public void run(PlayerInteractEvent evt) {
    Block target = evt.getClickedBlock();
    if (target == null) return;

    Player player = evt.getPlayer();
    if (fillFaceable(target) && !isFacedLog(target)) {
        target.setData(fillData(target));
        AzureAPI.playSound(player, Sound.BLOCK_WOOD_FALL, true);

        ItemStack item = evt.getItem();
        if (Item.isTool(item)) {
            item.setDurability((short) (item.getDurability() + 4));
            if (item.getType().getMaxDurability() <= item.getDurability()) {
                player.setItemInHand(null);
                AzureAPI.playSound(player, Sound.ENTITY_ITEM_BREAK, true);
            }
        }
    } else {
        AzureAPI.log(player, isFacedLog(target) ? "这块木头已削过皮了" : "这把刀只能削树皮用");
    }
}
FoodDiversityConsume.java 文件源码 项目:SurvivalPlus 阅读 23 收藏 0 点赞 0 评论 0
@EventHandler(priority = EventPriority.HIGHEST)
public void onConsumeCake(PlayerInteractEvent event)
{
    if(event.isCancelled()) return;
    Player player = event.getPlayer();
    if(event.hasBlock() && event.getAction().equals(Action.RIGHT_CLICK_BLOCK))
    {
        Block cake = event.getClickedBlock();
        if(cake.getType().equals(Material.CAKE_BLOCK))
        {
            if(player.getFoodLevel() < 20 && (player.getGameMode() == GameMode.SURVIVAL || player.getGameMode() == GameMode.ADVENTURE))
            {
                addStats(player, carbon, 171);
                addStats(player, protein, 114);
                addStats(player, salts, 3);
            }
        }
    }
}
GeneralEvents.java 文件源码 项目:mczone 阅读 19 收藏 0 点赞 0 评论 0
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {       
    Gamer g = Gamer.get(event.getPlayer());
    event.setCancelled(true);

    if (g.getVariable("arena") != null) {
        Arena a = (Arena) g.getVariable("arena");
        if (a.getState() == ArenaState.STARTED)
            event.setCancelled(false);
    }

    if (g.getVariable("edit") != null) {
        if ((boolean) g.getVariable("edit"))
            event.setCancelled(false);
    }
}
OldEventListeners.java 文件源码 项目:BedwarsXP 阅读 29 收藏 0 点赞 0 评论 0
@EventHandler
public void onPlayerInteract(PlayerInteractEvent e) {
    Game bw = io.github.yannici.bedwars.Main.getInstance().getGameManager()
            .getGameOfPlayer(e.getPlayer());
    if (bw == null) {
        return;
    }
    if (!Config.isGameEnabledXP(bw.getName())) {
        return;
    }
    XPManager.updateXPBar(bw.getName(), e.getPlayer());
}
SurvivalTeamSelector.java 文件源码 项目:SurvivalAPI 阅读 21 收藏 0 点赞 0 评论 0
/**
 * Event fired when a player uses his nether star
 *
 * @param event Event
 */
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event)
{
    if (this.game.getStatus().equals(Status.IN_GAME))
        event.getHandlers().unregister(this);
    else if (event.getItem() != null && event.getItem().getType() == Material.NETHER_STAR)
        this.openGui(event.getPlayer(), new GuiSelectTeam());
}
DetectionListener.java 文件源码 项目:Crescent 阅读 25 收藏 0 点赞 0 评论 0
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
    final Player player = event.getPlayer();

    getCheckVersion(player, CheckType.AUTOCLICKER, "A").call(event);

    getCheckVersion(player, CheckType.NOSWING, "A").call(event);
}
CellularPhoneListener.java 文件源码 项目:MT_Communication 阅读 19 收藏 0 点赞 0 评论 0
@EventHandler
public void onCellPhoneInteract(PlayerInteractEvent e) {
  Player p = e.getPlayer();

  if (p.getInventory().getItemInMainHand().getType() != Material.WATCH)
    return;

  e.setCancelled(true);

  CellularPhone phone = new CellularPhone(main);

  // Left click for recipient toggle
  if (e.getAction() == Action.LEFT_CLICK_AIR || e.getAction() == Action.LEFT_CLICK_BLOCK) {
    if (p.isSneaking()) {
      phone.getNextContact(p);

    } else {
      phone.getPreviousContact(p);

    }
  }

  // Right click for text messages
  if (e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) {
    if (p.isSneaking()) {
      phone.checkTextMessages(p);

    } else {
      phone.deleteTextMessage(p);

    }
  }

}


问题


面经


文章

微信
公众号

扫码关注公众号