SHARE
TWEET

Untitled

a guest Jan 24th, 2020 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. protected function executeSetWorld(CommandSender $sender, $level, $setting, $value)
  2.     {
  3.         $msg = null;
  4.  
  5.         $worldManager = PvPCore::getWorldHandler();
  6.  
  7.         if ($worldManager->isWorld($level)) {
  8.  
  9.             $hasUpdated = false;
  10.             $updatedVal = "None";
  11.  
  12.             switch ($setting) {
  13.                 case "kb":
  14.                 case "knockback":
  15.                     $updatedVal = "knockback";
  16.                     $value = floatval($value);
  17.                     break;
  18.                 case "delay":
  19.                 case "attackdelay":
  20.                     $updatedVal = "attack-delay";
  21.                     $value = intval($value);
  22.                     break;
  23.                 default:
  24.             }
  25.  
  26.             $world = $worldManager->getWorld($level);
  27.  
  28.             if ($updatedVal !== "None") {
  29.  
  30.                 if ($updatedVal === "attack-delay" and PvPCore::canParse($value, true)) {
  31.                     $world = $world->setAttackDelayTime($value);
  32.                     $hasUpdated = true;
  33.                 }
  34.                 if ($updatedVal === "knockback" and PvPCore::canParse($value, false)) {
  35.                     $world = $world->setKB($value);
  36.                     $hasUpdated = true;
  37.                 }
  38.             }
  39.  
  40.             if ($hasUpdated === true) {
  41.                 $worldManager->updateWorld($world);
  42.                 $msg = TextFormat::GREEN . "The level '{$level}' has been successfully updated!";
  43.             } else {
  44.                 $msg = TextFormat::RED . "The level '{$level}' failed to update!";
  45.             }
  46.  
  47.         } else $msg = TextFormat::RED . "Level '{$level}' does not exist!";
  48.  
  49.         if($msg !== null){
  50.             $sender->sendMessage($msg);
  51.         }
  52.  
  53.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top