本文整理汇总了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;
}
示例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);
}
}
}
示例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);
}
}
示例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);
}
示例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));
}
}
}
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
}
示例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);
}
}
}
示例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);
}
}
示例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);
}
示例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);
}
}
}
示例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);
}
}
示例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());
}
}