mirror of
https://github.com/webbukkit/dynmap.git
synced 2024-11-24 11:15:21 +01:00
Fixed tabs.
This commit is contained in:
parent
ff026e91b6
commit
be60623719
@ -136,7 +136,7 @@ public class DynmapPlugin extends JavaPlugin {
|
||||
if (configuration.getNode("web").getBoolean("allowwebchat", false)) {
|
||||
SendMessageHandler messageHandler = new SendMessageHandler() {{
|
||||
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>() {
|
||||
@Override
|
||||
public void triggered(Message t) {
|
||||
@ -319,11 +319,11 @@ public class DynmapPlugin extends JavaPlugin {
|
||||
}
|
||||
} else if (c.equals("hide")) {
|
||||
if (args.length == 1) {
|
||||
if(player != null && checkPlayerPermission(sender,"hide.self")) {
|
||||
playerList.setVisible(player.getName(),false);
|
||||
sender.sendMessage("You are now hidden on Dynmap.");
|
||||
return true;
|
||||
}
|
||||
if(player != null && checkPlayerPermission(sender,"hide.self")) {
|
||||
playerList.setVisible(player.getName(),false);
|
||||
sender.sendMessage("You are now hidden on Dynmap.");
|
||||
return true;
|
||||
}
|
||||
} else if (checkPlayerPermission(sender,"hide.others")) {
|
||||
for (int i = 1; i < args.length; i++) {
|
||||
playerList.setVisible(args[i],false);
|
||||
@ -333,11 +333,11 @@ public class DynmapPlugin extends JavaPlugin {
|
||||
}
|
||||
} else if (c.equals("show")) {
|
||||
if (args.length == 1) {
|
||||
if(player != null && checkPlayerPermission(sender,"show.self")) {
|
||||
playerList.setVisible(player.getName(),true);
|
||||
sender.sendMessage("You are now visible on Dynmap.");
|
||||
return true;
|
||||
}
|
||||
if(player != null && checkPlayerPermission(sender,"show.self")) {
|
||||
playerList.setVisible(player.getName(),true);
|
||||
sender.sendMessage("You are now visible on Dynmap.");
|
||||
return true;
|
||||
}
|
||||
} else if (checkPlayerPermission(sender,"show.others")) {
|
||||
for (int i = 1; i < args.length; i++) {
|
||||
playerList.setVisible(args[i],true);
|
||||
@ -362,15 +362,15 @@ public class DynmapPlugin extends JavaPlugin {
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean checkPlayerPermission(CommandSender sender, String permission) {
|
||||
if (!(sender instanceof Player)) {
|
||||
return true;
|
||||
} else if (!permissions.has(sender, permission.toLowerCase())) {
|
||||
sender.sendMessage("You don't have permission to use this command!");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
private boolean checkPlayerPermission(CommandSender sender, String permission) {
|
||||
if (!(sender instanceof Player)) {
|
||||
return true;
|
||||
} else if (!permissions.has(sender, permission.toLowerCase())) {
|
||||
sender.sendMessage("You don't have permission to use this command!");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void jsonConfig() {
|
||||
File outputFile;
|
||||
|
@ -31,7 +31,7 @@ class JsonTimerTask extends TimerTask {
|
||||
private Server server;
|
||||
private MapManager mapManager;
|
||||
private Configuration configuration;
|
||||
private ConfigurationNode regions;
|
||||
private ConfigurationNode regions;
|
||||
private static final JSONParser parser = new JSONParser();
|
||||
private long lastTimestamp = 0;
|
||||
|
||||
@ -40,14 +40,13 @@ class JsonTimerTask extends TimerTask {
|
||||
this.server = this.plugin.getServer();
|
||||
this.mapManager = this.plugin.getMapManager();
|
||||
this.configuration = config;
|
||||
//this.regions = configuration.getNode("web").getNode("components").getNode("regions");
|
||||
System.out.println();
|
||||
for(ConfigurationNode type : configuration.getNodeList("web.components", null))
|
||||
if(type.getString("type").equalsIgnoreCase("regions"))
|
||||
{
|
||||
this.regions = type;
|
||||
break;
|
||||
}
|
||||
//this.regions = configuration.getNode("web").getNode("components").getNode("regions");
|
||||
System.out.println();
|
||||
for(ConfigurationNode type : configuration.getNodeList("web.components", null))
|
||||
if(type.getString("type").equalsIgnoreCase("regions")) {
|
||||
this.regions = type;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void run() {
|
||||
@ -89,9 +88,9 @@ class JsonTimerTask extends TimerTask {
|
||||
|
||||
//Handles Updates
|
||||
for (World world : this.server.getWorlds()) {
|
||||
//Parse region file for multi world style
|
||||
if(regions.getBoolean("useworldpath", false))
|
||||
parseRegionFile(world.getName() + "/" + regions.getString("filename", "regions.yml"), regions.getString("filename", "regions.yml").replace(".", "_" + world.getName() + ".yml"));
|
||||
//Parse region file for multi world style
|
||||
if(regions.getBoolean("useworldpath", false))
|
||||
parseRegionFile(world.getName() + "/" + regions.getString("filename", "regions.yml"), regions.getString("filename", "regions.yml").replace(".", "_" + world.getName() + ".yml"));
|
||||
|
||||
current = System.currentTimeMillis();
|
||||
|
||||
@ -128,47 +127,47 @@ class JsonTimerTask extends TimerTask {
|
||||
}
|
||||
lastTimestamp = System.currentTimeMillis();
|
||||
|
||||
//Parse regions file for non worlds style
|
||||
if (!regions.getBoolean("useworldpath", false))
|
||||
parseRegionFile(regions.getString("filename", "regions.yml"), regions.getString("filename", "regions.yml"));
|
||||
//Parse regions file for non worlds style
|
||||
if (!regions.getBoolean("useworldpath", false))
|
||||
parseRegionFile(regions.getString("filename", "regions.yml"), regions.getString("filename", "regions.yml"));
|
||||
}
|
||||
|
||||
//handles parsing and writing region json files
|
||||
private void parseRegionFile(String regionFile, String outputFileName)
|
||||
{
|
||||
File outputFile;
|
||||
Configuration regionConfig = null;
|
||||
if(regions.getBoolean("useworldpath", false))
|
||||
{
|
||||
if(new File("plugins/"+regions.getString("name", "WorldGuard"), regionFile).exists())
|
||||
regionConfig = new Configuration(new File("plugins/"+regions.getString("name", "WorldGuard"), regionFile));
|
||||
else if(new File("plugins/"+regions.getString("name", "WorldGuard")+"/worlds", regionFile).exists())
|
||||
regionConfig = new Configuration(new File("plugins/"+regions.getString("name", "WorldGuard")+"/worlds", regionFile));
|
||||
}
|
||||
else
|
||||
regionConfig = new Configuration(new File("plugins/"+regions.getString("name", "WorldGuard"), regionFile));
|
||||
//File didn't exist
|
||||
if(regionConfig == null)
|
||||
return;
|
||||
regionConfig.load();
|
||||
//handles parsing and writing region json files
|
||||
private void parseRegionFile(String regionFile, String outputFileName)
|
||||
{
|
||||
File outputFile;
|
||||
Configuration regionConfig = null;
|
||||
if(regions.getBoolean("useworldpath", false))
|
||||
{
|
||||
if(new File("plugins/"+regions.getString("name", "WorldGuard"), regionFile).exists())
|
||||
regionConfig = new Configuration(new File("plugins/"+regions.getString("name", "WorldGuard"), regionFile));
|
||||
else if(new File("plugins/"+regions.getString("name", "WorldGuard")+"/worlds", regionFile).exists())
|
||||
regionConfig = new Configuration(new File("plugins/"+regions.getString("name", "WorldGuard")+"/worlds", regionFile));
|
||||
}
|
||||
else
|
||||
regionConfig = new Configuration(new File("plugins/"+regions.getString("name", "WorldGuard"), regionFile));
|
||||
//File didn't exist
|
||||
if(regionConfig == null)
|
||||
return;
|
||||
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);
|
||||
Map<?, ?> regionData = (Map<?, ?>) regionConfig.getProperty(regions.getString("basenode", "regions"));
|
||||
if (webWorldPath.isAbsolute())
|
||||
outputFile = webWorldPath;
|
||||
else {
|
||||
outputFile = new File(plugin.getDataFolder(), webWorldPath.toString());
|
||||
}
|
||||
try {
|
||||
FileOutputStream fos = new FileOutputStream(outputFile);
|
||||
fos.write(Json.stringifyJson(regionData).getBytes());
|
||||
fos.close();
|
||||
} catch (FileNotFoundException ex) {
|
||||
log.log(Level.SEVERE, "Exception while writing JSON-file.", ex);
|
||||
} catch (IOException ioe) {
|
||||
log.log(Level.SEVERE, "Exception while writing JSON-file.", ioe);
|
||||
}
|
||||
}
|
||||
File webWorldPath = new File(this.configuration.getString("webpath", "web")+"/standalone/", outputFileName);
|
||||
Map<?, ?> regionData = (Map<?, ?>) regionConfig.getProperty(regions.getString("basenode", "regions"));
|
||||
if (webWorldPath.isAbsolute())
|
||||
outputFile = webWorldPath;
|
||||
else {
|
||||
outputFile = new File(plugin.getDataFolder(), webWorldPath.toString());
|
||||
}
|
||||
try {
|
||||
FileOutputStream fos = new FileOutputStream(outputFile);
|
||||
fos.write(Json.stringifyJson(regionData).getBytes());
|
||||
fos.close();
|
||||
} catch (FileNotFoundException ex) {
|
||||
log.log(Level.SEVERE, "Exception while writing JSON-file.", ex);
|
||||
} catch (IOException ioe) {
|
||||
log.log(Level.SEVERE, "Exception while writing JSON-file.", ioe);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ public class SendMessageHandler implements HttpHandler {
|
||||
public Event<Message> onMessageReceived = new Event<SendMessageHandler.Message>();
|
||||
|
||||
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 LinkedList<WebUser> disallowedUserQueue = new LinkedList<WebUser>();
|
||||
private Object disallowedUsersLock = new Object();
|
||||
|
Loading…
Reference in New Issue
Block a user