本文整理匯總了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);
}
}
}
}
示例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();
}
}
}
}
}
示例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;
}
示例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;
}
示例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();
}
}
示例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!");
}
}
示例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)
{
;
}
}
}
示例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)});
}
}
}
示例9: markPlayerActive
import net.minecraft.server.MinecraftServer; //導入方法依賴的package包/類
public void markPlayerActive()
{
this.playerLastActiveTime = MinecraftServer.getCurrentTimeMillis();
}
示例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)
{
;
}
}
}
示例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();
}
}