Hey Guys...Why this won't work? There are two Plugins 1. Plugin "McKaff_Settings" 2. Plugin "McKaff_BowBash" So the "McKaff_Settings" plugin have a folder, named "PlayersInfo"...If a player join to a server he will get a file...My name in MCPE is "Jogi"..So if "Jogi" join, he get a file (McKaff_Settings/PlayersInfo/Jogi.yml) The file (McKaff_Settings/PlayersInfo/Jogi.yml) looks like that: Code: --- Language: EN ... So i have a other plugin where I need this Info (What a language the player selected).... McKaff_Settings: PHP: //.........public $messagesEN;public $messagesDE;//...........//Register English Messages $this->messagesEN = new Config($this->getDataFolder() ."languages/English.yml",Config::YAML); //Register Deutsch Messages $this->messagesDE = new Config($this->getDataFolder() ."languages/Deutsch.yml",Config::YAML); //.........public function PlayerLanguage(Player $player, $message) { $this->player = new Config($this->getDataFolder() . "PlayersInfo/" . strtolower($player->getName()), Config::YAML); $language = $this->player->get("Language"); if($language == "DE") { $player->sendMessage($this->messagesDE->get($message)); } if($language == "EN") { $player->sendMessage($this->messagesEN->get($message)); } } So and now the McKaff_BowBash plugin: PHP: //............public $networkplugin; public function onEnable(){ $this->getLogger()->info(TextFormat::GREEN."[McKaff_BowBash] succesfully enabled!"); $this->getServer()->getPluginManager()->registerEvents($this, $this); $this->registerSettings(); $this->saveDefaultConfig(); } public function onDisable(){ $this->getLogger()->info(TextFormat::RED."[McKaff_BowBash] disabled!"); }public function onCommand(CommandSender $sender, Command $cmd, $label, array $args){ if(strtolower($cmd->getName()) == "bb"){ if(isset($args[0])){ if($sender instanceof Player){ switch(strtolower($args[0])){ case "create": $this->getLanguageFromNetwork($sender, 'has_no_permission'); break; } } } } }public function getLanguageFromNetwork($player, $message){ $ec = $this->networkplugin->settings; switch($ec->getName()){ case "McKaff_Settings": $ec->PlayerLanguage($player, $message); break; } } public function registerSettings(){ $settings = ["McKaff_Settings"]; foreach($settings as $plugin){ $networkplugin = $this->getServer()->getPluginManager()->getPlugin($plugin); if($networkplugin instanceof Plugin && $networkplugin->isEnabled()){ $this->settings = $networkplugin; $this->getServer()->getLogger()->info(TextFormat::BLUE."[BB]Sucesfully connected with $plugin"); } else{ $this->getServer()->getLogger()->info(TextFormat::RED."[BB]WARNING! Can't find $plugin"); } } }//............... Thanks Marcelo234
Sorry (i forgot to write the Error) ERROR: Code: [09:27:25] [Server thread/CRITICAL]: Unhandled exception executing command 'bb create' in bb: Trying to get property of non-object [09:27:25] [Server thread/NOTICE]: InvalidStateException: "Trying to get property of non-object" (E_NOTICE) in "/McKaff_BowBash/src/McKaff_BowBash/BowBash" at line 53
use getLogger()->info() in order to check if the functions are called correctly. And check if there are messages in languages Config.
Hey guys I changed the code to test this..... NEW CODE: 1.Plugin McKaff_BowBash: PHP: <?phpnamespace McKaff_BowBash;use pocketmine\plugin\PluginBase;use pocketmine\command\Command;use pocketmine\command\CommandSender;use pocketmine\utils\Config;use pocketmine\utils\TextFormat;use pocketmine\Player;use pocketmine\event\Listener;use pocketmine\event\player\PlayerInteractEvent;use pocketmine\item\Item;use pocketmine\event\block\BlockBreakEvent;use pocketmine\event\block\BlockPlaceEvent;use pocketmine\level\Position;use pocketmine\event\player\PlayerJoinEvent;use pocketmine\event\player\PlayerChatEvent;use pocketmine\event\player\PlayerQuitEvent;use pocketmine\event\player\PlayerKickEvent;use pocketmine\plugin\Plugin;class BowBash extends PluginBase implements Listener{ public $networkplugin; public function onEnable(){ $this->getLogger()->info(TextFormat::GREEN."[McKaff_BowBash] succesfully enabled!"); $this->getServer()->getPluginManager()->registerEvents($this, $this); $this->registerSettings(); $this->saveDefaultConfig(); } public function onDisable(){ $this->getLogger()->info(TextFormat::RED."[McKaff_BowBash] disabled!"); } public function onCommand(CommandSender $sender, Command $cmd, $label, array $args){ if(strtolower($cmd->getName()) == "bb"){ if(isset($args[0])){ if($sender instanceof Player){ switch(strtolower($args[0])){ case "create": $this->getLanguageFromNetwork($sender); break; } } } } } public function getLanguageFromNetwork(Player $player){ $ec = $this->settings; switch($ec->getName()){ case "McKaff_Settings": $ec->PlayerLanguage($player); break; } } public function registerSettings(){ $settings = ["McKaff_Settings"]; foreach($settings as $plugin){ $networkplugin = $this->getServer()->getPluginManager()->getPlugin($plugin); if($networkplugin instanceof Plugin && $networkplugin->isEnabled()){ $this->settings = $networkplugin; $this->getServer()->getLogger()->info(TextFormat::BLUE."[BB]Sucesfully connected with $plugin"); } else{ $this->getServer()->getLogger()->info(TextFormat::RED."[BB]WARNING! Can't find $plugin"); } } }} 2.Plugin McKaff_Settings: PHP: public function PlayerLanguage(Player $player) { //$this->player = new Config($this->getDataFolder() . "PlayersInfo/" . strtolower($player->getName()), Config::YAML); //$language = $this->player->get("Language"); if($language == "DE") { //$player->sendMessage($this->messagesDE->get($message)); $player->sendMessage(TextFormat::GREEN."Deutsch"); $this->getLogger()->info(TextFormat::GREEN."Deutsch"); } if($language == "EN") { //$player->sendMessage($this->messagesEN->get($message)); $player->sendMessage(TextFormat::GREEN."English"); $this->getLogger()->info(TextFormat::GREEN."English"); } } I changed the few things, that I can see if the Problem is caused by $messagesDE or $messagesEN; CURRENT ERROR: Code: [13:54:56] [Server thread/CRITICAL]: Unhandled exception executing command 'bb create' in bb: Missing argument 2 for McKaff_Settings\Main::PlayerLanguage(), called in C:\Users\Marcelo\Desktop\McKaff_BowBash\McKaff_BowBash\plugins\McKaff_BowBash\src\McKaff_BowBash\BowBash.php on line 56 and defined [13:54:56] [Server thread/WARNING]: RuntimeException: "Missing argument 2 for McKaff_Settings\Main::PlayerLanguage(), called in C:\Users\Marcelo\Desktop\McKaff_BowBash\McKaff_BowBash\plugins\McKaff_BowBash\src\McKaff_BowBash\BowBash.php on line 56 and defined" (E_WARNING) in "/McKaff_Settings_v0.1.0.phar/src/McKaff_Settings/Main" at line 775
Okay I updated something in McKaff_Settings: PHP: public function PlayerLanguage(Player $player) { //$this->player = new Config($this->getDataFolder() . "PlayersInfo/" . strtolower($player->getName()), Config::YAML); //$language = $this->player->get("Language"); //if($language == "DE") { //$player->sendMessage($this->messagesDE->get($message)); $player->sendMessage(TextFormat::GREEN."Deutsch"); $this->getLogger()->info(TextFormat::GREEN."Deutsch"); //} //if($language == "EN") { //$player->sendMessage($this->messagesEN->get($message)); // $player->sendMessage(TextFormat::GREEN."English"); // $this->getLogger()->info(TextFormat::GREEN."English"); //} } Because I can't get the language if $language isn't in the code! But the ERROR is already there.....
BowBash.php sees only Settings.phar , not Settings.php . You used '/makeplugin' or something and made the Settings.phar plugin didn't you? Delete McKaff_Settings_v0.1.0.phar
So now i followed your instructions .....The McKaff_Settings Plugin isn't a .phar anymore.... So I have changed a few things too...But there is one more Error... 1.Plugin McKaff_Settings: PHP: public function PlayerLanguage(Player $player, $message) { $this->player = new Config($this->getDataFolder() . "PlayersInfo/" . strtolower($player->getName()), Config::YAML); $language = $this->player->get("Language"); if($language == "DE") { $player->sendMessage($this->messagesDE->get($message)); $player->sendMessage(TextFormat::GREEN."Deutsch"); $this->getLogger()->info(TextFormat::GREEN."Deutsch"); } if($language == "EN") { $player->sendMessage($this->messagesEN->get($message)); $player->sendMessage(TextFormat::GREEN."English"); $this->getLogger()->info(TextFormat::GREEN."English"); } } 2.Plugin McKaff_BowBash: PHP: public function onCommand(CommandSender $sender, Command $cmd, $label, array $args){ if(strtolower($cmd->getName()) == "bb"){ if(isset($args[0])){ if($sender instanceof Player){ switch(strtolower($args[0])){ case "create": $this->getLanguageFromNetwork($sender, 'test'); break; } } } } } public function getLanguageFromNetwork(Player $player, $message){ $networkplugin = $this->getServer()->getPluginManager()->getPlugin("McKaff_Settings"); $ec = $this->$networkplugin; $ec->PlayerLanguage($player, $message); } ERROR: Code: [16:30:49] [Server thread/CRITICAL]: Unhandled exception executing command 'bb create' in bb: Object of class McKaff_Settings\Main could not be converted to string [16:30:49] [Server thread/NOTICE]: ClassCastException: "Object of class McKaff_Settings\Main could not be converted to string" (E_RECOVERABLE_ERROR) in "/McKaff_BowBash/src/McKaff_BowBash/BowBash" at line 54 Thanks Marcelo234
Hey Guys now it works.....So for all who are interested in the Code here is the right form.... Plugin: McKaff_BowBash [Main] PHP: public function getLanguageFromNetwork(Player $player, $message){ $networkplugin = $this->getServer()->getPluginManager()->getPlugin("McKaff_Settings"); $networkplugin->PlayerLanguage($player, $message); } Thanks for all your Help..