本文整理汇总了Java中org.bukkit.craftbukkit.SpigotTimings类的典型用法代码示例。如果您正苦于以下问题:Java SpigotTimings类的具体用法?Java SpigotTimings怎么用?Java SpigotTimings使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SpigotTimings类属于org.bukkit.craftbukkit包,在下文中一共展示了SpigotTimings类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run
import org.bukkit.craftbukkit.SpigotTimings; //导入依赖的package包/类
public void run() {
// Spigot start - Wrap custom timings on Tasks
if (!Bukkit.getServer().getPluginManager().useTimings()) {
task.run();
return;
}
if (timings == null && this.getOwner() != null && this.isSync()) {
timings = SpigotTimings.getPluginTaskTimings(this, period);
}
if (timings != null) {
timings.startTiming();
}
task.run();
if (timings != null) {
timings.stopTiming();
}
// Spigot end
}
示例2: aB
import org.bukkit.craftbukkit.SpigotTimings; //导入依赖的package包/类
public void aB() {
SpigotTimings.serverCommandTimer.startTiming(); // Spigot
while (!this.j.isEmpty()) {
ServerCommand servercommand = (ServerCommand) this.j.remove(0);
// CraftBukkit start - ServerCommand for preprocessing
ServerCommandEvent event = new ServerCommandEvent(this.console, servercommand.command);
this.server.getPluginManager().callEvent(event);
servercommand = new ServerCommand(event.getCommand(), servercommand.source);
// this.getCommandHandler().a(servercommand.source, servercommand.command); // Called in dispatchServerCommand
this.server.dispatchServerCommand(this.console, servercommand);
// CraftBukkit end
}
SpigotTimings.serverCommandTimer.stopTiming(); // Spigot
}
示例3: aL
import org.bukkit.craftbukkit.SpigotTimings; //导入依赖的package包/类
public void aL() {
SpigotTimings.serverCommandTimer.startTiming(); // Spigot
while (!this.serverCommandQueue.isEmpty()) {
ServerCommand servercommand = (ServerCommand) this.serverCommandQueue.remove(0);
// CraftBukkit start - ServerCommand for preprocessing
ServerCommandEvent event = new ServerCommandEvent(console, servercommand.command);
server.getPluginManager().callEvent(event);
if (event.isCancelled()) continue;
servercommand = new ServerCommand(event.getCommand(), servercommand.source);
// this.getCommandHandler().a(servercommand.source, servercommand.command); // Called in dispatchServerCommand
server.dispatchServerCommand(console, servercommand);
// CraftBukkit end
}
SpigotTimings.serverCommandTimer.stopTiming(); // Spigot
}
示例4: CraftTask
import org.bukkit.craftbukkit.SpigotTimings; //导入依赖的package包/类
CraftTask(String timingName, final Plugin plugin, final Runnable task, final int id, final long period) {
this.plugin = plugin;
this.task = task;
this.id = id;
this.period = period;
this.timingName = timingName == null && task == null ? "Unknown" : timingName;
timings = this.isSync() ? SpigotTimings.getPluginTaskTimings(this, period) : null;
}
示例5: checkIfActive
import org.bukkit.craftbukkit.SpigotTimings; //导入依赖的package包/类
/**
* Checks if the entity is active for this tick.
*
* @param entity
* @return
*/
public static boolean checkIfActive(Entity entity)
{
SpigotTimings.checkIfActiveTimer.startTiming();
boolean isActive = entity.activatedTick >= MinecraftServer.currentTick || entity.defaultActivationState;
// Should this entity tick?
if ( !isActive )
{
if ( ( MinecraftServer.currentTick - entity.activatedTick - 1 ) % 20 == 0 )
{
// Check immunities every 20 ticks.
if ( checkEntityImmunities( entity ) )
{
// Triggered some sort of immunity, give 20 full ticks before we check again.
entity.activatedTick = MinecraftServer.currentTick + 20;
}
isActive = true;
}
// Add a little performance juice to active entities. Skip 1/4 if not immune.
} else if ( !entity.defaultActivationState && entity.ticksExisted % 4 == 0 && !checkEntityImmunities( entity ) )
{
isActive = false;
}
// Cauldron - we check for entities in forced chunks in World.updateEntityWithOptionalForce
// Make sure not on edge of unloaded chunk
int x = net.minecraft.util.MathHelper.floor_double( entity.posX );
int z = net.minecraft.util.MathHelper.floor_double( entity.posZ );
if ( isActive && !entity.worldObj.doChunksNearChunkExist( x, 0, z, 16 ) ) {
isActive = false;
}
SpigotTimings.checkIfActiveTimer.stopTiming();
return isActive;
}
示例6: activateEntities
import org.bukkit.craftbukkit.SpigotTimings; //导入依赖的package包/类
/**
* Find what entities are in range of the players in the world and set
* active if in range.
*
* @param world
*/
public static void activateEntities(World world)
{
SpigotTimings.entityActivationCheckTimer.startTiming();
final int miscActivationRange = world.spigotConfig.miscActivationRange;
final int animalActivationRange = world.spigotConfig.animalActivationRange;
final int monsterActivationRange = world.spigotConfig.monsterActivationRange;
int maxRange = Math.max( monsterActivationRange, animalActivationRange );
maxRange = Math.max( maxRange, miscActivationRange );
maxRange = Math.min( ( world.spigotConfig.viewDistance << 4 ) - 8, maxRange );
for ( Entity player : new ArrayList<Entity>( world.players ) )
{
player.activatedTick = MinecraftServer.currentTick;
growBB( maxBB, player.boundingBox, maxRange, 256, maxRange );
growBB( miscBB, player.boundingBox, miscActivationRange, 256, miscActivationRange );
growBB( animalBB, player.boundingBox, animalActivationRange, 256, animalActivationRange );
growBB( monsterBB, player.boundingBox, monsterActivationRange, 256, monsterActivationRange );
int i = MathHelper.floor( maxBB.a / 16.0D );
int j = MathHelper.floor( maxBB.d / 16.0D );
int k = MathHelper.floor( maxBB.c / 16.0D );
int l = MathHelper.floor( maxBB.f / 16.0D );
for ( int i1 = i; i1 <= j; ++i1 )
{
for ( int j1 = k; j1 <= l; ++j1 )
{
if ( world.getWorld().isChunkLoaded( i1, j1 ) )
{
activateChunkEntities( world.getChunkAt( i1, j1 ) );
}
}
}
}
SpigotTimings.entityActivationCheckTimer.stopTiming();
}
示例7: checkIfActive
import org.bukkit.craftbukkit.SpigotTimings; //导入依赖的package包/类
/**
* Checks if the entity is active for this tick.
*
* @param entity
* @return
*/
public static boolean checkIfActive(Entity entity)
{
SpigotTimings.checkIfActiveTimer.startTiming();
boolean isActive = entity.activatedTick >= MinecraftServer.currentTick || entity.defaultActivationState;
// Should this entity tick?
if ( !isActive )
{
if ( ( MinecraftServer.currentTick - entity.activatedTick - 1 ) % 20 == 0 )
{
// Check immunities every 20 ticks.
if ( checkEntityImmunities( entity ) )
{
// Triggered some sort of immunity, give 20 full ticks before we check again.
entity.activatedTick = MinecraftServer.currentTick + 20;
}
isActive = true;
}
// Add a little performance juice to active entities. Skip 1/4 if not immune.
} else if ( !entity.defaultActivationState && entity.ticksLived % 4 == 0 && !checkEntityImmunities( entity ) )
{
isActive = false;
}
int x = MathHelper.floor( entity.locX );
int z = MathHelper.floor( entity.locZ );
// Make sure not on edge of unloaded chunk
if ( isActive && !entity.world.areChunksLoaded( x, 0, z, 16 ) )
{
isActive = false;
}
SpigotTimings.checkIfActiveTimer.stopTiming();
return isActive;
}
示例8: activateEntities
import org.bukkit.craftbukkit.SpigotTimings; //导入依赖的package包/类
/**
* Find what entities are in range of the players in the world and set
* active if in range.
*
* @param world
*/
public static void activateEntities(World world)
{
SpigotTimings.entityActivationCheckTimer.startTiming();
final int miscActivationRange = world.spigotConfig.miscActivationRange;
final int animalActivationRange = world.spigotConfig.animalActivationRange;
final int monsterActivationRange = world.spigotConfig.monsterActivationRange;
int maxRange = Math.max( monsterActivationRange, animalActivationRange );
maxRange = Math.max( maxRange, miscActivationRange );
maxRange = Math.min( ( world.spigotConfig.viewDistance << 4 ) - 8, maxRange );
for ( Entity player : (List<Entity>) world.players )
{
player.activatedTick = MinecraftServer.currentTick;
growBB( maxBB, player.boundingBox, maxRange, 256, maxRange );
growBB( miscBB, player.boundingBox, miscActivationRange, 256, miscActivationRange );
growBB( animalBB, player.boundingBox, animalActivationRange, 256, animalActivationRange );
growBB( monsterBB, player.boundingBox, monsterActivationRange, 256, monsterActivationRange );
int i = MathHelper.floor( maxBB.a / 16.0D );
int j = MathHelper.floor( maxBB.d / 16.0D );
int k = MathHelper.floor( maxBB.c / 16.0D );
int l = MathHelper.floor( maxBB.f / 16.0D );
for ( int i1 = i; i1 <= j; ++i1 )
{
for ( int j1 = k; j1 <= l; ++j1 )
{
if ( world.getWorld().isChunkLoaded( i1, j1 ) )
{
activateChunkEntities( world.getChunkAt( i1, j1 ) );
}
}
}
}
SpigotTimings.entityActivationCheckTimer.stopTiming();
}
示例9: checkIfActive
import org.bukkit.craftbukkit.SpigotTimings; //导入依赖的package包/类
/**
* Checks if the entity is active for this tick.
*
* @param entity
* @return
*/
public static boolean checkIfActive(Entity entity)
{
SpigotTimings.checkIfActiveTimer.startTiming();
boolean isActive = entity.activatedTick >= MinecraftServer.currentTick || entity.defaultActivationState;
// Should this entity tick?
if ( !isActive )
{
if ( ( MinecraftServer.currentTick - entity.activatedTick - 1 ) % 20 == 0 )
{
// Check immunities every 20 ticks.
if ( checkEntityImmunities( entity ) )
{
// Triggered some sort of immunity, give 20 full ticks before we check again.
entity.activatedTick = MinecraftServer.currentTick + 20;
}
isActive = true;
}
// Add a little performance juice to active entities. Skip 1/4 if not immune.
} else if ( !entity.defaultActivationState && entity.ticksLived % 4 == 0 && !checkEntityImmunities( entity ) )
{
isActive = false;
}
int x = MathHelper.floor( entity.locX );
int z = MathHelper.floor( entity.locZ );
// Make sure not on edge of unloaded chunk
Chunk chunk = entity.world.getChunkIfLoaded( x >> 4, z >> 4 );
if ( isActive && !( chunk != null && chunk.areNeighborsLoaded( 1 ) ) )
{
isActive = false;
}
SpigotTimings.checkIfActiveTimer.stopTiming();
return isActive;
}
示例10: activateEntities
import org.bukkit.craftbukkit.SpigotTimings; //导入依赖的package包/类
/**
* Find what entities are in range of the players in the world and set
* active if in range.
*
* @param world
*/
public static void activateEntities(World world)
{
SpigotTimings.entityActivationCheckTimer.startTiming();
final int miscActivationRange = world.spigotConfig.miscActivationRange;
final int animalActivationRange = world.spigotConfig.animalActivationRange;
final int monsterActivationRange = world.spigotConfig.monsterActivationRange;
int maxRange = Math.max( monsterActivationRange, animalActivationRange );
maxRange = Math.max( maxRange, miscActivationRange );
maxRange = Math.min( ( world.spigotConfig.viewDistance << 4 ) - 8, maxRange );
for ( EntityHuman player : world.players )
{
player.activatedTick = MinecraftServer.currentTick;
maxBB = player.getBoundingBox().grow( maxRange, 256, maxRange );
miscBB = player.getBoundingBox().grow( miscActivationRange, 256, miscActivationRange );
animalBB = player.getBoundingBox().grow( animalActivationRange, 256, animalActivationRange );
monsterBB = player.getBoundingBox().grow( monsterActivationRange, 256, monsterActivationRange );
int i = MathHelper.floor( maxBB.a / 16.0D );
int j = MathHelper.floor( maxBB.d / 16.0D );
int k = MathHelper.floor( maxBB.c / 16.0D );
int l = MathHelper.floor( maxBB.f / 16.0D );
for ( int i1 = i; i1 <= j; ++i1 )
{
for ( int j1 = k; j1 <= l; ++j1 )
{
if ( world.getWorld().isChunkLoaded( i1, j1 ) )
{
activateChunkEntities( world.getChunkAt( i1, j1 ) );
}
}
}
}
SpigotTimings.entityActivationCheckTimer.stopTiming();
}
示例11: activateEntities
import org.bukkit.craftbukkit.SpigotTimings; //导入依赖的package包/类
/**
* Find what entities are in range of the players in the world and set
* active if in range.
*
* @param world
*/
public static void activateEntities(World world)
{
SpigotTimings.entityActivationCheckTimer.startTiming();
// Cauldron start - proxy world support
final int miscActivationRange = world.getSpigotConfig().miscActivationRange;
final int animalActivationRange = world.getSpigotConfig().animalActivationRange;
final int monsterActivationRange = world.getSpigotConfig().monsterActivationRange;
// Cauldron end
int maxRange = Math.max( monsterActivationRange, animalActivationRange );
maxRange = Math.max( maxRange, miscActivationRange );
maxRange = Math.min( ( world.getSpigotConfig().viewDistance << 4 ) - 8, maxRange ); // Cauldron
for ( Entity player : new ArrayList<Entity>( world.playerEntities ) )
{
player.activatedTick = MinecraftServer.currentTick;
growBB( maxBB, player.boundingBox, maxRange, 256, maxRange );
growBB( miscBB, player.boundingBox, miscActivationRange, 256, miscActivationRange );
growBB( animalBB, player.boundingBox, animalActivationRange, 256, animalActivationRange );
growBB( monsterBB, player.boundingBox, monsterActivationRange, 256, monsterActivationRange );
int i = MathHelper.floor_double( maxBB.minX / 16.0D );
int j = MathHelper.floor_double( maxBB.maxX / 16.0D );
int k = MathHelper.floor_double( maxBB.minZ / 16.0D );
int l = MathHelper.floor_double( maxBB.maxZ / 16.0D );
for ( int i1 = i; i1 <= j; ++i1 )
{
for ( int j1 = k; j1 <= l; ++j1 )
{
if ( world.getWorld().isChunkLoaded( i1, j1 ) )
{
activateChunkEntities( world.getChunkFromChunkCoords( i1, j1 ) );
}
}
}
}
SpigotTimings.entityActivationCheckTimer.stopTiming();
}
示例12: checkIfActive
import org.bukkit.craftbukkit.SpigotTimings; //导入依赖的package包/类
/**
* Checks if the entity is active for this tick.
*
* @param entity
* @return
*/
public static boolean checkIfActive(Entity entity)
{
SpigotTimings.checkIfActiveTimer.startTiming();
boolean isActive = entity.activatedTick >= MinecraftServer.currentTick || entity.defaultActivationState;
// Should this entity tick?
if ( !isActive )
{
if ( ( MinecraftServer.currentTick - entity.activatedTick - 1 ) % 20 == 0 )
{
// Check immunities every 20 ticks.
if ( checkEntityImmunities( entity ) )
{
// Triggered some sort of immunity, give 20 full ticks before we check again.
entity.activatedTick = MinecraftServer.currentTick + 20;
}
isActive = true;
}
// Add a little performance juice to active entities. Skip 1/4 if not immune.
} else if ( !entity.defaultActivationState && entity.ticksExisted % 4 == 0 && !checkEntityImmunities( entity ) )
{
isActive = false;
}
// Cauldron - we check for entities in forced chunks in World.updateEntityWithOptionalForce
// Make sure not on edge of unloaded chunk
int x = net.minecraft.util.MathHelper.floor_double( entity.posX );
int z = net.minecraft.util.MathHelper.floor_double( entity.posZ );
if ( isActive && !(entity.worldObj.isActiveBlockCoord(x, z) || entity.worldObj.doChunksNearChunkExist( x, 0, z, 16 ) )) {
isActive = false;
}
if(entity instanceof EntityFireworkRocket || !entity.isAddedToChunk()) // Force continued activation for teleporting entities
{
isActive = true;
}
SpigotTimings.checkIfActiveTimer.stopTiming();
return isActive;
}
示例13: run
import org.bukkit.craftbukkit.SpigotTimings; //导入依赖的package包/类
public void run() {
try {
if (this.init()) {
// Spigot start
for (long lastTick = 0L; this.isRunning; this.R = true) {
long curTime = System.nanoTime();
long wait = TICK_TIME - (curTime - lastTick) - catchupTime;
if (wait > 0) {
Thread.sleep(wait / 1000000);
catchupTime = 0;
continue;
} else {
catchupTime = Math.min(TICK_TIME * TPS, Math.abs(wait));
}
currentTPS = (currentTPS * 0.95) + (1E9 / (curTime - lastTick) * 0.05);
lastTick = curTime;
MinecraftServer.currentTick++;
SpigotTimings.serverTickTimer.startTiming();
this.s();
SpigotTimings.serverTickTimer.stopTiming();
org.spigotmc.CustomTimingsHandler.tick();
org.spigotmc.WatchdogThread.tick();
}
// Spigot end
} else {
this.a((CrashReport) null);
}
} catch (Throwable throwable) {
throwable.printStackTrace();
this.getLogger().severe("Encountered an unexpected exception " + throwable.getClass().getSimpleName(), throwable);
CrashReport crashreport = null;
if (throwable instanceof ReportedException) {
crashreport = this.b(((ReportedException) throwable).a());
} else {
crashreport = this.b(new CrashReport("Exception in server tick loop", throwable));
}
File file1 = new File(new File(this.q(), "crash-reports"), "crash-" + (new SimpleDateFormat("yyyy-MM-dd_HH.mm.ss")).format(new Date()) + "-server.txt");
if (crashreport.a(file1, this.getLogger())) {
this.getLogger().severe("This crash report has been saved to: " + file1.getAbsolutePath());
} else {
this.getLogger().severe("We were unable to save this crash report to disk.");
}
this.a(crashreport);
} finally {
try {
org.spigotmc.WatchdogThread.doStop();
this.stop();
this.isStopped = true;
} catch (Throwable throwable1) {
throwable1.printStackTrace();
} finally {
// CraftBukkit start - Restore terminal to original settings
try {
this.reader.getTerminal().restore();
} catch (Exception e) {
}
// CraftBukkit end
this.r();
}
}
}
示例14: World
import org.bukkit.craftbukkit.SpigotTimings; //导入依赖的package包/类
public World(IDataManager idatamanager, String s, WorldSettings worldsettings, WorldProvider worldprovider, MethodProfiler methodprofiler, IConsoleLogManager iconsolelogmanager, ChunkGenerator gen, org.bukkit.World.Environment env) {
this.spigotConfig = new org.spigotmc.SpigotWorldConfig( s ); // Spigot
this.generator = gen;
this.world = new CraftWorld((WorldServer) this, gen, env);
this.ticksPerAnimalSpawns = this.getServer().getTicksPerAnimalSpawns(); // CraftBukkit
this.ticksPerMonsterSpawns = this.getServer().getTicksPerMonsterSpawns(); // CraftBukkit
// CraftBukkit end
// Spigot start
this.chunkTickRadius = (byte) ( ( this.getServer().getViewDistance() < 7 ) ? this.getServer().getViewDistance() : 7 );
this.chunkTickList = new gnu.trove.map.hash.TLongShortHashMap( spigotConfig.chunksPerTick * 5, 0.7f, Long.MIN_VALUE, Short.MIN_VALUE );
this.chunkTickList.setAutoCompactionFactor( 0 );
// Spigot end
this.O = this.random.nextInt(12000);
this.H = new int['\u8000'];
this.dataManager = idatamanager;
this.methodProfiler = methodprofiler;
this.worldMaps = new WorldMapCollection(idatamanager);
this.logAgent = iconsolelogmanager;
this.worldData = idatamanager.getWorldData();
if (worldprovider != null) {
this.worldProvider = worldprovider;
} else if (this.worldData != null && this.worldData.j() != 0) {
this.worldProvider = WorldProvider.byDimension(this.worldData.j());
} else {
this.worldProvider = WorldProvider.byDimension(0);
}
if (this.worldData == null) {
this.worldData = new WorldData(worldsettings, s);
} else {
this.worldData.setName(s);
}
this.worldProvider.a(this);
this.chunkProvider = this.j();
if (!this.worldData.isInitialized()) {
try {
this.a(worldsettings);
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.a(throwable, "Exception initializing level");
try {
this.a(crashreport);
} catch (Throwable throwable1) {
;
}
throw new ReportedException(crashreport);
}
this.worldData.d(true);
}
VillageCollection villagecollection = (VillageCollection) this.worldMaps.get(VillageCollection.class, "villages");
if (villagecollection == null) {
this.villages = new VillageCollection(this);
this.worldMaps.a("villages", this.villages);
} else {
this.villages = villagecollection;
this.villages.a(this);
}
this.A();
this.a();
this.getServer().addWorld(this.world); // CraftBukkit
timings = new SpigotTimings.WorldTimingsHandler(this); // Spigot
}
示例15: u
import org.bukkit.craftbukkit.SpigotTimings; //导入依赖的package包/类
protected void u() throws ExceptionWorldConflict { // CraftBukkit - added throws
SpigotTimings.serverTickTimer.startTiming(); // Spigot
long i = System.nanoTime();
++this.ticks;
if (this.R) {
this.R = false;
this.methodProfiler.a = true;
this.methodProfiler.a();
}
this.methodProfiler.a("root");
this.v();
if (i - this.V >= 5000000000L) {
this.V = i;
this.q.setPlayerSample(new ServerPingPlayerSample(this.D(), this.C()));
GameProfile[] agameprofile = new GameProfile[Math.min(this.C(), 12)];
int j = MathHelper.nextInt(this.r, 0, this.C() - agameprofile.length);
for (int k = 0; k < agameprofile.length; ++k) {
agameprofile[k] = ((EntityPlayer) this.u.players.get(j + k)).getProfile();
}
Collections.shuffle(Arrays.asList(agameprofile));
this.q.b().a(agameprofile);
}
if ((this.autosavePeriod > 0) && ((this.ticks % this.autosavePeriod) == 0)) { // CraftBukkit
SpigotTimings.worldSaveTimer.startTiming(); // Spigot
this.methodProfiler.a("save");
this.u.savePlayers();
// Spigot Start
// We replace this with saving each individual world as this.saveChunks(...) is broken,
// and causes the main thread to sleep for random amounts of time depending on chunk activity
server.playerCommandState = true;
for (World world : worlds) {
world.getWorld().save();
}
server.playerCommandState = false;
// this.saveChunks(true);
// Spigot End
this.methodProfiler.b();
SpigotTimings.worldSaveTimer.stopTiming(); // Spigot
}
this.methodProfiler.a("tallying");
this.g[this.ticks % 100] = System.nanoTime() - i;
this.methodProfiler.b();
this.methodProfiler.a("snooper");
if (getSnooperEnabled() && !this.l.d() && this.ticks > 100) { // Spigot
this.l.a();
}
if (getSnooperEnabled() && this.ticks % 6000 == 0) { // Spigot
this.l.b();
}
this.methodProfiler.b();
this.methodProfiler.b();
org.spigotmc.WatchdogThread.tick(); // Spigot
SpigotTimings.serverTickTimer.stopTiming(); // Spigot
org.spigotmc.CustomTimingsHandler.tick(); // Spigot
}