Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Logger {
- private Plugin plugin;
- public String currentFileName;
- public Logger(Plugin plugin){
- this.plugin = plugin;
- currentFileName = fileName();
- }
- public void initLogging(){
- addTransactionTimeStamp();
- }
- private void addTransactionTimeStamp(){
- String newLoad = ""+date();
- try {
- FileWriter writer = new FileWriter(plugin.getPath() + "/transactions"+currentFileName+".txt",true);
- writer.append("\n**********"+newLoad+"**********\n");
- writer.close();
- }
- catch (IOException e) {
- // TODO Auto-generated catch block
- }
- }
- public void saveTransaction(String playerId, Long currentbal, Long amount, String operator, Long newAmount, String type, String description){
- try {
- try (FileWriter writer = new FileWriter(plugin.getPath() + "/transactions"+currentFileName+".txt",true)) {
- writer.append("\n"+date()+" : "+playerId+" : "+currentbal+" : "+operator+" : "+amount+" : "+newAmount+" : "+type+" : "+description);
- }
- }
- catch (IOException e) {
- // TODO Auto-generated catch block
- }
- }
- private String date(){
- SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
- Date date = new Date();
- String fdate = (formatter.format(date));
- return fdate;}
- private String fileName(){
- SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yyyy");
- Date date = new Date();
- String fdate = (formatter.format(date));
- return fdate;}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement