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

Commit

Permalink
More protection to the config file! :P
Browse files Browse the repository at this point in the history
  • Loading branch information
iksaku committed Feb 2, 2015
1 parent b7d18e9 commit 917707a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
3 changes: 3 additions & 0 deletions resources/config.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# EssentialsPE configuration
# This configuration flie let you modify how EssentialsPE work with some features

# DO NOT EDIT THIS PROPERTY! For internal use ONLY
version: 1.1.0

# Edit different parts of the AFK feature!
afk:
# Players that are AFK can, or not, be damaged
Expand Down
14 changes: 11 additions & 3 deletions src/EssentialsPE/Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,11 +267,18 @@ private function registerCommands(){
}

public function checkConfig(){
$this->saveDefaultConfig();
if(!file_exists($this->getDataFolder() . "config.yml")){
$this->saveDefaultConfig();
}
//$this->saveResource("Economy.yml");
$this->saveResource("Kits.yml");
$cfg = $this->getConfig();

if(!$cfg->exists("version")){
unlink($this->getDataFolder() . "config.yml");
$this->saveDefaultConfig();
}

$booleans = ["enable-custom-colors"];
foreach($booleans as $key){
$value = null;
Expand Down Expand Up @@ -334,7 +341,9 @@ public function checkConfig(){
}
break;
}
$this->getConfig()->setNested("afk." . $key, $value);
if($value !== null){
$this->getConfig()->setNested("afk." . $key, $value);
}
}

$updater = ["enabled", "time-interval", "warn-console", "warn-players", "stable"];
Expand Down Expand Up @@ -362,7 +371,6 @@ public function checkConfig(){
}

$cfg->save();
$cfg->reload();
}

private function saveConfigs(){
Expand Down

0 comments on commit 917707a

Please sign in to comment.