1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Solved SkyWars NBT update.

Discussion in 'Development' started by RyanShaw, Apr 26, 2018.

  1. RyanShaw

    RyanShaw Witch

    Messages:
    69
    Hi! I've been trying to update the skywars plugin by svile but ive bumped into two errors that ive no clue with, one regarding when the plugin loads up.
    PHP:
    public function onLoad()
    {
    if (!
    is_dir($this->getDataFolder()))
    @
    mkdir($this->getDataFolder() . "\x61\x72\x65\x6e\x61\x73"0755true);
    //This changes worlds NBT name with folders ones to avoid problems //world folder name should be used instead of doing this
    try {
    foreach (
    scandir($this->getServer()->getDataPath() . "\x77\x6f\x72\x6c\x64\x73") as $worldDir) {
    if (
    is_dir($this->getServer()->getDataPath() . "\x77\x6f\x72\x6c\x64\x73\x2f" $worldDir) && is_file($this->getServer()->getDataPath() . "\x77\x6f\x72\x6c\x64\x73\x2f" $worldDir "\x2f\x6c\x65\x76\x65\x6c\x2e\x64\x61\x74")) {
    $nbt = new NBT(NBT::BIG_ENDIAN);
    $nbt->readCompressed(file_get_contents($this->getServer()->getDataPath() . "\x77\x6f\x72\x6c\x64\x73\x2f" $worldDir "\x2f\x6c\x65\x76\x65\x6c\x2e\x64\x61\x74"));
    $levelData $nbt->getData();
    if (
    array_key_exists("\x44\x61\x74\x61"$levelData) && $levelData["\x44\x61\x74\x61"] instanceof Compound) {
    $levelData $levelData["\x44\x61\x74\x61"];
    if (
    array_key_exists("\x4c\x65\x76\x65\x6c\x4e\x61\x6d\x65"$levelData) && $levelData["\x4c\x65\x76\x65\x6c\x4e\x61\x6d\x65"] != $worldDir) {
    $levelData["\x4c\x65\x76\x65\x6c\x4e\x61\x6d\x65"] = new Str("\x4c\x65\x76\x65\x6c\x4e\x61\x6d\x65"$worldDir);
    $nbt->setData(new Compound('', ["\x44\x61\x74\x61" => $levelData]));
    file_put_contents($this->getServer()->getDataPath() . "\x77\x6f\x72\x6c\x64\x73\x2f" $worldDir "\x2f\x6c\x65\x76\x65\x6c\x2e\x64\x61\x74"$nbt->writeCompressed());
    }
    unset(
    $worldDir$levelData$nbt);
    } else {
    $this->getLogger()->critical('There is a problem with the "level.dat" of the world: §f' $worldDir);
    unset(
    $worldDir$levelData$nbt);
    }
    }
    }
    } catch (\
    Exception $e) {
    $this->getLogger()->critical($e->getMessage() . ' in §b' $e->getFile() . '§c on line §b' $e->getLine());
    }
    Which caused this error
    PHP:
     25.04 22:35:56 [ServerServer thread/CRITICAL Error"Cannot instantiate abstract class pocketmine\nbt\NBT" (EXCEPTIONin "SkyWars-svile-master/src/svile/sw/SWmain" at line 95 
    And the second one is when i try make an arena with /sw create
    PHP:
     25.04 23:09:49 [ServerServer thread/DEBUG #1 SkyWars-svile-master/src/svile/sw/SWcommands(267): pocketmine\nbt\tag\CompoundTag->__set(string generatorName, pocketmine\nbt\tag\StringTag object) 25.04 23:09:49 [Server] Server thread/DEBUG #0 vendor/pocketmine/nbt/src/tag/NoDynamicFieldsTrait(37): pocketmine\nbt\tag\CompoundTag->throw() 25.04 23:09:49 [Server] Server thread/CRITICAL RuntimeException: "Dynamic field access on pocketmine\nbt\tag\CompoundTag is no longer supported" (EXCEPTION) in "vendor/pocketmine/nbt/src/tag/NoDynamicFieldsTrait" at line 29 25.04 23:09:49 [Server] Server thread/CRITICAL Unhandled exception executing command 'sw create ryan 2 150 300' in sw: Dynamic field access on pocketmine\nbt\tag\CompoundTag is no longer supported 25.04 23:09:45 
    Correct me if im wrong but im sure that error refers to this line
    PHP:
     $provider->getLevelData()->LevelName = new Str('LevelName'$fworld); 
    If anyone can show me the changes need to be made i'd be very grateful. I've tried to look at other plugins to compare their nbt updates with this one but they're all so different! :confused: I think a tutorial in resources is needed for this :oops: The plugin is here if you don't know what one i'm referring to :p
     
    Last edited: Apr 26, 2018
  2. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    I think it's better you create an issue request for the author to update the plugin if you can't understand their coding style :oops:
     
  3. Tee7even

    Tee7even Slime

    Messages:
    81
    GitHub:
    tee7even
    What we have here is less like "style" and more like code that is intentionally made harder to understand.
     
  4. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    Yup, and also outdated.
     
  5. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    667
    A YouTuber is selling a fix. This plugin is very hard to understand and bad written.
     
  6. RyanShaw

    RyanShaw Witch

    Messages:
    69
    You're probably right but i don't think the author has intentions of updating it, plus you're not able to leave issues there sadly :p
    I can't say i agree with the bad written part, but is this a fix you have in your possession? Also I don't think its very fair for svile to make a big plugin like this and have someone else make money off it lol
     
  7. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    667
    Svile left plugin coding a looong time ago. He is coding MCPE hacks now. I don't think he cares but, read the license.
     
  8. RyanShaw

    RyanShaw Witch

    Messages:
    69
    Do you have this fix?
     
    Last edited: Apr 26, 2018
  9. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    RyanShaw likes this.
  10. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    667
    No, but I have joined the test server of this dev and it worked.
     
  11. RyanShaw

    RyanShaw Witch

    Messages:
    69
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.