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

Commit

Permalink
2.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
alejandroliu committed Nov 8, 2016
1 parent c491f3b commit ec8fc50
Show file tree
Hide file tree
Showing 20 changed files with 635 additions and 372 deletions.
411 changes: 243 additions & 168 deletions README.md

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ load: STARTUP

name: WorldProtect
description: protect worlds from griefers, pvp, limits and borders
version: 2.1.2
version: 2.2.0
author: aliuly
website: https://github.com/alejandroliu/pocketmine-plugins/tree/master/WorldProtect

Expand Down Expand Up @@ -49,6 +49,9 @@ permissions:
wp.cmd.unbreakable:
default: op
description: "Modify unbreakable block list"
wp.cmd.bancmd:
default: op
description: "Ban/unban commands"
wp.cmd.banitem:
default: op
description: "Ban/unban items"
Expand Down
14 changes: 12 additions & 2 deletions resources/messages/messages.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@
"Adventure"=""
"Auth List(%1%): "=""
"Available sub-commands for %1%"=""
"Ban Commands(%1%): "=""
"Ban an item"=""
"Banned(%1%): "=""
"Bans the given command"=""
"Blocks changed: %1%"=""
"Border: "=""
"Changing gamemode to %1%"=""
"Commands changed: %1%"=""
"Control PvP in world"=""
"Creates a border defined\n\tby x1,z1 to x2,z2\n\tUse [none] to remove\n\tIf [range] is specified the border is\n\t-range,-range to range,range\n\taround the spawn point"=""
"Creative"=""
Expand All @@ -34,6 +37,7 @@
"NO features enabled"=""
"NoExplode: "=""
"No blocks updated"=""
"No commands updated"=""
"No help for %1%"=""
"No items updated"=""
"No sub-commands available"=""
Expand All @@ -53,9 +57,11 @@
"Shows world motd text"=""
"Spectator"=""
"Survival"=""
"That command is banned here!"=""
"Unable to find level %1%"=""
"Unable to teleport to %1%\nWorld is full"=""
"Unban item"=""
"Unbans command"=""
"Unbreakable(%1%): "=""
"Unknown feature \"%1%\" ignored."=""
"Unknown sub-command %2% (try /%1% help)"=""
Expand Down Expand Up @@ -86,6 +92,7 @@
"[WP] Border for %1% is (%2%,%3%)-(%4%,%5%)"=""
"[WP] Border for %1% removed"=""
"[WP] Border for %1% set to (%2%,%3%)-(%4%,%5%)"=""
"[WP] Commands(%1%): %2%"=""
"[WP] Explosions Allowed in %1%"=""
"[WP] Explosions allowed in %1%"=""
"[WP] Explosions off in %1%'s spawn"=""
Expand All @@ -99,6 +106,7 @@
"[WP] NO Explosions in %1%'s spawn"=""
"[WP] NO PvP in %1%"=""
"[WP] NO PvP in %1%'s spawn"=""
"[WP] No banned commands in %1%"=""
"[WP] No banned items in %1%"=""
"[WP] No gamemode for %1%"=""
"[WP] No unbreakable blocks in %1%"=""
Expand All @@ -112,6 +120,7 @@
"[WP] You have been removed from\n[WP] %1%'s auth list"=""
"[WP] motd for %1% removed"=""
"[WP] motd for %1% updated"=""
"[command]"=""
"[id] ..."=""
"[id] [id]"=""
"[off|world|spawn]"=""
Expand All @@ -121,6 +130,7 @@
"[value]"=""
"[world]"=""
"auth(%1%)"=""
"bc:"=""
"bi:"=""
"border"=""
"gm:"=""
Expand All @@ -136,5 +146,5 @@
"spawn-off"=""
"ubab:"=""
"world"=""
"#Enable %1% features"=""
"#Usage: /%%s [world] %%s %%s"=""
"mc.lang"="spa"
"mc.version"="2.2.0"
26 changes: 19 additions & 7 deletions resources/messages/spa.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@
"Adventure"="Aventura"
"Auth List(%1%): "="Autorizado(%1%): "
"Available sub-commands for %1%"="Sub-comandos disponibles para %1%"
"Ban Commands(%1%): "="Comandos Prohibidos(%1%): "
"Ban an item"="Prohíbe objeto"
"Banned(%1%): "="Prohibído(%1%): "
"Bans the given command"="Prohibe comandos"
"Blocks changed: %1%"="Blóques modificados: %1%"
"Border: "="Límite: "
"Changing gamemode to %1%"="Cambiando modo de juego a %1%"
"Commands changed: %1%"="Comandos modificados: %1%"
"Control PvP in world"="Controla PvP en mundo"
"Creates a border defined\n\tby x1,z1 to x2,z2\n\tUse [none] to remove\n\tIf [range] is specified the border is\n\t-range,-range to range,range\n\taround the spawn point"="Crea un límite definido\n\tpor x1,z1 al x2,z2\n\tUse [none] para quitar\n\tSi [range] es proporcionado, el límite definido es\n\t -range,-range a range,range\n\talrededor del punto de aparición"
"Creative"="Creativo"
Expand All @@ -34,6 +37,7 @@
"NO features enabled"="No módules activados"
"NoExplode: "="AntiExplosión: "
"No blocks updated"="No se modificó ningún bloque"
"No commands updated"="Ningun commando modificado"
"No help for %1%"="No ayuda disponible para %1%"
"No items updated"="Ningún objeto modificado"
"No sub-commands available"="No hay sub comandos disponibles"
Expand All @@ -53,9 +57,11 @@
"Shows world motd text"="Muestra el mensaje de bienvenida a mundo"
"Spectator"="Espectador"
"Survival"="Supervivencia"
"That command is banned here!"="Ese comando no esta permitido"
"Unable to find level %1%"="No pudo encontrar el mundo %1%"
"Unable to teleport to %1%\nWorld is full"="No se puede teletransportar a %1%\nMundo esta lleno"
"Unban item"="Permitir objeto"
"Unbans command"="Permite comando"
"Unbreakable(%1%): "="Irrompíble(%1%): "
"Unknown feature \"%1%\" ignored."="Module \"%1%\" desconocido, ignorando"
"Unknown sub-command %2% (try /%1% help)"="Sub-comando %2% desconocido (Use /%1% help)"
Expand Down Expand Up @@ -86,6 +92,7 @@
"[WP] Border for %1% is (%2%,%3%)-(%4%,%5%)"="[WP] Límites de %1 son (%2%,%3%)-(%4%,%5%)"
"[WP] Border for %1% removed"="[WP] Quitando límites para %1% "
"[WP] Border for %1% set to (%2%,%3%)-(%4%,%5%)"="[WP] Límites para %1% son (%2%,%3%)-(%4%,%5%)"
"[WP] Commands(%1%): %2%"="[WP] Comandos(%1%): %2%"
"[WP] Explosions Allowed in %1%"="[WP] Explosiones no permitidas en %1%"
"[WP] Explosions allowed in %1%"="[WP] Explosiones no permitidas en %1%"
"[WP] Explosions off in %1%'s spawn"="[WP] Explosiones no permitidas en el punto de aparición de %1%"
Expand All @@ -99,6 +106,7 @@
"[WP] NO Explosions in %1%'s spawn"="[WP] no explosiones en punto de aparición de %1%"
"[WP] NO PvP in %1%"="No PvP en %1%"
"[WP] NO PvP in %1%'s spawn"="No PvP en punto de aparición de %1%"
"[WP] No banned commands in %1%"="[WP] No comandos prohibidos en %1%"
"[WP] No banned items in %1%"="[WP] No objetos prohibidos en %1%"
"[WP] No gamemode for %1%"="[WP] No hay modo de juego para %1%"
"[WP] No unbreakable blocks in %1%"="[WP] No bloques irrompíbles en %1%"
Expand All @@ -112,21 +120,23 @@
"[WP] You have been removed from\n[WP] %1%'s auth list"="[WP] Usted ha sido quitado de\n[WP] la lista autorizada de %1%"
"[WP] motd for %1% removed"="[WP] motd para %1% borrado"
"[WP] motd for %1% updated"="[WP] motd para %1% actualizado"
"[command]"="[comando]"
"[id] ..."="[id] ..."
"[id] [id]"=""
"[off|world|spawn]"=""
"[on|off|spawn-off]"=""
"[range|none|x1 z1 x2 z2]"=""
"[id] [id]"="[id] [id]"
"[off|world|spawn]"="[off|world|spawn]"
"[on|off|spawn-off]"="[on|off|spawn-off]"
"[range|none|x1 z1 x2 z2]"="range|none|x1 z1 x2 z2"
"[text]"="[texto]"
"[value]"="[valor]"
"[world]"="[mundo]"
"auth(%1%)"="autorizado(%1%)"
"bc:"="bc:"
"bi:"="bp:"
"border"="límite"
"gm:"="mj:"
"max:"=""
"motd"=""
"notnt:"=""
"max:"="max:"
"motd"="motd"
"notnt:"="notnt:"
"off"="si"
"on"="no"
"pvp:off"="pvp:no"
Expand All @@ -136,5 +146,7 @@
"spawn-off"="no en punto de aparición"
"ubab:"="irrompible:"
"world"="mundo"
"mc.lang"="spa"
"mc.version"="2.2.0"
"#Enable %1% features"="%1% módulos activados"
"#Usage: /%%s [world] %%s %%s"="Uso: /%%s [world] %%s %%s"
97 changes: 97 additions & 0 deletions src/aliuly/worldprotect/BanCmd.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
<?php
//= cmd:bancmd|unbancmd,Sub_Commands
//: Prevents commands to be used in worlds
//> usage: /wp _[world]_ **bancmd|unbancmd** _[command]_
//:
//: If no commands are given it will show a list of banned
//: commands. Otherwise the _command_ will be added/removed
//: from the ban list
//:
//= features
//: * Ban commands on a per world basis
namespace aliuly\worldprotect;

use pocketmine\plugin\PluginBase as Plugin;
use pocketmine\event\Listener;
use pocketmine\command\CommandSender;
use pocketmine\command\Command;

use pocketmine\event\player\PlayerCommandPreprocessEvent;
use pocketmine\Player;
use aliuly\worldprotect\common\mc;

class BanCmd extends BaseWp implements Listener {
public function __construct(Plugin $plugin) {
parent::__construct($plugin);
$this->owner->getServer()->getPluginManager()->registerEvents($this, $this->owner);
$this->enableSCmd("bancmd",["usage" => mc::_("[command]"),
"help" => mc::_("Bans the given command"),
"permission" => "wp.cmd.bancmd"]);
$this->enableSCmd("unbancmd",["usage" => mc::_("[command]"),
"help" => mc::_("Unbans command"),
"permission" => "wp.cmd.bancmd"]);
}

public function onSCommand(CommandSender $c,Command $cc,$scmd,$world,array $args) {
if ($scmd != "bancmd" && $scmd != "unbancmd") return false;
if (count($args) == 0) {
$cmds = $this->owner->getCfg($world, "bancmds", []);
if (count($cmds) == 0) {
$c->sendMessage(mc::_("[WP] No banned commands in %1%",$world));
} else {
$c->sendMessage(mc::_("[WP] Commands(%1%): %2%",count($cmds), implode(", ",$cmds)));
}
return true;
}
$cc = 0;
$cmds = $this->owner->getCfg($world, "bancmds", []);
if ($scmd == "unbancmd") {
foreach ($args as $i) {
if ($i{0} !== "/") $i = "/".$i;
$i = strtolower($i);
if (isset($cmds[$i])) {
unset($cmds[$i]);
++$cc;
}
}
} elseif ($scmd == "bancmd") {
foreach ($args as $i) {
if ($i{0} !== "/") $i = "/".$i;
$i = strtolower($i);
if (isset($cmds[$i])) continue;
$cmds[$i] = $i;
++$cc;
}
} else {
return false;
}
if (!$cc) {
$c->sendMessage(mc::_("No commands updated"));
return true;
}
if (count($cmds)) {
$this->owner->setCfg($world,"bancmds",$cmds);
} else {
$this->owner->unsetCfg($world,"bancmds");
}
$c->sendMessage(mc::_("Commands changed: %1%",$cc));
return true;
}
/**
* @priority LOWEST
*/
public function onCmd(PlayerCommandPreprocessEvent $ev) {

if ($ev->isCancelled()) return;
$pl = $ev->getPlayer();
$world = $pl->getLevel()->getName();
if (!isset($this->wcfg[$world])) return;
$cmdline = trim($ev->getMessage());
if ($cmdline == "") return;
$cmdline = preg_split('/\s+/',$cmdline);
$cmd = strtolower($cmdline[0]);
if (!isset($this->wcfg[$world][$cmd])) return;
$pl->sendMessage(mc::_("That command is banned here!"));
$ev->setCancelled();
}
}
31 changes: 19 additions & 12 deletions src/aliuly/worldprotect/BanItem.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
<?php
/**
** OVERVIEW:Basic Usage
**
** COMMANDS
**
** * banitem|unbanitem: Control items that can/cannot be used
** usage: /wp _[world]_ **banitem|unbanitem** _[Item-ids]_
** Manages which Items can or can not be used in a given world.
** You can get a list of items currently banned
** if you do not specify any _[item-ids]_. Otherwise these are
** added or removed from the list.
**/
//= cmd:banitem|unbanitem,Sub_Commands
//: Control itmes that can/cannot be used
//> usage: /wp _[world]_ **banitem|unbanitem** _[Item-ids]_
//:
//: Manages which Items can or can not be used in a given world.
//: You can get a list of items currently banned
//: if you do not specify any _[item-ids]_. Otherwise these are
//: added or removed from the list.
//:
//= features
//: * Ban specific items in a world
//
//= docs
//: Some items are able to modify a world by being consume (i.e. do not
//: need to be placed). For example, _bonemeal_, _water or lava buckets_.
//: To prevent this type of griefing, you can use the **banitem**
//: feature.
//:

namespace aliuly\worldprotect;

use pocketmine\plugin\PluginBase as Plugin;
Expand Down
28 changes: 14 additions & 14 deletions src/aliuly/worldprotect/GmMgr.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<?php
/**
** OVERVIEW:Basic Usage
**
** COMMANDS
**
** * gm : Configures a world's gamemode.
** usage : /wp _[world]_ gm _[value]_
** - /wp _[world]_ **gm**
** - Shows the current game mode
** - /wp _[world]_ **gm** _mode_
** - Sets world game mode
** - /wp _[world]_ **gm** **none**
** - Removes per world gamemode
**/
//= cmd:gm,Sub_Commands
//: Configures per world game modes
//> usage: /wp _[world]_ gm _[value]_
//:
//: Options:
//> - /wp _[world]_ **gm**
//: - show current gamemode
//> - /wp _[world]_ **gm** _<mode>_
//: - Sets the world gamemode to _mode_
//> - /wp _[world]_ **gm** **none**
//: - Removes per world game mode
//:
//= features
//: * Per world game modes
namespace aliuly\worldprotect;

use pocketmine\plugin\PluginBase as Plugin;
Expand Down
16 changes: 7 additions & 9 deletions src/aliuly/worldprotect/GmSaveInv.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
<?php
/**
** MODULE:gm-save-inv
** Will save inventory contents when switching gamemodes.
**
** This is useful
** for when you have per world game modes so that players going from a
** survival world to a creative world and back do not loose their
** inventory.
**/
//= module:gm-save-inv
//: Will save inventory contents when switching gamemodes.
//:
//: This is useful for when you have per world game modes so that
//: players going from a survival world to a creative world and back
//: do not loose their inventory.

namespace aliuly\worldprotect;

use pocketmine\plugin\PluginBase as Plugin;
Expand Down
Loading

0 comments on commit ec8fc50

Please sign in to comment.