Skip to content
This repository was archived by the owner on Jul 11, 2018. It is now read-only.

Commit 0c778aa

Browse files
committed
Added AutoHeal 1.0.0
1 parent abb9c19 commit 0c778aa

File tree

4 files changed

+85
-75
lines changed

4 files changed

+85
-75
lines changed

AutoHeal/plugin.yml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
main: aliuly\autoheal\Main
2+
api: 1.10.0
3+
load: POSTWORLD
4+
5+
name: AutoHeal
6+
description: Basic Auto-Healing Plugin
7+
version: 1.0.0
8+
author: aliuly
9+
10+
permissions:
11+
autoheal:
12+
default: false
13+
description: "Players with this permission can auto-heal"

AutoHeal/src/aliuly/autoheal/Main.php

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<?php
2+
namespace aliuly\autoheal;
3+
4+
use pocketmine\plugin\PluginBase;
5+
use pocketmine\utils\Config;
6+
use pocketmine\scheduler\CallbackTask;
7+
use pocketmine\utils\TextFormat;
8+
9+
//use pocketmine\Player;
10+
//use pocketmine\Server;
11+
//use pocketmine\item\Item;
12+
//use pocketmine\network\protocol\SetHealthPacket;
13+
14+
class Main extends PluginBase{
15+
protected $players;
16+
17+
public function onEnable(){
18+
if (!is_dir($this->getDataFolder())) mkdir($this->getDataFolder());
19+
$defaults = [
20+
"ranks" => [
21+
"vip1" => [40, 1],
22+
"vip2" => [80, 2],
23+
"vip3" => [800, 1],
24+
],
25+
"players" => [
26+
"joe" => "vip1",
27+
"tom" => "vip2",
28+
"smith" => "vip3",
29+
],
30+
];
31+
if (file_exists($this->getDataFolder()."config.yml")) {
32+
unset($defaults["ranks"]);
33+
unset($defaults["players"]);
34+
}
35+
$cfg = (new Config($this->getDataFolder()."config.yml",
36+
Config::YAML,$defaults))->getAll();
37+
if (!isset($cfg["ranks"])) $cfg["ranks"] = 0;
38+
$cnt = 0;
39+
$this->players = [];
40+
if (isset($cfg["players"])) {
41+
foreach ($cfg["players"] as $name => $rank) {
42+
if (!isset($cfg["ranks"][$rank])) continue;
43+
++$cnt;
44+
$this->players[$rank][$name] = $name;
45+
}
46+
}
47+
if ($cnt == 0) {
48+
$this->getLogger()->info(TextFormat::RED.
49+
"No ranks or players defined, disabling...");
50+
return;
51+
}
52+
$rcnt = 0;
53+
foreach ($cfg["ranks"] as $rank=>$det) {
54+
if (!isset($this->players[$rank])) continue;
55+
++$rcnt;
56+
list($rate,$amount) = $det;
57+
$this->getServer()->getScheduler()->scheduleRepeatingTask(new CallbackTask([$this,"healTimer"],[$rank,$amount]),$rate);
58+
}
59+
$this->getLogger()->info($rcnt." ranks defined");
60+
$this->getLogger()->info($cnt." players registered");
61+
}
62+
public function healTimer($rank,$amount) {
63+
$pls = $this->getServer()->getOnlinePlayers();
64+
foreach($pls as $pl) {
65+
if (!isset($this->players[$rank][$pl->getName()])) continue;
66+
// Yes, this is a vip!
67+
$new = $pl->getHealth() + $amount;
68+
if ($new > $pl->getMaxHealth()) $new = $pl->getMaxHealth();
69+
$pl->setHealth($new);
70+
}
71+
}
72+
}

Media/AutoHeal-icon.png

7.68 KB
Loading

README.md

-75
Original file line numberDiff line numberDiff line change
@@ -18,81 +18,6 @@ Give/Get items:
1818
* zombie : spawn_egg:32
1919
* villager : spawn_egg:15
2020

21-
22-
# Todo/Ideas
23-
24-
* Player Interact Peacefully
25-
- command: attack/interact - defualts to interact
26-
- if holding a weapon attack (always)
27-
- if holding compass/clock/food/string/feather/seeds (never)
28-
* Add a Snowball/Egg or something and use it as football..
29-
* RuneGM:
30-
* Adds a GameMaster:
31-
* Automatically spawned villager or a NPC (Player)
32-
* If LocalChat is active we use it... otherwise you need to use /rp
33-
command.
34-
* If attacked it will retaliate (or kill you...)
35-
* Implements the RuinPvP casino and shop functionality.
36-
* Provide rankings and stats...
37-
* Moves around randomly in his spawn area...
38-
* PMScript:
39-
{{ something }} the something is a PHP expression.
40-
Some syntax sugar:
41-
$[_A-Za-z][_a-zA-Z0-9]*.[_A-Za-z][_A-Za-z0-9]*[^(] ---> converted
42-
to $<something>->get<something>()
43-
44-
@ php ... this is raw PHP code.. prefered altenate syntax.
45-
else goes to "PM command processor"
46-
Event handlers... per world.
47-
Use closures:
48-
$example = function ($arg) {
49-
echo($arg);
50-
}
51-
$example("hello");
52-
Gets called onLevelLoad
53-
registerEvents($obj,$plugin);
54-
Check what "reload" does, can it unregister event? there is no API
55-
for it...
56-
?Loader: disablePlugin($plugin)
57-
>>>HandlerList::unregisterAll($plugin);
58-
?removePermissions
59-
60-
Context variables
61-
62-
* $Sender
63-
* $Console
64-
* $Server
65-
* $Player (if sender is a player otherwise null)
66-
* $Logger
67-
ON EVENT HANDLER
68-
* $Event
69-
70-
71-
# NEW PLUGIN IDEAS:
72-
73-
- plots: place a sign claim a plot. Place a sign restrict the plot.
74-
- per-level plugins. Plugins only active on a per level basis
75-
- async-task plugin?
76-
- fork per-level
77-
- creative restrict -
78-
- do not allow PvP in creative, warning or stop
79-
- if somebody kills in creative, we switch gamemode
80-
- creative pvp
81-
- track health
82-
83-
84-
# MINI GAMES
85-
86-
## DeathSwap
87-
88-
After the game has started, run away from your opponents.
89-
A random timer runs in the backround, and when it finishes after upto
90-
2 Minutes, 2 players postitions will be swapped. The timer will be
91-
restarted, and the next time it finishes, two new randomly chosen
92-
players will get swapped. Try to be the last person alive and kill
93-
other players without seeing them. It's up to you to find out how to
94-
do that.
95-
9621
# Copyright
9722

9823
bad-plugins

0 commit comments

Comments
 (0)