Create separate module for configs

This commit is contained in:
filoghost 2018-08-31 17:40:22 +02:00
parent 137d23b408
commit ff5ca5dddb
19 changed files with 59 additions and 11 deletions

37
Config/pom.xml Normal file
View File

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.gmail.filoghost.holographicdisplays</groupId>
<artifactId>holographicdisplays-parent</artifactId>
<version>2.3.0-SNAPSHOT</version>
</parent>
<artifactId>holographicdisplays-config</artifactId>
<name>HolographicDisplays Config</name>
<repositories>
<repository>
<id>elmakers-repo</id>
<url>http://maven.elmakers.com/repository/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>holographicdisplays-utils</artifactId>
<version>2.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>${spigot-api.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

View File

@ -14,7 +14,6 @@ import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.Plugin;
import com.gmail.filoghost.holographicdisplays.bridge.bungeecord.serverpinger.ServerAddress;
import com.gmail.filoghost.holographicdisplays.util.ConsoleLogger;
import com.gmail.filoghost.holographicdisplays.util.Utils;

View File

@ -1,4 +1,4 @@
package com.gmail.filoghost.holographicdisplays.bridge.bungeecord.serverpinger;
package com.gmail.filoghost.holographicdisplays.disk;
public class ServerAddress {

View File

@ -42,6 +42,12 @@
<version>2.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>holographicdisplays-config</artifactId>
<version>2.3.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>holographicdisplays-nms-interfaces</artifactId>

View File

@ -1,5 +1,6 @@
package com.gmail.filoghost.holographicdisplays;
import java.io.File;
import java.util.Set;
import java.util.logging.Level;
import java.util.regex.Matcher;
@ -302,4 +303,9 @@ public class HolographicDisplays extends JavaPlugin {
return protocolLibHook;
}
public static boolean isConfigFile(File file) {
return file.getName().toLowerCase().endsWith(".yml") && instance.getResource(file.getName()) != null;
}
}

View File

@ -12,10 +12,10 @@ import org.bukkit.Bukkit;
import org.bukkit.scheduler.BukkitRunnable;
import com.gmail.filoghost.holographicdisplays.HolographicDisplays;
import com.gmail.filoghost.holographicdisplays.bridge.bungeecord.serverpinger.ServerAddress;
import com.gmail.filoghost.holographicdisplays.bridge.bungeecord.serverpinger.ServerPinger;
import com.gmail.filoghost.holographicdisplays.bridge.bungeecord.serverpinger.PingResponse;
import com.gmail.filoghost.holographicdisplays.bridge.bungeecord.serverpinger.ServerPinger;
import com.gmail.filoghost.holographicdisplays.disk.Configuration;
import com.gmail.filoghost.holographicdisplays.disk.ServerAddress;
import com.gmail.filoghost.holographicdisplays.util.ConsoleLogger;
public class BungeeServerTracker {

View File

@ -6,6 +6,7 @@ import java.util.logging.Level;
import org.json.simple.JSONObject;
import org.json.simple.JSONValue;
import com.gmail.filoghost.holographicdisplays.disk.ServerAddress;
import com.gmail.filoghost.holographicdisplays.util.ConsoleLogger;
public class PingResponse

View File

@ -8,6 +8,8 @@ import java.net.Socket;
import java.net.SocketTimeoutException;
import java.net.UnknownHostException;
import com.gmail.filoghost.holographicdisplays.disk.ServerAddress;
public class ServerPinger {
public static PingResponse fetchData(final ServerAddress serverAddress, int timeout) throws SocketTimeoutException, UnknownHostException, IOException, Exception {

View File

@ -89,7 +89,7 @@ public class ReadimageCommand extends HologramSubCommand {
File targetImage = new File(HolographicDisplays.getInstance().getDataFolder(), fileName);
CommandValidator.isTrue(FileUtils.isParentFolder(HolographicDisplays.getInstance().getDataFolder(), targetImage), "The image must be inside HolographicDisplays' folder.");
CommandValidator.isTrue(!FileUtils.isConfigFile(targetImage), "Cannot read default configuration files.");
CommandValidator.isTrue(!HolographicDisplays.isConfigFile(targetImage), "Cannot read default configuration files.");
image = FileUtils.readImage(targetImage);
}

View File

@ -49,7 +49,7 @@ public class ReadtextCommand extends HologramSubCommand {
String fileName = args[1];
File targetFile = new File(HolographicDisplays.getInstance().getDataFolder(), fileName);
CommandValidator.isTrue(FileUtils.isParentFolder(HolographicDisplays.getInstance().getDataFolder(), targetFile), "The file must be inside HolographicDisplays' folder.");
CommandValidator.isTrue(!FileUtils.isConfigFile(targetFile), "Cannot read default configuration files.");
CommandValidator.isTrue(!HolographicDisplays.isConfigFile(targetFile), "Cannot read default configuration files.");
List<String> lines = FileUtils.readLines(targetFile);
hologram.clearLines();

View File

@ -12,7 +12,6 @@ import java.util.List;
import javax.imageio.ImageIO;
import com.gmail.filoghost.holographicdisplays.HolographicDisplays;
import com.gmail.filoghost.holographicdisplays.exception.UnreadableImageException;
@ -91,7 +90,4 @@ public class FileUtils {
return false;
}
public static boolean isConfigFile(File file) {
return file.getName().toLowerCase().endsWith(".yml") && HolographicDisplays.getInstance().getResource(file.getName()) != null;
}
}

View File

@ -21,6 +21,7 @@
<module>API</module>
<module>JavaCompat</module>
<module>Utils</module>
<module>Config</module>
<module>NMS/Interfaces</module>
<module>NMS/v1_8_R1</module>
<module>NMS/v1_8_R2</module>