當前位置: 首頁>>代碼示例>>Java>>正文


Java PlayerInteractEntityEvent類代碼示例

本文整理匯總了Java中org.bukkit.event.player.PlayerInteractEntityEvent的典型用法代碼示例。如果您正苦於以下問題:Java PlayerInteractEntityEvent類的具體用法?Java PlayerInteractEntityEvent怎麽用?Java PlayerInteractEntityEvent使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


PlayerInteractEntityEvent類屬於org.bukkit.event.player包,在下文中一共展示了PlayerInteractEntityEvent類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onEntityInteract

import org.bukkit.event.player.PlayerInteractEntityEvent; //導入依賴的package包/類
@EventHandler
public void onEntityInteract(PlayerInteractEntityEvent event) {
    if (event.getRightClicked() != null && event.getRightClicked() instanceof Villager)
        event.setCancelled(true);
    if (event.getRightClicked() != null && npcs.containsKey(event.getRightClicked().getUniqueId())) {
        event.setCancelled(true);
        Player p = event.getPlayer();
        if (plugin.getPD(p) != null) {
            if (lastClick.containsKey(p.getUniqueId())) {
                if (System.currentTimeMillis() - lastClick.get(p.getUniqueId()) < 333) {
                    return;
                }
            }
            lastClick.put(p.getUniqueId(), System.currentTimeMillis());
            npcs.get(event.getRightClicked().getUniqueId()).interact(p, plugin.getPD(p));
        }
    }
}
 
開發者ID:edasaki,項目名稱:ZentrelaRPG,代碼行數:19,代碼來源:NPCManager.java

示例2: onPlayerClickItemFram

import org.bukkit.event.player.PlayerInteractEntityEvent; //導入依賴的package包/類
@EventHandler
public void onPlayerClickItemFram(PlayerInteractEntityEvent event) {
    if (!event.isCancelled() && event.getRightClicked() != null && event.getRightClicked() instanceof ItemFrame) {
        for (Region region : regions) {
            if (region.contains(event.getRightClicked().getLocation())) {
                for (MatchTeam matchTeam : teams) {
                    if (matchTeam.containsPlayer(event.getPlayer())) {
                        FilterResult filterResult = evaluator.evaluate(event.getPlayer());
                        if (filterResult == FilterResult.DENY) {
                            event.setCancelled(true);
                            event.getPlayer().sendMessage(message);
                        } else if (filterResult == FilterResult.ALLOW) {
                            event.setCancelled(false);
                        }
                    }
                }
            }
        }
    }
}
 
開發者ID:WarzoneMC,項目名稱:Warzone,代碼行數:21,代碼來源:BuildFilterType.java

示例3: onMinecartEnter

import org.bukkit.event.player.PlayerInteractEntityEvent; //導入依賴的package包/類
@EventHandler
public void onMinecartEnter(PlayerInteractEntityEvent event) {
    if(!(event.getRightClicked() instanceof Minecart)) return;
    event.getRightClicked().setGlowing(false);
    event.getPlayer().playSound(event.getPlayer().getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1f, 1f);
    inMinecarts++;
    if(inMinecarts >= this.getAPI().getGameManager().getPlayersAlive()) {
        new BukkitRunnable() {
            public void run() {
                if(getAPI().getGameManager().getGameState() != GameState.INGAME) return;
                Bukkit.getOnlinePlayers().forEach(player -> {
                    if(getAPI().getGameManager().isAlive(player)) {
                        if(player.getVehicle() == null) getAPI().getGameManager().setAlive(player, false);
                    }
                });
                nextEvent();
            }
        }.runTaskLater(this.getAPI().getPlugin(), 20L);
    }
}
 
開發者ID:ArcadiaPlugins,項目名稱:Arcadia-Spigot,代碼行數:21,代碼來源:MusicalMinecartsGame.java

示例4: checkItemFrameRotate

import org.bukkit.event.player.PlayerInteractEntityEvent; //導入依賴的package包/類
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void checkItemFrameRotate(PlayerInteractEntityEvent event) {
    if(event.getRightClicked() instanceof ItemFrame) {
        ItemFrame itemFrame = (ItemFrame) event.getRightClicked();
        if(itemFrame.getItem() != null) {
            // If frame contains an item, right-click will rotate it, which is handled as a "use" event
            this.handleUse(event, getHangingBlockState(itemFrame), this.match.getParticipant(event.getPlayer()));
        } else if(event.getPlayer().getItemInHand() != null) {
            // If the frame is empty and it's right clicked with an item, this will place the item in the frame,
            // which is handled as a "place" event, with the placed item as the block material
            BlockState blockState = BlockStateUtils.cloneWithMaterial(itemFrame.getLocation().getBlock(),
                                                                      event.getPlayer().getItemInHand().getData());
            this.handleHangingPlace(event, blockState, event.getPlayer());
        }
    }
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:17,代碼來源:EventRuleMatchModule.java

示例5: onPlayerInteractEntity

import org.bukkit.event.player.PlayerInteractEntityEvent; //導入依賴的package包/類
@EventHandler
public void onPlayerInteractEntity(PlayerInteractEntityEvent event)
{
    if (event.getRightClicked().getType() == EntityType.OCELOT)
    {
        if (this.lock.contains(event.getPlayer().getUniqueId()))
            return;

        // Event called twice
        this.lock.add(event.getPlayer().getUniqueId());
        this.hub.getServer().getScheduler().runTaskLater(this.hub, () -> this.lock.remove(event.getPlayer().getUniqueId()), 10L);

        for (Graou graou : this.interactions)
        {
            if (graou.getGraouEntity().getBukkitEntity().getUniqueId().equals(event.getRightClicked().getUniqueId()))
            {
                graou.play(event.getPlayer());
                break;
            }
        }
    }
}
 
開發者ID:SamaGames,項目名稱:Hub,代碼行數:23,代碼來源:GraouManager.java

示例6: onPlayerInteractEntity

import org.bukkit.event.player.PlayerInteractEntityEvent; //導入依賴的package包/類
@EventHandler
public void onPlayerInteractEntity(PlayerInteractEntityEvent event)
{
    if (event.getRightClicked().getType() == EntityType.OCELOT)
    {
        if (this.lock.contains(event.getPlayer().getUniqueId()))
            return;

        // Event called twice
        this.lock.add(event.getPlayer().getUniqueId());
        this.hub.getServer().getScheduler().runTaskLater(this.hub, () -> this.lock.remove(event.getPlayer().getUniqueId()), 10L);

        for (Meow meow : this.interactions)
        {
            if (meow.getMeowEntity().getBukkitEntity().getUniqueId().equals(event.getRightClicked().getUniqueId()))
            {
                meow.play(event.getPlayer());
                break;
            }
        }
    }
}
 
開發者ID:SamaGames,項目名稱:Hub,代碼行數:23,代碼來源:MeowManager.java

示例7: onInteract

import org.bukkit.event.player.PlayerInteractEntityEvent; //導入依賴的package包/類
@EventHandler
public void onInteract(PlayerInteractEntityEvent event) {
    Player player = event.getPlayer();
    Entity entity = event.getRightClicked();
    Faction faction = FactionsXL.getInstance().getFactionCache().getByLocation(entity.getLocation());
    if (faction == null) {
        return;
    }
    if (isVillager(entity)) {
        event.setCancelled(true);
        faction.getPopulationMenu().openMain(player);
    } else if (isTrader(entity)) {
        event.setCancelled(true);
        faction.getEconomyMenu().open(player);
    }
}
 
開發者ID:DRE2N,項目名稱:FactionsXL,代碼行數:17,代碼來源:FMob.java

示例8: onClickFrame

import org.bukkit.event.player.PlayerInteractEntityEvent; //導入依賴的package包/類
@EventHandler(priority=EventPriority.HIGHEST)
public void onClickFrame(PlayerInteractEntityEvent e){
	if(!(e.getRightClicked() instanceof ItemFrame)) return;
	String uuid = e.getPlayer().getUniqueId().toString();
	long curTime = System.currentTimeMillis();
	int posInList;
	if(uuidsClickItem.contains(uuid)){
		posInList = uuidsClickItem.indexOf(uuid);
		if(curTime < (lastClickItem.get(posInList) + 200)){
			e.getPlayer().sendMessage(tag + ChatColor.RED + "Please slow down clicking item frames!");
			Vector movDirection = e.getPlayer().getEyeLocation().getDirection();
			movDirection = movDirection.normalize().multiply(-2);
			e.getPlayer().setVelocity(movDirection);
			e.setCancelled(true);
		}
		if(curTime < (lastClickItem.get(posInList) + 50)){
			e.getPlayer().kickPlayer(tag + ChatColor.RED + "Please do not spam item frames!");
			
		}
		lastClickItem.set(posInList, curTime);
	}else{
		uuidsClickItem.add(uuid);
		lastClickItem.add(curTime);
	}
}
 
開發者ID:OverloadedCore,項目名稱:kaosEssentials,代碼行數:26,代碼來源:Core.java

示例9: onPlayerInteractEntity

import org.bukkit.event.player.PlayerInteractEntityEvent; //導入依賴的package包/類
@EventHandler
public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
	Player p = event.getPlayer();
	Entity t = event.getRightClicked();
	PetInstance pet = PetInstance.get(t);
	if (pet == null)
		return;
	
	if (pet.getOwner().equalsIgnoreCase(p.getName())) {
		if (t.getPassenger() != null) {
			t.eject();
			t.setPassenger(null);
		}
		else {
			if (!p.isInsideVehicle())
				t.setPassenger(p);
		}
	}
	else {
		Chat.player(p, "&2[Pets] &cBuy pets at www.mczone.co/shop");
	}
}
 
開發者ID:thekeenant,項目名稱:mczone,代碼行數:23,代碼來源:PlayerEvents.java

示例10: onplayerinteract

import org.bukkit.event.player.PlayerInteractEntityEvent; //導入依賴的package包/類
@EventHandler
public void onplayerinteract(PlayerInteractEntityEvent e) {
	Player p = e.getPlayer();
	if (ConfigGProtection.getConfig().getBoolean("Protection.PlayerInteractEntity-ItemFrame.Enable")) {
		if (!ConfigGProtection.getConfig().getBoolean("Protection.PlayerInteractEntity-ItemFrame.World.All_World")) {
			if (WorldUtils.getWPIEIF().contains(p.getWorld().getName())) {
				if ((e.getRightClicked() instanceof ItemFrame)) {
			        e.setCancelled(true);
				}
			}
		} else {
			if ((e.getRightClicked() instanceof ItemFrame)) {
		        e.setCancelled(true);
			}
		}
    }
}
 
開發者ID:DianoxDragon,項目名稱:UltimateSpawn,代碼行數:18,代碼來源:BasicFeatures.java

示例11: onTouchEntity

import org.bukkit.event.player.PlayerInteractEntityEvent; //導入依賴的package包/類
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onTouchEntity(PlayerInteractEntityEvent e) {
	if (!cm.isAntiVillagerTrade) {
		return;
	}
	Entity entity = e.getRightClicked();
	if (entity == null || NeverLagUtils.checkCustomNpc(entity)) {
		return;
	}
	World world = entity.getWorld();
	if (world == null) {
		return;
	}
	if (cm.disableVillagerTradeWorld.contains(world.getName())) {
		if (entity instanceof Villager) {
			e.setCancelled(true);
		}
	}
}
 
開發者ID:jiongjionger,項目名稱:NeverLag,代碼行數:20,代碼來源:AntiVillagerTrade.java

示例12: rightClick

import org.bukkit.event.player.PlayerInteractEntityEvent; //導入依賴的package包/類
@EventHandler
public void rightClick(PlayerInteractEntityEvent e)
{
  if (!(e.getRightClicked() instanceof Player)) {
    return;
  }
  Player player = e.getPlayer();
  Player p = (Player)e.getRightClicked();
  if ((modMode.contains(player.getName())) && ((p instanceof Player)) && ((player instanceof Player)) && (player.getItemInHand().getType() == Material.BOOK)) {
    player.openInventory(p.getInventory());
    player.sendMessage(ChatColor.GRAY + " §6§ §rNow opening the inventory of §e" + p.getName() + ChatColor.GRAY + "§r.");
  }
 
  else if ((modMode.contains(player.getName())) && ((p instanceof Player)) && ((player instanceof Player)) && (player.getItemInHand().getType() == Material.PACKED_ICE)) {
  	player.sendMessage(ChatColor.GRAY + " §6§ §rAttempting to freeze §e"+ p.getName() + "§r.");
      player.chat("/ss " + p.getName());
  }
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:19,代碼來源:ModeratorMode.java

示例13: onInteractEntity

import org.bukkit.event.player.PlayerInteractEntityEvent; //導入依賴的package包/類
@EventHandler(priority = EventPriority.HIGHEST)
public void onInteractEntity(PlayerInteractEntityEvent e) {
    TOAUser u = TOA.getPlayer(e.getPlayer());

    e.setCancelled(true);

    if (e.getRightClicked() instanceof Villager) {
        Villager v = (Villager) e.getRightClicked();
        if (v.getCustomName().equalsIgnoreCase("") || v.getCustomName() == null) return;

        switch (ChatColor.stripColor(v.getCustomName())) {
            case "Comprador Variado":
                TOAMenu.openMenu(u, TOAMenu.MenuType.VARIADO);
                break;
            case "Comprador Armas":
                TOAMenu.openMenu(u, TOAMenu.MenuType.ARMAS);
                break;
        }
    }
}
 
開發者ID:cadox8,項目名稱:PA,代碼行數:21,代碼來源:PlayerEvents.java

示例14: onPlayerInteractEntity

import org.bukkit.event.player.PlayerInteractEntityEvent; //導入依賴的package包/類
@EventHandler
public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
    Player player = event.getPlayer();
    Entity entity = event.getRightClicked();
    try {
        int balance = ScrapsUtil.getScraps(player);
        if (entity.getType().equals(EntityType.VILLAGER)) {
            event.setCancelled(true);
            String npc = entity.getName();
            if (MerchantManager.getAllNPCs().contains(npc)) {
                ItemStack selling = MerchantManager.getItem(npc);
                int price = MerchantManager.getPrice(npc);
                if (balance >= price) {
                    player.getInventory().addItem(selling);
                    player.sendMessage(MerchantManager.getSuccessMessage(npc));
                    ScrapsUtil.removeScraps(player, price);
                } else {
                    player.sendMessage(MerchantManager.getDenialMessage(npc));
                }
            }
        }
    } catch (SQLException e) {
        e.printStackTrace();
    }
}
 
開發者ID:Warvale,項目名稱:Locked,代碼行數:26,代碼來源:MerchantListener.java

示例15: onHorseAccess

import org.bukkit.event.player.PlayerInteractEntityEvent; //導入依賴的package包/類
@EventHandler
public void onHorseAccess(final PlayerInteractEntityEvent event) {
    if (Sddls.isHorse(event.getRightClicked())) {
        final ItemStack saddle = Sddls.getSaddle(event.getRightClicked());
        if (saddle!=null && Sddls.isSigned(saddle)) {
            if (!Sddls.hasAccess(saddle, event.getPlayer())) {
                event.setCancelled(true);
                final OfflinePlayer owner = Sddls.getOwner(saddle);
                String name = "undefined";
                if (owner!=null) {
                    if (owner.hasPlayedBefore()) {
                        name = owner.getName();
                        if (owner.isOnline())
                            name = ((Player) owner).getDisplayName();
                    } else {
                        name = owner.getUniqueId().toString();
                    }
                }
                event.getPlayer().sendMessage(ChatColor.translateAlternateColorCodes('&', Sddls.noAccessMsg.replaceAll("%owner%", name)));
            }
        }
    }
}
 
開發者ID:piratjsk,項目名稱:Sddls,代碼行數:24,代碼來源:HorseListener.java


注:本文中的org.bukkit.event.player.PlayerInteractEntityEvent類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。