Book Image

Building Minecraft Server Modifications - Second Edition

By : Cody M. Sommer
4 (1)
Book Image

Building Minecraft Server Modifications - Second Edition

4 (1)
By: Cody M. Sommer

Overview of this book

Minecraft is a sandbox game that allows you to play it in any way you want. Coupled with a multiplayer server powered by Spigot, you can customize the game even more! Using the Bukkit API, anyone interested in learning how to program can control their Minecraft world by developing server plugins. This book is a great introduction to software development through the wonderful world of Minecraft. We start by instructing you through how to set up your home PC for Minecraft server development. This includes an IDE complete with the required libraries as well as a Spigot server to test on. You will be guided through writing code for several different plugins. Each chapter teaches you new skills to create plugins of increasing complexity, and each plugin adds a new concept of the Bukkit API By the end of the book, you will have all the knowledge you need about the API to successfully create any type of plugin. You can then practice and build your Java skills through developing more mods for their server.
Table of Contents (17 chapters)
Building Minecraft Server Modifications Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Setting up a new server


You will see the server folder populated with several files and folders. The purpose of some of these are explained in this section, but most of the files should not concern you at present:

  • plugins: This folder is where you will place all the Bukkit plugins that you wish to use on the server.

  • world: The folders that begin with world, such as world, world_nether, and so on, include all the information for the new world of the server. If you already have a Minecraft world that you wish to use, then replace these new folders with the old world folders. Do not attempt to do this while the server is running as it will cause problems.

  • server.properties: This file holds several options that allow you to change how a Minecraft server operates. You can open it with a text editor. There are many settings, and most of them are pretty self-explanatory. I will go over a few settings in the following list that you may want to modify. For a full list of property explanations, you can visit www.minecraftwiki.net/wiki/Server.properties. Changing any of these settings will require you to restart the server.

    • pvp=true: The pvp property can be set to a boolean value. PvP (short for Player versus Player) determines whether players can attack and harm each other. You will want to set this to true or false, depending on whether you want PvP to be on or off respectively.

    • difficulty=1: The difficulty property can be set to a number from 0 to 3, where 0 means Peaceful, 1 means Easy, 2 means Normal, and 3 means Hard. Everyone on the server will play at this difficulty level.

    • gamemode=0: This property determines which game mode players will start in, where 0 means Survival, 1 means Creative, and 2 means Adventure.

    • motd=A Minecraft Server: MOTD (short for Message Of The Day. This message will be displayed when viewing your server in the Minecraft multiplayer server list, as shown in the following screenshot. It is a good idea to set this to a short description of your server. An example of this is Bukkit plugin testing.

    • online-mode=true: This can be set to false to allow players to connect to the server when in the offline mode. This is useful in case http://minecraft.net/ is unavailable or your computer is not connected to the Internet. Running your server in the offline mode can cause security issues, such as other players logging in to your account.

  • bukkit.yml: This file contains many server options. These are the options that a vanilla server does not offer and are only available when you run a modified server. Note that this file is a YMAL (.yml) file and not a PROPERTIES (.properties) file. When you open it, you will see how the two file types are formatted differently. The first difference that you will see is that certain lines are indented. You do not need to fully understand the YMAL formatting, as it will be explained further as we progress through creating Bukkit plugins. There are a few settings in this file that I will bring to your attention, as shown in the following list. For a full list of these Bukkit settings, you can visit wiki.bukkit.org/Bukkit.yml. Like server.properties, changing any of these settings will require you to restart the server.

    • allow-end: true: A vanilla Minecraft server allows you to disable the nether world from functioning. A Bukkit server allows you to disable the end world as well. Set this to false to prevent players from traveling to the end.

    • use-exact-login-location: false: Vanilla Minecraft contains a feature that will prevent players from spawning inside a block. The player will instead be spawned above the block so that they will not be stuck when they join the server. This can be easily exploited to climb onto blocks that a player could normally not reach. Bukkit can prevent this from occurring by spawning the player exactly where they logged out. Set this property to true if you wish to prevent this.

    • spawn-limits: Bukkit allows a server admin to modify the number of monsters and animals that are allowed to spawn within a given chunk. If you are unfamiliar with the term chunk, it is a group of 16 x 16 blocks from bedrock to the highest point of the sky. The following is a picture of a single chunk in Minecraft; if you feel that there are too many (or too few) mobs, then you will want to adjust these values accordingly:

    • ticks-per: autosave: 0: Unlike vanilla Minecraft, a Bukkit server will not periodically save your player/world data. Automatically saving data may prevent the server from losing the changes that were made in the game in case it crashes or shuts down for some reason, such as the computer losing power. Vanilla has set this to 6000 by default. This value is provided in ticks. There are 20 ticks every second. We can determine how long 6,000 ticks is with this math: 6000 ticks / 20 ticks/second = 300 seconds and 300 seconds / 60 seconds/minute = 5 minutes. From this calculation, you should be able to calculate an appropriate time period after which you want your server to autosave your progress. If your server lags whenever it saves your changes, then you may want to increase this number. A setting of 72000 will cause a lag only once every hour. However, if the server crashes right before it saves, you may lose any progress that you made in the past hour.

  • spigot.yml: This file is similar to bukkit.yml. It has many settings and configurations that are only available when running a Spigot server. If you wish to configure any of these options, refer to the documentation at the top of the file.