Create a Stendhal server extension: Difference between revisions

Content deleted Content added
imported>Hendrik Brummermann
imported>Hendrik Brummermann
Line 83:
Now, I'm not going to re-post the entire script, as it gets to be just under 100 lines of code, and I don't want a INCREDIBLY long page!
First, we import a new class: <code>java.util.Calendar</code> With that, we can get the current date and time! Then, add these lines to your class method:
<source lang="java">
<pre>
StendhalRPRuleProcessor.register("date", this);
StendhalRPRuleProcessor.register("time", this);
</presource>
These register the date and time commands. Now, we add the if to onAction:
<source lang="java">
<pre>
if (type.equals("date")) {
onDate(world, rules, player, action);
Line 94:
onTime(world, rules, player, action);
}
</presource>
And add the two functions onDate and onTime:
<source lang="java">
<pre>
private void onDate(RPWorld world, StendhalRPRuleProcessor rules,
Player player, RPAction action) {
Line 109:
player.sendPrivateText("The current time is: " + calendar.getTime().toString());
}
</presource>
That's it! Now, just recompile your server, and boom! Your 75% there! Now, one last thing; configuring the server to moticeload your new extension.
 
==Configuration of marauroa==