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

Commit

Permalink
Tons of changes! Beta 1, here we go!
Browse files Browse the repository at this point in the history
  • Loading branch information
iksaku committed Aug 14, 2014
1 parent 427ebf2 commit f935d0b
Show file tree
Hide file tree
Showing 40 changed files with 1,039 additions and 301 deletions.
8 changes: 6 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
.idea/*
Nicks.yml
./idea/*
Nicks.yml
.idea/codeStyleSettings.xml
.idea/dictionaries/Jorge_González.xml
*.xml
.idea/EssentialsPE.iml
372 changes: 204 additions & 168 deletions plugin.yml

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions resources/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#EssentialsPE configuration
#This configuration flie let you modify how EssentialsPE work with some features

#This option let you disable player damage when they're AFK
safe-afk: true

#This option let you limit the block distance for players to teleport using "/jump"
#jump-distance: 1000
76 changes: 76 additions & 0 deletions src/EssentialsPE/Commands/AFK.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?php
namespace EssentialsPE\Commands;

use EssentialsPE\BaseCommand;
use EssentialsPE\Loader;
use pocketmine\command\CommandSender;
use pocketmine\Player;
use pocketmine\utils\TextFormat;

class AFK extends BaseCommand{
public function __construct(Loader $plugin){
parent::__construct($plugin, "afk", "Toggle the \"Away From the Keyboard\" status", "/afk [player]", ["away"]);
$this->setPermission("essentials.afk.use");
}

public function execute(CommandSender $sender, $alias, array $args){
if(!$this->testPermission($sender)){
return false;
}
if(count($args) > 1){
if(!$sender instanceof Player){
$sender->sendMessage(TextFormat::RED . "Usage: /afk <player>");
}else{
$sender->sendMessage(TextFormat::RED . "Usage: " . $this->getUsage());
}
return false;
}
switch(count($args)){
case 0:
if(!$sender instanceof Player){
$sender->sendMessage(TextFormat::RED . "Usage: /afk <player>");
return false;
}
$this->getAPI()->switchAFKMode($sender);
if(!$this->getAPI()->isAFK($sender)){
$sender->sendMessage(TextFormat::YELLOW . "You're no longer AFK");
$this->broadcastAFKStatus($sender, "is no longer AFK");
}else{
$sender->sendMessage(TextFormat::YELLOW . "You're now AFK");
$this->broadcastAFKStatus($sender, "is now AFK");
}
return true;
break;
case 1:
if(!$sender->hasPermission("essentials.afk.other")){
$sender->sendMessage(TextFormat::RED . $this->getPermissionMessage());
return false;
}
$player = $this->getAPI()->getPlayer($args[0]);
if(!$player instanceof Player){
$sender->sendMessage(TextFormat::RED . "[Error] Player not found");
return false;
}
$this->getAPI()->switchAFKMode($player);
if(!$this->getAPI()->isAFK($player)){
$player->sendMessage(TextFormat::YELLOW . "You're no longer AFK");
$this->broadcastAFKStatus($player, "is no longer AFK");
}else{
$player->sendMessage(TextFormat::YELLOW . "You're now AFK");
$this->broadcastAFKStatus($player, "is now AFK");
}
return true;
break;
}
return true;
}

private function broadcastAFKStatus(Player $player, $message){
foreach($player->getServer()->getOnlinePlayers() as $p){
if($p !== $player){
$p->sendMessage(TextFormat::YELLOW . $player->getDisplayName() . " " . $message);
$player->getServer()->getLogger()->info(TextFormat::GREEN . $player->getDisplayName() . " " . $message);
}
}
}
}
5 changes: 2 additions & 3 deletions src/EssentialsPE/Commands/Broadcast.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@
use EssentialsPE\BaseCommand;
use EssentialsPE\Loader;
use pocketmine\command\CommandSender;
use pocketmine\Server;
use pocketmine\utils\TextFormat;

class Broadcast extends BaseCommand{
public function __construct(Loader $plugin){
parent::__construct($plugin, "broadcast", "Broadcast a message.", "/broadcast <message>", ["bcast"]);
$this->setPermission("essentials.command.broadcast.use");
$this->setPermission("essentials.broadcast.use");
}

public function execute(CommandSender $sender, $alias, array $args){
Expand All @@ -20,7 +19,7 @@ public function execute(CommandSender $sender, $alias, array $args){
if(count($args) == 0){
$sender->sendMessage(TextFormat::RED . "Usage: " . $this->getUsage());
}else{
Server::getInstance()->broadcastMessage(TextFormat::LIGHT_PURPLE . "[Broadcast] " . TextFormat::RESET . implode(" ", $args));
$sender->getServer()->broadcastMessage(TextFormat::LIGHT_PURPLE . "[Broadcast] " . TextFormat::RESET . implode(" ", $args));
}
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/EssentialsPE/Commands/Burn.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
class Burn extends BaseCommand{
public function __construct(Loader $plugin){
parent::__construct($plugin, "burn", "Set a player on fire", "/burn <player> <seconds>");
$this->setPermission("essentials.command.burn");
$this->setPermission("essentials.burn");
}

public function execute(CommandSender $sender, $alias, array $args){
Expand Down
4 changes: 2 additions & 2 deletions src/EssentialsPE/Commands/ClearInventory.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
class ClearInventory extends BaseCommand{
public function __construct(Loader $plugin){
parent::__construct($plugin, "clearinventory", "Clear your/other's inventory", "/clearinventory [player]", ["ci", "clean", "clearinvent"]);
$this->setPermission("essentials.command.clearinventory.use");
$this->setPermission("essentials.clearinventory.use");
}

public function execute(CommandSender $sender, $alias, array $args){
Expand All @@ -34,7 +34,7 @@ public function execute(CommandSender $sender, $alias, array $args){
}
break;
case 1:
if(!$sender->hasPermission("essentials.command.clearinventory.other")){
if(!$sender->hasPermission("essentials.clearinventory.other")){
$sender->sendMessage(TextFormat::RED . $this->getPermissionMessage());
return false;
}else{
Expand Down
2 changes: 1 addition & 1 deletion src/EssentialsPE/Commands/Compass.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
class Compass extends BaseCommand{
public function __construct(Loader $plugin){
parent::__construct($plugin, "compass", "Display your current bearing direction", "/compass", ["direction"]);
$this->setPermission("essentials.command.compass");
$this->setPermission("essentials.compass");
}

public function execute(CommandSender $sender, $alias, array $args){
Expand Down
5 changes: 2 additions & 3 deletions src/EssentialsPE/Commands/Essentials.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,19 @@
use EssentialsPE\BaseCommand;
use EssentialsPE\Loader;
use pocketmine\command\CommandSender;
use pocketmine\Server;
use pocketmine\utils\TextFormat;

class Essentials extends BaseCommand{
public function __construct(Loader $plugin){
parent::__construct($plugin, "essentials", "Get current Essentials version", "/essentials", ["ess"]);
$this->setPermission("essentials.command.essentials");
$this->setPermission("essentials.essentials");
}

public function execute(CommandSender $sender, $alias, array $args){
if(!$this->testPermission($sender)){
return false;
}
$sender->sendMessage(TextFormat::YELLOW . "You're using " . TextFormat::AQUA . "EssentialsPE " . TextFormat::GREEN . "v" . Server::getInstance()->getPluginManager()->getPlugin("EssentialsPE")->getDescription()->getVersion());
$sender->sendMessage(TextFormat::YELLOW . "You're using " . TextFormat::AQUA . "EssentialsPE " . TextFormat::GREEN . "v" . $sender->getServer()->getPluginManager()->getPlugin("EssentialsPE")->getDescription()->getVersion());
return true;
}
}
4 changes: 2 additions & 2 deletions src/EssentialsPE/Commands/Extinguish.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
class Extinguish extends BaseCommand{
public function __construct(Loader $plugin){
parent::__construct($plugin, "extinguish", "Extinguish a player", "/extinguish [player]", ["ext"]);
$this->setPermission("essentials.command.extinguish.use");
$this->setPermission("essentials.extinguish.use");
}

public function execute(CommandSender $sender, $alias, array $args){
Expand All @@ -34,7 +34,7 @@ public function execute(CommandSender $sender, $alias, array $args){
}
break;
case 1:
if(!$sender->hasPermission("essentials.command.extinguish.other")){
if(!$sender->hasPermission("essentials.extinguish.other")){
$sender->sendMessage(TextFormat::RED . $this->getPermissionMessage());
}else{
$player = $this->getAPI()->getPlayer($args[0]);
Expand Down
4 changes: 2 additions & 2 deletions src/EssentialsPE/Commands/GetPos.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
class GetPos extends BaseCommand{
public function __construct(Loader $plugin){
parent::__construct($plugin, "getpos", "Get your/other's position", "/getpos [player]", ["coords", "position", "whereami", "getlocation", "getloc"]);
$this->setPermission("essentials.command.getpos.use");
$this->setPermission("essentials.getpos.use");
}

public function execute(CommandSender $sender, $alias, array $args){
Expand All @@ -34,7 +34,7 @@ public function execute(CommandSender $sender, $alias, array $args){
}
break;
case 1:
if(!$sender->hasPermission("essentials.command.getpos.other")){
if(!$sender->hasPermission("essentials.getpos.other")){
$sender->sendMessage(TextFormat::RED . $this->getPermissionMessage());
}else{
$player = $this->getAPI()->getPlayer($args[0]);
Expand Down
4 changes: 2 additions & 2 deletions src/EssentialsPE/Commands/God.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
class God extends BaseCommand{
public function __construct(Loader $plugin){
parent::__construct($plugin, "god", "Prevent you to take any damage", "/god [player]", ["godmode", "tgm"]);
$this->setPermission("essentials.command.god.use");
$this->setPermission("essentials.god.use");
}

public function execute(CommandSender $sender, $alias, array $args){
Expand Down Expand Up @@ -40,7 +40,7 @@ public function execute(CommandSender $sender, $alias, array $args){
return true;
break;
case 1:
if(!$sender->hasPermission("essentials.command.god.other")){
if(!$sender->hasPermission("essentials.god.other")){
$sender->sendMessage(TextFormat::RED . $this->getPermissionMessage());
return false;
}
Expand Down
4 changes: 2 additions & 2 deletions src/EssentialsPE/Commands/Heal.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
class Heal extends BaseCommand{
public function __construct(Loader $plugin){
parent::__construct($plugin, "heal", "Heal yourself or other player", "/heal [player]");
$this->setPermission("essentials.command.heal.use");
$this->setPermission("essentials.heal.use");
}

public function execute(CommandSender $sender, $alias, array $args){
Expand All @@ -34,7 +34,7 @@ public function execute(CommandSender $sender, $alias, array $args){
}
break;
case 1:
if(!$sender->hasPermission("essentials.command.heal.other")){
if(!$sender->hasPermission("essentials.heal.other")){
$sender->sendMessage(TextFormat::RED . $this->getPermissionMessage());
}else{
$player = $this->getAPI()->getPlayer($args[0]);
Expand Down
2 changes: 1 addition & 1 deletion src/EssentialsPE/Commands/Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
class Item extends BaseCommand{
public function __construct(Loader $plugin){
parent::__construct($plugin, "item", "Gives yourself an item", "/item <item[:damage|metadata]> [amount]", ["i"]);
$this->setPermission("essentials.command.item");
$this->setPermission("essentials.item");
}

public function execute(CommandSender $sender, $alias, array $args){
Expand Down
2 changes: 1 addition & 1 deletion src/EssentialsPE/Commands/Jump.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
class Jump extends BaseCommand{
public function __construct(Loader $plugin){
parent::__construct($plugin, "jump", "Teleport you to the block you're looking at", "/jump", ["j", "jumpto"]);
$this->setPermission("essentials.command.jump");
$this->setPermission("essentials.jump");
}

public function execute(CommandSender $sender, $alias, array $args){
Expand Down
5 changes: 2 additions & 3 deletions src/EssentialsPE/Commands/KickAll.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@
use EssentialsPE\BaseCommand;
use EssentialsPE\Loader;
use pocketmine\command\CommandSender;
use pocketmine\Server;
use pocketmine\utils\TextFormat;

class KickAll extends BaseCommand{
public function __construct(Loader $plugin){
parent::__construct($plugin, "kickall", "Kick all the players", "/kickall <reason>");
$this->setPermission("essentials.command.kickall");
$this->setPermission("essentials.kickall");
}

public function execute(CommandSender $sender, $alias, array $args){
Expand All @@ -24,7 +23,7 @@ public function execute(CommandSender $sender, $alias, array $args){
$reason = implode(" ", $args);
}

foreach(Server::getInstance()->getOnlinePlayers() as $p){
foreach($sender->getServer()->getOnlinePlayers() as $p){
if($p != $sender){
$p->kick($reason);
}
Expand Down
15 changes: 12 additions & 3 deletions src/EssentialsPE/Commands/More.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
class More extends BaseCommand{
public function __construct(Loader $plugin){
parent::__construct($plugin, "more", "Get a stack of the item you're holding", "/more");
$this->setPermission("essentials.command.more");
$this->setPermission("essentials.more.use");
}

public function execute(CommandSender $sender, $alias, array $args){
Expand All @@ -27,8 +27,17 @@ public function execute(CommandSender $sender, $alias, array $args){
}
$inv = $sender->getInventory();
$item = $inv->getItemInHand();
$item->setCount($item->getMaxStackSize());
$inv->setItemInHand($item);
if($item->getID() === 0){
$sender->sendMessage(TextFormat::RED . "You can't get a stack of AIR");
return false;
}
if(!$sender->hasPermission("essentials.more.oversizedstacks")){
$item->setCount($item->getMaxStackSize());
$inv->setItemInHand($item);
}else{
$item->setCount(64);
$inv->setItemInHand($item);
}
return true;
}
}
4 changes: 2 additions & 2 deletions src/EssentialsPE/Commands/Mute.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
class Mute extends BaseCommand{
public function __construct(Loader $plugin){
parent::__construct($plugin, "mute", "Prevent a player from chatting", "/mute <player>", ["silence"]);
$this->setPermission("essentials.command.mute");
$this->setPermission("essentials.mute");
}

public function execute(CommandSender $sender, $alias, array $args){
Expand All @@ -25,7 +25,7 @@ public function execute(CommandSender $sender, $alias, array $args){
if($player === false){
$sender->sendMessage(TextFormat::RED . "[Error] Player not found.");
}else{
if($player->hasPermission("essentials.command.mute.exempt")){
if($player->hasPermission("essentials.mute.exempt")){
if(!$this->getAPI()->isMuted($player)){
$sender->sendMessage(TextFormat::RED . "$args[0] can't be muted");
return false;
Expand Down
4 changes: 2 additions & 2 deletions src/EssentialsPE/Commands/Nick.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
class Nick extends BaseCommand{
public function __construct(Loader $plugin){
parent::__construct($plugin, "nick", "Change your in-game name", "/nick <new nick|off> [player]", ["nickname"]);
$this->setPermission("essentials.command.nick.use");
$this->setPermission("essentials.nick.use");
}

public function execute(CommandSender $sender, $alias, array $args){
Expand Down Expand Up @@ -38,7 +38,7 @@ public function execute(CommandSender $sender, $alias, array $args){
}
break;
case 2:
if(!$sender->hasPermission("essentials.command.nick.other")){
if(!$sender->hasPermission("essentials.nick.other")){
$sender->sendMessage(TextFormat::RED . $this->getPermissionMessage());
}else{
$nickname = $args[0];
Expand Down
Loading

0 comments on commit f935d0b

Please sign in to comment.