Fixed tabs.

This commit is contained in:
FrozenCow 2011-05-07 22:11:41 +02:00
parent ff026e91b6
commit be60623719
3 changed files with 71 additions and 72 deletions

View File

@ -136,7 +136,7 @@ public class DynmapPlugin extends JavaPlugin {
if (configuration.getNode("web").getBoolean("allowwebchat", false)) { if (configuration.getNode("web").getBoolean("allowwebchat", false)) {
SendMessageHandler messageHandler = new SendMessageHandler() {{ SendMessageHandler messageHandler = new SendMessageHandler() {{
maximumMessageInterval = (configuration.getNode("web").getInt("webchat-interval", 1) * 1000); maximumMessageInterval = (configuration.getNode("web").getInt("webchat-interval", 1) * 1000);
spamMessage = "\""+configuration.getNode("web").getString("spammessage", "You may only chat once every %interval% seconds.")+"\""; spamMessage = "\""+configuration.getNode("web").getString("spammessage", "You may only chat once every %interval% seconds.")+"\"";
onMessageReceived.addListener(new Listener<SendMessageHandler.Message>() { onMessageReceived.addListener(new Listener<SendMessageHandler.Message>() {
@Override @Override
public void triggered(Message t) { public void triggered(Message t) {
@ -319,11 +319,11 @@ public class DynmapPlugin extends JavaPlugin {
} }
} else if (c.equals("hide")) { } else if (c.equals("hide")) {
if (args.length == 1) { if (args.length == 1) {
if(player != null && checkPlayerPermission(sender,"hide.self")) { if(player != null && checkPlayerPermission(sender,"hide.self")) {
playerList.setVisible(player.getName(),false); playerList.setVisible(player.getName(),false);
sender.sendMessage("You are now hidden on Dynmap."); sender.sendMessage("You are now hidden on Dynmap.");
return true; return true;
} }
} else if (checkPlayerPermission(sender,"hide.others")) { } else if (checkPlayerPermission(sender,"hide.others")) {
for (int i = 1; i < args.length; i++) { for (int i = 1; i < args.length; i++) {
playerList.setVisible(args[i],false); playerList.setVisible(args[i],false);
@ -333,11 +333,11 @@ public class DynmapPlugin extends JavaPlugin {
} }
} else if (c.equals("show")) { } else if (c.equals("show")) {
if (args.length == 1) { if (args.length == 1) {
if(player != null && checkPlayerPermission(sender,"show.self")) { if(player != null && checkPlayerPermission(sender,"show.self")) {
playerList.setVisible(player.getName(),true); playerList.setVisible(player.getName(),true);
sender.sendMessage("You are now visible on Dynmap."); sender.sendMessage("You are now visible on Dynmap.");
return true; return true;
} }
} else if (checkPlayerPermission(sender,"show.others")) { } else if (checkPlayerPermission(sender,"show.others")) {
for (int i = 1; i < args.length; i++) { for (int i = 1; i < args.length; i++) {
playerList.setVisible(args[i],true); playerList.setVisible(args[i],true);
@ -362,15 +362,15 @@ public class DynmapPlugin extends JavaPlugin {
return false; return false;
} }
private boolean checkPlayerPermission(CommandSender sender, String permission) { private boolean checkPlayerPermission(CommandSender sender, String permission) {
if (!(sender instanceof Player)) { if (!(sender instanceof Player)) {
return true; return true;
} else if (!permissions.has(sender, permission.toLowerCase())) { } else if (!permissions.has(sender, permission.toLowerCase())) {
sender.sendMessage("You don't have permission to use this command!"); sender.sendMessage("You don't have permission to use this command!");
return false; return false;
} }
return true; return true;
} }
private void jsonConfig() { private void jsonConfig() {
File outputFile; File outputFile;

View File

@ -31,7 +31,7 @@ class JsonTimerTask extends TimerTask {
private Server server; private Server server;
private MapManager mapManager; private MapManager mapManager;
private Configuration configuration; private Configuration configuration;
private ConfigurationNode regions; private ConfigurationNode regions;
private static final JSONParser parser = new JSONParser(); private static final JSONParser parser = new JSONParser();
private long lastTimestamp = 0; private long lastTimestamp = 0;
@ -40,14 +40,13 @@ class JsonTimerTask extends TimerTask {
this.server = this.plugin.getServer(); this.server = this.plugin.getServer();
this.mapManager = this.plugin.getMapManager(); this.mapManager = this.plugin.getMapManager();
this.configuration = config; this.configuration = config;
//this.regions = configuration.getNode("web").getNode("components").getNode("regions"); //this.regions = configuration.getNode("web").getNode("components").getNode("regions");
System.out.println(); System.out.println();
for(ConfigurationNode type : configuration.getNodeList("web.components", null)) for(ConfigurationNode type : configuration.getNodeList("web.components", null))
if(type.getString("type").equalsIgnoreCase("regions")) if(type.getString("type").equalsIgnoreCase("regions")) {
{ this.regions = type;
this.regions = type; break;
break; }
}
} }
public void run() { public void run() {
@ -89,9 +88,9 @@ class JsonTimerTask extends TimerTask {
//Handles Updates //Handles Updates
for (World world : this.server.getWorlds()) { for (World world : this.server.getWorlds()) {
//Parse region file for multi world style //Parse region file for multi world style
if(regions.getBoolean("useworldpath", false)) if(regions.getBoolean("useworldpath", false))
parseRegionFile(world.getName() + "/" + regions.getString("filename", "regions.yml"), regions.getString("filename", "regions.yml").replace(".", "_" + world.getName() + ".yml")); parseRegionFile(world.getName() + "/" + regions.getString("filename", "regions.yml"), regions.getString("filename", "regions.yml").replace(".", "_" + world.getName() + ".yml"));
current = System.currentTimeMillis(); current = System.currentTimeMillis();
@ -128,47 +127,47 @@ class JsonTimerTask extends TimerTask {
} }
lastTimestamp = System.currentTimeMillis(); lastTimestamp = System.currentTimeMillis();
//Parse regions file for non worlds style //Parse regions file for non worlds style
if (!regions.getBoolean("useworldpath", false)) if (!regions.getBoolean("useworldpath", false))
parseRegionFile(regions.getString("filename", "regions.yml"), regions.getString("filename", "regions.yml")); parseRegionFile(regions.getString("filename", "regions.yml"), regions.getString("filename", "regions.yml"));
} }
//handles parsing and writing region json files //handles parsing and writing region json files
private void parseRegionFile(String regionFile, String outputFileName) private void parseRegionFile(String regionFile, String outputFileName)
{ {
File outputFile; File outputFile;
Configuration regionConfig = null; Configuration regionConfig = null;
if(regions.getBoolean("useworldpath", false)) if(regions.getBoolean("useworldpath", false))
{ {
if(new File("plugins/"+regions.getString("name", "WorldGuard"), regionFile).exists()) if(new File("plugins/"+regions.getString("name", "WorldGuard"), regionFile).exists())
regionConfig = new Configuration(new File("plugins/"+regions.getString("name", "WorldGuard"), regionFile)); regionConfig = new Configuration(new File("plugins/"+regions.getString("name", "WorldGuard"), regionFile));
else if(new File("plugins/"+regions.getString("name", "WorldGuard")+"/worlds", regionFile).exists()) else if(new File("plugins/"+regions.getString("name", "WorldGuard")+"/worlds", regionFile).exists())
regionConfig = new Configuration(new File("plugins/"+regions.getString("name", "WorldGuard")+"/worlds", regionFile)); regionConfig = new Configuration(new File("plugins/"+regions.getString("name", "WorldGuard")+"/worlds", regionFile));
} }
else else
regionConfig = new Configuration(new File("plugins/"+regions.getString("name", "WorldGuard"), regionFile)); regionConfig = new Configuration(new File("plugins/"+regions.getString("name", "WorldGuard"), regionFile));
//File didn't exist //File didn't exist
if(regionConfig == null) if(regionConfig == null)
return; return;
regionConfig.load(); regionConfig.load();
outputFileName = outputFileName.substring(0, outputFileName.lastIndexOf("."))+".json"; outputFileName = outputFileName.substring(0, outputFileName.lastIndexOf("."))+".json";
File webWorldPath = new File(this.configuration.getString("webpath", "web")+"/standalone/", outputFileName); File webWorldPath = new File(this.configuration.getString("webpath", "web")+"/standalone/", outputFileName);
Map<?, ?> regionData = (Map<?, ?>) regionConfig.getProperty(regions.getString("basenode", "regions")); Map<?, ?> regionData = (Map<?, ?>) regionConfig.getProperty(regions.getString("basenode", "regions"));
if (webWorldPath.isAbsolute()) if (webWorldPath.isAbsolute())
outputFile = webWorldPath; outputFile = webWorldPath;
else { else {
outputFile = new File(plugin.getDataFolder(), webWorldPath.toString()); outputFile = new File(plugin.getDataFolder(), webWorldPath.toString());
} }
try { try {
FileOutputStream fos = new FileOutputStream(outputFile); FileOutputStream fos = new FileOutputStream(outputFile);
fos.write(Json.stringifyJson(regionData).getBytes()); fos.write(Json.stringifyJson(regionData).getBytes());
fos.close(); fos.close();
} catch (FileNotFoundException ex) { } catch (FileNotFoundException ex) {
log.log(Level.SEVERE, "Exception while writing JSON-file.", ex); log.log(Level.SEVERE, "Exception while writing JSON-file.", ex);
} catch (IOException ioe) { } catch (IOException ioe) {
log.log(Level.SEVERE, "Exception while writing JSON-file.", ioe); log.log(Level.SEVERE, "Exception while writing JSON-file.", ioe);
} }
} }
} }

View File

@ -24,7 +24,7 @@ public class SendMessageHandler implements HttpHandler {
public Event<Message> onMessageReceived = new Event<SendMessageHandler.Message>(); public Event<Message> onMessageReceived = new Event<SendMessageHandler.Message>();
public int maximumMessageInterval = 1000; public int maximumMessageInterval = 1000;
public String spamMessage = "\"You may only chat once every %interval% seconds.\""; public String spamMessage = "\"You may only chat once every %interval% seconds.\"";
private HashMap<String, WebUser> disallowedUsers = new HashMap<String, WebUser>(); private HashMap<String, WebUser> disallowedUsers = new HashMap<String, WebUser>();
private LinkedList<WebUser> disallowedUserQueue = new LinkedList<WebUser>(); private LinkedList<WebUser> disallowedUserQueue = new LinkedList<WebUser>();
private Object disallowedUsersLock = new Object(); private Object disallowedUsersLock = new Object();