Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package mw;
- import java.io.BufferedWriter;
- import java.io.FileWriter;
- import java.text.DateFormat;
- import java.text.SimpleDateFormat;
- import java.util.Date;
- import java.util.List;
- import org.bukkit.Bukkit;
- import org.bukkit.World;
- public class ChatLog {
- public static void log_whisper(String to, String from, String message,
- char color_to, char color_from) {
- try {
- List<World> worlds = Bukkit.getWorlds();
- String worldname = worlds.get(0).getName();
- String filename = "F:\\xampp\\htdocs\\mc\\logs\\" + worldname
- + ".LOG";
- BufferedWriter out = new BufferedWriter(new FileWriter(filename,
- true));
- out.write("Whisper: " + from + " >>> " + to + ": "
- + message + "<br>\r\n");
- out.close();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- public static void log_message(String from, String message, boolean color) {
- try {
- List<World> worlds = Bukkit.getWorlds();
- String worldname = worlds.get(0).getName();
- String filename = "F:\\xampp\\htdocs\\mc\\logs\\" + worldname
- + ".LOG";
- BufferedWriter out = new BufferedWriter(new FileWriter(filename,
- true));
- String op = "";
- if (color) {
- op = " [OP]";
- }
- DateFormat dateFormat = new SimpleDateFormat(
- "EEE, d MMM yyyy HH:mm:ss Z");
- Date date = new Date();
- String timestamp = dateFormat.format(date);
- out.write("[" + timestamp + "] <" + from + ">" + op + " : "
- + message + "<br>\r\n");
- out.close();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- public static void log_server_message(String message) {
- try {
- List<World> worlds = Bukkit.getWorlds();
- String worldname = worlds.get(0).getName();
- String filename = "F:\\xampp\\htdocs\\mc\\logs\\" + worldname
- + ".LOG";
- DateFormat dateFormat = new SimpleDateFormat(
- "EEE, d MMM yyyy HH:mm:ss Z");
- Date date = new Date();
- String timestamp = dateFormat.format(date);
- BufferedWriter out = new BufferedWriter(new FileWriter(filename,
- true));
- out.write("[" + timestamp + "] <SERVER> : " + message
- + "<br>\r\n");
- out.close();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- public static void log_console_message(String message) {
- try {
- List<World> worlds = Bukkit.getWorlds();
- String worldname = worlds.get(0).getName();
- String filename = "F:\\xampp\\htdocs\\mc\\logs\\" + worldname
- + ".LOG";
- DateFormat dateFormat = new SimpleDateFormat(
- "EEE, d MMM yyyy HH:mm:ss Z");
- Date date = new Date();
- String timestamp = dateFormat.format(date);
- BufferedWriter out = new BufferedWriter(new FileWriter(filename,
- true));
- out.write("[" + timestamp + "] <CONSOLE> : " + message
- + "<br>\r\n");
- out.close();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- public static void log_warning(String message) {
- try {
- List<World> worlds = Bukkit.getWorlds();
- String worldname = worlds.get(0).getName();
- String filename = "F:\\xampp\\htdocs\\mc\\logs\\" + worldname
- + ".LOG";
- DateFormat dateFormat = new SimpleDateFormat(
- "EEE, d MMM yyyy HH:mm:ss Z");
- Date date = new Date();
- String timestamp = dateFormat.format(date);
- BufferedWriter out = new BufferedWriter(new FileWriter(filename,
- true));
- out.write("[" + timestamp + "] <WARNING> : " + message
- + "<br>\r\n");
- out.close();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- public static void log_error(String message) {
- try {
- List<World> worlds = Bukkit.getWorlds();
- String worldname = worlds.get(0).getName();
- String filename = "F:\\xampp\\htdocs\\mc\\logs\\" + worldname
- + ".LOG";
- DateFormat dateFormat = new SimpleDateFormat(
- "EEE, d MMM yyyy HH:mm:ss Z");
- Date date = new Date();
- String timestamp = dateFormat.format(date);
- BufferedWriter out = new BufferedWriter(new FileWriter(filename,
- true));
- out.write("[" + timestamp + "] <ERROR> : " + message
- + "<br>\r\n");
- out.close();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement