当前位置: 首页>>代码示例>>Java>>正文


Java MinecraftServer.getCurrentTimeMillis方法代码示例

本文整理汇总了Java中net.minecraft.server.MinecraftServer.getCurrentTimeMillis方法的典型用法代码示例。如果您正苦于以下问题:Java MinecraftServer.getCurrentTimeMillis方法的具体用法?Java MinecraftServer.getCurrentTimeMillis怎么用?Java MinecraftServer.getCurrentTimeMillis使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraft.server.MinecraftServer的用法示例。


在下文中一共展示了MinecraftServer.getCurrentTimeMillis方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: cleanupCache

import net.minecraft.server.MinecraftServer; //导入方法依赖的package包/类
/**
 * Removes BiomeCacheBlocks from this cache that haven't been accessed in at least 30 seconds.
 */
public void cleanupCache()
{
    long i = MinecraftServer.getCurrentTimeMillis();
    long j = i - this.lastCleanupTime;

    if (j > 7500L || j < 0L)
    {
        this.lastCleanupTime = i;

        for (int k = 0; k < this.cache.size(); ++k)
        {
            BiomeCache.Block biomecache$block = (BiomeCache.Block)this.cache.get(k);
            long l = i - biomecache$block.lastAccessTime;

            if (l > 30000L || l < 0L)
            {
                this.cache.remove(k--);
                long i1 = (long)biomecache$block.xPosition & 4294967295L | ((long)biomecache$block.zPosition & 4294967295L) << 32;
                this.cacheMap.remove(i1);
            }
        }
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:27,代码来源:BiomeCache.java

示例2: cleanQueryClientsMap

import net.minecraft.server.MinecraftServer; //导入方法依赖的package包/类
/**
 * Removes all clients whose auth is no longer valid
 */
private void cleanQueryClientsMap()
{
    if (this.running)
    {
        long i = MinecraftServer.getCurrentTimeMillis();

        if (i >= this.lastAuthCheckTime + 30000L)
        {
            this.lastAuthCheckTime = i;
            Iterator<Entry<SocketAddress, RConThreadQuery.Auth>> iterator = this.queryClients.entrySet().iterator();

            while (iterator.hasNext())
            {
                Entry<SocketAddress, RConThreadQuery.Auth> entry = (Entry)iterator.next();

                if (((RConThreadQuery.Auth)entry.getValue()).hasExpired(i).booleanValue())
                {
                    iterator.remove();
                }
            }
        }
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:27,代码来源:RConThreadQuery.java

示例3: getBiomeCacheBlock

import net.minecraft.server.MinecraftServer; //导入方法依赖的package包/类
/**
    * Returns a biome cache block at location specified.
    */
   @Override
public BiomeCache.Block getBiomeCacheBlock(int x, int z)
   {
       x = x >> 4;
       z = z >> 4;
       long i = (long)x & 4294967295L | ((long)z & 4294967295L) << 32;
       BiomeCache.Block biomecache$block = this.cacheMap.get(i);

       if (biomecache$block == null)
       {
           biomecache$block = new BiomeCache.Block(x, z);
           this.cacheMap.put(i, biomecache$block);
           this.cache.add(biomecache$block);
       }

       biomecache$block.lastAccessTime = MinecraftServer.getCurrentTimeMillis();
       return biomecache$block;
   }
 
开发者ID:V0idWa1k3r,项目名称:ExPetrum,代码行数:22,代码来源:WorldTypeExP.java

示例4: getBiomeCacheBlock

import net.minecraft.server.MinecraftServer; //导入方法依赖的package包/类
/**
 * Returns a biome cache block at location specified.
 */
public BiomeCache.Block getBiomeCacheBlock(int x, int z)
{
    x = x >> 4;
    z = z >> 4;
    long i = (long)x & 4294967295L | ((long)z & 4294967295L) << 32;
    BiomeCache.Block biomecache$block = (BiomeCache.Block)this.cacheMap.get(i);

    if (biomecache$block == null)
    {
        biomecache$block = new BiomeCache.Block(x, z);
        this.cacheMap.put(i, biomecache$block);
        this.cache.add(biomecache$block);
    }

    biomecache$block.lastAccessTime = MinecraftServer.getCurrentTimeMillis();
    return biomecache$block;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:21,代码来源:BiomeCache.java

示例5: run

import net.minecraft.server.MinecraftServer; //导入方法依赖的package包/类
public void run()
{
    this.logInfo("Query running on " + this.serverHostname + ":" + this.queryPort);
    this.lastAuthCheckTime = MinecraftServer.getCurrentTimeMillis();
    this.incomingPacket = new DatagramPacket(this.buffer, this.buffer.length);

    try
    {
        while (this.running)
        {
            try
            {
                this.querySocket.receive(this.incomingPacket);
                this.cleanQueryClientsMap();
                this.parseIncomingPacket(this.incomingPacket);
            }
            catch (SocketTimeoutException var7)
            {
                this.cleanQueryClientsMap();
            }
            catch (PortUnreachableException var8)
            {
                ;
            }
            catch (IOException ioexception)
            {
                this.stopWithException(ioexception);
            }
        }
    }
    finally
    {
        this.closeAllSockets();
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:36,代码来源:RConThreadQuery.java

示例6: update

import net.minecraft.server.MinecraftServer; //导入方法依赖的package包/类
/**
 * Like the old updateEntity(), except more generic.
 */
public void update()
{
    this.field_147366_g = false;
    ++this.networkTickCount;
    this.serverController.theProfiler.startSection("keepAlive");

    if ((long)this.networkTickCount - this.lastSentPingPacket > 40L)
    {
        this.lastSentPingPacket = (long)this.networkTickCount;
        this.lastPingTime = this.currentTimeMillis();
        this.field_147378_h = (int)this.lastPingTime;
        this.sendPacket(new S00PacketKeepAlive(this.field_147378_h));
    }

    this.serverController.theProfiler.endSection();

    if (this.chatSpamThresholdCount > 0)
    {
        --this.chatSpamThresholdCount;
    }

    if (this.itemDropThreshold > 0)
    {
        --this.itemDropThreshold;
    }

    if (this.playerEntity.getLastActiveTime() > 0L && this.serverController.getMaxPlayerIdleMinutes() > 0 && MinecraftServer.getCurrentTimeMillis() - this.playerEntity.getLastActiveTime() > (long)(this.serverController.getMaxPlayerIdleMinutes() * 1000 * 60))
    {
        this.kickPlayerFromServer("You have been idle for too long!");
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:35,代码来源:NetHandlerPlayServer.java

示例7: run

import net.minecraft.server.MinecraftServer; //导入方法依赖的package包/类
public void run()
{
    while (this.server.isServerRunning())
    {
        long i = this.server.getCurrentTime();
        long j = MinecraftServer.getCurrentTimeMillis();
        long k = j - i;

        if (k > this.maxTickTime && !this.firstRun)
        {
            LOGGER.fatal("A single server tick took {} seconds (should be max {})", new Object[] {String.format("%.2f", new Object[]{Float.valueOf((float)k / 1000.0F)}), String.format("%.2f", new Object[]{Float.valueOf(0.05F)})});
            LOGGER.fatal("Considering it to be crashed, server will forcibly shutdown.");
            ThreadMXBean threadmxbean = ManagementFactory.getThreadMXBean();
            ThreadInfo[] athreadinfo = threadmxbean.dumpAllThreads(true, true);
            StringBuilder stringbuilder = new StringBuilder();
            Error error = new Error();

            for (ThreadInfo threadinfo : athreadinfo)
            {
                if (threadinfo.getThreadId() == this.server.getServerThread().getId())
                {
                    error.setStackTrace(threadinfo.getStackTrace());
                }

                stringbuilder.append((Object)threadinfo);
                stringbuilder.append("\n");
            }

            CrashReport crashreport = new CrashReport("Watching Server", error);
            this.server.addServerInfoToCrashReport(crashreport);
            CrashReportCategory crashreportcategory = crashreport.makeCategory("Thread Dump");
            crashreportcategory.addCrashSection("Threads", stringbuilder);
            File file1 = new File(new File(this.server.getDataDirectory(), "crash-reports"), "crash-" + (new SimpleDateFormat("yyyy-MM-dd_HH.mm.ss")).format(new Date()) + "-server.txt");

            if (crashreport.saveToFile(file1))
            {
                LOGGER.error("This crash report has been saved to: {}", new Object[] {file1.getAbsolutePath()});
            }
            else
            {
                LOGGER.error("We were unable to save this crash report to disk.");
            }

            this.scheduleHalt();
        }

        this.firstRun = false;

        try
        {
            Thread.sleep(i + this.maxTickTime - j);
        }
        catch (InterruptedException var15)
        {
            ;
        }
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:59,代码来源:ServerHangWatchdog.java

示例8: processCommand

import net.minecraft.server.MinecraftServer; //导入方法依赖的package包/类
/**
 * Callback when the command is invoked
 */
public void processCommand(ICommandSender sender, String[] args) throws CommandException
{
    if (args.length < 1)
    {
        throw new WrongUsageException("commands.debug.usage", new Object[0]);
    }
    else
    {
        if (args[0].equals("start"))
        {
            if (args.length != 1)
            {
                throw new WrongUsageException("commands.debug.usage", new Object[0]);
            }

            notifyOperators(sender, this, "commands.debug.start", new Object[0]);
            MinecraftServer.getServer().enableProfiling();
            this.field_147206_b = MinecraftServer.getCurrentTimeMillis();
            this.field_147207_c = MinecraftServer.getServer().getTickCounter();
        }
        else
        {
            if (!args[0].equals("stop"))
            {
                throw new WrongUsageException("commands.debug.usage", new Object[0]);
            }

            if (args.length != 1)
            {
                throw new WrongUsageException("commands.debug.usage", new Object[0]);
            }

            if (!MinecraftServer.getServer().theProfiler.profilingEnabled)
            {
                throw new CommandException("commands.debug.notStarted", new Object[0]);
            }

            long i = MinecraftServer.getCurrentTimeMillis();
            int j = MinecraftServer.getServer().getTickCounter();
            long k = i - this.field_147206_b;
            int l = j - this.field_147207_c;
            this.func_147205_a(k, l);
            MinecraftServer.getServer().theProfiler.profilingEnabled = false;
            notifyOperators(sender, this, "commands.debug.stop", new Object[] {Float.valueOf((float)k / 1000.0F), Integer.valueOf(l)});
        }
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:51,代码来源:CommandDebug.java

示例9: markPlayerActive

import net.minecraft.server.MinecraftServer; //导入方法依赖的package包/类
public void markPlayerActive()
{
    this.playerLastActiveTime = MinecraftServer.getCurrentTimeMillis();
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:5,代码来源:EntityPlayerMP.java

示例10: run

import net.minecraft.server.MinecraftServer; //导入方法依赖的package包/类
public void run()
{
    while (this.server.isServerRunning())
    {
        long i = this.server.getCurrentTime();
        long j = MinecraftServer.getCurrentTimeMillis();
        long k = j - i;

        if (k > this.maxTickTime)
        {
            LOGGER.fatal("A single server tick took " + String.format("%.2f", new Object[] {Float.valueOf((float)k / 1000.0F)}) + " seconds (should be max " + String.format("%.2f", new Object[] {Float.valueOf(0.05F)}) + ")");
            LOGGER.fatal("Considering it to be crashed, server will forcibly shutdown.");
            ThreadMXBean threadmxbean = ManagementFactory.getThreadMXBean();
            ThreadInfo[] athreadinfo = threadmxbean.dumpAllThreads(true, true);
            StringBuilder stringbuilder = new StringBuilder();
            Error error = new Error();

            for (ThreadInfo threadinfo : athreadinfo)
            {
                if (threadinfo.getThreadId() == this.server.getServerThread().getId())
                {
                    error.setStackTrace(threadinfo.getStackTrace());
                }

                stringbuilder.append((Object)threadinfo);
                stringbuilder.append("\n");
            }

            CrashReport crashreport = new CrashReport("Watching Server", error);
            this.server.addServerInfoToCrashReport(crashreport);
            CrashReportCategory crashreportcategory = crashreport.makeCategory("Thread Dump");
            crashreportcategory.addCrashSection("Threads", stringbuilder);
            File file1 = new File(new File(this.server.getDataDirectory(), "crash-reports"), "crash-" + (new SimpleDateFormat("yyyy-MM-dd_HH.mm.ss")).format(new Date()) + "-server.txt");

            if (crashreport.saveToFile(file1))
            {
                LOGGER.error("This crash report has been saved to: " + file1.getAbsolutePath());
            }
            else
            {
                LOGGER.error("We were unable to save this crash report to disk.");
            }

            this.scheduleHalt();
        }

        try
        {
            Thread.sleep(i + this.maxTickTime - j);
        }
        catch (InterruptedException var15)
        {
            ;
        }
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:57,代码来源:ServerHangWatchdog.java

示例11: createQueryResponse

import net.minecraft.server.MinecraftServer; //导入方法依赖的package包/类
/**
 * Creates a query response as a byte array for the specified query DatagramPacket
 */
private byte[] createQueryResponse(DatagramPacket requestPacket) throws IOException
{
    long i = MinecraftServer.getCurrentTimeMillis();

    if (i < this.lastQueryResponseTime + 5000L)
    {
        byte[] abyte = this.output.toByteArray();
        byte[] abyte1 = this.getRequestID(requestPacket.getSocketAddress());
        abyte[1] = abyte1[0];
        abyte[2] = abyte1[1];
        abyte[3] = abyte1[2];
        abyte[4] = abyte1[3];
        return abyte;
    }
    else
    {
        this.lastQueryResponseTime = i;
        this.output.reset();
        this.output.writeInt(0);
        this.output.writeByteArray(this.getRequestID(requestPacket.getSocketAddress()));
        this.output.writeString("splitnum");
        this.output.writeInt(128);
        this.output.writeInt(0);
        this.output.writeString("hostname");
        this.output.writeString(this.serverMotd);
        this.output.writeString("gametype");
        this.output.writeString("SMP");
        this.output.writeString("game_id");
        this.output.writeString("MINECRAFT");
        this.output.writeString("version");
        this.output.writeString(this.server.getMinecraftVersion());
        this.output.writeString("plugins");
        this.output.writeString(this.server.getPlugins());
        this.output.writeString("map");
        this.output.writeString(this.worldName);
        this.output.writeString("numplayers");
        this.output.writeString("" + this.getNumberOfPlayers());
        this.output.writeString("maxplayers");
        this.output.writeString("" + this.maxPlayers);
        this.output.writeString("hostport");
        this.output.writeString("" + this.serverPort);
        this.output.writeString("hostip");
        this.output.writeString(this.queryHostname);
        this.output.writeInt(0);
        this.output.writeInt(1);
        this.output.writeString("player_");
        this.output.writeInt(0);
        String[] astring = this.server.getAllUsernames();

        for (String s : astring)
        {
            this.output.writeString(s);
        }

        this.output.writeInt(0);
        return this.output.toByteArray();
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:62,代码来源:RConThreadQuery.java


注:本文中的net.minecraft.server.MinecraftServer.getCurrentTimeMillis方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。