PocketMine-MP  1.4 - API 1.10.0
 All Classes Namespaces Functions Variables Pages
Achievement.php
1 <?php
2 
3 /*
4  *
5  * ____ _ _ __ __ _ __ __ ____
6  * | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
7  * | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
8  * | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
9  * |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
10  *
11  * This program is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License as published by
13  * the Free Software Foundation, either version 3 of the License, or
14  * (at your option) any later version.
15  *
16  * @author PocketMine Team
17 
18  *
19  *
20 */
21 
22 namespace pocketmine;
23 
25 
29 abstract class Achievement{
33  public static $list = [
34  /*"openInventory" => array(
35  "name" => "Taking Inventory",
36  "requires" => [],
37  ),*/
38  "mineWood" => [
39  "name" => "Getting Wood",
40  "requires" => [ //"openInventory",
41  ],
42  ],
43  "buildWorkBench" => [
44  "name" => "Benchmarking",
45  "requires" => [
46  "mineWood",
47  ],
48  ],
49  "buildPickaxe" => [
50  "name" => "Time to Mine!",
51  "requires" => [
52  "buildWorkBench",
53  ],
54  ],
55  "buildFurnace" => [
56  "name" => "Hot Topic",
57  "requires" => [
58  "buildPickaxe",
59  ],
60  ],
61  "acquireIron" => [
62  "name" => "Acquire hardware",
63  "requires" => [
64  "buildFurnace",
65  ],
66  ],
67  "buildHoe" => [
68  "name" => "Time to Farm!",
69  "requires" => [
70  "buildWorkBench",
71  ],
72  ],
73  "makeBread" => [
74  "name" => "Bake Bread",
75  "requires" => [
76  "buildHoe",
77  ],
78  ],
79  "bakeCake" => [
80  "name" => "The Lie",
81  "requires" => [
82  "buildHoe",
83  ],
84  ],
85  "buildBetterPickaxe" => [
86  "name" => "Getting an Upgrade",
87  "requires" => [
88  "buildPickaxe",
89  ],
90  ],
91  "buildSword" => [
92  "name" => "Time to Strike!",
93  "requires" => [
94  "buildWorkBench",
95  ],
96  ],
97  "diamonds" => [
98  "name" => "DIAMONDS!",
99  "requires" => [
100  "acquireIron",
101  ],
102  ],
103 
104  ];
105 
106 
107  public static function broadcast(Player $player, $achievementId){
108  if(isset(Achievement::$list[$achievementId])){
109  if(Server::getInstance()->getConfigString("announce-player-achievements", true) === true){
110  Server::getInstance()->broadcastMessage($player->getDisplayName() . " has just earned the achievement " . TextFormat::GREEN . Achievement::$list[$achievementId]["name"]);
111  }else{
112  $player->sendMessage("You have just earned the achievement " . TextFormat::GREEN . Achievement::$list[$achievementId]["name"]);
113  }
114 
115  return true;
116  }
117 
118  return false;
119  }
120 
121  public static function add($achievementId, $achievementName, array $requires = []){
122  if(!isset(Achievement::$list[$achievementId])){
123  Achievement::$list[$achievementId] = [
124  "name" => $achievementName,
125  "requires" => $requires,
126  ];
127 
128  return true;
129  }
130 
131  return false;
132  }
133 
134 
135 }
sendMessage($message)
Definition: Player.php:2350