mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-25 14:46:45 +01:00
Add logger
This commit is contained in:
parent
dc4776d16b
commit
4ceb54b566
@ -185,7 +185,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
||||
|
||||
@Override
|
||||
public void runEntityTask() {
|
||||
log(C.PREFIX + "KillAllEntities started.");
|
||||
PS.log(C.PREFIX + "KillAllEntities started.");
|
||||
TaskManager.runTaskRepeat(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -514,7 +514,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
||||
Settings.OFFLINE_MODE = true;
|
||||
}
|
||||
if (!checkVersion) {
|
||||
log(C.PREFIX + " &c[WARN] Titles are disabled - please update your version of Bukkit to support this feature.");
|
||||
PS.log(C.PREFIX + " &c[WARN] Titles are disabled - please update your version of Bukkit to support this feature.");
|
||||
Settings.TITLES = false;
|
||||
} else {
|
||||
AbstractTitle.TITLE_CLASS = new DefaultTitle_19();
|
||||
@ -523,11 +523,11 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
||||
}
|
||||
}
|
||||
if (Settings.OFFLINE_MODE) {
|
||||
log(C.PREFIX
|
||||
PS.log(C.PREFIX
|
||||
+ " &6PlotSquared is using Offline Mode UUIDs either because of user preference, or because you are using an old version of "
|
||||
+ "Bukkit");
|
||||
} else {
|
||||
log(C.PREFIX + " &6PlotSquared is using online UUIDs");
|
||||
PS.log(C.PREFIX + " &6PlotSquared is using online UUIDs");
|
||||
}
|
||||
if (Settings.USE_SQLUUIDHANDLER) {
|
||||
return new SQLUUIDHandler(wrapper);
|
||||
@ -575,7 +575,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
||||
public void startMetrics() {
|
||||
Metrics metrics = new Metrics(this);
|
||||
metrics.start();
|
||||
log(C.PREFIX + "&6Metrics enabled.");
|
||||
PS.log(C.PREFIX + "&6Metrics enabled.");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -599,7 +599,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
||||
SetGenCB.setGenerator(BukkitUtil.getWorld(worldName));
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
log("Failed to reload world: " + world);
|
||||
PS.log("Failed to reload world: " + world);
|
||||
Bukkit.getServer().unloadWorld(world, false);
|
||||
}
|
||||
}
|
||||
|
@ -539,7 +539,7 @@ public class MemorySection implements ConfigurationSection {
|
||||
List<?> list = getList(path);
|
||||
|
||||
if (list == null) {
|
||||
PS.get().IMP.log(path + " is null");
|
||||
PS.get().log(path + " is null");
|
||||
return new ArrayList<>(0);
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,7 @@ package com.intellectualcrafters.plot;
|
||||
import com.intellectualcrafters.plot.generator.GeneratorWrapper;
|
||||
import com.intellectualcrafters.plot.generator.HybridUtils;
|
||||
import com.intellectualcrafters.plot.generator.IndependentPlotGenerator;
|
||||
import com.intellectualcrafters.plot.logger.ILogger;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.AbstractTitle;
|
||||
import com.intellectualcrafters.plot.util.ChatManager;
|
||||
@ -20,7 +21,7 @@ import com.intellectualcrafters.plot.util.WorldUtil;
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
public interface IPlotMain {
|
||||
public interface IPlotMain extends ILogger {
|
||||
|
||||
/**
|
||||
* Log a message to console.
|
||||
|
@ -16,6 +16,7 @@ import com.intellectualcrafters.plot.generator.GeneratorWrapper;
|
||||
import com.intellectualcrafters.plot.generator.HybridPlotWorld;
|
||||
import com.intellectualcrafters.plot.generator.HybridUtils;
|
||||
import com.intellectualcrafters.plot.generator.IndependentPlotGenerator;
|
||||
import com.intellectualcrafters.plot.logger.ILogger;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotAnalysis;
|
||||
@ -48,7 +49,6 @@ import com.intellectualcrafters.plot.util.WorldUtil;
|
||||
import com.intellectualcrafters.plot.util.area.QuadMap;
|
||||
import com.plotsquared.listener.WESubscriber;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
@ -86,6 +86,7 @@ public class PS {
|
||||
|
||||
private static PS instance;
|
||||
public final IPlotMain IMP;
|
||||
public ILogger LOGGER;
|
||||
private final HashSet<Integer> plotAreaHashCheck = new HashSet<>();
|
||||
/**
|
||||
* All plot areas mapped by world (quick world access).
|
||||
@ -130,6 +131,7 @@ public class PS {
|
||||
PS.instance = this;
|
||||
this.thread = Thread.currentThread();
|
||||
this.IMP = iPlotMain;
|
||||
this.LOGGER = iPlotMain;
|
||||
this.platform = platform;
|
||||
this.version = this.IMP.getPluginVersion();
|
||||
try {
|
||||
@ -295,6 +297,27 @@ public class PS {
|
||||
return PS.instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the logger
|
||||
* @see com.intellectualcrafters.plot.logger.DelegateLogger
|
||||
* @see #getLogger()
|
||||
* @param logger
|
||||
*/
|
||||
public void setLogger(ILogger logger) {
|
||||
if (logger == null) {
|
||||
throw new IllegalArgumentException("Logger may not be null");
|
||||
}
|
||||
LOGGER = logger;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current logger
|
||||
* @return
|
||||
*/
|
||||
public ILogger getLogger() {
|
||||
return LOGGER;
|
||||
}
|
||||
|
||||
/**
|
||||
* Log a message to the IPlotMain logger.
|
||||
*
|
||||
@ -302,7 +325,7 @@ public class PS {
|
||||
* @see IPlotMain#log(String)
|
||||
*/
|
||||
public static void log(Object message) {
|
||||
PS.get().IMP.log(StringMan.getString(message));
|
||||
PS.get().LOGGER.log(StringMan.getString(message));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -0,0 +1,22 @@
|
||||
package com.intellectualcrafters.plot.logger;
|
||||
|
||||
public class DelegateLogger implements ILogger {
|
||||
|
||||
private final ILogger parent;
|
||||
|
||||
public DelegateLogger(ILogger parent) {
|
||||
if (parent == null) {
|
||||
throw new IllegalArgumentException("Parent cannot be null");
|
||||
}
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
public ILogger getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void log(String message) {
|
||||
parent.log(message);
|
||||
}
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
package com.intellectualcrafters.plot.logger;
|
||||
|
||||
public interface ILogger {
|
||||
public void log(String message);
|
||||
}
|
@ -344,7 +344,7 @@ public abstract class PlotArea {
|
||||
}
|
||||
for (Entry<String, Object> stringObjectEntry : options.entrySet()) {
|
||||
if (!config.contains(stringObjectEntry.getKey())) {
|
||||
PS.get().IMP.log(stringObjectEntry.toString());
|
||||
PS.get().log(stringObjectEntry.toString());
|
||||
config.set(stringObjectEntry.getKey(), stringObjectEntry.getValue());
|
||||
}
|
||||
}
|
||||
|
@ -122,17 +122,17 @@ public class SpongeMain implements IPlotMain {
|
||||
|
||||
@Listener
|
||||
public void init(GameInitializationEvent event) {
|
||||
log("PlotSquared: Game init");
|
||||
PS.log("PlotSquared: Game init");
|
||||
}
|
||||
|
||||
@Listener
|
||||
public void onInit(GamePreInitializationEvent event) {
|
||||
log("PlotSquared: Game pre init");
|
||||
PS.log("PlotSquared: Game pre init");
|
||||
}
|
||||
|
||||
@Listener
|
||||
public void onServerAboutToStart(GameAboutToStartServerEvent event) {
|
||||
log("PlotSquared: Server init");
|
||||
PS.log("PlotSquared: Server init");
|
||||
THIS = this;
|
||||
new PS(this, "Sponge");
|
||||
this.server = this.game.getServer();
|
||||
@ -177,7 +177,7 @@ public class SpongeMain implements IPlotMain {
|
||||
|
||||
@Override
|
||||
public int[] getServerVersion() {
|
||||
log("Checking minecraft version: Sponge: ");
|
||||
PS.log("Checking minecraft version: Sponge: ");
|
||||
String version = this.game.getPlatform().getMinecraftVersion().getName();
|
||||
String[] split = version.split("\\.");
|
||||
return new int[]{Integer.parseInt(split[0]), Integer.parseInt(split[1]), split.length == 3 ? Integer.parseInt(split[2]) : 0};
|
||||
@ -248,13 +248,13 @@ public class SpongeMain implements IPlotMain {
|
||||
@Override
|
||||
public void registerPlotPlusEvents() {
|
||||
// TODO Auto-generated method stub
|
||||
log("registerPlotPlusEvents is not implemented!");
|
||||
PS.log("registerPlotPlusEvents is not implemented!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerForceFieldEvents() {
|
||||
// TODO Auto-generated method stub
|
||||
log("registerForceFieldEvents is not implemented!");
|
||||
PS.log("registerForceFieldEvents is not implemented!");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -308,9 +308,9 @@ public class SpongeMain implements IPlotMain {
|
||||
try {
|
||||
SpongeMetrics metrics = new SpongeMetrics(this.game, this.plugin);
|
||||
metrics.start();
|
||||
log(C.PREFIX.s() + "&6Metrics enabled.");
|
||||
PS.log(C.PREFIX.s() + "&6Metrics enabled.");
|
||||
} catch (IOException ignored) {
|
||||
log(C.PREFIX.s() + "&cFailed to load up metrics.");
|
||||
PS.log(C.PREFIX.s() + "&cFailed to load up metrics.");
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user