<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" version="2.0">

<channel>
	<title>sk89q.com / thoughts</title>
	
	<link>http://www.sk89q.com</link>
	<description />
	<lastBuildDate>Sun, 31 Mar 2013 22:46:47 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/sk89q" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="sk89q" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>WorldEdit selections for Bukkit plugins</title>
		<link>http://www.sk89q.com/2013/03/worldedit-selections-for-bukkit-plugins/</link>
		<comments>http://www.sk89q.com/2013/03/worldedit-selections-for-bukkit-plugins/#comments</comments>
		<pubDate>Sat, 16 Mar 2013 00:12:21 +0000</pubDate>
		<dc:creator>sk89q</dc:creator>
				<category><![CDATA[Minecraft]]></category>

		<guid isPermaLink="false">http://www.sk89q.com/?p=2240</guid>
		<description><![CDATA[Here&#8217;s a quick guide to using the selection API for WorldEdit from a Bukkit plugin. A large part of WorldEdit uses an abstract internal API for easy portability  For your convenience, we provide a Bukkit-native selection API that makes it easier to work with that part of WorldEdit. It is possible to &#8220;reach through&#8221; to access [...]]]></description>
				<content:encoded><![CDATA[<p>Here&#8217;s a quick guide to using the selection API for WorldEdit from a Bukkit plugin.</p>
<p>A large part of WorldEdit uses an abstract internal API for easy portability  For your convenience, we provide a Bukkit-native selection API that makes it easier to work with that part of WorldEdit. It is possible to &#8220;reach through&#8221; to access to the internal features of WorldEdit, but if you are interested in only getting selections, that shouldn&#8217;t be needed.</p>
<h2>Getting a selection</h2>
<p>To get a selection, you need to:</p>
<ol>
<li>Get a reference to <a href="http://docs.sk89q.com/worldedit/apidocs/com/sk89q/worldedit/bukkit/WorldEditPlugin.html">WorldEditPlugin</a> from Bukkit&#8217;s plugin manager.</li>
<li>Cast the reference from JavaPlugin to a more specific WorldEditPlugin.</li>
<li>Get the selection by calling <a href="http://docs.sk89q.com/worldedit/apidocs/com/sk89q/worldedit/bukkit/WorldEditPlugin.html#getSelection(org.bukkit.entity.Player)">getSelection</a>().</li>
</ol>
<p>See the snippet below.</p>
<script src="https://gist.github.com/1d534a463206bc7d9cbf.js?file=selection.java"></script><noscript><p>View the code on <a href="https://gist.github.com/1d534a463206bc7d9cbf">Gist</a>.</p></noscript>
<p><span id="more-2240"></span></p>
<p>Remember that the user may not have a selection yet, in which case, you need to detect it and notify the user.</p>
<h2>What kind of shape?</h2>
<p><a href="http://docs.sk89q.com/worldedit/apidocs/com/sk89q/worldedit/bukkit/selections/Selection.html">Selection</a>s may be cuboids — that is, they may be boxes aligned to the world. However, they may also be 2D polygons extruded vertically. Depending on your use case, you may not care (you can just get the min/max points), but if you do, the selection object returned is actually one of a more specific kind. By using &#8220;instanceof,&#8221; you can detect which kind of shape it is and act accordingly.</p>
<script src="https://gist.github.com/1d534a463206bc7d9cbf.js?file=shape.java"></script><noscript><p>View the code on <a href="https://gist.github.com/1d534a463206bc7d9cbf">Gist</a>.</p></noscript>
<p>Be aware that new shapes may be added in the future and you need to be aware of changes.</p>
<h2>Proper dependencies</h2>
<p>If you are using WorldEdit with your plugin, you may need to require that WorldEdit be loaded before your plugin. That way, you can guarantee that it&#8217;s available when your plugin is loaded. There are two kind of dependencies supported by Bukkit: a hard dependency, that requires WorldEdit to be installed for your plugin to load, or a soft one, where the loader will try its best to load your plugin at the end, but will continue if the soft dependencies are not found.</p>
<p>The following would go into your plugin.yml for a hard dependency.</p>
<script src="https://gist.github.com/1d534a463206bc7d9cbf.js?file=depend.yml"></script><noscript><p>View the code on <a href="https://gist.github.com/1d534a463206bc7d9cbf">Gist</a>.</p></noscript>
<p>In the case of soft dependencies, you can specify it as so:</p>
<script src="https://gist.github.com/1d534a463206bc7d9cbf.js?file=soft_depend.yml"></script><noscript><p>View the code on <a href="https://gist.github.com/1d534a463206bc7d9cbf">Gist</a>.</p></noscript>
<p>Be aware that the call to getPlugin() in the first snippet <strong>may return null</strong> if you are using a soft dependency.<strong><br />
</strong></p>
<h2>API stability</h2>
<p>We don&#8217;t expect to change any of this any time soon, which means you won&#8217;t have to figure out why your plugin broke because of WorldEdit! It won&#8217;t break when MC versions change either.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sk89q.com/2013/03/worldedit-selections-for-bukkit-plugins/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Mirroring your Minecraft server</title>
		<link>http://www.sk89q.com/2013/03/mirroring-your-minecraft-server/</link>
		<comments>http://www.sk89q.com/2013/03/mirroring-your-minecraft-server/#comments</comments>
		<pubDate>Sun, 10 Mar 2013 22:04:56 +0000</pubDate>
		<dc:creator>sk89q</dc:creator>
				<category><![CDATA[Minecraft]]></category>

		<guid isPermaLink="false">http://www.sk89q.com/?p=2224</guid>
		<description><![CDATA[We moved our Minecraft server from Texas to Germany about a year ago, but we had to deal with the problem of the extra latency. It got worse when we found out that the data center&#8217;s connections had a bit network jitter that caused &#8220;pauses&#8221; at random times for users farther away. I wanted to [...]]]></description>
				<content:encoded><![CDATA[<p>We moved our Minecraft server from Texas to Germany about a year ago, but we had to deal with the problem of the extra latency. It got worse when we found out that the data center&#8217;s connections had a bit network jitter that caused &#8220;pauses&#8221; at random times for users farther away. I wanted to do something about it, without moving back across the pond. Now there <i>is</i> a physical distance between two places on Earth, and there&#8217;s no magic you can do there, but some creativity can be applied to the trip itself. Because there&#8217;s no direct Internet cable between, for example, California and Germany, a packet has to travel through several &#8220;hops&#8221; along the way. While the Internet is pretty good at finding the best links between two places and the hops in between, depending on who a data center may &#8220;peer with&#8221; and many other factors, sometimes you can interject to improve the situation a little.</p>
<p>In our case, some people experienced network jitter, while others didn&#8217;t. Because it really depended on which hops the connections passed through, the idea was to force a connection through a better performing hop.</p>
<p><img class="aligncenter size-full wp-image-2225" alt="mirror" src="http://www.sk89q.com/content/2013/03/mirror.png" /></p>
<p>How do you do that exactly? By setting up a &#8220;proxy&#8221; Minecraft server at a strategic location, users who had network issues could connect to that instead, and that proxy server would theoretically have a better route to the real server. <strong>tl, dr; You can make your server perform better for everyone else in the world, not necessarily by leaps and bounds, but at least by a little!</strong></p>
<p>This provided a sometimes massive decrease in both network jitter and sometimes latency issues. In our case, because the server was in Germany, Americans sometimes benefited a fair amount. This was especially true for those in Hawaii, which is quite a bit far from Germany, and a few Hawaiians noted that it was much better with the proxy.</p>
<p><span id="more-2224"></span></p>
<p><span style="color: #888888; font-size: 20px; line-height: 30px; text-transform: uppercase;">How do you do it?</span></p>
<p>Originally, I modified the <a href="https://github.com/sk89q/scripts/blob/master/signpost/signpost.py">&#8220;signpost.py&#8221; Minecraft server</a> I wrote (for emitting server-is-down messages) to pass connections through. We used to run multiple servers on different IP addresses linked together, and because Minecraft had started <a href="http://mc.kev009.com/Protocol#Handshake_.280x02.29">passing the hostname of the server</a> that you are connecting to in the login packet, I could choose which server to connect to right when you connected to the proxy, saving us the cost of buying IPs. It was pretty cool!</p>
<p>Nowadays, I actually use <a href="http://www.ogris.de/fproxy/">fproxy</a>, which touts itself as fast &#8220;generic tcp, load-balacing, IPv6-ready (reverse) proxy.&#8221; It&#8217;s <em>small</em> and works <em>well</em>, just the right size to toss on a dirt cheap VPS instance. For Linux users, you just need download the latest version, run &#8220;make&#8221; (make sure to install gcc and other build essentials), and use something like:</p>
<p><code>./fproxy 0.0.0.0:25565 -- 1.2.3.4:25565</code></p>
<p>That&#8217;ll redirect everything on port 25565 to the IP address 1.2.3.4.</p>
<p>One thing I need to note: <strong>you need to turn off the connection throttle</strong> on the server, otherwise the server thinks you&#8217;re spamming it (because all requests come from one IP). You used to have to do this by modifying a few lines in Minecraft&#8217;s server code, but Bukkit users can now adjust this in bukkit.yml by setting <code>connection-throttle</code> to 0. For Forge servers, I&#8217;m not sure if you can do it without modifying the code, as the case with vanilla. I actually have always removed the connection throttle whenever possible because it serves no real purpose but to confuse users who are rarely aware of such a throttle.</p>
<p>If you run multiple servers, you can <a href="http://www.reddit.com/r/admincraft/comments/x6ysr/tutorial_how_to_setup_srv_records_in_13/">setup SRV records</a> and setup several proxies.</p>
<h2>Anything else I can do?</h2>
<p>Yes! There are actually some other things you can do, but they require a bit more of an introduction. I&#8217;ll have to write it in a later post when I get some time.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sk89q.com/2013/03/mirroring-your-minecraft-server/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Improving your Minecraft server’s performance</title>
		<link>http://www.sk89q.com/2013/03/improving-your-minecraft-servers-performance/</link>
		<comments>http://www.sk89q.com/2013/03/improving-your-minecraft-servers-performance/#comments</comments>
		<pubDate>Sun, 03 Mar 2013 21:16:18 +0000</pubDate>
		<dc:creator>sk89q</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Minecraft]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[server]]></category>

		<guid isPermaLink="false">http://www.sk89q.com/?p=2077</guid>
		<description><![CDATA[Sometimes running a Minecraft means struggling with server lag, and sometimes this struggle can keep you awake at night (maybe&#8230;). No one wants to play on a server where everything seems to lag, and it can be quite disconcerting to a server owner to know that his or her server isn&#8217;t as fun as it [...]]]></description>
				<content:encoded><![CDATA[<p>Sometimes running a Minecraft means struggling with server lag, and sometimes this struggle can keep you awake at night (maybe&#8230;). No one wants to play on a server where everything seems to lag, and it can be quite disconcerting to a server owner to know that his or her server isn&#8217;t as fun as it could be. It is not entirely hopeless, however; the first step to fixing a problem is to understand it.</p>
<p>As some who I have helped may know, aside from working on WorldEdit and friends, I&#8217;ve been a pretty big performance nut, having been the first person to write a /tps command for Minecraft! Reading through this article, you&#8217;ll find:</p>
<ol>
<li>An overview of the game logic loop</li>
<li>How this all applies to modded servers</li>
<li>An explanation of transient problems</li>
<li>A guide to profiling your server</li>
<li>A macro-view of improving performance</li>
</ol>
<h2>The game logic loop</h2>
<p>The most important part of Minecraft is the game loop. In there is a clock keeping everything synchronized, going tick-tock at an ideally constant rate: twenty times per second, with each tick or tock lasting hopefully at most 50 milliseconds. During each cycle, game elements have to do their work — skeletons have to figure out where to walk, minecarts have to travel forward, grass has to spread, and light problems have to be checked. That&#8217;s a lengthy to-do list, considering how many blocks and entities are on a loaded world at at time (thousands). This tick-tock interval is called the tick rate or &#8220;TPS,&#8221; and you can get some mod or plugin to give you your server&#8217;s rate.</p>
<p><img class="aligncenter" alt="vanilla" src="http://www.sk89q.com/content/2013/02/vanilla.png" /></p>
<p>Quite a few things are on the to-do list, but as far as the &#8220;main game elements&#8221; go, those items are blocks, entities, and tile entities. Blocks include simple things such as sandstone, cobble, sugar cane, and things of that nature. Entities are your standard animals and monsters, in addition to paintings, item drops, and &#8220;objects that don&#8217;t fit perfectly on a grid.&#8221; Tile entities are a special kind of block, as they can hold any type of data (think storing an inventory, something sugar cane doesn&#8217;t have to do), and sometimes they must think separately. As previously mentioned, each loop has a budget of 50ms and each portion consumes some part of this pie. Any leftover time is considered idle.</p>
<p><span id="more-2077"></span></p>
<p>Usually on an un-loaded server, it works out and you have a nice slice of idle time, but what happens when it doesn&#8217;t &#8220;work out?&#8221; That &#8220;idle&#8221; slice in the picture above is nowhere to be found — it&#8217;s simply skipped over. That means that there&#8217;s no unused time anymore, and each clock cycle consumes <em>more</em> than 50ms. Things just <em>slow down</em> because they happen less frequently (including the passing of time!). While bits of Minecraft are multi-threaded (chat, for example), the game logic loop, the part you really care about, happens in one thread only.</p>
<p>Fundamentally, the problem is that of &#8220;too many items&#8221; with &#8220;each item taking 10 nanoseconds too long.&#8221; You have two approaches:</p>
<ol>
<li>Reduce the number of entities and blocks loaded at any time.</li>
<li>Optimize the code for each block or entity to do more in less time.</li>
</ol>
<h3>Reducing numbers</h3>
<p>One very important thing to note is that the number of <em>loaded</em> chunks correlates strongly with the number of blocks and entities. A reduction in the number of loaded chunks is a reduction in the number of offending objects!</p>
<p>How do you go about reducing numbers?</p>
<ol>
<li><span style="line-height: 14px;"><strong>Unload chunks more often and more reliably.</strong> Surprisingly, doing this makes a world of a difference because Minecraft tends to &#8220;leak&#8221; chunks. This means that over time, chunks continue to stay loaded, adding more entities and blocks. It&#8217;s an extremely old bug that&#8217;s been known around for forever. <a href="http://www.spigotmc.org/">Spigot</a> is one third-party server (based on Bukkit) that provides an option to do this, though several Bukkit plugins have provided it in the past. You can also restart the server occasionally to &#8220;fix&#8221; this problem.</span></li>
<li><strong>Reduce the chunk load radius.</strong> While this should be a last resort option, the view-distance option in server.properties adjusts the chunk load distance, which exponentially decreases the number of chunks to load every time you reduce the value by 1. This can be <em>extremely effective</em>.</li>
<li><strong>Design your gameplay around reducing numbers.</strong> Your choices determine what your players will do, which may include building massive sugar cane farms that create hundreds of sugar cane blocks that drop thousands of sugar cane items.</li>
</ol>
<p>Contrary to a popular belief, the number of players on a server does not correlate that strongly with &#8220;lag.&#8221; Players themselves do not use that much CPU, and players in the same area share the same loaded chunks. The number of chunks is what you should concern yourself with.</p>
<p>Just a note: While not many people can do this, turning off monsters (and animals) basically erases a big part of the pie, which has a massive benefit but the high cost of losing those lovely creepers.</p>
<h3>Optimizing the game</h3>
<p>Okay, so you&#8217;ve gotten the number of sugar canes down, but each sugar cane is still taking a little too much! Each one might take only 0.01ms, but when you still have hundreds of them, they add up.</p>
<p>The process of optimizing the entities and block themselves is not that easy; we&#8217;re talking about reducing entity or block &#8220;think time&#8221; by mere nano-seconds. However, there are people who work on the problem, to which you can benefit from their progress. For example, the <a href="http://www.spigotmc.org/">Spigot</a> project has a few of these tweaks, and if you run a vanilla server, those changes can make a bit of a dent in reducing lag on your server.</p>
<h2>Other portions of the loop</h2>
<p>While I&#8217;ve mentioned the blocks and entities, there are other things that go on during the loop that you need to be mindful of, and a few things you may want to do are:</p>
<ol>
<li><span style="line-height: 21px;"><strong>Possibly consider disabling random &#8220;re-lighting.&#8221;</strong> As some may remember, Minecraft used to have numerous lighting bugs (dark spots) all over the place after its last major lighting update (barring the newest 1.5 update). The &#8220;fix&#8221; was to re-check lighting constantly across all chunks. Disabling this (with <a href="http://www.spigotmc.org/">Spigot</a> or by commenting out a few lines in the logic loop) can have a massive benefit with an acceptable level of lighting bugs. I can say that I&#8217;ve been doing this since this update came out (the impact was quite noticeable) and no one has really complained. (Note: Minecraft 1.5 has a new lighting system and this point may be obsolete).</span></li>
<li><strong>Look into multi-threading chunk loading.</strong> Loading chunks requires them to be read from disk (a potentially very slow operation for magnetic disks), uncompressed, and then re-constructed into chunk, entity, etc. objects. Remember that chunks are <em>constantly</em> being loaded (and saved), because players are always moving even slightly across chunk borders. If you are using Bukkit, you already have the benefit of multi-threaded chunk loading. Otherwise, the best vanilla and Forge server users can do is to at least put the server&#8217;s world files on an SSD or RAM disk, and deal with the performance hit of decompression and object initialization.</li>
<li><strong>Be mindful of chunk generation.</strong> Chunks have to be generated as the world is explored, which can, depending on how many people there are, eat quite a bit of CPU. The older your world is, the less of a problem this is, but if you are starting a new one, you <em>may</em> want to pre-generate chunks, and for all other cases, you may want to set a maximum world border.</li>
<li><strong>Take note of the plugins that you use.</strong> Sometimes they just have to do what they need to do too (i.e. a skeleton can&#8217;t think in &#8220;zero&#8221; time either) to keep synchronized with the game, and you have to be aware of the costs involved.</li>
</ol>
<p>There are other things going on in the loop, but they are not as worth mentioning. I may visit them in the future.</p>
<h2>Now, modded servers?</h2>
<p>If you do not run a modded server, you <a href="#transient-problems">can skip to the next section</a>.</p>
<p>If running a vanilla Minecraft server was not enough of a headache, it doesn&#8217;t get any better with a modded server (using mods from FTB or Tekkit, for example). Aside from the incredible number of exploits that come and go, the sometimes endless number of world crashing bugs, the unhelpful personalities that you sometimes have to deal with, getting the server to run smoothly can give you a few bald spots. But hey, it&#8217;s more fun.</p>
<p>With mods, the main change is that you know have a lot more entities and/or tile entities. (Though if you use the Forge server, you may also lose out on the improvements in Bukkit&#8217;s ecosystem, unless you use <a href="https://github.com/MinecraftPortCentral/MCPC-Plus">MCPC-Plus</a>.)</p>
<p><img class="aligncenter size-full wp-image-2026" alt="modded" src="http://www.sk89q.com/content/2013/02/modded.png" /></p>
<p>Here&#8217;s the problem though: it&#8217;s a lot more. You still want to reduce the number of items and optimize each one, but it&#8217;s much difficult when you have hundreds of new blocks and entities to manage (plus you often don&#8217;t readily have access to the code of mods). Rather, you have to take a differing approach when dealing with modded additions:</p>
<ol>
<li><span style="line-height: 14px;"><strong>Understand what the mods you install do, choosing wisely.</strong> Some mods, simply because they do more things, require more CPU. A flower mod? Probably doesn&#8217;t use that much CPU. A mod that simulates a tornado? Possibly a problem.</span></li>
<li><strong>Design gameplay around the more CPU-expensive features.</strong> Sometimes you still want the mod, even if it&#8217;s expensive. The best course of action here is to design your server around them to discourage people from using more CPU-expensive features. You can also downright disable features, but that makes for sad players.</li>
</ol>
<h3>What makes a mod expensive?</h3>
<p>Many mods have the potential to be both extremely cheap and expensive, performance wise, because it all depends on how the mod is utilized. To begin considering the potential cost of using a mod,</p>
<ol>
<li>Consider what the additions in a mod actually do, and what &#8220;algorithm&#8221; might have to run on every tick. For example, an item that has to travel through a pipe has to find destination pipes and then inch forward every tick. That&#8217;s not actually that bad, but contrast this with liquid pipes, which may have to &#8220;balance&#8221; liquid throughout the pipes, although liquid pipes are still simpler than many other things.</li>
<li>Profile the Minecraft server (and see function call elapsed times) so you know what actually does take up the most CPU, either confirming or disproving your theories. We&#8217;ll get into this later.</li>
</ol>
<p>Here are some examples:</p>
<ul>
<li>Logistics Pipes is a wonderful mod that automatically can route items between machines and inventories to do useful things such as keeping machines stocked with fuel, or distributing items across a network of chests. This, however, means that each item that enters the system requires that a destination for it be found among possibly a spider web of pipes. Supplier pipes, which routinely request from the network an item to stock a chest or machine with, can eat a lot of CPU time.</li>
<li>RedPower2 allows the creation of &#8220;frame machines&#8221; that can move many blocks at one time. Combine this with its block breakers to make an automatic mining machine. Besides the obvious problems this involves, imagine the load demanded by a machine that is moving across the world and mining large numbers of blocks (which themselves trigger physics events).</li>
<li>Greg&#8217;s Floodlights allow the lighting of long tunnels up to the light level of skylight. As Minecraft&#8217;s lighting system is fairly simple, the way the floodlights accomplish this is by placing invisible light blocks along the length of the beam. Lighting, for one, is expensive in Minecraft, and to add to that, the flood lights can be triggered by redstone.</li>
</ul>
<p>That&#8217;s not to say that there is anything wrong with those mods. You probably might want to install them! They are fun. Instead of removing them outright, design your server&#8217;s gameplay around the more problematic features so as to discourage people from using them. For example, some possibilities would be:</p>
<ol>
<li>Making Buildcraft quarries cheaper to entice people to prefer them over RedPower2 frame borers (although this is not as effective as you&#8217;d like).</li>
<li>Providing alternative ways to make cobblestone for IndustrialCraft2 scrap generation that do not require RedPower2 block breakers (which can get very expensive when you make a 100-breaker array!). Thermal Expansion provides a lag-free method of generating cobble, for example.</li>
</ol>
<h2><a id="transient-problems"></a>Transient problems</h2>
<p>We&#8217;ve so far discussed problems that are always ongoing throughout the lifetime of a server, but some issues come and go. There&#8217;s no point trying to tackle the ongoing problems until you have a handle on issues that may be pretty easy to solve. Some examples include:</p>
<ol>
<li><span style="line-height: 14px;"><strong>Item drops;</strong> They too are entities, and they consume CPU time like any other entity. With thousands of item drops on the map (which may occur due to massive sugar cane farms, for example), this can have a very significant impact on the server. Those who run modded servers are very familiar with this problem.</span></li>
<li><strong>Massive numbers of creatures;</strong> Massive mob grinders or animal farms can collect hundreds of entities that all eat up some slice of the CPU&#8217;s pie. You may need to occasionally prune monsters that are bunched together, or otherwise design gameplay mechanics accordingly to discourage people from making these farms.</li>
<li><strong>TNT;</strong> Massive TNT explosions may or may not have an impact on your server, depending on the server and the set of plugins that you use. A lot of servers outright disable TNT too. If you happen to allow TNT, you might want to conduct some tests.</li>
<li><strong>RedPower2 tubes;</strong> (modded servers only) RedPower2 tubes never drop items, which is great, but sometimes the items get stuck bouncing around the pipes. This is not that easy to do, but once in a while, someone does it on accident and it will completely murder your server (and also consume a ton of network bandwidth).</li>
</ol>
<p>That&#8217;s merely a sampling of the number of transient problems that you may have. Usually one of the best ways to identify transient problems is to profile your server, which we will cover next.</p>
<p>Be aware that WorldGuard does have a feature, <strong>/stoplag</strong>, that is basically the heavy-handed solution to a lot of vanilla transient issues. It will wipe all dropped items and monsters continually (even in newly loaded chunks), until you turn it off with <strong>/stoplag -c</strong>. (Warning: It will wipe all animals, as well as NPCs if you use Noppe&#8217;s NPC mod.)</p>
<h2>Profiling Minecraft</h2>
<p>Wouldn&#8217;t it be great to see actual numbers?</p>
<p>One plus with Java is its large ecosystem of tools for inspecting a running Java application. JVisualVM is one popular utility, and its &#8220;sampling&#8221; feature is extremely beneficial to identifying exact sources of server lag. What it does is simply to very periodically ask a Java process &#8220;what are you doing?&#8221; and then record the results, which would show, for example, if skeletons, were using 5% of the CPU time. Sampling is not accurate as &#8220;profiling&#8221; (which instead records <em>every call</em> as opposed to asking periodically), but it&#8217;s more than sufficient in this case (and a whole less server killing).</p>
<p><strong>Note:</strong> This guide assumes that you are running JVisualVM on the same system as the server, or at least have access to a desktop environment, but this is not an option for many people. In my case, I have a very light VNC setup on the server to access JVisualVM directly, but you can <a href="https://www.google.com/search?q=jvisual+over+ssh">try passing JVisualVM over SSH</a> (which doesn&#8217;t seem to work very well for me). Another option is to use X11 over SSH, but I find this horrifically slow. There&#8217;s also the option to use <a href="http://freenx.berlios.de/">FreeNX</a>. If you are using a game hosting provider, you are completely out of luck.</p>
<p>You can get JVisualVM by downloading the <a href="http://www.oracle.com/technetwork/java/javase/downloads/index.html">Java Development Kit</a>. Once you install it, you will find &#8220;jvisualvm&#8221; or &#8220;jvisualvm.exe&#8221; (for Windows users, look in C:\Program Files\Java\jdk#.##\bin, or in &#8220;Program Files (x86)&#8221; for 32-bit).</p>
<p style="text-align: center;"><a href="http://www.sk89q.com/content/2013/03/jvisualvm.png"><img class="aligncenter  wp-image-2137" alt="jvisualvm" src="http://www.sk89q.com/content/2013/03/jvisualvm.png" /></a></p>
<p>You&#8217;ll notice on the left side a list of currently open Java applications, and you should find your server somewhere on there. Double click the process.</p>
<p>Open the &#8220;Sampler&#8221; tab and click the &#8220;CPU&#8221; button to start collecting data.</p>
<p style="text-align: center;"><a href="http://www.sk89q.com/content/2013/03/sampler.png"><img class="aligncenter  wp-image-2138" alt="sampler" src="http://www.sk89q.com/content/2013/03/sampler.png" /></a></p>
<p>You will want to wait for as long as you are willing to wait to get more accurate data, and then click &#8220;Snapshot.&#8221;</p>
<p style="text-align: center;"><a href="http://www.sk89q.com/content/2013/03/snapshot.png"><img class=" wp-image-2139 aligncenter" alt="snapshot" src="http://www.sk89q.com/content/2013/03/snapshot.png" /></a></p>
<p>What you are interested in is <strong>Server thread</strong>. It is where the game logic loop resides. Expanding that node should give you the first function called (remember, in a program, functions call functions, which calls functions, which calls more). You will want to expand it until you get to the meaty part (but stick to expanding the nodes that are consuming the most CPU time).</p>
<p>It&#8217;s noteworthy to see that <strong>sleep[native]()</strong> is consuming 95.5% of the CPU time in the above screenshot. This is <strong>good</strong> — it is that &#8220;idle&#8221; part of the game logic loop, because I generated this screenshot on a server with nothing on it. You&#8217;d be in a great shape if your sleep() call showed up on the results with such a high percentage!</p>
<p>Why are the names strange? What does &#8220;r()&#8221; do? &#8220;b()&#8221;? Be aware that Mojang obfuscates the names of the code in the game (presumably to slightly complicate code theft), you will have to deal with this problem. Once you start profiling your server more often, you will learn to know what goes where. Please note that I ran this on a Bukkit server, and CraftBukkit de-obfuscates the class names (so you see MinecraftServer of MinecraftServer.r()), but you would see something like ayy.r() on a vanilla or Forge server. (If you&#8217;re on a Forge server or vanilla server, you can look at the files in conf/ from <a href="http://mcp.ocean-labs.de/index.php/Main_Page">MCP</a> to translate the names.)</p>
<p>Those are screenshots of an empty server: what would a real server look like? Here&#8217;s one on MCPC-Plus (which is a combination of Bukkit and Forge), and you can see easily what is consuming the most CPU time. It&#8217;s a modded server, and so you will see modded additions in the screenshot below:</p>
<p><img class="aligncenter size-full wp-image-2141" alt="real_data" src="http://www.sk89q.com/content/2013/03/real_data.png" /></p>
<p>I&#8217;ve expanded it to the level where entities and tile entities are processed. What we can tell from this screenshot:</p>
<ul>
<li>Buildcraft (which is a mod) is eating 21.9% of a tick&#8217;s time on its pipes.
<ul>
<li>However, most of that time is actually spent on the Logistic Pipes mod.</li>
</ul>
</li>
<li>11.6% of the time (md.j_) is spent on living entities (skeletones, sheep, etc.). &#8220;md&#8221; corresponds to the living entity class. I used MCP to translate the name, as MCPC-Plus uses obfuscated class names.</li>
<li>12.7% is spent on RedPower2 motors. This corresponds to mostly RP2 frame boring machines, which is consuming about 12% of the entire server&#8217;s CPU time (in the main thread),</li>
<li>Even though entities take up 17.5% (yc.g()), much of that percentage under that is taken up by items that take less than 1% of the time. That&#8217;s the problem of just &#8220;too many items.&#8221;</li>
<li>You could go on and analyze more of what is going on, but for now, that should serve as an example.</li>
</ul>
<p>Powerful information, isn&#8217;t it?</p>
<h2>Can I blame java?</h2>
<p>No, sadly not. While Java (or rather, the Java Virtual Machine) is known to use more memory than it may need to, CPU performance wise, it is very comparable to native code that is generated by C++ or C. That means that a port of Minecraft would not do you any good! (A rewrite would, but so would a rewrite of MC in Java.)</p>
<p>One thing I have neglected, however, to mention is that Java may need to run the &#8220;garbage collector&#8221; (that identifies unused objects and frees up memory) and it would tie up the game logic loop too, although it is not part of the loop. Before your eyes light up any further through, the JVM is defaulting to the multi-threaded garbage collectors now, meaning any lag that you may be experiencing is likely caused by other issues (unless you are on a single-core machine). That said, you <em>can</em> tweak the garbage collector in use, or even explicitly set one.<em><br />
</em></p>
<p>There are <a href="http://www.oracle.com/technetwork/java/javase/gc-tuning-6-140523.html">many articles and resources on how to tune the Java GC</a>, but a lot of the options are more suited to optimizing long-running &#8220;enterprise&#8221; Java applications with uptimes of 10 months. That is not to say that you won&#8217;t benefit, and it&#8217;s something worth to try. Off the bat, I only suggest at minimum two flags (which, as I said, may be redundant):</p>
<p><code>java <strong>-server -XX:+UseConcMarkSweepGC</strong> -jar minecraft_server.jar</code></p>
<p>You&#8217;ll find a lot of the Minecraft-related threads on the Internet about what flags you can use, and <a href="http://www.minecraftforum.net/topic/63836-making-your-server-lag-less-by-tuning-java-settings/">even I wrote one a long, long time ago</a>, but make sure that you <strong>understand what the flags you are using do,</strong> as sometimes people even suggest putting conflicting flags together!</p>
<p>Note: Java 7 has a new garbage collector named G1. I&#8217;ve heard good things about it, from people who run enterprise applications, and terrible things about it, from people who use it on Minecraft. I&#8217;ve had a poor experience using it on Minecraft myself. The flag I presented above does not use G1, but instead chooses the older Concurrent Mark and Sweep GC.</p>
<h2>The big picture</h2>
<p>We&#8217;ve been tackling the problem of performance on a micro level — looking into internals and what not — but let&#8217;s step back and see what else you can do.</p>
<ol>
<li>Throw more money at the hardware.</li>
<li>Configure your operating system accordingly to reduce overhead.</li>
<li>Multi-thread the game logic loop so it can be split among several processors or cores.</li>
<li>Run several servers and link them together.</li>
</ol>
<h3>Hardware counts, somewhat</h3>
<p>There is a limit to how much money you can throw at the hardware, at least until Minecraft&#8217;s game loop is multi-threaded. Your problem is that you do not need more cores — you need cores with faster clock speeds (think 10 Ghz), but you&#8217;re not going to find those kind of processors to buy, and at best, you can try overclocking (for home-hosted or colocated servers). If you have the funds, buy the fastest processor that you can get your hands on (preferring clock speed over the number of cores).</p>
<p>Aside from the processor, RAM does matter, but it&#8217;s more of a &#8220;minimum&#8221; that you need. If you do not have enough RAM and the server has to be swapped to disk (put into virtual memory), the performance hit is massive because the disk may be too slow, and you&#8217;d be in contention with the chunk loading. Once you have enough RAM, throwing more RAM at the server won&#8217;t do much at all.</p>
<p>However, hard disk speed, especially if you do not have multi-threaded chunk loading, can have a very big impact. This is actually where a lot of virtual private servers (VPS&#8217;s) and game server providers (GSPs) fail to meet requirements, because a lot of chunk loading and saving is being blocked by waiting on the disk (which also consumes CPU time, counted as &#8220;I/O wait&#8221;). If you&#8217;re intending on purchasing a new VPS (or even a dedicated server) for Minecraft, you should <a href="http://www.lowendtalk.com/discussion/42/test-the-disk-io-of-your-vps">test its read/write speed</a> (and several times over a period to find an average).</p>
<p>You can get around disk speed problems by using a RAM disk, which essentially makes a part of your RAM into virtual disk space. RAM is <i>absurdly </i>fast, but it comes with its own problem: everything in RAM is lost on server reboot, and so you need some way to frequently copy the server back to disk. If you use a RAM disk, make sure to <a href="http://www.sk89q.com/2013/02/running-out-of-disk-space-on-a-minecraft-server/">not underestimate the amount of space that your world will need</a> too. You can use an SSD instead, which is nowhere as fast, but still considerably quicker than magnetic disk (but be aware, SSDs don&#8217;t like a lot of writes, which Minecraft is a prime user of).</p>
<h3>Reducing system overhead</h3>
<p>Even with the right hardware, you may want to tweak your system to reduce a bit of overhead. These tips are Linux-oriented, but I&#8217;m sure users of other operating systems may have some similar (or related) courses of action:</p>
<ol>
<li><span style="line-height: 14px;"><strong>Consider enabling Linux&#8217;s &#8220;hugepages.&#8221;</strong> It reduces the overhead of accessing memory by increasing the size of Linux&#8217;s fundamental memory block size. Check your search engine on how you can do this on your particular distribution.<br />
</span></li>
<li><strong>Reduce Linux&#8217;s swappiness value.</strong> Even if you have a massive amount of RAM available, you may notice that sometimes Linux still swaps programs to disk.  If you have plenty of RAM to blow (with usually a safe amount of free RAM, to prevent sudden excruciating swaps), you can <a href="http://en.wikipedia.org/wiki/Swappiness">try setting the swappiness factor to 0</a>.</li>
<li><strong>Tune tcp_wmem/tcp_rmem accordingly.</strong> This was suggested to me (by <a href="http://www.reddit.com/user/chiisana">/u/chiisana</a>), and I&#8217;m afraid that I&#8217;ve never considered this! <a href="http://wwwx.cs.unc.edu/~sparkst/howto/network_tuning.php">See this article for more information</a>. It might help a bit overall.</li>
</ol>
<h3>Multi-thread all the things</h3>
<p>You can multi-thread the game logic loop, but this is not an easy task (and worth hundreds of hours of work). The reason is that making algorithms parallel is quite hard work, as seen below just making a simple counter parallel:</p>
<p><img class="aligncenter" alt="race_condition" src="http://www.sk89q.com/content/4013/02/race_condition1.png" /></p>
<p>Now apply that to hundreds of game blocks and entities, especially if you have mods. None of them expect it, and if you were to put them into different threads, they would all step on each others&#8217; toes and inevitably corrupt something. Some have nevertheless tried (see nallar&#8217;s <a style="line-height: inherit;" href="http://forum.feed-the-beast.com/threads/tickthreading-concurrent-entity-tile-entity-ticks-and-other-optimisations.6498/">TickThreading project</a>), and a few have made progress. Unfortunately, it is largely a hack until the entire game is redesigned from the group up with multi-threading in mind. (You can try TickThreading if you wish though, but sadly it did not work for me on a large pre-existing world.)<span style="line-height: inherit;"><br />
</span></p>
<h3>More servers</h3>
<p>Lastly, another solution is to run several servers and link them together. Many people have done this in the past, by making portal mods, shared chat mods (something I used to do), and linking serves through one common proxy server (see <a href="https://github.com/ElasticPortalSuite/BungeeCord/">BungeeCord</a>). At some point, this is your only option, and so you may want to consider organizing your server to be cash flow positive in order to pay for more servers.</p>
<h2>In conclusion</h2>
<p>As a summary of this post,</p>
<ol>
<li>Make sure you are running on good hardware (esp. for shared systems).
<ol>
<li>Ensure you have a dual-core (or processor) or better CPU available, with the fastest (and reliable) clock speed that you can get your hands on.</li>
<li>Make sure you have enough RAM so that Minecraft isn&#8217;t swapped to disk.</li>
<li>Make sure that your hard disk throughput is high enough, or consider using a RAM disk.</li>
<li>Consider tweaking your operating system to reduce overhead.</li>
</ol>
</li>
<li>Make sure to identify and remove transient problems. If your server starts lagging, look for the transient problems first and foremost.
<ol>
<li>Are people building things that drop too many items?</li>
<li>Is there some giant collection of 300 sheep somewhere on the server?</li>
<li>Did someone sent off a ton of TNT?</li>
<li>Is there some massive flow of water or lava somewhere?</li>
<li>For a modded server, are people building poorly-designed pipe systems? Frame borers?</li>
</ol>
</li>
<li>The next step is to tackle ongoing problems, and to repeat the bolded entries from above:
<ol>
<li>Install <a href="http://www.spigotmc.org/">Spigot</a> if possible.</li>
<li>Add in an auto-restarter if you do not have something to unload chunks automatically.</li>
<li>Reduce the view-distance setting in server.properties.</li>
<li>Design your gameplay to incentivize people to build less demanding things.</li>
<li>Disable random &#8220;re-lighting&#8221; of chunks if possible (with Spigot, possibly).</li>
<li>Use Bukkit if you aren&#8217;t already for multi-threaded chunk loading</li>
<li>Pre-generate chunks if necessary, and/or set a world border.</li>
<li>Go through mods and plugins to see if one of them is spending more time than you can handle at the moment. Contact their developers and see what options they can provide you (and be nice! writing fast code is not as easy as it might sound sometimes.)</li>
</ol>
</li>
<li>When in doubt, use JVisualVM (or another profiler, of several available, but JVisualVM is free) to find out the exact cause. In fact, you should use a profiler whenever possible.</li>
<li>If you just can&#8217;t squeeze enough performance out, consider making several servers.</li>
</ol>
<p>(On a relevant note, if you play with mods and your frame rate is really low, you can try using JVisualVM on the client too to figure out which mod is using the most CPU and eating into rendering!)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sk89q.com/2013/03/improving-your-minecraft-servers-performance/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Make the Steam web client compact</title>
		<link>http://www.sk89q.com/2013/03/make-the-steam-web-client-compact/</link>
		<comments>http://www.sk89q.com/2013/03/make-the-steam-web-client-compact/#comments</comments>
		<pubDate>Fri, 01 Mar 2013 21:12:20 +0000</pubDate>
		<dc:creator>sk89q</dc:creator>
				<category><![CDATA[Games]]></category>

		<guid isPermaLink="false">http://www.sk89q.com/?p=2118</guid>
		<description><![CDATA[Something wonderful I discovered just the other day was Steam&#8217;s web chat client, which is a nice changeover from the desktop application freezing all the time for me. Google Chrome users can make it a small window and make shortcuts for it with Chrome&#8217;s Tools -&#62; &#8220;Create application shortcuts&#8221; under the main menu. It&#8217;s all web-based and [...]]]></description>
				<content:encoded><![CDATA[<p>Something wonderful I discovered just the other day was <a href="http://steamcommunity.com/chat/">Steam&#8217;s web chat client</a>, which is a nice changeover from the desktop application freezing all the time for me. Google Chrome users can <strong>make it a small window and make shortcuts for it</strong> with Chrome&#8217;s Tools -&gt; &#8220;Create application shortcuts&#8221; under the main menu.</p>
<p>It&#8217;s all web-based and powered by HTML, and so with a few changes to the page to make it more compact&#8230;</p>
<p><img class="aligncenter size-full wp-image-2119" alt="steam" src="http://www.sk89q.com/content/2013/03/steam.png" /></p>
<p>To do the same, you&#8217;ll need <a href="https://chrome.google.com/webstore/detail/oiaejidbmkiecgbjeifoejpgmdaleoha">Stylebot</a> if you&#8217;re on Chrome, or something equivalent for other browsers (<a href="https://addons.mozilla.org/en-US/firefox/addon/stylish/">Stylish</a> for Firefox). After installing Stylebot, navigate to the Steam chat page, click the &#8220;css&#8221; button in the address bar (it&#8217;s to the right), click the &#8220;Edit CSS&#8221; button on the new sidebar, and then paste in the code below:</p>
<p><span id="more-2118"></span></p>
<script src="https://gist.github.com/5067645.js"></script><noscript><p>View the code on <a href="https://gist.github.com/5067645">Gist</a>.</p></noscript>
<p>If you are using the application shortcut, the CSS changes made in the main Chrome browser will also be reflected there.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sk89q.com/2013/03/make-the-steam-web-client-compact/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>From GitHub, to Redmine, to YouTrack</title>
		<link>http://www.sk89q.com/2013/02/from-github-to-redmine-to-youtrack/</link>
		<comments>http://www.sk89q.com/2013/02/from-github-to-redmine-to-youtrack/#comments</comments>
		<pubDate>Thu, 28 Feb 2013 21:07:35 +0000</pubDate>
		<dc:creator>sk89q</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.sk89q.com/?p=2105</guid>
		<description><![CDATA[The first issue tracker (for reporting bugs and keeping track of issue requests) for WorldEdit, et al. was that provided of GitHub. Primarily tag-based, you could design how people would mark issues in the way that you wanted. While the situation has gotten slightly better since we last relied on the tracker, our ultimate problem [...]]]></description>
				<content:encoded><![CDATA[<p>The first issue tracker (for reporting bugs and keeping track of issue requests) for WorldEdit, et al. was that provided of <a href="https://github.com/blog/411-github-issue-tracker">GitHub</a>. Primarily tag-based, you could design how people would mark issues in the way that you wanted. While the situation has gotten slightly better since we last relied on the tracker, our ultimate problem with this flexibility was that some users would tag issues correctly, and many others would not. The lack of consistency meant that some time would have to be spent weeding out the bad reports and keeping track of the bugs or issues that needed more priority – a problem you tend to have when you allow public reporters. It was a problem that could be dealt with, but we just weren&#8217;t willing to deal with it in any capacity.</p>
<p>We briefly tested out <a href="https://www.assembla.com">Assembla</a> 2-3 years ago to replace the tracker. It is more of an overall solution than simply a bug tracker, providing a <a href="https://www.assembla.com/features/">“workspace” with optional support for its own hosted repositories, wiki, messaging, and file uploading</a>. The features were optional and we were able to disable what we did not need. Unfortunately, the interface was cluttered – we felt that the interface was built more for the developer than your public issue reporter. As the goal was to promote the reporting of bugs and feature requests, we were hesitant to continue using Assembla. One proposal was to make a more user-friendly frontend, but we felt that it was outside the scope of our responsibility. In addition, my main concern with ditching GitHub was that it meant that new issues added on Assembla wouldn’t appear to users on GitHub who had starred the project (the community aspect is useful for an open source project), meaning that we weren’t far from the tipping point for the decision. It was not too long until we decided to return back to GitHub.</p>
<p>Sometime later, once our issues came to light again, we decided to try out <a href="http://www.redmine.org/">Redmine</a>. A popular open source Ruby-powered issue tracker, it had a few things going for it:</p>
<p><span id="more-2105"></span></p>
<ul>
<li>There was a copy I had installed around in 2007 that seemed to still work. As marginal as that sounds, installing Redmine has never been a particularly welcoming experience, requiring that you not mismatch a minor dependency version without completely breaking the installation. (Redmine has broken twice in the past for us due to some not-entirely-relevant updates.)</li>
<li>It was free to us and open source. Granted, as a not-for-profit open source project, we had many options available for us and this was not unique to Redmine, but it was definitely a plus.</li>
<li>It was easily themable if we wanted, and it was decently pretty out of the box. While function is important, aesthetics and usability was important to consider as well. Redmine seemed to fit the bill.</li>
<li>The interface of Redmine has historically been pretty straightforward. There’s not too much on the screen: just the issues, and registering and posting a new issue seemed easy enough.</li>
<li>We could define fields however we wanted, forcing people to make the right choices when prompted with the New Issue screen. Every one less mistake users made in their report was one less mistake a developer or issue tracker moderator had to fix.</li>
</ul>
<p>All seemed good, except for a major inconvenience: having to manage hundreds of issues quickly with Redmine was a chore. It supported Ajax requests – right clicking issues and choosing new states – but it required a new page refresh. If I had to make multiple changes to many requests quickly, it meant that I had to rely on the old “shift-middle-click” trick to open each change request in a new browser tab, sometimes requiring 40 tabs open in the process. Searching for issues was not the easiest and we lost the ability to tag issues entirely by switching over from GitHub. Everything just felt more of a struggle.</p>
<p>For all the features it had over GitHub, it lacked some more advanced features we desired, such as a proper issue workflow configuration.  Issues shouldn’t jump between different states randomly, especially as initiated by a user. We had users marking the priorities of their own issues as “CRITICAL” when it was anything but. The problem was no longer so much as users not putting enough tags, but now it was that users were incorrectly setting the properties of their issues.  A number of these bugs or features affecting us had been reported on Redmine’s own tracker, but many of those issues were untouched for years (possibly because their own developers found managing the issues difficult!, or so I can conjecture). Redmine was anything but a dead project, but it was not moving quickly enough for us.</p>
<p>Nevertheless, we trudged on with Redmine for over a year. We always wanted to try something new, but we weren’t willing to disappoint ourselves by choosing the wrong one. <a href="http://www.bugzilla.org/">Bugzilla</a> seemed to confuse the heck of the non-savvy folk, <a href="http://www.fogcreek.com/fogbugz/">FogzBugz</a> wasn’t free for open source projects, <a href="http://trac.edgewall.org/">Trac</a> wasn&#8217;t an option for a few reasons (which I don&#8217;t recall), <a href="http://www.atlassian.com/software/jira/">JIRA</a> bothered us with a number of smaller issues, <a href="http://www.mantisbt.org/">Mantis Bugs</a> was <i>just ugly</i> (sorry), all the other smaller SaaS issue trackers seem too young and lacked far too many features (which was sometimes billed as “less clutter”), and the list just goes on.</p>
<h2>Enough was enough</h2>
<p>Towards the end of last year, I had taken a short break prior and returned to the tracker, finding it filled with hundreds of simply invalid bugs that everyone else had appeared to stop caring to prune. I began the task of pruning myself, but at some point I decided that it was just not worth it. We needed a new issue tracker.</p>
<p><img class="aligncenter size-full wp-image-2106" alt="redmine" src="http://www.sk89q.com/content/2013/02/redmine.png" /></p>
<p>Years of dealing with the problem meant that we had weeded out most of the other issue trackers and we ended up choosing between three:</p>
<ul>
<li>Bugzilla, because it has a long history and was used by a number of large organizations. It also had improved a lot over the years, even taking on a new default theme so that it would no longer look “from 1995” out of the box.</li>
<li>JIRA, simply because it had a very large feature set and filled nearly all our needs. It had a very capable workflow editor and provided support for numerous 3<sup>rd</sup>-party plugins.</li>
<li><a href="http://www.jetbrains.com/youtrack/">YouTrack</a> was actually new to us. None of us were aware of it previously, but perhaps because the tracker had made huge gains in features in the previous few years. We were familiar with <a href="http://www.jetbrains.com/idea/">JetBrain’s other work</a>, and we were generally impressed.</li>
</ul>
<p>I installed the trial versions of JIRA and YouTrack and asked various people to play with it and provide me with their opinion. Bugzilla was already familiar to everyone and so I skipped over a trial installation for that (and because I didn’t want to set up a Perl script again). The general response was:</p>
<ul>
<li>People either loved or hated Bugzilla. This wasn’t really useful to making a decision, and so we just put Bugzilla at the bottom of the list for the time being.</li>
<li>The most common complaint about JIRA was that it was “slow.” On load, it definitely required a lot of resources, but once everything had been cached, the interface was fairly quick. I’m sure on a local network, there would not be an issue at all, but this would be hosted over the Internet and perception was everything. Because of that, there was quite a bit of resistance to JIRA.</li>
<li>People commonly complained about YouTrack’s interface being “too different.” It doesn’t normally use a table-based view, something many people are used to, and the new issue screen has a radical display where the field names (type, priority, milestone) are not displayed, which worried us as to whether people would start plugging in the wrong choices. It was just all around different.</li>
</ul>
<h2>Choosing the right one</h2>
<p>YouTrack was, as you may know, our eventual choice, and we don’t regret it. Everyone got used to the interface and it was not a problem at all. Users didn’t have a problem with navigating the tracker, as it was so straight forward (and yet powerful). One cool thing about YouTrack is that it has a <a href="http://blog.jetbrains.com/youtrack/2012/02/spicing-up-youtrack-with-workflows/">proper downloadable Workflow Editor</a> utilizing its own powerful DSL, which was miles more convenient than having to work through <a href="https://confluence.atlassian.com/display/JIRA/Configuring+Workflow">JIRA’s numerous dialogs to setup a simple workflow</a>. In fact, I had grand plans to set up an elaborate workflow to prevent users from misreporting issues, but we ended up only needed a few simple rules.</p>
<p>Why? Navigating issues was a breeze, and the problems we had with people misreporting bugs turned out to be not as big of a problem anymore. The best part is probably the search bar at the top: you can filter issues exactly how you want using its expressive search language. Also partially command driven, rather than having to click through several dialogs to complete more complex tasks, you can just type a few commands in the right place. Before every release, we make sure to look through certain searches to make sure that we have not forgotten anything, something we didn&#8217;t find as easy to do with other trackers.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sk89q.com/2013/02/from-github-to-redmine-to-youtrack/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Version control all the things</title>
		<link>http://www.sk89q.com/2013/02/version-control-all-the-things/</link>
		<comments>http://www.sk89q.com/2013/02/version-control-all-the-things/#comments</comments>
		<pubDate>Mon, 25 Feb 2013 23:17:01 +0000</pubDate>
		<dc:creator>sk89q</dc:creator>
				<category><![CDATA[Minecraft]]></category>
		<category><![CDATA[deployment]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[server]]></category>

		<guid isPermaLink="false">http://www.sk89q.com/?p=2082</guid>
		<description><![CDATA[Version control is practically essential to any software project, and it can be extremely useful even for your Minecraft server. What it does is simple: track any change, either large or small, knowing exactly who made the change, when the change was made, and exactly what the changes were. Software projects tend to use them because of [...]]]></description>
				<content:encoded><![CDATA[<p>Version control is practically essential to any software project, and it can be extremely useful even for your Minecraft server. What it does is simple: track any change, either large or small, knowing exactly <em>who</em> made the change, <em>when</em> the change was made, and exactly <em>what</em> the changes were. Software projects tend to use them because of those benefits, but if you aren&#8217;t already, there are many benefits to tracking every plugin, mod, or configuration change made to your server.<br />
<img class="aligncenter size-full wp-image-2093" alt="changelog" src="http://www.sk89q.com/content/2013/02/changelog.png" /></p>
<ul>
<li><span style="line-height: 14px;">Easily spread around the work of updating the server (or corresponding client) with others. No more figuring out how to merge changes when you need to send files to other team members. Compared to Dropbox, you have far more tools available to you with a proper version control system — easily see differences down to individual lines.</span></li>
<li>Track every &#8220;release&#8221; of your server, which means that you can know exactly what was updated on what day, and most importantly, allow you to <em>rollback</em> to a prior release without having to scrounge around for the old files or old configurations.</li>
<li>If combined with a &#8220;deployment script,&#8221; you can just plug in a version that you want (i.e. release-2013-02-20) and your server could be automatically updated. Did the update go badly? Return to an old version (release-2013-02-16 perhaps?) instantly.</li>
</ul>
<p><span id="more-2082"></span></p>
<p>When we need to update the server (or client, in the case of a modded server), it&#8217;s just a matter of a few commands. It is almost a luxury to do updates (well, at least until you realize mod X eats all the bandwidth and plugin Y has a dupe exploit you missed).</p>
<h2>Picking a version control system</h2>
<p><img class="aligncenter size-full wp-image-2101" alt="servers" src="http://www.sk89q.com/content/2013/02/servers.png" /></p>
<p>The most remarkable difference between version control systems (VCS) is whether one is &#8220;distributed&#8221; or not.</p>
<ul>
<li>With a non-distributed VCS, a central server stores all of the history and each person with access has a copy of the latest version. Changes made must be immediately sent to the server when &#8220;committed&#8221; (at least historically; some systems have updated to be more competitive with distributed systems).</li>
<li><span style="line-height: 14px;">A distributed VCS does not require a central server to store the entire repository. Each person has an entire copy with all of the history, and each person can make changes independently, and multiple commits can be collected together before they are pushed to a central server. Distributed VCS software still allows for collaboration, but the server hosting the repository is not particularly special: it merely has the copy that everyone else synchronizes with.</span></li>
</ul>
<p>I personally strongly recommend <a href="http://www.git.com/">Git</a>, a popular distributed VCS used for WorldEdit, Bukkit, and many other projects. It has good support for non-text files too, which is perfect when you need to store binary code (.jars and such).</p>
<h2>Now that I&#8217;ve chosen Git for you</h2>
<p>You need to get Git. For Linux users, you can get it from your operating system&#8217;s package manager. Windows users should install <a style="line-height: inherit;" href="https://code.google.com/p/msysgit/downloads/list?q=full+installer+official+git">mysysgit</a> (I recommend selecting &#8220;Use from command line&#8221; during install), but they should also consider installing <a style="line-height: inherit;" href="https://code.google.com/p/tortoisegit/">TortoiseGit</a> too, which allows right clicking folders in Windows Explorer and using Git with an actual GUI. Mac OS X users <a style="line-height: inherit;" href="https://code.google.com/p/git-osx-installer/">can get an installer</a> and can also <a style="line-height: inherit;" href="http://gitx.frim.nl/">get a GUI too</a>.</p>
<p>Furthermore, if you are working with others or wish to later &#8220;deploy&#8221; the changes to a server from that server itself (if you have a VPS or dedicated server), you may want to host a version of your repositories somewhere. It provides a central place for several people to synchronize changes with. Many services provide public open source repositories for free, but you probably are considering a private option.</p>
<ul>
<li><span style="line-height: 14px;"><a href="https://github.com/plans">GitHub</a> is arguably the most popular Git service provider. They charge for the number of repositories that you have, but allow for an unlimited number of collaborators, with a micro plan starting at $7/mo (as of writing).</span></li>
<li><a href="https://bitbucket.org/">BitBucket</a> charges by the number of collaborators, but allows for an unlimited number of repositories. They also have a free plan as well, which you may want to start out with.</li>
<li>You can also set up Git on your own server if you have one. Linux users can setup <a href="https://github.com/sitaramc/gitolite">Gitolite</a>.</li>
<li>There are also many other services that provide Git hosting, which you can look for. <a href="https://www.assembla.com">Assembla</a> is another one.</li>
</ul>
<p>How Git authenticates you is not through a password: you need to generate an SSH key, which is kind of like a super long cryptographically-generated password (but a bit more than that). You can generate a key using ssh-key-gen on Mac OS X or Linux, or with <a href="http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html">PuTTYgen</a> on Windows. Two keys will be generated: a public one to give to the host that you may have chosen (GitHub, BitBulcet, etc.), and a private one you need to keep secret and that you will use to authenticate yourself.</p>
<h2>Using Git</h2>
<p>One minor downside to Git is its higher learning curve, but the effort will pay off. Let&#8217;s first review some of the words that you will have to know to start, some of which are common to all version control systems.<br />
<img class="aligncenter size-full wp-image-2097" alt="branching" src="http://www.sk89q.com/content/2013/02/branching.png" /></p>
<ul>
<li>The log is your log of changes.</li>
<li>A commit is a set of changes that you make together and then apply a description to (i.e. &#8220;Fixed X and Y&#8221;).</li>
<li>A branch is a &#8220;fork&#8221; of your repository, which a separate list of changes that can diverge from the main branch.</li>
<li>A merge is the merging of changes from a different branch (to the top of the current branch&#8217;s list of changes).</li>
<li>A conflict is when automatic merging fails because two people modified the same file at the same place.</li>
<li>Pushing is sending changes to a server.</li>
<li>Pulling or fetching is receiving the latest changes from a server.</li>
<li>A clone is the process of downloading the entire copy of a repository.</li>
</ul>
<p>Sadly, a full-blown tutorial for using Git is a bit outside the scope of this article, but Git has a wonderfully large number of resources. You can <a href="http://try.github.com/levels/1/challenges/1">start by using this interactive Git tutorial</a> and continue on by <a href="http://git-scm.com/documentation">reading this Git book</a>. Linux (and Mac OS X) <a href="http://gitimmersion.com/">users can also try this step by step introduction</a>. If none of that fancies you, you can try searching the web, or possibly asking a few of your programmer friends :)</p>
<p>Be aware that Git is predominately a command line program, but if you had installed a GUI, you can try using that. The processes and terminology carry over; you just know need to press the right buttons!</p>
<p>On the subject of a deployment script, it is much easier if you control the server that Minecraft is hosted on. That way, you can simply download the latest changes from Git and copy them over to where the server&#8217;s files are stored. Otherwise, you may have to use something to upload the files over FTP. Sadly I do not have an example deployment script to provide, as mine is fairly specific to my case, but all you need to do (which you can even put as lines in a .bat file) is download the latest changes using the right git commands (i.e. git pull, or git checkout release-XXXXX) and then copy files as needed (or compile plugins, or whatever).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sk89q.com/2013/02/version-control-all-the-things/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Minecraft server on a full disk</title>
		<link>http://www.sk89q.com/2013/02/running-out-of-disk-space-on-a-minecraft-server/</link>
		<comments>http://www.sk89q.com/2013/02/running-out-of-disk-space-on-a-minecraft-server/#comments</comments>
		<pubDate>Wed, 20 Feb 2013 20:44:21 +0000</pubDate>
		<dc:creator>sk89q</dc:creator>
				<category><![CDATA[Games]]></category>
		<category><![CDATA[Minecraft]]></category>
		<category><![CDATA[chunk]]></category>
		<category><![CDATA[disk space]]></category>

		<guid isPermaLink="false">http://www.sk89q.com/?p=1928</guid>
		<description><![CDATA[Recently, a Minecraft server I host used up all the disk space on its RAM drive, and consequently bad things resulted, but it further worsened by the fact that my friend kept the server running for eight hours more. The following is an explanation of what occurs when the Minecraft server keeps running but with [...]]]></description>
				<content:encoded><![CDATA[<p>Recently, a Minecraft server I host used up all the disk space on its RAM drive, and consequently bad things resulted, but it further worsened by the fact that my friend kept the server running for eight hours more. The following is an explanation of what occurs when the Minecraft server keeps running but with no actual available disk space.</p>
<h2>Running out of disk space</h2>
<p>Does running out of disk space cause data loss? Not necessarily. Picture a chunk file as the example below, with three different chunks stored in different &#8220;slots.&#8221; The three squares represent disk space already &#8220;acquired&#8221; on the disk as one single .mca file, with the white areas representing acquired (from the PoV of a hard drive) but unused (from the PoV of Minecraft) space.</p>
<p><img class="aligncenter size-full wp-image-1929" alt="chunk" src="http://www.sk89q.com/content/2013/02/chunk.png" /></p>
<p>Sometimes a chunk needs to be enlarged, but only some activities do that. If you are placing down &#8220;simple&#8221; blocks like sandstone or cobble, you&#8217;re just changing a few bits of data in the chunk, so the chunk does not need to be resized. However, this is different when you add new entities (mobs, such as skeletons, or item drops, etc.) or new tile entities (more complex blocks, like chests, furnaces, etc.) because the existing space isn&#8217;t enough to store all the new data (think inventories!). Those changes require more disk space to store the chunk.</p>
<p><img class="aligncenter" alt="chunk1" src="http://www.sk89q.com/content/2013/02/chunk1.png" /></p>
<p>But even then, even if the hard drive itself is out of space, sometimes it is OK. The middle chunk above still has &#8220;room&#8221; to expand. The white space available was already, as mentioned previously, acquired on the disk.</p>
<p>The problems appear when the slot that the chunk is already contained within becomes too small to fit the newest version of that chunk. What happens is that a new free area has to be found in the file that can fit the chunk, but if that cannot be found, the chunk is placed at the end of the file. Placing data at the end of the file means that the entire file itself has to be enlarged, therefore requiring more actual disk space usage. When the hard disk is out of space, the extra data has nowhere to go. Because the header of the .mca file indexes where a particular chunk is stored, the index for this chunk may now point to this section of the file that cannot actually be written, causing the chunk to simply &#8220;disappear&#8221; on next load.</p>
<p><img class="aligncenter" alt="chunk2" src="http://www.sk89q.com/content/2013/02/chunk2.png" /></p>
<p>As seemingly irrelevant this information is to the world outside Minecraft, this also explains the same problem that your computer has when saving something to disk. When you save a file, it has the same, sometimes difficult, task: find a place to store the bits. If you&#8217;ve ever heard about &#8220;fragmentation,&#8221; that is when, rather than simply moving the entire file to another place, the file is split across across several areas. Of course, while Minecraft can put more data at the end of the file, your hard drive has a fixed amount of total space. The chunk format used by Minecraft does not do fragmentation.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sk89q.com/2013/02/running-out-of-disk-space-on-a-minecraft-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Speaking of signature verification</title>
		<link>http://www.sk89q.com/2013/02/using-my-minecraft-launcher-to-pull-custom-updates/</link>
		<comments>http://www.sk89q.com/2013/02/using-my-minecraft-launcher-to-pull-custom-updates/#comments</comments>
		<pubDate>Tue, 19 Feb 2013 08:25:39 +0000</pubDate>
		<dc:creator>sk89q</dc:creator>
				<category><![CDATA[Minecraft]]></category>

		<guid isPermaLink="false">http://www.sk89q.com/?p=1874</guid>
		<description><![CDATA[One seemingly silly problem to deal with for those who host a &#8220;modded&#8221; Minecraft server is getting people to properly install those modifications. Copying a few files here and there seems simple enough, but it would be silly to say that connecting a backup generator to an electrical mains should be easy, just because it [...]]]></description>
				<content:encoded><![CDATA[<p>One seemingly silly problem to deal with for those who host a &#8220;modded&#8221; Minecraft server is getting people to properly install those modifications. Copying a few files here and there seems simple enough, but it would be silly to say that connecting a backup generator to an electrical mains should be easy, just because it was easy to someone who dealt in the business. It comes down to an issue of numbers: if the difficulty was, for example, 10% harder, that could mean that there are 20% less people who can do it.</p>
<p>Several months ago, I updated my Minecraft launcher to support custom downloads and open sourced the entire launcher. While the update system worked pretty well, there was one caveat: it required that downloads be digitally signed, similar in principle to the browser verification of yourbank.com truly coming from yourbank.com. Setting up digital signatures is pretty straightforward, but it’s a straightforward in the same vein as client installation – it is easy if you are familiar with the tasks involved. For that reason, as of today, I have decided to disable digital signature verification for custom packages, which should make it vastly easier (vanilla downloads from Mojang are unaffected). I was trying hard to avoid this, but other, more elegant options require a currently unrealistic input of time and effort from me.</p>
<p><strong>tl;dr: I have made a change to my Minecraft launcher which vastly makes the use of the custom update feature easier to setup, which allows you to setup a custom modified MC client for people.</strong> Use it to make playing with friends less hectic, or use it to distribute necessary files for a modded server. After following the steps described within this post, you should be able to distribute your own files and install them into a user&#8217;s game. Towards the end of the post will be a discussion of some non-technical issues involved with this. <a href="http://build.sk89q.com/job/SKMCLauncher/">Update to the latest version of the launcher</a> to use this newest change.</p>
<h2>Building the package</h2>
<p><img class="aligncenter size-full wp-image-1988" alt="update" src="http://www.sk89q.com/content/2013/02/update.png?3" /></p>
<p>You&#8217;ll need three files:</p>
<ol>
<li>A .zip file containing the files to install. This archive should contain files that would be placed into the root Minecraft folder (aka. .minecraft).</li>
<li>A package XML file containing a list of files to install, with a link to the ZIP archive.</li>
<li>An update XML file containing a link to the package file and a version string.</li>
</ol>
<p><span id="more-1874"></span></p>
<p>The package XML file is the more complicated file, as it has to contain all the files that need to be installed even on a fresh installation of Minecraft. You&#8217;ll see in the example file below three <code>&lt;filegroup&gt;</code> sections, the first of which is your main concern, as it points to the ZIP archive mentioned above. The other file group sections merely point the launcher to where additional required Minecraft files can be acquired. As you may notice, you would have to change the directory URL for the ZIP file, the filename of the ZIP file, as well as the size in bytes so that the launcher can accurately draw the download progress bar.</p>
<script src="https://gist.github.com/4983914.js?file=package.xml"></script><noscript><p>View the code on <a href="https://gist.github.com/4983914">Gist</a>.</p></noscript>
<p>The latter update XML file is considerably simple. The version string you choose can be anything, but it must stay the same until you issue an update. Upon the launcher finding a different version, it will download the referenced URL to update. The URL points to the current latest package version.</p>
<script src="https://gist.github.com/4983914.js?file=update.xml"></script><noscript><p>View the code on <a href="https://gist.github.com/4983914">Gist</a>.</p></noscript>
<p>Once you&#8217;ve placed all three files on a web server somewhere, fire up the launcher, create a new configuration, choose a folder to store the files, and insert the URL to the update XML file.</p>
<h2>Installation mechanisms</h2>
<p>The next question arises is that of &#8220;how does the launcher actually install the file?&#8221; It simply extracts the files over the Minecraft directory and overwrites any files. As for updates, the launcher keeps track of the list of files from prior updates and removes any files that disappeared between updates. A player&#8217;s saves would not be removed because it would not be part of the download ZIP, but any configuration change made by the user on a file added by the update would be wiped on next update. Overall, this process allows for very simple installation at the cost of some flexibility.</p>
<p><img class="aligncenter size-full wp-image-1997" alt="update_logic" src="http://www.sk89q.com/content/2013/02/update_logic.png" /></p>
<p>Support for incremental updates is there, as the resources downloaded from Mojang use that, but it is a bit convoluted and meant to fit in with Mojang&#8217;s existing download scheme. I may detail how it works in a future post, but for now, sticking to full updates is easier to get working.</p>
<h2>The other issues</h2>
<p>What about minecraft.jar? You have bundle that with the .zip (to keep it simple for you), which is not entirely kosher, but remember that you can already download Minecraft (without logging in) from <a href="http://assets.minecraft.net">assets.minecraft.net</a>. However, this decision is up to you.</p>
<p>The second issue is that you may distribute other people&#8217;s work, which will inevitably happen, and so I can only ask of you to be sure that to have permission to distribute the files. The terms are often mentioned on people&#8217;s posts, but send them a friendly message if they are not clear about it.</p>
<p>There are currently a few rough edges with the launcher. The fact that you have to fiddle with the configuration screen is not ideal, and the fact that you can&#8217;t just two click add a configuration is another dislike from me. Letting users add their own client customization is also not so easy, although it could argued that you would not want to make that easy. If you distribute your own copy of the launcher (and make appropriate modifications), these rough edges disappear, but this is obviously not the best option. I will see if I can find some time to sand out some of the left over difficulties. Remember that <a href="https://github.com/sk89q/skmclauncher">you can contribute to the project</a>, as it is open source.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sk89q.com/2013/02/using-my-minecraft-launcher-to-pull-custom-updates/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
		</item>
		<item>
		<title>Hey look, I’m you with your privileges</title>
		<link>http://www.sk89q.com/2012/07/fixing-the-minecraft-session-stealer-exploit/</link>
		<comments>http://www.sk89q.com/2012/07/fixing-the-minecraft-session-stealer-exploit/#comments</comments>
		<pubDate>Sat, 07 Jul 2012 17:58:31 +0000</pubDate>
		<dc:creator>sk89q</dc:creator>
				<category><![CDATA[Minecraft]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://www.sk89q.com/?p=1819</guid>
		<description><![CDATA[Update: The man-in-the-middle attack described in this post is now ineffective as it was fixed in Minecraft 1.3, but the solution still works if you desire extra security. A &#8220;session stealer&#8221; exploit in Minecraft is now being used increasingly widely to gain operator privileges on a target server. Anyone with the ability (or the freely [...]]]></description>
				<content:encoded><![CDATA[<p><ins>Update:</ins> The man-in-the-middle attack described in this post is now ineffective as it was fixed in Minecraft 1.3, but the solution still works if you desire extra security.</p>
<p>A &#8220;session stealer&#8221; exploit in Minecraft is now being used increasingly widely to gain operator privileges on a target server. Anyone with the ability (or the freely available tools) can impersonate another user, which comes in handy to gain elevated privileges on a given server. The underlying exploit is actually extremely old, and while a small number of people have long been aware of it, news broke to the greater community recently and now it is a real relevant concern. On the flip side, the bug will finally be fixed (after three years) with the release of Minecraft 1.3. Hooray public disclosure.</p>
<p><img class="aligncenter size-full wp-image-2000" alt="exploit_logic" src="http://www.sk89q.com/content/2012/07/exploit_logic.png" /></p>
<h2>But I don&#8217;t want to wait for a fix</h2>
<p>If you run a server, it&#8217;s understandable that you would want a fix now. You can ensure that you don&#8217;t expose your own account, but you also have to ensure that your own moderators do not either. That can be harder than it sounds, especially depending on who you are working with, and so some — even minor — protection to use would be nice. Unfortunately, it is not possible to fix the problem from just the server&#8217;s side, and so people have attempted to work around the problem by using a mix of some rather inconvenient solutions (mostly involving a /login command). Instead, I decided on a different novel way to protect the accounts of my moderators, described below.</p>
<p><span id="more-1819"></span></p>
<ol>
<li>It doesn&#8217;t require any client-side changes;</li>
<li>It is a one-time setup for everyone;</li>
<li>It completely fixes the exploit for your server;</li>
<li>And it is grossly simple to setup.</li>
</ol>
<p>All it requires is that everyone that you want to protect to switch to connecting with a secret server address instead. This solution exploits the fact that, when you connect to a Minecraft server, the address used is sent to that server. If your friend has a special address to use, and someone foreign tries to login to the server without that special address, the server has a clear indication that your friend is not really your friend. Some examples of address that you can use include:</p>
<ul>
<li>noHeY.example.com</li>
<li>zqTPa.example.com</li>
<li>5v9h0.example.com</li>
<li>nmJka.example.com</li>
</ul>
<p><img class="aligncenter size-full wp-image-2003" alt="working_example" src="http://www.sk89q.com/content/2012/07/working_example.png" /></p>
<p>When an attacker tries the exploit:</p>
<p><a href="http://www.sk89q.com/content/2012/07/working_example2.png"><img class="aligncenter size-full wp-image-2004" alt="working_example2" src="http://www.sk89q.com/content/2012/07/working_example2.png" /></a></p>
<h2>So, how do I actually use this?</h2>
<p>Before you setup the Minecraft server, you have to first set up the secret domains. There are, fortunately or unfortunately, a dozen different ways to do this, all depending on your particular setup. While I can&#8217;t delve deep into this in this post, I can recommend that you setup a wildcard DNS entry if possible, so all subdomains (*.example.com) get sent to your server. That way, an attacker can&#8217;t so easily guess domains and test their guesses. Another option, however, is to use your computer&#8217;s &#8220;hosts file&#8221; (search this up) in order to manually map any domain, even one that you do not own, to point to a certain IP address. This latter option is the safest, but it is also does require a bit more work from everyone involved.</p>
<p>On the Minecraft server side of this fix, I have added a check feature into WorldGuard (Bukkit required) that lets you check the connecting address of certain players, which you can apply to the accounts of your moderators. <a href="http://dev.bukkit.org/server-mods/worldguard/">Download the latest version</a>, and then setup your plugins/WorldGuard/config.yml to look like:</p>
<script src="https://gist.github.com/9a6df391d205327efc8d.js"></script><noscript><p>View the code on <a href="https://gist.github.com/9a6df391d205327efc8d">Gist</a>.</p></noscript>
<p>Be aware that this is, however, not a proper fix. It will protect a server, but it will not protect an account. If a session gets stolen, the attacker would not be able to use it on your server, but the account can be used on any other server. There is nothing much a server owner can really do (besides more drastic measures) and we are all waiting on Mojang to properly fix this problem.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sk89q.com/2012/07/fixing-the-minecraft-session-stealer-exploit/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>My open source launcher</title>
		<link>http://www.sk89q.com/2012/03/open-sourced-minecraft-launcher/</link>
		<comments>http://www.sk89q.com/2012/03/open-sourced-minecraft-launcher/#comments</comments>
		<pubDate>Sun, 18 Mar 2012 01:09:28 +0000</pubDate>
		<dc:creator>sk89q</dc:creator>
				<category><![CDATA[Minecraft]]></category>

		<guid isPermaLink="false">http://www.sk89q.com/?p=1802</guid>
		<description><![CDATA[I&#8217;ve opened sourced my Minecraft launcher! It has support for easy installation of addons, Minecraft updating, and other cool things. You can find compiled versions (and a link to the source) on the MC forums.]]></description>
				<content:encoded><![CDATA[<p>I&#8217;ve opened sourced my Minecraft launcher! It has support for easy installation of addons, Minecraft updating, and other cool things.</p>
<div style="text-align: center;"><a href="http://www.sk89q.com/content/2012/03/SKs_Minecraft_Launcher-2012-03-17_16.27.51.png"><img class="aligncenter size-medium wp-image-1805" title="SKs_Minecraft_Launcher-2012-03-17_16.27.51" alt="" src="http://www.sk89q.com/content/2012/03/SKs_Minecraft_Launcher-2012-03-17_16.27.51-187x300.png" width="187" height="300" /></a></div>
<p>You can find compiled versions (and a link to the source) <a href="http://www.minecraftforum.net/topic/1104030-launcher-sks-launcher-v310-easily-install-addons-update-mc-open-source/">on the MC forums</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sk89q.com/2012/03/open-sourced-minecraft-launcher/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
	</channel>
</rss><!-- Dynamic page generated in 0.300 seconds. --><!-- Cached page generated by WP-Super-Cache on 2013-05-20 13:29:29 --><!-- Compression = gzip -->
