convert code
This commit is contained in:
parent
808eefe7e6
commit
19447e5e54
Binary file not shown.
Binary file not shown.
BIN
.gradle/5.6.1/fileContent/fileContent.lock
Normal file
BIN
.gradle/5.6.1/fileContent/fileContent.lock
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
.gradle/5.6.1/fileHashes/resourceHashesCache.bin
Normal file
BIN
.gradle/5.6.1/fileHashes/resourceHashesCache.bin
Normal file
Binary file not shown.
BIN
.gradle/5.6.1/javaCompile/classAnalysis.bin
Normal file
BIN
.gradle/5.6.1/javaCompile/classAnalysis.bin
Normal file
Binary file not shown.
BIN
.gradle/5.6.1/javaCompile/jarAnalysis.bin
Normal file
BIN
.gradle/5.6.1/javaCompile/jarAnalysis.bin
Normal file
Binary file not shown.
BIN
.gradle/5.6.1/javaCompile/javaCompile.lock
Normal file
BIN
.gradle/5.6.1/javaCompile/javaCompile.lock
Normal file
Binary file not shown.
BIN
.gradle/5.6.1/javaCompile/taskHistory.bin
Normal file
BIN
.gradle/5.6.1/javaCompile/taskHistory.bin
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -44,6 +44,7 @@
|
||||
</list>
|
||||
</component>
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="GradleMigrationSettings" migrationVersion="1" />
|
||||
<component name="GradleSettings">
|
||||
<option name="linkedExternalProjectsSettings">
|
||||
<GradleProjectSettings>
|
||||
@ -64,6 +65,127 @@
|
||||
</profile>
|
||||
<version value="1.0" />
|
||||
</component>
|
||||
<component name="Palette2">
|
||||
<group name="Swing">
|
||||
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
|
||||
</item>
|
||||
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true">
|
||||
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
|
||||
<initial-values>
|
||||
<property name="text" value="Button" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="RadioButton" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="CheckBox" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="Label" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
|
||||
<preferred-size width="-1" height="20" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
|
||||
</item>
|
||||
</group>
|
||||
</component>
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/WebInfoSponge.iml" filepath="$PROJECT_DIR$/WebInfoSponge.iml" />
|
||||
@ -239,6 +361,24 @@
|
||||
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.checkerframework/checker-qual/2.4.0/f5ad56eea38b765c2418157d34a47c1827558c87/checker-qual-2.4.0-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
<library name="Gradle: org.javassist:javassist:3.26.0-GA">
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/javassist/javassist/3.26.0-GA/javassist-3.26.0-GA.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
<library name="Gradle: org.nanohttpd:nanohttpd:2.3.1">
|
||||
<CLASSES>
|
||||
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.nanohttpd/nanohttpd/2.3.1/a8d54d1ca554a77f377eff6bf9e16ca8383c8f6c/nanohttpd-2.3.1.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC>
|
||||
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.nanohttpd/nanohttpd/2.3.1/1c128229d2de5d623d3821d0e1b3a4be0e24d7c6/nanohttpd-2.3.1-javadoc.jar!/" />
|
||||
</JAVADOC>
|
||||
<SOURCES>
|
||||
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.nanohttpd/nanohttpd/2.3.1/c820129da77c30b2e4ea1cea619d7f589a17bcdd/nanohttpd-2.3.1-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
<library name="Gradle: org.ow2.asm:asm:5.2">
|
||||
<CLASSES>
|
||||
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.ow2.asm/asm/5.2/4ce3ecdc7115bcbf9d4ff4e6ec638e60760819df/asm-5.2.jar!/" />
|
||||
@ -248,6 +388,17 @@
|
||||
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.ow2.asm/asm/5.2/ed60d4287d18996bc940f26656c570532b20d863/asm-5.2-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
<library name="Gradle: org.reflections:reflections:0.9.12">
|
||||
<CLASSES>
|
||||
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.reflections/reflections/0.9.12/1c9d44c563eebe9b8a3afebd29ed5c4646db800c/reflections-0.9.12.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC>
|
||||
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.reflections/reflections/0.9.12/966c4cd9b2c387f0868539314dc199c8d688adec/reflections-0.9.12-javadoc.jar!/" />
|
||||
</JAVADOC>
|
||||
<SOURCES>
|
||||
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.reflections/reflections/0.9.12/bce0f060e07c97ee9a04f6bdc4fd940adc4debcb/reflections-0.9.12-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
<library name="Gradle: org.slf4j:slf4j-api:1.7.25">
|
||||
<CLASSES>
|
||||
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.slf4j/slf4j-api/1.7.25/da76ca59f6a57ee3102f8f9bd9cee742973efa8a/slf4j-api-1.7.25.jar!/" />
|
||||
|
@ -1,7 +1,53 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="4c49626a-dc81-4683-a8c7-378558b6cdc3" name="Default Changelist" comment="" />
|
||||
<list default="true" id="4c49626a-dc81-4683-a8c7-378558b6cdc3" name="Default Changelist" comment="">
|
||||
<change afterPath="$PROJECT_DIR$/src/main/java/ru/redguy/webinfomod/Config.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/src/main/java/ru/redguy/webinfomod/IWebPage.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/src/main/java/ru/redguy/webinfomod/Logger.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/src/main/java/ru/redguy/webinfomod/LoggerType.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/src/main/java/ru/redguy/webinfomod/User.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/src/main/java/ru/redguy/webinfomod/UsersConfig.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/src/main/java/ru/redguy/webinfomod/WebPage.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/src/main/java/ru/redguy/webinfomod/WebServer.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/src/main/java/ru/redguy/webinfomod/langs/Category.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/src/main/java/ru/redguy/webinfomod/langs/LangFile.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/src/main/java/ru/redguy/webinfomod/langs/Links.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/src/main/java/ru/redguy/webinfomod/langs/RootCategory.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/src/main/java/ru/redguy/webinfomod/langs/Titles.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/src/main/java/ru/redguy/webinfomod/langs/Words.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/src/main/java/ru/redguy/webinfomod/langs/enums/Links.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/src/main/java/ru/redguy/webinfomod/langs/enums/RootCategories.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/src/main/java/ru/redguy/webinfomod/langs/enums/Titles.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/src/main/java/ru/redguy/webinfomod/langs/enums/Words.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/src/main/java/ru/redguy/webinfomod/langs/langcaterories/Difficulty.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/src/main/java/ru/redguy/webinfomod/pages/Index.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/src/main/java/ru/redguy/webinfomod/pages/auth/Index.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/src/main/java/ru/redguy/webinfomod/pages/auth/Worker.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/src/main/java/ru/redguy/webinfomod/pages/json/MainData.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/src/main/java/ru/redguy/webinfomod/pages/logout/Index.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/src/main/java/ru/redguy/webinfomod/utils/DataUtils.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/src/main/java/ru/redguy/webinfomod/utils/DoerUtils.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/src/main/java/ru/redguy/webinfomod/utils/WebUtils.java" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/src/main/resources/resources/langs/ru.json" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/src/main/resources/resources/web/css/index.css" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/src/main/resources/resources/web/js/index.js" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/src/main/resources/resources/web/pages/Index.html" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/src/main/resources/resources/web/pages/auth/Index.html" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.gradle/5.6.1/executionHistory/executionHistory.bin" beforeDir="false" afterPath="$PROJECT_DIR$/.gradle/5.6.1/executionHistory/executionHistory.bin" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.gradle/5.6.1/executionHistory/executionHistory.lock" beforeDir="false" afterPath="$PROJECT_DIR$/.gradle/5.6.1/executionHistory/executionHistory.lock" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.gradle/5.6.1/fileHashes/fileHashes.bin" beforeDir="false" afterPath="$PROJECT_DIR$/.gradle/5.6.1/fileHashes/fileHashes.bin" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.gradle/5.6.1/fileHashes/fileHashes.lock" beforeDir="false" afterPath="$PROJECT_DIR$/.gradle/5.6.1/fileHashes/fileHashes.lock" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.gradle/buildOutputCleanup/buildOutputCleanup.lock" beforeDir="false" afterPath="$PROJECT_DIR$/.gradle/buildOutputCleanup/buildOutputCleanup.lock" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.gradle/buildOutputCleanup/outputFiles.bin" beforeDir="false" afterPath="$PROJECT_DIR$/.gradle/buildOutputCleanup/outputFiles.bin" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/WebInfoSponge.ipr" beforeDir="false" afterPath="$PROJECT_DIR$/WebInfoSponge.ipr" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/WebInfoSponge.iws" beforeDir="false" afterPath="$PROJECT_DIR$/WebInfoSponge.iws" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/WebInfoSponge.main.iml" beforeDir="false" afterPath="$PROJECT_DIR$/WebInfoSponge.main.iml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/WebInfoSponge.test.iml" beforeDir="false" afterPath="$PROJECT_DIR$/WebInfoSponge.test.iml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/build.gradle" beforeDir="false" afterPath="$PROJECT_DIR$/build.gradle" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/gradle/wrapper/gradle-wrapper.properties" beforeDir="false" afterPath="$PROJECT_DIR$/gradle/wrapper/gradle-wrapper.properties" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main/java/ru/redguy/webinfomod/WebInfoSponge.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/ru/redguy/webinfomod/WebInfoSponge.java" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
||||
@ -24,7 +70,18 @@
|
||||
</state>
|
||||
</system>
|
||||
</component>
|
||||
<component name="FileTemplateManagerImpl">
|
||||
<option name="RECENT_TEMPLATES">
|
||||
<list>
|
||||
<option value="Class" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="Git.Settings">
|
||||
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
||||
</component>
|
||||
<component name="ProjectId" id="1argTTn1XgFiBy75NdzurT2eMDw" />
|
||||
<component name="ProjectLevelVcsManager" settingsEditedManually="true" />
|
||||
<component name="ProjectViewState">
|
||||
<option name="hideEmptyMiddlePackages" value="true" />
|
||||
<option name="showExcludedFiles" value="true" />
|
||||
@ -33,8 +90,18 @@
|
||||
<component name="PropertiesComponent">
|
||||
<property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
|
||||
<property name="android.sdk.path" value="C:/Android/SDK" />
|
||||
<property name="last_opened_file_path" value="$PROJECT_DIR$/src/main/java/ru/redguy/webinfomod" />
|
||||
<property name="project.structure.last.edited" value="Modules" />
|
||||
<property name="project.structure.proportion" value="0.0" />
|
||||
<property name="project.structure.side.proportion" value="0.0" />
|
||||
<property name="settings.editor.selected.configurable" value="preferences.JavaFX" />
|
||||
</component>
|
||||
<component name="RecentsManager">
|
||||
<key name="CopyFile.RECENT_KEYS">
|
||||
<recent name="C:\Users\Ilya\Source\Repos\WebInfoSponge\src\main\java\ru\redguy\webinfomod" />
|
||||
<recent name="C:\Users\Ilya\Source\Repos\WebInfoSponge\src\main" />
|
||||
</key>
|
||||
</component>
|
||||
<component name="RunManager">
|
||||
<configuration default="true" type="Application" factoryName="Application">
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
|
||||
@ -58,6 +125,7 @@
|
||||
</option>
|
||||
<option name="vmOptions" />
|
||||
</ExternalSystemSettings>
|
||||
<GradleScriptDebugEnabled>true</GradleScriptDebugEnabled>
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
<configuration default="true" type="JUnit" factoryName="JUnit">
|
||||
@ -90,4 +158,34 @@
|
||||
</task>
|
||||
<servers />
|
||||
</component>
|
||||
<component name="WindowStateProjectService">
|
||||
<state x="275" y="23" key="#Project_Structure" timestamp="1587909798375">
|
||||
<screen x="0" y="0" width="1366" height="728" />
|
||||
</state>
|
||||
<state x="275" y="23" key="#Project_Structure/0.0.1366.728@0.0.1366.728" timestamp="1587909798375" />
|
||||
<state x="336" y="0" key="CommitChangelistDialog2" timestamp="1587499510823">
|
||||
<screen x="0" y="0" width="1366" height="728" />
|
||||
</state>
|
||||
<state x="336" y="0" key="CommitChangelistDialog2/0.0.1366.728@0.0.1366.728" timestamp="1587499510823" />
|
||||
<state width="1323" height="178" key="GridCell.Tab.0.bottom" timestamp="1587911372460">
|
||||
<screen x="0" y="0" width="1366" height="728" />
|
||||
</state>
|
||||
<state width="1323" height="178" key="GridCell.Tab.0.bottom/0.0.1366.728@0.0.1366.728" timestamp="1587911372460" />
|
||||
<state width="1323" height="178" key="GridCell.Tab.0.center" timestamp="1587911372460">
|
||||
<screen x="0" y="0" width="1366" height="728" />
|
||||
</state>
|
||||
<state width="1323" height="178" key="GridCell.Tab.0.center/0.0.1366.728@0.0.1366.728" timestamp="1587911372460" />
|
||||
<state width="1323" height="178" key="GridCell.Tab.0.left" timestamp="1587911372460">
|
||||
<screen x="0" y="0" width="1366" height="728" />
|
||||
</state>
|
||||
<state width="1323" height="178" key="GridCell.Tab.0.left/0.0.1366.728@0.0.1366.728" timestamp="1587911372460" />
|
||||
<state width="1323" height="178" key="GridCell.Tab.0.right" timestamp="1587911372460">
|
||||
<screen x="0" y="0" width="1366" height="728" />
|
||||
</state>
|
||||
<state width="1323" height="178" key="GridCell.Tab.0.right/0.0.1366.728@0.0.1366.728" timestamp="1587911372460" />
|
||||
<state x="65" y="35" key="new project wizard" timestamp="1587499840883">
|
||||
<screen x="0" y="0" width="1366" height="728" />
|
||||
</state>
|
||||
<state x="65" y="35" key="new project wizard/0.0.1366.728@0.0.1366.728" timestamp="1587499840883" />
|
||||
</component>
|
||||
</project>
|
@ -11,20 +11,22 @@
|
||||
</component>
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$/build/generated/sources/annotationProcessor/java/main">
|
||||
<sourceFolder url="file://$MODULE_DIR$/build/generated/sources/annotationProcessor/java/main" isTestSource="false" generated="true" />
|
||||
</content>
|
||||
<content url="file://$MODULE_DIR$/src/main">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Gradle: org.slf4j:slf4j-api:1.7.25" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Gradle: com.google.guava:guava:21.0" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.nanohttpd:nanohttpd:2.3.1" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.reflections:reflections:0.9.12" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.javassist:javassist:3.26.0-GA" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Gradle: com.google.errorprone:error_prone_annotations:2.0.15" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Gradle: com.google.code.gson:gson:2.8.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Gradle: org.apache.commons:commons-lang3:3.5" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Gradle: com.google.code.findbugs:jsr305:3.0.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Gradle: com.google.inject:guice:4.1.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Gradle: com.github.ben-manes.caffeine:caffeine:2.5.4" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Gradle: org.apache.commons:commons-lang3:3.5" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Gradle: com.github.ben-manes.caffeine:guava:2.5.4" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Gradle: org.spongepowered:plugin-meta:0.4.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Gradle: org.spongepowered:configurate-hocon:3.6" level="project" />
|
||||
@ -32,13 +34,17 @@
|
||||
<orderEntry type="library" scope="PROVIDED" name="Gradle: org.spongepowered:configurate-yaml:3.6" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Gradle: com.flowpowered:flow-math:1.0.3" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Gradle: com.flowpowered:flow-noise:1.0.1-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Gradle: org.ow2.asm:asm:5.2" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Gradle: javax.inject:javax.inject:1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Gradle: org.ow2.asm:asm:5.2" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Gradle: aopalliance:aopalliance:1.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Gradle: org.spongepowered:configurate-core:3.6" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Gradle: com.typesafe:config:1.3.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Gradle: org.spongepowered:spongeapi:7.1.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Gradle: org.checkerframework:checker-qual:2.4.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Gradle: org.yaml:snakeyaml:1.18" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Gradle: com.github.ben-manes.caffeine:caffeine:2.5.4" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Gradle: org.slf4j:slf4j-api:1.7.25" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Gradle: com.google.guava:guava:21.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Gradle: com.google.code.gson:gson:2.8.0" level="project" />
|
||||
</component>
|
||||
</module>
|
@ -19,28 +19,31 @@
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module" module-name="WebInfoSponge.main" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Gradle: org.checkerframework:checker-qual:2.4.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Gradle: org.yaml:snakeyaml:1.18" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Gradle: com.typesafe:config:1.3.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Gradle: org.spongepowered:configurate-core:3.6" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Gradle: aopalliance:aopalliance:1.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Gradle: javax.inject:javax.inject:1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Gradle: org.ow2.asm:asm:5.2" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Gradle: com.flowpowered:flow-noise:1.0.1-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Gradle: com.flowpowered:flow-math:1.0.3" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Gradle: org.spongepowered:configurate-yaml:3.6" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Gradle: org.spongepowered:configurate-gson:3.6" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Gradle: org.spongepowered:configurate-hocon:3.6" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Gradle: org.spongepowered:plugin-meta:0.4.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Gradle: com.github.ben-manes.caffeine:guava:2.5.4" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Gradle: org.spongepowered:spongeapi:7.1.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Gradle: org.slf4j:slf4j-api:1.7.25" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Gradle: com.google.guava:guava:21.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Gradle: com.google.errorprone:error_prone_annotations:2.0.15" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Gradle: com.google.code.gson:gson:2.8.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Gradle: org.apache.commons:commons-lang3:3.5" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Gradle: com.google.code.findbugs:jsr305:3.0.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Gradle: com.github.ben-manes.caffeine:caffeine:2.5.4" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Gradle: com.google.inject:guice:4.1.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Gradle: com.google.code.findbugs:jsr305:3.0.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Gradle: org.apache.commons:commons-lang3:3.5" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Gradle: com.google.code.gson:gson:2.8.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Gradle: com.google.errorprone:error_prone_annotations:2.0.15" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Gradle: com.google.guava:guava:21.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Gradle: org.slf4j:slf4j-api:1.7.25" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Gradle: org.spongepowered:spongeapi:7.1.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Gradle: com.github.ben-manes.caffeine:guava:2.5.4" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Gradle: org.spongepowered:plugin-meta:0.4.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Gradle: org.spongepowered:configurate-hocon:3.6" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Gradle: org.spongepowered:configurate-gson:3.6" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Gradle: org.spongepowered:configurate-yaml:3.6" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Gradle: com.flowpowered:flow-math:1.0.3" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Gradle: com.flowpowered:flow-noise:1.0.1-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Gradle: org.spongepowered:configurate-core:3.6" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Gradle: javax.inject:javax.inject:1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Gradle: aopalliance:aopalliance:1.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Gradle: org.yaml:snakeyaml:1.18" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.nanohttpd:nanohttpd:2.3.1" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.reflections:reflections:0.9.12" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.javassist:javassist:3.26.0-GA" level="project" />
|
||||
</component>
|
||||
<component name="TestModuleProperties" production-module="WebInfoSponge.main" />
|
||||
</module>
|
@ -11,6 +11,9 @@ targetCompatibility = '1.8'
|
||||
dependencies {
|
||||
compileOnly 'org.spongepowered:spongeapi:7.1.0'
|
||||
annotationProcessor 'org.spongepowered:spongeapi:7.1.0'
|
||||
compile 'org.nanohttpd:nanohttpd:2.3.1'
|
||||
compile 'org.reflections:reflections:0.9.12'
|
||||
compile 'org.apache.directory.studio:org.apache.commons.io:2.4'
|
||||
}
|
||||
|
||||
sponge.plugin.id = pluginId
|
||||
|
20
build/resources/main/resources/langs/ru.json
Normal file
20
build/resources/main/resources/langs/ru.json
Normal file
@ -0,0 +1,20 @@
|
||||
{
|
||||
"Links": {
|
||||
"login": "Войти",
|
||||
"logout": "Выйти",
|
||||
"cp": "Панель управления"
|
||||
},
|
||||
"Titles":{
|
||||
"auth": "Авторизация"
|
||||
},
|
||||
"Words": {
|
||||
"user": "Пользователь",
|
||||
"password": "Пароль",
|
||||
"Difficulty": {
|
||||
"PEACEFUL": "Мирная",
|
||||
"EASY": "Простая",
|
||||
"NORMAL": "Нормальная",
|
||||
"HARD": "Сложная"
|
||||
}
|
||||
}
|
||||
}
|
0
build/resources/main/resources/web/css/index.css
Normal file
0
build/resources/main/resources/web/css/index.css
Normal file
33
build/resources/main/resources/web/js/index.js
Normal file
33
build/resources/main/resources/web/js/index.js
Normal file
@ -0,0 +1,33 @@
|
||||
function onload() {
|
||||
updatePageInfo();
|
||||
}
|
||||
|
||||
function updatePageInfo() {
|
||||
let header = document.getElementById("header");
|
||||
let stat = document.getElementById("stat");
|
||||
header.innerText = "Идёт загрузка...";
|
||||
stat.innerHTML = "";
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open('GET', '/json/mainData.json', true);
|
||||
xhr.setRequestHeader("Content-Type", "text/plain;charset=UTF-8");
|
||||
xhr.send();
|
||||
xhr.onreadystatechange = function () {
|
||||
if (xhr.readyState !== 4) return;
|
||||
let data = JSON.parse(xhr.responseText);
|
||||
header.innerText = "Мод запущен на сервере";
|
||||
appendLine(stat, ["Версия игры", data.MineV]);
|
||||
appendLine(stat, ["Игроки", data.Players]);
|
||||
}
|
||||
}
|
||||
|
||||
function appendLine(table,array) {
|
||||
let tr = document.createElement("tr");
|
||||
for (let arrayKey in array) {
|
||||
let td = document.createElement("td");
|
||||
td.innerText = array[arrayKey];
|
||||
tr.appendChild(td);
|
||||
}
|
||||
table.appendChild(tr);
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", onload);
|
30
build/resources/main/resources/web/pages/Index.html
Normal file
30
build/resources/main/resources/web/pages/Index.html
Normal file
@ -0,0 +1,30 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>WebInfo</title>
|
||||
<style>
|
||||
.header {
|
||||
text-align: center;
|
||||
font-size: 200%;
|
||||
}
|
||||
#stat {
|
||||
margin: 0 auto;
|
||||
}
|
||||
.authLink {
|
||||
float: right;
|
||||
}
|
||||
</style>
|
||||
<script src="/js/index.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="header" id="header">
|
||||
Идёт загрузка...
|
||||
</div>
|
||||
<main>
|
||||
<replace id="1"/>
|
||||
<table id="stat">
|
||||
</table>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
19
build/resources/main/resources/web/pages/auth/Index.html
Normal file
19
build/resources/main/resources/web/pages/auth/Index.html
Normal file
@ -0,0 +1,19 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title><replace id="1"/></title>
|
||||
<style>
|
||||
form {
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<form method="post" action="/auth/worker/">
|
||||
<label for="user"><replace id="2"/>: <input name="user" id="user" type="text"></label><br>
|
||||
<label for="password"><replace id="3"/>: <input name="password" id="password" type="password"></label><br>
|
||||
<input type="submit">
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
3
gradle/wrapper/gradle-wrapper.properties
vendored
3
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,5 +1,6 @@
|
||||
#Sun Apr 26 16:46:02 MSK 2020
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.1-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.1-all.zip
|
||||
|
52
src/main/java/ru/redguy/webinfomod/Config.java
Normal file
52
src/main/java/ru/redguy/webinfomod/Config.java
Normal file
@ -0,0 +1,52 @@
|
||||
package ru.redguy.webinfomod;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import org.spongepowered.api.Sponge;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class Config {
|
||||
|
||||
private JsonObject jsonObject;
|
||||
public Map<String, String> sessions;
|
||||
private Logger logger;
|
||||
|
||||
public Config(Logger logger) throws IOException {
|
||||
this.logger = logger;
|
||||
JsonParser parser = new JsonParser();
|
||||
Object obj = null; //читаем JSON файл
|
||||
try {
|
||||
obj = parser.parse(new FileReader("config/WebInfoMod.json"));
|
||||
} catch (FileNotFoundException e) {
|
||||
File f = new File("config/WebInfoMod.json");
|
||||
f.createNewFile();
|
||||
FileWriter fw = new FileWriter(f);
|
||||
fw.write(
|
||||
"{"+System.lineSeparator()+
|
||||
"\"WebPort\":8080,"+System.lineSeparator()+
|
||||
"\"lang\":\"ru\""+System.lineSeparator()+
|
||||
"}"
|
||||
);
|
||||
fw.close();
|
||||
obj = parser.parse(new FileReader("config/WebInfoMod.json"));
|
||||
}
|
||||
jsonObject = (JsonObject) obj;
|
||||
jsonObject.addProperty("MineV",Sponge.getPlatform().getMinecraftVersion().getName());
|
||||
sessions = new HashMap<String,String>();
|
||||
}
|
||||
|
||||
public String getString(String name) {
|
||||
return jsonObject.get(name).getAsString();
|
||||
}
|
||||
|
||||
public int getInt(String name) {
|
||||
return jsonObject.get(name).getAsInt();
|
||||
}
|
||||
|
||||
public Logger getLogger() {
|
||||
return logger;
|
||||
}
|
||||
}
|
11
src/main/java/ru/redguy/webinfomod/IWebPage.java
Normal file
11
src/main/java/ru/redguy/webinfomod/IWebPage.java
Normal file
@ -0,0 +1,11 @@
|
||||
package ru.redguy.webinfomod;
|
||||
|
||||
import fi.iki.elonen.NanoHTTPD;
|
||||
import ru.redguy.webinfomod.langs.LangFile;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public interface IWebPage {
|
||||
|
||||
public NanoHTTPD.Response getPage(Config config, LangFile langFile, NanoHTTPD.IHTTPSession session) throws IOException;
|
||||
}
|
22
src/main/java/ru/redguy/webinfomod/Logger.java
Normal file
22
src/main/java/ru/redguy/webinfomod/Logger.java
Normal file
@ -0,0 +1,22 @@
|
||||
package ru.redguy.webinfomod;
|
||||
|
||||
public class Logger {
|
||||
|
||||
org.slf4j.Logger logger;
|
||||
|
||||
public Logger(org.slf4j.Logger logger){
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
public void info(LoggerType logFrom, String message) {
|
||||
logger.info("["+logFrom.getName()+"] "+message);
|
||||
}
|
||||
|
||||
public void warn(LoggerType logFrom, String message) {
|
||||
logger.warn("["+logFrom.getName()+"] "+message);
|
||||
}
|
||||
|
||||
public void error(LoggerType logFrom, String message) {
|
||||
logger.error("["+logFrom.getName()+"] "+message);
|
||||
}
|
||||
}
|
16
src/main/java/ru/redguy/webinfomod/LoggerType.java
Normal file
16
src/main/java/ru/redguy/webinfomod/LoggerType.java
Normal file
@ -0,0 +1,16 @@
|
||||
package ru.redguy.webinfomod;
|
||||
|
||||
public enum LoggerType {
|
||||
Client("Client"),
|
||||
Web("Web");
|
||||
|
||||
private String name;
|
||||
|
||||
LoggerType(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
12
src/main/java/ru/redguy/webinfomod/User.java
Normal file
12
src/main/java/ru/redguy/webinfomod/User.java
Normal file
@ -0,0 +1,12 @@
|
||||
package ru.redguy.webinfomod;
|
||||
|
||||
public class User {
|
||||
|
||||
public String user;
|
||||
public String password;
|
||||
|
||||
public User(String user, String password) {
|
||||
this.user = user;
|
||||
this.password = password;
|
||||
}
|
||||
}
|
48
src/main/java/ru/redguy/webinfomod/UsersConfig.java
Normal file
48
src/main/java/ru/redguy/webinfomod/UsersConfig.java
Normal file
@ -0,0 +1,48 @@
|
||||
package ru.redguy.webinfomod;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
public class UsersConfig {
|
||||
|
||||
private JsonArray rawUsers;
|
||||
|
||||
public UsersConfig() throws IOException {
|
||||
JsonParser parser = new JsonParser();
|
||||
Object rawData;
|
||||
try {
|
||||
rawData = parser.parse(new FileReader("config/WebInfoUsers.json"));
|
||||
} catch (FileNotFoundException e) {
|
||||
File f = new File("config/WebInfoUsers.json");
|
||||
f.createNewFile();
|
||||
FileWriter fw = new FileWriter(f);
|
||||
fw.write(
|
||||
"[{"+System.lineSeparator()+
|
||||
"\"user\":\"admin\","+System.lineSeparator()+
|
||||
"\"password\":\"admin\""+System.lineSeparator()+
|
||||
"}]"
|
||||
);
|
||||
fw.close();
|
||||
rawData = parser.parse(new FileReader("config/WebInfoMod.json"));
|
||||
}
|
||||
rawUsers = (JsonArray) rawData;
|
||||
}
|
||||
|
||||
public User getUser(String name) {
|
||||
User result = null;
|
||||
for (JsonElement rawUser : rawUsers) {
|
||||
JsonObject userJson = rawUser.getAsJsonObject();
|
||||
if(userJson.get("user").getAsString().equals(name)) {
|
||||
result = new User(
|
||||
userJson.get("user").getAsString(),
|
||||
userJson.get("password").getAsString()
|
||||
);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
@ -5,6 +5,9 @@ import org.slf4j.Logger;
|
||||
import org.spongepowered.api.event.game.state.GameStartedServerEvent;
|
||||
import org.spongepowered.api.event.Listener;
|
||||
import org.spongepowered.api.plugin.Plugin;
|
||||
import ru.redguy.webinfomod.langs.LangFile;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@Plugin(
|
||||
id = "webinfomod",
|
||||
@ -20,7 +23,16 @@ public class WebInfoSponge {
|
||||
@Inject
|
||||
private Logger logger;
|
||||
|
||||
public ru.redguy.webinfomod.Logger myLogger;
|
||||
public Config config;
|
||||
public WebServer webServer;
|
||||
public LangFile langFile;
|
||||
|
||||
@Listener
|
||||
public void onServerStart(GameStartedServerEvent event) {
|
||||
public void onServerStart(GameStartedServerEvent event) throws IOException {
|
||||
myLogger = new ru.redguy.webinfomod.Logger(logger);
|
||||
config = new Config(myLogger);
|
||||
langFile = new LangFile(config);
|
||||
webServer = new WebServer(config.getInt("WebPort"), config, langFile);
|
||||
}
|
||||
}
|
||||
|
12
src/main/java/ru/redguy/webinfomod/WebPage.java
Normal file
12
src/main/java/ru/redguy/webinfomod/WebPage.java
Normal file
@ -0,0 +1,12 @@
|
||||
package ru.redguy.webinfomod;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Target(value= ElementType.TYPE)
|
||||
@Retention(value= RetentionPolicy.RUNTIME)
|
||||
public @interface WebPage {
|
||||
String url();
|
||||
}
|
73
src/main/java/ru/redguy/webinfomod/WebServer.java
Normal file
73
src/main/java/ru/redguy/webinfomod/WebServer.java
Normal file
@ -0,0 +1,73 @@
|
||||
package ru.redguy.webinfomod;
|
||||
|
||||
import fi.iki.elonen.NanoHTTPD;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.reflections.Reflections;
|
||||
import org.reflections.scanners.FieldAnnotationsScanner;
|
||||
import org.reflections.scanners.MethodAnnotationsScanner;
|
||||
import org.reflections.scanners.MethodParameterScanner;
|
||||
import org.reflections.scanners.TypeAnnotationsScanner;
|
||||
import org.reflections.util.ClasspathHelper;
|
||||
import org.reflections.util.ConfigurationBuilder;
|
||||
import org.reflections.util.FilterBuilder;
|
||||
import ru.redguy.webinfomod.langs.LangFile;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
public class WebServer extends NanoHTTPD {
|
||||
|
||||
Config config;
|
||||
Reflections reflections;
|
||||
LangFile langFile;
|
||||
|
||||
public WebServer(int port, Config config, LangFile langFile) throws IOException {
|
||||
super(port);
|
||||
ConfigurationBuilder configBuilder =
|
||||
new ConfigurationBuilder()
|
||||
.filterInputsBy(new FilterBuilder().includePackage("ru.redguy.webinfomod.pages"))
|
||||
.setUrls(ClasspathHelper.forPackage("ru.redguy.webinfomod.pages"))
|
||||
.setScanners(
|
||||
new TypeAnnotationsScanner(),
|
||||
new MethodParameterScanner(),
|
||||
new MethodAnnotationsScanner(),
|
||||
new FieldAnnotationsScanner()
|
||||
);
|
||||
this.reflections = new Reflections(configBuilder);
|
||||
start(NanoHTTPD.SOCKET_READ_TIMEOUT, false);
|
||||
this.config = config;
|
||||
this.langFile = langFile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response serve(IHTTPSession session) {
|
||||
|
||||
if(session.getUri().startsWith("/css/")||session.getUri().startsWith("/js/")) {
|
||||
String path = "/resources/web"+session.getUri();
|
||||
try {
|
||||
return newFixedLengthResponse(
|
||||
IOUtils.toString(WebServer.class.getResourceAsStream(path), StandardCharsets.UTF_8));
|
||||
} catch (IOException ignored) {
|
||||
}
|
||||
|
||||
} else {
|
||||
for (Class<?> mClass : reflections.getTypesAnnotatedWith(WebPage.class, true)) {
|
||||
if (mClass.getAnnotation(WebPage.class).url().equals(session.getUri())) {
|
||||
try {
|
||||
return (Response) mClass.getMethod("getPage", Config.class, LangFile.class, IHTTPSession.class).invoke(mClass.newInstance(), config, langFile, session);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
} catch (NoSuchMethodException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InstantiationException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return newFixedLengthResponse("Not Founded!");
|
||||
}
|
||||
}
|
5
src/main/java/ru/redguy/webinfomod/langs/Category.java
Normal file
5
src/main/java/ru/redguy/webinfomod/langs/Category.java
Normal file
@ -0,0 +1,5 @@
|
||||
package ru.redguy.webinfomod.langs;
|
||||
|
||||
public class Category {
|
||||
public String getString(Object login) {return null;}
|
||||
}
|
38
src/main/java/ru/redguy/webinfomod/langs/LangFile.java
Normal file
38
src/main/java/ru/redguy/webinfomod/langs/LangFile.java
Normal file
@ -0,0 +1,38 @@
|
||||
package ru.redguy.webinfomod.langs;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import ru.redguy.webinfomod.Config;
|
||||
import ru.redguy.webinfomod.langs.enums.RootCategories;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
public class LangFile {
|
||||
private JsonObject jsonObject;
|
||||
public LangFile(Config config) throws IOException {
|
||||
JsonParser parser = new JsonParser();
|
||||
Object obj = parser.parse(
|
||||
IOUtils.toString(
|
||||
LangFile.class.getResourceAsStream(
|
||||
"/resources/langs/"+config.getString("lang")+".json"
|
||||
)));
|
||||
jsonObject = (JsonObject) obj;
|
||||
}
|
||||
|
||||
public LangFile(JsonObject jsonObject) {
|
||||
this.jsonObject = jsonObject;
|
||||
}
|
||||
|
||||
public RootCategory getCategory(RootCategories category) {
|
||||
switch (category) {
|
||||
case Links:
|
||||
return new Links(jsonObject.getAsJsonObject("Links"));
|
||||
case Titles:
|
||||
return new Titles(jsonObject.getAsJsonObject("Titles"));
|
||||
case Words:
|
||||
return new Words(jsonObject.getAsJsonObject("Words"));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
16
src/main/java/ru/redguy/webinfomod/langs/Links.java
Normal file
16
src/main/java/ru/redguy/webinfomod/langs/Links.java
Normal file
@ -0,0 +1,16 @@
|
||||
package ru.redguy.webinfomod.langs;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
public class Links extends RootCategory {
|
||||
|
||||
JsonObject jsonObject;
|
||||
|
||||
public Links(JsonObject jsonObject) {
|
||||
this.jsonObject = jsonObject;
|
||||
}
|
||||
|
||||
public String getString(ru.redguy.webinfomod.langs.enums.Links links) {
|
||||
return jsonObject.get(links.getName()).getAsString();
|
||||
}
|
||||
}
|
11
src/main/java/ru/redguy/webinfomod/langs/RootCategory.java
Normal file
11
src/main/java/ru/redguy/webinfomod/langs/RootCategory.java
Normal file
@ -0,0 +1,11 @@
|
||||
package ru.redguy.webinfomod.langs;
|
||||
|
||||
import ru.redguy.webinfomod.langs.langcaterories.Difficulty;
|
||||
|
||||
public class RootCategory {
|
||||
public String getString(Object non) {return null;}
|
||||
|
||||
public Category getCategory(Object non) {
|
||||
return null;
|
||||
}
|
||||
}
|
16
src/main/java/ru/redguy/webinfomod/langs/Titles.java
Normal file
16
src/main/java/ru/redguy/webinfomod/langs/Titles.java
Normal file
@ -0,0 +1,16 @@
|
||||
package ru.redguy.webinfomod.langs;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
public class Titles extends RootCategory {
|
||||
|
||||
JsonObject jsonObject;
|
||||
|
||||
public Titles(JsonObject jsonObject) {
|
||||
this.jsonObject = jsonObject;
|
||||
}
|
||||
|
||||
public String getString(ru.redguy.webinfomod.langs.enums.Titles titles) {
|
||||
return jsonObject.get(titles.getName()).getAsString();
|
||||
}
|
||||
}
|
24
src/main/java/ru/redguy/webinfomod/langs/Words.java
Normal file
24
src/main/java/ru/redguy/webinfomod/langs/Words.java
Normal file
@ -0,0 +1,24 @@
|
||||
package ru.redguy.webinfomod.langs;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import ru.redguy.webinfomod.langs.langcaterories.Difficulty;
|
||||
|
||||
public class Words extends 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();
|
||||
}
|
||||
|
||||
public Category getCategory(ru.redguy.webinfomod.langs.enums.Words words) {
|
||||
switch (words) {
|
||||
case difficulty:
|
||||
return new Difficulty(jsonObject.getAsJsonObject("Difficulty"));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
17
src/main/java/ru/redguy/webinfomod/langs/enums/Links.java
Normal file
17
src/main/java/ru/redguy/webinfomod/langs/enums/Links.java
Normal file
@ -0,0 +1,17 @@
|
||||
package ru.redguy.webinfomod.langs.enums;
|
||||
|
||||
public enum Links {
|
||||
controlPanel("cp"),
|
||||
logout("logout"),
|
||||
login("login");
|
||||
|
||||
private String name;
|
||||
|
||||
Links(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package ru.redguy.webinfomod.langs.enums;
|
||||
|
||||
public enum RootCategories {
|
||||
Links,
|
||||
Titles,
|
||||
Words
|
||||
}
|
15
src/main/java/ru/redguy/webinfomod/langs/enums/Titles.java
Normal file
15
src/main/java/ru/redguy/webinfomod/langs/enums/Titles.java
Normal file
@ -0,0 +1,15 @@
|
||||
package ru.redguy.webinfomod.langs.enums;
|
||||
|
||||
public enum Titles {
|
||||
authPage("auth");
|
||||
|
||||
private String name;
|
||||
|
||||
Titles(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
17
src/main/java/ru/redguy/webinfomod/langs/enums/Words.java
Normal file
17
src/main/java/ru/redguy/webinfomod/langs/enums/Words.java
Normal file
@ -0,0 +1,17 @@
|
||||
package ru.redguy.webinfomod.langs.enums;
|
||||
|
||||
public enum Words {
|
||||
user("user"),
|
||||
password("password"),
|
||||
difficulty("Difficulty");
|
||||
|
||||
private String name;
|
||||
|
||||
Words(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package ru.redguy.webinfomod.langs.langcaterories;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import ru.redguy.webinfomod.langs.Category;
|
||||
|
||||
public class Difficulty extends Category {
|
||||
|
||||
JsonObject jsonObject;
|
||||
|
||||
public Difficulty(JsonObject jsonObject) {
|
||||
this.jsonObject = jsonObject;
|
||||
}
|
||||
|
||||
public String getString(Difficulty enumDifficulty) {
|
||||
return jsonObject.get(enumDifficulty.toString()).getAsString();
|
||||
}
|
||||
}
|
28
src/main/java/ru/redguy/webinfomod/pages/Index.java
Normal file
28
src/main/java/ru/redguy/webinfomod/pages/Index.java
Normal file
@ -0,0 +1,28 @@
|
||||
package ru.redguy.webinfomod.pages;
|
||||
|
||||
import fi.iki.elonen.NanoHTTPD;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import ru.redguy.webinfomod.*;
|
||||
import ru.redguy.webinfomod.langs.LangFile;
|
||||
import ru.redguy.webinfomod.langs.enums.Links;
|
||||
import ru.redguy.webinfomod.langs.enums.RootCategories;
|
||||
import ru.redguy.webinfomod.utils.WebUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
@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());
|
||||
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));
|
||||
}
|
||||
return NanoHTTPD.newFixedLengthResponse(page);
|
||||
}
|
||||
}
|
25
src/main/java/ru/redguy/webinfomod/pages/auth/Index.java
Normal file
25
src/main/java/ru/redguy/webinfomod/pages/auth/Index.java
Normal file
@ -0,0 +1,25 @@
|
||||
package ru.redguy.webinfomod.pages.auth;
|
||||
|
||||
import fi.iki.elonen.NanoHTTPD;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import ru.redguy.webinfomod.*;
|
||||
import ru.redguy.webinfomod.langs.LangFile;
|
||||
import ru.redguy.webinfomod.langs.enums.RootCategories;
|
||||
import ru.redguy.webinfomod.langs.enums.Titles;
|
||||
import ru.redguy.webinfomod.langs.enums.Words;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
@WebPage(url = "/auth/")
|
||||
public class Index implements IWebPage {
|
||||
|
||||
public NanoHTTPD.Response getPage(Config config, LangFile langFile, NanoHTTPD.IHTTPSession session) throws IOException {
|
||||
String path = "/resources/web/pages/auth/Index.html";
|
||||
String page = IOUtils.toString(WebServer.class.getResourceAsStream(path), Charset.defaultCharset());
|
||||
page = page.replace("<replace id=\"1\"/>",langFile.getCategory(RootCategories.Titles).getString(Titles.authPage));
|
||||
page = page.replace("<replace id=\"2\"/>",langFile.getCategory(RootCategories.Words).getString(Words.user));
|
||||
page = page.replace("<replace id=\"3\"/>",langFile.getCategory(RootCategories.Words).getString(Words.password));
|
||||
return NanoHTTPD.newFixedLengthResponse(page);
|
||||
}
|
||||
}
|
60
src/main/java/ru/redguy/webinfomod/pages/auth/Worker.java
Normal file
60
src/main/java/ru/redguy/webinfomod/pages/auth/Worker.java
Normal file
@ -0,0 +1,60 @@
|
||||
package ru.redguy.webinfomod.pages.auth;
|
||||
|
||||
import fi.iki.elonen.NanoHTTPD;
|
||||
import ru.redguy.webinfomod.*;
|
||||
import ru.redguy.webinfomod.langs.LangFile;
|
||||
import ru.redguy.webinfomod.utils.WebUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@WebPage(url = "/auth/worker/")
|
||||
public class Worker implements IWebPage {
|
||||
public NanoHTTPD.Response getPage(Config config, LangFile langFile, NanoHTTPD.IHTTPSession session) throws IOException {
|
||||
try {
|
||||
session.parseBody(new HashMap<String, String>());
|
||||
} catch (NanoHTTPD.ResponseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Map<String, List<String>> decodedQueryParameters = WebUtils.decodeParams(session.getQueryParameterString());
|
||||
if(!decodedQueryParameters.containsKey("user")) {
|
||||
NanoHTTPD.Response response = NanoHTTPD.newFixedLengthResponse(NanoHTTPD.Response.Status.REDIRECT,NanoHTTPD.MIME_PLAINTEXT,"");
|
||||
response.addHeader("Location","/auth/");
|
||||
return response;
|
||||
} else {
|
||||
if(!decodedQueryParameters.containsKey("password")) {
|
||||
NanoHTTPD.Response response = NanoHTTPD.newFixedLengthResponse(NanoHTTPD.Response.Status.REDIRECT,NanoHTTPD.MIME_PLAINTEXT,"");
|
||||
response.addHeader("Location","/auth/");
|
||||
return response;
|
||||
} else {
|
||||
UsersConfig usersConfig = new UsersConfig();
|
||||
User user = usersConfig.getUser(decodedQueryParameters.get("user").get(0));
|
||||
if(user == null) {
|
||||
NanoHTTPD.Response response = NanoHTTPD.newFixedLengthResponse(NanoHTTPD.Response.Status.REDIRECT,NanoHTTPD.MIME_PLAINTEXT,"");
|
||||
response.addHeader("Location", "/auth/");
|
||||
return response;
|
||||
} else {
|
||||
if (!user.password.equals(decodedQueryParameters.get("password").get(0))) {
|
||||
NanoHTTPD.Response response = NanoHTTPD.newFixedLengthResponse(NanoHTTPD.Response.Status.REDIRECT,NanoHTTPD.MIME_PLAINTEXT,"");
|
||||
response.addHeader("Location", "/auth/");
|
||||
return response;
|
||||
} else {
|
||||
Date date = new Date();
|
||||
String token = WebUtils.MD5(date.getTime()+"MagickSalt");
|
||||
WebUtils.CookieHandler ch = new WebUtils.CookieHandler(session.getHeaders());
|
||||
ch.set("session",token,1);
|
||||
config.sessions.put(token,user.user);
|
||||
NanoHTTPD.Response response = NanoHTTPD.newFixedLengthResponse(NanoHTTPD.Response.Status.REDIRECT,NanoHTTPD.MIME_PLAINTEXT,"");
|
||||
response.addHeader("Location", "/");
|
||||
ch.unloadQueue(response);
|
||||
config.getLogger().info(LoggerType.Web,user.user + " login!");
|
||||
return response;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
25
src/main/java/ru/redguy/webinfomod/pages/json/MainData.java
Normal file
25
src/main/java/ru/redguy/webinfomod/pages/json/MainData.java
Normal file
@ -0,0 +1,25 @@
|
||||
package ru.redguy.webinfomod.pages.json;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import fi.iki.elonen.NanoHTTPD;
|
||||
import ru.redguy.webinfomod.*;
|
||||
import ru.redguy.webinfomod.langs.LangFile;
|
||||
import ru.redguy.webinfomod.utils.DataUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@WebPage(url="/json/mainData.json")
|
||||
public class MainData implements IWebPage {
|
||||
|
||||
public NanoHTTPD.Response getPage(Config config, LangFile langFile, NanoHTTPD.IHTTPSession session) throws IOException {
|
||||
JsonObject jsonObject = new JsonObject();
|
||||
jsonObject.addProperty("MineV",config.getString("MineV"));
|
||||
StringBuilder players = new StringBuilder();
|
||||
for (String s : DataUtils.getPlayersList()) {
|
||||
players.append(s).append(",");
|
||||
}
|
||||
players.deleteCharAt(players.length()-1);
|
||||
jsonObject.addProperty("Players",players.toString());
|
||||
return NanoHTTPD.newFixedLengthResponse(jsonObject.toString());
|
||||
}
|
||||
}
|
21
src/main/java/ru/redguy/webinfomod/pages/logout/Index.java
Normal file
21
src/main/java/ru/redguy/webinfomod/pages/logout/Index.java
Normal file
@ -0,0 +1,21 @@
|
||||
package ru.redguy.webinfomod.pages.logout;
|
||||
|
||||
import fi.iki.elonen.NanoHTTPD;
|
||||
import ru.redguy.webinfomod.*;
|
||||
import ru.redguy.webinfomod.langs.LangFile;
|
||||
import ru.redguy.webinfomod.utils.WebUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@WebPage(url = "/logout/")
|
||||
public class Index implements IWebPage {
|
||||
public NanoHTTPD.Response getPage(Config config, LangFile langFile, NanoHTTPD.IHTTPSession session) throws IOException {
|
||||
WebUtils.CookieHandler ch = new WebUtils.CookieHandler(session.getHeaders());
|
||||
config.getLogger().info(LoggerType.Web,config.sessions.get(ch.read("session"))+ " has been logout!");
|
||||
ch.delete("session");
|
||||
NanoHTTPD.Response response = NanoHTTPD.newFixedLengthResponse(NanoHTTPD.Response.Status.REDIRECT,NanoHTTPD.MIME_PLAINTEXT,"");
|
||||
response.addHeader("Location", "/");
|
||||
ch.unloadQueue(response);
|
||||
return response;
|
||||
}
|
||||
}
|
17
src/main/java/ru/redguy/webinfomod/utils/DataUtils.java
Normal file
17
src/main/java/ru/redguy/webinfomod/utils/DataUtils.java
Normal file
@ -0,0 +1,17 @@
|
||||
package ru.redguy.webinfomod.utils;
|
||||
|
||||
import org.spongepowered.api.Sponge;
|
||||
import org.spongepowered.api.entity.living.player.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class DataUtils {
|
||||
public static List<String> getPlayersList() {
|
||||
List<String> result = new ArrayList<String>();
|
||||
for (Player onlinePlayer : Sponge.getServer().getOnlinePlayers()) {
|
||||
result.add(onlinePlayer.getName());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
5
src/main/java/ru/redguy/webinfomod/utils/DoerUtils.java
Normal file
5
src/main/java/ru/redguy/webinfomod/utils/DoerUtils.java
Normal file
@ -0,0 +1,5 @@
|
||||
package ru.redguy.webinfomod.utils;
|
||||
|
||||
public class DoerUtils {
|
||||
|
||||
}
|
170
src/main/java/ru/redguy/webinfomod/utils/WebUtils.java
Normal file
170
src/main/java/ru/redguy/webinfomod/utils/WebUtils.java
Normal file
@ -0,0 +1,170 @@
|
||||
package ru.redguy.webinfomod.utils;
|
||||
|
||||
import fi.iki.elonen.NanoHTTPD;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
public class WebUtils {
|
||||
public static Map<String, List<String>> decodeParams(String queryString) {
|
||||
Map<String, List<String>> parms = new HashMap<String, List<String>>();
|
||||
if (queryString != null) {
|
||||
StringTokenizer st = new StringTokenizer(queryString, "&");
|
||||
while (st.hasMoreTokens()) {
|
||||
String e = st.nextToken();
|
||||
int sep = e.indexOf('=');
|
||||
String propertyName = sep >= 0 ? decodePercent(e.substring(0, sep)).trim() : decodePercent(e).trim();
|
||||
if (!parms.containsKey(propertyName)) {
|
||||
parms.put(propertyName, new ArrayList<String>());
|
||||
}
|
||||
String propertyValue = sep >= 0 ? decodePercent(e.substring(sep + 1)) : null;
|
||||
if (propertyValue != null) {
|
||||
parms.get(propertyName).add(propertyValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
return parms;
|
||||
}
|
||||
|
||||
protected static String decodePercent(String str) {
|
||||
String decoded = null;
|
||||
try {
|
||||
decoded = URLDecoder.decode(str, "UTF8");
|
||||
} catch (UnsupportedEncodingException ignored) {
|
||||
}
|
||||
return decoded;
|
||||
}
|
||||
|
||||
public static String MD5(String md5) {
|
||||
try {
|
||||
java.security.MessageDigest md = java.security.MessageDigest.getInstance("MD5");
|
||||
byte[] array = md.digest(md5.getBytes());
|
||||
StringBuffer sb = new StringBuffer();
|
||||
for (int i = 0; i < array.length; ++i) {
|
||||
sb.append(Integer.toHexString((array[i] & 0xFF) | 0x100).substring(1,3));
|
||||
}
|
||||
return sb.toString();
|
||||
} catch (java.security.NoSuchAlgorithmException e) {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static class CookieHandler implements Iterable<String> {
|
||||
|
||||
private final HashMap<String, String> cookies = new HashMap<String, String>();
|
||||
|
||||
private final ArrayList<Cookie> queue = new ArrayList<Cookie>();
|
||||
|
||||
public CookieHandler(Map<String, String> httpHeaders) {
|
||||
String raw = httpHeaders.get("cookie");
|
||||
if (raw != null) {
|
||||
String[] tokens = raw.split(";");
|
||||
for (String token : tokens) {
|
||||
String[] data = token.trim().split("=");
|
||||
if (data.length == 2) {
|
||||
this.cookies.put(data[0], data[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a cookie with an expiration date from a month ago, effectively
|
||||
* deleting it on the client side.
|
||||
*
|
||||
* @param name
|
||||
* The cookie name.
|
||||
*/
|
||||
public void delete(String name) {
|
||||
set(name, "-delete-", -30);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<String> iterator() {
|
||||
return this.cookies.keySet().iterator();
|
||||
}
|
||||
|
||||
/**
|
||||
* Read a cookie from the HTTP Headers.
|
||||
*
|
||||
* @param name
|
||||
* The cookie's name.
|
||||
* @return The cookie's value if it exists, null otherwise.
|
||||
*/
|
||||
public String read(String name) {
|
||||
return this.cookies.get(name);
|
||||
}
|
||||
|
||||
public void set(Cookie cookie) {
|
||||
this.queue.add(cookie);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a cookie.
|
||||
*
|
||||
* @param name
|
||||
* The cookie's name.
|
||||
* @param value
|
||||
* The cookie's value.
|
||||
* @param expires
|
||||
* How many days until the cookie expires.
|
||||
*/
|
||||
public void set(String name, String value, int expires) {
|
||||
this.queue.add(new Cookie(name, value, Cookie.getHTTPTime(expires)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Internally used by the webserver to add all queued cookies into the
|
||||
* Response's HTTP Headers.
|
||||
*
|
||||
* @param response
|
||||
* The Response object to which headers the queued cookies
|
||||
* will be added.
|
||||
*/
|
||||
public void unloadQueue(NanoHTTPD.Response response) {
|
||||
for (Cookie cookie : this.queue) {
|
||||
response.addHeader("Set-Cookie", cookie.getHTTPHeader());
|
||||
}
|
||||
}
|
||||
|
||||
public void printDebug() {
|
||||
System.out.println(cookies);
|
||||
}
|
||||
}
|
||||
|
||||
public static class Cookie {
|
||||
|
||||
public static String getHTTPTime(int days) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z", Locale.US);
|
||||
dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||
calendar.add(Calendar.DAY_OF_MONTH, days);
|
||||
return dateFormat.format(calendar.getTime());
|
||||
}
|
||||
|
||||
private final String n, v, e;
|
||||
|
||||
public Cookie(String name, String value) {
|
||||
this(name, value, 30);
|
||||
}
|
||||
|
||||
public Cookie(String name, String value, int numDays) {
|
||||
this.n = name;
|
||||
this.v = value;
|
||||
this.e = getHTTPTime(numDays);
|
||||
}
|
||||
|
||||
public Cookie(String name, String value, String expires) {
|
||||
this.n = name;
|
||||
this.v = value;
|
||||
this.e = expires;
|
||||
}
|
||||
|
||||
public String getHTTPHeader() {
|
||||
String fmt = "%s=%s; expires=%s; path=/";
|
||||
return String.format(fmt, this.n, this.v, this.e);
|
||||
}
|
||||
}
|
||||
}
|
20
src/main/resources/resources/langs/ru.json
Normal file
20
src/main/resources/resources/langs/ru.json
Normal file
@ -0,0 +1,20 @@
|
||||
{
|
||||
"Links": {
|
||||
"login": "Войти",
|
||||
"logout": "Выйти",
|
||||
"cp": "Панель управления"
|
||||
},
|
||||
"Titles":{
|
||||
"auth": "Авторизация"
|
||||
},
|
||||
"Words": {
|
||||
"user": "Пользователь",
|
||||
"password": "Пароль",
|
||||
"Difficulty": {
|
||||
"PEACEFUL": "Мирная",
|
||||
"EASY": "Простая",
|
||||
"NORMAL": "Нормальная",
|
||||
"HARD": "Сложная"
|
||||
}
|
||||
}
|
||||
}
|
0
src/main/resources/resources/web/css/index.css
Normal file
0
src/main/resources/resources/web/css/index.css
Normal file
33
src/main/resources/resources/web/js/index.js
Normal file
33
src/main/resources/resources/web/js/index.js
Normal file
@ -0,0 +1,33 @@
|
||||
function onload() {
|
||||
updatePageInfo();
|
||||
}
|
||||
|
||||
function updatePageInfo() {
|
||||
let header = document.getElementById("header");
|
||||
let stat = document.getElementById("stat");
|
||||
header.innerText = "Идёт загрузка...";
|
||||
stat.innerHTML = "";
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open('GET', '/json/mainData.json', true);
|
||||
xhr.setRequestHeader("Content-Type", "text/plain;charset=UTF-8");
|
||||
xhr.send();
|
||||
xhr.onreadystatechange = function () {
|
||||
if (xhr.readyState !== 4) return;
|
||||
let data = JSON.parse(xhr.responseText);
|
||||
header.innerText = "Мод запущен на сервере";
|
||||
appendLine(stat, ["Версия игры", data.MineV]);
|
||||
appendLine(stat, ["Игроки", data.Players]);
|
||||
}
|
||||
}
|
||||
|
||||
function appendLine(table,array) {
|
||||
let tr = document.createElement("tr");
|
||||
for (let arrayKey in array) {
|
||||
let td = document.createElement("td");
|
||||
td.innerText = array[arrayKey];
|
||||
tr.appendChild(td);
|
||||
}
|
||||
table.appendChild(tr);
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", onload);
|
30
src/main/resources/resources/web/pages/Index.html
Normal file
30
src/main/resources/resources/web/pages/Index.html
Normal file
@ -0,0 +1,30 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>WebInfo</title>
|
||||
<style>
|
||||
.header {
|
||||
text-align: center;
|
||||
font-size: 200%;
|
||||
}
|
||||
#stat {
|
||||
margin: 0 auto;
|
||||
}
|
||||
.authLink {
|
||||
float: right;
|
||||
}
|
||||
</style>
|
||||
<script src="/js/index.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="header" id="header">
|
||||
Идёт загрузка...
|
||||
</div>
|
||||
<main>
|
||||
<replace id="1"/>
|
||||
<table id="stat">
|
||||
</table>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
19
src/main/resources/resources/web/pages/auth/Index.html
Normal file
19
src/main/resources/resources/web/pages/auth/Index.html
Normal file
@ -0,0 +1,19 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title><replace id="1"/></title>
|
||||
<style>
|
||||
form {
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<form method="post" action="/auth/worker/">
|
||||
<label for="user"><replace id="2"/>: <input name="user" id="user" type="text"></label><br>
|
||||
<label for="password"><replace id="3"/>: <input name="password" id="password" type="password"></label><br>
|
||||
<input type="submit">
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
Reference in New Issue
Block a user