Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Main.php #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 87 additions & 3 deletions src/ServerKits/Main.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,17 @@ class Main extends PluginBase{
//Prefix
const PREFIX = "&7[&cServer&4Kits&7] ";

/** @var array */
public $cfg;

/** @var bool */
public $economy;

/**
* @param string $symbol
* @param string $message
*
* @return string
*/
public function translateColors($symbol, $message){

$message = str_replace($symbol."0", TextFormat::BLACK, $message);
Expand Down Expand Up @@ -67,12 +74,22 @@ public function translateColors($symbol, $message){
return $message;
}

/**
* @param Player $player
*
* @return void
*/
public function registerFirstJoin(Player $player){
@mkdir($this->getDataFolder() . "data/");
$tmp = new Config($this->getDataFolder() . "data/" . strtolower($player->getName() . ".dat"));
$tmp->save();
}

/**
* @param Player $player
*
* @return bool
*/
public function hasJoinedFirstTime(Player $player){
if(file_exists($this->getDataFolder() . "data/" . strtolower($player->getName() . ".dat"))){
return false;
Expand All @@ -81,6 +98,9 @@ public function hasJoinedFirstTime(Player $player){
}
}

/**
* @return void
*/
public function onEnable(){
@mkdir($this->getDataFolder());
$this->saveDefaultConfig();
Expand All @@ -106,26 +126,44 @@ public function onEnable(){
}
}
//Config Functions
/**
* @return string
*/
public function isDefaultKitEnabled(){
$tmp = $this->getConfig()->getAll();
return $tmp["enable-default-kit"];
}

/**
* @return string
*/
public function getDefaultKit(){
$tmp = $this->getConfig()->getAll();
return $tmp["default-kit"];
}

//not sure
/**
* @return array
*/
public function getUsePermissions(){
$tmp = $this->getConfig()->getAll();
return $tmp["use-permissions"];
}

/**
* @return string
*/
public function getEnableSigns(){
$tmp = $this->getConfig()->getAll();
return $tmp["enable-signs"];
}

/**
* @param Player $player
* @param string $kit
*
* @return string
*/
public function getKitReceivedMessage(Player $player, $kit){
$tmp = $this->getConfig()->getAll();
$format = $tmp["kit-received-message"];
Expand All @@ -141,6 +179,9 @@ public function getKitReceivedMessage(Player $player, $kit){
return $format;
}
//Kits Config functions
/**
* @return void
*/
public function initializeKitsPermissions(){
$tmp = new Config($this->getDataFolder() . "kits.yml");
$tmp = $tmp->getAll();
Expand All @@ -151,18 +192,31 @@ public function initializeKitsPermissions(){
}
}

/**
* @param string $kit
*
* @return bool
*/
public function KitExists($kit){
$tmp = new Config($this->getDataFolder() . "kits.yml");
$tmp = $tmp->getAll();
return isset($tmp[$kit]);
}

/**
* @return string[]
*/
public function getAllKits(){
$tmp = new Config($this->getDataFolder() . "kits.yml");
$tmp = $tmp->getAll();
return array_keys($tmp);
}

/**
* @param string $kit
*
* @return bool|string
*/
public function getKitName($kit){
$tmp = new Config($this->getDataFolder() . "kits.yml");
$tmp = $tmp->getAll();
Expand All @@ -173,6 +227,11 @@ public function getKitName($kit){
}
}

/**
* @param string $kit
*
* @return bool|string
*/
public function getKitPrice($kit){
$tmp = new Config($this->getDataFolder() . "kits.yml");
$tmp = $tmp->getAll();
Expand All @@ -183,6 +242,12 @@ public function getKitPrice($kit){
}
}

/**
* @param Player $player
* @param string $kit
*
* @return int
*/
public function parseKitItems(Player $player, $kit){
$tmp = new Config($this->getDataFolder() . "kits.yml");
$tmp = $tmp->getAll();
Expand All @@ -206,7 +271,13 @@ public function parseKitItems(Player $player, $kit){
return 0;
}
}


/**
* @param Player $player
* @param string $kit
*
* @return int
*/
public function parseKitCommands(Player $player, $kit){
$tmp = new Config($this->getDataFolder() . "kits.yml");
$tmp = $tmp->getAll();
Expand All @@ -227,6 +298,13 @@ public function parseKitCommands(Player $player, $kit){
}
}

/**
* @param string $command
* @param Player $player
* @param string $kit
*
* @return string
*/
public function getFormattedCommand($command, Player $player, $kit){
//Check if the kit exists
if($this->KitExists($kit)){
Expand All @@ -240,6 +318,12 @@ public function getFormattedCommand($command, Player $player, $kit){
return $command;
}

/**
* @param Player $player
* @param string $kit
*
* @return int
*/
public function giveKit(Player $player, $kit){
$tmp = new Config($this->getDataFolder() . "kits.yml");
$tmp = $tmp->getAll();
Expand Down