Assignment 3, CSC102, Spring 2012
1 Guidelines
1.1 Contracts & Test Cases
For this and all remaining assignments, every method you develop must come with the following things:
A commented header line that expresses the result of the function in terms of its inputs, written in English. Be as precise as you can within the space of a line or two. When implementing a method on mixed data, this comment only need appear in the interface.
Data Definition. When a problem asks you to develop data (classes and interfaces), provide examples of the data. Every class needs to come with constructors and an equals method.
Test cases. When a problem asks you to develop a method, provide assertEquals tests. If the method is on a piece of mixed data, be sure to provide test cases for all of the union’s variants. In this assignment, you will put all of the test cases in a single class named Tests.
2 Assignment
In this assignment, you’ll be implementing a simple "find the hidden spot" game for Minecraft, where starting the came creates a platform at a randomly chosen spot nearby, and the first player to reach the spot wins. This project will be somewhat open-ended; the basic functionality is required, but I would encourage your team to add bells and whistles.
This is an extremely open-ended assignment, and I’m going to list the steps that I would follow in implementing it.
Suggested development sequence:
Get minecraft running on your local machine.
Get a minecraft *server* running on your local machine (specifically, a CraftBukkit server).
Connect to the server running locally.
Use the instructions online to construct a trivial plugin.
Get logging working, so that your plugin can issue messages that appear on the server output
implement an onCommand method, so that players can type, say "/hello" and the plugin will respond with a simple broadcast message such as "hi there."
implement a plugin that creates a square pad of stone immediately below the player when the player calls "/pad".
implement a plugin that creates a square pad of stone at a random location that is between 5 and 10 units from the player when called
implement a plugin that uses an EventListener to observe every player motion (PlayerMoveEvent) and logs a message every 20 move events.
extend your plugin to print a message when the player moves to a particular set of coordinates.
add instance variables (fields) to your Listener object (and its constructor) so that it can be created "knowing" about a particular goal spot.
tie it all together: when the user types "/startgame", the onCommand method chooses a random goal location, places a pad there, then creates a Listener that knows about the goal object, and adds it to the system.
Done!
3 Classes and Methods you’ll be interested in
This is a summary of the classes you’ll be interested in, and the methods of these classes that you’ll probably want to use. More specifically, these are the methods that I used; feel free to use any others that you’d like. You can see all of the Bukkit classes and interfaces and methods online at
http://jd.bukkit.org/doxygen/index.html
### JavaPlugin (subclass this, and use these methods:) |
|
- getServer() |
- getLogger() |
|
### Server: |
|
- getPluginManager() |
- broadcastMessage(String) |
|
### CommandSender (superclass of Player) |
|
### Logger |
|
- info(String) |
|
### Player |
|
- getLocation() |
- getWorld() |
- getDisplayName() |
|
### Command |
|
- getName() |
|
### Location |
|
- getBlockX() |
- getBlockY() |
- getBlockZ() |
- getX() |
- getY() |
- getZ() |
|
### Random |
|
- nextDouble() |
|
### PlayerMoveEvent |
|
- getPlayer() |
|
### Listener (must implement this interface) |
|
### EventHandler (must implement this interface) |
|
### Material |
|
... many materials... |
|
### World |
|
- getMaxHeight() |
- getBlockAt() |
|
### Block |
|
- getType() |
- setType(Material) |
|
### Math |
|
- static floor(double) |
- static cos(double) |
- static sin(double) |
|
### PluginManager |
|
- registerEvents(Listener, Plugin) |
|
4 Testable Portions
There are several portions of this assignment that can be tested; these do not make up the whole assignment, by any means, but WebCAT will run tests on these components, to ensure that they work as expected.
Put all of your code in a package called edu.calpoly.cpe102.p3
- Include a Utils class, with these static methods:
nearbyLocation: this method should accept a Location and a double distance, and return a random location whose y value is the same but that is of the given distance from the given location.
makePlatform: this method should accept a World and a Location and create a 7x7 platform of stone whose middle piece is in the given location. So, if the location given were (27.5,68.6,-80.4), then the platform should include blocks at locations (24,68,-84) up through (30,68,-78).
5 Handin
This is a team project, and only one of your team should hand in your project, as with the prior assignment.
6 Errors in the Assignment
I bet you can find some errors in this assignment. When you do, let me know about them!