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

Commit

Permalink
Show max players in world on a sign, removed break sign crash
Browse files Browse the repository at this point in the history
  • Loading branch information
alejandroliu committed Aug 26, 2016
1 parent 925b6c4 commit 91b9663
Show file tree
Hide file tree
Showing 8 changed files with 275 additions and 48 deletions.
30 changes: 24 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,36 @@

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

## Overview

<!-- php: $v_forum_thread = "http://forums.pocketmine.net/threads/signwarp.7276/"; -->
<!-- template: prologue.md -->

**DO NOT POST QUESTION/BUG-REPORTS/REQUESTS IN THE REVIEWS**
It is difficult to carry a conversation in the reviews. If you have a
question/bug-report/request please use the

It is difficult to carry a conversation in the reviews. If you
have a question/bug-report/request please use the
[Thread](http://forums.pocketmine.net/threads/signwarp.7276/) for
that. You are more likely to get a response and help that way.

**NOTE:**

This documentation was last updated for version **1.5.1**.

Please go to
[github](https://github.com/alejandroliu/pocketmine-plugins/tree/master/SignWarp)
for the most up-to-date documentation.

You can also download this plugin from this [page](https://github.com/alejandroliu/pocketmine-plugins/releases/tag/SignWarp-1.5.1).

<!-- template-end -->

A Plugin implementing simple _Sign_ based warps.

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

### Configuration

Configuration is throug the `config.yml` file.
Configuration is through the `config.yml` file.
The following sections are defined:

#### config.yml
Expand Down Expand Up @@ -131,9 +143,15 @@ The following sections are defined:

# Changes

* 1.5.1: bug-fix
* Removed a nasty crash in BreakSign
* 1.5.0:
* Signs now show max players in world.
* 1.4.0:
* Clean-up and use library stuff
* Removed broadcast setting
* Removed broadcast setting: Use
[GrabBag](http://forums.pocketmine.net/plugins/grabbag.1060/)
**broadcast-tp** module
* Translations: Spanish
* 1.3.2: CallbackTask
* Removed CallbackTask deprecation warnings
Expand Down
7 changes: 4 additions & 3 deletions plugin.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
name: SignWarp
api: [1.10.0]
version: 1.4.0
api: [1.10.0,1.12.0]
version: 1.5.1
load: POSTWORLD
main: aliuly\signwarp\Main
author: aliuly
softdepend: [FastTransfer]
softdepend: [FastTransfer,WorldProtect]
website: https://github.com/alejandroliu/pocketmine-plugins/tree/master/SignWarp

permissions:
signwarp.place.sign:
Expand Down
3 changes: 3 additions & 0 deletions resources/messages/messages.ini
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@
"N/A"=""
"Nothing happens!"=""
"Nothing happens..."=""
"Only version %1% available"=""
"Returns x,y,z coordinates"=""
"Somebody removed FastTransfer!"=""
"Spectator"=""
"Survival"=""
"Teleporting..."=""
"This version of SignWarp requires"=""
"You are at %1%,%2%,%3%"=""
"You are not allowed to make Warp signs"=""
"You are not allowed to make\nTransfer Warp signs"=""
Expand All @@ -35,6 +37,7 @@
"[SignWarp] Unable to load world \"%1%\""=""
"[SignWarp] Warp to %1%,%2%,%3% created by %4%"=""
"[SignWarp] World \"%1%\" does not exist!"=""
"at least version 2.1.0 of WorldProtect"=""
"dynamic-updates: OFF"=""
"dynamic-updates: ON"=""
"enabled /xyz command"=""
7 changes: 5 additions & 2 deletions resources/messages/spa.ini
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@
"N/A"="N/A"
"Nothing happens!"="No pasa nada!"
"Nothing happens..."="No pasa nada..."
"Only version %1% available"="Solo version %1% disponible"
"Returns x,y,z coordinates"="Muestra la ubicación x,y,z"
"Somebody removed FastTransfer!"="Algien borró FastTransfer!"
"Spectator"="Espectador"
"Survival"="Supervivencia"
"Teleporting..."="Teletransportando..."
"This version of SignWarp requires"="Esta ersion de SignWarp necesita"
"You are at %1%,%2%,%3%"="Usted está en %1%,%2%,%3%"
"You are not allowed to make Warp signs"="No tiene permiso para crear carteles de Warp"
"You are not allowed to make\nTransfer Warp signs"="No tiene permiso para create carteles the FastTransfer"
Expand All @@ -35,6 +37,7 @@
"[SignWarp] Unable to load world \"%1%\""="[SignWarp] No se pudo cargar %1%"
"[SignWarp] Warp to %1%,%2%,%3% created by %4%"="[SignWarp] Warp para %1%,%2%,%3% creado por %4%"
"[SignWarp] World \"%1%\" does not exist!"="[SignWarp] %1% no existe"
"dynamic-updates: OFF"=""
"dynamic-updates: ON"=""
"at least version 2.1.0 of WorldProtect"="por lo moenos version 2.1.0 de WorldProtect"
"dynamic-updates: OFF"="dynamic-updates: Des-Activatdos"
"dynamic-updates: ON"="dynamic-updates: Activados"
"enabled /xyz command"="Comando /xyz activado"
31 changes: 26 additions & 5 deletions src/aliuly/signwarp/Main.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ class Main extends PluginBase implements Listener {
public function onEnable(){
if (!is_dir($this->getDataFolder())) mkdir($this->getDataFolder());
mc::plugin_init($this,$this->getFile());
$wp = $this->getServer()->getPluginManager()->getPlugin("WorldProtect");
if ($wp !== null && version_compare($wp->getDescription()->getVersion(),"2.1.0") < 0) {
$this->getLogger()->warning(TextFormat::RED.mc::_("This version of SignWarp requires"));
$this->getLogger()->warning(TextFormat::RED.mc::_("at least version 2.1.0 of WorldProtect"));
$this->getLogger()->warning(TextFormat::RED.mc::_("Only version %1% available",$wp->getDescription()->getVersion()));
throw new \RuntimeException("Runtime checks failed");
return;
}
$defaults =
[
"version" => $this->getDescription()->getVersion(),
Expand Down Expand Up @@ -167,13 +175,18 @@ private function checkSign(Player $pl,array $sign) {
$pl->sendMessage(mc::_("[SignWarp] INTERNAL ERROR"));
return null;
}
private function breakSign(Player $pl,Sign $tile,$msg = "") {
if ($msg != "") $pl->sendMessage($msg);
public function doBreakSign($tile) {
$l = $tile->getLevel();
$l->setBlockIdAt($tile->getX(),$tile->getY(),$tile->getZ(),Block::AIR);
$l->setBlockDataAt($tile->getX(),$tile->getY(),$tile->getZ(),0);
$tile->close();
}
public function breakSign(Player $pl,Sign $tile,$msg = "") {
if ($msg != "") $pl->sendMessage($msg);
$this->getServer()->getScheduler()->scheduleDelayedTask(
new PluginCallbackTask($this,[$this,"doBreakSign"],[$tile]),10
);
}
private function check_coords($line,array &$vec) {
$mv = array();
if (!preg_match('/^\s*(-?\d+)\s+(-?\d+)\s+(-?\d+)\s*$/',$line,$mv)) {
Expand Down Expand Up @@ -326,16 +339,24 @@ public function playerTouchIt(PlayerInteractEvent $event){
//
//////////////////////////////////////////////////////////////////////
public function updateSigns() {
$wp = $this->getServer()->getPluginManager()->getPlugin("WorldProtect");
foreach ($this->getServer()->getLevels() as $lv) {
foreach ($lv->getTiles() as $tile) {
if (!($tile instanceof Sign)) continue;
$sign = $tile->getText();
if(!in_array($sign[0],$this->text["world"])) continue;

if (!($t = $this->matchCounter($sign[3]))) continue;
if ($this->getServer()->isLevelLoaded($sign[1])) {
$cnt = count($this->getServer()->getLevelByName($sign[1])->getPlayers());
$upd = $t.$cnt;
if (($lv = $this->getServer()->getLevelByName($sign[1])) !== null) {
$cnt = count($lv->getPlayers());
$max = null;
if ($wp !== null) $max = $wp->getMaxPlayers($lv->getName());
if ($max == null)
$upd = $t. TextFormat::BLUE . $cnt;
else
$upd = $t . ($cnt>=$max ? TextFormat::RED : TextFormat::GREEN).
$cnt . "/" . $max;

} else {
$upd = $t.mc::_("N/A");
}
Expand Down
Loading

0 comments on commit 91b9663

Please sign in to comment.