Permalink
Browse files

New events, item methods

  • Loading branch information...
1 parent 2bdc8c4 commit d69fe5d5e77620704bd747a893556b31c67040e5 @shoghicp shoghicp committed Mar 5, 2014
View
@@ -5,6 +5,7 @@
*.txt text eol=lf
*.properties text eol=lf
*.bat text eol=crlf
+*.cmd text eol=crlf
# Custom for Visual Studio
*.cs diff=csharp
View
@@ -1,19 +1,11 @@
players/*
worlds/*
plugins/*
-logs/*
bin/*
-.idea/*
*.log
-*.pmf
*.txt
server.properties
-
-############
-## Windows
-############
-
# Windows image file caches
Thumbs.db
View
@@ -0,0 +1,125 @@
+<?php
+
+/**
+ *
+ * ____ _ _ __ __ _ __ __ ____
+ * | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
+ * | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
+ * | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
+ * |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * @author PocketMine Team
+ * @link http://www.pocketmine.net/
+ *
+ *
+*/
+
+abstract class Achievement{
+ public static $list = array(
+ /*"openInventory" => array(
+ "name" => "Taking Inventory",
+ "requires" => array(),
+ ),*/
+ "mineWood" => array(
+ "name" => "Getting Wood",
+ "requires" => array(
+ //"openInventory",
+ ),
+ ),
+ "buildWorkBench" => array(
+ "name" => "Benchmarking",
+ "requires" => array(
+ "mineWood",
+ ),
+ ),
+ "buildPickaxe" => array(
+ "name" => "Time to Mine!",
+ "requires" => array(
+ "buildWorkBench",
+ ),
+ ),
+ "buildFurnace" => array(
+ "name" => "Hot Topic",
+ "requires" => array(
+ "buildPickaxe",
+ ),
+ ),
+ "acquireIron" => array(
+ "name" => "Acquire hardware",
+ "requires" => array(
+ "buildFurnace",
+ ),
+ ),
+ "buildHoe" => array(
+ "name" => "Time to Farm!",
+ "requires" => array(
+ "buildWorkBench",
+ ),
+ ),
+ "makeBread" => array(
+ "name" => "Bake Bread",
+ "requires" => array(
+ "buildHoe",
+ ),
+ ),
+ "bakeCake" => array(
+ "name" => "The Lie",
+ "requires" => array(
+ "buildHoe",
+ ),
+ ),
+ "buildBetterPickaxe" => array(
+ "name" => "Getting an Upgrade",
+ "requires" => array(
+ "buildPickaxe",
+ ),
+ ),
+ "buildSword" => array(
+ "name" => "Time to Strike!",
+ "requires" => array(
+ "buildWorkBench",
+ ),
+ ),
+ "diamonds" => array(
+ "name" => "DIAMONDS!",
+ "requires" => array(
+ "acquireIron",
+ ),
+ ),
+
+ );
+
+
+ public static function broadcast(Player $player, $achievementId){
+ if(isset(Achievement::$list[$achievementId])){
+ $result = ServerAPI::request()->api->dhandle("achievement.broadcast", array("player" => $player, "achievementId" => $achievementId));
+ if($result !== false and $result !== true){
+ if(ServerAPI::request()->api->getProperty("announce-player-achievements") == true){
+ ServerAPI::request()->api->chat->broadcast($player->getUsername()." has just earned the achievement ".Achievement::$list[$achievementId]["name"]);
+ }else{
+ $player->sendChat("You have just earned the achievement ".Achievement::$list[$achievementId]["name"]);
+ }
+ }
+ return true;
+ }
+ return false;
+ }
+
+ public static function add($achievementId, $achievementName, array $requires = array()){
+ if(!isset(Achievement::$list[$achievementId])){
+ Achievement::$list[$achievementId] = array(
+ "name" => $achievementName,
+ "requires" => $requires,
+ );
+ return true;
+ }
+ return false;
+ }
+
+
+}
Oops, something went wrong.

0 comments on commit d69fe5d

Please sign in to comment.