Advertisement
james1bow

Untitled

Sep 4th, 2024
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.79 KB | None | 0 0
  1. public class Logger {
  2.    
  3.     private Plugin plugin;
  4.    
  5.     public String currentFileName;
  6.    
  7.     public Logger(Plugin plugin){
  8.        
  9.         this.plugin = plugin;
  10.         currentFileName = fileName();
  11.     }
  12.    
  13.     public void initLogging(){
  14.         addTransactionTimeStamp();
  15.        
  16.        
  17.     }
  18.    
  19.     private void addTransactionTimeStamp(){
  20.         String newLoad = ""+date();
  21.         try {
  22.             FileWriter writer = new FileWriter(plugin.getPath() + "/transactions"+currentFileName+".txt",true);
  23.             writer.append("\n**********"+newLoad+"**********\n");
  24.             writer.close();
  25.             }
  26.                 catch (IOException e) {
  27.             // TODO Auto-generated catch block
  28.  
  29.             }
  30.        
  31.     }
  32.    
  33.     public void saveTransaction(String playerId, Long currentbal, Long amount, String operator, Long newAmount, String type, String description){
  34.        
  35.         try {
  36.             try (FileWriter writer = new FileWriter(plugin.getPath() + "/transactions"+currentFileName+".txt",true)) {
  37.                 writer.append("\n"+date()+" : "+playerId+" : "+currentbal+" : "+operator+" : "+amount+" : "+newAmount+" : "+type+" : "+description);
  38.             }
  39.             }
  40.                 catch (IOException e) {
  41.             // TODO Auto-generated catch block
  42.  
  43.             }
  44.        
  45.     }
  46.    
  47.    
  48.     private String date(){
  49.        SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");  
  50.        Date date = new Date();
  51.        String fdate = (formatter.format(date));
  52.     return fdate;}
  53.    
  54.     private String fileName(){
  55.        SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yyyy");  
  56.        Date date = new Date();
  57.        String fdate = (formatter.format(date));
  58.     return fdate;}
  59.    
  60.    
  61.    
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement