Java 类org.bukkit.craftbukkit.SpigotTimings 实例源码

项目:Almura-Server    文件:CraftTask.java   
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
}
项目:Tweakkit-Server    文件:DedicatedServer.java   
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
}
项目:SpigotSource    文件:DedicatedServer.java   
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
}
项目:Uranium    文件:CraftTask.java   
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;
}
项目:Uranium    文件:ActivationRange.java   
/**
 * 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;
}
项目:ThermosRebased    文件:CraftTask.java   
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;
}
项目:ThermosRebased    文件:ActivationRange.java   
/**
 * 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;
}
项目:Thermos    文件:CraftTask.java   
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;
}
项目:KCauldron    文件:CraftTask.java   
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;
}
项目:KCauldron    文件:ActivationRange.java   
/**
 * 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;
}
项目:CauldronGit    文件:CraftTask.java   
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;
}
项目:CauldronGit    文件:ActivationRange.java   
/**
 * 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;
}
项目:Cauldron-Old    文件:CraftTask.java   
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;
}
项目:Cauldron-Old    文件:ActivationRange.java   
/**
 * 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;
}
项目:Cauldron-Reloaded    文件:CraftTask.java   
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;
}
项目:Cauldron-Reloaded    文件:ActivationRange.java   
/**
 * 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;
}
项目:FFoKC    文件:CraftTask.java   
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;
}
项目:FFoKC    文件:ActivationRange.java   
/**
 * 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;
}
项目:Almura-Server    文件:ActivationRange.java   
/**
 * 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();
}
项目:Almura-Server    文件:ActivationRange.java   
/**
 * 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;
}
项目:Tweakkit-Server    文件:CraftTask.java   
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;
}
项目:Tweakkit-Server    文件:ActivationRange.java   
/**
 * 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();
}
项目:Tweakkit-Server    文件:ActivationRange.java   
/**
 * 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;
}
项目:Cauldron    文件:CraftTask.java   
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;
}
项目:Cauldron    文件:ActivationRange.java   
/**
 * 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;
}
项目:SpigotSource    文件:CraftTask.java   
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;
}
项目:SpigotSource    文件:ActivationRange.java   
/**
 * 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();
}
项目:Uranium    文件:ActivationRange.java   
/**
 * 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();
}
项目:ThermosRebased    文件:ActivationRange.java   
/**
 * 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();
}
项目:Thermos    文件:ActivationRange.java   
/**
 * 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();
}
项目:Thermos    文件:ActivationRange.java   
/**
 * 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;
}
项目:KCauldron    文件:ActivationRange.java   
/**
 * 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();
}
项目:CauldronGit    文件:ActivationRange.java   
/**
 * 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();
}
项目:Cauldron-Old    文件:ActivationRange.java   
/**
 * 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();
}
项目:Cauldron-Reloaded    文件:ActivationRange.java   
/**
 * 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();
}
项目:FFoKC    文件:ActivationRange.java   
/**
 * 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();
}
项目:Almura-Server    文件:MinecraftServer.java   
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();
        }
    }
}
项目:Almura-Server    文件:World.java   
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
}
项目:Tweakkit-Server    文件:MinecraftServer.java   
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
}
项目:Tweakkit-Server    文件:World.java   
public World(IDataManager idatamanager, String s, WorldSettings worldsettings, WorldProvider worldprovider, MethodProfiler methodprofiler, 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 net.minecraft.util.gnu.trove.map.hash.TLongShortHashMap( spigotConfig.chunksPerTick * 5, 0.7f, Long.MIN_VALUE, Short.MIN_VALUE );
    this.chunkTickList.setAutoCompactionFactor( 0 );
    // Spigot end

    this.K = this.random.nextInt(12000);
    this.allowMonsters = true;
    this.allowAnimals = true;
    this.L = new ArrayList();
    this.I = new int['\u8000'];
    this.dataManager = idatamanager;
    this.methodProfiler = methodprofiler;
    this.worldMaps = new PersistentCollection(idatamanager);
    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();
    timings = new SpigotTimings.WorldTimingsHandler(this); // Spigot - code below can generate new world and access timings
    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);
    }

    PersistentVillage persistentvillage = (PersistentVillage) this.worldMaps.get(PersistentVillage.class, "villages");

    if (persistentvillage == null) {
        this.villages = new PersistentVillage(this);
        this.worldMaps.a("villages", this.villages);
    } else {
        this.villages = persistentvillage;
        this.villages.a(this);
    }

    this.B();
    this.a();

    this.getServer().addWorld(this.world); // CraftBukkit
}