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