Skip to content

Commit

Permalink
Cow using com.dumptruckman.minecraft:Logging for logging purposes.
Browse files Browse the repository at this point in the history
  • Loading branch information
dumptruckman committed Oct 20, 2012
1 parent 20ab321 commit 8f58000
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 37 deletions.
40 changes: 40 additions & 0 deletions pom.xml
Expand Up @@ -115,6 +115,37 @@
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<artifactSet>
<includes>
<include>com.dumptruckman.minecraft:Logging</include>
</includes>
</artifactSet>
<relocations>
<relocation>
<pattern>com.dumptruckman.minecraft.util.Logging</pattern>
<shadedPattern>com.onarandombox.MultiversePortals.util.MVPLogging
</shadedPattern>
</relocation>
<relocation>
<pattern>com.dumptruckman.minecraft.util.DebugLog</pattern>
<shadedPattern>com.onarandombox.MultiverseCore.utils.DebugFileLogger</shadedPattern>
</relocation>
</relocations>
</configuration>
</execution>
</executions>
</plugin>
</plugins> </plugins>
</build> </build>
<dependencies> <dependencies>
Expand All @@ -127,6 +158,15 @@
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<!-- End of Multiverse Core Dependency --> <!-- End of Multiverse Core Dependency -->
<!-- Start of Logging Dependency -->
<dependency>
<groupId>com.dumptruckman.minecraft</groupId>
<artifactId>Logging</artifactId>
<version>1.0.6</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<!-- End of Logging Dependency -->
</dependencies> </dependencies>
<distributionManagement> <distributionManagement>
<repository> <repository>
Expand Down
Expand Up @@ -7,9 +7,9 @@


package com.onarandombox.MultiverseSignPortals; package com.onarandombox.MultiverseSignPortals;


import com.dumptruckman.minecraft.util.Logging;
import com.onarandombox.MultiverseCore.MultiverseCore; import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MVPlugin; import com.onarandombox.MultiverseCore.api.MVPlugin;
import com.onarandombox.MultiverseCore.utils.DebugLog;
import com.onarandombox.MultiverseSignPortals.listeners.MVSPBlockListener; import com.onarandombox.MultiverseSignPortals.listeners.MVSPBlockListener;
import com.onarandombox.MultiverseSignPortals.listeners.MVSPPlayerListener; import com.onarandombox.MultiverseSignPortals.listeners.MVSPPlayerListener;
import com.onarandombox.MultiverseSignPortals.listeners.MVSPPluginListener; import com.onarandombox.MultiverseSignPortals.listeners.MVSPPluginListener;
Expand All @@ -18,15 +18,10 @@
import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;


import java.io.File;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger;


public class MultiverseSignPortals extends JavaPlugin implements MVPlugin { public class MultiverseSignPortals extends JavaPlugin implements MVPlugin {


public static final Logger log = Logger.getLogger("Minecraft");
public static final String logPrefix = "[Multiverse-SignPortals] ";
protected static DebugLog debugLog;
protected MultiverseCore core; protected MultiverseCore core;
protected MVSPPlayerListener playerListener; protected MVSPPlayerListener playerListener;
protected MVSPPluginListener pluginListener; protected MVSPPluginListener pluginListener;
Expand All @@ -39,20 +34,19 @@ public void onEnable() {
this.core = (MultiverseCore) getServer().getPluginManager().getPlugin("Multiverse-Core"); this.core = (MultiverseCore) getServer().getPluginManager().getPlugin("Multiverse-Core");
// Test if the Core was found, if not we'll disable this plugin. // Test if the Core was found, if not we'll disable this plugin.
if (this.core == null) { if (this.core == null) {
log.info(logPrefix + "Multiverse-Core not found, will keep looking."); Logging.info("Multiverse-Core not found, will keep looking.");
getServer().getPluginManager().disablePlugin(this); getServer().getPluginManager().disablePlugin(this);
return; return;
} }
if (this.core.getProtocolVersion() < requiresProtocol) { if (this.core.getProtocolVersion() < requiresProtocol) {
log.severe(logPrefix + "Your Multiverse-Core is OUT OF DATE"); Logging.severe("Your Multiverse-Core is OUT OF DATE");
log.severe(logPrefix + "This version of SignPortals requires Protocol Level: " + requiresProtocol); Logging.severe("This version of SignPortals requires Protocol Level: " + requiresProtocol);
log.severe(logPrefix + "Your of Core Protocol Level is: " + this.core.getProtocolVersion()); Logging.severe("Your of Core Protocol Level is: " + this.core.getProtocolVersion());
log.severe(logPrefix + "Grab an updated copy at: "); Logging.severe("Grab an updated copy at: ");
log.severe(logPrefix + "http://bukkit.onarandombox.com/?dir=multiverse-core"); Logging.severe("http://bukkit.onarandombox.com/?dir=multiverse-core");
getServer().getPluginManager().disablePlugin(this); getServer().getPluginManager().disablePlugin(this);
return; return;
} }
debugLog = new DebugLog("Multiverse-SignPortals", getDataFolder() + File.separator + "debug.log");


this.core.incrementPluginCount(); this.core.incrementPluginCount();


Expand All @@ -70,18 +64,18 @@ public void onEnable() {


this.portalDetector = new PortalDetector(this); this.portalDetector = new PortalDetector(this);


log.info(logPrefix + "- Version " + this.getDescription().getVersion() + " Enabled - By " + getAuthors()); Logging.log(true, Level.INFO, " Enabled - By %s", getAuthors());
} }


public void onDisable() { public void onDisable() {
// The Usual // The Usual
log.info(logPrefix + "- Disabled"); Logging.info("- Disabled");
} }


/** This fires before I get Enabled. */ /** This fires before I get Enabled. */
public void onLoad() { public void onLoad() {
Logging.init(this);
this.getDataFolder().mkdirs(); this.getDataFolder().mkdirs();
debugLog = new DebugLog("Multiverse-SignPortals", getDataFolder() + File.separator + "debug.log");
} }


/** /**
Expand All @@ -103,25 +97,7 @@ private String getAuthors() {


@Override @Override
public void log(Level level, String msg) { public void log(Level level, String msg) {
if (level == Level.FINE && MultiverseCore.getStaticConfig().getGlobalDebug() >= 1) { Logging.log(level, msg);
staticDebugLog(Level.INFO, msg);
} else if (level == Level.FINER && MultiverseCore.getStaticConfig().getGlobalDebug() >= 2) {
staticDebugLog(Level.INFO, msg);
} else if (level == Level.FINEST && MultiverseCore.getStaticConfig().getGlobalDebug() >= 3) {
staticDebugLog(Level.INFO, msg);
} else if (level != Level.FINE && level != Level.FINER && level != Level.FINEST) {
staticLog(level, msg);
}
}

private void staticLog(Level level, String msg) {
log.log(level, logPrefix + " " + msg);
debugLog.log(level, logPrefix + " " + msg);
}

private void staticDebugLog(Level level, String msg) {
log.log(level, "[MVSignPortals-Debug] " + msg);
debugLog.log(level, "[MVSignPortals-Debug] " + msg);
} }


// No longer using, use getVersionInfo instead. // No longer using, use getVersionInfo instead.
Expand All @@ -133,14 +109,14 @@ public String dumpVersionInfo(String buffer) {
} }


public String getVersionInfo() { public String getVersionInfo() {
return new StringBuffer("[Multiverse-SignPortals] Multiverse-SignPortals Version: ").append(this.getDescription().getVersion()).append('\n').toString(); return new StringBuilder("[Multiverse-SignPortals] Multiverse-SignPortals Version: ").append(this.getDescription().getVersion()).append('\n').toString();
} }


// No longer using, use getVersionInfo instead. // No longer using, use getVersionInfo instead.
@Deprecated @Deprecated
private String logAndAddToPasteBinBuffer(String string) { private String logAndAddToPasteBinBuffer(String string) {
this.log(Level.INFO, string); this.log(Level.INFO, string);
return logPrefix + string + "\n"; return Logging.getPrefixedMessage(string, false);
} }


@Override @Override
Expand Down

0 comments on commit 8f58000

Please sign in to comment.