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.dumptruckman.minecraft:buscript</include>
<include>org.mcstats:metrics</include>
<include>com.dumptruckman.minecraft:Logging</include>
</includes>
</artifactSet>
<relocations>
@ -202,6 +203,10 @@
<pattern>org.mcstats</pattern>
<shadedPattern>org.mcstats.multiverse</shadedPattern>
</relocation>
<relocation>
<pattern>com.dumptruckman.minecraft.util.Logging</pattern>
<shadedPattern>com.onarandombox.MultiverseCore.utils.CoreLogging</shadedPattern>
</relocation>
</relocations>
</configuration>
</execution>
@ -274,6 +279,15 @@
<scope>compile</scope>
</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 -->
<dependency>
<groupId>junit</groupId>

View File

@ -8,6 +8,7 @@
package com.onarandombox.MultiverseCore;
import buscript.Buscript;
import com.dumptruckman.minecraft.util.Logging;
import com.fernferret.allpay.AllPay;
import com.fernferret.allpay.GenericBank;
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.MVWeatherListener;
import com.onarandombox.MultiverseCore.utils.AnchorManager;
import com.onarandombox.MultiverseCore.utils.DebugLog;
import com.onarandombox.MultiverseCore.utils.MVMessaging;
import com.onarandombox.MultiverseCore.utils.MVPermissions;
import com.onarandombox.MultiverseCore.utils.MVPlayerSession;
@ -105,7 +105,6 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* 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.
*/
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);
}
@ -177,10 +176,6 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
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.
private CommandHandler commandHandler;
@ -226,9 +221,8 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
// Create our DataFolder
getDataFolder().mkdirs();
// Setup our Debug Log
debugLog = new DebugLog("Multiverse-Core", getDataFolder() + File.separator + "debug.log");
debugLog.setStandardLogger(LOGGER);
SerializationConfig.initLogging(debugLog);
Logging.init(this);
SerializationConfig.initLogging(Logging.getLogger());
// Setup our BlockSafety
this.blockSafety = new SimpleBlockSafety(this);
// Setup our LocationManipulation
@ -806,7 +800,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
@Override
public void onDisable() {
this.saveMVConfigs();
debugLog.close();
Logging.close();
this.banker = null;
this.bank = null;
log(Level.INFO, "- Disabled");
@ -873,7 +867,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
*/
@Override
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 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) {
if (level == Level.FINE && MultiverseCoreConfiguration.getInstance().getGlobalDebug() >= 1) {
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);
}
Logging.log(level, msg, false);
}
/**
* 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.
*
* @param level The Log-{@link Level}
* @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) {
debugLog.log(level, msg);
Logging.log(level, msg, false);
}
/**

View File

@ -7,6 +7,7 @@
package com.onarandombox.MultiverseCore.listeners;
import com.dumptruckman.minecraft.util.Logging;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MVWorldManager;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
@ -318,16 +319,12 @@ public class MVPlayerListener implements Listener {
public void run() {
// 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()) {
MultiverseCore.staticLog(Level.FINE, "Handling gamemode for player: "
+ player.getName() + ", Changing to " + world.getGameMode().toString());
MultiverseCore.staticLog(Level.FINEST, "From World: " + player.getWorld());
MultiverseCore.staticLog(Level.FINEST, "To World: " + world);
Logging.fine("Handling gamemode for player: %s, Changing to %s", player.getName(), world.getGameMode().toString());
Logging.finest("From World: %s", player.getWorld());
Logging.finest("To World: %s", world);
player.setGameMode(world.getGameMode());
} else {
MultiverseCore.staticLog(Level.FINE, "The gamemode was NOT changed for player '"
+ player.getName() + "' because he is now in world '"
+ player.getWorld().getName() + "' instead of world '"
+ world.getName() +"'");
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());
}
}
}, 1L);

View File

@ -7,6 +7,7 @@
package com.onarandombox.MultiverseCore.utils;
import com.dumptruckman.minecraft.util.Logging;
import com.onarandombox.MultiverseCore.MultiverseCore;
import org.bukkit.Location;
import org.bukkit.configuration.ConfigurationSection;
@ -16,7 +17,6 @@ import org.bukkit.entity.Player;
import java.io.File;
import java.io.IOException;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
@ -50,10 +50,10 @@ public class AnchorManager {
//world:x,y,z:pitch:yaw
Location anchorLocation = plugin.getLocationManipulation().stringToLocation(anchorsSection.getString(key, ""));
if (anchorLocation != null) {
MultiverseCore.staticLog(Level.INFO, "Loading anchor: '" + key + "'...");
Logging.info("Loading anchor: '%s'...", key);
this.anchors.put(key, anchorLocation);
} 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;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.dumptruckman.minecraft.util.Logging;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.entity.Minecart;
import org.bukkit.entity.Vehicle;
import java.util.logging.Level;
/**
* Used to determine block/location-related facts.
*
@ -75,28 +73,28 @@ public class BlockSafety {
if (this.isSolidBlock(world.getBlockAt(actual).getType())
|| this.isSolidBlock(upOne.getBlock().getType())) {
MultiverseCore.staticLog(Level.FINER, "Error Here (Actual)? ("
+ actual.getBlock().getType() + ")[" + this.isSolidBlock(actual.getBlock().getType()) + "]");
MultiverseCore.staticLog(Level.FINER, "Error Here (upOne)? ("
+ upOne.getBlock().getType() + ")[" + this.isSolidBlock(upOne.getBlock().getType()) + "]");
Logging.finer("Error Here (Actual)? (%s)[%s]", actual.getBlock().getType(),
this.isSolidBlock(actual.getBlock().getType()));
Logging.finer("Error Here (upOne)? (%s)[%s]", upOne.getBlock().getType(),
this.isSolidBlock(upOne.getBlock().getType()));
return false;
}
if (downOne.getBlock().getType() == Material.LAVA || downOne.getBlock().getType() == Material.STATIONARY_LAVA) {
MultiverseCore.staticLog(Level.FINER, "Error Here (downOne)? ("
+ downOne.getBlock().getType() + ")[" + this.isSolidBlock(downOne.getBlock().getType()) + "]");
Logging.finer("Error Here (downOne)? (%s)[%s]", downOne.getBlock().getType(),
this.isSolidBlock(downOne.getBlock().getType()));
return false;
}
if (downOne.getBlock().getType() == Material.FIRE) {
MultiverseCore.staticLog(Level.FINER, "There's fire below! ("
+ actual.getBlock().getType() + ")[" + this.isSolidBlock(actual.getBlock().getType()) + "]");
Logging.finer("There's fire below! (%s)[%s]", actual.getBlock().getType(),
this.isSolidBlock(actual.getBlock().getType()));
return false;
}
if (isBlockAboveAir(actual)) {
MultiverseCore.staticLog(Level.FINER, "Is block above air [" + isBlockAboveAir(actual) + "]");
MultiverseCore.staticLog(Level.FINER, "Has 2 blocks of water below [" + this.hasTwoBlocksofWaterBelow(actual) + "]");
Logging.finer("Is block above air [%s]", isBlockAboveAir(actual));
Logging.finer("Has 2 blocks of water below [%s]", this.hasTwoBlocksofWaterBelow(actual));
return this.hasTwoBlocksofWaterBelow(actual);
}
return true;

View File

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