mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-20 19:49:44 +00:00
PHP8: new str_* function
This commit is contained in:
parent
69385e16f2
commit
1275a4558c
7 changed files with 15 additions and 15 deletions
|
|
@ -190,8 +190,8 @@ class PlayerAPI{
|
|||
}
|
||||
break;
|
||||
case "tp":
|
||||
if(count($args) <= 2 or substr($args[0], 0, 2) === "w:" or substr($args[1], 0, 2) === "w:"){
|
||||
if((!isset($args[1]) or substr($args[0], 0, 2) === "w:") and isset($args[0]) and ($issuer instanceof Player)){
|
||||
if(count($args) <= 2 or str_starts_with($args[0], "w:") or str_starts_with($args[1], "w:")){
|
||||
if((!isset($args[1]) or str_starts_with($args[0], "w:")) and isset($args[0]) and ($issuer instanceof Player)){
|
||||
$name = $issuer->username;
|
||||
$target = implode(" ", $args);
|
||||
}elseif(isset($args[1]) and isset($args[0])){
|
||||
|
|
@ -297,7 +297,7 @@ class PlayerAPI{
|
|||
}
|
||||
|
||||
public function teleport(&$name, &$target){
|
||||
if(substr($target, 0, 2) === "w:"){
|
||||
if(str_starts_with($target, "w:")){
|
||||
$lv = $this->server->api->level->get(substr($target, 2));
|
||||
if($lv instanceof Level){
|
||||
$origin = $this->get($name);
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ class TimeAPI{
|
|||
$p = strtolower(array_shift($args));
|
||||
switch($p){
|
||||
case "check":
|
||||
if(substr($args[0] ?? "", 0, 2) === "w:"){
|
||||
if(str_starts_with($args[0] ?? "", "w:")){
|
||||
$levelName = preg_replace("/w:/", "", $args[0]);
|
||||
$level = $this->server->api->level->get($levelName);
|
||||
if($level instanceof Level){
|
||||
|
|
@ -44,7 +44,7 @@ class TimeAPI{
|
|||
$output .= "Time" . $world . ": " . $this->getDate($level) . ", " . $this->getPhase($level) . " (" . $this->get(true, $level) . " ticks)\n";
|
||||
break;
|
||||
case "add":
|
||||
if(substr($args[1] ?? "", 0, 2) === "w:"){
|
||||
if(str_starts_with($args[1] ?? "", "w:")){
|
||||
$levelName = preg_replace("/w:/", "", $args[1]);
|
||||
$level = $this->server->api->level->get($levelName);
|
||||
if($level instanceof Level){
|
||||
|
|
@ -65,7 +65,7 @@ class TimeAPI{
|
|||
$output .= "Added $addTime ticks" . $world . "\n";
|
||||
break;
|
||||
case "set":
|
||||
if(isset($args[1]) and substr($args[1], 0, 2) === "w:"){
|
||||
if(isset($args[1]) and str_starts_with($args[1], "w:")){
|
||||
$levelName = preg_replace("/w:/", "", $args[1]);
|
||||
$level = $this->server->api->level->get($levelName);
|
||||
if($level instanceof Level){
|
||||
|
|
@ -92,7 +92,7 @@ class TimeAPI{
|
|||
case "day":
|
||||
case "sunset":
|
||||
case "night":
|
||||
if(count($args) > 1 && substr($args[1], 0, 2) === "w:"){
|
||||
if(count($args) > 1 && str_starts_with($args[1], "w:")){
|
||||
$levelName = preg_replace("/w:/", "", $args[1]);
|
||||
$level = $this->server->api->level->get($levelName);
|
||||
if($level instanceof Level){
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue