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


Java PlayerEvent类代码示例

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


PlayerEvent类属于org.bukkit.event.player包,在下文中一共展示了PlayerEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: accept

import org.bukkit.event.player.PlayerEvent; //导入依赖的package包/类
@Override
public WrappedEvent<?> accept(WrappedEvent<?> we) {
    long cdEndTime = 0;
    if (we.wis.hasKey("giSection.cooldown-" + cooldownId))
        cdEndTime = Long.parseLong(we.wis.getString("giSection.cooldown-" + cooldownId));
    long sysTime = System.currentTimeMillis();
    long delta = sysTime - cdEndTime;
    if (delta < 0) {
        if (we.event instanceof PlayerEvent) {
            ((PlayerEvent) we.event).getPlayer().sendMessage(I18n.format("function_help.cooldown.cd_not_end", -delta/1000.0));
        }
        we.cancelled = true;
    } else {
        we.wis.setString("giSection.cooldown-" + cooldownId, Long.toString(sysTime + cooldown * 1000));
    }
    return we;
}
 
开发者ID:NyaaCat,项目名称:GenericTools,代码行数:18,代码来源:FuncCooldown.java

示例2: 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);
        }
    }
}
 
开发者ID:EndlessCodeGroup,项目名称:RPGInventory,代码行数:23,代码来源:InventoryListener.java

示例3: onPlayerEvent

import org.bukkit.event.player.PlayerEvent; //导入依赖的package包/类
@Override
protected void onPlayerEvent(PlayerEvent event) {

    if (event instanceof PlayerInteractEvent) {
        PlayerInteractEvent interactEvent = (PlayerInteractEvent) event;

        if (interactEvent.hasBlock()) {
            callEvent(interactEvent.getClickedBlock(), event);
        } else {
            callEvent(interactEvent.getPlayer(), event);
        }
    }
    else {
        callEvent(event.getPlayer(), event);
    }
}
 
开发者ID:JCThePants,项目名称:PV-Star,代码行数:17,代码来源:ArenaEventForwarder.java

示例4: shouldHandlePlayerEvent

import org.bukkit.event.player.PlayerEvent; //导入依赖的package包/类
@Test
// This simply forwards to shouldCancelEvent(Player), so the rest is already tested
public void shouldHandlePlayerEvent() {
    // given
    String playerName = "example";
    Player player = mockPlayerWithName(playerName);
    PlayerEvent event = new TestPlayerEvent(player);
    given(playerCache.isAuthenticated(playerName)).willReturn(true);

    // when
    boolean result = listenerService.shouldCancelEvent(event);

    // then
    assertThat(result, equalTo(false));
    verify(playerCache).isAuthenticated(playerName);
    verifyZeroInteractions(dataSource);
}
 
开发者ID:AuthMe,项目名称:AuthMeReloaded,代码行数:18,代码来源:ListenerServiceTest.java

示例5: call

import org.bukkit.event.player.PlayerEvent; //导入依赖的package包/类
public void call(Event event) {
    for (Map.Entry<Class<?>, LuaValue> entry : eventListeners.entrySet()) {
        if (entry.getKey() == event.getClass()) {
            if (event instanceof PlayerEvent) {
                entry.getValue().call(new PlayerEventType((PlayerEvent) event));
            } else {
                entry.getValue().call(new EventType(event));
            }
        }
    }
}
 
开发者ID:LukkitPlus,项目名称:Lukkit,代码行数:12,代码来源:EventAttachment.java

示例6: 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);
}
 
开发者ID:HuliPvP,项目名称:Chambers,代码行数:14,代码来源:ProfileListener.java

示例7: check

import org.bukkit.event.player.PlayerEvent; //导入依赖的package包/类
private boolean check(PlayerEvent e) {
    boolean allowIncog = configsManager.getBroadcastConfig().getBoolean("Hide_Incognito_Player");
    if (isVanished(e.getPlayer())) {
        return false;
    } else if (allowIncog) {
        if (e.getPlayer().hasPermission("minecordbot.incognito")) {
            return false;
        }
    }
    return true;
}
 
开发者ID:CyR1en,项目名称:Minecordbot,代码行数:12,代码来源:UserQuitJoinListener.java

示例8: safeToProceed

import org.bukkit.event.player.PlayerEvent; //导入依赖的package包/类
private boolean safeToProceed(PlayerEvent event) {
    boolean safe = true;
    if (event instanceof PlayerJoinEvent) {
        if (((PlayerJoinEvent) event).getJoinMessage() == null && ((PlayerJoinEvent) event).getJoinMessage().isEmpty()) {
            safe = false;
            Logger.warn("The previous PlayerJoinEvent message was missing!");
        }
    } else if (event instanceof PlayerQuitEvent) {
        if (((PlayerQuitEvent) event).getQuitMessage() == null && ((PlayerQuitEvent) event).getQuitMessage().isEmpty()) {
            safe = false;
            Logger.warn("The previous PlayerQuitEvent message was missing!");
        }
    }
    return safe;
}
 
开发者ID:CyR1en,项目名称:Minecordbot,代码行数:16,代码来源:UserQuitJoinListener.java

示例9: 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);
	}
}
 
开发者ID:lj2000lj,项目名称:BeeLogin,代码行数:12,代码来源:EventCanceler.java

示例10: forceGamemode

import org.bukkit.event.player.PlayerEvent; //导入依赖的package包/类
private void forceGamemode(PlayerEvent evt) {
    if (!evt.getPlayer().hasPermission("spigotplus.gamemode.exempt")) {
        GameMode gamemode = getWorldGamemode(evt.getPlayer().getWorld().getName());
        if (!evt.getPlayer().getGameMode().equals(gamemode)) {
            evt.getPlayer().setGameMode(gamemode);
        }
    }
}
 
开发者ID:robotman3000,项目名称:Spigot-Plus,代码行数:9,代码来源:GamemodeManager.java

示例11: on

import org.bukkit.event.player.PlayerEvent; //导入依赖的package包/类
public void on(Object e) {

            if (!(e instanceof Event))
                return;

            Event event = (Event) e;

            onEvent(event);

            if (event instanceof PlayerEvent) {
                onPlayerEvent((PlayerEvent)event);
            }
            else if (event instanceof BlockEvent) {
                onBlockEvent((BlockEvent)event);
            }
            else if (event instanceof HangingEvent) {
                onHangingEvent((HangingEvent)event);
            }
            else if (event instanceof InventoryEvent) {
                onInventoryEvent((InventoryEvent) event);
            }
            else if (event instanceof VehicleEvent) {
                onVehicleEvent((VehicleEvent) event);
            }
            else if (event instanceof EntityEvent) {
                onEntityEvent((EntityEvent) event);
            }
        }
 
开发者ID:JCThePants,项目名称:NucleusFramework,代码行数:29,代码来源:BukkitEventForwarder.java

示例12: handleQuit

import org.bukkit.event.player.PlayerEvent; //导入依赖的package包/类
private void handleQuit(PlayerEvent event) {
	SpleefPlayer player = heavySpleef.getSpleefPlayer(event.getPlayer());
	if (!checking.containsKey(player)) {
		return;
	}
	
	handleFail(player, FailCause.QUIT, null);
}
 
开发者ID:xaniox,项目名称:HeavySpleef,代码行数:9,代码来源:JoinRequester.java

示例13: executeUnsafe

import org.bukkit.event.player.PlayerEvent; //导入依赖的package包/类
private void executeUnsafe(ReplacerAPI replaceManager, T event) {
    String variable = replacer.getVariable();
    for (Function<T, Integer> function : scoreFunctions) {
        int newScore = function.apply(event);
        if (replacer.isGlobal()) {
            for (Player player : Bukkit.getOnlinePlayers()) {
                replaceManager.forceUpdate(player, variable, newScore);
            }
        } else if (event instanceof PlayerEvent) {
            replaceManager.forceUpdate(((PlayerEvent) event).getPlayer(), variable, newScore);
        }
    }
}
 
开发者ID:games647,项目名称:ScoreboardStats,代码行数:14,代码来源:EventReplacer.java

示例14: onPlayerSwapHandItems

import org.bukkit.event.player.PlayerEvent; //导入依赖的package包/类
@FutureEventHandler(event = "player.PlayerSwapHandItemsEvent", priority = EventPriority.HIGHEST)
public void onPlayerSwapHandItems(WrappedEvent ev)
{
	if(SpectatorPlus.get().getPlayerData(((PlayerEvent) ev.getEvent()).getPlayer()).isSpectating())
	{
		ev.setCancelled(true);
	}
}
 
开发者ID:pgmann,项目名称:SpectatorPlus,代码行数:9,代码来源:SpectatorsInteractionsListener.java

示例15: mockShouldCancel

import org.bukkit.event.player.PlayerEvent; //导入依赖的package包/类
/**
 * Mocks, based on the given event, the correct method in {@link ListenerService} to return
 * the provided {@code result}.
 *
 * @param result the result the service should return
 * @param listenerService the service to mock
 * @param event the event
 */
private static void mockShouldCancel(boolean result, ListenerService listenerService, Event event) {
    if (event instanceof PlayerEvent) {
        given(listenerService.shouldCancelEvent((PlayerEvent) event)).willReturn(result);
    } else if (event instanceof EntityEvent) {
        given(listenerService.shouldCancelEvent((EntityEvent) event)).willReturn(result);
    } else {
        throw new IllegalStateException("Found event with unsupported type: " + event.getClass());
    }
}
 
开发者ID:AuthMe,项目名称:AuthMeReloaded,代码行数:18,代码来源:EventCancelVerifier.java


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