replaced logging with com.dumptruckman.minecraft:Logging lib.

This commit is contained in:
Jeremy Wood 2012-10-17 14:23:00 -04:00
parent 0437a4bd92
commit d7535b0551
6 changed files with 59 additions and 63 deletions

14
pom.xml
View File

@ -179,6 +179,7 @@
<include>com.pneumaticraft.commandhandler:CommandHandler</include> <include>com.pneumaticraft.commandhandler:CommandHandler</include>
<include>com.dumptruckman.minecraft:buscript</include> <include>com.dumptruckman.minecraft:buscript</include>
<include>org.mcstats:metrics</include> <include>org.mcstats:metrics</include>
<include>com.dumptruckman.minecraft:Logging</include>
</includes> </includes>
</artifactSet> </artifactSet>
<relocations> <relocations>
@ -202,6 +203,10 @@
<pattern>org.mcstats</pattern> <pattern>org.mcstats</pattern>
<shadedPattern>org.mcstats.multiverse</shadedPattern> <shadedPattern>org.mcstats.multiverse</shadedPattern>
</relocation> </relocation>
<relocation>
<pattern>com.dumptruckman.minecraft.util.Logging</pattern>
<shadedPattern>com.onarandombox.MultiverseCore.utils.CoreLogging</shadedPattern>
</relocation>
</relocations> </relocations>
</configuration> </configuration>
</execution> </execution>
@ -274,6 +279,15 @@
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<!-- End of Metrics Dependency --> <!-- End of Metrics Dependency -->
<!-- Start of Logging Dependency -->
<dependency>
<groupId>com.dumptruckman.minecraft</groupId>
<artifactId>Logging</artifactId>
<version>1.0.1</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<!-- End of Logging Dependency -->
<!-- Start of Test Dependencies --> <!-- Start of Test Dependencies -->
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>

View File

@ -8,6 +8,7 @@
package com.onarandombox.MultiverseCore; package com.onarandombox.MultiverseCore;
import buscript.Buscript; import buscript.Buscript;
import com.dumptruckman.minecraft.util.Logging;
import com.fernferret.allpay.AllPay; import com.fernferret.allpay.AllPay;
import com.fernferret.allpay.GenericBank; import com.fernferret.allpay.GenericBank;
import com.onarandombox.MultiverseCore.api.BlockSafety; import com.onarandombox.MultiverseCore.api.BlockSafety;
@ -69,7 +70,6 @@ import com.onarandombox.MultiverseCore.listeners.MVPluginListener;
import com.onarandombox.MultiverseCore.listeners.MVPortalListener; import com.onarandombox.MultiverseCore.listeners.MVPortalListener;
import com.onarandombox.MultiverseCore.listeners.MVWeatherListener; import com.onarandombox.MultiverseCore.listeners.MVWeatherListener;
import com.onarandombox.MultiverseCore.utils.AnchorManager; import com.onarandombox.MultiverseCore.utils.AnchorManager;
import com.onarandombox.MultiverseCore.utils.DebugLog;
import com.onarandombox.MultiverseCore.utils.MVMessaging; import com.onarandombox.MultiverseCore.utils.MVMessaging;
import com.onarandombox.MultiverseCore.utils.MVPermissions; import com.onarandombox.MultiverseCore.utils.MVPermissions;
import com.onarandombox.MultiverseCore.utils.MVPlayerSession; import com.onarandombox.MultiverseCore.utils.MVPlayerSession;
@ -105,7 +105,6 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger;
/** /**
* The implementation of the Multiverse-{@link Core}. * The implementation of the Multiverse-{@link Core}.
@ -141,7 +140,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
* @param teleportee The name of the player that was teleported. * @param teleportee The name of the player that was teleported.
*/ */
public static void addPlayerToTeleportQueue(String teleporter, String teleportee) { public static void addPlayerToTeleportQueue(String teleporter, String teleportee) {
staticLog(Level.FINEST, "Adding mapping '" + teleporter + "' => '" + teleportee + "' to teleport queue"); Logging.finest( "Adding mapping '%s' => '%s' to teleport queue", teleporter, teleportee);
teleportQueue.put(teleportee, teleporter); teleportQueue.put(teleportee, teleporter);
} }
@ -177,10 +176,6 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
return MultiverseCore.PROTOCOL; return MultiverseCore.PROTOCOL;
} }
// Useless stuff to keep us going.
private static final Logger LOGGER = Logger.getLogger("Minecraft");
private static DebugLog debugLog;
// Setup our Map for our Commands using the CommandHandler. // Setup our Map for our Commands using the CommandHandler.
private CommandHandler commandHandler; private CommandHandler commandHandler;
@ -226,9 +221,8 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
// Create our DataFolder // Create our DataFolder
getDataFolder().mkdirs(); getDataFolder().mkdirs();
// Setup our Debug Log // Setup our Debug Log
debugLog = new DebugLog("Multiverse-Core", getDataFolder() + File.separator + "debug.log"); Logging.init(this);
debugLog.setStandardLogger(LOGGER); SerializationConfig.initLogging(Logging.getLogger());
SerializationConfig.initLogging(debugLog);
// Setup our BlockSafety // Setup our BlockSafety
this.blockSafety = new SimpleBlockSafety(this); this.blockSafety = new SimpleBlockSafety(this);
// Setup our LocationManipulation // Setup our LocationManipulation
@ -806,7 +800,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
@Override @Override
public void onDisable() { public void onDisable() {
this.saveMVConfigs(); this.saveMVConfigs();
debugLog.close(); Logging.close();
this.banker = null; this.banker = null;
this.bank = null; this.bank = null;
log(Level.INFO, "- Disabled"); log(Level.INFO, "- Disabled");
@ -873,7 +867,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
*/ */
@Override @Override
public void log(Level level, String msg) { public void log(Level level, String msg) {
staticLog(level, msg); Logging.log(level, msg, false);
} }
/** /**
@ -881,30 +875,28 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
* *
* @param level The Log-{@link Level}. * @param level The Log-{@link Level}.
* @param msg The message to log. * @param msg The message to log.
*
* @deprecated Replaced by {@link Logging}. Please refrain from using this from a third party plugin as the
* messages will appear to originate from Multiverse-Core.
*/ */
@Deprecated
public static void staticLog(Level level, String msg) { public static void staticLog(Level level, String msg) {
if (level == Level.FINE && MultiverseCoreConfiguration.getInstance().getGlobalDebug() >= 1) { Logging.log(level, msg, false);
staticDebugLog(level, msg);
} else if (level == Level.FINER && MultiverseCoreConfiguration.getInstance().getGlobalDebug() >= 2) {
staticDebugLog(level, msg);
} else if (level == Level.FINEST && MultiverseCoreConfiguration.getInstance().getGlobalDebug() >= 3) {
staticDebugLog(level, msg);
} else if (level != Level.FINE && level != Level.FINER && level != Level.FINEST) {
String message = LOG_TAG + " " + msg;
LOGGER.log(level, message);
debugLog.log(level, message);
}
} }
/** /**
* Print messages to the Debug Log, if the servers in Debug Mode then we also wan't to print the messages to the * Print messages to the Debug Log, if the servers in Debug Mode then we also want to print the messages to the
* standard Server Console. * standard Server Console.
* *
* @param level The Log-{@link Level} * @param level The Log-{@link Level}
* @param msg The message * @param msg The message
*
* @deprecated Replaced by {@link Logging}. Please refrain from using this from a third party plugin as the
* messages will appear to originate from Multiverse-Core.
*/ */
@Deprecated
public static void staticDebugLog(Level level, String msg) { public static void staticDebugLog(Level level, String msg) {
debugLog.log(level, msg); Logging.log(level, msg, false);
} }
/** /**

View File

@ -7,6 +7,7 @@
package com.onarandombox.MultiverseCore.listeners; package com.onarandombox.MultiverseCore.listeners;
import com.dumptruckman.minecraft.util.Logging;
import com.onarandombox.MultiverseCore.MultiverseCore; import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MVWorldManager; import com.onarandombox.MultiverseCore.api.MVWorldManager;
import com.onarandombox.MultiverseCore.api.MultiverseWorld; import com.onarandombox.MultiverseCore.api.MultiverseWorld;
@ -318,16 +319,12 @@ public class MVPlayerListener implements Listener {
public void run() { public void run() {
// Check that the player is in the new world and they haven't been teleported elsewhere or the event cancelled. // Check that the player is in the new world and they haven't been teleported elsewhere or the event cancelled.
if (player.getWorld() == world.getCBWorld()) { if (player.getWorld() == world.getCBWorld()) {
MultiverseCore.staticLog(Level.FINE, "Handling gamemode for player: " Logging.fine("Handling gamemode for player: %s, Changing to %s", player.getName(), world.getGameMode().toString());
+ player.getName() + ", Changing to " + world.getGameMode().toString()); Logging.finest("From World: %s", player.getWorld());
MultiverseCore.staticLog(Level.FINEST, "From World: " + player.getWorld()); Logging.finest("To World: %s", world);
MultiverseCore.staticLog(Level.FINEST, "To World: " + world);
player.setGameMode(world.getGameMode()); player.setGameMode(world.getGameMode());
} else { } else {
MultiverseCore.staticLog(Level.FINE, "The gamemode was NOT changed for player '" Logging.fine("The gamemode was NOT changed for player '%s' because he is now in world '%s' instead of world '%s'", player.getName(), player.getWorld().getName(), world.getName());
+ player.getName() + "' because he is now in world '"
+ player.getWorld().getName() + "' instead of world '"
+ world.getName() +"'");
} }
} }
}, 1L); }, 1L);

View File

@ -7,6 +7,7 @@
package com.onarandombox.MultiverseCore.utils; package com.onarandombox.MultiverseCore.utils;
import com.dumptruckman.minecraft.util.Logging;
import com.onarandombox.MultiverseCore.MultiverseCore; import com.onarandombox.MultiverseCore.MultiverseCore;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
@ -16,7 +17,6 @@ import org.bukkit.entity.Player;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
@ -50,10 +50,10 @@ public class AnchorManager {
//world:x,y,z:pitch:yaw //world:x,y,z:pitch:yaw
Location anchorLocation = plugin.getLocationManipulation().stringToLocation(anchorsSection.getString(key, "")); Location anchorLocation = plugin.getLocationManipulation().stringToLocation(anchorsSection.getString(key, ""));
if (anchorLocation != null) { if (anchorLocation != null) {
MultiverseCore.staticLog(Level.INFO, "Loading anchor: '" + key + "'..."); Logging.info("Loading anchor: '%s'...", key);
this.anchors.put(key, anchorLocation); this.anchors.put(key, anchorLocation);
} else { } else {
MultiverseCore.staticLog(Level.WARNING, "The location for anchor '" + key + "' is INVALID."); Logging.warning("The location for anchor '%s' is INVALID.", key);
} }
} }

View File

@ -7,15 +7,13 @@
package com.onarandombox.MultiverseCore.utils; package com.onarandombox.MultiverseCore.utils;
import com.onarandombox.MultiverseCore.MultiverseCore; import com.dumptruckman.minecraft.util.Logging;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.entity.Minecart; import org.bukkit.entity.Minecart;
import org.bukkit.entity.Vehicle; import org.bukkit.entity.Vehicle;
import java.util.logging.Level;
/** /**
* Used to determine block/location-related facts. * Used to determine block/location-related facts.
* *
@ -75,28 +73,28 @@ public class BlockSafety {
if (this.isSolidBlock(world.getBlockAt(actual).getType()) if (this.isSolidBlock(world.getBlockAt(actual).getType())
|| this.isSolidBlock(upOne.getBlock().getType())) { || this.isSolidBlock(upOne.getBlock().getType())) {
MultiverseCore.staticLog(Level.FINER, "Error Here (Actual)? (" Logging.finer("Error Here (Actual)? (%s)[%s]", actual.getBlock().getType(),
+ actual.getBlock().getType() + ")[" + this.isSolidBlock(actual.getBlock().getType()) + "]"); this.isSolidBlock(actual.getBlock().getType()));
MultiverseCore.staticLog(Level.FINER, "Error Here (upOne)? (" Logging.finer("Error Here (upOne)? (%s)[%s]", upOne.getBlock().getType(),
+ upOne.getBlock().getType() + ")[" + this.isSolidBlock(upOne.getBlock().getType()) + "]"); this.isSolidBlock(upOne.getBlock().getType()));
return false; return false;
} }
if (downOne.getBlock().getType() == Material.LAVA || downOne.getBlock().getType() == Material.STATIONARY_LAVA) { if (downOne.getBlock().getType() == Material.LAVA || downOne.getBlock().getType() == Material.STATIONARY_LAVA) {
MultiverseCore.staticLog(Level.FINER, "Error Here (downOne)? (" Logging.finer("Error Here (downOne)? (%s)[%s]", downOne.getBlock().getType(),
+ downOne.getBlock().getType() + ")[" + this.isSolidBlock(downOne.getBlock().getType()) + "]"); this.isSolidBlock(downOne.getBlock().getType()));
return false; return false;
} }
if (downOne.getBlock().getType() == Material.FIRE) { if (downOne.getBlock().getType() == Material.FIRE) {
MultiverseCore.staticLog(Level.FINER, "There's fire below! (" Logging.finer("There's fire below! (%s)[%s]", actual.getBlock().getType(),
+ actual.getBlock().getType() + ")[" + this.isSolidBlock(actual.getBlock().getType()) + "]"); this.isSolidBlock(actual.getBlock().getType()));
return false; return false;
} }
if (isBlockAboveAir(actual)) { if (isBlockAboveAir(actual)) {
MultiverseCore.staticLog(Level.FINER, "Is block above air [" + isBlockAboveAir(actual) + "]"); Logging.finer("Is block above air [%s]", isBlockAboveAir(actual));
MultiverseCore.staticLog(Level.FINER, "Has 2 blocks of water below [" + this.hasTwoBlocksofWaterBelow(actual) + "]"); Logging.finer("Has 2 blocks of water below [%s]", this.hasTwoBlocksofWaterBelow(actual));
return this.hasTwoBlocksofWaterBelow(actual); return this.hasTwoBlocksofWaterBelow(actual);
} }
return true; return true;

View File

@ -7,18 +7,15 @@
package com.onarandombox.MultiverseCore.utils; package com.onarandombox.MultiverseCore.utils;
import com.onarandombox.MultiverseCore.MultiverseCore; import com.dumptruckman.minecraft.util.Logging;
import com.onarandombox.MultiverseCore.api.BlockSafety; import com.onarandombox.MultiverseCore.api.BlockSafety;
import com.onarandombox.MultiverseCore.api.Core; import com.onarandombox.MultiverseCore.api.Core;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.entity.Minecart; import org.bukkit.entity.Minecart;
import org.bukkit.entity.Vehicle; import org.bukkit.entity.Vehicle;
import java.util.logging.Level;
/** /**
* The default-implementation of {@link BlockSafety}. * The default-implementation of {@link BlockSafety}.
*/ */
@ -67,28 +64,26 @@ public class SimpleBlockSafety implements BlockSafety {
if (isSolidBlock(world.getBlockAt(actual).getType()) if (isSolidBlock(world.getBlockAt(actual).getType())
|| isSolidBlock(upOne.getBlock().getType())) { || isSolidBlock(upOne.getBlock().getType())) {
MultiverseCore.staticLog(Level.FINER, "Error Here (Actual)? (" Logging.finer("Error Here (Actual)? (%s)[%s]", actual.getBlock().getType(),
+ actual.getBlock().getType() + ")[" + isSolidBlock(actual.getBlock().getType()) + "]"); isSolidBlock(actual.getBlock().getType()));
MultiverseCore.staticLog(Level.FINER, "Error Here (upOne)? (" Logging.finer("Error Here (upOne)? (%s)[%s]", upOne.getBlock().getType(),
+ upOne.getBlock().getType() + ")[" + isSolidBlock(upOne.getBlock().getType()) + "]"); isSolidBlock(upOne.getBlock().getType()));
return false; return false;
} }
if (downOne.getBlock().getType() == Material.LAVA || downOne.getBlock().getType() == Material.STATIONARY_LAVA) { if (downOne.getBlock().getType() == Material.LAVA || downOne.getBlock().getType() == Material.STATIONARY_LAVA) {
MultiverseCore.staticLog(Level.FINER, "Error Here (downOne)? (" Logging.finer("Error Here (downOne)? (%s)[%s]", downOne.getBlock().getType(), isSolidBlock(downOne.getBlock().getType()));
+ downOne.getBlock().getType() + ")[" + isSolidBlock(downOne.getBlock().getType()) + "]");
return false; return false;
} }
if (downOne.getBlock().getType() == Material.FIRE) { if (downOne.getBlock().getType() == Material.FIRE) {
MultiverseCore.staticLog(Level.FINER, "There's fire below! (" Logging.finer("There's fire below! (%s)[%s]", actual.getBlock().getType(), isSolidBlock(actual.getBlock().getType()));
+ actual.getBlock().getType() + ")[" + isSolidBlock(actual.getBlock().getType()) + "]");
return false; return false;
} }
if (isBlockAboveAir(actual)) { if (isBlockAboveAir(actual)) {
MultiverseCore.staticLog(Level.FINER, "Is block above air [" + isBlockAboveAir(actual) + "]"); Logging.finer("Is block above air [%s]", isBlockAboveAir(actual));
MultiverseCore.staticLog(Level.FINER, "Has 2 blocks of water below [" + this.hasTwoBlocksofWaterBelow(actual) + "]"); Logging.finer("Has 2 blocks of water below [%s]", this.hasTwoBlocksofWaterBelow(actual));
return this.hasTwoBlocksofWaterBelow(actual); return this.hasTwoBlocksofWaterBelow(actual);
} }
return true; return true;