Hi! I have a error on my plugin. Well, my plugin hot send message! PHP: public function onCommand(CommandSender $sender, Command $cmd, $label, array $args){ $name = $sender->getName(); if($cmd->getName() == "staty"){ if(empty($args[0])){ if($sender instanceof Player){ $player = $sender; $pconfig = new Config($this->getDataFolder()."/Players/".strtolower($name).".yml", Config::YAML); $online = $pconfig->get("Online", "true"); $joins = $pconfig->get("JoinCount", "0"); $deaths = $pconfig->get("DeathCount", "0"); $kills = $pconfig->get("KillCount", "0"); $places = $pconfig->get("PlaceCount", "0"); $breaks = $pconfig->get("BreakCount", "0"); $player->sendMessage("§8[§7 ---------- §8[§c".$this->prefix."§8]§7 ---------- §8]"); $player->sendMessage("§c* §7Online:§c ".$online." "); $player->sendMessage("§c* §7Odwiedzin:§c ".$joins." "); $player->sendMessage("§c* §7Zabojstwa:§c ".$kills." "); $player->sendMessage("§c* §7Smierci:§c ".$deaths." "); $player->sendMessage("§c* §7Postawione Bloki:§c ".$places." "); $player->sendMessage("§c* §7Zniszczone Bloki:§c ".$breaks." "); $player->sendMessage("§8[§7 ---------- §8[§c".$this->prefix."§8]§7 ---------- §8]"); } }elseif(!empty($args[0])){ if(file_exists($this->getDataFolder()."/Players/".strtolower($args[0]).".yml")){ $pconfig = new Config($this->getDataFolder()."/Players/".strtolower($args[0]).".yml", Config::YAML); $online = $pconfig->get("Online", "true"); $joins = $pconfig->get("JoinCount", "0"); $deaths = $pconfig->get("DeathCount", "0"); $kills = $pconfig->get("KillCount", "0"); $places = $pconfig->get("PlaceCount", "0"); $breaks = $pconfig->get("BreakCount", "0"); $sender->sendMessage("§8[§7 ---------- §8[§c".$this->prefix."§8]§7 ---------- §8]"); $sender->sendMessage("§c* §7Online:§c ".$online." "); $sender->sendMessage("§c* §7Odwiedzin:§c ".$joins." "); $sender->sendMessage("§c* §7Zabojstwa:§c ".$kills." "); $sender->sendMessage("§c* §7Smierci:§c ".$deaths." "); $sender->sendMessage("§c* §7Postawione Bloki:§c ".$places." "); $sender->sendMessage("§c* §7Zniszczone Bloki:§c ".$breaks." "); $sender->sendMessage("§8[§7 ---------- §8[§c".$this->prefix."§8]§7 ---------- §8]"); }else{ $sender->sendMessage($this->prefix.C::RED." Dieser Spieler war noch nie auf dem Server!"); } } } } Please help on edit my plugin
On the $pconfig->get you must online write "Online" for example and not the "true" PHP: $online = $pconfig->get("Online"); $joins = $pconfig->get("JoinCount"); $deaths = $pconfig->get("DeathCount"); $kills = $pconfig->get("KillCount"); $places = $pconfig->get("PlaceCount"); $breaks = $pconfig->get("BreakCount");
I assume your issue is fixed, but please fix this . Its easy if you make your folder's name lowercase which can save your life in the future!
PHP: <?phpnamespace StatusGracza;use pocketmine\plugin\PluginBase;use pocketmine\Player;use pocketmine\utils\TextFormat as C;use pocketmine\utils\Config;use pocketmine\event\Listener;use pocketmine\level\Level;use pocketmine\level\Position;use pocketmine\level\Position\getLevel;use pocketmine\math\Vector3;use pocketmine\event\player\PlayerJoinEvent;use pocketmine\event\player\PlayerQuitEvent;use pocketmine\event\player\PlayerDeathEvent;use pocketmine\event\block\BlockBreakEvent;use pocketmine\event\block\BlockPlaceEvent; use pocketmine\command\Command;use pocketmine\command\CommandSender;class Main extends PluginBase implements Listener{ public $prefix = C::GRAY."".C::AQUA."§cSTATY§7".C::GRAY.""; public function onEnable(){ $this->getServer()->getPluginManager()->registerEvents($this,$this); @mkdir($this->getDataFolder()); @mkdir($this->getDataFolder()."Players"); $this->getLogger()->info("by McpeBooster!"); } public function initPlayer($player){ $name = $player->getName(); $pconfig = new Config($this->getDataFolder()."/Players/".strtolower($name).".yml", Config::YAML); if(empty($pconfig->get("JoinCount"))){ $pconfig->set("Online","true"); $pconfig->set("JoinCount", "0"); $pconfig->set("DeathCount", "0"); $pconfig->set("KillCount", "0"); $pconfig->set("PlaceCount", "0"); $pconfig->set("BreakCount", "0"); } } public function onCommand(CommandSender $sender, Command $cmd, $label, array $args){ $name = $sender->getName(); if($cmd->getName() == "staty"){ if(empty($args[0])){ if($sender instanceof Player){ $player = $sender; $pconfig = new Config($this->getDataFolder()."/Players/".strtolower($name).".yml", Config::YAML);$online = $pconfig->get("Online"); $joins = $pconfig->get("JoinCount"); $deaths = $pconfig->get("DeathCount"); $kills = $pconfig->get("KillCount"); $places = $pconfig->get("PlaceCount"); $breaks = $pconfig->get("BreakCount"); $player->sendMessage("§8[§7 ---------- §8[§c".$this->prefix."§8]§7 ---------- §8]"); $player->sendMessage("§c* §7Online:§c ".$online); $player->sendMessage("§c* §7Odwiedzin:§c ".$joins); $player->sendMessage("§c* §7Zabojstwa:§c ".$kills); $player->sendMessage("§c* §7Smierci:§c ".$deaths); $player->sendMessage("§c* §7Postawione Bloki:§c ".$places); $player->sendMessage("§c* §7Zniszczone Bloki:§c ".$breaks); $player->sendMessage("§8[§7 ---------- §8[§c".$this->prefix."§8]§7 ---------- §8]"); } }elseif(!empty($args[0])){ if(file_exists($this->getDataFolder()."/Players/".strtolower($args[0]).".yml")){ $pconfig = new Config($this->getDataFolder()."/Players/".strtolower($args[0]).".yml", Config::YAML);$online = $pconfig->get("Online"); $joins = $pconfig->get("JoinCount"); $deaths = $pconfig->get("DeathCount"); $kills = $pconfig->get("KillCount"); $places = $pconfig->get("PlaceCount"); $breaks = $pconfig->get("BreakCount"); $sender->sendMessage("§8[§7 ---------- §8[§c".$this->prefix."§8]§7 ---------- §8]"); $sender->sendMessage("§c* §7Online:§c ".$online); $sender->sendMessage("§c* §7Odwiedzin:§c ".$joins); $sender->sendMessage("§c* §7Zabojstwa:§c ".$kills); $sender->sendMessage("§c* §7Smierci:§c ".$deaths); $sender->sendMessage("§c* §7Postawione Bloki:§c ".$places); $sender->sendMessage("§c* §7Zniszczone Bloki:§c ".$breaks); $sender->sendMessage("§8[§7 ---------- §8[§c".$this->prefix."§8]§7 ---------- §8]"); }else{ $sender->sendMessage($this->prefix.C::RED." Dieser Spieler war noch nie auf dem Server!"); } } } } public function onJoin(PlayerJoinEvent $event){ $player = $event->getPlayer(); $name = $player->getName(); $this->initPlayer($player); $pconfig = new Config($this->getDataFolder()."/Players/".strtolower($name).".yml", Config::YAML); $joins = $pconfig->get("JoinCount"); $pconfig->set("JoinCount", $joins + 1); $pconfig->set("Online", "true"); $pconfig->save(); } public function onPlace(BlockPlaceEvent $event){ $player = $event->getPlayer(); $name = $player->getName(); $pconfig = new Config($this->getDataFolder()."/Players/".strtolower($name).".yml", Config::YAML); $places = $pconfig->get("PlaceCount"); $pconfig->set("PlaceCount", $places + 1); $pconfig->save(); } public function onDestroy(BlockBreakEvent $event){ $player = $event->getPlayer(); $name = $player->getName(); $pconfig = new Config($this->getDataFolder()."/Players/".strtolower($name).".yml", Config::YAML); $breaks = $pconfig->get("BreakCount"); $pconfig->set("BreakCount", $breaks + 1); $pconfig->save(); } public function onQuit(PlayerQuitEvent $event){ $player = $event->getPlayer(); $name = $player->getName(); $pconfig = new Config($this->getDataFolder()."/Players/".strtolower($name).".yml", Config::YAML); $pconfig->set("Online", "false"); $pconfig->save(); } public function onDeath(PlayerDeathEvent $event){ $player = $event->getPlayer(); $name = $player->getName(); $pconfig = new Config($this->getDataFolder()."/Players/".strtolower($name).".yml", Config::YAML); $deaths = $pconfig->get("DeathCount"); $pconfig->set("DeathCount", $deaths + 1); $lastDmg = $player->getLastDamageCause(); if($lastDmg instanceof EntityDamageEvent){ if($lastDmg instanceof EntityDamageByEntityEvent){ $killer = $lastDmg->getDamager(); if($killer instanceof Player){ $kconfig = new Config($this->getDataFolder()."/Players/".strtolower($killer).".yml", Config::YAML); $kills = $kconfig->get("KillCount"); $kconfig->set("KillCount", $kills + 1); } } } $pconfig->save(); }}
PHP: name: StatusGraczamain: StatusGracza\Mainversion: 1.0.0api: 2.0.0author: McpeBoostercommands: staty: description: "Statystyki danego gracza"