StaticPortMappingCollection)){ throw new \RuntimeException("Failed to portforward (unsupported?)"); } /** @noinspection PhpUndefinedFieldInspection */ $com->StaticPortMappingCollection->Add($port, "UDP", $port, $myLocalIP, true, "PocketMine-MP"); } public static function RemovePortForward(int $port) : bool{ if(!Utils::$online){ return false; } if(Utils::getOS() != "win" or !class_exists("COM")){ return false; } try{ /** @noinspection PhpUndefinedClassInspection */ $com = new \COM("HNetCfg.NATUPnP"); /** @noinspection PhpUndefinedFieldInspection */ if($com === false or !is_object($com->StaticPortMappingCollection)){ return false; } /** @noinspection PhpUndefinedFieldInspection */ $com->StaticPortMappingCollection->Remove($port, "UDP"); }catch(\Throwable $e){ return false; } return true; } }