PHP: case "sethome": if(!isset($homes)){ $homes = array(); $homeCount = 0; } else { $homes = $this->homes->getNested("$name.homes.$level"); $homeCount = count($homes); } $sender->sendMessage("$maxHomes $homeCount"); if(!$sender instanceof Player){ $sender->sendMessage(TextFormat::RED . "This command is valid in-game only."); return true; } if(!isset($args[0]) || isset($args[1])){ $sender->sendMessage(TextFormat::RED . "One argument is required."); return false; } if($homeCount >= $maxHomes){ $sender->sendMessage("You have reached your maximum home limit."); return true; } $x = $sender->getX(); $y = $sender->getY(); $z = $sender->getZ(); $data = array($x, $y, $z); $this->homes->setNested("$name.homes.$level." . $args[0] . "", $data); $this->homes->save(); $homesLeft = $maxHomes - $homeCount; $sender->sendMessage("You have successfully created a new home: " . $args[0] . ". Now you have $homesLeft home left."); break;case "home": if(!isset($homes)){ $sender->sendMessage("You do not have a home."); return true; } foreach($homes as $homeName){ if(!isset($args[0])){ $sender->sendMessage("Available homes:"); $sender->sendMessage($homeName); $sender->sendMessage("You currently have $homeCount/$maxHomes homes"); return true; } if(!$homeName === $args[0]){ $sender->sendMessage("That home does not exist."); return true; } $coordinate = $this->homes->getNested("$name.homes.$level." . $args[0] . ""); $sender->teleport(new Position($coordinate[0], $coordinate[1], $coordinate[2])); $sender->sendMessage("You have been teleported to your home: " . $args[0] . "."); return true; break; (I would like to tell you that there are much more in this code, but this is the part I am having trouble with. This means that the bracket might be missing. Also, sorry for the amount of codes, I am absolutely desperate.) I have written this code myself, and I have noticed millions of problems that have been annoying me since couple of days ago. 1. In the sethome section, $homeCount does not update unless I stop the server. I was pretty sure it would update, but it get stuck at that instance of number of homes. 2. In the home section, I am getting RuntimeException: "Illegal offset type in isset or empty" errors. I have no idea what this means, and what is even worse is that when it used to work, $homeName only returned the first home name only. 3. In the home section again, there is a part where I check if that home exists. It just doesn't work. I thought it would behave like what happened in the problem 2 and block anything but the first home, but it just lets all the homes. It would be superb if you answered at least one of them, and even better if you find other mistakes. I am not that good with coding still, so it would help me a lot. Thank you in advance.
Can you please upload all of the code? It's really hard to help when we don't know which kind of objects the properties are. Also, if you don't want to share the code to the public, feel free to PM me it.