Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
florensie committed Apr 18, 2021
0 parents commit ae30750
Show file tree
Hide file tree
Showing 25 changed files with 1,194 additions and 0 deletions.
118 changes: 118 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
# User-specific stuff
.idea/

*.iml
*.ipr
*.iws

# IntelliJ
out/
# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Compiled class file
*.class

# Log file
*.log

# BlueJ files
*.ctxt

# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

*~

# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*

# KDE directory preferences
.directory

# Linux trash folder which might appear on any partition or disk
.Trash-*

# .nfs files are created when an open file is removed but is still being accessed
.nfs*

# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon

# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

# Windows thumbnail cache files
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db

# Dump file
*.stackdump

# Folder config file
[Dd]esktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp

# Windows shortcuts
*.lnk

.gradle
build/

# Ignore Gradle GUI config
gradle-app.setting

# Cache of project
.gradletasknamecache

**/build/

# Common working directory
run/

# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
!gradle-wrapper.jar
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2021 Florens

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# CraftQL
CraftQL is a server-side Minecraft mod that allows querying and mutating game objects through a schema-driven GraphQL API.
The project is currently quite experimental, proceed with caution.

## Installation
This mod requires Fabric API and Fabric Language Kotlin to be installed.
Several other libraries for GraphQL and a HTTP/Websocket server are included.

## Usage
The GraphQL API is exposed at `http://localhost:8080/graphql`. You can start using the mod immediately with the
[base schema] or you can choose to [replace/expand this schema through a datapack](#custom-schemas).

### Demo
Here you can find a 3-minute video that demonstrates the combined power of a GraphQL API and Minecraft.

[![Demonstration video thumbnail](https://img.youtube.com/vi/N04EBNkHH2g/0.jpg)](https://www.youtube.com/watch?v=N04EBNkHH2g)

## Custom Schemas
There is just one small [base schema] included in the mod. Chances are this doesn't fit your needs,
which is why schemas are supplied fully data-driven.

> Note: the location of this base schema might change in the future
You can make a datapack to add or replace schemas by placing your `.graphqls` file(s) at this path: `data/[namespace]/schemas/`.
All field on your schema's types are resolved at runtime. Remapping to intermediary is also taken care of, CraftQL
assumes your schema uses yarn mappings.

> Note: replacing schemas is currently untested will probably not work
[base schema]: src/main/resources/data/minecraft/schemas/base.graphqls
113 changes: 113 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
plugins {
id 'org.jetbrains.kotlin.jvm' version '1.4.32'
id 'fabric-loom' version '0.7-SNAPSHOT'
id 'maven-publish'
}

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

archivesBaseName = project.archives_base_name
version = project.mod_version
group = project.maven_group

repositories {
mavenCentral()
maven { url = "https://www.cursemaven.com" }
maven {url = "https://jitpack.io" }
}

dependencies {
minecraft "com.mojang:minecraft:${project.minecraft_version}"
include mappings("net.fabricmc:yarn:${project.yarn_version}:v2")
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_api_version}"
modImplementation "net.fabricmc:fabric-language-kotlin:1.5.0+kotlin.1.4.31"

// Dev runtime
modRuntime "curse.maven:lazydfu-433518:3209972"
modRuntime "com.github.alphaqu:DashLoader:master-SNAPSHOT"

// GraphQL
include implementation("com.graphql-java-kickstart:graphql-java-tools:11.0.0") // FIXME: this doesn't have 11.1.0 yet
include implementation("com.graphql-java-kickstart:graphql-java-servlet:${project.graphql_kickstart_version}")

// Jetty
include implementation("org.eclipse.jetty:jetty-webapp:${project.jetty_version}")
include implementation("org.eclipse.jetty:jetty-http:${project.jetty_version}")
include implementation("org.eclipse.jetty:jetty-annotations:${project.jetty_version}")
include implementation("org.eclipse.jetty.websocket:websocket-api:${project.jetty_version}")
include implementation("org.eclipse.jetty.websocket:websocket-server:${project.jetty_version}")
include implementation("org.eclipse.jetty.websocket:javax-websocket-server-impl:${project.jetty_version}")
include implementation("org.eclipse.jetty.websocket:websocket-common:${project.jetty_version}")

// Transitive JiJ TODO: find a better way to do this
// These were manually added until it didn't crash, there might still be something missing
include "com.fasterxml.jackson.core:jackson-core:${project.jackson_version}"
include "com.fasterxml.jackson.core:jackson-annotations:${project.jackson_version}"
include "com.fasterxml.jackson.core:jackson-databind:${project.jackson_version}"
include "com.fasterxml.jackson.datatype:jackson-datatype-jdk8:${project.jackson_version}"
include "com.fasterxml.jackson.module:jackson-module-kotlin:${project.jackson_version}"
include "com.fasterxml:classmate:1.5.0"
include "com.graphql-java:graphql-java:16.1"
include "com.graphql-java:java-dataloader:2.2.3"
include "com.graphql-java-kickstart:graphql-java-kickstart:${project.graphql_kickstart_version}"
include "javax.websocket:javax.websocket-api:1.1"
include "javax.servlet:javax.servlet-api:3.1.0"
include "org.eclipse.jetty:jetty-server:${project.jetty_version}"
include "org.eclipse.jetty:jetty-client:${project.jetty_version}"
include "org.eclipse.jetty:jetty-util:${project.jetty_version}"
include "org.eclipse.jetty:jetty-io:${project.jetty_version}"
include "org.eclipse.jetty:jetty-servlet:${project.jetty_version}"
include "org.eclipse.jetty:jetty-security:${project.jetty_version}"
include "org.eclipse.jetty.websocket:websocket-servlet:${project.jetty_version}"
include "org.eclipse.jetty.websocket:websocket-client:${project.jetty_version}"
include "org.eclipse.jetty.websocket:javax-websocket-client-impl:${project.jetty_version}"
include "org.antlr:antlr4-runtime:4.8"
include "org.reactivestreams:reactive-streams:1.0.2"
include "org.slf4j:slf4j-api:1.7.30"
include "org.apache.commons:commons-lang3:3.9" // FIXME: minecraft loads an older version, breaks a lot of java versions
}

processResources {
duplicatesStrategy(DuplicatesStrategy.WARN)
inputs.property "version", project.version

from(sourceSets.main.resources.srcDirs) {
include "fabric.mod.json"
expand "version": project.version
}

from(sourceSets.main.resources.srcDirs) {
exclude "fabric.mod.json"
}
}

tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
}

task sourcesJar(type: Jar, dependsOn: classes) {
classifier = "sources"
from sourceSets.main.allSource
}

jar {
from "LICENSE"
}

publishing {
publications {
mavenJava(MavenPublication) {
artifact(remapJar) {
builtBy remapJar
}
artifact(sourcesJar) {
builtBy remapSourcesJar
}
}
}

repositories {
}
}
19 changes: 19 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
org.gradle.jvmargs=-Xmx4G

# Fabric Properties (https://modmuss50.me/fabric.html)
minecraft_version=1.16.5
loader_version=0.11.3
yarn_version=1.16.5+build.6
fabric_api_version=0.32.9+1.16

# Mod Properties
mod_version=1.0.0
maven_group=be.florens
archives_base_name=craftql

# Mod Dependencies
graphql_kickstart_version=11.1.0
jetty_version=9.4.28.v20200408

# Transitive Jar-in-Jar
jackson_version=2.12.0
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
5 changes: 5 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit ae30750

Please sign in to comment.