1.S3 release
This commit is contained in:
parent
41642d0ddb
commit
aea5600d8e
3
.gitignore
vendored
3
.gitignore
vendored
@ -21,3 +21,6 @@
|
|||||||
|
|
||||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||||
hs_err_pid*
|
hs_err_pid*
|
||||||
|
|
||||||
|
.gradle
|
||||||
|
build
|
@ -8,6 +8,12 @@ version = pluginVersion
|
|||||||
sourceCompatibility = '1.8'
|
sourceCompatibility = '1.8'
|
||||||
targetCompatibility = '1.8'
|
targetCompatibility = '1.8'
|
||||||
|
|
||||||
|
compileJava.options.encoding = 'UTF-8'
|
||||||
|
|
||||||
|
jar {
|
||||||
|
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
|
||||||
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly 'org.spongepowered:spongeapi:7.1.0'
|
compileOnly 'org.spongepowered:spongeapi:7.1.0'
|
||||||
annotationProcessor 'org.spongepowered:spongeapi:7.1.0'
|
annotationProcessor 'org.spongepowered:spongeapi:7.1.0'
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
pluginGroup=ru.redguy
|
pluginGroup=ru.redguy
|
||||||
pluginId=webinfomod
|
pluginId=webinfomod
|
||||||
pluginVersion=1.S2
|
pluginVersion=1.S3
|
||||||
|
@ -7,6 +7,7 @@ import ru.redguy.webinfomod.langs.enums.RootCategories;
|
|||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
public class LangFile {
|
public class LangFile {
|
||||||
private JsonObject jsonObject;
|
private JsonObject jsonObject;
|
||||||
@ -16,7 +17,7 @@ public class LangFile {
|
|||||||
IOUtils.toString(
|
IOUtils.toString(
|
||||||
LangFile.class.getResourceAsStream(
|
LangFile.class.getResourceAsStream(
|
||||||
"/resources/langs/"+config.getString("lang")+".json"
|
"/resources/langs/"+config.getString("lang")+".json"
|
||||||
)));
|
), StandardCharsets.UTF_8));
|
||||||
jsonObject = (JsonObject) obj;
|
jsonObject = (JsonObject) obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ package ru.redguy.webinfomod.langs;
|
|||||||
|
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
|
|
||||||
public class Links extends RootCategory {
|
public class Links implements RootCategory {
|
||||||
|
|
||||||
JsonObject jsonObject;
|
JsonObject jsonObject;
|
||||||
|
|
||||||
@ -10,7 +10,13 @@ public class Links extends RootCategory {
|
|||||||
this.jsonObject = jsonObject;
|
this.jsonObject = jsonObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getString(ru.redguy.webinfomod.langs.enums.Links links) {
|
@Override
|
||||||
return jsonObject.get(links.getName()).getAsString();
|
public String getString(Object object) {
|
||||||
|
return jsonObject.get(((ru.redguy.webinfomod.langs.enums.Links)object).getName()).getAsString();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Category getCategory(Object object) {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,7 @@
|
|||||||
package ru.redguy.webinfomod.langs;
|
package ru.redguy.webinfomod.langs;
|
||||||
|
|
||||||
import ru.redguy.webinfomod.langs.langcaterories.Difficulty;
|
public interface RootCategory {
|
||||||
|
public String getString(Object object);
|
||||||
|
|
||||||
public class RootCategory {
|
public Category getCategory(Object object);
|
||||||
public String getString(Object non) {return null;}
|
|
||||||
|
|
||||||
public Category getCategory(Object non) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@ package ru.redguy.webinfomod.langs;
|
|||||||
|
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
|
|
||||||
public class Titles extends RootCategory {
|
public class Titles implements RootCategory {
|
||||||
|
|
||||||
JsonObject jsonObject;
|
JsonObject jsonObject;
|
||||||
|
|
||||||
@ -10,7 +10,13 @@ public class Titles extends RootCategory {
|
|||||||
this.jsonObject = jsonObject;
|
this.jsonObject = jsonObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getString(ru.redguy.webinfomod.langs.enums.Titles titles) {
|
@Override
|
||||||
return jsonObject.get(titles.getName()).getAsString();
|
public String getString(Object object) {
|
||||||
|
return jsonObject.get(((ru.redguy.webinfomod.langs.enums.Titles)object).getName()).getAsString();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Category getCategory(Object object) {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,21 +1,24 @@
|
|||||||
package ru.redguy.webinfomod.langs;
|
package ru.redguy.webinfomod.langs;
|
||||||
|
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
|
import com.google.inject.internal.cglib.core.$ReflectUtils;
|
||||||
import ru.redguy.webinfomod.langs.langcaterories.Difficulty;
|
import ru.redguy.webinfomod.langs.langcaterories.Difficulty;
|
||||||
|
|
||||||
public class Words extends RootCategory {
|
public class Words implements RootCategory {
|
||||||
JsonObject jsonObject;
|
JsonObject jsonObject;
|
||||||
|
|
||||||
public Words(JsonObject jsonObject) {
|
public Words(JsonObject jsonObject) {
|
||||||
this.jsonObject = jsonObject;
|
this.jsonObject = jsonObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getString(ru.redguy.webinfomod.langs.enums.Links links) {
|
@Override
|
||||||
return jsonObject.get(links.getName()).getAsString();
|
public String getString(Object object) {
|
||||||
|
return jsonObject.get(((ru.redguy.webinfomod.langs.enums.Words)object).getName()).getAsString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Category getCategory(ru.redguy.webinfomod.langs.enums.Words words) {
|
@Override
|
||||||
switch (words) {
|
public Category getCategory(Object object) {
|
||||||
|
switch (((ru.redguy.webinfomod.langs.enums.Words)object)) {
|
||||||
case difficulty:
|
case difficulty:
|
||||||
return new Difficulty(jsonObject.getAsJsonObject("Difficulty"));
|
return new Difficulty(jsonObject.getAsJsonObject("Difficulty"));
|
||||||
}
|
}
|
||||||
|
@ -10,18 +10,19 @@ import ru.redguy.webinfomod.utils.WebUtils;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
@WebPage(url = "/")
|
@WebPage(url = "/")
|
||||||
public class Index implements IWebPage {
|
public class Index implements IWebPage {
|
||||||
public NanoHTTPD.Response getPage(Config config, LangFile langFile, NanoHTTPD.IHTTPSession session) throws IOException {
|
public NanoHTTPD.Response getPage(Config config, LangFile langFile, NanoHTTPD.IHTTPSession session) throws IOException {
|
||||||
String path = "/resources/web/pages/Index.html";
|
String path = "/resources/web/pages/Index.html";
|
||||||
String page = IOUtils.toString(WebServer.class.getResourceAsStream(path), Charset.defaultCharset());
|
String page = IOUtils.toString(WebServer.class.getResourceAsStream(path), StandardCharsets.UTF_8);
|
||||||
WebUtils.CookieHandler ch = new WebUtils.CookieHandler(session.getHeaders());
|
WebUtils.CookieHandler ch = new WebUtils.CookieHandler(session.getHeaders());
|
||||||
if(ch.read("session") == null) {
|
if(ch.read("session") == null) {
|
||||||
page = page.replace("<replace id=\"1\"/>","<a href=\"auth/\" class=\"authLink\">"+langFile.getCategory(RootCategories.Links).getString(Links.login)+"</a>");
|
page = page.replace("<replace id=\"1\"/>","<a href=\"auth/\" class=\"authLink\">"+langFile.getCategory(RootCategories.Links).getString(Links.login)+"</a>");
|
||||||
} else {
|
} else {
|
||||||
page = page.replace("<replace id=\"1\"/>","<a href=\"logout/\" class=\"authLink\">"+langFile.getCategory(RootCategories.Links).getString(Links.logout)+"</a>" +
|
page = page.replace("<replace id=\"1\"/>","<a href=\"logout/\" class=\"authLink\">"+langFile.getCategory(RootCategories.Links).getString(Links.logout)+"</a><br>" +
|
||||||
"<a href=\"cp\" class=\"authLink\">"+langFile.getCategory(RootCategories.Links).getString(Links.controlPanel));
|
"<a href=\"cp\" class=\"authLink\">"+langFile.getCategory(RootCategories.Links).getString(Links.controlPanel)+"</a>");
|
||||||
}
|
}
|
||||||
return NanoHTTPD.newFixedLengthResponse(page);
|
return NanoHTTPD.newFixedLengthResponse(page);
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,9 @@ public class MainData implements IWebPage {
|
|||||||
for (String s : DataUtils.getPlayersList()) {
|
for (String s : DataUtils.getPlayersList()) {
|
||||||
players.append(s).append(",");
|
players.append(s).append(",");
|
||||||
}
|
}
|
||||||
players.deleteCharAt(players.length()-1);
|
if(players.length() > 0) {
|
||||||
|
players.deleteCharAt(players.length() - 1);
|
||||||
|
}
|
||||||
jsonObject.addProperty("Players",players.toString());
|
jsonObject.addProperty("Players",players.toString());
|
||||||
return NanoHTTPD.newFixedLengthResponse(jsonObject.toString());
|
return NanoHTTPD.newFixedLengthResponse(jsonObject.toString());
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="ru">
|
<html lang="ru">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
|
||||||
<title>WebInfo</title>
|
<title>WebInfo</title>
|
||||||
<style>
|
<style>
|
||||||
.header {
|
.header {
|
||||||
|
Reference in New Issue
Block a user