Skip to content

Commit

Permalink
Removed OPTIONS /blocks endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
Niels-NTG committed Dec 16, 2022
1 parent 30021fb commit ad96f61
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 18 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ When you open a Minecraft world, this mod opens an HTTP Server on localhost:9000
The current endpoints of the interface are

```
GET,PUT,OPTIONS /blocks Modify blocks in the world
GET,PUT /blocks Modify blocks in the world
POST /command Run Minecraft commands
GET /chunks Get raw chunk nbt data
GET /buildarea Get the build area defined by the /setbuildarea chat command
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,8 @@ public void internalHandle(HttpExchange httpExchange) throws IOException {
} else {
responseString = responseStringBuilder.deleteCharAt(responseStringBuilder.length() - 1).toString();
}

} else if (method.equals("options")) {
responseString = new Gson().toJson(new BlockInfoForOptionsRequest());

} else {
throw new HandlerBase.HttpException("Method not allowed. Only PUT, GET and OPTIONS requests are supported.", 405);
throw new HandlerBase.HttpException("Method not allowed. Only PUT and GET requests are supported.", 405);
}

//headers
Expand Down Expand Up @@ -322,18 +318,6 @@ public static String getBlockRegistryName(Block block) {
return ForgeRegistries.BLOCKS.getKey(block).toString();
}

public class BlockInfoForOptionsRequest {
private String version;
private String[] methods = {"GET", "PUT", "OPTIONS"};
private ArrayList<String> dimensions = new ArrayList<>();
public BlockInfoForOptionsRequest() {
this.version = mcServer.getServerVersion();
for (ResourceKey<Level> levelResourceKey : mcServer.levelKeys()) {
this.dimensions.add(levelResourceKey.location().getPath());
}
}
}

// function that converts a bunch of Property/Comparable pairs into strings that look like 'property=value'
private static final Function<Map.Entry<Property<?>, Comparable<?>>, String> propertyToStringFunction =
new Function<>() {
Expand Down

0 comments on commit ad96f61

Please sign in to comment.