Skip to content
This repository has been archived by the owner on Apr 8, 2022. It is now read-only.

Commit

Permalink
MC 1.13, Den 1.0.3, Java 8, fix meta
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Feb 22, 2019
1 parent 82af81e commit 1bec416
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 11 deletions.
22 changes: 19 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<bukkit.version>1.8.7-R0.1-SNAPSHOT</bukkit.version>
<denizen.version>0.9.7-SNAPSHOT</denizen.version>
<bukkit.version>1.13.2-R0.1-SNAPSHOT</bukkit.version>
<denizen.version>1.0.3-SNAPSHOT</denizen.version>
</properties>

<issueManagement>
<system>GitHub</system>
<url>https://github.com/Morphan1/Webizen/issues</url>
<url>https://github.com/DenizenScript/Webizen/issues</url>
</issueManagement>

<!-- Repositories -->
Expand Down Expand Up @@ -51,4 +51,20 @@
</dependency>
</dependencies>

<build>
<defaultGoal>clean package install</defaultGoal>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<compilerArgument></compilerArgument>
</configuration>
</plugin>
</plugins>
</build>

</project>
10 changes: 5 additions & 5 deletions src/main/java/space/morphanone/webizen/commands/WebCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,22 @@ public class WebCommand extends AbstractCommand {
// @Stable unstable
// @Short Manages the web server ran on your minecraft server
// @Author Morphan1
// @group server

// @group addons
//
// @Description
// Lets you start or stop a web server
// Only one web server can run on the server at once
// The default port when the port argument is not specified, is 80
// TODO: Document command details!

//
// @Usage
// Use to start the web server on port 10123
// - web start port:10123

//
// @Usage
// Use to stop the web server
// - web stop

//
// @Plugin Webizen
// -->

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ public class GetRequestScriptEvent extends BasicRequestScriptEvent {

// <--[event]
// @Events
// GET request
// get request
//
// @Regex ^on get request$
//
// @Cancellable false
//
Expand All @@ -24,7 +26,6 @@ public class GetRequestScriptEvent extends BasicRequestScriptEvent {
// "TYPE:" + Element to set the MIME (multi purpose mail extension) of the response (e.g. text/html)
//
// @Plugin Webizen
//
// -->

public GetRequestScriptEvent() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.sun.net.httpserver.HttpExchange;
import net.aufdemrand.denizen.utilities.DenizenAPI;
import net.aufdemrand.denizen.utilities.Utilities;
import net.aufdemrand.denizencore.objects.Element;
import net.aufdemrand.denizencore.objects.dObject;
import net.aufdemrand.denizencore.scripts.containers.ScriptContainer;
Expand All @@ -17,6 +18,34 @@

public class PostRequestScriptEvent extends BasicRequestScriptEvent {

// <--[event]
// @Events
// post request
//
// @Regex ^on post request$
//
// @Cancellable false
//
// @Triggers when the web server receives a GET request
//
// @Context
// <context.address> Returns the IP address of the device that sent the request.
// <context.request> Returns the path that was requested
// <context.query> Returns a dList of the query included with the request
// <context.user_info> Returns info about the authenticated user sending the request, if any.
// <context.upload_name> returns the name of the file posted.
// <context.upload_size_mb> returns the size of the upload in MegaBytes (where 1 MegaByte = 1 000 000 Bytes).
//
// @Determine
// Element to set the content of the response directly
// "FILE:" + Element to set the file for the response via a file path
// "PARSED_FILE:" + Element to set the parsed file for the response via a file path, this will parse any denizen tags inside the file
// "CODE:" + Element to set the HTTP status code of the response (e.g. 200)
// "TYPE:" + Element to set the MIME (multi purpose mail extension) of the response (e.g. text/html)
// "SAVE_UPLOAD:" + Element to save the upload to a file.
//
// @Plugin Webizen
// -->
public PostRequestScriptEvent() {
instance = this;
}
Expand All @@ -41,12 +70,16 @@ public void fire(HttpExchange httpExchange) {
dB.echoError(e);
}
this.saveUpload = null;

super.fire(httpExchange);

if (this.saveUpload != null) {
try {
File file = new File(DenizenAPI.getCurrentInstance().getDataFolder(), saveUpload.asString());
if (!Utilities.isSafeFile(file)) {
dB.echoError("Save failed: cannot save there!");
return;
}
file.getParentFile().mkdirs();
FileOutputStream outputStream = new FileOutputStream(file);
outputStream.write(this.requestBody);
Expand Down

0 comments on commit 1bec416

Please sign in to comment.