Commit 907a738d authored by Marius Lindvall's avatar Marius Lindvall

Migrate from code.varden.info

parents
Pipeline #2 canceled with stages
TERMS AND CONDITIONS
0. USED TERMS
MOD - modification, plugin, a piece of software that interfaces with
the Minecraft client to extend, add, change or remove original
capabilities.
MOJANG - Mojang AB
OWNER - bilde2910, Marius Lindvall, Original author(s) of the MOD.
Under the copyright terms accepted when purchasing Minecraft
(https://minecraft.net/terms) the OWNER has full rights over their
MOD despite use of MOJANG code.
USER - End user of the mod, person installing the mod.
1. LIABILITY
THIS MOD IS PROVIDED 'AS IS' WITH NO WARRANTIES, IMPLIED OR
OTHERWISE. THE OWNER OF THIS MOD TAKES NO RESPONSIBILITY FOR ANY
DAMAGES INCURRED FROM THE USE OF THIS MOD. THIS MOD ALTERS
FUNDAMENTAL PARTS OF THE MINECRAFT GAME, PARTS OF MINECRAFT MAY NOT
WORK WITH THIS MOD INSTALLED. ALL DAMAGES CAUSED FROM THE USE OR
MISUSE OF THIS MOD FALL ON THE USER.
2. USE
Use of this MOD to be installed, manually or automatically, is given
to the USER without restriction.
3. REDISTRIBUTION
This MOD may only be distributed where uploaded, mirrored, or
otherwise linked to by the OWNER solely. All mirrors of this mod must
have advance written permission from the OWNER. ANY attempts to make
money off of this MOD (selling, selling modified versions, adfly,
sharecash, etc.) are STRICTLY FORBIDDEN, and the OWNER may claim
damages or take other action to rectify the situation.
4. DERIVATIVE WORKS/MODIFICATION
This mod is provided freely and may be decompiled and modified for
private use, either with a decompiler or a bytecode editor. Public
distribution of modified versions of this MOD require advance written
permission of the OWNER and may be subject to certain terms.
http://bit.ly/clmcmod
\ No newline at end of file
http://varden.info/product.php?sid=13
\ No newline at end of file
/*
Copyright (C) 2014 Varden Development / Marius Lindvall / bilde2910
under the Varden Development Minecraft Mod License version 1.
The license has been attached below for convenience.
---------------------------------------------------------------------
TERMS AND CONDITIONS
0. USED TERMS
MOD - modification, plugin, a piece of software that interfaces with
the Minecraft client to extend, add, change or remove original
capabilities.
MOJANG - Mojang AB
OWNER - bilde2910, Marius Lindvall, Original author(s) of the MOD.
Under the copyright terms accepted when purchasing Minecraft
(https://minecraft.net/terms) the OWNER has full rights over their
MOD despite use of MOJANG code.
USER - End user of the mod, person installing the mod.
1. LIABILITY
THIS MOD IS PROVIDED 'AS IS' WITH NO WARRANTIES, IMPLIED OR
OTHERWISE. THE OWNER OF THIS MOD TAKES NO RESPONSIBILITY FOR ANY
DAMAGES INCURRED FROM THE USE OF THIS MOD. THIS MOD ALTERS
FUNDAMENTAL PARTS OF THE MINECRAFT GAME, PARTS OF MINECRAFT MAY NOT
WORK WITH THIS MOD INSTALLED. ALL DAMAGES CAUSED FROM THE USE OR
MISUSE OF THIS MOD FALL ON THE USER.
2. USE
Use of this MOD to be installed, manually or automatically, is given
to the USER without restriction.
3. REDISTRIBUTION
This MOD may only be distributed where uploaded, mirrored, or
otherwise linked to by the OWNER solely. All mirrors of this mod must
have advance written permission from the OWNER. ANY attempts to make
money off of this MOD (selling, selling modified versions, adfly,
sharecash, etc.) are STRICTLY FORBIDDEN, and the OWNER may claim
damages or take other action to rectify the situation.
4. DERIVATIVE WORKS/MODIFICATION
This mod is provided freely and may be decompiled and modified for
private use, either with a decompiler or a bytecode editor. Public
distribution of modified versions of this MOD require advance written
permission of the OWNER and may be subject to certain terms.
*/
package info.varden.chatlog;
import net.minecraft.client.Minecraft;
import net.minecraft.util.text.TextComponentString;
import net.minecraftforge.client.ClientCommandHandler;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.Mod.Instance;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import org.apache.logging.log4j.Logger;
@Mod(modid="info.varden.chatlog", name="ChatLog", version="2.1.1.91")
public class ChatLog {
public Themes themes;
public HtmlConverter htmlConverter;
public ConfigManager configManager;
public Logs logs;
public Minecraft mc;
public Util util;
private Logger logger;
@Instance(value = "info.varden.chatlog")
public static ChatLog instance;
@EventHandler
public void preInit(FMLPreInitializationEvent event) {
this.logger = event.getModLog();
}
@EventHandler
public void load(FMLInitializationEvent event) {
this.mc = Minecraft.getMinecraft();
logInfo("Initializing ChatLog...");
this.util = new Util(this);
this.themes = new Themes(this);
this.themes.initThemes();
this.htmlConverter = new HtmlConverter(this);
this.configManager = new ConfigManager(this);
this.logs = new Logs(this);
this.configManager.readPropertiesFile();
logInfo("Initialized.");
}
@EventHandler
public void postInit(FMLPostInitializationEvent event) {
logInfo("Registering chat handler to Forge event bus...");
MinecraftForge.EVENT_BUS.register(new ChatReceivedHandler(this));
logInfo("Chat handler registered.");
logInfo("Registering control command to client command registry...");
ClientCommandHandler.instance.registerCommand(new Command(this));
logInfo("Control command registered.");
}
public void logInfo(String message) {
this.logger.info(message);
}
public void logWarning(String message) {
this.logger.warn(message);
}
public void logSevere(String message) {
this.logger.error(message);
}
public void postToChat(String message) {
TextComponentString cp = new TextComponentString("\u00a78[\u00a7cChatLog\u00a78] " + message);
this.mc.thePlayer.addChatComponentMessage(cp);
}
public void postSimple(String message) {
TextComponentString cp = new TextComponentString(message);
this.mc.thePlayer.addChatComponentMessage(cp);
}
}
/*
Copyright (C) 2014 Varden Development / Marius Lindvall / bilde2910
under the Varden Development Minecraft Mod License version 1.
The license has been attached below for convenience.
---------------------------------------------------------------------
TERMS AND CONDITIONS
0. USED TERMS
MOD - modification, plugin, a piece of software that interfaces with
the Minecraft client to extend, add, change or remove original
capabilities.
MOJANG - Mojang AB
OWNER - bilde2910, Marius Lindvall, Original author(s) of the MOD.
Under the copyright terms accepted when purchasing Minecraft
(https://minecraft.net/terms) the OWNER has full rights over their
MOD despite use of MOJANG code.
USER - End user of the mod, person installing the mod.
1. LIABILITY
THIS MOD IS PROVIDED 'AS IS' WITH NO WARRANTIES, IMPLIED OR
OTHERWISE. THE OWNER OF THIS MOD TAKES NO RESPONSIBILITY FOR ANY
DAMAGES INCURRED FROM THE USE OF THIS MOD. THIS MOD ALTERS
FUNDAMENTAL PARTS OF THE MINECRAFT GAME, PARTS OF MINECRAFT MAY NOT
WORK WITH THIS MOD INSTALLED. ALL DAMAGES CAUSED FROM THE USE OR
MISUSE OF THIS MOD FALL ON THE USER.
2. USE
Use of this MOD to be installed, manually or automatically, is given
to the USER without restriction.
3. REDISTRIBUTION
This MOD may only be distributed where uploaded, mirrored, or
otherwise linked to by the OWNER solely. All mirrors of this mod must
have advance written permission from the OWNER. ANY attempts to make
money off of this MOD (selling, selling modified versions, adfly,
sharecash, etc.) are STRICTLY FORBIDDEN, and the OWNER may claim
damages or take other action to rectify the situation.
4. DERIVATIVE WORKS/MODIFICATION
This mod is provided freely and may be decompiled and modified for
private use, either with a decompiler or a bytecode editor. Public
distribution of modified versions of this MOD require advance written
permission of the OWNER and may be subject to certain terms.
*/
package info.varden.chatlog;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import net.minecraftforge.client.event.ClientChatReceivedEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
public class ChatReceivedHandler {
private ChatLog cl;
public ChatReceivedHandler(ChatLog cl) {
this.cl = cl;
}
@SubscribeEvent
public void onChatMessageReceived(ClientChatReceivedEvent event) {
if (this.cl.configManager.props.getProperty("enabled", "true").equalsIgnoreCase("false")) {
return;
}
String message = event.getMessage().getFormattedText();
String noformat = message.replaceAll("\\xA7[A-Za-z0-9]", "");
String[] strs = new String[0];
try {
String propAF = URLDecoder.decode(this.cl.configManager.props.getProperty("filters", ""), "UTF-8");
strs = propAF.split("\0");
} catch (UnsupportedEncodingException e) {
}
boolean match = strs.length <= 1;
for (int i = 1; i < strs.length; i++) {
Pattern p = Pattern.compile(strs[i]);
Matcher m = p.matcher(noformat);
if (m.find()) {
match = true;
break;
}
}
if (match) {
this.cl.logs.write(message, (strs.length > 1 ? this.cl.util.getLogFlag("F") : ""));
}
}
}
This diff is collapsed.
/*
Copyright (C) 2014 Varden Development / Marius Lindvall / bilde2910
under the Varden Development Minecraft Mod License version 1.
The license has been attached below for convenience.
---------------------------------------------------------------------
TERMS AND CONDITIONS
0. USED TERMS
MOD - modification, plugin, a piece of software that interfaces with
the Minecraft client to extend, add, change or remove original
capabilities.
MOJANG - Mojang AB
OWNER - bilde2910, Marius Lindvall, Original author(s) of the MOD.
Under the copyright terms accepted when purchasing Minecraft
(https://minecraft.net/terms) the OWNER has full rights over their
MOD despite use of MOJANG code.
USER - End user of the mod, person installing the mod.
1. LIABILITY
THIS MOD IS PROVIDED 'AS IS' WITH NO WARRANTIES, IMPLIED OR
OTHERWISE. THE OWNER OF THIS MOD TAKES NO RESPONSIBILITY FOR ANY
DAMAGES INCURRED FROM THE USE OF THIS MOD. THIS MOD ALTERS
FUNDAMENTAL PARTS OF THE MINECRAFT GAME, PARTS OF MINECRAFT MAY NOT
WORK WITH THIS MOD INSTALLED. ALL DAMAGES CAUSED FROM THE USE OR
MISUSE OF THIS MOD FALL ON THE USER.
2. USE
Use of this MOD to be installed, manually or automatically, is given
to the USER without restriction.
3. REDISTRIBUTION
This MOD may only be distributed where uploaded, mirrored, or
otherwise linked to by the OWNER solely. All mirrors of this mod must
have advance written permission from the OWNER. ANY attempts to make
money off of this MOD (selling, selling modified versions, adfly,
sharecash, etc.) are STRICTLY FORBIDDEN, and the OWNER may claim
damages or take other action to rectify the situation.
4. DERIVATIVE WORKS/MODIFICATION
This mod is provided freely and may be decompiled and modified for
private use, either with a decompiler or a bytecode editor. Public
distribution of modified versions of this MOD require advance written
permission of the OWNER and may be subject to certain terms.
*/
package info.varden.chatlog;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Properties;
public class ConfigManager {
private static String PROPINFO = "Do not edit \"filters\" manually. Do this using filter commands. For more info, run '//cl filter?' in-game.";
private ChatLog cl;
public String[] properties = new String[4];
private boolean initialized = false;
public Properties props = null;
public boolean nospam = false;
public String tsFormat = "HH:mm:ss";
public ConfigManager(ChatLog cl) {
this.cl = cl;
}
public boolean isInitialized() {
return initialized;
}
private String[] genPropertiesFile(String configFileLocation, String[] propChatLog1)
{
this.cl.logInfo("Generating configuration file...");
Properties prop = new Properties();
String[] propChatLog = propChatLog1;
propChatLog[0] = "-1";
propChatLog[1] = "0";
propChatLog[2] = "HH:mm:ss";
propChatLog[3] = "false";
try
{
prop.setProperty("max_logs", propChatLog[0]);
prop.setProperty("color_pack", propChatLog[1]);
prop.setProperty("timestamp_format", propChatLog[2]);
prop.setProperty("collapse_repetitions", propChatLog[3]);
this.props = prop;
prop.store(new FileOutputStream(configFileLocation), PROPINFO);
this.cl.logInfo("Configuration file successfully generated.");
}
catch (IOException ex1)
{
ex1.printStackTrace();
this.cl.logSevere("FAILED TO GENERATE CONFIGURATION FILE: " + ex1.getMessage());
}
return propChatLog;
}
public void readPropertiesFile() {
Properties prop = new Properties();
try
{
File cfLoc = new File(Util.getConfigFilePath());
if (cfLoc.exists())
{
this.cl.logInfo("Reading configuration file...");
prop.load(new FileInputStream(Util.getConfigFilePath()));
properties[0] = prop.getProperty("max_logs", "-1");
properties[1] = prop.getProperty("color_pack", "0");
properties[2] = prop.getProperty("timestamp_format", "HH:mm:ss");
properties[3] = prop.getProperty("collapse_repetitions", "false");
prop.setProperty("max_logs", properties[0]);
prop.setProperty("color_pack", properties[1]);
prop.setProperty("timestamp_format", properties[2]);
prop.setProperty("collapse_repetitions", properties[3]);
props = prop;
nospam = properties[3].equalsIgnoreCase("true");
prop.store(new FileOutputStream(Util.getConfigFilePath()), PROPINFO);
}
else
{
this.cl.logInfo("Configuration file not found, generating a new one...");
properties = genPropertiesFile(Util.getConfigFilePath(), properties);
}
}
catch (IOException ex)
{
//Something has gone wrong, create a new properties file
ex.printStackTrace();
this.cl.logWarning("Configuration file corrupt or inaccessible! Generating a new one...");
properties = genPropertiesFile(Util.getConfigFilePath(), properties);
}
implementProperties();
}
public void savePropertiesFile() {
try {
this.props.store(new FileOutputStream(Util.getConfigFilePath()), PROPINFO);
} catch (IOException e) {
this.cl.logSevere("Failed to save properties file!");
e.printStackTrace();
}
}
private void implementProperties() {
this.cl.themes.setCurrentTheme(Integer.parseInt(properties[1]));
int maxFileCount = Integer.parseInt(properties[0]);
if (maxFileCount > -1) {
this.cl.logs.prune(maxFileCount);
}
initialized = true;
}
}
/*
Copyright (C) 2014 Varden Development / Marius Lindvall / bilde2910
under the Varden Development Minecraft Mod License version 1.
The license has been attached below for convenience.
---------------------------------------------------------------------
TERMS AND CONDITIONS
0. USED TERMS
MOD - modification, plugin, a piece of software that interfaces with
the Minecraft client to extend, add, change or remove original
capabilities.
MOJANG - Mojang AB
OWNER - bilde2910, Marius Lindvall, Original author(s) of the MOD.
Under the copyright terms accepted when purchasing Minecraft
(https://minecraft.net/terms) the OWNER has full rights over their
MOD despite use of MOJANG code.
USER - End user of the mod, person installing the mod.
1. LIABILITY
THIS MOD IS PROVIDED 'AS IS' WITH NO WARRANTIES, IMPLIED OR
OTHERWISE. THE OWNER OF THIS MOD TAKES NO RESPONSIBILITY FOR ANY
DAMAGES INCURRED FROM THE USE OF THIS MOD. THIS MOD ALTERS
FUNDAMENTAL PARTS OF THE MINECRAFT GAME, PARTS OF MINECRAFT MAY NOT
WORK WITH THIS MOD INSTALLED. ALL DAMAGES CAUSED FROM THE USE OR
MISUSE OF THIS MOD FALL ON THE USER.
2. USE
Use of this MOD to be installed, manually or automatically, is given
to the USER without restriction.
3. REDISTRIBUTION
This MOD may only be distributed where uploaded, mirrored, or
otherwise linked to by the OWNER solely. All mirrors of this mod must
have advance written permission from the OWNER. ANY attempts to make
money off of this MOD (selling, selling modified versions, adfly,
sharecash, etc.) are STRICTLY FORBIDDEN, and the OWNER may claim
damages or take other action to rectify the situation.
4. DERIVATIVE WORKS/MODIFICATION
This mod is provided freely and may be decompiled and modified for
private use, either with a decompiler or a bytecode editor. Public
distribution of modified versions of this MOD require advance written
permission of the OWNER and may be subject to certain terms.
*/
package info.varden.chatlog;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
public class HtmlConverter {
private ChatLog cl;
public HtmlConverter(ChatLog cl) {
this.cl = cl;
}
public String convert(String message, String flags) {
DateFormat dftime = null;
String curTime = null;
if (!this.cl.configManager.tsFormat.equals("null")) {
dftime = new SimpleDateFormat(this.cl.configManager.tsFormat);
curTime = dftime.format(new Date());
}
String prefix = "<code><span>" +
(flags.length() > 0 ? "<b>[" : "") +
(flags.contains("F") ? "<span style=\"color: red;\" title=\"Filtered message\">F</span>" : "") +
(flags.contains("S") ? "<span style=\"color: blue;\" title=\"Control message\">S</span>" : "") +
(flags.length() > 0 ? "]</b> " : "") +
(this.cl.configManager.tsFormat.equals("null") ? "" : "[" + curTime + "] ");
String suffix = "</span></code><br>\n";
String rPar1 = message.replace("<", "&lt;");
rPar1 = rPar1.replace(">", "&gt;");
if (cl.themes.getCurrentTheme() != 2) {
String theme[] = cl.themes.getTheme(cl.themes.getCurrentTheme());
rPar1 = rPar1.replaceAll("\\xA70", "</span><span style=\"color: #" + theme[0] + ";\">");
rPar1 = rPar1.replaceAll("\\xA71", "</span><span style=\"color: #" + theme[1] + ";\">");
rPar1 = rPar1.replaceAll("\\xA72", "</span><span style=\"color: #" + theme[2] + ";\">");
rPar1 = rPar1.replaceAll("\\xA73", "</span><span style=\"color: #" + theme[3] + ";\">");
rPar1 = rPar1.replaceAll("\\xA74", "</span><span style=\"color: #" + theme[4] + ";\">");
rPar1 = rPar1.replaceAll("\\xA75", "</span><span style=\"color: #" + theme[5] + ";\">");
rPar1 = rPar1.replaceAll("\\xA76", "</span><span style=\"color: #" + theme[6] + ";\">");
rPar1 = rPar1.replaceAll("\\xA77", "</span><span style=\"color: #" + theme[7] + ";\">");
rPar1 = rPar1.replaceAll("\\xA78", "</span><span style=\"color: #" + theme[8] + ";\">");
rPar1 = rPar1.replaceAll("\\xA79", "</span><span style=\"color: #" + theme[9] + ";\">");
rPar1 = rPar1.replaceAll("\\xA7a", "</span><span style=\"color: #" + theme[10] + ";\">");
rPar1 = rPar1.replaceAll("\\xA7b", "</span><span style=\"color: #" + theme[11] + ";\">");
rPar1 = rPar1.replaceAll("\\xA7c", "</span><span style=\"color: #" + theme[12] + ";\">");
rPar1 = rPar1.replaceAll("\\xA7d", "</span><span style=\"color: #" + theme[13] + ";\">");
rPar1 = rPar1.replaceAll("\\xA7e", "</span><span style=\"color: #" + theme[14] + ";\">");
rPar1 = rPar1.replaceAll("\\xA7f", "</span><span style=\"color: #" + theme[15] + ";\">");//is white, but use black to make it visible above background
rPar1 = rPar1.replaceAll("\\xA7A", "</span><span style=\"color: #" + theme[10] + ";\">");
rPar1 = rPar1.replaceAll("\\xA7B", "</span><span style=\"color: #" + theme[11] + ";\">");
rPar1 = rPar1.replaceAll("\\xA7C", "</span><span style=\"color: #" + theme[12] + ";\">");
rPar1 = rPar1.replaceAll("\\xA7D", "</span><span style=\"color: #" + theme[13] + ";\">");
rPar1 = rPar1.replaceAll("\\xA7E", "</span><span style=\"color: #" + theme[14] + ";\">");
rPar1 = rPar1.replaceAll("\\xA7F", "</span><span style=\"color: #" + theme[15] + ";\">");//is white, but use black to make it visible above background
rPar1 = rPar1.replaceAll("\\xA7k", "");
rPar1 = rPar1.replaceAll("\\xA7l", "");
rPar1 = rPar1.replaceAll("\\xA7m", "");
rPar1 = rPar1.replaceAll("\\xA7n", "");
rPar1 = rPar1.replaceAll("\\xA7o", "");
rPar1 = rPar1.replaceAll("\\xA7r", "</span><span>");
rPar1 = rPar1.replaceAll("\\xA7K", "");
rPar1 = rPar1.replaceAll("\\xA7L", "");
rPar1 = rPar1.replaceAll("\\xA7M", "");
rPar1 = rPar1.replaceAll("\\xA7N", "");
rPar1 = rPar1.replaceAll("\\xA7O", "");
rPar1 = rPar1.replaceAll("\\xA7R", "</span><span>");
}
return prefix + rPar1 + suffix;
}
}
/*
Copyright (C) 2014 Varden Development / Marius Lindvall / bilde2910
under the Varden Development Minecraft Mod License version 1.
The license has been attached below for convenience.
---------------------------------------------------------------------
TERMS AND CONDITIONS
0. USED TERMS
MOD - modification, plugin, a piece of software that interfaces with
the Minecraft client to extend, add, change or remove original
capabilities.
MOJANG - Mojang AB
OWNER - bilde2910, Marius Lindvall, Original author(s) of the MOD.
Under the copyright terms accepted when purchasing Minecraft
(https://minecraft.net/terms) the OWNER has full rights over their
MOD despite use of MOJANG code.
USER - End user of the mod, person installing the mod.
1. LIABILITY
THIS MOD IS PROVIDED 'AS IS' WITH NO WARRANTIES, IMPLIED OR
OTHERWISE. THE OWNER OF THIS MOD TAKES NO RESPONSIBILITY FOR ANY
DAMAGES INCURRED FROM THE USE OF THIS MOD. THIS MOD ALTERS
FUNDAMENTAL PARTS OF THE MINECRAFT GAME, PARTS OF MINECRAFT MAY NOT
WORK WITH THIS MOD INSTALLED. ALL DAMAGES CAUSED FROM THE USE OR
MISUSE OF THIS MOD FALL ON THE USER.
2. USE
Use of this MOD to be installed, manually or automatically, is given
to the USER without restriction.
3. REDISTRIBUTION
This MOD may only be distributed where uploaded, mirrored, or
otherwise linked to by the OWNER solely. All mirrors of this mod must
have advance written permission from the OWNER. ANY attempts to make
money off of this MOD (selling, selling modified versions, adfly,
sharecash, etc.) are STRICTLY FORBIDDEN, and the OWNER may claim
damages or take other action to rectify the situation.
4. DERIVATIVE WORKS/MODIFICATION
This mod is provided freely and may be decompiled and modified for
private use, either with a decompiler or a bytecode editor. Public
distribution of modified versions of this MOD require advance written
permission of the OWNER and may be subject to certain terms.
*/
package info.varden.chatlog;
import java.io.File;
import java.io.FilenameFilter;
public class LogFilenameFilter implements FilenameFilter {
@Override
public boolean accept(File dir, String filename) {
return filename.endsWith(".htm");
}
}
/*
Copyright (C) 2014 Varden Development / Marius Lindvall / bilde2910
under the Varden Development Minecraft Mod License version 1.
The license has been attached below for convenience.
---------------------------------------------------------------------
TERMS AND CONDITIONS
0. USED TERMS
MOD - modification, plugin, a piece of software that interfaces with
the Minecraft client to extend, add, change or remove original
capabilities.
MOJANG - Mojang AB
OWNER - bilde2910, Marius Lindvall, Original author(s) of the MOD.
Under the copyright terms accepted when purchasing Minecraft
(https://minecraft.net/terms) the OWNER has full rights over their
MOD despite use of MOJANG code.
USER - End user of the mod, person installing the mod.
1. LIABILITY
THIS MOD IS PROVIDED 'AS IS' WITH NO WARRANTIES, IMPLIED OR
OTHERWISE. THE OWNER OF THIS MOD TAKES NO RESPONSIBILITY FOR ANY
DAMAGES INCURRED FROM THE USE OF THIS MOD. THIS MOD ALTERS
FUNDAMENTAL PARTS OF THE MINECRAFT GAME, PARTS OF MINECRAFT MAY NOT
WORK WITH THIS MOD INSTALLED. ALL DAMAGES CAUSED FROM THE USE OR
MISUSE OF THIS MOD FALL ON THE USER.
2. USE
Use of this MOD to be installed, manually or automatically, is given
to the USER without restriction.
3. REDISTRIBUTION
This MOD may only be distributed where uploaded, mirrored, or
otherwise linked to by the OWNER solely. All mirrors of this mod must
have advance written permission from the OWNER. ANY attempts to make
money off of this MOD (selling, selling modified versions, adfly,
sharecash, etc.) are STRICTLY FORBIDDEN, and the OWNER may claim
damages or take other action to rectify the situation.
4. DERIVATIVE WORKS/MODIFICATION
This mod is provided freely and may be decompiled and modified for
private use, either with a decompiler or a bytecode editor. Public
distribution of modified versions of this MOD require advance written
permission of the OWNER and may be subject to certain terms.
*/
package info.varden.chatlog;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
public class Logs {
private final ChatLog cl;
private FileWriter fw = null;
private volatile boolean canWrite = false;
private String lastLine = null;
private int repetitions = 0;
public Logs(ChatLog cl) {
this.cl = cl;
}
public static File[] find(String dirName){
File dir = new File(dirName);
return dir.listFiles(new LogFilenameFilter());
}
public void prune(int maxCount) {
cl.logInfo("Clearing old logs...");
File[] storedLogs = find(Util.getChatLogFolderPath());
if (storedLogs.length > maxCount)
{
//Arrays.sort(storedLogs, NameFileComparator.NAME_INSENSITIVE_COMPARATOR);
int filesStoreAfter = storedLogs.length;
ArrayList<File> toBeDeleted = new ArrayList<File>(0);
ArrayList<File> allLists = new ArrayList<File>(Arrays.asList(storedLogs));
while (filesStoreAfter > maxCount)