本文整理汇总了Java中org.bukkit.event.player.PlayerInteractEntityEvent.getRightClicked方法的典型用法代码示例。如果您正苦于以下问题:Java PlayerInteractEntityEvent.getRightClicked方法的具体用法?Java PlayerInteractEntityEvent.getRightClicked怎么用?Java PlayerInteractEntityEvent.getRightClicked使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.event.player.PlayerInteractEntityEvent
的用法示例。
在下文中一共展示了PlayerInteractEntityEvent.getRightClicked方法的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));
}
}
}
示例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);
}
}
}
}
}
}
}
示例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);
}
}
示例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());
}
}
}
示例5: 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);
}
}
示例6: 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);
}
}
示例7: 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");
}
}
示例8: 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);
}
}
}
}
示例9: 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);
}
}
}
示例10: 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());
}
}
示例11: 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;
}
}
}
示例12: 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();
}
}
示例13: 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;
}
}
}
示例14: 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");
}
}
示例15: changeOwner
import org.bukkit.event.player.PlayerInteractEntityEvent; //导入方法依赖的package包/类
/**
* Change the owner of a pet.
*
* @param event
* @param oldOwner
* @param newOwner
*/
private void changeOwner(PlayerInteractEntityEvent event, AnimalTamer oldOwner, Player newOwner) {
if (chargePrice(event.getPlayer(), changeOwnerPrice)) {
Tameable tameableAnimal = (Tameable) event.getRightClicked();
// Change owner.
tameableAnimal.setOwner(newOwner);
event.getPlayer().sendMessage(plugin.getChatHeader()
+ plugin.getPluginLang().getString("owner-changed", "This pet was given to a new owner!"));
newOwner.sendMessage(plugin.getChatHeader()
+ plugin.getPluginLang().getString("new-owner", "Player PLAYER gave you ownership of a pet!")
.replace("PLAYER", event.getPlayer().getName()));
// Create new event to allow other plugins to be aware of the ownership change.
PlayerChangeAnimalOwnershipEvent playerChangeAnimalOwnershipEvent = new PlayerChangeAnimalOwnershipEvent(
oldOwner, newOwner, tameableAnimal);
Bukkit.getServer().getPluginManager().callEvent(playerChangeAnimalOwnershipEvent);
}
}