mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-15 12:13:54 -07:00
@@ -6,6 +6,7 @@ import java.io.InputStream;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
import org.bukkit.util.config.Configuration;
|
||||
|
||||
@@ -147,4 +148,10 @@ public interface Plugin extends CommandExecutor {
|
||||
* @return ChunkGenerator for use in the default world generation
|
||||
*/
|
||||
public ChunkGenerator getDefaultWorldGenerator(String worldName, String id);
|
||||
|
||||
public long getTiming(Event.Type type);
|
||||
|
||||
public void incTiming(Event.Type type, long delta);
|
||||
|
||||
public void resetTimings();
|
||||
}
|
||||
|
@@ -336,7 +336,9 @@ public final class SimplePluginManager implements PluginManager {
|
||||
if (eventListeners != null) {
|
||||
for (RegisteredListener registration : eventListeners) {
|
||||
try {
|
||||
long start = System.nanoTime();
|
||||
registration.callEvent(event);
|
||||
registration.getPlugin().incTiming(event.getType(), System.nanoTime() - start);
|
||||
} catch (AuthorNagException ex) {
|
||||
Plugin plugin = registration.getPlugin();
|
||||
|
||||
|
@@ -20,6 +20,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
@@ -43,6 +44,7 @@ public abstract class JavaPlugin implements Plugin {
|
||||
private EbeanServer ebean = null;
|
||||
private FileConfiguration newConfig = null;
|
||||
private File configFile = null;
|
||||
private long[] timings = new long[Event.Type.values().length];
|
||||
|
||||
public JavaPlugin() {}
|
||||
|
||||
@@ -367,4 +369,16 @@ public abstract class JavaPlugin implements Plugin {
|
||||
public String toString() {
|
||||
return getDescription().getFullName();
|
||||
}
|
||||
|
||||
public long getTiming(Event.Type type) {
|
||||
return timings[type.ordinal()];
|
||||
}
|
||||
|
||||
public void incTiming(Event.Type type, long delta) {
|
||||
timings[type.ordinal()] += delta;
|
||||
}
|
||||
|
||||
public void resetTimings() {
|
||||
timings = new long[Event.Type.values().length];
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user