Skip to content

Commit

Permalink
Hidden "Retro" and "Slim"... The first release is coming... :D
Browse files Browse the repository at this point in the history
  • Loading branch information
iksaku committed Jul 29, 2014
1 parent ffd2220 commit bc3ece6
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 34 deletions.
32 changes: 11 additions & 21 deletions src/HealthBar/HealthBarCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,29 +30,21 @@ public function execute(CommandSender $sender, $alias, array $args){
}
switch(count($args)){
case 1:
switch($args[0]){
switch(strtolower($args[0])){
case "style":
if(!$sender->hasPermission("healthbar.command.style")){
$sender->sendMessage(TextFormat::RED . $this->getPermissionMessage());
return false;
}
if(!$sender instanceof Player){
$sender->sendMessage(TextFormat::RED . "Please run this command in-game");
}else{
$sender->sendMessage(TextFormat::RED . "Usage: /healthbar style <desired style>");
}
$sender->sendMessage(TextFormat::RED . "Usage: /healthbar style <desired style>");
return true;
break;
case "position":
if(!$sender->hasPermission("healthbar.command.position")){
$sender->sendMessage(TextFormat::RED . $this->getPermissionMessage());
return false;
}
if(!$sender instanceof Player){
$sender->sendMessage(TextFormat::RED . "Please run this command in-game");
}else{
$sender->sendMessage(TextFormat::RED . "Usage: /healthbar position <desired position>");
}
$sender->sendMessage(TextFormat::RED . "Usage: /healthbar position <desired position>");
return true;
break;
case "toggle":
Expand All @@ -74,17 +66,15 @@ public function execute(CommandSender $sender, $alias, array $args){
return true;
break;
case 2:
switch($args[0]){
switch(strtolower($args[0])){
case "style":
if(!$sender->hasPermission("healthbar.command.style")){
$sender->sendMessage(TextFormat::RED . $this->getPermissionMessage());
return false;
}
switch($args[1]){
switch(strtolower($args[1])){
case "default":
case "retro":
case "slim":
$this->plugin->setStyle($args[1]);
$this->plugin->setStyle(strtolower($args[1]));
$sender->sendMessage(TextFormat::YELLOW . "[HealthBar] Updating style...");
return true;
break;
Expand All @@ -99,12 +89,12 @@ public function execute(CommandSender $sender, $alias, array $args){
$sender->sendMessage(TextFormat::RED . $this->getPermissionMessage());
return false;
}
switch($args[1]){
switch(strtolower($args[1])){
case "above":
case "under":
case "left":
case "right":
$this->plugin->setPosition($args[1]);
$this->plugin->setPosition(strtolower($args[1]));
$sender->sendMessage(TextFormat::YELLOW . "[HealthBar] Updating position...");
return true;
break;
Expand All @@ -122,7 +112,7 @@ public function execute(CommandSender $sender, $alias, array $args){
if(!$sender instanceof Player){
$sender->sendMessage(TextFormat::RED . "Usage: /healthbar toggle <on|off> <player>");
}
switch($args[1]){
switch(strtolower($args[1])){
case "on":
$sender->sendMessage(TextFormat::YELLOW . "Setting your HealthBar...");
$this->plugin->setHealthBar($sender, true, $sender->getHealth());
Expand All @@ -146,7 +136,7 @@ public function execute(CommandSender $sender, $alias, array $args){
return true;
break;
case 3:
if($args[0] != "toggle"){
if(strtolower($args[0]) != "toggle"){
$sender->sendMessage(TextFormat::RED . "Usage: " . $this->getUsage());
return false;
}else{
Expand All @@ -158,7 +148,7 @@ public function execute(CommandSender $sender, $alias, array $args){
if($player === false){
$sender->sendMessage(TextFormat::RED . "[Error] Player not found.");
}else{
switch($args[1]){
switch(strtolower($args[1])){
case "on":
$sender->sendMessage(TextFormat::YELLOW . "Setting player' HealthBar...");
$player->sendMessage(TextFormat::YELLOW . "Setting your HealthBar...");
Expand Down
28 changes: 15 additions & 13 deletions src/HealthBar/Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,19 +83,17 @@ public function getPlayer($player){
}

public function getStyle(){
$style = $this->getConfig()->get("style");
switch($style){
$style = strtolower($this->getConfig()->get("style"));
switch(strtolower($style)){
case "default":
case "retro":
case "slim":
return $style;
break;
}
return false;
}

public function getPosition(){
$position = $this->getConfig()->get("position");
$position = strtolower($this->getConfig()->get("position"));
switch($position){
case "above":
case "under":
Expand All @@ -108,10 +106,9 @@ public function getPosition(){
}

public function setStyle($style){
$style = strtolower($style);
switch($style){
case "default":
case "retro":
case "slim":
$this->getConfig()->set("style", $style);
$this->getConfig()->save();
break;
Expand All @@ -123,6 +120,7 @@ public function setStyle($style){
}

public function setPosition($position){
$position = strtolower($position);
switch($position){
case "above":
case "under":
Expand Down Expand Up @@ -159,34 +157,38 @@ public function updateHealthBar(Player $player, $health = false, $name = false){
case "default":
$style = "[" . $health . "/" . $maxhealth . "]";
break;
case "retro":
/*case "retro":
$bar = "";
$h = $health;
$mh = $maxhealth - $health;
while($h >= 1){
while($h >= 1 && $h % 2){
$bar .= $bar . "|";
$h--;
$h--;
}
while($mh >= 1){
while($mh >= 1 && $mh % 2){
$bar .= $bar . ":";
$mh--;
$mh--;
}
$style = $bar;
break;
case "slim":
$bar = "";
$h = $health;
$mh = $maxhealth - $health;
while($h >= 1){
while($h >= 1 && $h % 2){
$bar .= $bar . "=";
$h--;
$h--;
}
while($mh >= 1){
while($mh >= 1 && $mh % 2){
$bar .= $bar . "-";
$mh--;
$mh--;
}
$style = $bar;
break;
break;*/
}

switch($position){
Expand Down

0 comments on commit bc3ece6

Please sign in to comment.