mirror of
https://github.com/ME1312/SubServers-2.git
synced 2024-11-22 18:26:06 +01:00
Correct config loading issue
This solves a 'file in use' error on windows
This commit is contained in:
parent
ada14c0889
commit
c9afe48674
317
Artifacts/Download/index.html
Normal file
317
Artifacts/Download/index.html
Normal file
@ -0,0 +1,317 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
</head>
|
||||
<body>
|
||||
<style>
|
||||
* {
|
||||
font-family: Avenir;
|
||||
}
|
||||
|
||||
html {
|
||||
min-height: 100%;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
body {
|
||||
background-color: #EEE;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
margin: 0px !important;
|
||||
}
|
||||
|
||||
.app-version > span.short {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.page .page-title {
|
||||
display: table;
|
||||
vertical-align: middle;
|
||||
margin: 0.83em auto;
|
||||
margin-bottom: 0px;
|
||||
font-size: 1.5em;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.page .page-subtitle {
|
||||
display: block;
|
||||
margin: 0px;
|
||||
margin-right: 12px;
|
||||
font-size: 0.5em;
|
||||
color: #777;
|
||||
font-weight: normal;
|
||||
font-style: italic;
|
||||
text-align: right;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.page a.page-subtitle:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.page .options {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.page .options > .desktop-spacer {
|
||||
flex-basis: 25%;
|
||||
}
|
||||
|
||||
.page .options > div-option {
|
||||
padding: 25px;
|
||||
flex-basis: 100%;
|
||||
border-right: 2px solid #CCC;
|
||||
}
|
||||
|
||||
.page .options > div-option:last-of-type {
|
||||
border-right: none;
|
||||
}
|
||||
|
||||
.page .options > div-option > form > input,
|
||||
.page .options > div-option > form > button,
|
||||
.page .options > div-option > form > a,
|
||||
.page .options > div-option > button,
|
||||
.page .options > div-option > a {
|
||||
display: inline-block;
|
||||
padding: 4px 12px;
|
||||
text-decoration: none;
|
||||
text-transform: uppercase;
|
||||
border: none;
|
||||
-webkit-box-shadow: 1px 1px 4px rgba(0,0,0,0.4);
|
||||
box-shadow: 1px 1px 4px rgba(0,0,0,0.4);
|
||||
-webkit-transition: all 0.4s;
|
||||
-o-transition: all 0.4s;
|
||||
transition: all 0.4s;
|
||||
font-size: 1.125em;
|
||||
}
|
||||
|
||||
.page .options > div-option > form > input {
|
||||
padding-left: 0px;
|
||||
padding-right: 0px;
|
||||
}
|
||||
|
||||
.page .options > .option-1 > a {
|
||||
color: #ffffff;
|
||||
background-color: #4caf50;
|
||||
border-color: transparent
|
||||
}
|
||||
|
||||
.page .options > .option-1 > a:hover {
|
||||
background-color: #3d8b40;
|
||||
border-color: rgba(0,0,0,0);
|
||||
}
|
||||
|
||||
.page .options > .option-2 {
|
||||
padding-top: 23px;
|
||||
}
|
||||
|
||||
.page .options > .option-2 > form {
|
||||
display: inline-block;
|
||||
border-bottom: 2px solid #CCC;
|
||||
box-sizing: border-box;
|
||||
font-size: 1.125em;
|
||||
}
|
||||
|
||||
.page .options > .option-2 > form > input {
|
||||
background-color: transparent;
|
||||
border: none;
|
||||
height: 100%;
|
||||
padding-top: 2px;
|
||||
padding-bottom: 2px;
|
||||
outline: none;
|
||||
-webkit-box-shadow: none;
|
||||
-moz-box-shadow: none;
|
||||
box-shadow: none;
|
||||
font-size: 1em;
|
||||
}
|
||||
|
||||
.page .options > .option-2 > form > input:focus {
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.page .options > .option-2 > button {
|
||||
color: #fff;
|
||||
background-color: #0d87e9;
|
||||
border-color: #2e6da4;
|
||||
cursor:pointer;
|
||||
font-size: 1em;
|
||||
}
|
||||
|
||||
.page .options > .option-2 > button:hover {
|
||||
background-color: #337ab7;
|
||||
}
|
||||
|
||||
.page .options > .option-3 > a {
|
||||
color: #fff;
|
||||
background-color: #f0ad4e;
|
||||
border-color: #eea236;
|
||||
}
|
||||
|
||||
.page .options > .option-3 > a:hover {
|
||||
color: #fff;
|
||||
background-color: #ec971f;
|
||||
border-color: #d58512;
|
||||
}
|
||||
|
||||
.page .options > div-option > span {
|
||||
color: #777;
|
||||
font-size: 0.8em;
|
||||
}
|
||||
|
||||
.footer {
|
||||
margin-bottom: 0px;
|
||||
padding: 8px;
|
||||
padding-top: 0px;
|
||||
position: absolute;
|
||||
bottom: 0px;
|
||||
left: 0px;
|
||||
right: 0px;
|
||||
}
|
||||
|
||||
.footer > div {
|
||||
height: 32px;
|
||||
float: right;
|
||||
}
|
||||
|
||||
.footer img {
|
||||
height: 32px;
|
||||
float: left;
|
||||
}
|
||||
|
||||
.footer > div > a {
|
||||
padding-left: 8px;
|
||||
padding-right: 8px;
|
||||
vertical-align: middle;
|
||||
line-height: 32px;
|
||||
font-size: 14px;
|
||||
color: #333;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.footer > div > a:hover,
|
||||
.footer > div > a:active {
|
||||
color: #555;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
@media only screen and (max-width:875px),
|
||||
only screen and (max-height:475px) {
|
||||
.app-version > span.full {
|
||||
display: none;
|
||||
}
|
||||
.app-version > span.short {
|
||||
display: inline;
|
||||
}
|
||||
.page .options {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.page .options > .desktop-spacer {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.page .options > div-option {
|
||||
display: block;
|
||||
padding: 25px 0px;
|
||||
margin: 0px 25px;
|
||||
border-right: none;
|
||||
border-bottom: 2px solid #CCC;
|
||||
}
|
||||
|
||||
.page .options > div-option:last-of-type {
|
||||
border-bottom: none;
|
||||
}
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: Avenir;
|
||||
src: url("https://raw.githubusercontent.com/ME1312/SubServers-2/master/SubServers.Bungee/Avenir-Book.ttf");
|
||||
}
|
||||
</style>
|
||||
<div class="download"><center>
|
||||
<div class="page">
|
||||
<span class="page-title">You're about to download <span class="full-app-name"><unknown></span><br><a class="page-subtitle" href="%commit_source%" target="_blank">from commit <span class="app-version"><unknown></span></a></span><hr>
|
||||
Thank you for downloading <span class="app-name"><unknown></span>. Choose how you would like to get your file:<br><br>
|
||||
<div class="options">
|
||||
<div class="desktop-spacer"></div>
|
||||
<div-option class="option-1">
|
||||
<a href="%adfly_app_download%">Watch a quick ad</a>
|
||||
<br><span>through adf.ly</span>
|
||||
<p>It only takes 5 seconds to support the developer these days. Then we'll take you straight to your download.</p>
|
||||
</div-option>
|
||||
<div-option class="option-2">
|
||||
<form id="option-2" action="https://www.paypal.com/cgi-bin/webscr" method="get" target="_blank"><!--
|
||||
--><input type="hidden" name="cmd" value="_xclick" /><!--
|
||||
--><input type="hidden" name="business" value="ECL5BPVRT5ANA" /><!--
|
||||
--><input type="hidden" name="lc" value="US" /><!--
|
||||
--><input type="hidden" name="item_name" value="Donation" /><!--
|
||||
-->$<input type="number" name="amount" min="1" value="15" max="9999" /><!--
|
||||
--><input type="hidden" name="currency_code" value="USD" /><!--
|
||||
--><input type="hidden" name="button_subtype" value="services" /><!--
|
||||
--><input type="hidden" name="bn" value="PP%2dBuyNowBF%3abtn_buynowCC_LG%2egif%3aNonHosted" /><!--
|
||||
--></form><button type="submit" form="option-2">Donate</button>
|
||||
<br><span>and download after</span>
|
||||
<p>I'd appreciate any donation, even if it's just a dollar.</p>
|
||||
</div-option>
|
||||
<div-option class="option-3">
|
||||
<a download="%" href="%app_download%" draggable="true">Direct Download</a>
|
||||
<br><span>SubServers is always free to use</span>
|
||||
<p>You don't have to do that stuff to use SubServers, but it's always appreciated.</p>
|
||||
</div-option>
|
||||
<div class="desktop-spacer"></div>
|
||||
</div>
|
||||
</div>
|
||||
</center></div>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<div class="footer">
|
||||
<hr>
|
||||
<a href="javascript:void(0)"><img src="https://src.ME1312.net/img/me1312.net.inverted.png" /></a>
|
||||
<div><a href="https://github.com/ME1312/SubServers-2/tree/master/Artifacts" target="_blank">Download not working?</a></div>
|
||||
</div>
|
||||
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
|
||||
<script>
|
||||
var hash = getHash();
|
||||
function getHash() {
|
||||
var hash = window.location.hash.substring(1);
|
||||
var params = {}
|
||||
hash.split('&').map(hk => {
|
||||
let temp = hk.split('=');
|
||||
params[temp[0]] = temp[1]
|
||||
});
|
||||
return params;
|
||||
}
|
||||
if (hash.hasOwnProperty("app")) {
|
||||
$('.full-app-name').html(hash.app)
|
||||
$('.app-name').html(hash.app.replace(/^(.+?)\.([^.]*)$/, '$1'));
|
||||
if (hash.hasOwnProperty("commit")) {
|
||||
$('.app-version').html('<span class="full">' + hash.commit + '</span><span class="short">' + hash.commit.substring(0, 7) + '</span>');
|
||||
$('a').each(function() {
|
||||
var a = $(this);
|
||||
if (a.attr('download') == '%')
|
||||
a.attr('download', hash.app);
|
||||
switch (a.attr("href").toLowerCase()) {
|
||||
case "%adfly_app_download%":
|
||||
a.attr("href", "https://adf.ly/18562515/raw.githubusercontent.com/ME1312/SubServers-2/" + hash.commit + "/Artifacts/" + hash.app);
|
||||
break;
|
||||
case "%app_download%":
|
||||
a.attr("href", "https://raw.githubusercontent.com/ME1312/SubServers-2/" + hash.commit + "/Artifacts/" + hash.app);
|
||||
break;
|
||||
case "%commit_page%":
|
||||
a.attr("href", "https://github.com/ME1312/SubServers-2/commit/" + hash.commit);
|
||||
break;
|
||||
case "%commit_source%":
|
||||
a.attr("href", "https://github.com/ME1312/SubServers-2/tree/" + hash.commit);
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -353,7 +353,9 @@ public class InternalSubCreator extends SubCreator {
|
||||
private void generateProperties(File dir, int port) throws IOException {
|
||||
File file = new File(dir, "server.properties");
|
||||
if (!file.exists()) file.createNewFile();
|
||||
String content = Util.readAll(new BufferedReader(new InputStreamReader(new FileInputStream(file)))).replace("server-port=", "server-port=" + port).replace("server-ip=", "server-ip=" + host.getAddress().getHostAddress());
|
||||
InputStream stream = new FileInputStream(file);
|
||||
String content = Util.readAll(new BufferedReader(new InputStreamReader(stream))).replace("server-port=", "server-port=" + port).replace("server-ip=", "server-ip=" + host.getAddress().getHostAddress());
|
||||
stream.close();
|
||||
file.delete();
|
||||
PrintWriter writer = new PrintWriter(file, "UTF-8");
|
||||
writer.write(content);
|
||||
|
@ -8,7 +8,6 @@ import org.yaml.snakeyaml.error.YAMLException;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* YAML Config Class
|
||||
@ -32,7 +31,9 @@ public class YAMLConfig {
|
||||
this.file = file;
|
||||
this.yaml = new Yaml(getDumperOptions());
|
||||
if (file.exists()) {
|
||||
this.config = new YAMLSection((LinkedHashMap<String, ?>) yaml.loadAs(new FileInputStream(file), LinkedHashMap.class), null, null, yaml);
|
||||
InputStream stream = new FileInputStream(file);
|
||||
this.config = new YAMLSection((LinkedHashMap<String, ?>) yaml.loadAs(stream, LinkedHashMap.class), null, null, yaml);
|
||||
stream.close();
|
||||
} else {
|
||||
this.config = new YAMLSection(null, null, null, yaml);
|
||||
}
|
||||
@ -65,7 +66,9 @@ public class YAMLConfig {
|
||||
@SuppressWarnings("unchecked")
|
||||
public void reload() throws IOException {
|
||||
if (file.exists()) {
|
||||
this.config = new YAMLSection((LinkedHashMap<String, ?>) yaml.loadAs(new FileInputStream(file), LinkedHashMap.class), null, null, yaml);
|
||||
InputStream stream = new FileInputStream(file);
|
||||
this.config = new YAMLSection((LinkedHashMap<String, ?>) yaml.loadAs(stream, LinkedHashMap.class), null, null, yaml);
|
||||
stream.close();
|
||||
} else {
|
||||
this.config = new YAMLSection(null, null, null, yaml);
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ public final class Util {
|
||||
*/
|
||||
public static <V> V getCaseInsensitively(Map<String, V> map, String key) {
|
||||
HashMap<String, String> insensitivity = new HashMap<String, String>();
|
||||
for (String item : map.keySet()) insensitivity.put(item.toLowerCase(), item);
|
||||
for (String item : map.keySet()) if (!insensitivity.keySet().contains(item.toLowerCase())) insensitivity.put(item.toLowerCase(), item);
|
||||
if (insensitivity.keySet().contains(key.toLowerCase())) {
|
||||
return map.get(insensitivity.get(key.toLowerCase()));
|
||||
} else {
|
||||
|
@ -64,6 +64,7 @@ public final class SubPlugin extends BungeeCord implements Listener {
|
||||
private boolean posted = false;
|
||||
private BigInteger lastSignature = new BigInteger("-1");
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected SubPlugin(PrintStream out) throws IOException {
|
||||
System.out.println("SubServers > Loading SubServers.Bungee v" + version.toString() + " Libraries (for Minecraft " + api.getGameVersion() + ")");
|
||||
|
||||
@ -176,8 +177,8 @@ public final class SubPlugin extends BungeeCord implements Listener {
|
||||
System.out.println("SubServers > Pre-Parsing Config...");
|
||||
for (String name : config.get().getSection("Servers").getKeys()) {
|
||||
try {
|
||||
if (!config.get().getSection("Hosts").contains(config.get().getSection("Servers").getSection(name).getString("Host"))) throw new InvalidServerException("There is no host with this name: " + config.get().getSection("Servers").getSection(name).getString("Host"));
|
||||
legServers.put(name, new BungeeServerInfo(name, new InetSocketAddress(InetAddress.getByName(config.get().getSection("Hosts").getSection(config.get().getSection("Servers").getSection(name).getString("Host")).getRawString("Address")), config.get().getSection("Servers").getSection(name).getInt("Port")), config.get().getSection("Servers").getSection(name).getColoredString("Motd", '&'), config.get().getSection("Servers").getSection(name).getBoolean("Restricted")));
|
||||
if (Util.getCaseInsensitively((Map<String, ?>) config.get().getObject("Hosts"), config.get().getSection("Servers").getSection(name).getString("Host")) == null) throw new InvalidServerException("There is no host with this name: " + config.get().getSection("Servers").getSection(name).getString("Host"));
|
||||
legServers.put(name, new BungeeServerInfo(name, new InetSocketAddress(InetAddress.getByName((String) ((Map<String, ?>) Util.getCaseInsensitively((Map<String, ?>) config.get().getObject("Hosts"), config.get().getSection("Servers").getSection(name).getString("Host"))).get("Address")), config.get().getSection("Servers").getSection(name).getInt("Port")), config.get().getSection("Servers").getSection(name).getColoredString("Motd", '&'), config.get().getSection("Servers").getSection(name).getBoolean("Restricted")));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
Binary file not shown.
@ -6,12 +6,8 @@ import org.yaml.snakeyaml.DumperOptions;
|
||||
import org.yaml.snakeyaml.Yaml;
|
||||
import org.yaml.snakeyaml.error.YAMLException;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.*;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* YAML Config Class
|
||||
@ -35,7 +31,9 @@ public class YAMLConfig {
|
||||
this.file = file;
|
||||
this.yaml = new Yaml(getDumperOptions());
|
||||
if (file.exists()) {
|
||||
this.config = new YAMLSection((LinkedHashMap<String, ?>) yaml.loadAs(new FileInputStream(file), LinkedHashMap.class), null, null, yaml);
|
||||
InputStream stream = new FileInputStream(file);
|
||||
this.config = new YAMLSection((LinkedHashMap<String, ?>) yaml.loadAs(stream, LinkedHashMap.class), null, null, yaml);
|
||||
stream.close();
|
||||
} else {
|
||||
this.config = new YAMLSection(null, null, null, yaml);
|
||||
}
|
||||
@ -68,7 +66,9 @@ public class YAMLConfig {
|
||||
@SuppressWarnings("unchecked")
|
||||
public void reload() throws IOException {
|
||||
if (file.exists()) {
|
||||
this.config = new YAMLSection((LinkedHashMap<String, ?>) yaml.loadAs(new FileInputStream(file), LinkedHashMap.class), null, null, yaml);
|
||||
InputStream stream = new FileInputStream(file);
|
||||
this.config = new YAMLSection((LinkedHashMap<String, ?>) yaml.loadAs(stream, LinkedHashMap.class), null, null, yaml);
|
||||
stream.close();
|
||||
} else {
|
||||
this.config = new YAMLSection(null, null, null, yaml);
|
||||
}
|
||||
|
Binary file not shown.
@ -55,7 +55,9 @@ public final class Launch {
|
||||
try {
|
||||
boolean success = false;
|
||||
if (getFileExtension(plugin.getName()).equalsIgnoreCase("zip")) {
|
||||
Util.unzip(new FileInputStream(plugin), dir);
|
||||
InputStream stream = new FileInputStream(plugin);
|
||||
Util.unzip(stream, dir);
|
||||
stream.close();
|
||||
success = true;
|
||||
} else if (getFileExtension(plugin.getName()).equalsIgnoreCase("jar")) {
|
||||
extractJar(plugin, dir);
|
||||
|
@ -8,7 +8,6 @@ import org.yaml.snakeyaml.error.YAMLException;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* YAML Config Class
|
||||
@ -32,7 +31,9 @@ public class YAMLConfig {
|
||||
this.file = file;
|
||||
this.yaml = new Yaml(getDumperOptions());
|
||||
if (file.exists()) {
|
||||
this.config = new YAMLSection((LinkedHashMap<String, ?>) yaml.loadAs(new FileInputStream(file), LinkedHashMap.class), null, null, yaml);
|
||||
InputStream stream = new FileInputStream(file);
|
||||
this.config = new YAMLSection((LinkedHashMap<String, ?>) yaml.loadAs(stream, LinkedHashMap.class), null, null, yaml);
|
||||
stream.close();
|
||||
} else {
|
||||
this.config = new YAMLSection(null, null, null, yaml);
|
||||
}
|
||||
@ -65,7 +66,9 @@ public class YAMLConfig {
|
||||
@SuppressWarnings("unchecked")
|
||||
public void reload() throws IOException {
|
||||
if (file.exists()) {
|
||||
this.config = new YAMLSection((LinkedHashMap<String, ?>) yaml.loadAs(new FileInputStream(file), LinkedHashMap.class), null, null, yaml);
|
||||
InputStream stream = new FileInputStream(file);
|
||||
this.config = new YAMLSection((LinkedHashMap<String, ?>) yaml.loadAs(stream, LinkedHashMap.class), null, null, yaml);
|
||||
stream.close();
|
||||
} else {
|
||||
this.config = new YAMLSection(null, null, null, yaml);
|
||||
}
|
||||
|
Binary file not shown.
@ -8,7 +8,6 @@ import org.yaml.snakeyaml.error.YAMLException;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* YAML Config Class
|
||||
@ -32,7 +31,9 @@ public class YAMLConfig {
|
||||
this.file = file;
|
||||
this.yaml = new Yaml(getDumperOptions());
|
||||
if (file.exists()) {
|
||||
this.config = new YAMLSection((LinkedHashMap<String, ?>) yaml.loadAs(new FileInputStream(file), LinkedHashMap.class), null, null, yaml);
|
||||
InputStream stream = new FileInputStream(file);
|
||||
this.config = new YAMLSection((LinkedHashMap<String, ?>) yaml.loadAs(stream, LinkedHashMap.class), null, null, yaml);
|
||||
stream.close();
|
||||
} else {
|
||||
this.config = new YAMLSection(null, null, null, yaml);
|
||||
}
|
||||
@ -65,7 +66,9 @@ public class YAMLConfig {
|
||||
@SuppressWarnings("unchecked")
|
||||
public void reload() throws IOException {
|
||||
if (file.exists()) {
|
||||
this.config = new YAMLSection((LinkedHashMap<String, ?>) yaml.loadAs(new FileInputStream(file), LinkedHashMap.class), null, null, yaml);
|
||||
InputStream stream = new FileInputStream(file);
|
||||
this.config = new YAMLSection((LinkedHashMap<String, ?>) yaml.loadAs(stream, LinkedHashMap.class), null, null, yaml);
|
||||
stream.close();
|
||||
} else {
|
||||
this.config = new YAMLSection(null, null, null, yaml);
|
||||
}
|
||||
@ -77,6 +80,7 @@ public class YAMLConfig {
|
||||
* @throws IOException
|
||||
*/
|
||||
public void save() throws IOException {
|
||||
if (!file.exists()) file.createNewFile();
|
||||
FileWriter writer = new FileWriter(file);
|
||||
yaml.dump(config.map, writer);
|
||||
writer.close();
|
||||
|
Loading…
Reference in New Issue
Block a user