Sueta
DA

DataBase

1.0

Easy "DataBase" based on yml files

·Plugin

Features:

  • You can create as many yml file as you want.
  • Easy file saving
  • You can save your yml files to a folder
  • You can delete files
  • You can clear or delete the DataBase's folder
  • You can get statistics of the DataBase (e.g: how many files in the folder or the size of the folder.)

Installation:

  1. Download the file from github, or there is an external link:
    [Link]
  2. Drag and drop the .java file to your project!
  3. Done!

Basic:

  • Create a new DataBase variable and fill it in the onEnable() method
    public   class  Main  extends  JavaPlugin  (   )   {  
    
       public  DataBase db  ;  
    
       public   void  onEnable  (   )   {  
        db  =   new  DataBase  (   this   )   ;  
       }  
    
     }

You everywhere can use name.yml format insead of name

Setting a folder
//There is two way of:  

 //You call the class like:  
db  =   new  DataBase  (   this  ,  "foldername"   )   ;  

 //You can set in another line:  
db.  setFolder   (   "foldername"   )   ;
Creating a new file
db.  create   (   "Name"   )   ;  
 //You don't need to save the file after creating.
Saving the file
db.  save   (   "Name"   )   ;
Deleting a file
db.  delete   (   "Name"   )   ;
Checking the success
//You can check the success of save , delete, create methods  
 boolean  success  =  save  (   "name.yml"   )   ;  
 boolean  success  =  create  (   "name.yml"   )   ;  
 boolean  success  =  delete  (   "name.yml"   )   ;
Setting a value
db  -  getYML  (   "Name.yml"   )   ;  
 //And after getYML() you can do everything like a getConfig().  
 //Examples:  
db.  getYML   (   "Name.yml"   )  .  createSection   (   "test"   )   ;  
 //Never forget saving!  
db.  save   (   "Name.yml"   )   ;
Getting a value
String   a1  =  db.  getYML   (   "Name"   )  .  getString   (   "teszt.a1"   )   ;
Checking the file is exist in the DataBase
db.  containsFile   (   "Name.yml"   )   ;  

 //Example:  
 if   (  db.  containsFile   (   "Name.yml"   )   )   {  
  p.  sendMessage   (   "True!"   )   ;  
 }
Clearing or Deleting a folder
db.  clearFolder   (   )   ;  
 //This is delete all files from the folder  

db.  deleteFolder   (   )   ;  
 //This is delete the folder and delete all files from it

get methods:

db.  getFolderFile   (   )   ;   //returns a File variable
db.  getFolderName   (   )   ;   //returns a String variable
db.  getFolderFileCount   (   )   ;   //returns an int variable, which is the number of how many files in the folder
db.  getFolderFiles   (   )   ;   //returns the all files from the folder
db.  getFolderSize   (   )   ;   //returns a long , which is the folder size in kilobytes
db.  getFileSize   (   "Name"   )   ;   //returns a long, which is the size of the file in kilobytes.

Similar projects

Plugin →