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

Commit

Permalink
Better Formatting :P
Browse files Browse the repository at this point in the history
  • Loading branch information
DaPigGuy committed Jul 13, 2016
1 parent e2f42b1 commit c6b1bdb
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 44 deletions.
41 changes: 19 additions & 22 deletions src/WeaponsPlus/Commands/WeaponsPlusCommand.php
Original file line number Diff line number Diff line change
@@ -1,68 +1,65 @@
<?php

namespace WeaponsPlus\Commands;

use pocketmine\command\defaults\VanillaCommand;
use pocketmine\command\CommandSender;
use pocketmine\Player;

class BreakReplaceCommand extends VanillaCommand{
public function __construct($name, $plugin){
parent::__construct(
$name, "Toggle weapons", "/weaponsplus"
);
class BreakReplaceCommand extends VanillaCommand {
public function __construct($name, $plugin) {
parent::__construct($name, "Toggle weapons", "/weaponsplus");
$this->setPermission("weaponsplus.command");
$this->plugin = $plugin;
}

public function execute(CommandSender $sender, $currentAlias, array $args){
if(!$this->testPermission($sender)){
public function execute(CommandSender $sender, $currentAlias, array $args) {
if(!$this->testPermission($sender)) {
return true;
}
if(!$sender instanceof Player){
if(!$sender instanceof Player) {
$sender->sendMessage("§cYou must use the command in-game.");
return false;
}
if(!isset($args[0])){
if(!isset($args[0])) {
$sender->sendMessage("/weaponplus <weapon|list>");
return false;
}
switch($args[0]){
switch($args[0]) {
case "effectblade":
case "eb":
if(!$sender->hasPermission("weaponsplus.command.effectblade")){
if(!$sender->hasPermission("weaponsplus.command.effectblade")) {
return false;
}
if($this->plugin->getEBStatus($sender)){
if($this->plugin->getEBStatus($sender)) {
$this->plugin->disableEB($sender);
$sender->sendMessage("§aEffectBlades disabled.");
}else{
} else {
$this->plugin->enableEB($sender);
$sender->sendMessage("§aEffectBlades enabled.");
}
break;
case "list":
if(!isset($args[1])){
if(!isset($args[1])) {
$page = 1;
}else{
} else {
$page = $args[1];
}
if(!is_numeric($page)){
if(!is_numeric($page)) {
$page = 1;
}
if($page > 1){
if($page > 1) {
$page = 1;
}
switch($page){
switch($page) {
case 0:
case 1:
$sender->sendMessage("--- Weapons Page 1 of 1---\n§2effectblades");
break;
}
return true;
}
}
return true;
}
}
return true;
}

}
19 changes: 9 additions & 10 deletions src/WeaponsPlus/EventListener.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

namespace WeaponsPlus;

use pocketmine\entity\Effect;
Expand All @@ -8,8 +7,8 @@
use pocketmine\event\Listener;
use pocketmine\Player;

class EventListener implements Listener{
public function __construct($plugin){
class EventListener implements Listener {
public function __construct($plugin) {
$this->plugin = $plugin;
}

Expand All @@ -19,12 +18,12 @@ public function __construct($plugin){
* @priority MONITOR
* @ignoreCancelled true
*/
public function onDamage(EntityDamageEvent $event){
public function onDamage(EntityDamageEvent $event) {
$entity = $event->getEntity();
if($entity instanceof Player){
if($event instanceof EntityDamageByEntityEvent && $event->getDamager() instanceof Player){
if(($this->plugin->getEBStatus($entity) || ($this->plugin->getConfig()->get("auto-enable-effect-blades") && !$this->plugin->getEBStatus($entity))) && $this->plugin->getConfig()->get("effect-blades")){
foreach($this->plugin->getConfig()->get("effects") as $information){
if($entity instanceof Player) {
if($event instanceof EntityDamageByEntityEvent && $event->getDamager() instanceof Player) {
if(($this->plugin->getEBStatus($entity) || ($this->plugin->getConfig()->get("auto-enable-effect-blades") && !$this->plugin->getEBStatus($entity))) && $this->plugin->getConfig()->get("effect-blades")) {
foreach($this->plugin->getConfig()->get("effects") as $information) {
$info = explode(" ", $info);
$itemid = $info[0];
$itemdamage = $info[1];
Expand All @@ -33,7 +32,7 @@ public function onDamage(EntityDamageEvent $event){
$effecttime = $info[4];
$particlevisible = $info[5];
$item = $event->getDamager()->getInventory()->getItemInHand();
if($item->getId() == $itemid && $item->getDamage() == $itemdamage){
if($item->getId() == $itemid && $item->getDamage() == $itemdamage) {
$effect = Effect::getEffect($effectid);
$effect->setAmplifier($effectlevel);
$effect->setDuration($effecttime * 20);
Expand All @@ -46,4 +45,4 @@ public function onDamage(EntityDamageEvent $event){
}
}

}
}
24 changes: 12 additions & 12 deletions src/WeaponsPlus/Main.php
Original file line number Diff line number Diff line change
@@ -1,48 +1,48 @@
<?php

namespace WeaponsPlus;

use pocketmine\plugin\PluginBase;
use pocketmine\utils\Config;
use pocketmine\Player;

class Main extends PluginBase{
class Main extends PluginBase {
public $ebstatuses;
public $ebstatuseslist;
public function onEnable(){

public function onEnable() {
$this->ebstatuseslist = new Config($this->getDataFolder() . "eb.yml", Config::YAML);
$this->loadEBStatuses();
$this->saveDefaultConfig();
$this->getServer()->getPluginManager()->registerEvents(new EventListener($this), $this);
$this->getLogger()->info("§aEnabled.");
}

public function loadEBStatuses(){
foreach($this->ebstatuseslist->getAll() as $name => $status){
public function loadEBStatuses() {
foreach($this->ebstatuseslist->getAll() as $name => $status) {
$this->ebstatuses[strtolower($name)] = $status;
}
}

public function saveEBStatuses(){
foreach($this->ebstatuses as $name => $status){
public function saveEBStatuses() {
foreach($this->ebstatuses as $name => $status) {
$this->ebstatuseslist->set($name, $status);
}
$this->ebstatuseslist->save();
}

public function enableEB(Player $player){
public function enableEB(Player $player) {
$this->ebstatuses[strtolower($player->getName())] = true;
$this->saveEBStatuses();
}

public function disableEB(Player $player){
public function disableEB(Player $player) {
$this->ebstatuses[strtolower($player->getName())] = false;
$this->saveEBStatuses();
}

public function getEBStatus(Player $player){
if(!isset($this->ebstatuses[strtolower($player->getName())])) return false;
public function getEBStatus(Player $player) {
if(!isset($this->ebstatuses[strtolower($player->getName())]))
return false;
return $this->ebstatuses[strtolower($player->getName())];
}

Expand Down

0 comments on commit c6b1bdb

Please sign in to comment.