Server-side multiworld support with several improvements overal.
This commit is contained in:
parent
2fd91ef94b
commit
5b0171c459
20 changed files with 398 additions and 296 deletions
|
|
@ -1,8 +1,6 @@
|
|||
package org.dynmap.debug;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
|
@ -11,14 +9,9 @@ import org.bukkit.event.Event.Priority;
|
|||
import org.bukkit.event.player.PlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
import org.bukkit.event.player.PlayerListener;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class BukkitPlayerDebugger implements Debugger {
|
||||
protected static final Logger log = Logger.getLogger("Minecraft");
|
||||
|
||||
private boolean isLogging = false;
|
||||
|
||||
private JavaPlugin plugin;
|
||||
private HashSet<Player> debugees = new HashSet<Player>();
|
||||
private String debugCommand;
|
||||
|
|
@ -28,10 +21,10 @@ public class BukkitPlayerDebugger implements Debugger {
|
|||
public BukkitPlayerDebugger(JavaPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
|
||||
PluginDescriptionFile pdfFile = plugin.getDescription();
|
||||
debugCommand = "/debug_" + pdfFile.getName();
|
||||
undebugCommand = "/undebug_" + pdfFile.getName();
|
||||
prepend = pdfFile.getName() + ": ";
|
||||
String name = "dynmap";
|
||||
debugCommand = "/debug_" + name;
|
||||
undebugCommand = "/undebug_" + name;
|
||||
prepend = name + ": ";
|
||||
}
|
||||
|
||||
public synchronized void enable() {
|
||||
|
|
@ -63,19 +56,15 @@ public class BukkitPlayerDebugger implements Debugger {
|
|||
|
||||
public synchronized void debug(String message) {
|
||||
sendToDebuggees(message);
|
||||
if (isLogging)
|
||||
log.info(prepend + message);
|
||||
}
|
||||
|
||||
public synchronized void error(String message) {
|
||||
sendToDebuggees(prepend + ChatColor.RED + message);
|
||||
log.log(Level.SEVERE, prepend + message);
|
||||
}
|
||||
|
||||
public synchronized void error(String message, Throwable thrown) {
|
||||
sendToDebuggees(prepend + ChatColor.RED + message);
|
||||
sendToDebuggees(thrown.toString());
|
||||
log.log(Level.SEVERE, prepend + message);
|
||||
}
|
||||
|
||||
protected class CommandListener extends PlayerListener {
|
||||
|
|
|
|||
32
src/main/java/org/dynmap/debug/Debug.java
Normal file
32
src/main/java/org/dynmap/debug/Debug.java
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
package org.dynmap.debug;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
public class Debug {
|
||||
private static List<Debugger> debuggers = new LinkedList<Debugger>();
|
||||
|
||||
public synchronized static void addDebugger(Debugger d) {
|
||||
debuggers.add(d);
|
||||
}
|
||||
|
||||
public synchronized static void removeDebugger(Debugger d) {
|
||||
debuggers.remove(d);
|
||||
}
|
||||
|
||||
public synchronized static void clearDebuggers() {
|
||||
debuggers.clear();
|
||||
}
|
||||
|
||||
public synchronized static void debug(String message) {
|
||||
for(Debugger d : debuggers) d.debug(message);
|
||||
}
|
||||
|
||||
public synchronized static void error(String message) {
|
||||
for(Debugger d : debuggers) d.error(message);
|
||||
}
|
||||
|
||||
public synchronized static void error(String message, Throwable thrown) {
|
||||
for(Debugger d : debuggers) d.error(message, thrown);
|
||||
}
|
||||
}
|
||||
25
src/main/java/org/dynmap/debug/LogDebugger.java
Normal file
25
src/main/java/org/dynmap/debug/LogDebugger.java
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
package org.dynmap.debug;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class LogDebugger implements Debugger {
|
||||
protected static final Logger log = Logger.getLogger("Minecraft");
|
||||
private static String prepend = "dynmap: ";
|
||||
|
||||
@Override
|
||||
public void debug(String message) {
|
||||
log.info(prepend + message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(String message) {
|
||||
log.log(Level.SEVERE, prepend + message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(String message, Throwable thrown) {
|
||||
log.log(Level.SEVERE, prepend + message);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue