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

Commit 91b9663

Browse files
committed
Show max players in world on a sign, removed break sign crash
1 parent 925b6c4 commit 91b9663

8 files changed

Lines changed: 275 additions & 48 deletions

File tree

README.md

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,36 @@
44

55
* Summary: Warp between places using signs
66
* Dependency Plugins: n/a
7-
* PocketMine-MP version: 1.4 - API 1.10.0
7+
* PocketMine-MP version: 1.4 (API:1.10.0), 1.5 (API:1.12.0)
88
* OptionalPlugins: FastTransfer
99
* Categories: Teleportation
1010
* Plugin Access: Other Plugins, Commands, Tile Entities, Manages worlds
11-
* WebSite: [github](https://github.com/alejandroliu/pocketmine-plugins/tree/master/SignWarp)
11+
* WebSite: https://github.com/alejandroliu/pocketmine-plugins/tree/master/SignWarp
1212

1313
## Overview
1414

15+
<!-- php: $v_forum_thread = "http://forums.pocketmine.net/threads/signwarp.7276/"; -->
16+
<!-- template: prologue.md -->
17+
1518
**DO NOT POST QUESTION/BUG-REPORTS/REQUESTS IN THE REVIEWS**
16-
It is difficult to carry a conversation in the reviews. If you have a
17-
question/bug-report/request please use the
19+
20+
It is difficult to carry a conversation in the reviews. If you
21+
have a question/bug-report/request please use the
1822
[Thread](http://forums.pocketmine.net/threads/signwarp.7276/) for
1923
that. You are more likely to get a response and help that way.
2024

25+
**NOTE:**
26+
27+
This documentation was last updated for version **1.5.1**.
28+
2129
Please go to
2230
[github](https://github.com/alejandroliu/pocketmine-plugins/tree/master/SignWarp)
2331
for the most up-to-date documentation.
2432

33+
You can also download this plugin from this [page](https://github.com/alejandroliu/pocketmine-plugins/releases/tag/SignWarp-1.5.1).
34+
35+
<!-- template-end -->
36+
2537
A Plugin implementing simple _Sign_ based warps.
2638

2739
Basic Usage:
@@ -103,7 +115,7 @@ You need the **FastTransfer** plugin for this to work.
103115

104116
### Configuration
105117

106-
Configuration is throug the `config.yml` file.
118+
Configuration is through the `config.yml` file.
107119
The following sections are defined:
108120

109121
#### config.yml
@@ -131,9 +143,15 @@ The following sections are defined:
131143

132144
# Changes
133145

146+
* 1.5.1: bug-fix
147+
* Removed a nasty crash in BreakSign
148+
* 1.5.0:
149+
* Signs now show max players in world.
134150
* 1.4.0:
135151
* Clean-up and use library stuff
136-
* Removed broadcast setting
152+
* Removed broadcast setting: Use
153+
[GrabBag](http://forums.pocketmine.net/plugins/grabbag.1060/)
154+
**broadcast-tp** module
137155
* Translations: Spanish
138156
* 1.3.2: CallbackTask
139157
* Removed CallbackTask deprecation warnings

plugin.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
name: SignWarp
2-
api: [1.10.0]
3-
version: 1.4.0
2+
api: [1.10.0,1.12.0]
3+
version: 1.5.1
44
load: POSTWORLD
55
main: aliuly\signwarp\Main
66
author: aliuly
7-
softdepend: [FastTransfer]
7+
softdepend: [FastTransfer,WorldProtect]
8+
website: https://github.com/alejandroliu/pocketmine-plugins/tree/master/SignWarp
89

910
permissions:
1011
signwarp.place.sign:

resources/messages/messages.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@
1313
"N/A"=""
1414
"Nothing happens!"=""
1515
"Nothing happens..."=""
16+
"Only version %1% available"=""
1617
"Returns x,y,z coordinates"=""
1718
"Somebody removed FastTransfer!"=""
1819
"Spectator"=""
1920
"Survival"=""
2021
"Teleporting..."=""
22+
"This version of SignWarp requires"=""
2123
"You are at %1%,%2%,%3%"=""
2224
"You are not allowed to make Warp signs"=""
2325
"You are not allowed to make\nTransfer Warp signs"=""
@@ -35,6 +37,7 @@
3537
"[SignWarp] Unable to load world \"%1%\""=""
3638
"[SignWarp] Warp to %1%,%2%,%3% created by %4%"=""
3739
"[SignWarp] World \"%1%\" does not exist!"=""
40+
"at least version 2.1.0 of WorldProtect"=""
3841
"dynamic-updates: OFF"=""
3942
"dynamic-updates: ON"=""
4043
"enabled /xyz command"=""

resources/messages/spa.ini

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@
1313
"N/A"="N/A"
1414
"Nothing happens!"="No pasa nada!"
1515
"Nothing happens..."="No pasa nada..."
16+
"Only version %1% available"="Solo version %1% disponible"
1617
"Returns x,y,z coordinates"="Muestra la ubicación x,y,z"
1718
"Somebody removed FastTransfer!"="Algien borró FastTransfer!"
1819
"Spectator"="Espectador"
1920
"Survival"="Supervivencia"
2021
"Teleporting..."="Teletransportando..."
22+
"This version of SignWarp requires"="Esta ersion de SignWarp necesita"
2123
"You are at %1%,%2%,%3%"="Usted está en %1%,%2%,%3%"
2224
"You are not allowed to make Warp signs"="No tiene permiso para crear carteles de Warp"
2325
"You are not allowed to make\nTransfer Warp signs"="No tiene permiso para create carteles the FastTransfer"
@@ -35,6 +37,7 @@
3537
"[SignWarp] Unable to load world \"%1%\""="[SignWarp] No se pudo cargar %1%"
3638
"[SignWarp] Warp to %1%,%2%,%3% created by %4%"="[SignWarp] Warp para %1%,%2%,%3% creado por %4%"
3739
"[SignWarp] World \"%1%\" does not exist!"="[SignWarp] %1% no existe"
38-
"dynamic-updates: OFF"=""
39-
"dynamic-updates: ON"=""
40+
"at least version 2.1.0 of WorldProtect"="por lo moenos version 2.1.0 de WorldProtect"
41+
"dynamic-updates: OFF"="dynamic-updates: Des-Activatdos"
42+
"dynamic-updates: ON"="dynamic-updates: Activados"
4043
"enabled /xyz command"="Comando /xyz activado"

src/aliuly/signwarp/Main.php

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,14 @@ class Main extends PluginBase implements Listener {
3939
public function onEnable(){
4040
if (!is_dir($this->getDataFolder())) mkdir($this->getDataFolder());
4141
mc::plugin_init($this,$this->getFile());
42+
$wp = $this->getServer()->getPluginManager()->getPlugin("WorldProtect");
43+
if ($wp !== null && version_compare($wp->getDescription()->getVersion(),"2.1.0") < 0) {
44+
$this->getLogger()->warning(TextFormat::RED.mc::_("This version of SignWarp requires"));
45+
$this->getLogger()->warning(TextFormat::RED.mc::_("at least version 2.1.0 of WorldProtect"));
46+
$this->getLogger()->warning(TextFormat::RED.mc::_("Only version %1% available",$wp->getDescription()->getVersion()));
47+
throw new \RuntimeException("Runtime checks failed");
48+
return;
49+
}
4250
$defaults =
4351
[
4452
"version" => $this->getDescription()->getVersion(),
@@ -167,13 +175,18 @@ private function checkSign(Player $pl,array $sign) {
167175
$pl->sendMessage(mc::_("[SignWarp] INTERNAL ERROR"));
168176
return null;
169177
}
170-
private function breakSign(Player $pl,Sign $tile,$msg = "") {
171-
if ($msg != "") $pl->sendMessage($msg);
178+
public function doBreakSign($tile) {
172179
$l = $tile->getLevel();
173180
$l->setBlockIdAt($tile->getX(),$tile->getY(),$tile->getZ(),Block::AIR);
174181
$l->setBlockDataAt($tile->getX(),$tile->getY(),$tile->getZ(),0);
175182
$tile->close();
176183
}
184+
public function breakSign(Player $pl,Sign $tile,$msg = "") {
185+
if ($msg != "") $pl->sendMessage($msg);
186+
$this->getServer()->getScheduler()->scheduleDelayedTask(
187+
new PluginCallbackTask($this,[$this,"doBreakSign"],[$tile]),10
188+
);
189+
}
177190
private function check_coords($line,array &$vec) {
178191
$mv = array();
179192
if (!preg_match('/^\s*(-?\d+)\s+(-?\d+)\s+(-?\d+)\s*$/',$line,$mv)) {
@@ -326,16 +339,24 @@ public function playerTouchIt(PlayerInteractEvent $event){
326339
//
327340
//////////////////////////////////////////////////////////////////////
328341
public function updateSigns() {
342+
$wp = $this->getServer()->getPluginManager()->getPlugin("WorldProtect");
329343
foreach ($this->getServer()->getLevels() as $lv) {
330344
foreach ($lv->getTiles() as $tile) {
331345
if (!($tile instanceof Sign)) continue;
332346
$sign = $tile->getText();
333347
if(!in_array($sign[0],$this->text["world"])) continue;
334348

335349
if (!($t = $this->matchCounter($sign[3]))) continue;
336-
if ($this->getServer()->isLevelLoaded($sign[1])) {
337-
$cnt = count($this->getServer()->getLevelByName($sign[1])->getPlayers());
338-
$upd = $t.$cnt;
350+
if (($lv = $this->getServer()->getLevelByName($sign[1])) !== null) {
351+
$cnt = count($lv->getPlayers());
352+
$max = null;
353+
if ($wp !== null) $max = $wp->getMaxPlayers($lv->getName());
354+
if ($max == null)
355+
$upd = $t. TextFormat::BLUE . $cnt;
356+
else
357+
$upd = $t . ($cnt>=$max ? TextFormat::RED : TextFormat::GREEN).
358+
$cnt . "/" . $max;
359+
339360
} else {
340361
$upd = $t.mc::_("N/A");
341362
}

0 commit comments

Comments
 (0)