Loader.php PHP: <?phpnamespace MCMMOPE;use pocketmine\event\Listener;use pocketmine\plugin\PluginBase;use pocketmine\utils\TextFormat;use MCMMOPE\Mining;use pocketmine\event\entity\EntitySpawnEvent;use pocketmine\command\CommandExecutor;use pocketmine\command\CommandSender;use pocketmine\command\Command;use pocketmine\utils\Config;class Loader extends PluginBase implements Listener,CommandExecutor{ public function dataPath() { return $this->getDataFolder(); } public function onEnable(){ $this->getServer()->getPluginManager()->registerEvents($this, $this); ##SOON$this->getServer()->getPluginManager()->registerEvents(new Commands($this), $this); $this->getServer()->getPluginManager()->registerEvents(new Mining($this), $this); $this->getLogger()->info(TextFormat::GREEN."MCMMOPE Enabled!"); $this->getCommand("activate_mining")->setExecutor(new Mining($this)); @mkdir($this->getDataFolder()); $this->saveResource("mininglevel.yml"); $this->saveResource("miningexperiance.yml"); $this->mininglevel = new Config($this->getDataFolder() . "mininglevel.yml", Config::YAML); $this->miningexperiance = new Config($this->getDataFolder() . "miningexperiance.yml", Config::YAML); $this->miningexperiance->save(); $this->mininglevel->save(); } public function onDisable(){ $this->getLogger()->info(TextFormat::RED."MCMMOEPE Disabled!"); }} Mining.php: PHP: <?phpnamespace MCMMOPE;use pocketmine\Player;use pocketmine\plugin\PluginBase;use pocketmine\utils\TextFormat as c;use pocketmine\Server;use pocketmine\event\Cancellable;use pocketmine\event\Listener;use pocketmine\event\block\BlockBreakEvent;use pocketmine\utils\Config;use pocketmine\command\CommandExecutor;use pocketmine\command\CommandSender;use pocketmine\command\Command;use MCMMOPE\Loader;use pocketmine\entity\Effect;class Mining extends PluginBase implements Listener{ public function __construct(Loader $plugin){ $this->plugin = $plugin; } public function dataPath() { return $this->getDataFolder(); } public function onBreak(BlockBreakEvent $event){ $p = $event->getPlayer(); $name = $p->getName(); $test = $p->getInventory()->getItemInHand(); if ($test->getCustomName() === "§eZa Roc\n§rTorture 25 Percent\nExplosive 25 Percent") { $event->getBlock()->setNameTag("TEST"); } $this->mininglevel = $this->loader->getDataFolder() . "mininglevel.yml"; $this->miningexperiance = $this->loader->getDataFolder() . "miningexperiance.yml"; $level = $this->mininglevel->get($name); $exp = $this->miningexperiance->get($name); if($event->getBlock()->GetId() == 1){ $this->mininglevel->set($name,$exp+30); $this->mininglevel->Save(); if($exp = 1000){ $p->sendMessage("Mining Skill Is Now Level 1"); }if($exp = 2000 ){ $p->sendMessage("Mining Skill Is Now Level 2"); }}} public function onCommand(CommandSender $sender, Command $cmd, $label, array $args){ if(strtolower($cmd->getName()) === "activate_mining"){ $dataFile = $this->loader->getDataFolder() . strtolower($sender->getName()); $name = $sender; if(is_file($dataFile)) { $data = yaml_parse_file($dataFile); $lastTime = $data["last-execute-command"][$cmd->getName()]; } else { $lastTime = 0; } if(time() - $lastTime < 5) { $sender->sendMessage("You execute too frequently!"); return true; }else if(time() - $lastTime > 5) { $sender->SendMessage("Skill Activated"); ##if($name->) ##$name->addEffect(Effect::getEffect(20)->setDuration($duration)->setAmplifier(1)); }$data["last-execute-command"][$cmd->getName()] = time(); yaml_emit_file($dataFile, $data); // handle command return true;}}}
You'd be better off saving/creating the mining.yml resource in the onEnable function like @LilCrispy2o9 said and then create a Config instance in your listener and assign it to a class property. That way you don't create a new Config object each time your event handler is called.
In Mining.php add PHP: public $mininglevel; then in your __construct function add PHP: $this->mininglevel = new Config($this->plugin->getDataFolder() . "mininglevel.yml"); There are also quit a few other erros in your code, you shoudl go and look on github to get a better understanding of PHP and other things.
*Sigh* I'm getting the same error again. I modified my code so it generated everything onJoin but it still gives me the error " [18:29:40] [Server thread/CRITICAL]: "Could not pass event 'pocketmine\event\block\BlockBreakEvent' to 'MCMMOPE v': Call to a member function get() on string on MCMMOPE\Skills\Mining [18:29:40] [Server thread/CRITICAL]: Error: "Call to a member function get() on string" (EXCEPTION) in "/plugins/AMCMMOPE/src/MCMMOPE/Skills/Mining" at line 43" Mining: PHP: <?phpnamespace MCMMOPE\Skills;use pocketmine\Player;use pocketmine\plugin\PluginBase;use pocketmine\utils\TextFormat as c;use pocketmine\Server;use pocketmine\event\Cancellable;use pocketmine\event\Listener;use pocketmine\event\block\BlockBreakEvent;use pocketmine\utils\Config;use pocketmine\command\CommandExecutor;use pocketmine\command\CommandSender;use pocketmine\command\Command;use MCMMOPE\Loader;use pocketmine\entity\Effect;class Mining extends PluginBase implements Listener{public function dataPath() { return $this->getDataFolder(); } public function __construct(Loader $plugin){ $this->plugin = $plugin; ##$this->mininglevel = new Config($this->plugin->getDataFolder() . "mininglevel.yml"); ##$this->miningexperiance= new Config($this->plugin->getDataFolder() . "miningexperiance.yml"); } public function onBreak(BlockBreakEvent $event){ $player = $event->getPlayer(); $file = ($this->getDataFolder()."Players/".$player->getName().".yml"); $data = $file->get("Kills", "KillsEXP", "AcrobaticsLevel", "AcrobaticsEXP", "ExcavationLevel", "ExcavationEXP", "MiningLevel", "MiningEXP"); if($event->getBlock()->GetId() == 1){ if(file_exists($PlayerFile)){ if($file->exists($data)){ $p->sendmessage("TIS LIT"); $data->set("MiningEXP", +1); $this->PlayerFile->save(); } } } } private function mininghaste(Player $player){ $file = $this->getDataFolder()."Players/".$player->getName().".yml"; $data = $file->get("MiningEXP"); $player->sendMessage("Skill Activated!"); }public function onCommand(CommandSender $sender, Command $cmd, $label, array $args){ if(strtolower($cmd->getName()) === "activate_mining"){ $dataFile = $this->getDataFolder() . strtolower($sender->getName()); $name = $sender; if(is_file($dataFile)) { $data = yaml_parse_file($dataFile); $lastTime = $data["last-execute-command"][$cmd->getName()]; } else { $lastTime = 0; } if(time() - $lastTime < 5) { $sender->sendMessage("You execute too frequently!"); return true; }else if(time() - $lastTime > 5) { $this->mininghaste($sender); ##if($name->) ##$name->addEffect(Effect::getEffect(20)->setDuration($duration)->setAmplifier(1)); }$data["last-execute-command"][$cmd->getName()] = time(); yaml_emit_file($dataFile, $data); // handle command return true;}}} Loader: PHP: <?phpnamespace MCMMOPE;use pocketmine\event\Listener;use pocketmine\plugin\PluginBase;use pocketmine\utils\TextFormat as TF;use MCMMOPE\Skills\Mining;use pocketmine\event\entity\EntitySpawnEvent;use pocketmine\command\CommandExecutor;use pocketmine\command\CommandSender;use pocketmine\command\Command;use pocketmine\utils\Config;use pocketmine\event\player\PlayerJoinEvent;class Loader extends PluginBase implements Listener,CommandExecutor{ public function dataPath() { return $this->getDataFolder(); } public function onEnable(){ $this->getServer()->getPluginManager()->registerEvents($this, $this); ##SOON$this->getServer()->getPluginManager()->registerEvents(new Commands($this), $this); $this->getServer()->getPluginManager()->registerEvents(new Mining($this), $this); $this->getLogger()->info(TF::GREEN."MCMMOPE Enabled!"); $this->getCommand("activate_mining")->setExecutor(new Mining($this)); ##@mkdir($this->getDataFolder()); ##$this->saveResource("mininglevel.yml"); ## $this->saveResource("miningexperiance.yml"); ## $this->mininglevel = new Config($this->getDataFolder() . "mininglevel.yml", Config::YAML); ## $this->miningexperiance = new Config($this->getDataFolder() . "miningexperiance.yml", Config::YAML); ## $this->miningexperiance->save(); ## $this->mininglevel->save(); } public function onDisable(){ $this->getLogger()->info(TF::RED."MCMMOEPE Disabled!"); } public function onJoin(PlayerJoinEvent $event){ $player = $event->getPlayer(); $file = $this->getDataFolder()."Players/".$player->getName().".yml"; $player->sendmessage("TEST"); if(!file_exists($file)){ $this->PlayerFile = new Config($this->getDataFolder()."Players/".$player->getName().".yml", Config::YAML); $this->PlayerFile->set("KillsLevel", 0); $this->PlayerFile->set("KillsEXP", 0); $this->PlayerFile->set("AcrobaticsLevel", 0); $this->PlayerFile->set("AcrobaticsEXP", 0); $this->PlayerFile->set("MiningLevel", 0); $this->PlayerFile->set("MiningEXP", 0); $this->PlayerFile->set("ExcavationLevel", 0); $this->PlayerFile->set("ExcavationEXP", 0); $this->PlayerFile->save(); $this->getLogger()->info(TF::GREEN."Your new ".TF::BOLD. TF::GRAY."MMO".TF::RESET. TF::GREEN." account has been created!"); } $this->PlayerFile = new Config($this->getDataFolder()."Players/".$player->getName().".yml", Config::YAML); $data = $this->PlayerFile->get("Kills", "KillsEXP", "AcrobaticsLevel", "AcrobaticsEXP", "ExcavationLevel", "ExcavationEXP", "MiningLevel", "MiningEXP"); if(!$this->PlayerFile->exists($data)){ $this->PlayerFile->set("KillsLevel", 0); $this->PlayerFile->set("KillsEXP", 0); $this->PlayerFile->set("AcrobaticsLevel", 0); $this->PlayerFile->set("AcrobaticsEXP", 0); $this->PlayerFile->set("ExcavationLevel", 0); $this->PlayerFile->set("ExcavationEXP", 0); $this->PlayerFile->set("MiningLevel", 0); $this->PlayerFile->set("MiningEXP", 0); $this->PlayerFile->save(); } }}
PHP: $file = ($this->getDataFolder()."Players/".$player->getName().".yml");$data = $file->get("Kills", "KillsEXP", "AcrobaticsLevel", "AcrobaticsEXP", "ExcavationLevel", "ExcavationEXP", "MiningLevel", "MiningEXP"); While an attempt was made, this is not the way you read a YML config. $file is a string, which the error implies. Trying to call get() on it would be useless, because it is a string, not a config object. This may be of some use.
PocketMine utilizes Object Oriented PHP, correct? You are trying to call a function get() (which you are actually doing incorrectly, but we can talk about that later) to get data from a YML file. Strings do not provide this method, but PocketMine provides a utility class called Config to assist you with parsing these files. To use it and it's methods (including get()), all you have to do is to construct a new instance of the Config object with the things it needs. The line I linked you to shows you what it needs. You can do this from here.
http://php.net/manual/en/language.oop5.decon.php But I suppose you won't understand what that page talks about unless you read from the beginning. http://php.net/manual/en/language.oop5.basic.php