本文整理汇总了Java中org.bukkit.event.player.PlayerEvent.getPlayer方法的典型用法代码示例。如果您正苦于以下问题:Java PlayerEvent.getPlayer方法的具体用法?Java PlayerEvent.getPlayer怎么用?Java PlayerEvent.getPlayer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.event.player.PlayerEvent
的用法示例。
在下文中一共展示了PlayerEvent.getPlayer方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onItemDisappeared
import org.bukkit.event.player.PlayerEvent; //导入方法依赖的package包/类
private void onItemDisappeared(PlayerEvent event, ItemStack item) {
final Player player = event.getPlayer();
final PlayerInventory inventory = player.getInventory();
final int slotId = inventory.getHeldItemSlot();
if (!InventoryManager.playerIsLoaded(player)) {
return;
}
if (ItemUtils.isEmpty(inventory.getItemInMainHand()) || item.equals(inventory.getItemInMainHand())) {
final Slot slot = InventoryManager.getQuickSlot(slotId);
if (slot != null) {
new BukkitRunnable() {
@Override
public void run() {
InventoryUtils.heldFreeSlot(player, slotId, InventoryUtils.SearchType.NEXT);
inventory.setItem(slotId, slot.getCup());
}
}.runTaskLater(RPGInventory.getInstance(), 1);
}
}
}
示例2: removeProfile
import org.bukkit.event.player.PlayerEvent; //导入方法依赖的package包/类
private void removeProfile(PlayerEvent event) {
Player player = event.getPlayer();
Game game = plugin.getGameManager().getGame();
Profile profile = plugin.getProfileManager().getProfileByUuid(player.getUniqueId());
if (profile != null && profile.getTeam() != null) {
if (game.hasStarted()) {
plugin.getGameManager().getGame().getOffline().add(player.getName());
profile.getTeam().getOffline().add(player.getName());
}
profile.getTeam().removeMember(profile);
}
plugin.getProfileManager().removeProfile(profile);
}
示例3: anyPlayerEvent
import org.bukkit.event.player.PlayerEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST)
public void anyPlayerEvent(PlayerEvent event){
if(!(event instanceof Cancellable))
return;
if (!usingBeeLoginMod)
return;
Player player = event.getPlayer();
if (!loginStatus.get(player.getName().toLowerCase())) {
((Cancellable) event).setCancelled(true);
}
}
示例4: getLoggablePlayerEvent
import org.bukkit.event.player.PlayerEvent; //导入方法依赖的package包/类
private LoggablePlayerEvent getLoggablePlayerEvent(PlayerEventAction action, PlayerEvent event) {
final Player player = event.getPlayer();
final Location location = player.getLocation();
final World world = player.getWorld();
Point3d coordinates = new Point3d(location.getX(), location.getY(), location.getZ());
LoggablePlayerEvent playerEvent = new LoggablePlayerEvent(world.getFullTime(), minecraft_server, world.getName(), action);
LivingEntity eventPlayer = new LivingEntity("player", player.getDisplayName());
eventPlayer.setMaxHealth(player.getMaxHealth());
eventPlayer.setCurrentHealth(player.getHealth());
for (PotionEffect potion : player.getActivePotionEffects()) {
eventPlayer.addPotions(potion.getType().getName() + ":" + potion.getAmplifier());
}
playerEvent.setPlayer(eventPlayer);
if (event instanceof PlayerMoveEvent) {
// Teleport is a child class so this is to allow us to identify the child class
if (event instanceof PlayerTeleportEvent)
playerEvent.setAction("Teleport"); // Should use the action enum instead of the string.
// The coordinates from the event and the destination of the move event are slightly different so this corrects that.
Point3d destination = new Point3d(((PlayerMoveEvent) event).getTo().getX(), ((PlayerMoveEvent) event).getTo().getY(), ((PlayerMoveEvent) event).getTo().getZ());
playerEvent.setDest(destination);
Point3d source = new Point3d(((PlayerMoveEvent) event).getFrom().getX(), ((PlayerMoveEvent) event).getFrom().getY(), ((PlayerMoveEvent) event).getFrom().getZ());
playerEvent.setSrc(source);
}
return playerEvent;
}
示例5: shouldCancelEvent
import org.bukkit.event.player.PlayerEvent; //导入方法依赖的package包/类
/**
* Returns whether an event should be canceled (for unauthenticated, non-NPC players).
*
* @param event the event to process
* @return true if the event should be canceled, false otherwise
*/
public boolean shouldCancelEvent(PlayerEvent event) {
Player player = event.getPlayer();
return shouldCancelEvent(player);
}