Delete player.dat upon disconnect

Discussion in 'Archived: Plugin Requests' started by x128, Jul 18, 2013.

  1. Offline

    x128

    Plugin category: Misc.

    Suggested name: DatLeave

    What I want: I would love to see a super simple plugin that deletes the player's dat file when they leave the server.

    Why do I want this? I am building a UHC Network and I would like to not save any player data when the player disconnects so that they will have to start over.

    Ideas for commands: No commands needed for this plugin.

    Ideas for permissions: No permissions needed for this plugin.

    When I'd like it by: Today.

    Extra Information: The path to my player's save folder is UHC/players/

    Thank you!
     
  2. Offline

    xxmobkiller

    What would i get if i make this plugin right now
     
  3. Offline

    x128

    xxmobkiller
    The satisfaction of helping another player with a plugin for their server?
    Monetary offers aren't allowed on BukkitDev.
     
  4. Offline

    xxmobkiller

    I know but would you offer me any donations ?
    I will still make the plugin?
     
  5. Offline

    x128

    xxmobkiller I'd try once I got my server up and some donations rolling in.
     
  6. Offline

    xxmobkiller

    Ok. I will be done with this in 2 minutes or less. Do you want me to post the .jar on here or send it to you on skype
     
  7. Offline

    x128

    xxmobkiller If you could post it on here that would be great. I currently don't have Skype installed :(
     
  8. Offline

    xxmobkiller

    Ok i will post it on here. When i get it done
     
  9. Offline

    x128

  10. Offline

    Deckerz

    xxmobkiller you really shouldn't just do request for gain. i will have this done in about 1 hours
     
  11. Offline

    pwnpk23

    You forgot to mention if the file would make [PLAYERNAME].dat
     
  12. Offline

    Deckerz

    Here you are: <Edit by Moderator: Redacted mediafire url>



    Source:
    Code:java
    1. package com.declanmc.dat.destroy;
    2.  
    3. import java.io.File;
    4. import org.bukkit.Bukkit;
    5. import org.bukkit.event.EventHandler;
    6. import org.bukkit.event.Listener;
    7. import org.bukkit.event.player.PlayerKickEvent;
    8. import org.bukkit.event.player.PlayerQuitEvent;
    9. import org.bukkit.plugin.java.JavaPlugin;
    10.  
    11. public class DatDestroy extends JavaPlugin implements Listener
    12. {
    13. public void onEnable(){
    14. Bukkit.getServer().getPluginManager().registerEvents(this, this);
    15.  
    16. }
    17. public void onDisable(){
    18.  
    19. }
    20. @EventHandler
    21. public void leave(PlayerQuitEvent e){
    22. String file = "";
    23. file = e.getPlayer().getWorld().getWorldFolder().getPath().toString();
    24. file = file +"/players/"+e.getPlayer().getDisplayName()+".dat";
    25. final String file2 = file;
    26. Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
    27. public void run() {
    28. deleteFile(file2);
    29. }
    30. }
    31. , 5L);
    32. }
    33. @EventHandler
    34. public void leave(PlayerKickEvent e){
    35. String file = "";
    36. file = e.getPlayer().getWorld().getWorldFolder().getPath().toString();
    37. file = file +"/players/"+e.getPlayer().getDisplayName()+".dat";
    38. final String file2 = file;
    39. Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
    40. public void run() {
    41. deleteFile(file2);
    42. }
    43. }
    44. , 5L);
    45. }
    46. public boolean deleteFile(String file)
    47. {
    48. File f1 = new File(file);
    49. boolean success = f1.delete();
    50. return success;
    51. }
    52. }
    53.  
     
    Last edited by a moderator: Nov 6, 2016
    jacklin213, AndyMcB1 and hawkfalcon like this.
  13. Offline

    x128

    declanmc96 Thank you so much! Works like a charm :)
     
  14. Offline

    Deckerz

    No probelmo
     
  15. Offline

    Me4502

    Just by the way, this is actually possible without a plugin. Don't give the server write permissions to the players folder and it won't even make them.
     
  16. Offline

    Deckerz

    But plugin is allot easier
     
  17. Offline

    Me4502


    Not really, it's super easy to set perms on a folder.
     

Share This Page