Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Solved Delete Player.yml Data

Comments in 'Plugin Development' started by CrazedMiner, Aug 30, 2015.

  1. CrazedMiner
    Offline

    CrazedMiner Notable Member Plugin Developer

    Joined:
    Jan 31, 2015
    Posts:
    348
    Plugins:
    2
    Minecraft User:
    CrazedMinerYT
    Hi, I was wondering if it is possible to delete the playername.yml data in the players folder when they quit, this would save us Dev's from clearing their inventory and resetting their location. Thanks!
  2. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    No. The data are saved after PlayerQuitEvent is fired. Instead, use PlayerQuitEvent::setAutoSave(false)
    RekkuzaRage likes this.
  3. RekkuzaRage
    Offline

    RekkuzaRage Active Member

    Joined:
    Apr 15, 2014
    Posts:
    251
    Minecraft User:
    RekkuzaRage
    Never knew about that. :)
  4. CrazedMiner
    Offline

    CrazedMiner Notable Member Plugin Developer

    Joined:
    Jan 31, 2015
    Posts:
    348
    Plugins:
    2
    Minecraft User:
    CrazedMinerYT
    Could I have an example plz? <3
  5. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    PHP:
     public function onQuit(PlayerQuitEvent $e){
      
    $e->setAutoSave(false);
    }
  6. CrazedMiner
    Offline

    CrazedMiner Notable Member Plugin Developer

    Joined:
    Jan 31, 2015
    Posts:
    348
    Plugins:
    2
    Minecraft User:
    CrazedMinerYT
    Doesn't work, when I join I spawn exactly where I left.
  7. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    It shouldn't save your data if you used it.
  8. CrazedMiner
    Offline

    CrazedMiner Notable Member Plugin Developer

    Joined:
    Jan 31, 2015
    Posts:
    348
    Plugins:
    2
    Minecraft User:
    CrazedMinerYT
    PHP:
    public function onQuit(PlayerQuitEvent $event) {
            
    $player $event->getPlayer();
            
    $name strtolower($player->getName());
            
    $event->setAutoSave(false);
            if(
    file_exists($this->getServer()->getDataPath() . "players/" $name ".yml")) {
                @
    unlink($this->getServer()->getDataPath() . "players/" $name ".yml");
            }
        }
    Doesn't work tho.
  9. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    Its not saved in .yml but in .dat
  10. CrazedMiner
    Offline

    CrazedMiner Notable Member Plugin Developer

    Joined:
    Jan 31, 2015
    Posts:
    348
    Plugins:
    2
    Minecraft User:
    CrazedMinerYT
    Oop's, I tried it with .dat as the file type and it still doesn't work :(
  11. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Are you sure you are handling that event? Like, listeners registered?
    Primus likes this.
  12. CrazedMiner
    Offline

    CrazedMiner Notable Member Plugin Developer

    Joined:
    Jan 31, 2015
    Posts:
    348
    Plugins:
    2
    Minecraft User:
    CrazedMinerYT
    Wow, I haven't done that in ages, I'm not gonna try and code stuff when I'm tied next time, thanks!

Share This Page

Advertisement