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


Java EventException类代码示例

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


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

示例1: execute

import org.bukkit.event.EventException; //导入依赖的package包/类
@Override
// 计算调用次数和花费总时间以及花费最多的时间
public void execute(Listener listener, Event e) throws EventException {
	if (e.isAsynchronous()) {
		this.eventExecutor.execute(listener, e);
	} else {
		long startTime = System.nanoTime();
		try {
			try{
				this.eventExecutor.execute(listener, e);
			}catch(Throwable ex){
				MonitorUtils.AExceptionCatcher(plugin, ex);
			}
		} finally {
			long endTime = System.nanoTime();
			long executeTime = endTime - startTime;
			if(ConfigFunction.MonitorPluginLagWarningenable){
				if(executeTime/1000000 > ConfigFunction.MonitorPluginLagWarningPeriod){
					AzureAPI.log("警告!服务器主线程陷入停顿超过配置设定值!因为插件" + this.getPlugin().getName() + " 执行了一次耗时 " + executeTime/1000000 + " 毫秒的位于 " + listener.getClass().getName() + " 的监听器 " + e.getEventName() + " 的操作!");
				}
			}
			this.record(e.getEventName(), executeTime);
		}
	}
}
 
开发者ID:GelandiAssociation,项目名称:EscapeLag,代码行数:26,代码来源:EventExecutorInjector.java

示例2: onPlayerTeamChange

import org.bukkit.event.EventException; //导入依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerTeamChange(PlayerChangePartyEvent event) throws EventException {
    event.yield();

    invalidate(event.getPlayer());

    if(event.getOldParty() instanceof Team) {
        this.getTeamEntry((Team) event.getOldParty()).invalidate();
    }

    if(event.getNewParty() instanceof Team) {
        this.getTeamEntry((Team) event.getNewParty()).invalidate();
    }

    if(event.getOldParty() instanceof Tribute || event.getNewParty() instanceof Tribute) {
        this.getFreeForAllEntry(event.getMatch()).invalidate();
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:19,代码来源:MatchTabManager.java

示例3: onJoinLeave

import org.bukkit.event.EventException; //导入依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR)
public void onJoinLeave(PlayerChangePartyEvent event) throws EventException {
    final Player viewer = event.getPlayer().getBukkit();

    if(event.isLeavingMatch()) {
        Optional.ofNullable(views.rowMap().remove(viewer))
                .ifPresent(row -> row.values().forEach(View::destroy));
    }

    event.yield();

    if(event.isJoiningMatch()) {
        for(BossBarSource source : globalSources) {
            views.put(viewer, source, new View(source, viewer));
        }
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:18,代码来源:BossBarMatchModule.java

示例4: execute

import org.bukkit.event.EventException; //导入依赖的package包/类
@Override
// 计算调用次数和花费总时间以及花费最多的时间
public void execute(Listener listener, Event e) throws EventException {
	if (e.isAsynchronous()) {
		this.eventExecutor.execute(listener, e);
	} else {
		long startTime = System.nanoTime();
		try {
			this.eventExecutor.execute(listener, e);
		} finally {
			long endTime = System.nanoTime();
			long executeTime = endTime - startTime;
			this.record(e.getEventName(), executeTime);
		}
	}
}
 
开发者ID:jiongjionger,项目名称:NeverLag,代码行数:17,代码来源:EventExecutorInjector.java

示例5: callEvent

import org.bukkit.event.EventException; //导入依赖的package包/类
@Override
public void callEvent(Event event) throws EventException {
    if (event.isAsynchronous()) {
        super.callEvent(event);
        return;
    }
    count++;
    Class<? extends Event> newEventClass = event.getClass();
    if (this.eventClass == null) {
        this.eventClass = newEventClass;
    } else if (!this.eventClass.equals(newEventClass)) {
        multiple = true;
        this.eventClass = getCommonSuperclass(newEventClass, this.eventClass).asSubclass(Event.class);
    }
    long start = System.nanoTime();
    super.callEvent(event);
    totalTime += System.nanoTime() - start;
}
 
开发者ID:CyberdyneCC,项目名称:Thermos-Bukkit,代码行数:19,代码来源:TimedRegisteredListener.java

示例6: callEvent

import org.bukkit.event.EventException; //导入依赖的package包/类
@Override
public void callEvent(Event event) throws EventException {
    if (event.isAsynchronous()) {
        super.callEvent(event);
        return;
    }
    count++;
    Class<? extends Event> newEventClass = event.getClass();
    if (this.eventClass == null) {
        this.eventClass = newEventClass;
    } else if (!this.eventClass.equals(newEventClass)) {
        multiple = true;
        this.eventClass = getCommonSuperclass(newEventClass, this.eventClass).asSubclass(Event.class);
    }
    long start = System.nanoTime();
    super.callEvent(event);
    long elapsed = System.nanoTime() - start;
    if (elapsed > maxNanos) {
        this.maxNanos = elapsed;
    }
    if (report && elapsed > reportThresholdNanos) {
        handler.reportDuration(this, elapsed);
    }
    totalNanos += elapsed;
}
 
开发者ID:totemo,项目名称:NerdLag,代码行数:26,代码来源:MaxTimedRegisteredListener.java

示例7: onPartyChange

import org.bukkit.event.EventException; //导入依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR)
public void onPartyChange(final PlayerChangePartyEvent event) throws EventException {
    final MatchPlayer player = event.getPlayer();
    if(event.getOldParty() == null) {
        // Join match
        event.yield();
        if(event.getNewParty().isParticipating()) {
            enterState(player, new Joining(player));
        } else {
            enterState(player, new Observing(player, true, true));
        }
    } else if(event.getNewParty() == null) {
        // Leave match
        leaveState(player);
    } else {
        // Party change during match
        withState(player, state -> {
            state.onEvent(event);
            if(hasQueuedTransitions(player)) {
                // If the party change caused a state transition, leave the old
                // state before the change, and enter the new state afterward.

                // The potential danger here is that the player has no spawn state
                // during the party change, while other events are firing. The
                // danger is minimized by listening at MONITOR priority.

                leaveState(player);
                event.yield();
                processQueuedTransitions(player);
            }
        });
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:34,代码来源:SpawnMatchModule.java

示例8: suspend

import org.bukkit.event.EventException; //导入依赖的package包/类
@EventHandler
void suspend(ServerSuspendEvent event) throws EventException {
    try { event.yield(); }
    finally {
        runners().forEach(Runner::resume);
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:8,代码来源:CountdownContext.java

示例9: onPartyChange

import org.bukkit.event.EventException; //导入依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR)
public void onPartyChange(PlayerChangePartyEvent event) throws EventException {
    if(event.newParty().isPresent()) {
        invalidate(event.getPlayer());
    } else {
        // Before a player leaves, force all filters false that are not already false.
        // So, all dynamic player filters are effectively wrapped in "___ and online",
        // and listeners don't need to do any cleanup as long as they don't hold on to
        // players that don't match the filter.
        listeners.columnMap().forEach((scope, column) -> {
            if(scope.isInstance(event.getPlayer())) {
                // For each filter in this scope
                column.forEach((filter, filterListeners) -> {
                    // If player joined very recently, they may not have a cached response yet
                    final Boolean response = lastResponses.get(filter, event.getPlayer());
                    if(response != null && response) {
                        filterListeners.fall.forEach(listener -> dispatch((FilterListener<? super MatchPlayer>) listener, filter, event.getPlayer(), false));
                    }
                });
            }
        });

        event.yield();

        // Wait until after the event to remove them, in case they get invalidated during the event.
        dirtySet.remove(event.getPlayer());
        lastResponses.columnKeySet().remove(event.getPlayer());
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:30,代码来源:FilterMatchModule.java

示例10: SuspendListener

import org.bukkit.event.EventException; //导入依赖的package包/类
@Inject SuspendListener(Set<Suspendable> suspendables) {
    ThrowingConsumer<ServerSuspendEvent, EventException> yielder = Event::yield;
    for(Suspendable suspendable : suspendables) {
        ThrowingConsumer<ServerSuspendEvent, EventException> next = yielder;
        yielder = event -> suspendable.suspend(() -> next.acceptThrows(event));
    }
    this.yielder = yielder;
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:9,代码来源:SuspendListener.java

示例11: addPlayersToRegisteredTeam

import org.bukkit.event.EventException; //导入依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void addPlayersToRegisteredTeam(EntrantRegisterEvent event) throws EventException {
    event.yield();

    Match match = event.getTeam().getMatch();
    TeamMatchModule tmm = match.needMatchModule(TeamMatchModule.class);

    for(MatchPlayer player : match.getPlayers()) {
        if(event.getEntrant().members().contains(player.getPlayerId())) {
            tourney.getLogger().info("Adding player '" + player.getDisplayName() + "' to team '" + event.getTeam().getName() + "'");
            tmm.forceJoin(player, event.getTeam());
        }
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:15,代码来源:TeamListener.java

示例12: onPlayerLeave

import org.bukkit.event.EventException; //导入依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerLeave(PlayerChangePartyEvent event) throws EventException {
    if(event.getNewParty() != null) return;

    event.yield();

    ReadyManager readyManager = readyManagerProvider.get().orElse(null);
    if (readyManager == null) return;

    Tournament tournament = tournamentProvider.get();
    Party party = event.getOldParty();
    if (party != null && party.isParticipatingType() && party.getPlayers().size() < tournament.min_players_per_match()) {
        readyManager.markNotReady(party);
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:16,代码来源:ReadyListener.java

示例13: onQuit

import org.bukkit.event.EventException; //导入依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onQuit(PlayerQuitEvent event) throws EventException {
    event.setQuitMessage(null);
    final User user = userStore.getUser(event.getPlayer());
    final SessionChange change = pendingQuits.getIfPresent(user);

    event.yield();

    if(change != null) {
        pendingQuits.invalidate(user);
        announce(change);
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:14,代码来源:JoinMessageAnnouncer.java

示例14: execute

import org.bukkit.event.EventException; //导入依赖的package包/类
@Override
public void execute(Listener listener, Event event) throws EventException {
	if (cm.disableExplode) {
		((Collection<?>) Reflection.getMethod(event.getClass(), "blockList")
			.invoke(event)).clear();
	}
}
 
开发者ID:jiongjionger,项目名称:NeverLag,代码行数:8,代码来源:ExplodeDisabler.java

示例15: execute

import org.bukkit.event.EventException; //导入依赖的package包/类
@Override
public void execute(Listener listener, Event event) throws EventException {
    if (!event.isAsynchronous()) {
        long start = System.nanoTime();
        //todo add a more aggressive 10 ms cpu sample
        originalExecutor.execute(listener, event);
        long end = System.nanoTime();

        totalTime += end - start;
        count++;
    }
}
 
开发者ID:games647,项目名称:LagMonitor,代码行数:13,代码来源:ListenerInjector.java


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