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,
MVWorld object) throws ChangeDeniedException {
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();
}
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,
MVWorld object) throws ChangeDeniedException {
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()));
plugin.getPlayerListener().handleGameModeAndFlight(p, MVWorld.this);
}
@ -319,16 +319,16 @@ public class MVWorld implements MultiverseWorld {
// verify that the location is safe
if (!bs.playerCanSpawnHereSafely(newValue)) {
// 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()));
plugin.log(Level.WARNING, "Old Location: " + plugin.getLocationManipulation().strCoordsRaw(oldValue));
plugin.log(Level.WARNING, "New (unsafe) Location: " + plugin.getLocationManipulation().strCoordsRaw(newValue));
Logging.warning(String.format("Somebody tried to set the spawn location for '%s' to an unsafe value! Adjusting...", getAlias()));
Logging.warning("Old Location: " + plugin.getLocationManipulation().strCoordsRaw(oldValue));
Logging.warning("New (unsafe) Location: " + plugin.getLocationManipulation().strCoordsRaw(newValue));
SafeTTeleporter teleporter = plugin.getSafeTTeleporter();
newValue = teleporter.getSafeLocation(newValue, SPAWN_LOCATION_SEARCH_TOLERANCE, SPAWN_LOCATION_SEARCH_RADIUS);
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();
}
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);
@ -411,7 +411,7 @@ public class MVWorld implements MultiverseWorld {
// Add limit bypass to it's parent
this.limitbypassperm.addParent("mv.bypass.playerlimit.*", true);
} 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
if (!bs.playerCanSpawnHereSafely(location)) {
if (!this.getAdjustSpawn()) {
this.plugin.log(Level.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.");
this.plugin.log(Level.FINE, "To turn on spawn adjustment for this world simply type:");
this.plugin.log(Level.FINE, "/mvm set adjustspawn true " + this.getAlias());
Logging.fine("Spawn location from world.dat file was unsafe!!");
Logging.fine("NOT adjusting spawn for '" + this.getAlias() + "' because you told me not to.");
Logging.fine("To turn on spawn adjustment for this world simply type:");
Logging.fine("/mvm set adjustspawn true " + this.getAlias());
return location;
}
// If it's not, find a better one.
SafeTTeleporter teleporter = this.plugin.getSafeTTeleporter();
this.plugin.log(Level.WARNING, "Spawn location from world.dat file was unsafe. Adjusting...");
this.plugin.log(Level.WARNING, "Original Location: " + plugin.getLocationManipulation().strCoordsRaw(location));
Logging.warning("Spawn location from world.dat file was unsafe. Adjusting...");
Logging.warning("Original Location: " + plugin.getLocationManipulation().strCoordsRaw(location));
Location newSpawn = teleporter.getSafeLocation(location,
SPAWN_LOCATION_SEARCH_TOLERANCE, SPAWN_LOCATION_SEARCH_RADIUS);
// 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));
return newerSpawn;
} 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.loadWorlds(true);
} 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();
@ -383,7 +383,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
pm.registerEvents(this.entityListener, this);
pm.registerEvents(this.weatherListener, 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(new MVMapListener(this), this);
}
@ -502,13 +502,13 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
try {
wconf.load(worldsFile);
} catch (IOException e) {
log(Level.WARNING, "Cannot load worlds.yml");
Logging.warning("Cannot load worlds.yml");
} catch (InvalidConfigurationException e) {
log(Level.WARNING, "Your worlds.yml is invalid!");
Logging.warning("Your worlds.yml is invalid!");
}
if (!wconf.isConfigurationSection("worlds")) { // empty config
this.log(Level.FINE, "No worlds to migrate!");
Logging.fine("No worlds to migrate!");
return;
}
@ -521,7 +521,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
// fine
newValues.put(entry.getKey(), entry.getValue());
} else if (entry.getValue() instanceof ConfigurationSection) {
this.log(Level.FINE, "Migrating: " + entry.getKey());
Logging.fine("Migrating: " + entry.getKey());
// we have to migrate this
WorldProperties world = new WorldProperties(Collections.EMPTY_MAP);
ConfigurationSection section = (ConfigurationSection) entry.getValue();
@ -687,8 +687,8 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
try {
difficulty = Difficulty.valueOf(section.getString("difficulty").toUpperCase());
} catch (IllegalArgumentException e) {
this.log(Level.WARNING, "Could not parse difficulty: " + section.getString("difficulty"));
this.log(Level.WARNING, "Setting world " + entry.getKey() + " difficulty to NORMAL");
Logging.warning("Could not parse difficulty: " + section.getString("difficulty"));
Logging.warning("Setting world " + entry.getKey() + " difficulty to NORMAL");
difficulty = Difficulty.NORMAL;
}
if (difficulty != null) {
@ -705,7 +705,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
wasChanged = true;
} else {
// 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
wasChanged = true;
}
@ -839,8 +839,12 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
/**
* {@inheritDoc}
*
* @deprecated This is now deprecated, nobody needs it any longer.
* All logging is now done with {@link Logging}.
*/
@Override
@Deprecated
public void log(Level level, String 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"));
return true;
} 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;
}
}

View File

@ -7,11 +7,17 @@
package com.onarandombox.MultiverseCore.api;
import com.dumptruckman.minecraft.util.Logging;
import org.bukkit.Server;
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 {
/**
* Logs a message at the specified level.

View File

@ -7,6 +7,7 @@
package com.onarandombox.MultiverseCore.commands;
import com.dumptruckman.minecraft.util.Logging;
import com.onarandombox.MultiverseCore.MultiverseCore;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
@ -60,7 +61,7 @@ public class DebugCommand extends MultiverseCommand {
sender.sendMessage("Multiverse Debug mode is " + ChatColor.RED + "OFF");
} else {
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;
import com.dumptruckman.minecraft.util.Logging;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.Teleporter;
import com.onarandombox.MultiverseCore.api.MVDestination;
@ -94,7 +95,7 @@ public class TeleportCommand extends MultiverseCommand {
MVTeleportEvent teleportEvent = new MVTeleportEvent(d, teleportee, teleporter, true);
this.plugin.getServer().getPluginManager().callEvent(teleportEvent);
if (teleportEvent.isCancelled()) {
this.plugin.log(Level.FINE, "Someone else cancelled the MVTeleport Event!!!");
Logging.fine("Someone else cancelled the MVTeleport Event!!!");
return;
}
@ -162,9 +163,9 @@ public class TeleportCommand extends MultiverseCommand {
((CustomTeleporterDestination)d).getTeleporter() : this.playerTeleporter;
TeleportResult result = teleportObject.teleport(teleporter, teleportee, d);
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)));
this.plugin.log(Level.FINE, "Queueing Command");
Logging.fine("Queueing Command");
Class<?>[] paramTypes = { CommandSender.class, Player.class, Location.class };
List<Object> items = new ArrayList<Object>();
items.add(teleporter);

View File

@ -9,6 +9,7 @@ package com.onarandombox.MultiverseCore.listeners;
import java.util.logging.Level;
import com.dumptruckman.minecraft.util.Logging;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.AsyncPlayerChatEvent;
@ -20,7 +21,7 @@ import com.onarandombox.MultiverseCore.MultiverseCore;
public class MVAsyncPlayerChatListener extends MVChatListener {
public MVAsyncPlayerChatListener(MultiverseCore plugin, MVPlayerListener 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;
import com.dumptruckman.minecraft.util.Logging;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MVWorldManager;
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.
*/
if (type == null || type.getName() == null) {
this.plugin.log(Level.FINER, "Found a null typed creature.");
Logging.finer("Found a null typed creature.");
return;
}

View File

@ -9,6 +9,7 @@ package com.onarandombox.MultiverseCore.listeners;
import java.util.logging.Level;
import com.dumptruckman.minecraft.util.Logging;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerChatEvent;
@ -21,7 +22,7 @@ import com.onarandombox.MultiverseCore.MultiverseCore;
public class MVPlayerChatListener extends MVChatListener {
public MVPlayerChatListener(MultiverseCore plugin, MVPlayerListener 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()) {
this.plugin.log(Level.FINE, "Spawning " + event.getPlayer().getName() + " at their bed");
Logging.fine("Spawning " + event.getPlayer().getName() + " at their bed");
return;
}
@ -110,15 +110,15 @@ public class MVPlayerListener implements Listener {
public void playerJoin(PlayerJoinEvent event) {
Player p = event.getPlayer();
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()) {
this.plugin.log(Level.FINE, "Moving NEW player to(firstspawnoverride): "
Logging.fine("Moving NEW player to(firstspawnoverride): "
+ worldManager.getFirstSpawnWorld().getSpawnLocation());
this.sendPlayerToDefaultWorld(p);
}
return;
} 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!
&& !this.plugin.getMVPerms().hasPermission(p, "multiverse.access." + p.getWorld().getName(), false)) {
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)
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() + "'");
if (event.isCancelled()) {
return;
@ -166,25 +166,25 @@ public class MVPlayerListener implements Listener {
String teleporterName = MultiverseCore.getPlayerTeleporter(teleportee.getName());
if (teleporterName != null) {
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();
} else {
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() + "'");
MultiverseWorld fromWorld = this.worldManager.getMVWorld(event.getFrom().getWorld().getName());
MultiverseWorld toWorld = this.worldManager.getMVWorld(event.getTo().getWorld().getName());
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 "
+ "actions will be taken by Multiverse-Core.");
return;
}
if (event.getFrom().getWorld().equals(event.getTo().getWorld())) {
// 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());
return;
}
@ -192,7 +192,7 @@ public class MVPlayerListener implements Listener {
// Charge the teleporter
event.setCancelled(!pt.playerHasMoneyToEnter(fromWorld, toWorld, teleporter, teleportee, true));
if (event.isCancelled() && teleporter != null) {
this.plugin.log(Level.FINE, "Player '" + teleportee.getName()
Logging.fine("Player '" + teleportee.getName()
+ "' was DENIED ACCESS to '" + toWorld.getAlias()
+ "' because '" + teleporter.getName()
+ "' don't have the FUNDS required to enter it.");
@ -203,14 +203,14 @@ public class MVPlayerListener implements Listener {
if (plugin.getMVConfig().getEnforceAccess()) {
event.setCancelled(!pt.playerCanGoFromTo(fromWorld, toWorld, teleporter, teleportee));
if (event.isCancelled() && teleporter != null) {
this.plugin.log(Level.FINE, "Player '" + teleportee.getName()
Logging.fine("Player '" + teleportee.getName()
+ "' was DENIED ACCESS to '" + toWorld.getAlias()
+ "' because '" + teleporter.getName()
+ "' don't have: multiverse.access." + event.getTo().getWorld().getName());
return;
}
} 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.");
}
@ -220,7 +220,7 @@ public class MVPlayerListener implements Listener {
if (toWorld.getCBWorld().getPlayers().size() >= toWorld.getPlayerLimit()) {
// Ouch the world is full, lets see if the player can bypass that limitation
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()
+ "' because the world is full and '" + teleporter.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) {
this.plugin.log(Level.FINE, "MV-Core is allowing Player '" + playerName
Logging.fine("MV-Core is allowing Player '" + playerName
+ "' to go to '" + worldName + "'.");
}
@ -282,12 +282,12 @@ public class MVPlayerListener implements Listener {
MultiverseWorld toWorld = this.worldManager.getMVWorld(event.getTo().getWorld().getName());
if (event.getFrom().getWorld().equals(event.getTo().getWorld())) {
// 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;
}
event.setCancelled(!pt.playerHasMoneyToEnter(fromWorld, toWorld, event.getPlayer(), event.getPlayer(), true));
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()
+ "' because they don't have the FUNDS required to enter.");
return;
@ -295,12 +295,12 @@ public class MVPlayerListener implements Listener {
if (plugin.getMVConfig().getEnforceAccess()) {
event.setCancelled(!pt.playerCanGoFromTo(fromWorld, toWorld, event.getPlayer(), event.getPlayer()));
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()
+ "' because they don't have: multiverse.access." + event.getTo().getWorld().getName());
}
} 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()
+ "' because enforceaccess is off.");
}
@ -311,7 +311,7 @@ public class MVPlayerListener implements Listener {
event.getPortalTravelAgent().setSearchRadius(plugin.getMVConfig().getPortalSearchRadius());
}
} 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) {
this.handleGameModeAndFlight(player, mvWorld);
} 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.");
}
}
@ -376,7 +376,7 @@ public class MVPlayerListener implements Listener {
player.getName(), player.getWorld().getName(), world.getName());
}
} 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);

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.MultiverseWorld;
import org.bukkit.Material;
@ -56,7 +57,7 @@ public class MVPortalListener implements Listener {
public void portalForm(PortalCreateEvent event) {
MultiverseWorld world = this.plugin.getMVWorldManager().getMVWorld(event.getWorld());
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);
}
}
@ -79,7 +80,7 @@ public class MVPortalListener implements Listener {
}
MultiverseWorld world = this.plugin.getMVWorldManager().getMVWorld(event.getPlayer().getWorld());
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);
}
}

View File

@ -74,7 +74,7 @@ public class AnchorManager {
this.anchorConfig.save(new File(this.plugin.getDataFolder(), "anchors.yml"));
return true;
} 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;
}
}

View File

@ -2,6 +2,7 @@ package com.onarandombox.MultiverseCore.utils;
import java.util.logging.Level;
import com.dumptruckman.minecraft.util.Logging;
import com.onarandombox.MultiverseCore.api.SafeTTeleporter;
import com.onarandombox.MultiverseCore.destination.CannonDestination;
import org.bukkit.Location;
@ -89,7 +90,7 @@ public class BukkitTravelAgent implements TravelAgent {
private Location getSafeLocation() {
// At this time, these can never use the velocity.
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();
Location newLoc = agent.destination.getLocation(agent.player);

View File

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

View File

@ -7,6 +7,7 @@
package com.onarandombox.MultiverseCore.utils;
import com.dumptruckman.minecraft.util.Logging;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MVDestination;
import com.onarandombox.MultiverseCore.api.MVWorldManager;
@ -100,7 +101,7 @@ public class MVPermissions implements PermissionsInterface {
public boolean canEnterWorld(Player p, MultiverseWorld w) {
// If we're not enforcing access, anyone can enter.
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 this.hasPermission(p, "multiverse.access." + w.getName(), false);
@ -257,14 +258,14 @@ public class MVPermissions implements PermissionsInterface {
boolean hasPermission = sender.hasPermission(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,
player.getDisplayName(), ChatColor.WHITE));
}
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 {
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;
}

View File

@ -7,6 +7,7 @@
package com.onarandombox.MultiverseCore.utils;
import com.dumptruckman.minecraft.util.Logging;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
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.
*/
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;
if (plugin.getMVConfig().getTeleportIntercept()) {

View File

@ -7,6 +7,7 @@
package com.onarandombox.MultiverseCore.utils;
import com.dumptruckman.minecraft.util.Logging;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
@ -86,7 +87,7 @@ public class PurgeWorlds {
}
int entitiesKilled = 0;
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
if (killMonster(mvworld, e, thingsToKill, negateMonsters)) {
@ -133,16 +134,16 @@ public class PurgeWorlds {
entityName = e.toString().replaceAll("Craft", "").toUpperCase();
}
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 (!negate) {
this.plugin.log(Level.FINEST, "Removing a monster: " + e);
Logging.finest("Removing a monster: " + e);
e.remove();
return true;
}
} else {
if (negate) {
this.plugin.log(Level.FINEST, "Removing a monster: " + e);
Logging.finest("Removing a monster: " + e);
e.remove();
return true;
}

View File

@ -7,6 +7,7 @@
package com.onarandombox.MultiverseCore.utils;
import com.dumptruckman.minecraft.util.Logging;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.SafeTTeleporter;
import com.onarandombox.MultiverseCore.api.MVDestination;
@ -58,9 +59,9 @@ public class SimpleSafeTTeleporter implements SafeTTeleporter {
if (safe != null) {
safe.setX(safe.getBlockX() + .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 {
this.plugin.log(Level.FINE, "Uh oh! No safe place found!");
Logging.fine("Uh oh! No safe place found!");
}
return safe;
}
@ -72,8 +73,8 @@ public class SimpleSafeTTeleporter implements SafeTTeleporter {
}
// We want half of it, so we can go up and down
tolerance /= 2;
this.plugin.log(Level.FINER, "Given Location of: " + plugin.getLocationManipulation().strCoordsRaw(l));
this.plugin.log(Level.FINER, "Checking +-" + tolerance + " with a radius of " + radius);
Logging.finer("Given Location of: " + plugin.getLocationManipulation().strCoordsRaw(l));
Logging.finer("Checking +-" + tolerance + " with a radius of " + radius);
// For now this will just do a straight up block.
Location locToCheck = l.clone();
@ -191,7 +192,7 @@ public class SimpleSafeTTeleporter implements SafeTTeleporter {
@Override
public TeleportResult safelyTeleport(CommandSender teleporter, Entity teleportee, MVDestination d) {
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;
}
Player teleporteePlayer = null;
@ -248,7 +249,7 @@ public class SimpleSafeTTeleporter implements SafeTTeleporter {
public Location getSafeLocation(Entity e, MVDestination d) {
Location l = d.getLocation(e);
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;
}
if (e instanceof Minecart) {
@ -267,21 +268,21 @@ public class SimpleSafeTTeleporter implements SafeTTeleporter {
// Add offset to account for a vehicle on dry land!
if (e instanceof Minecart && !plugin.getBlockSafety().isEntitiyOnTrack(safeLocation)) {
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;
}
if (e instanceof Player) {
Player p = (Player) e;
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) {
Player p = (Player) e.getPassenger();
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;
}

View File

@ -91,7 +91,7 @@ public class WorldManager implements MVWorldManager {
}
}
} 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();
}
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);
return false;
}
@ -202,16 +202,16 @@ public class WorldManager implements MVWorldManager {
// save the worlds config to disk (worlds.yml)
if (!saveWorldsConfig()) {
this.plugin.log(Level.SEVERE, "Failed to save worlds.yml");
Logging.severe("Failed to save worlds.yml");
return false;
}
// actually load the world
if (doLoad(newName)) {
this.plugin.log(Level.FINE, "Succeeded at loading cloned world '" + newName + "'");
Logging.fine("Succeeded at loading cloned world '" + newName + "'");
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;
}
@ -284,7 +284,7 @@ public class WorldManager implements MVWorldManager {
Logging.info(builder.toString());
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;
}
@ -357,7 +357,7 @@ public class WorldManager implements MVWorldManager {
MultiverseWorld world = this.getMVWorld(this.firstSpawn);
if (world == null) {
// 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 {
return this.getMVWorld(this.plugin.getServer().getWorlds().get(0));
} catch (IndexOutOfBoundsException e) {
@ -440,15 +440,15 @@ public class WorldManager implements MVWorldManager {
}
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!");
this.plugin.log(Level.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("The world '" + name + "' could NOT be loaded because it contains errors and is probably corrupt!");
Logging.severe("Try using Minecraft Region Fixer to repair your world! '" + name + "'");
Logging.severe("https://github.com/Fenixin/Minecraft-Region-Fixer");
}
private void nullWorld(String name) {
this.plugin.log(Level.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!");
this.plugin.log(Level.SEVERE, "Server version info: " + Bukkit.getServer().getVersion());
Logging.severe("The world '" + name + "' could NOT be loaded because the server didn't like it!");
Logging.severe("We don't really know why this is. Contact the developer of your server software!");
Logging.severe("Server version info: " + Bukkit.getServer().getVersion());
}
private boolean doLoad(String name) {
@ -488,8 +488,8 @@ public class WorldManager implements MVWorldManager {
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()) {
this.plugin.log(Level.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("WorldManager: Can't load this world because the folder was deleted/moved: " + worldName);
Logging.warning("Use '/mv remove' to remove it from the config!");
return false;
}
@ -536,7 +536,7 @@ public class WorldManager implements MVWorldManager {
MVWorldDeleteEvent mvwde = new MVWorldDeleteEvent(getMVWorld(name), removeFromConfig);
this.plugin.getServer().getPluginManager().callEvent(mvwde);
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;
}
@ -552,7 +552,7 @@ public class WorldManager implements MVWorldManager {
try {
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)) {
Logging.info("World '%s' was DELETED.", name);
return true;
@ -866,7 +866,7 @@ public class WorldManager implements MVWorldManager {
this.configWorlds.save(new File(this.plugin.getDataFolder(), "worlds.yml"));
return true;
} 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;
}
}

View File

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