Merge pull request #2505 from benwoo1110/logging

Update to all use static logging.
This commit is contained in:
nicegamer7 2020-12-12 09:58:19 -05:00 committed by GitHub
commit 540394e266
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 125 additions and 106 deletions

View File

@ -214,7 +214,7 @@ public class MVWorld implements MultiverseWorld {
public Double validateChange(String property, Double newValue, Double oldValue, public Double validateChange(String property, Double newValue, Double oldValue,
MVWorld object) throws ChangeDeniedException { MVWorld object) throws ChangeDeniedException {
if (newValue <= 0) { if (newValue <= 0) {
plugin.log(Level.FINE, "Someone tried to set a scale <= 0, aborting!"); Logging.fine("Someone tried to set a scale <= 0, aborting!");
throw new ChangeDeniedException(); throw new ChangeDeniedException();
} }
return super.validateChange(property, newValue, oldValue, object); return super.validateChange(property, newValue, oldValue, object);
@ -297,7 +297,7 @@ public class MVWorld implements MultiverseWorld {
public GameMode validateChange(String property, GameMode newValue, GameMode oldValue, public GameMode validateChange(String property, GameMode newValue, GameMode oldValue,
MVWorld object) throws ChangeDeniedException { MVWorld object) throws ChangeDeniedException {
for (Player p : plugin.getServer().getWorld(getName()).getPlayers()) { for (Player p : plugin.getServer().getWorld(getName()).getPlayers()) {
plugin.log(Level.FINER, String.format("Setting %s's GameMode to %s", Logging.finer(String.format("Setting %s's GameMode to %s",
p.getName(), newValue.toString())); p.getName(), newValue.toString()));
plugin.getPlayerListener().handleGameModeAndFlight(p, MVWorld.this); plugin.getPlayerListener().handleGameModeAndFlight(p, MVWorld.this);
} }
@ -319,16 +319,16 @@ public class MVWorld implements MultiverseWorld {
// verify that the location is safe // verify that the location is safe
if (!bs.playerCanSpawnHereSafely(newValue)) { if (!bs.playerCanSpawnHereSafely(newValue)) {
// it's not ==> find a better one! // it's not ==> find a better one!
plugin.log(Level.WARNING, String.format("Somebody tried to set the spawn location for '%s' to an unsafe value! Adjusting...", getAlias())); Logging.warning(String.format("Somebody tried to set the spawn location for '%s' to an unsafe value! Adjusting...", getAlias()));
plugin.log(Level.WARNING, "Old Location: " + plugin.getLocationManipulation().strCoordsRaw(oldValue)); Logging.warning("Old Location: " + plugin.getLocationManipulation().strCoordsRaw(oldValue));
plugin.log(Level.WARNING, "New (unsafe) Location: " + plugin.getLocationManipulation().strCoordsRaw(newValue)); Logging.warning("New (unsafe) Location: " + plugin.getLocationManipulation().strCoordsRaw(newValue));
SafeTTeleporter teleporter = plugin.getSafeTTeleporter(); SafeTTeleporter teleporter = plugin.getSafeTTeleporter();
newValue = teleporter.getSafeLocation(newValue, SPAWN_LOCATION_SEARCH_TOLERANCE, SPAWN_LOCATION_SEARCH_RADIUS); newValue = teleporter.getSafeLocation(newValue, SPAWN_LOCATION_SEARCH_TOLERANCE, SPAWN_LOCATION_SEARCH_RADIUS);
if (newValue == null) { if (newValue == null) {
plugin.log(Level.WARNING, "Couldn't fix the location. I have to abort the spawn location-change :/"); Logging.warning("Couldn't fix the location. I have to abort the spawn location-change :/");
throw new ChangeDeniedException(); throw new ChangeDeniedException();
} }
plugin.log(Level.WARNING, "New (safe) Location: " + plugin.getLocationManipulation().strCoordsRaw(newValue)); Logging.warning("New (safe) Location: " + plugin.getLocationManipulation().strCoordsRaw(newValue));
} }
} }
return super.validateChange(property, newValue, oldValue, object); return super.validateChange(property, newValue, oldValue, object);
@ -411,7 +411,7 @@ public class MVWorld implements MultiverseWorld {
// Add limit bypass to it's parent // Add limit bypass to it's parent
this.limitbypassperm.addParent("mv.bypass.playerlimit.*", true); this.limitbypassperm.addParent("mv.bypass.playerlimit.*", true);
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
this.plugin.log(Level.FINER, "Permissions nodes were already added for " + this.name); Logging.finer("Permissions nodes were already added for " + this.name);
} }
} }
@ -422,16 +422,16 @@ public class MVWorld implements MultiverseWorld {
// Verify that location was safe // Verify that location was safe
if (!bs.playerCanSpawnHereSafely(location)) { if (!bs.playerCanSpawnHereSafely(location)) {
if (!this.getAdjustSpawn()) { if (!this.getAdjustSpawn()) {
this.plugin.log(Level.FINE, "Spawn location from world.dat file was unsafe!!"); Logging.fine("Spawn location from world.dat file was unsafe!!");
this.plugin.log(Level.FINE, "NOT adjusting spawn for '" + this.getAlias() + "' because you told me not to."); Logging.fine("NOT adjusting spawn for '" + this.getAlias() + "' because you told me not to.");
this.plugin.log(Level.FINE, "To turn on spawn adjustment for this world simply type:"); Logging.fine("To turn on spawn adjustment for this world simply type:");
this.plugin.log(Level.FINE, "/mvm set adjustspawn true " + this.getAlias()); Logging.fine("/mvm set adjustspawn true " + this.getAlias());
return location; return location;
} }
// If it's not, find a better one. // If it's not, find a better one.
SafeTTeleporter teleporter = this.plugin.getSafeTTeleporter(); SafeTTeleporter teleporter = this.plugin.getSafeTTeleporter();
this.plugin.log(Level.WARNING, "Spawn location from world.dat file was unsafe. Adjusting..."); Logging.warning("Spawn location from world.dat file was unsafe. Adjusting...");
this.plugin.log(Level.WARNING, "Original Location: " + plugin.getLocationManipulation().strCoordsRaw(location)); Logging.warning("Original Location: " + plugin.getLocationManipulation().strCoordsRaw(location));
Location newSpawn = teleporter.getSafeLocation(location, Location newSpawn = teleporter.getSafeLocation(location,
SPAWN_LOCATION_SEARCH_TOLERANCE, SPAWN_LOCATION_SEARCH_RADIUS); SPAWN_LOCATION_SEARCH_TOLERANCE, SPAWN_LOCATION_SEARCH_RADIUS);
// I think we could also do this, as I think this is what Notch does. // I think we could also do this, as I think this is what Notch does.
@ -450,7 +450,7 @@ public class MVWorld implements MultiverseWorld {
this.getName(), plugin.getLocationManipulation().locationToString(newerSpawn)); this.getName(), plugin.getLocationManipulation().locationToString(newerSpawn));
return newerSpawn; return newerSpawn;
} else { } else {
this.plugin.log(Level.SEVERE, "Safe spawn NOT found!!!"); Logging.severe("Safe spawn NOT found!!!");
} }
} }
} }

View File

@ -306,7 +306,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
this.worldManager.loadDefaultWorlds(); this.worldManager.loadDefaultWorlds();
this.worldManager.loadWorlds(true); this.worldManager.loadWorlds(true);
} else { } else {
this.log(Level.SEVERE, "Your configs were not loaded. Very little will function in Multiverse."); Logging.severe("Your configs were not loaded. Very little will function in Multiverse.");
} }
this.anchorManager.loadAnchors(); this.anchorManager.loadAnchors();
@ -383,7 +383,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
pm.registerEvents(this.entityListener, this); pm.registerEvents(this.entityListener, this);
pm.registerEvents(this.weatherListener, this); pm.registerEvents(this.weatherListener, this);
pm.registerEvents(this.portalListener, this); pm.registerEvents(this.portalListener, this);
log(Level.INFO, ChatColor.GREEN + "We are aware of the warning about the deprecated event. There is no alternative that allows us to do what we need to do and performance impact is negligible. It is safe to ignore."); Logging.info(ChatColor.GREEN + "We are aware of the warning about the deprecated event. There is no alternative that allows us to do what we need to do and performance impact is negligible. It is safe to ignore.");
pm.registerEvents(this.worldListener, this); pm.registerEvents(this.worldListener, this);
pm.registerEvents(new MVMapListener(this), this); pm.registerEvents(new MVMapListener(this), this);
} }
@ -502,13 +502,13 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
try { try {
wconf.load(worldsFile); wconf.load(worldsFile);
} catch (IOException e) { } catch (IOException e) {
log(Level.WARNING, "Cannot load worlds.yml"); Logging.warning("Cannot load worlds.yml");
} catch (InvalidConfigurationException e) { } catch (InvalidConfigurationException e) {
log(Level.WARNING, "Your worlds.yml is invalid!"); Logging.warning("Your worlds.yml is invalid!");
} }
if (!wconf.isConfigurationSection("worlds")) { // empty config if (!wconf.isConfigurationSection("worlds")) { // empty config
this.log(Level.FINE, "No worlds to migrate!"); Logging.fine("No worlds to migrate!");
return; return;
} }
@ -521,7 +521,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
// fine // fine
newValues.put(entry.getKey(), entry.getValue()); newValues.put(entry.getKey(), entry.getValue());
} else if (entry.getValue() instanceof ConfigurationSection) { } else if (entry.getValue() instanceof ConfigurationSection) {
this.log(Level.FINE, "Migrating: " + entry.getKey()); Logging.fine("Migrating: " + entry.getKey());
// we have to migrate this // we have to migrate this
WorldProperties world = new WorldProperties(Collections.EMPTY_MAP); WorldProperties world = new WorldProperties(Collections.EMPTY_MAP);
ConfigurationSection section = (ConfigurationSection) entry.getValue(); ConfigurationSection section = (ConfigurationSection) entry.getValue();
@ -687,8 +687,8 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
try { try {
difficulty = Difficulty.valueOf(section.getString("difficulty").toUpperCase()); difficulty = Difficulty.valueOf(section.getString("difficulty").toUpperCase());
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
this.log(Level.WARNING, "Could not parse difficulty: " + section.getString("difficulty")); Logging.warning("Could not parse difficulty: " + section.getString("difficulty"));
this.log(Level.WARNING, "Setting world " + entry.getKey() + " difficulty to NORMAL"); Logging.warning("Setting world " + entry.getKey() + " difficulty to NORMAL");
difficulty = Difficulty.NORMAL; difficulty = Difficulty.NORMAL;
} }
if (difficulty != null) { if (difficulty != null) {
@ -705,7 +705,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
wasChanged = true; wasChanged = true;
} else { } else {
// huh? // huh?
this.log(Level.WARNING, "Removing unknown entry in the config: " + entry); Logging.warning("Removing unknown entry in the config: " + entry);
// just don't add to newValues // just don't add to newValues
wasChanged = true; wasChanged = true;
} }
@ -839,8 +839,12 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
/** /**
* {@inheritDoc} * {@inheritDoc}
*
* @deprecated This is now deprecated, nobody needs it any longer.
* All logging is now done with {@link Logging}.
*/ */
@Override @Override
@Deprecated
public void log(Level level, String msg) { public void log(Level level, String msg) {
Logging.log(level, msg); Logging.log(level, msg);
} }
@ -1059,7 +1063,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
this.multiverseConfig.save(new File(getDataFolder(), "config.yml")); this.multiverseConfig.save(new File(getDataFolder(), "config.yml"));
return true; return true;
} catch (IOException e) { } catch (IOException e) {
this.log(Level.SEVERE, "Could not save Multiverse config.yml config. Please check your file permissions."); Logging.severe("Could not save Multiverse config.yml config. Please check your file permissions.");
return false; return false;
} }
} }

View File

@ -7,11 +7,17 @@
package com.onarandombox.MultiverseCore.api; package com.onarandombox.MultiverseCore.api;
import com.dumptruckman.minecraft.util.Logging;
import org.bukkit.Server; import org.bukkit.Server;
import java.util.logging.Level; import java.util.logging.Level;
/** A simple API to require plugins to have a log method. */ /**
* A simple API to require plugins to have a log method.
*
* @deprecated Replaced by {@link Logging}.
* */
@Deprecated
public interface LoggablePlugin { public interface LoggablePlugin {
/** /**
* Logs a message at the specified level. * Logs a message at the specified level.

View File

@ -7,6 +7,7 @@
package com.onarandombox.MultiverseCore.commands; package com.onarandombox.MultiverseCore.commands;
import com.dumptruckman.minecraft.util.Logging;
import com.onarandombox.MultiverseCore.MultiverseCore; import com.onarandombox.MultiverseCore.MultiverseCore;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -60,7 +61,7 @@ public class DebugCommand extends MultiverseCommand {
sender.sendMessage("Multiverse Debug mode is " + ChatColor.RED + "OFF"); sender.sendMessage("Multiverse Debug mode is " + ChatColor.RED + "OFF");
} else { } else {
sender.sendMessage("Multiverse Debug mode is " + ChatColor.GREEN + debugLevel); sender.sendMessage("Multiverse Debug mode is " + ChatColor.GREEN + debugLevel);
this.plugin.log(Level.FINE, "Multiverse Debug ENABLED"); Logging.fine("Multiverse Debug ENABLED");
} }
} }
} }

View File

@ -7,6 +7,7 @@
package com.onarandombox.MultiverseCore.commands; package com.onarandombox.MultiverseCore.commands;
import com.dumptruckman.minecraft.util.Logging;
import com.onarandombox.MultiverseCore.MultiverseCore; import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.Teleporter; import com.onarandombox.MultiverseCore.api.Teleporter;
import com.onarandombox.MultiverseCore.api.MVDestination; import com.onarandombox.MultiverseCore.api.MVDestination;
@ -94,7 +95,7 @@ public class TeleportCommand extends MultiverseCommand {
MVTeleportEvent teleportEvent = new MVTeleportEvent(d, teleportee, teleporter, true); MVTeleportEvent teleportEvent = new MVTeleportEvent(d, teleportee, teleporter, true);
this.plugin.getServer().getPluginManager().callEvent(teleportEvent); this.plugin.getServer().getPluginManager().callEvent(teleportEvent);
if (teleportEvent.isCancelled()) { if (teleportEvent.isCancelled()) {
this.plugin.log(Level.FINE, "Someone else cancelled the MVTeleport Event!!!"); Logging.fine("Someone else cancelled the MVTeleport Event!!!");
return; return;
} }
@ -162,9 +163,9 @@ public class TeleportCommand extends MultiverseCommand {
((CustomTeleporterDestination)d).getTeleporter() : this.playerTeleporter; ((CustomTeleporterDestination)d).getTeleporter() : this.playerTeleporter;
TeleportResult result = teleportObject.teleport(teleporter, teleportee, d); TeleportResult result = teleportObject.teleport(teleporter, teleportee, d);
if (result == TeleportResult.FAIL_UNSAFE) { if (result == TeleportResult.FAIL_UNSAFE) {
this.plugin.log(Level.FINE, "Could not teleport " + teleportee.getName() Logging.fine("Could not teleport " + teleportee.getName()
+ " to " + plugin.getLocationManipulation().strCoordsRaw(d.getLocation(teleportee))); + " to " + plugin.getLocationManipulation().strCoordsRaw(d.getLocation(teleportee)));
this.plugin.log(Level.FINE, "Queueing Command"); Logging.fine("Queueing Command");
Class<?>[] paramTypes = { CommandSender.class, Player.class, Location.class }; Class<?>[] paramTypes = { CommandSender.class, Player.class, Location.class };
List<Object> items = new ArrayList<Object>(); List<Object> items = new ArrayList<Object>();
items.add(teleporter); items.add(teleporter);

View File

@ -9,6 +9,7 @@ package com.onarandombox.MultiverseCore.listeners;
import java.util.logging.Level; import java.util.logging.Level;
import com.dumptruckman.minecraft.util.Logging;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.player.AsyncPlayerChatEvent; import org.bukkit.event.player.AsyncPlayerChatEvent;
@ -20,7 +21,7 @@ import com.onarandombox.MultiverseCore.MultiverseCore;
public class MVAsyncPlayerChatListener extends MVChatListener { public class MVAsyncPlayerChatListener extends MVChatListener {
public MVAsyncPlayerChatListener(MultiverseCore plugin, MVPlayerListener playerListener) { public MVAsyncPlayerChatListener(MultiverseCore plugin, MVPlayerListener playerListener) {
super(plugin, playerListener); super(plugin, playerListener);
plugin.log(Level.FINE, "Created AsyncPlayerChatEvent listener."); Logging.fine("Created AsyncPlayerChatEvent listener.");
} }
/** /**

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;
@ -98,7 +99,7 @@ public class MVEntityListener implements Listener {
* Handle people with non-standard animals: ie a patched craftbukkit. * Handle people with non-standard animals: ie a patched craftbukkit.
*/ */
if (type == null || type.getName() == null) { if (type == null || type.getName() == null) {
this.plugin.log(Level.FINER, "Found a null typed creature."); Logging.finer("Found a null typed creature.");
return; return;
} }

View File

@ -9,6 +9,7 @@ package com.onarandombox.MultiverseCore.listeners;
import java.util.logging.Level; import java.util.logging.Level;
import com.dumptruckman.minecraft.util.Logging;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerChatEvent; import org.bukkit.event.player.PlayerChatEvent;
@ -21,7 +22,7 @@ import com.onarandombox.MultiverseCore.MultiverseCore;
public class MVPlayerChatListener extends MVChatListener { public class MVPlayerChatListener extends MVChatListener {
public MVPlayerChatListener(MultiverseCore plugin, MVPlayerListener playerListener) { public MVPlayerChatListener(MultiverseCore plugin, MVPlayerListener playerListener) {
super(plugin, playerListener); super(plugin, playerListener);
plugin.log(Level.FINE, "Registered PlayerChatEvent listener."); Logging.fine("Registered PlayerChatEvent listener.");
} }
/** /**

View File

@ -71,7 +71,7 @@ public class MVPlayerListener implements Listener {
if (mvWorld.getBedRespawn() && event.isBedSpawn()) { if (mvWorld.getBedRespawn() && event.isBedSpawn()) {
this.plugin.log(Level.FINE, "Spawning " + event.getPlayer().getName() + " at their bed"); Logging.fine("Spawning " + event.getPlayer().getName() + " at their bed");
return; return;
} }
@ -110,15 +110,15 @@ public class MVPlayerListener implements Listener {
public void playerJoin(PlayerJoinEvent event) { public void playerJoin(PlayerJoinEvent event) {
Player p = event.getPlayer(); Player p = event.getPlayer();
if (!p.hasPlayedBefore()) { if (!p.hasPlayedBefore()) {
this.plugin.log(Level.FINER, "Player joined for the FIRST time!"); Logging.finer("Player joined for the FIRST time!");
if (plugin.getMVConfig().getFirstSpawnOverride()) { if (plugin.getMVConfig().getFirstSpawnOverride()) {
this.plugin.log(Level.FINE, "Moving NEW player to(firstspawnoverride): " Logging.fine("Moving NEW player to(firstspawnoverride): "
+ worldManager.getFirstSpawnWorld().getSpawnLocation()); + worldManager.getFirstSpawnWorld().getSpawnLocation());
this.sendPlayerToDefaultWorld(p); this.sendPlayerToDefaultWorld(p);
} }
return; return;
} else { } else {
this.plugin.log(Level.FINER, "Player joined AGAIN!"); Logging.finer("Player joined AGAIN!");
if (this.plugin.getMVConfig().getEnforceAccess() // check this only if we're enforcing access! if (this.plugin.getMVConfig().getEnforceAccess() // check this only if we're enforcing access!
&& !this.plugin.getMVPerms().hasPermission(p, "multiverse.access." + p.getWorld().getName(), false)) { && !this.plugin.getMVPerms().hasPermission(p, "multiverse.access." + p.getWorld().getName(), false)) {
p.sendMessage("[MV] - Sorry you can't be in this world anymore!"); p.sendMessage("[MV] - Sorry you can't be in this world anymore!");
@ -156,7 +156,7 @@ public class MVPlayerListener implements Listener {
*/ */
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST)
public void playerTeleport(PlayerTeleportEvent event) { public void playerTeleport(PlayerTeleportEvent event) {
this.plugin.log(Level.FINER, "Got teleport event for player '" Logging.finer("Got teleport event for player '"
+ event.getPlayer().getName() + "' with cause '" + event.getCause() + "'"); + event.getPlayer().getName() + "' with cause '" + event.getCause() + "'");
if (event.isCancelled()) { if (event.isCancelled()) {
return; return;
@ -166,25 +166,25 @@ public class MVPlayerListener implements Listener {
String teleporterName = MultiverseCore.getPlayerTeleporter(teleportee.getName()); String teleporterName = MultiverseCore.getPlayerTeleporter(teleportee.getName());
if (teleporterName != null) { if (teleporterName != null) {
if (teleporterName.equals("CONSOLE")) { if (teleporterName.equals("CONSOLE")) {
this.plugin.log(Level.FINER, "We know the teleporter is the console! Magical!"); Logging.finer("We know the teleporter is the console! Magical!");
teleporter = this.plugin.getServer().getConsoleSender(); teleporter = this.plugin.getServer().getConsoleSender();
} else { } else {
teleporter = this.plugin.getServer().getPlayer(teleporterName); teleporter = this.plugin.getServer().getPlayer(teleporterName);
} }
} }
this.plugin.log(Level.FINER, "Inferred sender '" + teleporter + "' from name '" Logging.finer("Inferred sender '" + teleporter + "' from name '"
+ teleporterName + "', fetched from name '" + teleportee.getName() + "'"); + teleporterName + "', fetched from name '" + teleportee.getName() + "'");
MultiverseWorld fromWorld = this.worldManager.getMVWorld(event.getFrom().getWorld().getName()); MultiverseWorld fromWorld = this.worldManager.getMVWorld(event.getFrom().getWorld().getName());
MultiverseWorld toWorld = this.worldManager.getMVWorld(event.getTo().getWorld().getName()); MultiverseWorld toWorld = this.worldManager.getMVWorld(event.getTo().getWorld().getName());
if (toWorld == null) { if (toWorld == null) {
this.plugin.log(Level.FINE, "Player '" + teleportee.getName() + "' is teleporting to world '" Logging.fine("Player '" + teleportee.getName() + "' is teleporting to world '"
+ event.getTo().getWorld().getName() + "' which is not managed by Multiverse-Core. No further " + event.getTo().getWorld().getName() + "' which is not managed by Multiverse-Core. No further "
+ "actions will be taken by Multiverse-Core."); + "actions will be taken by Multiverse-Core.");
return; return;
} }
if (event.getFrom().getWorld().equals(event.getTo().getWorld())) { if (event.getFrom().getWorld().equals(event.getTo().getWorld())) {
// The player is Teleporting to the same world. // The player is Teleporting to the same world.
this.plugin.log(Level.FINER, "Player '" + teleportee.getName() + "' is teleporting to the same world."); Logging.finer("Player '" + teleportee.getName() + "' is teleporting to the same world.");
this.stateSuccess(teleportee.getName(), toWorld.getAlias()); this.stateSuccess(teleportee.getName(), toWorld.getAlias());
return; return;
} }
@ -192,7 +192,7 @@ public class MVPlayerListener implements Listener {
// Charge the teleporter // Charge the teleporter
event.setCancelled(!pt.playerHasMoneyToEnter(fromWorld, toWorld, teleporter, teleportee, true)); event.setCancelled(!pt.playerHasMoneyToEnter(fromWorld, toWorld, teleporter, teleportee, true));
if (event.isCancelled() && teleporter != null) { if (event.isCancelled() && teleporter != null) {
this.plugin.log(Level.FINE, "Player '" + teleportee.getName() Logging.fine("Player '" + teleportee.getName()
+ "' was DENIED ACCESS to '" + toWorld.getAlias() + "' was DENIED ACCESS to '" + toWorld.getAlias()
+ "' because '" + teleporter.getName() + "' because '" + teleporter.getName()
+ "' don't have the FUNDS required to enter it."); + "' don't have the FUNDS required to enter it.");
@ -203,14 +203,14 @@ public class MVPlayerListener implements Listener {
if (plugin.getMVConfig().getEnforceAccess()) { if (plugin.getMVConfig().getEnforceAccess()) {
event.setCancelled(!pt.playerCanGoFromTo(fromWorld, toWorld, teleporter, teleportee)); event.setCancelled(!pt.playerCanGoFromTo(fromWorld, toWorld, teleporter, teleportee));
if (event.isCancelled() && teleporter != null) { if (event.isCancelled() && teleporter != null) {
this.plugin.log(Level.FINE, "Player '" + teleportee.getName() Logging.fine("Player '" + teleportee.getName()
+ "' was DENIED ACCESS to '" + toWorld.getAlias() + "' was DENIED ACCESS to '" + toWorld.getAlias()
+ "' because '" + teleporter.getName() + "' because '" + teleporter.getName()
+ "' don't have: multiverse.access." + event.getTo().getWorld().getName()); + "' don't have: multiverse.access." + event.getTo().getWorld().getName());
return; return;
} }
} else { } else {
this.plugin.log(Level.FINE, "Player '" + teleportee.getName() Logging.fine("Player '" + teleportee.getName()
+ "' was allowed to go to '" + toWorld.getAlias() + "' because enforceaccess is off."); + "' was allowed to go to '" + toWorld.getAlias() + "' because enforceaccess is off.");
} }
@ -220,7 +220,7 @@ public class MVPlayerListener implements Listener {
if (toWorld.getCBWorld().getPlayers().size() >= toWorld.getPlayerLimit()) { if (toWorld.getCBWorld().getPlayers().size() >= toWorld.getPlayerLimit()) {
// Ouch the world is full, lets see if the player can bypass that limitation // Ouch the world is full, lets see if the player can bypass that limitation
if (!pt.playerCanBypassPlayerLimit(toWorld, teleporter, teleportee)) { if (!pt.playerCanBypassPlayerLimit(toWorld, teleporter, teleportee)) {
this.plugin.log(Level.FINE, "Player '" + teleportee.getName() Logging.fine("Player '" + teleportee.getName()
+ "' was DENIED ACCESS to '" + toWorld.getAlias() + "' was DENIED ACCESS to '" + toWorld.getAlias()
+ "' because the world is full and '" + teleporter.getName() + "' because the world is full and '" + teleporter.getName()
+ "' doesn't have: mv.bypass.playerlimit." + event.getTo().getWorld().getName()); + "' doesn't have: mv.bypass.playerlimit." + event.getTo().getWorld().getName());
@ -235,7 +235,7 @@ public class MVPlayerListener implements Listener {
} }
private void stateSuccess(String playerName, String worldName) { private void stateSuccess(String playerName, String worldName) {
this.plugin.log(Level.FINE, "MV-Core is allowing Player '" + playerName Logging.fine("MV-Core is allowing Player '" + playerName
+ "' to go to '" + worldName + "'."); + "' to go to '" + worldName + "'.");
} }
@ -282,12 +282,12 @@ public class MVPlayerListener implements Listener {
MultiverseWorld toWorld = this.worldManager.getMVWorld(event.getTo().getWorld().getName()); MultiverseWorld toWorld = this.worldManager.getMVWorld(event.getTo().getWorld().getName());
if (event.getFrom().getWorld().equals(event.getTo().getWorld())) { if (event.getFrom().getWorld().equals(event.getTo().getWorld())) {
// The player is Portaling to the same world. // The player is Portaling to the same world.
this.plugin.log(Level.FINER, "Player '" + event.getPlayer().getName() + "' is portaling to the same world."); Logging.finer("Player '" + event.getPlayer().getName() + "' is portaling to the same world.");
return; return;
} }
event.setCancelled(!pt.playerHasMoneyToEnter(fromWorld, toWorld, event.getPlayer(), event.getPlayer(), true)); event.setCancelled(!pt.playerHasMoneyToEnter(fromWorld, toWorld, event.getPlayer(), event.getPlayer(), true));
if (event.isCancelled()) { if (event.isCancelled()) {
this.plugin.log(Level.FINE, "Player '" + event.getPlayer().getName() Logging.fine("Player '" + event.getPlayer().getName()
+ "' was DENIED ACCESS to '" + event.getTo().getWorld().getName() + "' was DENIED ACCESS to '" + event.getTo().getWorld().getName()
+ "' because they don't have the FUNDS required to enter."); + "' because they don't have the FUNDS required to enter.");
return; return;
@ -295,12 +295,12 @@ public class MVPlayerListener implements Listener {
if (plugin.getMVConfig().getEnforceAccess()) { if (plugin.getMVConfig().getEnforceAccess()) {
event.setCancelled(!pt.playerCanGoFromTo(fromWorld, toWorld, event.getPlayer(), event.getPlayer())); event.setCancelled(!pt.playerCanGoFromTo(fromWorld, toWorld, event.getPlayer(), event.getPlayer()));
if (event.isCancelled()) { if (event.isCancelled()) {
this.plugin.log(Level.FINE, "Player '" + event.getPlayer().getName() Logging.fine("Player '" + event.getPlayer().getName()
+ "' was DENIED ACCESS to '" + event.getTo().getWorld().getName() + "' was DENIED ACCESS to '" + event.getTo().getWorld().getName()
+ "' because they don't have: multiverse.access." + event.getTo().getWorld().getName()); + "' because they don't have: multiverse.access." + event.getTo().getWorld().getName());
} }
} else { } else {
this.plugin.log(Level.FINE, "Player '" + event.getPlayer().getName() Logging.fine("Player '" + event.getPlayer().getName()
+ "' was allowed to go to '" + event.getTo().getWorld().getName() + "' was allowed to go to '" + event.getTo().getWorld().getName()
+ "' because enforceaccess is off."); + "' because enforceaccess is off.");
} }
@ -311,7 +311,7 @@ public class MVPlayerListener implements Listener {
event.getPortalTravelAgent().setSearchRadius(plugin.getMVConfig().getPortalSearchRadius()); event.getPortalTravelAgent().setSearchRadius(plugin.getMVConfig().getPortalSearchRadius());
} }
} catch (ClassNotFoundException ignore) { } catch (ClassNotFoundException ignore) {
plugin.log(Level.FINE, "TravelAgent not available for PlayerPortalEvent for " + event.getPlayer().getName()); Logging.fine("TravelAgent not available for PlayerPortalEvent for " + event.getPlayer().getName());
} }
} }
@ -335,7 +335,7 @@ public class MVPlayerListener implements Listener {
if (mvWorld != null) { if (mvWorld != null) {
this.handleGameModeAndFlight(player, mvWorld); this.handleGameModeAndFlight(player, mvWorld);
} else { } else {
this.plugin.log(Level.FINER, "Not handling gamemode and flight for world '" + world.getName() Logging.finer("Not handling gamemode and flight for world '" + world.getName()
+ "' not managed by Multiverse."); + "' not managed by Multiverse.");
} }
} }
@ -376,7 +376,7 @@ public class MVPlayerListener implements Listener {
player.getName(), player.getWorld().getName(), world.getName()); player.getName(), player.getWorld().getName(), world.getName());
} }
} else { } else {
MVPlayerListener.this.plugin.log(Level.FINE, "Player: " + player.getName() + " is IMMUNE to gamemode changes!"); Logging.fine("Player: " + player.getName() + " is IMMUNE to gamemode changes!");
} }
} }
}, 1L); }, 1L);

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.MultiverseWorld; import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import org.bukkit.Material; import org.bukkit.Material;
@ -56,7 +57,7 @@ public class MVPortalListener implements Listener {
public void portalForm(PortalCreateEvent event) { public void portalForm(PortalCreateEvent event) {
MultiverseWorld world = this.plugin.getMVWorldManager().getMVWorld(event.getWorld()); MultiverseWorld world = this.plugin.getMVWorldManager().getMVWorld(event.getWorld());
if (world != null && !world.getAllowedPortals().isPortalAllowed(PortalType.NETHER)) { if (world != null && !world.getAllowedPortals().isPortalAllowed(PortalType.NETHER)) {
plugin.log(Level.FINE, "Cancelling creation of nether portal because portalForm disallows."); Logging.fine("Cancelling creation of nether portal because portalForm disallows.");
event.setCancelled(true); event.setCancelled(true);
} }
} }
@ -79,7 +80,7 @@ public class MVPortalListener implements Listener {
} }
MultiverseWorld world = this.plugin.getMVWorldManager().getMVWorld(event.getPlayer().getWorld()); MultiverseWorld world = this.plugin.getMVWorldManager().getMVWorld(event.getPlayer().getWorld());
if (world != null && !world.getAllowedPortals().isPortalAllowed(PortalType.ENDER)) { if (world != null && !world.getAllowedPortals().isPortalAllowed(PortalType.ENDER)) {
plugin.log(Level.FINE, "Cancelling creation of ender portal because portalForm disallows."); Logging.fine("Cancelling creation of ender portal because portalForm disallows.");
event.setCancelled(true); event.setCancelled(true);
} }
} }

View File

@ -74,7 +74,7 @@ public class AnchorManager {
this.anchorConfig.save(new File(this.plugin.getDataFolder(), "anchors.yml")); this.anchorConfig.save(new File(this.plugin.getDataFolder(), "anchors.yml"));
return true; return true;
} catch (IOException e) { } catch (IOException e) {
this.plugin.log(Level.SEVERE, "Failed to save anchors.yml. Please check your file permissions."); Logging.severe("Failed to save anchors.yml. Please check your file permissions.");
return false; return false;
} }
} }

View File

@ -2,6 +2,7 @@ package com.onarandombox.MultiverseCore.utils;
import java.util.logging.Level; import java.util.logging.Level;
import com.dumptruckman.minecraft.util.Logging;
import com.onarandombox.MultiverseCore.api.SafeTTeleporter; import com.onarandombox.MultiverseCore.api.SafeTTeleporter;
import com.onarandombox.MultiverseCore.destination.CannonDestination; import com.onarandombox.MultiverseCore.destination.CannonDestination;
import org.bukkit.Location; import org.bukkit.Location;
@ -89,7 +90,7 @@ public class BukkitTravelAgent implements TravelAgent {
private Location getSafeLocation() { private Location getSafeLocation() {
// At this time, these can never use the velocity. // At this time, these can never use the velocity.
if (agent.destination instanceof CannonDestination) { if (agent.destination instanceof CannonDestination) {
agent.core.log(Level.FINE, "Using Stock TP method. This cannon will have 0 velocity"); Logging.fine("Using Stock TP method. This cannon will have 0 velocity");
} }
SafeTTeleporter teleporter = agent.core.getSafeTTeleporter(); SafeTTeleporter teleporter = agent.core.getSafeTTeleporter();
Location newLoc = agent.destination.getLocation(agent.player); Location newLoc = agent.destination.getLocation(agent.player);

View File

@ -72,12 +72,11 @@ public class FileUtils {
* Helper method to copy the world-folder. * Helper method to copy the world-folder.
* @param source Source-File * @param source Source-File
* @param target Target-File * @param target Target-File
* @param log A logger that logs the operation
* *
* @return true if it had success * @return true if it had success
*/ */
public static boolean copyFolder(File source, File target, Logger log) { public static boolean copyFolder(File source, File target) {
return copyFolder(source, target, null, log); return copyFolder(source, target, null);
} }
/** /**
@ -85,11 +84,10 @@ public class FileUtils {
* @param source Source-File * @param source Source-File
* @param target Target-File * @param target Target-File
* @param excludeFiles files to ignore and not copy over to Target-File * @param excludeFiles files to ignore and not copy over to Target-File
* @param log A logger that logs the operation
* *
* @return true if it had success * @return true if it had success
*/ */
public static boolean copyFolder(File source, File target, List<String> excludeFiles, Logger log) { public static boolean copyFolder(File source, File target, List<String> excludeFiles) {
Path sourceDir = source.toPath(); Path sourceDir = source.toPath();
Path targetDir = target.toPath(); Path targetDir = target.toPath();
@ -97,7 +95,7 @@ public class FileUtils {
Files.walkFileTree(sourceDir, new CopyDirFileVisitor(sourceDir, targetDir, excludeFiles)); Files.walkFileTree(sourceDir, new CopyDirFileVisitor(sourceDir, targetDir, excludeFiles));
return true; return true;
} catch (IOException e) { } catch (IOException e) {
log.log(Level.WARNING, "Unable to copy directory", e); Logging.warning("Unable to copy directory", e);
return false; return false;
} }
} }

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 com.onarandombox.MultiverseCore.api.MVDestination; import com.onarandombox.MultiverseCore.api.MVDestination;
import com.onarandombox.MultiverseCore.api.MVWorldManager; import com.onarandombox.MultiverseCore.api.MVWorldManager;
@ -100,7 +101,7 @@ public class MVPermissions implements PermissionsInterface {
public boolean canEnterWorld(Player p, MultiverseWorld w) { public boolean canEnterWorld(Player p, MultiverseWorld w) {
// If we're not enforcing access, anyone can enter. // If we're not enforcing access, anyone can enter.
if (!plugin.getMVConfig().getEnforceAccess()) { if (!plugin.getMVConfig().getEnforceAccess()) {
this.plugin.log(Level.FINEST, "EnforceAccess is OFF. Player was allowed in " + w.getAlias()); Logging.finest("EnforceAccess is OFF. Player was allowed in " + w.getAlias());
return true; return true;
} }
return this.hasPermission(p, "multiverse.access." + w.getName(), false); return this.hasPermission(p, "multiverse.access." + w.getName(), false);
@ -257,14 +258,14 @@ public class MVPermissions implements PermissionsInterface {
boolean hasPermission = sender.hasPermission(node); boolean hasPermission = sender.hasPermission(node);
if (!sender.isPermissionSet(node)) { if (!sender.isPermissionSet(node)) {
this.plugin.log(Level.FINER, String.format("The node [%s%s%s] was %sNOT%s set for [%s%s%s].", Logging.finer(String.format("The node [%s%s%s] was %sNOT%s set for [%s%s%s].",
ChatColor.RED, node, ChatColor.WHITE, ChatColor.RED, ChatColor.WHITE, ChatColor.AQUA, ChatColor.RED, node, ChatColor.WHITE, ChatColor.RED, ChatColor.WHITE, ChatColor.AQUA,
player.getDisplayName(), ChatColor.WHITE)); player.getDisplayName(), ChatColor.WHITE));
} }
if (hasPermission) { if (hasPermission) {
this.plugin.log(Level.FINER, "Checking to see if player [" + player.getName() + "] has permission [" + node + "]... YES"); Logging.finer("Checking to see if player [" + player.getName() + "] has permission [" + node + "]... YES");
} else { } else {
this.plugin.log(Level.FINER, "Checking to see if player [" + player.getName() + "] has permission [" + node + "]... NO"); Logging.finer("Checking to see if player [" + player.getName() + "] has permission [" + node + "]... NO");
} }
return hasPermission; return hasPermission;
} }

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 com.onarandombox.MultiverseCore.api.MultiverseWorld; import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import org.bukkit.Material; import org.bukkit.Material;
@ -195,7 +196,7 @@ public class PermissionTools {
* @return True if they can't go to the world, False if they can. * @return True if they can't go to the world, False if they can.
*/ */
public boolean playerCanGoFromTo(MultiverseWorld fromWorld, MultiverseWorld toWorld, CommandSender teleporter, Player teleportee) { public boolean playerCanGoFromTo(MultiverseWorld fromWorld, MultiverseWorld toWorld, CommandSender teleporter, Player teleportee) {
this.plugin.log(Level.FINEST, "Checking '" + teleporter + "' can send '" + teleportee + "' somewhere"); Logging.finest("Checking '" + teleporter + "' can send '" + teleportee + "' somewhere");
Player teleporterPlayer; Player teleporterPlayer;
if (plugin.getMVConfig().getTeleportIntercept()) { if (plugin.getMVConfig().getTeleportIntercept()) {

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 com.onarandombox.MultiverseCore.api.MultiverseWorld; import com.onarandombox.MultiverseCore.api.MultiverseWorld;
@ -86,7 +87,7 @@ public class PurgeWorlds {
} }
int entitiesKilled = 0; int entitiesKilled = 0;
for (Entity e : world.getEntities()) { for (Entity e : world.getEntities()) {
this.plugin.log(Level.FINEST, "Entity list (aval for purge) from WORLD < " + mvworld.getName() + " >: " + e.toString()); Logging.finest("Entity list (aval for purge) from WORLD < " + mvworld.getName() + " >: " + e.toString());
// Check against Monsters // Check against Monsters
if (killMonster(mvworld, e, thingsToKill, negateMonsters)) { if (killMonster(mvworld, e, thingsToKill, negateMonsters)) {
@ -133,16 +134,16 @@ public class PurgeWorlds {
entityName = e.toString().replaceAll("Craft", "").toUpperCase(); entityName = e.toString().replaceAll("Craft", "").toUpperCase();
} }
if (e instanceof Slime || e instanceof Monster || e instanceof Ghast || e instanceof EnderDragon) { if (e instanceof Slime || e instanceof Monster || e instanceof Ghast || e instanceof EnderDragon) {
this.plugin.log(Level.FINEST, "Looking at a monster: " + e); Logging.finest("Looking at a monster: " + e);
if (creaturesToKill.contains(entityName) || creaturesToKill.contains("ALL") || creaturesToKill.contains("MONSTERS")) { if (creaturesToKill.contains(entityName) || creaturesToKill.contains("ALL") || creaturesToKill.contains("MONSTERS")) {
if (!negate) { if (!negate) {
this.plugin.log(Level.FINEST, "Removing a monster: " + e); Logging.finest("Removing a monster: " + e);
e.remove(); e.remove();
return true; return true;
} }
} else { } else {
if (negate) { if (negate) {
this.plugin.log(Level.FINEST, "Removing a monster: " + e); Logging.finest("Removing a monster: " + e);
e.remove(); e.remove();
return true; return true;
} }

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 com.onarandombox.MultiverseCore.api.SafeTTeleporter; import com.onarandombox.MultiverseCore.api.SafeTTeleporter;
import com.onarandombox.MultiverseCore.api.MVDestination; import com.onarandombox.MultiverseCore.api.MVDestination;
@ -58,9 +59,9 @@ public class SimpleSafeTTeleporter implements SafeTTeleporter {
if (safe != null) { if (safe != null) {
safe.setX(safe.getBlockX() + .5); // SUPPRESS CHECKSTYLE: MagicNumberCheck safe.setX(safe.getBlockX() + .5); // SUPPRESS CHECKSTYLE: MagicNumberCheck
safe.setZ(safe.getBlockZ() + .5); // SUPPRESS CHECKSTYLE: MagicNumberCheck safe.setZ(safe.getBlockZ() + .5); // SUPPRESS CHECKSTYLE: MagicNumberCheck
this.plugin.log(Level.FINE, "Hey! I found one: " + plugin.getLocationManipulation().strCoordsRaw(safe)); Logging.fine("Hey! I found one: " + plugin.getLocationManipulation().strCoordsRaw(safe));
} else { } else {
this.plugin.log(Level.FINE, "Uh oh! No safe place found!"); Logging.fine("Uh oh! No safe place found!");
} }
return safe; return safe;
} }
@ -72,8 +73,8 @@ public class SimpleSafeTTeleporter implements SafeTTeleporter {
} }
// We want half of it, so we can go up and down // We want half of it, so we can go up and down
tolerance /= 2; tolerance /= 2;
this.plugin.log(Level.FINER, "Given Location of: " + plugin.getLocationManipulation().strCoordsRaw(l)); Logging.finer("Given Location of: " + plugin.getLocationManipulation().strCoordsRaw(l));
this.plugin.log(Level.FINER, "Checking +-" + tolerance + " with a radius of " + radius); Logging.finer("Checking +-" + tolerance + " with a radius of " + radius);
// For now this will just do a straight up block. // For now this will just do a straight up block.
Location locToCheck = l.clone(); Location locToCheck = l.clone();
@ -191,7 +192,7 @@ public class SimpleSafeTTeleporter implements SafeTTeleporter {
@Override @Override
public TeleportResult safelyTeleport(CommandSender teleporter, Entity teleportee, MVDestination d) { public TeleportResult safelyTeleport(CommandSender teleporter, Entity teleportee, MVDestination d) {
if (d instanceof InvalidDestination) { if (d instanceof InvalidDestination) {
this.plugin.log(Level.FINER, "Entity tried to teleport to an invalid destination"); Logging.finer("Entity tried to teleport to an invalid destination");
return TeleportResult.FAIL_INVALID; return TeleportResult.FAIL_INVALID;
} }
Player teleporteePlayer = null; Player teleporteePlayer = null;
@ -248,7 +249,7 @@ public class SimpleSafeTTeleporter implements SafeTTeleporter {
public Location getSafeLocation(Entity e, MVDestination d) { public Location getSafeLocation(Entity e, MVDestination d) {
Location l = d.getLocation(e); Location l = d.getLocation(e);
if (plugin.getBlockSafety().playerCanSpawnHereSafely(l)) { if (plugin.getBlockSafety().playerCanSpawnHereSafely(l)) {
plugin.log(Level.FINE, "The first location you gave me was safe."); Logging.fine("The first location you gave me was safe.");
return l; return l;
} }
if (e instanceof Minecart) { if (e instanceof Minecart) {
@ -267,21 +268,21 @@ public class SimpleSafeTTeleporter implements SafeTTeleporter {
// Add offset to account for a vehicle on dry land! // Add offset to account for a vehicle on dry land!
if (e instanceof Minecart && !plugin.getBlockSafety().isEntitiyOnTrack(safeLocation)) { if (e instanceof Minecart && !plugin.getBlockSafety().isEntitiyOnTrack(safeLocation)) {
safeLocation.setY(safeLocation.getBlockY() + .5); safeLocation.setY(safeLocation.getBlockY() + .5);
this.plugin.log(Level.FINER, "Player was inside a minecart. Offsetting Y location."); Logging.finer("Player was inside a minecart. Offsetting Y location.");
} }
this.plugin.log(Level.FINE, "Had to look for a bit, but I found a safe place for ya!"); Logging.finer("Had to look for a bit, but I found a safe place for ya!");
return safeLocation; return safeLocation;
} }
if (e instanceof Player) { if (e instanceof Player) {
Player p = (Player) e; Player p = (Player) e;
this.plugin.getMessaging().sendMessage(p, "No safe locations found!", false); this.plugin.getMessaging().sendMessage(p, "No safe locations found!", false);
this.plugin.log(Level.FINER, "No safe location found for " + p.getName()); Logging.finer("No safe location found for " + p.getName());
} else if (e.getPassenger() instanceof Player) { } else if (e.getPassenger() instanceof Player) {
Player p = (Player) e.getPassenger(); Player p = (Player) e.getPassenger();
this.plugin.getMessaging().sendMessage(p, "No safe locations found!", false); this.plugin.getMessaging().sendMessage(p, "No safe locations found!", false);
this.plugin.log(Level.FINER, "No safe location found for " + p.getName()); Logging.finer("No safe location found for " + p.getName());
} }
this.plugin.log(Level.FINE, "Sorry champ, you're basically trying to teleport into a minefield. I should just kill you now."); Logging.fine("Sorry champ, you're basically trying to teleport into a minefield. I should just kill you now.");
return null; return null;
} }

View File

@ -91,7 +91,7 @@ public class WorldManager implements MVWorldManager {
} }
} }
} else { } else {
this.plugin.log(Level.WARNING, "Could not read 'bukkit.yml'. Any Default worldgenerators will not be loaded!"); Logging.warning("Could not read 'bukkit.yml'. Any Default worldgenerators will not be loaded!");
} }
} }
@ -181,7 +181,7 @@ public class WorldManager implements MVWorldManager {
oldWorld.getCBWorld().save(); oldWorld.getCBWorld().save();
} }
Logging.config("Copying files for world '%s'", oldName); Logging.config("Copying files for world '%s'", oldName);
if (!FileUtils.copyFolder(oldWorldFile, newWorldFile, ignoreFiles, Logging.getLogger())) { if (!FileUtils.copyFolder(oldWorldFile, newWorldFile, ignoreFiles)) {
Logging.warning("Failed to copy files for world '%s', see the log info", newName); Logging.warning("Failed to copy files for world '%s', see the log info", newName);
return false; return false;
} }
@ -202,16 +202,16 @@ public class WorldManager implements MVWorldManager {
// save the worlds config to disk (worlds.yml) // save the worlds config to disk (worlds.yml)
if (!saveWorldsConfig()) { if (!saveWorldsConfig()) {
this.plugin.log(Level.SEVERE, "Failed to save worlds.yml"); Logging.severe("Failed to save worlds.yml");
return false; return false;
} }
// actually load the world // actually load the world
if (doLoad(newName)) { if (doLoad(newName)) {
this.plugin.log(Level.FINE, "Succeeded at loading cloned world '" + newName + "'"); Logging.fine("Succeeded at loading cloned world '" + newName + "'");
return true; return true;
} }
this.plugin.log(Level.SEVERE, "Failed to load the cloned world '" + newName + "'"); Logging.severe("Failed to load the cloned world '" + newName + "'");
return false; return false;
} }
@ -284,7 +284,7 @@ public class WorldManager implements MVWorldManager {
Logging.info(builder.toString()); Logging.info(builder.toString());
if (!doLoad(c, true)) { if (!doLoad(c, true)) {
this.plugin.log(Level.SEVERE, "Failed to Create/Load the world '" + name + "'"); Logging.severe("Failed to Create/Load the world '" + name + "'");
return false; return false;
} }
@ -357,7 +357,7 @@ public class WorldManager implements MVWorldManager {
MultiverseWorld world = this.getMVWorld(this.firstSpawn); MultiverseWorld world = this.getMVWorld(this.firstSpawn);
if (world == null) { if (world == null) {
// If the spawn world was unloaded, get the default world // If the spawn world was unloaded, get the default world
this.plugin.log(Level.WARNING, "The world specified as the spawn world (" + this.firstSpawn + ") did not exist!!"); Logging.warning("The world specified as the spawn world (" + this.firstSpawn + ") did not exist!!");
try { try {
return this.getMVWorld(this.plugin.getServer().getWorlds().get(0)); return this.getMVWorld(this.plugin.getServer().getWorlds().get(0));
} catch (IndexOutOfBoundsException e) { } catch (IndexOutOfBoundsException e) {
@ -440,15 +440,15 @@ public class WorldManager implements MVWorldManager {
} }
private void brokenWorld(String name) { private void brokenWorld(String name) {
this.plugin.log(Level.SEVERE, "The world '" + name + "' could NOT be loaded because it contains errors and is probably corrupt!"); Logging.severe("The world '" + name + "' could NOT be loaded because it contains errors and is probably corrupt!");
this.plugin.log(Level.SEVERE, "Try using Minecraft Region Fixer to repair your world! '" + name + "'"); Logging.severe("Try using Minecraft Region Fixer to repair your world! '" + name + "'");
this.plugin.log(Level.SEVERE, "https://github.com/Fenixin/Minecraft-Region-Fixer"); Logging.severe("https://github.com/Fenixin/Minecraft-Region-Fixer");
} }
private void nullWorld(String name) { private void nullWorld(String name) {
this.plugin.log(Level.SEVERE, "The world '" + name + "' could NOT be loaded because the server didn't like it!"); Logging.severe("The world '" + name + "' could NOT be loaded because the server didn't like it!");
this.plugin.log(Level.SEVERE, "We don't really know why this is. Contact the developer of your server software!"); Logging.severe("We don't really know why this is. Contact the developer of your server software!");
this.plugin.log(Level.SEVERE, "Server version info: " + Bukkit.getServer().getVersion()); Logging.severe("Server version info: " + Bukkit.getServer().getVersion());
} }
private boolean doLoad(String name) { private boolean doLoad(String name) {
@ -488,8 +488,8 @@ public class WorldManager implements MVWorldManager {
throw new IllegalArgumentException("That world is already loaded!"); throw new IllegalArgumentException("That world is already loaded!");
if (!ignoreExists && !new File(this.plugin.getServer().getWorldContainer(), worldName).exists() && !new File(this.plugin.getServer().getWorldContainer().getParent(), worldName).exists()) { if (!ignoreExists && !new File(this.plugin.getServer().getWorldContainer(), worldName).exists() && !new File(this.plugin.getServer().getWorldContainer().getParent(), worldName).exists()) {
this.plugin.log(Level.WARNING, "WorldManager: Can't load this world because the folder was deleted/moved: " + worldName); Logging.warning("WorldManager: Can't load this world because the folder was deleted/moved: " + worldName);
this.plugin.log(Level.WARNING, "Use '/mv remove' to remove it from the config!"); Logging.warning("Use '/mv remove' to remove it from the config!");
return false; return false;
} }
@ -536,7 +536,7 @@ public class WorldManager implements MVWorldManager {
MVWorldDeleteEvent mvwde = new MVWorldDeleteEvent(getMVWorld(name), removeFromConfig); MVWorldDeleteEvent mvwde = new MVWorldDeleteEvent(getMVWorld(name), removeFromConfig);
this.plugin.getServer().getPluginManager().callEvent(mvwde); this.plugin.getServer().getPluginManager().callEvent(mvwde);
if (mvwde.isCancelled()) { if (mvwde.isCancelled()) {
this.plugin.log(Level.FINE, "Tried to delete a world, but the event was cancelled!"); Logging.fine("Tried to delete a world, but the event was cancelled!");
return false; return false;
} }
@ -552,7 +552,7 @@ public class WorldManager implements MVWorldManager {
try { try {
File worldFile = world.getWorldFolder(); File worldFile = world.getWorldFolder();
plugin.log(Level.FINER, "deleteWorld(): worldFile: " + worldFile.getAbsolutePath()); Logging.finer("deleteWorld(): worldFile: " + worldFile.getAbsolutePath());
if (deleteWorldFolder ? FileUtils.deleteFolder(worldFile) : FileUtils.deleteFolderContents(worldFile)) { if (deleteWorldFolder ? FileUtils.deleteFolder(worldFile) : FileUtils.deleteFolderContents(worldFile)) {
Logging.info("World '%s' was DELETED.", name); Logging.info("World '%s' was DELETED.", name);
return true; return true;
@ -866,7 +866,7 @@ public class WorldManager implements MVWorldManager {
this.configWorlds.save(new File(this.plugin.getDataFolder(), "worlds.yml")); this.configWorlds.save(new File(this.plugin.getDataFolder(), "worlds.yml"));
return true; return true;
} catch (IOException e) { } catch (IOException e) {
this.plugin.log(Level.SEVERE, "Could not save worlds.yml. Please check your settings."); Logging.severe("Could not save worlds.yml. Please check your settings.");
return false; return false;
} }
} }

View File

@ -81,7 +81,7 @@ public class FileUtilsTest {
assertFalse(Files.isDirectory(targetChildDir)); assertFalse(Files.isDirectory(targetChildDir));
assertFalse(Files.isRegularFile(targetChildDirFile)); assertFalse(Files.isRegularFile(targetChildDirFile));
assertTrue(FileUtils.copyFolder(parentDir.toFile(), targetDir.toFile(), Logging.getLogger())); assertTrue(FileUtils.copyFolder(parentDir.toFile(), targetDir.toFile()));
assertTrue(Files.isDirectory(targetDir)); assertTrue(Files.isDirectory(targetDir));
assertTrue(Files.isRegularFile(targetFile)); assertTrue(Files.isRegularFile(targetFile));
@ -107,7 +107,7 @@ public class FileUtilsTest {
assertFalse(Files.isRegularFile(targetChildDirFile)); assertFalse(Files.isRegularFile(targetChildDirFile));
assertFalse(Files.isRegularFile(targetChildIgnoreFile)); assertFalse(Files.isRegularFile(targetChildIgnoreFile));
assertTrue(FileUtils.copyFolder(parentDir.toFile(), targetDir.toFile(), excludeFiles, Logging.getLogger())); assertTrue(FileUtils.copyFolder(parentDir.toFile(), targetDir.toFile(), excludeFiles));
assertTrue(Files.isDirectory(targetDir)); assertTrue(Files.isDirectory(targetDir));
assertTrue(Files.isRegularFile(targetFile)); assertTrue(Files.isRegularFile(targetFile));
@ -129,7 +129,7 @@ public class FileUtilsTest {
assertFalse(Files.isDirectory(targetChildDir)); assertFalse(Files.isDirectory(targetChildDir));
assertFalse(Files.isRegularFile(targetChildDirFile)); assertFalse(Files.isRegularFile(targetChildDirFile));
assertTrue(FileUtils.copyFolder(parentDir.toFile(), targetDir.toFile(), Logging.getLogger())); assertTrue(FileUtils.copyFolder(parentDir.toFile(), targetDir.toFile()));
assertTrue(Files.isDirectory(targetDir)); assertTrue(Files.isDirectory(targetDir));
assertTrue(Files.isRegularFile(targetFile)); assertTrue(Files.isRegularFile(targetFile));
@ -145,6 +145,6 @@ public class FileUtilsTest {
assertTrue(Files.isDirectory(targetDir)); assertTrue(Files.isDirectory(targetDir));
assertTrue(Files.isRegularFile(targetFile)); assertTrue(Files.isRegularFile(targetFile));
assertFalse(FileUtils.copyFolder(parentDir.toFile(), targetDir.toFile(), Logging.getLogger())); assertFalse(FileUtils.copyFolder(parentDir.toFile(), targetDir.toFile()));
} }
} }