本文整理汇总了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);
}
}
}
示例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();
}
}
示例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));
}
}
}
示例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);
}
}
}
示例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;
}
示例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;
}
示例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);
}
});
}
}
示例8: suspend
import org.bukkit.event.EventException; //导入依赖的package包/类
@EventHandler
void suspend(ServerSuspendEvent event) throws EventException {
try { event.yield(); }
finally {
runners().forEach(Runner::resume);
}
}
示例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());
}
}
示例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;
}
示例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());
}
}
}
示例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);
}
}
示例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);
}
}
示例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();
}
}
示例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++;
}
}