public function onCommand(CommandSender $sender, Command $cmd, string $label, array $args) : bool { switch($cmd->getName()){ case "modban": if($sender instanceof Player) { if($sender->hasPermission("gpe.ban")){ $name = $this->getServer()->getPlayerExact($args[0]); if($args[1] == "24"){ $hour = "24"; } else if ($args[1] == "336"){ $hour = "336"; } else if ($args[1] == "720"){ $hour = "720"; } else if ($args[1] == "48"){ $hour = "48"; } else if ($args[1] == "8760"){ $hour = "8760"; } else if ($args[1] == "1000"){ $hour = "1000"; } else if ($args[1] == "96"){ $hour = "96"; } if(count($args) >= 2) { $reason = ""; for ($i = 2; $i < count($args); $i++) { $reason .= $args[$i]; $reason .= " "; } } $reason = substr($reason, 0, strlen($reason) - 1); if($hour == "24"){ $totalTime = 24 * 3600; $banCount = 24; } else if ($hour == "336"){ $totalTime = 336 * 3600; $banCount = 336; } else if ($hour == "720"){ $totalTime = 720 * 3600; $banCount = 720; } else if ($hour == "48"){ $totalTime = 48 * 3600; $banCount = 48; } else if ($hour == "8760"){ $totalTime = 8760 * 3600; $banCount = 8760; } else if ($hour == "1000"){ $totalTime = 1000 * 3600; $banCount = 1000; } else if ($hour == "96"){ $totalTime = 96 * 3600; $banCount = 96; } if($name instanceof Player) { $name->kick(TextFormat::RED . "You have been mod banned for " . TextFormat::AQUA . $hour . " hours. " . TextFormat::RED . "Comment: " . TextFormat::AQUA . $reason); $this->banList[strtolower($name->getName())] = $name; $name = trim(strtolower($name->getName())); $config = new Config($this->getDataFolder() . "players/" . strtolower($name) . ".yml", Config::YAML); $data = $config->getAll(); $totalBanCount = $data["BanCount"]; $newBanCount = $totalBanCount + $banCount; $config = new Config($this->getDataFolder() . "players/" . strtolower($name) . ".yml", Config::YAML); $config->set("Ban", "True"); $config->set("BanCount", $newBanCount); $config->set("Hour", $hour); $config->set("TotalTime", $totalTime); $config->set("Reason", $reason); $config->save(); $this->getServer()->broadcastMessage(TextFormat::WHITE . "•" .TextFormat::GREEN . $name . " has been [BANNED] for " . $reason . "."); $sender->sendMessage(TextFormat::WHITE . "•" . TextFormat::BLUE . $name . " has been banned!"); } } } else{ $sender->sendMessage(TextFormat::RED . "Use this Command in-game."); return true; } break;
Sorry, but i did totally lmao there. The whole hour whatever-the-f*ck converting part can be compressed into: PHP: $hour = $args[1];$totalTime = $args[1] * 3600;$banCount = $args[1]; and to get back to your error, it's probably because you're not checking if your user has supplied arg 1/ the time. so, this should be "fixing" it: PHP: public function onCommand(CommandSender $sender, Command $cmd, string $label, array $args) : bool {switch($cmd->getName()){case "modban":if($sender instanceof Player) {if($sender->hasPermission("gpe.ban")){$name = $this->getServer()->getPlayerExact($args[0]);if(!isset($args[1]){return false;}$hour = $args[1];$totalTime = $args[1] * 3600;$banCount = $args[1];if(count($args) >= 2) {$reason = "";for ($i = 2; $i < count($args); $i++) {$reason .= $args[$i];$reason .= " ";}}$reason = substr($reason, 0, strlen($reason) - 1);if($name instanceof Player) {$name->kick(TextFormat::RED . "You have been mod banned for " . TextFormat::AQUA . $hour . " hours. " . TextFormat::RED . "Comment: " . TextFormat::AQUA . $reason);$this->banList[strtolower($name->getName())] = $name;$name = trim(strtolower($name->getName()));$config = new Config($this->getDataFolder() . "players/" . strtolower($name) . ".yml", Config::YAML);$data = $config->getAll();$totalBanCount = $data["BanCount"];$newBanCount = $totalBanCount + $banCount;$config = new Config($this->getDataFolder() . "players/" . strtolower($name) . ".yml", Config::YAML);$config->set("Ban", "True");$config->set("BanCount", $newBanCount);$config->set("Hour", $hour);$config->set("TotalTime", $totalTime);$config->set("Reason", $reason);$config->save();$this->getServer()->broadcastMessage(TextFormat::WHITE . "•" .TextFormat::GREEN . $name . " has been [BANNED] for " . $reason . ".");$sender->sendMessage(TextFormat::WHITE . "•" . TextFormat::BLUE . $name . " has been banned!");}}}else{$sender->sendMessage(TextFormat::RED . "Use this Command in-game.");return true;}break; But seriously, keep your hands off that plugin, it deserves to burn.