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

Commit

Permalink
v1.1.4 (#31)
Browse files Browse the repository at this point in the history
* v1.1.4 start

* Add new config options

* update message

* v1.1.4

- Fix One kit per life bug
- Added clear inventory option
- Added start from first slot option

* v1.1.4
  • Loading branch information
Infernus101 committed Nov 25, 2017
1 parent 789c799 commit b4bd3d1
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 28 deletions.
2 changes: 1 addition & 1 deletion plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: KitUI
author: Infernus101
api: [3.0.0-ALPHA1, 3.0.0-ALPHA2, 3.0.0-ALPHA3, 3.0.0-ALPHA4, 3.0.0-ALPHA5, 3.0.0-ALPHA6, 3.0.0-ALPHA7, 3.0.0-ALPHA8, 3.0.0-ALPHA9]
main: Infernus101\KitUI\Main
version: 1.1.3
version: 1.1.4
permission: # kit permissions - kit.<kit name>
kit.command:
description: kit command!
Expand Down
4 changes: 4 additions & 0 deletions resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,8 @@
one-kit-per-life: true
# Players can claim another kit if they relog(only if one-kit-per-life is true)
reset-on-logout: true
# Start adding items from the first slot of inventory no matter what, will delete the present item at slot
start-from-first: false
# Clears player inventory before adding the kit
clear-inventory: false
...
49 changes: 23 additions & 26 deletions src/Infernus101/KitUI/Kit.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,38 +38,35 @@ public function getName() : string{
return $this->name;
}

public function isInventoryFull(Player $player){
$full = true;
for($i = 0; $i < $player->getInventory()->getSize(); $i++){
if($player->getInventory()->getItem($i)->getId() === 0){
$full = false;
}
}
return $full;
}

public function add(Player $player){
$inv = $player->getInventory();
$flag = false;


if($this->pl->config->get("clear-inventory")){
$inv->clearAll();
$player->getCraftingGrid()->clearAll();
}

if(!$this->pl->config->get("start-from-first")){
if(count($this->data["items"]) + count($inv->getContents()) > $inv->getSize()){
$player->sendMessage($this->pl->language->getTranslation("inv-full"));
return;
}
foreach($this->data["items"] as $itemString){
$inv->setItem($inv->firstEmpty(), $i = $this->loadItem(...explode(":", $itemString)));
}
}
else{
$tag = 0;
foreach($this->data["items"] as $itemString){
$inv->setItem($tag++, $i = $this->loadItem(...explode(":", $itemString)));
}
}

isset($this->data["helmet"]) and $inv->setHelmet($this->loadItem(...explode(":", $this->data["helmet"])));
isset($this->data["chestplate"]) and $inv->setChestplate($this->loadItem(...explode(":", $this->data["chestplate"])));
isset($this->data["leggings"]) and $inv->setLeggings($this->loadItem(...explode(":", $this->data["leggings"])));
isset($this->data["boots"]) and $inv->setBoots($this->loadItem(...explode(":", $this->data["boots"])));

foreach($this->data["items"] as $itemString){
if(!$this->isInventoryFull($player)){
$inv->setItem($inv->firstEmpty(), $i = $this->loadItem(...explode(":", $itemString)));
}
else{
$flag = true;
}
}

if($flag == true){
$player->sendMessage($this->pl->language->getTranslation("inv-full"));
}

if(isset($this->data["effects"])){
foreach($this->data["effects"] as $effectString){
$e = $this->loadEffect(...explode(":", $effectString));
Expand All @@ -89,7 +86,7 @@ public function add(Player $player){
$this->timers[strtolower($player->getName())] = $this->timer;
}

$this->pl->hasKit[strtolower($player->getName())] = $this;
$this->pl->kitused[strtolower($player->getName())] = $this;

}

Expand Down
1 change: 1 addition & 0 deletions src/Infernus101/KitUI/Main.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class Main extends PluginBase implements Listener {

public function onEnable(){
@mkdir($this->getDataFolder()."timer/");
$this->getServer()->getLogger()->notice(base64_decode('DQogICAgICAgIF9fX19fICAgICAgIF9fICAgICAgICAgICAgICAgICAgICAgICAgICAgX18gIF9fX19fICBfXyAgDQogICBfX19ffF8gICBffCAgICAgLyBffCAgICAgICAgICAgICAgICAgICAgICAgICAvICB8fCAgXyAgfC8gIHwgDQogIC8gX18gXCB8IHwgXyBfXyB8IHxfIF9fXyBfIF9fIF8gX18gIF8gICBfIF9fXyBgfCB8fCB8LycgfGB8IHwgDQogLyAvIF9gIHx8IHx8ICdfIFx8ICBfLyBfIFwgJ19ffCAnXyBcfCB8IHwgLyBfX3wgfCB8fCAgL3wgfCB8IHwgDQp8IHwgKF98IHx8IHx8IHwgfCB8IHx8ICBfXy8gfCAgfCB8IHwgfCB8X3wgXF9fIFxffCB8XCB8Xy8gL198IHxfDQogXCBcX18sX1xfX18vX3wgfF98X3wgXF9fX3xffCAgfF98IHxffFxfXyxffF9fXy9cX19fL1xfX18vIFxfX18vDQogIFxfX19fLyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgDQo='));
$this->getServer()->getLogger()->notice("[KitUI] Enabled! - By Infernus101");
$this->configFixer();
$files = array("kits.yml","config.yml");
Expand Down
2 changes: 1 addition & 1 deletion src/Infernus101/KitUI/lang/LangManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function __construct(Main $pl){
"mainmenu-content" => "Select a kit for info -",
"select-option" => "Do you wanna select this kit, player?",
"selected-kit" => "Selected kit: {%0}",
"inv-full" => "> Some of the items were not added to your inventory since your inventory got full!",
"inv-full" => "You do not have enough space in your inventory for this kit",
"cant-afford" => "You cannot afford kit: {%0} Cost: {%1}",
"one-per-life" => "You can only get one kit per life",
"timer1" => "Kit {%0} is in cooldown at the moment",
Expand Down

0 comments on commit b4bd3d1

Please sign in to comment.