Timings v2
TODO: Add #isStopping to FullServerTickHandler#stopTiming in patch 191 expose isRunning
This commit is contained in:
@@ -381,7 +381,6 @@ public final class SimplePluginManager implements PluginManager {
|
||||
}
|
||||
}
|
||||
|
||||
org.bukkit.command.defaults.TimingsCommand.timingStart = System.nanoTime(); // Spigot
|
||||
return result.toArray(new Plugin[result.size()]);
|
||||
}
|
||||
|
||||
@@ -429,9 +428,9 @@ public final class SimplePluginManager implements PluginManager {
|
||||
|
||||
if (result != null) {
|
||||
plugins.add(result);
|
||||
lookupNames.put(result.getDescription().getName(), result);
|
||||
lookupNames.put(result.getDescription().getName().toLowerCase(java.util.Locale.ENGLISH), result); // Paper
|
||||
for (String provided : result.getDescription().getProvides()) {
|
||||
lookupNames.putIfAbsent(provided, result);
|
||||
lookupNames.putIfAbsent(provided.toLowerCase(java.util.Locale.ENGLISH), result); // Paper
|
||||
}
|
||||
}
|
||||
|
||||
@@ -461,7 +460,7 @@ public final class SimplePluginManager implements PluginManager {
|
||||
@Nullable
|
||||
public synchronized Plugin getPlugin(@NotNull String name) {
|
||||
if (true) {return this.paperPluginManager.getPlugin(name);} // Paper
|
||||
return lookupNames.get(name.replace(' ', '_'));
|
||||
return lookupNames.get(name.replace(' ', '_').toLowerCase(java.util.Locale.ENGLISH)); // Paper
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -689,7 +688,8 @@ public final class SimplePluginManager implements PluginManager {
|
||||
throw new IllegalPluginAccessException("Plugin attempted to register " + event + " while not enabled");
|
||||
}
|
||||
|
||||
if (useTimings) {
|
||||
executor = new co.aikar.timings.TimedEventExecutor(executor, plugin, null, event); // Paper
|
||||
if (false) { // Spigot - RL handles useTimings check now // Paper
|
||||
getEventListeners(event).register(new TimedRegisteredListener(listener, executor, priority, plugin, ignoreCancelled));
|
||||
} else {
|
||||
getEventListeners(event).register(new RegisteredListener(listener, executor, priority, plugin, ignoreCancelled));
|
||||
@@ -924,7 +924,7 @@ public final class SimplePluginManager implements PluginManager {
|
||||
@Override
|
||||
public boolean useTimings() {
|
||||
if (true) {return this.paperPluginManager.useTimings();} // Paper
|
||||
return useTimings;
|
||||
return co.aikar.timings.Timings.isTimingsEnabled(); // Spigot
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -932,8 +932,9 @@ public final class SimplePluginManager implements PluginManager {
|
||||
*
|
||||
* @param use True if per event timing code should be used
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public void useTimings(boolean use) {
|
||||
useTimings = use;
|
||||
co.aikar.timings.Timings.setTimingsEnabled(use); // Paper
|
||||
}
|
||||
|
||||
// Paper start
|
||||
|
||||
@@ -55,7 +55,6 @@ public final class JavaPluginLoader implements PluginLoader {
|
||||
private final Pattern[] fileFilters = new Pattern[]{Pattern.compile("\\.jar$")};
|
||||
private final List<PluginClassLoader> loaders = new CopyOnWriteArrayList<PluginClassLoader>();
|
||||
private final LibraryLoader libraryLoader;
|
||||
public static final CustomTimingsHandler pluginParentTimer = new CustomTimingsHandler("** Plugins"); // Spigot
|
||||
|
||||
/**
|
||||
* This class was not meant to be constructed explicitly
|
||||
@@ -294,27 +293,21 @@ public final class JavaPluginLoader implements PluginLoader {
|
||||
}
|
||||
}
|
||||
|
||||
final CustomTimingsHandler timings = new CustomTimingsHandler("Plugin: " + plugin.getDescription().getFullName() + " Event: " + listener.getClass().getName() + "::" + method.getName() + "(" + eventClass.getSimpleName() + ")", pluginParentTimer); // Spigot
|
||||
EventExecutor executor = new EventExecutor() {
|
||||
EventExecutor executor = new co.aikar.timings.TimedEventExecutor(new EventExecutor() { // Paper
|
||||
@Override
|
||||
public void execute(@NotNull Listener listener, @NotNull Event event) throws EventException {
|
||||
public void execute(@NotNull Listener listener, @NotNull Event event) throws EventException { // Paper
|
||||
try {
|
||||
if (!eventClass.isAssignableFrom(event.getClass())) {
|
||||
return;
|
||||
}
|
||||
// Spigot start
|
||||
boolean isAsync = event.isAsynchronous();
|
||||
if (!isAsync) timings.startTiming();
|
||||
method.invoke(listener, event);
|
||||
if (!isAsync) timings.stopTiming();
|
||||
// Spigot end
|
||||
} catch (InvocationTargetException ex) {
|
||||
throw new EventException(ex.getCause());
|
||||
} catch (Throwable t) {
|
||||
throw new EventException(t);
|
||||
}
|
||||
}
|
||||
};
|
||||
}, plugin, method, eventClass); // Paper
|
||||
if (false) { // Spigot - RL handles useTimings check now
|
||||
eventSet.add(new TimedRegisteredListener(listener, executor, eh.priority(), plugin, eh.ignoreCancelled()));
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user