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


Java PlayerInteractEntityEvent.getPlayer方法代码示例

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


在下文中一共展示了PlayerInteractEntityEvent.getPlayer方法的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: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: onPlayerInteractEntity

import org.bukkit.event.player.PlayerInteractEntityEvent; //导入方法依赖的package包/类
@EventHandler
public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
    Player p = event.getPlayer();
    Entity e = event.getRightClicked();
    if (p.getItemInHand() != null && p.getItemInHand().isSimilar(SelectorLayout.getSelectorItem())) {
        SelectorLayout.getSelectorMenu().showTo(p);
        event.setCancelled(true);
        return;
    }

    if (ReflectionUtil.getEntityHandle(e) instanceof IEntityPet) {
        IPet pet = ((IEntityPet) ReflectionUtil.getEntityHandle(e)).getPet();
        event.setCancelled(true);
        PetInteractEvent iEvent = new PetInteractEvent(pet, p, PetInteractEvent.Action.RIGHT_CLICK, false);
        EchoPet.getPlugin().getServer().getPluginManager().callEvent(iEvent);
        if (!iEvent.isCancelled()) {
            pet.getEntityPet().onInteract(p);
            return;
        }
    }
}
 
开发者ID:TechzoneMC,项目名称:SonarPet,代码行数:22,代码来源:PetOwnerListener.java

示例8: onInteractEntity

import org.bukkit.event.player.PlayerInteractEntityEvent; //导入方法依赖的package包/类
@EventHandler
public void onInteractEntity(PlayerInteractEntityEvent iee) {
  Player p = iee.getPlayer();
  Game g = BedwarsRel.getInstance().getGameManager().getGameOfPlayer(p);
  if (g == null) {
    return;
  }

  if (g.getState() == GameState.WAITING) {
    iee.setCancelled(true);
    return;
  }

  if (g.getState() == GameState.RUNNING) {
    this.inGameInteractEntity(iee, g, p);
  }
}
 
开发者ID:BedwarsRel,项目名称:BedwarsRel,代码行数:18,代码来源:PlayerListener.java

示例9: onInteractEvent

import org.bukkit.event.player.PlayerInteractEntityEvent; //导入方法依赖的package包/类
@EventHandler
public void onInteractEvent(PlayerInteractEntityEvent e){
   	RedProtect.get().logger.debug("RPEntityListener - Is PlayerInteractEntityEvent");
   	if (e.isCancelled()) {
           return;
       }
	Player p = e.getPlayer();
	if (p == null){
		return;
	}
	Location l = e.getRightClicked().getLocation();
	Region r = RedProtect.get().rm.getTopRegion(l);	
	Entity et = e.getRightClicked();
	if (r != null && !r.canInteractPassives(p) && (et instanceof Animals || et instanceof Villager || et instanceof Golem)) {
		if (et instanceof Tameable){
			Tameable tam = (Tameable) et;
			if (tam.isTamed() && tam.getOwner() != null && tam.getOwner().getName().equals(p.getName())){
				return;
			}
		}
	    e.setCancelled(true);
		RPLang.sendMessage(p, "entitylistener.region.cantinteract");
	}
}
 
开发者ID:FabioZumbi12,项目名称:RedProtect,代码行数:25,代码来源:RPEntityListener.java

示例10: onEntityInteract

import org.bukkit.event.player.PlayerInteractEntityEvent; //导入方法依赖的package包/类
@EventHandler
public void onEntityInteract(PlayerInteractEntityEvent e) {
	if (Main.PlayingPlayers.contains(e.getPlayer()) || Main.WaitingPlayers.contains(e.getPlayer())) {
		e.setCancelled(true);
	}

	if (e.getRightClicked() instanceof Villager) {
		Villager v = (Villager) e.getRightClicked();
		if (v.getCustomName().equals("Try Guns") || v.getCustomName().equals("§b§lTry Guns")) {
			if (Main.WaitingPlayers.contains(e.getPlayer())) {
				Player p = e.getPlayer();
				v.setCustomName("§b§lTry Guns");
				v.setCustomNameVisible(true);
				p.openInventory(Guns.tryGunsInventory);
			} else {
				e.setCancelled(true);
				e.getPlayer().sendMessage(Main.codSignature + "§cYou may only try guns when in COD-Warfare");
			}
		}
	}
}
 
开发者ID:frostythedev,项目名称:COD-Warfare,代码行数:22,代码来源:Listeners.java

示例11: onPlayerInteract

import org.bukkit.event.player.PlayerInteractEntityEvent; //导入方法依赖的package包/类
/**
 * On player interact.
 * 
 * @param evt
 *            the evt
 */
@EventHandler
public void onPlayerInteract(PlayerInteractEntityEvent evt) {

	EntityShopEntity shopEntity = EntityShopEntity.forEntity(evt.getRightClicked());

	if (shopEntity != null) {
		evt.setCancelled(true);
		Player player = evt.getPlayer();

		try {
			shopEntityManager.open(shopEntity, player);
		} catch (WellPermissionException e) {
			plugin.getLogger().log(Level.INFO, String.format("%s couldn't open auction house (%s)", player.getName(), e.getKey()));
		}
	}
}
 
开发者ID:ngasull,项目名称:well-auction,代码行数:23,代码来源:AuctionEntityShopListener.java

示例12: onPlayerInteractEntity

import org.bukkit.event.player.PlayerInteractEntityEvent; //导入方法依赖的package包/类
/**
 * On player interact entity.
 * 
 * @param event
 *            the event
 */
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
	if (!playerConf.get(event.getPlayer()).isAdminMod()
			&& event.getRightClicked() instanceof ItemFrame) {

		Player player = (Player) event.getPlayer();
		IDummyLand land = Factoid.getThisPlugin().iLands().getLandOrOutsideArea(
				event.getRightClicked().getLocation());

		if ((land instanceof ILand && ((ILand) land).isBanned(player))
				|| !checkPermission(land, player,
						PermissionList.BUILD.getPermissionType())
				|| !checkPermission(land, player,
						PermissionList.BUILD_PLACE.getPermissionType())) {
			messagePermission(player);
			event.setCancelled(true);
		}
	}
}
 
开发者ID:Tabinol,项目名称:Factoid,代码行数:26,代码来源:PlayerListener.java

示例13: jailStickHandling

import org.bukkit.event.player.PlayerInteractEntityEvent; //导入方法依赖的package包/类
@EventHandler
public void jailStickHandling(PlayerInteractEntityEvent event) {
	if (!(event.getRightClicked() instanceof Player))
		return;

	Player policeman = event.getPlayer();
	Player criminal = (Player) event.getRightClicked();

	if (plugin.getConfig().getList("batons")
			.contains(policeman.getItemInHand().getType().toString())) {
		if (policeman.hasPermission("prisonpolice.stick")) {
			if (criminal.hasPermission("prisonpolice.fugitive")
					|| plugin.sql.isOnList(criminal.getUniqueId())) {
				policeman.sendMessage("You've managed to arrest "
						+ criminal.getName() + ".");
				criminal.sendMessage("You've been arrested. Have fun back in jail, criminal scum.");
				plugin.jailCommands(policeman, criminal);
				plugin.sql.removeEvidenceList(criminal.getUniqueId());
			}
		} else {
		}
	}
}
 
开发者ID:SeanStar,项目名称:PrisonPolice,代码行数:24,代码来源:PrisonPoliceListener.java

示例14: PlayerRightClick

import org.bukkit.event.player.PlayerInteractEntityEvent; //导入方法依赖的package包/类
@EventHandler
public void PlayerRightClick(PlayerInteractEntityEvent event)
{
    if(event.getRightClicked() instanceof Villager)
    {
        Player p = event.getPlayer();
        if(p.getInventory().getHelmet() != null) {
            p.getInventory().getHelmet().setDurability((short) 0);
        }
        if(p.getInventory().getChestplate() != null){
            p.getInventory().getChestplate().setDurability((short) 0);
        }
        if(p.getInventory().getLeggings() != null) {
            p.getInventory().getLeggings().setDurability((short) 0);
        }
        if(p.getInventory().getLeggings() != null) {
            p.getInventory().getBoots().setDurability((short) 0);
        }
    }
}
 
开发者ID:Khillynn,项目名称:RandomStuff,代码行数:21,代码来源:randomStuff.java

示例15: handleEntityInteraction

import org.bukkit.event.player.PlayerInteractEntityEvent; //导入方法依赖的package包/类
void handleEntityInteraction(final PlayerInteractEntityEvent event, final Menu menu) {
	if (!this.module.getState().isEnabled()) { return; }

	final Player player = event.getPlayer();
	final Entity entity = event.getRightClicked();

	// Checks: Itemcheck, Worldcheck, Entitytypecheck, Regioncheck
	if (Utility.getItemInHand(player).isPresent() || !player.isSneaking()) { return; }
	if (!player.getWorld().getEnvironment().equals(Environment.NORMAL)) { return; }
	if (!this.module.canBeProtected(entity.getType(), entity.getLocation())) { return; }
	if (!ProtUtils.doesRegionAllowProtections(this.module, player.getLocation(), player)) { return; }

	// Check if the entity is protected
	Protection prot = this.module.cache.getByUniqueId(entity.getUniqueId()).orElse(null);
	if (prot == null) { return; }

	this.handleInteraction(prot, player, menu);
}
 
开发者ID:Craftolution,项目名称:CraftoPlugin,代码行数:19,代码来源:WhiteBlacklistMenuListener.java


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