mirror of
https://github.com/ME1312/SubServers-2.git
synced 2025-02-16 19:51:26 +01:00
Shorten client's data folder name
This commit is contained in:
parent
51e83f4fb0
commit
b6a66cfb3b
@ -42,6 +42,7 @@ import static net.ME1312.SubServers.Client.Bukkit.Library.AccessMode.*;
|
|||||||
public final class SubPlugin extends JavaPlugin {
|
public final class SubPlugin extends JavaPlugin {
|
||||||
HashMap<Integer, SubDataClient> subdata = new HashMap<Integer, SubDataClient>();
|
HashMap<Integer, SubDataClient> subdata = new HashMap<Integer, SubDataClient>();
|
||||||
Pair<Long, Map<String, Map<String, String>>> lang = null;
|
Pair<Long, Map<String, Map<String, String>>> lang = null;
|
||||||
|
private UniversalFile dir;
|
||||||
public YAMLConfig config;
|
public YAMLConfig config;
|
||||||
public SubProtocol subprotocol;
|
public SubProtocol subprotocol;
|
||||||
|
|
||||||
@ -66,13 +67,12 @@ public final class SubPlugin extends JavaPlugin {
|
|||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
try {
|
try {
|
||||||
Bukkit.getLogger().info("SubServers > Loading SubServers.Client.Bukkit v" + version.toString() + " Libraries (for Minecraft " + api.getGameVersion() + ")");
|
Bukkit.getLogger().info("SubServers > Loading SubServers.Client.Bukkit v" + version.toString() + " Libraries (for Minecraft " + api.getGameVersion() + ")");
|
||||||
getDataFolder().mkdirs();
|
dir = new UniversalFile(getDataFolder().getParentFile(), "SubServers-Client");
|
||||||
if (new UniversalFile(getDataFolder().getParentFile(), "SubServers-Client:config.yml").exists()) {
|
if (getDataFolder().exists()) {
|
||||||
Files.move(new UniversalFile(getDataFolder().getParentFile(), "SubServers-Client:config.yml").toPath(), new UniversalFile(getDataFolder(), "config.yml").toPath(), StandardCopyOption.REPLACE_EXISTING);
|
Files.move(getDataFolder().toPath(), dir.toPath(), StandardCopyOption.REPLACE_EXISTING);
|
||||||
Util.deleteDirectory(new UniversalFile(getDataFolder().getParentFile(), "SubServers-Client"));
|
} else dir.mkdirs();
|
||||||
}
|
ConfigUpdater.updateConfig(new UniversalFile(dir, "config.yml"));
|
||||||
ConfigUpdater.updateConfig(new UniversalFile(getDataFolder(), "config.yml"));
|
config = new YAMLConfig(new UniversalFile(dir, "config.yml"));
|
||||||
config = new YAMLConfig(new UniversalFile(getDataFolder(), "config.yml"));
|
|
||||||
if (new UniversalFile(new File(System.getProperty("user.dir")), "subdata.json").exists()) {
|
if (new UniversalFile(new File(System.getProperty("user.dir")), "subdata.json").exists()) {
|
||||||
FileReader reader = new FileReader(new UniversalFile(new File(System.getProperty("user.dir")), "subdata.json"));
|
FileReader reader = new FileReader(new UniversalFile(new File(System.getProperty("user.dir")), "subdata.json"));
|
||||||
config.get().getMap("Settings").set("SubData", new YAMLSection(parseJSON(Util.readAll(reader))));
|
config.get().getMap("Settings").set("SubData", new YAMLSection(parseJSON(Util.readAll(reader))));
|
||||||
@ -81,8 +81,8 @@ public final class SubPlugin extends JavaPlugin {
|
|||||||
new UniversalFile(new File(System.getProperty("user.dir")), "subdata.json").delete();
|
new UniversalFile(new File(System.getProperty("user.dir")), "subdata.json").delete();
|
||||||
}
|
}
|
||||||
if (new UniversalFile(new File(System.getProperty("user.dir")), "subdata.rsa.key").exists()) {
|
if (new UniversalFile(new File(System.getProperty("user.dir")), "subdata.rsa.key").exists()) {
|
||||||
if (new UniversalFile(getDataFolder(), "subdata.rsa.key").exists()) new UniversalFile(getDataFolder(), "subdata.rsa.key").delete();
|
if (new UniversalFile(dir, "subdata.rsa.key").exists()) new UniversalFile(dir, "subdata.rsa.key").delete();
|
||||||
Files.move(new UniversalFile(new File(System.getProperty("user.dir")), "subdata.rsa.key").toPath(), new UniversalFile(getDataFolder(), "subdata.rsa.key").toPath());
|
Files.move(new UniversalFile(new File(System.getProperty("user.dir")), "subdata.rsa.key").toPath(), new UniversalFile(dir, "subdata.rsa.key").toPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
|
getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
|
||||||
@ -103,9 +103,9 @@ public final class SubPlugin extends JavaPlugin {
|
|||||||
|
|
||||||
System.out.println("SubData > AES Encryption Available");
|
System.out.println("SubData > AES Encryption Available");
|
||||||
}
|
}
|
||||||
if (new UniversalFile(getDataFolder(), "subdata.rsa.key").exists()) {
|
if (new UniversalFile(dir, "subdata.rsa.key").exists()) {
|
||||||
try {
|
try {
|
||||||
subprotocol.registerCipher("RSA", new RSA(new UniversalFile(getDataFolder(), "subdata.rsa.key")));
|
subprotocol.registerCipher("RSA", new RSA(new UniversalFile(dir, "subdata.rsa.key")));
|
||||||
System.out.println("SubData > RSA Encryption Available");
|
System.out.println("SubData > RSA Encryption Available");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -157,7 +157,7 @@ public final class SubPlugin extends JavaPlugin {
|
|||||||
public void reload(boolean notifyPlugins) throws IOException {
|
public void reload(boolean notifyPlugins) throws IOException {
|
||||||
resetDate = Calendar.getInstance().getTime().getTime();
|
resetDate = Calendar.getInstance().getTime().getTime();
|
||||||
|
|
||||||
ConfigUpdater.updateConfig(new UniversalFile(getDataFolder(), "config.yml"));
|
ConfigUpdater.updateConfig(new UniversalFile(dir, "config.yml"));
|
||||||
config.reload();
|
config.reload();
|
||||||
|
|
||||||
if (notifyPlugins) {
|
if (notifyPlugins) {
|
||||||
|
@ -57,7 +57,8 @@ public final class SubPlugin {
|
|||||||
public SubProtocol subprotocol;
|
public SubProtocol subprotocol;
|
||||||
|
|
||||||
@ConfigDir(sharedRoot = false)
|
@ConfigDir(sharedRoot = false)
|
||||||
@Inject public File dir;
|
@Inject public File xdir;
|
||||||
|
public UniversalFile dir;
|
||||||
public Logger log = LoggerFactory.getLogger("SubServers");
|
public Logger log = LoggerFactory.getLogger("SubServers");
|
||||||
public UIHandler gui = null;
|
public UIHandler gui = null;
|
||||||
public Version version;
|
public Version version;
|
||||||
@ -86,11 +87,10 @@ public final class SubPlugin {
|
|||||||
api = new SubAPI(this);
|
api = new SubAPI(this);
|
||||||
try {
|
try {
|
||||||
log.info("Loading SubServers.Client.Sponge v" + version.toString() + " Libraries (for Minecraft " + api.getGameVersion() + ")");
|
log.info("Loading SubServers.Client.Sponge v" + version.toString() + " Libraries (for Minecraft " + api.getGameVersion() + ")");
|
||||||
dir.mkdirs();
|
dir = new UniversalFile(xdir.getParentFile(), "subservers-client");
|
||||||
if (new UniversalFile(dir.getParentFile(), "SubServers-Client:config.yml").exists()) {
|
if (xdir.exists()) {
|
||||||
Files.move(new UniversalFile(dir.getParentFile(), "SubServers-Client:config.yml").toPath(), new UniversalFile(dir, "config.yml").toPath(), StandardCopyOption.REPLACE_EXISTING);
|
Files.move(xdir.toPath(), dir.toPath(), StandardCopyOption.REPLACE_EXISTING);
|
||||||
Util.deleteDirectory(new UniversalFile(dir.getParentFile(), "SubServers-Client"));
|
} else dir.mkdirs();
|
||||||
}
|
|
||||||
ConfigUpdater.updateConfig(new UniversalFile(dir, "config.yml"));
|
ConfigUpdater.updateConfig(new UniversalFile(dir, "config.yml"));
|
||||||
config = new YAMLConfig(new UniversalFile(dir, "config.yml"));
|
config = new YAMLConfig(new UniversalFile(dir, "config.yml"));
|
||||||
if (new UniversalFile(new File(System.getProperty("user.dir")), "subdata.json").exists()) {
|
if (new UniversalFile(new File(System.getProperty("user.dir")), "subdata.json").exists()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user