mirror of
https://github.com/GTNewHorizons/CraftTweaker.git
synced 2026-11-25 14:24:28 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4218fc6d6e | ||
|
|
65444eaabd | ||
|
|
9cb4b69fb3 | ||
|
|
c7b559f51d | ||
|
|
0bbae413d8 | ||
|
|
007914da83 | ||
|
|
5f580467d1 | ||
|
|
063d75a36b | ||
|
|
9b255eb1c1 | ||
|
|
b557b56166 | ||
|
|
e7b020545e | ||
|
|
6c70311d0b | ||
|
|
2d878e671b | ||
|
|
8bb680471f | ||
|
|
7f3b65c4b7 |
No files matched your search
@@ -1,19 +0,0 @@
|
|||||||
# This is the universal Text Editor Configuration
|
|
||||||
# for all GTNewHorizons projects
|
|
||||||
# See: https://editorconfig.org/
|
|
||||||
|
|
||||||
root = true
|
|
||||||
|
|
||||||
[*]
|
|
||||||
charset = utf-8
|
|
||||||
end_of_line = lf
|
|
||||||
indent_size = 4
|
|
||||||
indent_style = space
|
|
||||||
insert_final_newline = true
|
|
||||||
trim_trailing_whitespace = true
|
|
||||||
|
|
||||||
[*.{bat,ini}]
|
|
||||||
end_of_line = crlf
|
|
||||||
|
|
||||||
[*.{dtd,json,info,mcmeta,md,sh,svg,xml,xsd,xsl,yaml,yml}]
|
|
||||||
indent_size = 2
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
# Ignore spotlessApply reformat
|
|
||||||
a309488cdf7837ae1a27fab25305405ca7fe34e9
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
* text eol=lf
|
|
||||||
|
|
||||||
*.[jJ][aA][rR] binary
|
|
||||||
|
|
||||||
*.[pP][nN][gG] binary
|
|
||||||
*.[jJ][pP][gG] binary
|
|
||||||
*.[jJ][pP][eE][gG] binary
|
|
||||||
*.[gG][iI][fF] binary
|
|
||||||
*.[tT][iI][fF] binary
|
|
||||||
*.[tT][iI][fF][fF] binary
|
|
||||||
*.[iI][cC][oO] binary
|
|
||||||
*.[sS][vV][gG] text
|
|
||||||
*.[eE][pP][sS] binary
|
|
||||||
*.[xX][cC][fF] binary
|
|
||||||
|
|
||||||
*.[kK][aA][rR] binary
|
|
||||||
*.[mM]4[aA] binary
|
|
||||||
*.[mM][iI][dD] binary
|
|
||||||
*.[mM][iI][dD][iI] binary
|
|
||||||
*.[mM][pP]3 binary
|
|
||||||
*.[oO][gG][gG] binary
|
|
||||||
*.[rR][aA] binary
|
|
||||||
|
|
||||||
*.7[zZ] binary
|
|
||||||
*.[gG][zZ] binary
|
|
||||||
*.[tT][aA][rR] binary
|
|
||||||
*.[tT][gG][zZ] binary
|
|
||||||
*.[zZ][iI][pP] binary
|
|
||||||
|
|
||||||
*.[tT][cC][nN] binary
|
|
||||||
*.[sS][oO] binary
|
|
||||||
*.[dD][lL][lL] binary
|
|
||||||
*.[dD][yY][lL][iI][bB] binary
|
|
||||||
*.[pP][sS][dD] binary
|
|
||||||
*.[tT][tT][fF] binary
|
|
||||||
*.[oO][tT][fF] binary
|
|
||||||
|
|
||||||
*.[pP][aA][tT][cC][hH] -text
|
|
||||||
|
|
||||||
*.[bB][aA][tT] text eol=crlf
|
|
||||||
*.[cC][mM][dD] text eol=crlf
|
|
||||||
*.[pP][sS]1 text eol=crlf
|
|
||||||
|
|
||||||
*[aA][uU][tT][oO][gG][eE][nN][eE][rR][aA][tT][eE][dD]* binary
|
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
directory="run/crash-reports"
|
||||||
|
if [ -d $directory ]; then
|
||||||
|
echo "Crash reports detected:"
|
||||||
|
cat $directory/*
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo "No crash reports detected"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
|
||||||
|
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
|
||||||
|
|
||||||
name: Build and test
|
name: Build and test
|
||||||
|
|
||||||
@@ -9,5 +11,35 @@ on:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-and-test:
|
build-and-test:
|
||||||
uses: GTNewHorizons/GTNH-Actions-Workflows/.github/workflows/build-and-test.yml@master
|
runs-on: ubuntu-latest
|
||||||
secrets: inherit
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Set up JDK 8
|
||||||
|
uses: actions/setup-java@v2
|
||||||
|
with:
|
||||||
|
java-version: '8'
|
||||||
|
distribution: 'adopt'
|
||||||
|
cache: gradle
|
||||||
|
|
||||||
|
- name: Grant execute permission for gradlew
|
||||||
|
run: chmod +x gradlew
|
||||||
|
|
||||||
|
- name: Setup the workspace
|
||||||
|
run: ./gradlew setupCIWorkspace
|
||||||
|
|
||||||
|
- name: Build the mod
|
||||||
|
run: ./gradlew build
|
||||||
|
|
||||||
|
- name: Run server for 1 minute
|
||||||
|
run: |
|
||||||
|
mkdir run
|
||||||
|
echo "eula=true" > run/eula.txt
|
||||||
|
timeout 60 ./gradlew runServer || true
|
||||||
|
|
||||||
|
- name: Test no crashes happend
|
||||||
|
run: |
|
||||||
|
chmod +x .github/scripts/test-no-crash-reports.sh
|
||||||
|
.github/scripts/test-no-crash-reports.sh
|
||||||
@@ -1,14 +1,51 @@
|
|||||||
|
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
|
||||||
|
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
|
||||||
|
|
||||||
name: Release tagged build
|
name: Release tagged build
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
tags: [ '*' ]
|
tags:
|
||||||
|
- '*'
|
||||||
permissions:
|
|
||||||
contents: write
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
release-tags:
|
build:
|
||||||
uses: GTNewHorizons/GTNH-Actions-Workflows/.github/workflows/release-tags.yml@master
|
runs-on: ubuntu-latest
|
||||||
secrets: inherit
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Set release version
|
||||||
|
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Set up JDK 8
|
||||||
|
uses: actions/setup-java@v2
|
||||||
|
with:
|
||||||
|
java-version: '8'
|
||||||
|
distribution: 'adopt'
|
||||||
|
cache: gradle
|
||||||
|
|
||||||
|
- name: Grant execute permission for gradlew
|
||||||
|
run: chmod +x gradlew
|
||||||
|
|
||||||
|
- name: Setup the workspace
|
||||||
|
run: ./gradlew setupCIWorkspace
|
||||||
|
|
||||||
|
- name: Build the mod
|
||||||
|
run: ./gradlew build
|
||||||
|
|
||||||
|
- name: Release under current tag
|
||||||
|
uses: "marvinpinto/action-automatic-releases@latest"
|
||||||
|
with:
|
||||||
|
repo_token: "${{ secrets.GITHUB_TOKEN }}"
|
||||||
|
automatic_release_tag: "${{ env.RELEASE_VERSION }}"
|
||||||
|
prerelease: false
|
||||||
|
title: "${{ env.RELEASE_VERSION }}"
|
||||||
|
files: build/libs/*.jar
|
||||||
|
|
||||||
|
- name: Publish to Maven
|
||||||
|
run: ./gradlew publish
|
||||||
|
env:
|
||||||
|
MAVEN_USER: ${{ secrets.MAVEN_USER }}
|
||||||
|
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
|
||||||
+1
-7
@@ -1,11 +1,9 @@
|
|||||||
.gradle
|
.gradle
|
||||||
.settings
|
.settings
|
||||||
/.idea/
|
/.idea/
|
||||||
.shelf
|
|
||||||
/run/
|
/run/
|
||||||
/build/
|
/build/
|
||||||
/eclipse/
|
/eclipse/
|
||||||
.vscode
|
|
||||||
.classpath
|
.classpath
|
||||||
.project
|
.project
|
||||||
/bin/
|
/bin/
|
||||||
@@ -29,8 +27,4 @@ whitelist.json
|
|||||||
*.iws
|
*.iws
|
||||||
src/main/resources/mixins.*.json
|
src/main/resources/mixins.*.json
|
||||||
*.bat
|
*.bat
|
||||||
/src/main/generated/
|
buildSrc/
|
||||||
/src/test/generated/
|
|
||||||
.DS_Store
|
|
||||||
classes
|
|
||||||
layout.json
|
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
[submodule "ZenScript"]
|
||||||
|
path = ZenScript
|
||||||
|
url = https://github.com/GTNewHorizons/ZenScript.git
|
||||||
Submodule
+1
Submodule ZenScript added at 7b8d3632f3.
+14
-9
@@ -1,12 +1,17 @@
|
|||||||
import minetweaker.tasks.RegisterZenClassesTask
|
sourceSets.main {
|
||||||
|
java.srcDir("ZenScript/src/main/java")
|
||||||
def makeRegistryTask = tasks.register('makeRegistry', RegisterZenClassesTask) {
|
|
||||||
dependsOn("compileJava")
|
|
||||||
inputDir.set(file("build/classes/java/main/"))
|
|
||||||
outputDir.set(file("build/classes/java/main/"))
|
|
||||||
className.set("minetweaker.mc1710.MineTweakerRegistry")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.named("classes").configure {
|
task initZenScript(type: Exec) {
|
||||||
dependsOn(makeRegistryTask)
|
description = "Updates (and inits) git submodules"
|
||||||
|
group = "Build Setup"
|
||||||
|
commandLine("git", "submodule", "update", "--init", "--recursive", "--remote")
|
||||||
|
|
||||||
|
// // Checkout a specific commit. Otherwise the build will fail!
|
||||||
|
// commandLine("git", "--git-dir=\"ZenScript/.git\"", "checkout", "e7144825")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tasks.setupCIWorkspace.dependsOn initZenScript
|
||||||
|
tasks.setupDevWorkspace.dependsOn initZenScript
|
||||||
|
tasks.setupDecompWorkspace.dependsOn initZenScript
|
||||||
|
tasks.compileJava.dependsOn initZenScript
|
||||||
+591
-2
@@ -1,5 +1,594 @@
|
|||||||
//version: 1707058017
|
//version: 1642484596
|
||||||
|
/*
|
||||||
|
DO NOT CHANGE THIS FILE!
|
||||||
|
|
||||||
|
Also, you may replace this file at any time if there is an update available.
|
||||||
|
Please check https://github.com/GTNewHorizons/ExampleMod1.7.10/blob/main/build.gradle for updates.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
import com.github.jengelman.gradle.plugins.shadow.tasks.ConfigureShadowRelocation
|
||||||
|
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||||
|
|
||||||
|
import java.util.concurrent.TimeUnit
|
||||||
|
|
||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
maven {
|
||||||
|
name = "forge"
|
||||||
|
url = "https://maven.minecraftforge.net"
|
||||||
|
}
|
||||||
|
maven {
|
||||||
|
name = "sonatype"
|
||||||
|
url = "https://oss.sonatype.org/content/repositories/snapshots/"
|
||||||
|
}
|
||||||
|
maven {
|
||||||
|
name = "Scala CI dependencies"
|
||||||
|
url = "https://repo1.maven.org/maven2/"
|
||||||
|
}
|
||||||
|
maven {
|
||||||
|
name = "jitpack"
|
||||||
|
url = "https://jitpack.io"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dependencies {
|
||||||
|
classpath 'com.github.GTNewHorizons:ForgeGradle:1.2.5'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id 'com.gtnewhorizons.gtnhconvention'
|
id 'idea'
|
||||||
|
id 'scala'
|
||||||
|
id("org.ajoberstar.grgit") version("3.1.1")
|
||||||
|
id("com.github.johnrengelman.shadow") version("4.0.4")
|
||||||
|
id("com.palantir.git-version") version("0.12.3")
|
||||||
|
id("maven-publish")
|
||||||
|
}
|
||||||
|
|
||||||
|
apply plugin: 'forge'
|
||||||
|
|
||||||
|
def projectJavaVersion = JavaLanguageVersion.of(8)
|
||||||
|
|
||||||
|
java {
|
||||||
|
toolchain {
|
||||||
|
languageVersion.set(projectJavaVersion)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
idea {
|
||||||
|
module {
|
||||||
|
inheritOutputDirs = true
|
||||||
|
downloadJavadoc = true
|
||||||
|
downloadSources = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(JavaVersion.current() != JavaVersion.VERSION_1_8) {
|
||||||
|
throw new GradleException("This project requires Java 8, but it's running on " + JavaVersion.current())
|
||||||
|
}
|
||||||
|
|
||||||
|
checkPropertyExists("modName")
|
||||||
|
checkPropertyExists("modId")
|
||||||
|
checkPropertyExists("modGroup")
|
||||||
|
checkPropertyExists("autoUpdateBuildScript")
|
||||||
|
checkPropertyExists("minecraftVersion")
|
||||||
|
checkPropertyExists("forgeVersion")
|
||||||
|
checkPropertyExists("replaceGradleTokenInFile")
|
||||||
|
checkPropertyExists("gradleTokenModId")
|
||||||
|
checkPropertyExists("gradleTokenModName")
|
||||||
|
checkPropertyExists("gradleTokenVersion")
|
||||||
|
checkPropertyExists("gradleTokenGroupName")
|
||||||
|
checkPropertyExists("apiPackage")
|
||||||
|
checkPropertyExists("accessTransformersFile")
|
||||||
|
checkPropertyExists("usesMixins")
|
||||||
|
checkPropertyExists("mixinPlugin")
|
||||||
|
checkPropertyExists("mixinsPackage")
|
||||||
|
checkPropertyExists("coreModClass")
|
||||||
|
checkPropertyExists("containsMixinsAndOrCoreModOnly")
|
||||||
|
checkPropertyExists("usesShadowedDependencies")
|
||||||
|
checkPropertyExists("developmentEnvironmentUserName")
|
||||||
|
|
||||||
|
boolean noPublishedSources = project.findProperty("noPublishedSources") ? project.noPublishedSources.toBoolean() : false
|
||||||
|
|
||||||
|
String javaSourceDir = "src/main/java/"
|
||||||
|
String scalaSourceDir = "src/main/scala/"
|
||||||
|
|
||||||
|
String targetPackageJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/")
|
||||||
|
String targetPackageScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/")
|
||||||
|
if((getFile(targetPackageJava).exists() || getFile(targetPackageScala).exists()) == false) {
|
||||||
|
throw new GradleException("Could not resolve \"modGroup\"! Could not find " + targetPackageJava + " or " + targetPackageScala)
|
||||||
|
}
|
||||||
|
|
||||||
|
if(apiPackage) {
|
||||||
|
targetPackageJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString().replaceAll("\\.", "/")
|
||||||
|
targetPackageScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString().replaceAll("\\.", "/")
|
||||||
|
if((getFile(targetPackageJava).exists() || getFile(targetPackageScala).exists()) == false) {
|
||||||
|
throw new GradleException("Could not resolve \"apiPackage\"! Could not find " + targetPackageJava + " or " + targetPackageScala)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(accessTransformersFile) {
|
||||||
|
String targetFile = "src/main/resources/META-INF/" + accessTransformersFile
|
||||||
|
if(getFile(targetFile).exists() == false) {
|
||||||
|
throw new GradleException("Could not resolve \"accessTransformersFile\"! Could not find " + targetFile)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(usesMixins.toBoolean()) {
|
||||||
|
if(mixinsPackage.isEmpty() || mixinPlugin.isEmpty()) {
|
||||||
|
throw new GradleException("\"mixinPlugin\" requires \"mixinsPackage\" and \"mixinPlugin\" to be set!")
|
||||||
|
}
|
||||||
|
|
||||||
|
targetPackageJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinsPackage.toString().replaceAll("\\.", "/")
|
||||||
|
targetPackageScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinsPackage.toString().replaceAll("\\.", "/")
|
||||||
|
if((getFile(targetPackageJava).exists() || getFile(targetPackageScala).exists()) == false) {
|
||||||
|
throw new GradleException("Could not resolve \"mixinsPackage\"! Could not find " + targetPackageJava + " or " + targetPackageScala)
|
||||||
|
}
|
||||||
|
|
||||||
|
String targetFileJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinPlugin.toString().replaceAll("\\.", "/") + ".java"
|
||||||
|
String targetFileScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinPlugin.toString().replaceAll("\\.", "/") + ".scala"
|
||||||
|
String targetFileScalaJava = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinPlugin.toString().replaceAll("\\.", "/") + ".java"
|
||||||
|
if((getFile(targetFileJava).exists() || getFile(targetFileScala).exists() || getFile(targetFileScalaJava).exists()) == false) {
|
||||||
|
throw new GradleException("Could not resolve \"mixinPlugin\"! Could not find " + targetFileJava + " or " + targetFileScala + " or " + targetFileScalaJava)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(coreModClass) {
|
||||||
|
String targetFileJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + coreModClass.toString().replaceAll("\\.", "/") + ".java"
|
||||||
|
String targetFileScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + coreModClass.toString().replaceAll("\\.", "/") + ".scala"
|
||||||
|
String targetFileScalaJava = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + coreModClass.toString().replaceAll("\\.", "/") + ".java"
|
||||||
|
if((getFile(targetFileJava).exists() || getFile(targetFileScala).exists() || getFile(targetFileScalaJava).exists()) == false) {
|
||||||
|
throw new GradleException("Could not resolve \"coreModClass\"! Could not find " + targetFileJava + " or " + targetFileScala + " or " + targetFileScalaJava)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
configurations.all {
|
||||||
|
resolutionStrategy.cacheChangingModulesFor(0, TimeUnit.SECONDS)
|
||||||
|
|
||||||
|
// Make sure GregTech build won't time out
|
||||||
|
System.setProperty("org.gradle.internal.http.connectionTimeout", 120000 as String)
|
||||||
|
System.setProperty("org.gradle.internal.http.socketTimeout", 120000 as String)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fix Jenkins' Git: chmod a file should not be detected as a change and append a '.dirty' to the version
|
||||||
|
'git config core.fileMode false'.execute()
|
||||||
|
|
||||||
|
// Pulls version first from the VERSION env and then git tag
|
||||||
|
String identifiedVersion
|
||||||
|
try {
|
||||||
|
String versionOverride = System.getenv("VERSION") ?: null
|
||||||
|
identifiedVersion = versionOverride == null ? gitVersion() : versionOverride
|
||||||
|
version = minecraftVersion + "-" + identifiedVersion
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
throw new IllegalStateException("This mod must be version controlled by Git AND the repository must provide at least one tag, or the VERSION override must be set!");
|
||||||
|
}
|
||||||
|
|
||||||
|
group = modGroup
|
||||||
|
if(project.hasProperty("customArchiveBaseName") && customArchiveBaseName) {
|
||||||
|
archivesBaseName = customArchiveBaseName
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
archivesBaseName = modId
|
||||||
|
}
|
||||||
|
|
||||||
|
minecraft {
|
||||||
|
version = minecraftVersion + "-" + forgeVersion + "-" + minecraftVersion
|
||||||
|
runDir = "run"
|
||||||
|
|
||||||
|
if (replaceGradleTokenInFile) {
|
||||||
|
replaceIn replaceGradleTokenInFile
|
||||||
|
if(gradleTokenModId) {
|
||||||
|
replace gradleTokenModId, modId
|
||||||
|
}
|
||||||
|
if(gradleTokenModName) {
|
||||||
|
replace gradleTokenModName, modName
|
||||||
|
}
|
||||||
|
if(gradleTokenVersion) {
|
||||||
|
replace gradleTokenVersion, versionDetails().lastTag
|
||||||
|
}
|
||||||
|
if(gradleTokenGroupName) {
|
||||||
|
replace gradleTokenGroupName, modGroup
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(file("addon.gradle").exists()) {
|
||||||
|
apply from: "addon.gradle"
|
||||||
|
}
|
||||||
|
|
||||||
|
apply from: 'repositories.gradle'
|
||||||
|
|
||||||
|
configurations {
|
||||||
|
implementation.extendsFrom(shadowImplementation) // TODO: remove after all uses are refactored
|
||||||
|
implementation.extendsFrom(shadowCompile)
|
||||||
|
implementation.extendsFrom(shadeCompile)
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
maven {
|
||||||
|
name = "Overmind forge repo mirror"
|
||||||
|
url = "https://gregtech.overminddl1.com/"
|
||||||
|
}
|
||||||
|
if(usesMixins.toBoolean()) {
|
||||||
|
maven {
|
||||||
|
name = "sponge"
|
||||||
|
url = "https://repo.spongepowered.org/repository/maven-public"
|
||||||
|
}
|
||||||
|
maven {
|
||||||
|
url = "https://jitpack.io"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
if(usesMixins.toBoolean()) {
|
||||||
|
annotationProcessor("org.ow2.asm:asm-debug-all:5.0.3")
|
||||||
|
annotationProcessor("com.google.guava:guava:24.1.1-jre")
|
||||||
|
annotationProcessor("com.google.code.gson:gson:2.8.6")
|
||||||
|
annotationProcessor("org.spongepowered:mixin:0.8-SNAPSHOT")
|
||||||
|
// using 0.8 to workaround a issue in 0.7 which fails mixin application
|
||||||
|
compile("com.github.GTNewHorizons:SpongePoweredMixin:0.7.12-GTNH") {
|
||||||
|
// Mixin includes a lot of dependencies that are too up-to-date
|
||||||
|
exclude module: "launchwrapper"
|
||||||
|
exclude module: "guava"
|
||||||
|
exclude module: "gson"
|
||||||
|
exclude module: "commons-io"
|
||||||
|
exclude module: "log4j-core"
|
||||||
|
}
|
||||||
|
compile("com.github.GTNewHorizons:SpongeMixins:1.5.0")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
apply from: 'dependencies.gradle'
|
||||||
|
|
||||||
|
def mixingConfigRefMap = "mixins." + modId + ".refmap.json"
|
||||||
|
def refMap = "${tasks.compileJava.temporaryDir}" + File.separator + mixingConfigRefMap
|
||||||
|
def mixinSrg = "${tasks.reobf.temporaryDir}" + File.separator + "mixins.srg"
|
||||||
|
|
||||||
|
task generateAssets {
|
||||||
|
if(usesMixins.toBoolean()) {
|
||||||
|
getFile("/src/main/resources/mixins." + modId + ".json").text = """{
|
||||||
|
"required": true,
|
||||||
|
"minVersion": "0.7.11",
|
||||||
|
"package": "${modGroup}.${mixinsPackage}",
|
||||||
|
"plugin": "${modGroup}.${mixinPlugin}",
|
||||||
|
"refmap": "${mixingConfigRefMap}",
|
||||||
|
"target": "@env(DEFAULT)",
|
||||||
|
"compatibilityLevel": "JAVA_8"
|
||||||
|
}
|
||||||
|
|
||||||
|
"""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
task relocateShadowJar(type: ConfigureShadowRelocation) {
|
||||||
|
target = tasks.shadowJar
|
||||||
|
prefix = modGroup + ".shadow"
|
||||||
|
}
|
||||||
|
|
||||||
|
shadowJar {
|
||||||
|
project.configurations.shadeCompile.each { dep ->
|
||||||
|
from(project.zipTree(dep)) {
|
||||||
|
exclude 'META-INF', 'META-INF/**'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
manifest {
|
||||||
|
attributes(getManifestAttributes())
|
||||||
|
}
|
||||||
|
|
||||||
|
minimize() // This will only allow shading for actually used classes
|
||||||
|
configurations = [project.configurations.shadowImplementation, project.configurations.shadowCompile]
|
||||||
|
dependsOn(relocateShadowJar)
|
||||||
|
}
|
||||||
|
|
||||||
|
jar {
|
||||||
|
project.configurations.shadeCompile.each { dep ->
|
||||||
|
from(project.zipTree(dep)) {
|
||||||
|
exclude 'META-INF', 'META-INF/**'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
manifest {
|
||||||
|
attributes(getManifestAttributes())
|
||||||
|
}
|
||||||
|
|
||||||
|
if(usesShadowedDependencies.toBoolean()) {
|
||||||
|
dependsOn(shadowJar)
|
||||||
|
enabled = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
reobf {
|
||||||
|
if(usesMixins.toBoolean()) {
|
||||||
|
addExtraSrgFile mixinSrg
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
afterEvaluate {
|
||||||
|
if(usesMixins.toBoolean()) {
|
||||||
|
tasks.compileJava {
|
||||||
|
options.compilerArgs += [
|
||||||
|
"-AreobfSrgFile=${tasks.reobf.srg}",
|
||||||
|
"-AoutSrgFile=${mixinSrg}",
|
||||||
|
"-AoutRefMapFile=${refMap}",
|
||||||
|
// Elan: from what I understand they are just some linter configs so you get some warning on how to properly code
|
||||||
|
"-XDenableSunApiLintControl",
|
||||||
|
"-XDignore.symbol.file"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
runClient {
|
||||||
|
def arguments = []
|
||||||
|
|
||||||
|
if(usesMixins.toBoolean()) {
|
||||||
|
arguments += [
|
||||||
|
"--mods=../build/libs/$modId-${version}.jar",
|
||||||
|
"--tweakClass org.spongepowered.asm.launch.MixinTweaker"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
if(developmentEnvironmentUserName) {
|
||||||
|
arguments += [
|
||||||
|
"--username",
|
||||||
|
developmentEnvironmentUserName
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
args(arguments)
|
||||||
|
}
|
||||||
|
|
||||||
|
runServer {
|
||||||
|
def arguments = []
|
||||||
|
|
||||||
|
if (usesMixins.toBoolean()) {
|
||||||
|
arguments += [
|
||||||
|
"--mods=../build/libs/$modId-${version}.jar",
|
||||||
|
"--tweakClass org.spongepowered.asm.launch.MixinTweaker"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
args(arguments)
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.withType(JavaExec).configureEach {
|
||||||
|
javaLauncher.set(
|
||||||
|
javaToolchains.launcherFor {
|
||||||
|
languageVersion = projectJavaVersion
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
processResources
|
||||||
|
{
|
||||||
|
// this will ensure that this task is redone when the versions change.
|
||||||
|
inputs.property "version", project.version
|
||||||
|
inputs.property "mcversion", project.minecraft.version
|
||||||
|
|
||||||
|
// replace stuff in mcmod.info, nothing else
|
||||||
|
from(sourceSets.main.resources.srcDirs) {
|
||||||
|
include 'mcmod.info'
|
||||||
|
|
||||||
|
// replace version and mcversion
|
||||||
|
expand "minecraftVersion": project.minecraft.version,
|
||||||
|
"modVersion": versionDetails().lastTag,
|
||||||
|
"modId": modId,
|
||||||
|
"modName": modName
|
||||||
|
}
|
||||||
|
|
||||||
|
if(usesMixins.toBoolean()) {
|
||||||
|
from refMap
|
||||||
|
}
|
||||||
|
|
||||||
|
// copy everything else, thats not the mcmod.info
|
||||||
|
from(sourceSets.main.resources.srcDirs) {
|
||||||
|
exclude 'mcmod.info'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def getManifestAttributes() {
|
||||||
|
def manifestAttributes = [:]
|
||||||
|
if(containsMixinsAndOrCoreModOnly.toBoolean() == false && (usesMixins.toBoolean() || coreModClass)) {
|
||||||
|
manifestAttributes += ["FMLCorePluginContainsFMLMod": true]
|
||||||
|
}
|
||||||
|
|
||||||
|
if(accessTransformersFile) {
|
||||||
|
manifestAttributes += ["FMLAT" : accessTransformersFile.toString()]
|
||||||
|
}
|
||||||
|
|
||||||
|
if(coreModClass) {
|
||||||
|
manifestAttributes += ["FMLCorePlugin": modGroup + "." + coreModClass]
|
||||||
|
}
|
||||||
|
|
||||||
|
if(usesMixins.toBoolean()) {
|
||||||
|
manifestAttributes += [
|
||||||
|
"TweakClass" : "org.spongepowered.asm.launch.MixinTweaker",
|
||||||
|
"MixinConfigs" : "mixins." + modId + ".json",
|
||||||
|
"ForceLoadAsMod" : containsMixinsAndOrCoreModOnly.toBoolean() == false
|
||||||
|
]
|
||||||
|
}
|
||||||
|
return manifestAttributes
|
||||||
|
}
|
||||||
|
|
||||||
|
task sourcesJar(type: Jar) {
|
||||||
|
from (sourceSets.main.allJava)
|
||||||
|
from (file("$projectDir/LICENSE"))
|
||||||
|
getArchiveClassifier().set('sources')
|
||||||
|
}
|
||||||
|
|
||||||
|
task shadowDevJar(type: ShadowJar) {
|
||||||
|
project.configurations.shadeCompile.each { dep ->
|
||||||
|
from(project.zipTree(dep)) {
|
||||||
|
exclude 'META-INF', 'META-INF/**'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
from sourceSets.main.output
|
||||||
|
getArchiveClassifier().set("dev")
|
||||||
|
|
||||||
|
manifest {
|
||||||
|
attributes(getManifestAttributes())
|
||||||
|
}
|
||||||
|
|
||||||
|
minimize() // This will only allow shading for actually used classes
|
||||||
|
configurations = [project.configurations.shadowImplementation, project.configurations.shadowCompile]
|
||||||
|
}
|
||||||
|
|
||||||
|
task relocateShadowDevJar(type: ConfigureShadowRelocation) {
|
||||||
|
target = tasks.shadowDevJar
|
||||||
|
prefix = modGroup + ".shadow"
|
||||||
|
}
|
||||||
|
|
||||||
|
task circularResolverJar(type: Jar) {
|
||||||
|
dependsOn(relocateShadowDevJar)
|
||||||
|
dependsOn(shadowDevJar)
|
||||||
|
enabled = false
|
||||||
|
}
|
||||||
|
|
||||||
|
task devJar(type: Jar) {
|
||||||
|
project.configurations.shadeCompile.each { dep ->
|
||||||
|
from(project.zipTree(dep)) {
|
||||||
|
exclude 'META-INF', 'META-INF/**'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
from sourceSets.main.output
|
||||||
|
getArchiveClassifier().set("dev")
|
||||||
|
|
||||||
|
manifest {
|
||||||
|
attributes(getManifestAttributes())
|
||||||
|
}
|
||||||
|
|
||||||
|
if(usesShadowedDependencies.toBoolean()) {
|
||||||
|
dependsOn(circularResolverJar)
|
||||||
|
enabled = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
task apiJar(type: Jar) {
|
||||||
|
from (sourceSets.main.allJava) {
|
||||||
|
include modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString().replaceAll("\\.", "/") + '/**'
|
||||||
|
}
|
||||||
|
|
||||||
|
from (sourceSets.main.output) {
|
||||||
|
include modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString().replaceAll("\\.", "/") + '/**'
|
||||||
|
}
|
||||||
|
|
||||||
|
from (sourceSets.main.resources.srcDirs) {
|
||||||
|
include("LICENSE")
|
||||||
|
}
|
||||||
|
|
||||||
|
getArchiveClassifier().set('api')
|
||||||
|
}
|
||||||
|
|
||||||
|
artifacts {
|
||||||
|
if(!noPublishedSources) {
|
||||||
|
archives sourcesJar
|
||||||
|
}
|
||||||
|
archives devJar
|
||||||
|
if(apiPackage) {
|
||||||
|
archives apiJar
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// publishing
|
||||||
|
publishing {
|
||||||
|
publications {
|
||||||
|
maven(MavenPublication) {
|
||||||
|
artifact source: usesShadowedDependencies.toBoolean() ? shadowJar : jar, classifier: ""
|
||||||
|
if(!noPublishedSources) {
|
||||||
|
artifact source: sourcesJar, classifier: "src"
|
||||||
|
}
|
||||||
|
artifact source: usesShadowedDependencies.toBoolean() ? shadowDevJar : devJar, classifier: "dev"
|
||||||
|
if (apiPackage) {
|
||||||
|
artifact source: apiJar, classifier: "api"
|
||||||
|
}
|
||||||
|
|
||||||
|
groupId = System.getenv("ARTIFACT_GROUP_ID") ?: "com.github.GTNewHorizons"
|
||||||
|
artifactId = System.getenv("ARTIFACT_ID") ?: project.name
|
||||||
|
// Using the identified version, not project.version as it has the prepended 1.7.10
|
||||||
|
version = System.getenv("RELEASE_VERSION") ?: identifiedVersion
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
maven {
|
||||||
|
url = "http://jenkins.usrv.eu:8081/nexus/content/repositories/releases"
|
||||||
|
credentials {
|
||||||
|
username = System.getenv("MAVEN_USER") ?: "NONE"
|
||||||
|
password = System.getenv("MAVEN_PASSWORD") ?: "NONE"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Updating
|
||||||
|
task updateBuildScript {
|
||||||
|
doLast {
|
||||||
|
if (performBuildScriptUpdate(projectDir.toString())) return
|
||||||
|
|
||||||
|
print("Build script already up-to-date!")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isNewBuildScriptVersionAvailable(projectDir.toString())) {
|
||||||
|
if (autoUpdateBuildScript.toBoolean()) {
|
||||||
|
performBuildScriptUpdate(projectDir.toString())
|
||||||
|
} else {
|
||||||
|
println("Build script update available! Run 'gradle updateBuildScript'")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static URL availableBuildScriptUrl() {
|
||||||
|
new URL("https://raw.githubusercontent.com/GTNewHorizons/ExampleMod1.7.10/main/build.gradle")
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean performBuildScriptUpdate(String projectDir) {
|
||||||
|
if (isNewBuildScriptVersionAvailable(projectDir)) {
|
||||||
|
def buildscriptFile = getFile("build.gradle")
|
||||||
|
availableBuildScriptUrl().withInputStream { i -> buildscriptFile.withOutputStream { it << i } }
|
||||||
|
print("Build script updated. Please REIMPORT the project or RESTART your IDE!")
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean isNewBuildScriptVersionAvailable(String projectDir) {
|
||||||
|
Map parameters = ["connectTimeout": 2000, "readTimeout": 2000]
|
||||||
|
|
||||||
|
String currentBuildScript = getFile("build.gradle").getText()
|
||||||
|
String currentBuildScriptHash = getVersionHash(currentBuildScript)
|
||||||
|
String availableBuildScript = availableBuildScriptUrl().newInputStream(parameters).getText()
|
||||||
|
String availableBuildScriptHash = getVersionHash(availableBuildScript)
|
||||||
|
|
||||||
|
boolean isUpToDate = currentBuildScriptHash.empty || availableBuildScriptHash.empty || currentBuildScriptHash == availableBuildScriptHash
|
||||||
|
return !isUpToDate
|
||||||
|
}
|
||||||
|
|
||||||
|
static String getVersionHash(String buildScriptContent) {
|
||||||
|
String versionLine = buildScriptContent.find("^//version: [a-z0-9]*")
|
||||||
|
if(versionLine != null) {
|
||||||
|
return versionLine.split(": ").last()
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
configure(updateBuildScript) {
|
||||||
|
group = 'forgegradle'
|
||||||
|
description = 'Updates the build script to the latest version'
|
||||||
|
}
|
||||||
|
|
||||||
|
// Helper methods
|
||||||
|
|
||||||
|
def checkPropertyExists(String propertyName) {
|
||||||
|
if (project.hasProperty(propertyName) == false) {
|
||||||
|
throw new GradleException("This project requires a property \"" + propertyName + "\"! Please add it your \"gradle.properties\". You can find all properties and their description here: https://github.com/GTNewHorizons/ExampleMod1.7.10/blob/main/gradle.properties")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def getFile(String relativePath) {
|
||||||
|
return new File(projectDir, relativePath)
|
||||||
}
|
}
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
build/
|
|
||||||
.gradle
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
import java.io.File
|
|
||||||
|
|
||||||
plugins {
|
|
||||||
id("java")
|
|
||||||
}
|
|
||||||
|
|
||||||
java {
|
|
||||||
toolchain {
|
|
||||||
languageVersion.set(JavaLanguageVersion.of(8))
|
|
||||||
vendor.set(JvmVendorSpec.AZUL)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Make sure JAVA_HOME is set as an environment variable
|
|
||||||
ext.javaToolsJar = files(
|
|
||||||
javaToolchains.compilerFor(java.toolchain).map { tc ->
|
|
||||||
new File(tc.executablePath.asFile.parentFile.parentFile, "lib/tools.jar")
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
repositories {
|
|
||||||
mavenCentral();
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
gradleApi()
|
|
||||||
implementation 'org.ow2.asm:asm-debug-all:5.0.3'
|
|
||||||
implementation files(javaToolsJar)
|
|
||||||
}
|
|
||||||
@@ -1,170 +0,0 @@
|
|||||||
package minetweaker.tasks;
|
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileReader;
|
|
||||||
import java.io.FileWriter;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Properties;
|
|
||||||
import java.util.Stack;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
import org.gradle.api.DefaultTask;
|
|
||||||
import org.gradle.api.tasks.InputDirectory;
|
|
||||||
import org.gradle.api.tasks.InputFile;
|
|
||||||
import org.gradle.api.tasks.TaskAction;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Java preprocessor. Enables conditional modification of Java source files.
|
|
||||||
*
|
|
||||||
* @author Stan Hebben
|
|
||||||
*/
|
|
||||||
public class JMorph extends DefaultTask {
|
|
||||||
@InputDirectory
|
|
||||||
public File inputDir;
|
|
||||||
|
|
||||||
@InputFile
|
|
||||||
public File propertiesFile;
|
|
||||||
|
|
||||||
@TaskAction
|
|
||||||
public void doTask() {
|
|
||||||
try {
|
|
||||||
Properties properties = new Properties();
|
|
||||||
BufferedReader reader = new BufferedReader(new FileReader(propertiesFile));
|
|
||||||
properties.load(reader);
|
|
||||||
reader.close();
|
|
||||||
|
|
||||||
processDirectory(inputDir, properties);
|
|
||||||
} catch (IOException ex) {
|
|
||||||
Logger.getLogger(JMorph.class.getName()).log(Level.SEVERE, null, ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void processDirectory(File dir, Properties properties) throws IOException {
|
|
||||||
for (File file : dir.listFiles()) {
|
|
||||||
if (file.isFile()) {
|
|
||||||
if (file.getName().endsWith(".java") || file.getName().endsWith(".java.d")) {
|
|
||||||
processJavaFile(file, properties);
|
|
||||||
}
|
|
||||||
} else if (file.isDirectory()) {
|
|
||||||
processDirectory(file, properties);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void processJavaFile(File file, Properties properties) throws IOException {
|
|
||||||
StringBuilder output = new StringBuilder();
|
|
||||||
|
|
||||||
File outputFile = file.getName().endsWith(".java.d")
|
|
||||||
? new File(file.getParentFile(), file.getName().substring(0, file.getName().length() - 2))
|
|
||||||
: file;
|
|
||||||
|
|
||||||
try (BufferedReader reader = new BufferedReader(new FileReader(file))) {
|
|
||||||
String line = reader.readLine();
|
|
||||||
if (line == null) return;
|
|
||||||
|
|
||||||
Stack<Boolean> conditions = new Stack<>();
|
|
||||||
conditions.push(Boolean.TRUE);
|
|
||||||
do {
|
|
||||||
String trimmed = line.trim();
|
|
||||||
if (trimmed.startsWith("//#fileifdef")) {
|
|
||||||
String id = getIdentifier(trimmed, 13);
|
|
||||||
if (properties.containsKey(id)) {
|
|
||||||
if (file.getName().endsWith(".java.d")) {
|
|
||||||
outputFile = new File(file.getParentFile(), file.getName().substring(0, file.getName().length() - 2));
|
|
||||||
} else {
|
|
||||||
outputFile = file;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (file.getName().endsWith(".java")) {
|
|
||||||
outputFile = new File(file.getParentFile(), file.getName() + ".d");
|
|
||||||
} else {
|
|
||||||
outputFile = file;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (trimmed.startsWith("//#fileifndef")) {
|
|
||||||
String id = getIdentifier(trimmed, 14);
|
|
||||||
if (!properties.containsKey(id)) {
|
|
||||||
outputFile = file.getName().endsWith(".java.d")
|
|
||||||
? new File(file.getParentFile(), file.getName().substring(0, file.getName().length() - 2))
|
|
||||||
: file;
|
|
||||||
} else {
|
|
||||||
outputFile = file.getName().endsWith(".java")
|
|
||||||
? new File(file.getParentFile(), file.getName() + ".d")
|
|
||||||
: file;
|
|
||||||
}
|
|
||||||
} else if (trimmed.startsWith("//#ifdef")) {
|
|
||||||
String id = getIdentifier(trimmed, 9);
|
|
||||||
conditions.push(properties.containsKey(id));
|
|
||||||
} else if (trimmed.startsWith("//#ifndef")) {
|
|
||||||
String id = getIdentifier(trimmed, 10);
|
|
||||||
conditions.push(!properties.containsKey(id));
|
|
||||||
} else if (trimmed.startsWith("//#else")) {
|
|
||||||
conditions.push(!conditions.pop());
|
|
||||||
} else if (trimmed.startsWith("//#elseif")) {
|
|
||||||
conditions.pop();
|
|
||||||
String id = getIdentifier(trimmed, 10);
|
|
||||||
conditions.push(properties.containsKey(id));
|
|
||||||
} else if (trimmed.startsWith("//#endif")) {
|
|
||||||
conditions.pop();
|
|
||||||
if (conditions.isEmpty()) {
|
|
||||||
System.err.println("Error: too many #endifs in " + file.getName());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} else if (trimmed.startsWith("//+")) {
|
|
||||||
if (conditions.peek()) line = uncomment(line).toString();
|
|
||||||
} else if (trimmed.length() != 0) {
|
|
||||||
if (!conditions.peek()) line = comment(line).toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
output.append(line).append('\n');
|
|
||||||
|
|
||||||
line = reader.readLine();
|
|
||||||
} while (line != null);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (outputFile != file)
|
|
||||||
file.delete();
|
|
||||||
|
|
||||||
try (FileWriter writer = new FileWriter(outputFile)) {
|
|
||||||
writer.append(output);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static CharSequence comment(String line) {
|
|
||||||
StringBuilder output = new StringBuilder();
|
|
||||||
for (int i = 0; i < line.length(); i++) {
|
|
||||||
if (line.charAt(i) == ' ' || line.charAt(i) == '\t') {
|
|
||||||
output.append(line.charAt(i));
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
output.append("//+").append(line.substring(i));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return output;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static CharSequence uncomment(String line) {
|
|
||||||
StringBuilder output = new StringBuilder();
|
|
||||||
for (int i = 0; i < line.length(); i++) {
|
|
||||||
if (line.charAt(i) == ' ' || line.charAt(i) == '\t') {
|
|
||||||
output.append(line.charAt(i));
|
|
||||||
} else if (line.charAt(i) == '/' && line.charAt(i + 1) == '/' && line.charAt(i + 2) == '+') {
|
|
||||||
output.append(line.substring(i + 3));
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
return line;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return output;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String getIdentifier(String line, int offset) {
|
|
||||||
int from = offset;
|
|
||||||
int to = offset;
|
|
||||||
if (!Character.isJavaIdentifierStart(line.charAt(to))) return null;
|
|
||||||
to++;
|
|
||||||
while (to < line.length() && Character.isJavaIdentifierPart(line.charAt(to))) to++;
|
|
||||||
return line.substring(from, to);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package minetweaker.tasks;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import org.gradle.api.DefaultTask;
|
|
||||||
import org.gradle.api.tasks.InputFile;
|
|
||||||
import org.gradle.api.tasks.OutputFile;
|
|
||||||
import org.gradle.api.tasks.TaskAction;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class MergeJarsTask extends DefaultTask {
|
|
||||||
@InputFile
|
|
||||||
public File mainInput;
|
|
||||||
|
|
||||||
@InputFile
|
|
||||||
public File[] inputs;
|
|
||||||
|
|
||||||
@OutputFile
|
|
||||||
public File output;
|
|
||||||
|
|
||||||
@TaskAction
|
|
||||||
public void doTask() {
|
|
||||||
System.out.println("Main: " + mainInput.toString());
|
|
||||||
System.out.println("Inputs: " + inputs.length);
|
|
||||||
System.out.println("Output: " + output.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,205 +0,0 @@
|
|||||||
package minetweaker.tasks;
|
|
||||||
|
|
||||||
import java.io.BufferedInputStream;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
import org.gradle.api.DefaultTask;
|
|
||||||
import org.gradle.api.file.DirectoryProperty;
|
|
||||||
import org.gradle.api.provider.Property;
|
|
||||||
import org.gradle.api.tasks.Input;
|
|
||||||
import org.gradle.api.tasks.InputDirectory;
|
|
||||||
import org.gradle.api.tasks.Optional;
|
|
||||||
import org.gradle.api.tasks.OutputDirectory;
|
|
||||||
import org.gradle.api.tasks.TaskAction;
|
|
||||||
import org.objectweb.asm.AnnotationVisitor;
|
|
||||||
import org.objectweb.asm.ClassReader;
|
|
||||||
import org.objectweb.asm.ClassVisitor;
|
|
||||||
import org.objectweb.asm.ClassWriter;
|
|
||||||
import org.objectweb.asm.MethodVisitor;
|
|
||||||
import org.objectweb.asm.Opcodes;
|
|
||||||
import org.objectweb.asm.Type;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Generates a native registrar class. Finds all classes with a @ZenClass or
|
|
||||||
* @ZenExpansion annotation and generates a class with a single static
|
|
||||||
* getClasses(List<Class>) method. Overrides existing files if they exist.
|
|
||||||
* (handy for having a stub in the original source)
|
|
||||||
*
|
|
||||||
* @author Stan Hebben
|
|
||||||
*/
|
|
||||||
public abstract class RegisterZenClassesTask extends DefaultTask {
|
|
||||||
@InputDirectory
|
|
||||||
public abstract DirectoryProperty getInputDir();
|
|
||||||
|
|
||||||
@OutputDirectory
|
|
||||||
@Optional
|
|
||||||
public abstract DirectoryProperty getOutputDir();
|
|
||||||
|
|
||||||
@Input
|
|
||||||
public abstract Property<String> getClassName();
|
|
||||||
|
|
||||||
public RegisterZenClassesTask() {
|
|
||||||
getOutputDir().convention(getInputDir());
|
|
||||||
}
|
|
||||||
|
|
||||||
@TaskAction
|
|
||||||
public void doTask() {
|
|
||||||
final File inputDir = getInputDir().get().getAsFile();
|
|
||||||
final File outputDir = getOutputDir().get().getAsFile();
|
|
||||||
final String className = getClassName().get();
|
|
||||||
|
|
||||||
List<String> classNames = new ArrayList<>();
|
|
||||||
List<OnRegisterMethod> onRegisterMethods = new ArrayList<>();
|
|
||||||
iterate(inputDir, null, classNames, onRegisterMethods);
|
|
||||||
|
|
||||||
String fullClassName = className.replace('.', '/');
|
|
||||||
|
|
||||||
// generate class
|
|
||||||
ClassWriter output = new ClassWriter(ClassWriter.COMPUTE_MAXS);
|
|
||||||
output.visit(Opcodes.V1_6, Opcodes.ACC_PUBLIC, fullClassName, null, "java/lang/Object", null);
|
|
||||||
|
|
||||||
MethodVisitor method = output.visitMethod(Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC, "getClasses", "(Ljava/util/List;)V", null, null);
|
|
||||||
method.visitCode();
|
|
||||||
|
|
||||||
for (String clsName : classNames) {
|
|
||||||
method.visitVarInsn(Opcodes.ALOAD, 0);
|
|
||||||
method.visitLdcInsn(Type.getType("L" + clsName + ";"));
|
|
||||||
method.visitMethodInsn(Opcodes.INVOKEINTERFACE, "java/util/List", "add", "(Ljava/lang/Object;)Z", true);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (OnRegisterMethod onRegisterMethod : onRegisterMethods) {
|
|
||||||
method.visitMethodInsn(Opcodes.INVOKESTATIC, onRegisterMethod.className, onRegisterMethod.methodName, "()V", false);
|
|
||||||
}
|
|
||||||
|
|
||||||
method.visitInsn(Opcodes.RETURN);
|
|
||||||
|
|
||||||
method.visitMaxs(0, 0);
|
|
||||||
method.visitEnd();
|
|
||||||
|
|
||||||
output.visitEnd();
|
|
||||||
|
|
||||||
// write output file
|
|
||||||
File outputFile = new File(outputDir, fullClassName + ".class");
|
|
||||||
File outputFileDir = outputFile.getParentFile();
|
|
||||||
if (!outputFileDir.exists()) {
|
|
||||||
outputFileDir.mkdirs();
|
|
||||||
}
|
|
||||||
if (outputFile.exists()) {
|
|
||||||
outputFile.delete();
|
|
||||||
}
|
|
||||||
|
|
||||||
try(FileOutputStream outputStream = new FileOutputStream(outputFile)) {
|
|
||||||
outputStream.write(output.toByteArray());
|
|
||||||
} catch (IOException ex) {
|
|
||||||
Logger.getLogger(RegisterZenClassesTask.class.getName()).log(Level.SEVERE, null, ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void iterate(File dir, String pkg, List<String> classNames, List<OnRegisterMethod> onRegisterMethods) {
|
|
||||||
for (File f : dir.listFiles()) {
|
|
||||||
if (f.isDirectory()) {
|
|
||||||
if (pkg == null) {
|
|
||||||
iterate(f, f.getName(), classNames, onRegisterMethods);
|
|
||||||
} else {
|
|
||||||
iterate(f, pkg + "/" + f.getName(), classNames, onRegisterMethods);
|
|
||||||
}
|
|
||||||
} else if (f.isFile()) {
|
|
||||||
if (f.getName().endsWith(".class")) {
|
|
||||||
processJavaClass(f, pkg, classNames, onRegisterMethods);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void processJavaClass(File cls, String pkg, List<String> classNames, List<OnRegisterMethod> onRegisterMethods) {
|
|
||||||
try(InputStream input = new BufferedInputStream(new FileInputStream(cls))) {
|
|
||||||
ClassReader reader = new ClassReader(input);
|
|
||||||
|
|
||||||
AnnotationDetector detector = new AnnotationDetector();
|
|
||||||
reader.accept(detector, ClassReader.SKIP_CODE);
|
|
||||||
input.close();
|
|
||||||
|
|
||||||
if (detector.isAnnotated) {
|
|
||||||
classNames.add(pkg + "/" + cls.getName().substring(0, cls.getName().length() - 6));
|
|
||||||
}
|
|
||||||
for (MethodAnnotationDetector onRegisterMethod : detector.onRegister) {
|
|
||||||
onRegisterMethods.add(new OnRegisterMethod(
|
|
||||||
pkg + "/" + cls.getName().substring(0, cls.getName().length() - 6),
|
|
||||||
onRegisterMethod.name));
|
|
||||||
}
|
|
||||||
} catch (IOException ex) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class AnnotationDetector extends ClassVisitor {
|
|
||||||
private boolean isAnnotated = false;
|
|
||||||
private List<MethodAnnotationDetector> onRegister = new ArrayList<>();
|
|
||||||
|
|
||||||
public AnnotationDetector() {
|
|
||||||
super(Opcodes.ASM5);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
|
|
||||||
if (desc.equals("Lstanhebben/zenscript/annotations/ZenExpansion;")) {
|
|
||||||
isAnnotated = true;
|
|
||||||
} else if (desc.equals("Lstanhebben/zenscript/annotations/ZenClass;")) {
|
|
||||||
isAnnotated = true;
|
|
||||||
} else if (desc.equals("Lminetweaker/annotations/BracketHandler;")) {
|
|
||||||
isAnnotated = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return super.visitAnnotation(desc, visible);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
|
|
||||||
return new MethodAnnotationDetector(this, name, desc);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class MethodAnnotationDetector extends MethodVisitor {
|
|
||||||
private final AnnotationDetector detector;
|
|
||||||
private final String name;
|
|
||||||
private final String desc;
|
|
||||||
|
|
||||||
public MethodAnnotationDetector(AnnotationDetector detector, String name, String desc) {
|
|
||||||
super(Opcodes.ASM4);
|
|
||||||
|
|
||||||
this.detector = detector;
|
|
||||||
this.name = name;
|
|
||||||
this.desc = desc;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
|
|
||||||
if (desc.equals("Lminetweaker/annotations/OnRegister;")) {
|
|
||||||
if (this.desc.equals("()V")) {
|
|
||||||
detector.onRegister.add(this);
|
|
||||||
} else {
|
|
||||||
throw new RuntimeException("OnRegister annotation must be used on a static method without arguments or return value");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return super.visitAnnotation(desc, visible);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class OnRegisterMethod {
|
|
||||||
private final String className;
|
|
||||||
private final String methodName;
|
|
||||||
|
|
||||||
public OnRegisterMethod(String className, String methodName) {
|
|
||||||
this.className = className;
|
|
||||||
this.methodName = methodName;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
package stanhebben.zenscript.annotations;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Used to indicate comparison types.
|
|
||||||
*
|
|
||||||
* @author Stan Hebben
|
|
||||||
*/
|
|
||||||
public enum CompareType {
|
|
||||||
LT,
|
|
||||||
GT,
|
|
||||||
EQ,
|
|
||||||
NE,
|
|
||||||
LE,
|
|
||||||
GE
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
package stanhebben.zenscript.annotations;
|
|
||||||
|
|
||||||
import java.lang.annotation.ElementType;
|
|
||||||
import java.lang.annotation.Retention;
|
|
||||||
import java.lang.annotation.RetentionPolicy;
|
|
||||||
import java.lang.annotation.Target;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Makes a class implementing List expose itself as iterable over keys and values.
|
|
||||||
*
|
|
||||||
* @author Stan Hebben
|
|
||||||
*/
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
|
||||||
@Target(ElementType.TYPE)
|
|
||||||
public @interface IterableList {
|
|
||||||
String value();
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
package stanhebben.zenscript.annotations;
|
|
||||||
|
|
||||||
import java.lang.annotation.ElementType;
|
|
||||||
import java.lang.annotation.Retention;
|
|
||||||
import java.lang.annotation.RetentionPolicy;
|
|
||||||
import java.lang.annotation.Target;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Makes a class implementing Map expose itself as iterable over keys and values.
|
|
||||||
*
|
|
||||||
* @author Stan Hebben
|
|
||||||
*/
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
|
||||||
@Target(ElementType.TYPE)
|
|
||||||
public @interface IterableMap {
|
|
||||||
String key();
|
|
||||||
String value();
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
package stanhebben.zenscript.annotations;
|
|
||||||
|
|
||||||
import java.lang.annotation.ElementType;
|
|
||||||
import java.lang.annotation.Retention;
|
|
||||||
import java.lang.annotation.RetentionPolicy;
|
|
||||||
import java.lang.annotation.Target;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Indicates a simple iterable. Annotated class must implement the iterable
|
|
||||||
* interface.
|
|
||||||
*
|
|
||||||
* @author Stan Hebben
|
|
||||||
*/
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
|
||||||
@Target(ElementType.TYPE)
|
|
||||||
public @interface IterableSimple {
|
|
||||||
String value();
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
package stanhebben.zenscript.annotations;
|
|
||||||
|
|
||||||
import java.lang.annotation.ElementType;
|
|
||||||
import java.lang.annotation.Retention;
|
|
||||||
import java.lang.annotation.RetentionPolicy;
|
|
||||||
import java.lang.annotation.Target;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Indicates that the given method parameter cannot be null.
|
|
||||||
*
|
|
||||||
* @author Stan Hebben
|
|
||||||
*/
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
|
||||||
@Target(ElementType.PARAMETER)
|
|
||||||
public @interface NotNull {
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
package stanhebben.zenscript.annotations;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Enum used to indicate operator type.
|
|
||||||
*
|
|
||||||
* @author Stan Hebben
|
|
||||||
*/
|
|
||||||
public enum OperatorType {
|
|
||||||
ADD,
|
|
||||||
SUB,
|
|
||||||
MUL,
|
|
||||||
DIV,
|
|
||||||
MOD,
|
|
||||||
CAT,
|
|
||||||
OR,
|
|
||||||
AND,
|
|
||||||
XOR,
|
|
||||||
NEG,
|
|
||||||
NOT,
|
|
||||||
INDEXSET,
|
|
||||||
INDEXGET,
|
|
||||||
RANGE,
|
|
||||||
CONTAINS,
|
|
||||||
COMPARE,
|
|
||||||
MEMBERGETTER,
|
|
||||||
MEMBERSETTER,
|
|
||||||
EQUALS
|
|
||||||
}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
package stanhebben.zenscript.annotations;
|
|
||||||
|
|
||||||
import java.lang.annotation.ElementType;
|
|
||||||
import java.lang.annotation.Retention;
|
|
||||||
import java.lang.annotation.RetentionPolicy;
|
|
||||||
import java.lang.annotation.Target;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Denotes that this parameter is optional. Inside the script, this parameter
|
|
||||||
* may be omitted, in which case it is automatically filled with the default
|
|
||||||
* value of that parameter type (false, null or 0). Invalid for @NonNull type.
|
|
||||||
*
|
|
||||||
* @author Stanneke
|
|
||||||
*/
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
|
||||||
@Target(ElementType.PARAMETER)
|
|
||||||
public @interface Optional {
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
package stanhebben.zenscript.annotations;
|
|
||||||
|
|
||||||
import java.lang.annotation.ElementType;
|
|
||||||
import java.lang.annotation.Retention;
|
|
||||||
import java.lang.annotation.RetentionPolicy;
|
|
||||||
import java.lang.annotation.Target;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Denotes a caster. Casters are capable of converting one type into another.
|
|
||||||
* They implement the 'as' operator.
|
|
||||||
*
|
|
||||||
* For a native class, no arguments are provided. For an expansion method, the
|
|
||||||
* argument is the source value.
|
|
||||||
*
|
|
||||||
* @author Stan Hebben
|
|
||||||
*/
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
|
||||||
@Target(ElementType.METHOD)
|
|
||||||
public @interface ZenCaster {
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
package stanhebben.zenscript.annotations;
|
|
||||||
|
|
||||||
import java.lang.annotation.ElementType;
|
|
||||||
import java.lang.annotation.Retention;
|
|
||||||
import java.lang.annotation.RetentionPolicy;
|
|
||||||
import java.lang.annotation.Target;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Exposes this class to ZenScript. The class can then be imported and accessed
|
|
||||||
* into any script.
|
|
||||||
*
|
|
||||||
* @author Stan Hebben
|
|
||||||
*/
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
|
||||||
@Target({ElementType.TYPE, ElementType.METHOD})
|
|
||||||
public @interface ZenClass {
|
|
||||||
/**
|
|
||||||
* Contains the class' package and name. If omitted, the java package and
|
|
||||||
* name will be used.
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
String value() default "";
|
|
||||||
}
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
package stanhebben.zenscript.annotations;
|
|
||||||
|
|
||||||
import java.lang.annotation.ElementType;
|
|
||||||
import java.lang.annotation.Retention;
|
|
||||||
import java.lang.annotation.RetentionPolicy;
|
|
||||||
import java.lang.annotation.Target;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Indicates that the given class contains an expansion for a certain type.
|
|
||||||
* The expansions themselves are given through annotated static methods.
|
|
||||||
*
|
|
||||||
* @author Stan Hebben
|
|
||||||
*/
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
|
||||||
@Target({ElementType.TYPE, ElementType.METHOD})
|
|
||||||
public @interface ZenExpansion {
|
|
||||||
/**
|
|
||||||
* Contains the type of the annotated class. May be any kind of ZenScript type.
|
|
||||||
*
|
|
||||||
* Examples:
|
|
||||||
* <ul>
|
|
||||||
* <li>int</li>
|
|
||||||
* <li>my.package.MyClass</li>
|
|
||||||
* <li>my.package.MyClass[]</li>
|
|
||||||
* <li>any</li>
|
|
||||||
* <li>any[]</li>
|
|
||||||
* <li>any[any]</li>
|
|
||||||
* </li>
|
|
||||||
* </ul>
|
|
||||||
*
|
|
||||||
* @return expanded type
|
|
||||||
*/
|
|
||||||
public String value();
|
|
||||||
}
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
package stanhebben.zenscript.annotations;
|
|
||||||
|
|
||||||
import java.lang.annotation.ElementType;
|
|
||||||
import java.lang.annotation.Retention;
|
|
||||||
import java.lang.annotation.RetentionPolicy;
|
|
||||||
import java.lang.annotation.Target;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Indicates a getter. Will make the given method accessible as getter, that is,
|
|
||||||
* it's called when value.name is being used.
|
|
||||||
*
|
|
||||||
* For a native class, no arguments are provided. For an expansion, a single
|
|
||||||
* argument with the source value is provided.
|
|
||||||
*
|
|
||||||
* @author Stan Hebben
|
|
||||||
*/
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
|
||||||
@Target(ElementType.METHOD)
|
|
||||||
public @interface ZenGetter {
|
|
||||||
/**
|
|
||||||
* Getter name. If omitted, the method name will be used as value name.
|
|
||||||
*
|
|
||||||
* @return getter name
|
|
||||||
*/
|
|
||||||
String value() default "";
|
|
||||||
}
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
package stanhebben.zenscript.annotations;
|
|
||||||
|
|
||||||
import java.lang.annotation.ElementType;
|
|
||||||
import java.lang.annotation.Retention;
|
|
||||||
import java.lang.annotation.RetentionPolicy;
|
|
||||||
import java.lang.annotation.Target;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Indicates a member getter. A member getter is a special kind of operator which
|
|
||||||
* is a fallback if a member could not be resolved. Can be used to make contents
|
|
||||||
* available as if they were members.
|
|
||||||
*
|
|
||||||
* If this method is a native class, it accepts a single string parameter with
|
|
||||||
* the member name. If this method is an expansion method, it accepts the source
|
|
||||||
* value and the member name.
|
|
||||||
*
|
|
||||||
* @author Stan Hebben
|
|
||||||
*/
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
|
||||||
@Target(ElementType.METHOD)
|
|
||||||
public @interface ZenMemberGetter {
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
package stanhebben.zenscript.annotations;
|
|
||||||
|
|
||||||
import java.lang.annotation.ElementType;
|
|
||||||
import java.lang.annotation.Retention;
|
|
||||||
import java.lang.annotation.RetentionPolicy;
|
|
||||||
import java.lang.annotation.Target;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Used to indicate a member setter. Companion to member getters, but allow
|
|
||||||
* setting contents of this object as if they were members.
|
|
||||||
*
|
|
||||||
* If this method is a native class, it accepts a string parameter with
|
|
||||||
* the member name and a second parameter with the value. If this method is an
|
|
||||||
* expansion method, it accepts the source value, the member name and the value
|
|
||||||
* to be assigned.
|
|
||||||
*
|
|
||||||
* @author Stan Hebben
|
|
||||||
*/
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
|
||||||
@Target(ElementType.METHOD)
|
|
||||||
public @interface ZenMemberSetter {
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
package stanhebben.zenscript.annotations;
|
|
||||||
|
|
||||||
import java.lang.annotation.ElementType;
|
|
||||||
import java.lang.annotation.Retention;
|
|
||||||
import java.lang.annotation.RetentionPolicy;
|
|
||||||
import java.lang.annotation.Target;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Used to indicate an exposed method.
|
|
||||||
*
|
|
||||||
* If this method is part of a native class, it will simply accept the parameters
|
|
||||||
* as provided. If it is part of an expansion method, it will also accept the
|
|
||||||
* instance value as first parameter.
|
|
||||||
*
|
|
||||||
* @author Stan Hebben
|
|
||||||
*/
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
|
||||||
@Target(ElementType.METHOD)
|
|
||||||
public @interface ZenMethod {
|
|
||||||
/**
|
|
||||||
* Method name. If omitted, the original method name will be used.
|
|
||||||
*
|
|
||||||
* @return method name
|
|
||||||
*/
|
|
||||||
public String value() default "";
|
|
||||||
}
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package stanhebben.zenscript.annotations;
|
|
||||||
|
|
||||||
import java.lang.annotation.ElementType;
|
|
||||||
import java.lang.annotation.Retention;
|
|
||||||
import java.lang.annotation.RetentionPolicy;
|
|
||||||
import java.lang.annotation.Target;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Used to indicate static methods for expansions. For native classes, use ZenMethod
|
|
||||||
* instead on a static method.
|
|
||||||
*
|
|
||||||
* @author Stan Hebben
|
|
||||||
*/
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
|
||||||
@Target(ElementType.METHOD)
|
|
||||||
public @interface ZenMethodStatic {
|
|
||||||
/**
|
|
||||||
* Method name. If omitted, the annotated method name will be used.
|
|
||||||
*
|
|
||||||
* @return method name
|
|
||||||
*/
|
|
||||||
public String value() default "";
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
package stanhebben.zenscript.annotations;
|
|
||||||
|
|
||||||
import java.lang.annotation.ElementType;
|
|
||||||
import java.lang.annotation.Retention;
|
|
||||||
import java.lang.annotation.RetentionPolicy;
|
|
||||||
import java.lang.annotation.Target;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Used to indicate an operator. The arguments depend on the kind of operator.
|
|
||||||
*
|
|
||||||
* @author Stan Hebben
|
|
||||||
*/
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
|
||||||
@Target(ElementType.METHOD)
|
|
||||||
public @interface ZenOperator {
|
|
||||||
/**
|
|
||||||
* Operator type for this operator.
|
|
||||||
*
|
|
||||||
* @return operator type
|
|
||||||
*/
|
|
||||||
OperatorType value();
|
|
||||||
}
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
package stanhebben.zenscript.annotations;
|
|
||||||
|
|
||||||
import java.lang.annotation.ElementType;
|
|
||||||
import java.lang.annotation.Retention;
|
|
||||||
import java.lang.annotation.RetentionPolicy;
|
|
||||||
import java.lang.annotation.Target;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Used to annotate setters. Will make the given method accessible as setter, that is,
|
|
||||||
* it's called when value.name is being assinged a value.
|
|
||||||
*
|
|
||||||
* For a native class, a single argument with the assinged value is provided.
|
|
||||||
* For an expansion, the target object and assigned value are provided.
|
|
||||||
*
|
|
||||||
* @author Stan Hebben
|
|
||||||
*/
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
|
||||||
@Target(ElementType.METHOD)
|
|
||||||
public @interface ZenSetter {
|
|
||||||
/**
|
|
||||||
* Setter name. If omitted, the method name is used as property name.
|
|
||||||
*
|
|
||||||
* @return setter name
|
|
||||||
*/
|
|
||||||
String value() default "";
|
|
||||||
}
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package stanhebben.zenscript.docs;
|
|
||||||
|
|
||||||
import com.sun.javadoc.MethodDoc;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class ZenCasterDoc {
|
|
||||||
private final MethodDoc method;
|
|
||||||
|
|
||||||
public ZenCasterDoc(MethodDoc method) {
|
|
||||||
this.method = method;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MethodDoc getMethod() {
|
|
||||||
return method;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package stanhebben.zenscript.docs;
|
|
||||||
|
|
||||||
import com.sun.javadoc.ClassDoc;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class ZenClassDoc {
|
|
||||||
private final ClassDoc cls;
|
|
||||||
private final String name;
|
|
||||||
private final List<ZenExpansionDoc> expansions;
|
|
||||||
|
|
||||||
public ZenClassDoc(ClassDoc cls, String name) {
|
|
||||||
this.cls = cls;
|
|
||||||
this.name = name;
|
|
||||||
expansions = new ArrayList<ZenExpansionDoc>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ClassDoc getDoc() {
|
|
||||||
return cls;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addExpansion(ZenExpansionDoc expansion) {
|
|
||||||
expansions.add(expansion);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<ZenExpansionDoc> getExpansions() {
|
|
||||||
return expansions;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package stanhebben.zenscript.docs;
|
|
||||||
|
|
||||||
import com.sun.javadoc.ClassDoc;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class ZenExpansionDoc {
|
|
||||||
private final ClassDoc cls;
|
|
||||||
private final String type;
|
|
||||||
|
|
||||||
public ZenExpansionDoc(ClassDoc cls, String type) {
|
|
||||||
this.cls = cls;
|
|
||||||
this.type = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getType() {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ClassDoc getDoc() {
|
|
||||||
return cls;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package stanhebben.zenscript.docs;
|
|
||||||
|
|
||||||
import com.sun.javadoc.MethodDoc;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class ZenMethodDoc {
|
|
||||||
private final String name;
|
|
||||||
private final MethodDoc method;
|
|
||||||
private final List<ZenParameterDoc> parameters;
|
|
||||||
|
|
||||||
public ZenMethodDoc(String name, MethodDoc method, List<ZenParameterDoc> parameters) {
|
|
||||||
this.name = name;
|
|
||||||
this.method = method;
|
|
||||||
this.parameters = parameters;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MethodDoc getDoc() {
|
|
||||||
return method;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<ZenParameterDoc> getParameters() {
|
|
||||||
return parameters;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,70 +0,0 @@
|
|||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package stanhebben.zenscript.docs;
|
|
||||||
|
|
||||||
import com.sun.javadoc.MethodDoc;
|
|
||||||
import com.sun.javadoc.Type;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import static stanhebben.zenscript.docs.ZenOperatorDocType.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class ZenOperatorDoc {
|
|
||||||
private static Map<String, ZenOperatorDocType> TYPES;
|
|
||||||
|
|
||||||
static {
|
|
||||||
TYPES = new HashMap<String, ZenOperatorDocType>();
|
|
||||||
TYPES.put("stanhebben.zenscript.annotations.OperatorType.ADD", ADD);
|
|
||||||
TYPES.put("stanhebben.zenscript.annotations.OperatorType.SUB", SUB);
|
|
||||||
TYPES.put("stanhebben.zenscript.annotations.OperatorType.MUL", MUL);
|
|
||||||
TYPES.put("stanhebben.zenscript.annotations.OperatorType.DIV", DIV);
|
|
||||||
TYPES.put("stanhebben.zenscript.annotations.OperatorType.MOD", MOD);
|
|
||||||
TYPES.put("stanhebben.zenscript.annotations.OperatorType.CAT", CAT);
|
|
||||||
TYPES.put("stanhebben.zenscript.annotations.OperatorType.OR", OR);
|
|
||||||
TYPES.put("stanhebben.zenscript.annotations.OperatorType.AND", AND);
|
|
||||||
TYPES.put("stanhebben.zenscript.annotations.OperatorType.XOR", XOR);
|
|
||||||
TYPES.put("stanhebben.zenscript.annotations.OperatorType.NEG", NEG);
|
|
||||||
TYPES.put("stanhebben.zenscript.annotations.OperatorType.NOT", NOT);
|
|
||||||
TYPES.put("stanhebben.zenscript.annotations.OperatorType.INDEXSET", INDEXSET);
|
|
||||||
TYPES.put("stanhebben.zenscript.annotations.OperatorType.INDEXGET", INDEXGET);
|
|
||||||
TYPES.put("stanhebben.zenscript.annotations.OperatorType.RANGE", RANGE);
|
|
||||||
TYPES.put("stanhebben.zenscript.annotations.OperatorType.CONTAINS", CONTAINS);
|
|
||||||
TYPES.put("stanhebben.zenscript.annotations.OperatorType.COMPARE", COMPARE);
|
|
||||||
TYPES.put("stanhebben.zenscript.annotations.OperatorType.MEMBERGETTER", MEMBERGETTER);
|
|
||||||
TYPES.put("stanhebben.zenscript.annotations.OperatorType.MEMBERSETTER", MEMBERSETTER);
|
|
||||||
TYPES.put("stanhebben.zenscript.annotations.OperatorType.EQUALS", EQUALS);
|
|
||||||
}
|
|
||||||
|
|
||||||
private final String operator;
|
|
||||||
private final MethodDoc method;
|
|
||||||
private final Type[] types;
|
|
||||||
|
|
||||||
public ZenOperatorDoc(String operator, MethodDoc method, Type[] types) {
|
|
||||||
this.operator = operator;
|
|
||||||
this.method = method;
|
|
||||||
this.types = types;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getOperator() {
|
|
||||||
return operator;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Type[] getTypes() {
|
|
||||||
return types;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ZenOperatorDocType getOperatorType() {
|
|
||||||
return TYPES.get(operator);
|
|
||||||
}
|
|
||||||
|
|
||||||
public MethodDoc getMethod() {
|
|
||||||
return method;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package stanhebben.zenscript.docs;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public enum ZenOperatorDocType {
|
|
||||||
ADD("+ %s"),
|
|
||||||
SUB("- %s"),
|
|
||||||
MUL("* %s"),
|
|
||||||
DIV("/ %s"),
|
|
||||||
MOD("%% %s"),
|
|
||||||
CAT("~ %s"),
|
|
||||||
OR("| %s"),
|
|
||||||
AND("& %s"),
|
|
||||||
XOR("^ %s"),
|
|
||||||
NEG("-"),
|
|
||||||
NOT("~"),
|
|
||||||
INDEXSET("[%s] = %s"),
|
|
||||||
INDEXGET("[%s]"),
|
|
||||||
RANGE(".. %s"),
|
|
||||||
CONTAINS("%s in"),
|
|
||||||
COMPARE("compareTo(%s)"),
|
|
||||||
MEMBERGETTER(".member"),
|
|
||||||
MEMBERSETTER(".member = %s"),
|
|
||||||
EQUALS("== %s");
|
|
||||||
|
|
||||||
private final String pattern;
|
|
||||||
|
|
||||||
private ZenOperatorDocType(String pattern) {
|
|
||||||
this.pattern = pattern;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String fill(String... contents) {
|
|
||||||
return String.format(pattern, (Object[]) contents);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package stanhebben.zenscript.docs;
|
|
||||||
|
|
||||||
import com.sun.javadoc.AnnotationDesc;
|
|
||||||
import com.sun.javadoc.Parameter;
|
|
||||||
import com.sun.javadoc.Type;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class ZenParameterDoc {
|
|
||||||
private boolean optional;
|
|
||||||
private final String name;
|
|
||||||
private final Type type;
|
|
||||||
|
|
||||||
public ZenParameterDoc(Parameter parameter) {
|
|
||||||
optional = false;
|
|
||||||
name = parameter.name();
|
|
||||||
type = parameter.type();
|
|
||||||
|
|
||||||
for (AnnotationDesc annotation : parameter.annotations()) {
|
|
||||||
if (annotation.annotationType().qualifiedName().equals("stanhebben.zenscript.annotations.Optional")) {
|
|
||||||
optional = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isOptional() {
|
|
||||||
return optional;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Type getType() {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package stanhebben.zenscript.docs;
|
|
||||||
|
|
||||||
import com.sun.javadoc.Type;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Stan
|
|
||||||
*/
|
|
||||||
public class ZenPropertyDoc {
|
|
||||||
private Type type;
|
|
||||||
private String name;
|
|
||||||
private boolean canGet;
|
|
||||||
private boolean canSet;
|
|
||||||
private String[] comment;
|
|
||||||
|
|
||||||
public ZenPropertyDoc(String name, Type type) {
|
|
||||||
this.type = type;
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Type getType() {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isCanGet() {
|
|
||||||
return canGet;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCanGet(boolean canGet) {
|
|
||||||
this.canGet = canGet;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isCanSet() {
|
|
||||||
return canSet;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCanSet(boolean canSet) {
|
|
||||||
this.canSet = canSet;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String[] getComment() {
|
|
||||||
return comment;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setComment(String[] comment) {
|
|
||||||
this.comment = comment;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,856 +0,0 @@
|
|||||||
package stanhebben.zenscript.docs;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import com.sun.javadoc.AnnotationDesc;
|
|
||||||
import com.sun.javadoc.ClassDoc;
|
|
||||||
import com.sun.javadoc.DocErrorReporter;
|
|
||||||
import com.sun.javadoc.LanguageVersion;
|
|
||||||
import com.sun.javadoc.MethodDoc;
|
|
||||||
import com.sun.javadoc.Parameter;
|
|
||||||
import com.sun.javadoc.RootDoc;
|
|
||||||
import com.sun.javadoc.Type;
|
|
||||||
import com.sun.tools.doclets.standard.Standard;
|
|
||||||
import java.io.BufferedWriter;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileWriter;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.Writer;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import stanhebben.zenscript.util.StringUtil;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Example usage: (from minetweaker API source dir):
|
|
||||||
*
|
|
||||||
* javadoc -doclet stanhebben.zenscript.docs.ZenScriptDoclet -docletpath ..\..\..\..\ZenScript\build\classes\main -cp ..\..\..\..\ZenScript\build\libs\ZenScript.jar -sourcepath . -subpackages minetweaker
|
|
||||||
*
|
|
||||||
* @author Stan Hebben
|
|
||||||
*/
|
|
||||||
public class ZenScriptDoclet extends Standard {
|
|
||||||
public static boolean validOptions(String[][] strings, DocErrorReporter der) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int optionLength(String option) {
|
|
||||||
if(option.equals("-baseurl")) {
|
|
||||||
return 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Standard.optionLength(option);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean start(RootDoc root) {
|
|
||||||
File output = new File("zendoc");
|
|
||||||
String baseUrl = "/doc/";
|
|
||||||
for (String[] options : root.options()) {
|
|
||||||
//System.out.println(Arrays.toString(options));
|
|
||||||
if (options[0].equals("-d")) {
|
|
||||||
output = new File(options[1]);
|
|
||||||
} else if (options[0].equals("-baseurl")) {
|
|
||||||
baseUrl = options[1];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ClassDoc[] classes = root.classes();
|
|
||||||
List<ZenClassDoc> documentedClasses = new ArrayList<ZenClassDoc>();
|
|
||||||
List<ZenExpansionDoc> expansionClasses = new ArrayList<ZenExpansionDoc>();
|
|
||||||
|
|
||||||
for (int i = 0; i < classes.length; ++i) {
|
|
||||||
ClassDoc cls = classes[i];
|
|
||||||
|
|
||||||
for (AnnotationDesc annotation : cls.annotations()) {
|
|
||||||
//String fullName = annotation.annotationType().containingPackage().name() + '.' + annotation.annotationType().name();
|
|
||||||
String fullName = annotation.annotationType().qualifiedName();
|
|
||||||
if (fullName.equals("stanhebben.zenscript.annotations.ZenClass")) {
|
|
||||||
documentedClasses.add(new ZenClassDoc(cls, (String) (annotation.elementValues()[0].value().value())));
|
|
||||||
} else if (fullName.equals("stanhebben.zenscript.annotations.ZenExpansion")) {
|
|
||||||
expansionClasses.add(new ZenExpansionDoc(cls, (String) (annotation.elementValues()[0].value().value())));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<String, ZenClassDoc> classesByName = new HashMap<String, ZenClassDoc>();
|
|
||||||
Map<String, ZenClassDoc> classesByJavaName = new HashMap<String, ZenClassDoc>();
|
|
||||||
|
|
||||||
for (ZenClassDoc documentedClass : documentedClasses) {
|
|
||||||
classesByName.put(documentedClass.getName(), documentedClass);
|
|
||||||
classesByJavaName.put(documentedClass.getDoc().qualifiedName(), documentedClass);
|
|
||||||
}
|
|
||||||
for (ZenExpansionDoc expansion : expansionClasses) {
|
|
||||||
if (classesByName.containsKey(expansion.getType())) {
|
|
||||||
classesByName.get(expansion.getType()).addExpansion(expansion);
|
|
||||||
} else {
|
|
||||||
if (expansion.getType().endsWith("]")) {
|
|
||||||
String baseName = expansion.getType().substring(0, expansion.getType().lastIndexOf('['));
|
|
||||||
if (classesByName.containsKey(baseName)) {
|
|
||||||
classesByName.get(baseName).addExpansion(expansion);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
System.out.println("Number of classes to document: " + classesByName.size());
|
|
||||||
System.out.println("Output directory: " + output);
|
|
||||||
if (!output.exists()) output.mkdirs();
|
|
||||||
|
|
||||||
String packageList = buildPackageList(documentedClasses, baseUrl);
|
|
||||||
|
|
||||||
for (ZenClassDoc doc : classesByName.values()) {
|
|
||||||
try {
|
|
||||||
File outputDoc = new File(output, doc.getName().replace('.', '/') + ".html");
|
|
||||||
File outputDocParent = outputDoc.getParentFile();
|
|
||||||
if (!outputDocParent.exists()) outputDocParent.mkdirs();
|
|
||||||
|
|
||||||
Writer writer = new BufferedWriter(new FileWriter(outputDoc));
|
|
||||||
|
|
||||||
String simpleName = doc.getName().substring(doc.getName().lastIndexOf('.') + 1);
|
|
||||||
|
|
||||||
writer.append("<!DOCTYPE html>");
|
|
||||||
writer.append("<html><head>");
|
|
||||||
writer.append("<title>ZenDoc : " + simpleName + "</title>");
|
|
||||||
writer.append("<link rel=\"stylesheet\" href=\"/css/bootstrap.min.css\" />");
|
|
||||||
writer.append("<link rel=\"stylesheet\" href=\"/css/bootstrap-theme.css\" />");
|
|
||||||
writer.append("<link rel=\"stylesheet\" href=\"/css/font-awesome.min.css\" />");
|
|
||||||
writer.append("</head><body>");
|
|
||||||
writer.append("<div class=\"container\"><div class=\"row\">");
|
|
||||||
writer.append(packageList);
|
|
||||||
writer.append("<div class=\"col-md-9\">");
|
|
||||||
|
|
||||||
String pkgName = doc.getName().substring(0, doc.getName().lastIndexOf('.'));
|
|
||||||
writer.append("<div class=\"class-package-name\">");
|
|
||||||
writer.append(pkgName);
|
|
||||||
writer.append("</div>");
|
|
||||||
|
|
||||||
// output class or interface contents
|
|
||||||
writer.append("<h1>");
|
|
||||||
if (doc.getDoc().isInterface()) {
|
|
||||||
writer.append("Interface ");
|
|
||||||
} else {
|
|
||||||
writer.append("Class ");
|
|
||||||
}
|
|
||||||
|
|
||||||
writer.append(doc.getDoc().name()).append("</h1>");
|
|
||||||
if (doc.getDoc().interfaces().length > 0) {
|
|
||||||
writer.append("<div class=\"implemented-interfaces\">implements ");
|
|
||||||
boolean first = true;
|
|
||||||
for (Type itype : doc.getDoc().interfaceTypes()) {
|
|
||||||
if (first) {
|
|
||||||
first = false;
|
|
||||||
} else {
|
|
||||||
writer.append(", ");
|
|
||||||
}
|
|
||||||
|
|
||||||
outputType(writer, itype, classesByJavaName, baseUrl);
|
|
||||||
}
|
|
||||||
writer.append("</div>");
|
|
||||||
}
|
|
||||||
|
|
||||||
writer.append("<hr />");
|
|
||||||
writer.append("<div class=\"documentation-class\">");
|
|
||||||
|
|
||||||
for (String p : StringUtil.splitParagraphs(doc.getDoc().commentText())) {
|
|
||||||
writer.append("<p>");
|
|
||||||
writer.append(p);
|
|
||||||
writer.append("</p>");
|
|
||||||
}
|
|
||||||
|
|
||||||
writer.append("</div>");
|
|
||||||
|
|
||||||
|
|
||||||
if (doc.getDoc().isInterface() && doc.getDoc().methods().length == 1) {
|
|
||||||
// functional interface
|
|
||||||
writer.append("<h2>Functional interface</h2>");
|
|
||||||
|
|
||||||
MethodDoc method = doc.getDoc().methods()[0];
|
|
||||||
writer.append("<div class=\"functional-interface-signature\">");
|
|
||||||
writer.append("function (");
|
|
||||||
|
|
||||||
boolean first = true;
|
|
||||||
for (Parameter parameter : method.parameters()) {
|
|
||||||
if (first) {
|
|
||||||
first = false;
|
|
||||||
} else {
|
|
||||||
writer.append(", ");
|
|
||||||
}
|
|
||||||
ZenParameterDoc paramdoc = new ZenParameterDoc(parameter);
|
|
||||||
writer.append(paramdoc.getName());
|
|
||||||
writer.append(" as ");
|
|
||||||
outputType(writer, paramdoc.getType(), classesByJavaName, baseUrl);
|
|
||||||
}
|
|
||||||
writer.append(") as ");
|
|
||||||
outputType(writer, method.returnType(), classesByJavaName, baseUrl);
|
|
||||||
writer.append("</div>");
|
|
||||||
|
|
||||||
String[] comment = StringUtil.splitParagraphs(method.commentText());
|
|
||||||
for (String line : comment) {
|
|
||||||
writer.append("<p>");
|
|
||||||
writer.append(line);
|
|
||||||
writer.append("</p>");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
writer.append("<h2>Member Overview</h2>");
|
|
||||||
|
|
||||||
// collect members
|
|
||||||
|
|
||||||
LinkedHashMap<String, ZenPropertyDoc> instanceProperties = new LinkedHashMap<String, ZenPropertyDoc>();
|
|
||||||
LinkedHashMap<String, ZenPropertyDoc> staticProperties = new LinkedHashMap<String, ZenPropertyDoc>();
|
|
||||||
List<ZenMethodDoc> instanceMethods = new ArrayList<ZenMethodDoc>();
|
|
||||||
List<ZenMethodDoc> staticMethods = new ArrayList<ZenMethodDoc>();
|
|
||||||
List<ZenOperatorDoc> operators = new ArrayList<ZenOperatorDoc>();
|
|
||||||
List<ZenCasterDoc> casters = new ArrayList<ZenCasterDoc>();
|
|
||||||
|
|
||||||
for (MethodDoc method : doc.getDoc().methods()) {
|
|
||||||
for (AnnotationDesc annotation : method.annotations()) {
|
|
||||||
String fullName = annotation.annotationType().qualifiedName();
|
|
||||||
|
|
||||||
if (fullName.equals("stanhebben.zenscript.annotations.ZenMethod")
|
|
||||||
|| fullName.equals("stanhebben.zenscript.annotations.ZenMethodStatic")) {
|
|
||||||
String name = annotation.elementValues().length > 0
|
|
||||||
? (String) (annotation.elementValues()[0].value().value())
|
|
||||||
: "";
|
|
||||||
|
|
||||||
if (name.length() == 0) {
|
|
||||||
name = method.name();
|
|
||||||
}
|
|
||||||
|
|
||||||
List<ZenParameterDoc> parameters = new ArrayList<ZenParameterDoc>();
|
|
||||||
for (Parameter parameter : method.parameters()) {
|
|
||||||
parameters.add(new ZenParameterDoc(parameter));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (method.isStatic()) {
|
|
||||||
staticMethods.add(new ZenMethodDoc(name, method, parameters));
|
|
||||||
} else {
|
|
||||||
instanceMethods.add(new ZenMethodDoc(name, method, parameters));
|
|
||||||
}
|
|
||||||
} else if (fullName.equals("stanhebben.zenscript.annotations.ZenGetter")) {
|
|
||||||
String name = annotation.elementValues().length > 0
|
|
||||||
? (String) (annotation.elementValues()[0].value().value())
|
|
||||||
: "";
|
|
||||||
|
|
||||||
if (name.length() == 0) {
|
|
||||||
name = method.name();
|
|
||||||
}
|
|
||||||
|
|
||||||
Type type = method.returnType();
|
|
||||||
String[] comment = StringUtil.splitParagraphs(method.commentText());
|
|
||||||
|
|
||||||
if (!method.isStatic()) {
|
|
||||||
if (instanceProperties.containsKey(name)) {
|
|
||||||
ZenPropertyDoc property = instanceProperties.get(name);
|
|
||||||
property.setCanGet(true);
|
|
||||||
property.setComment(comment);
|
|
||||||
} else {
|
|
||||||
ZenPropertyDoc property = new ZenPropertyDoc(name, type);
|
|
||||||
property.setCanGet(true);
|
|
||||||
property.setComment(comment);
|
|
||||||
instanceProperties.put(name, property);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (staticProperties.containsKey(name)) {
|
|
||||||
ZenPropertyDoc property = staticProperties.get(name);
|
|
||||||
property.setCanGet(true);
|
|
||||||
property.setComment(comment);
|
|
||||||
} else {
|
|
||||||
ZenPropertyDoc property = new ZenPropertyDoc(name, type);
|
|
||||||
property.setCanGet(true);
|
|
||||||
property.setComment(comment);
|
|
||||||
staticProperties.put(name, property);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (fullName.equals("stanhebben.zenscript.annotations.ZenSetter")) {
|
|
||||||
String name = annotation.elementValues().length > 0
|
|
||||||
? (String) (annotation.elementValues()[0].value().value())
|
|
||||||
: "";
|
|
||||||
|
|
||||||
if (name.length() == 0) {
|
|
||||||
name = method.name();
|
|
||||||
}
|
|
||||||
|
|
||||||
Type type = method.parameters()[0].type();
|
|
||||||
String[] comment = StringUtil.splitParagraphs(method.commentText());
|
|
||||||
|
|
||||||
if (!method.isStatic()) {
|
|
||||||
if (instanceProperties.containsKey(name)) {
|
|
||||||
ZenPropertyDoc property = instanceProperties.get(name);
|
|
||||||
property.setCanSet(true);
|
|
||||||
} else {
|
|
||||||
ZenPropertyDoc property = new ZenPropertyDoc(name, type);
|
|
||||||
property.setCanGet(true);
|
|
||||||
property.setComment(comment);
|
|
||||||
instanceProperties.put(name, property);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (staticProperties.containsKey(name)) {
|
|
||||||
ZenPropertyDoc property = staticProperties.get(name);
|
|
||||||
property.setCanSet(true);
|
|
||||||
} else {
|
|
||||||
ZenPropertyDoc property = new ZenPropertyDoc(name, type);
|
|
||||||
property.setCanGet(true);
|
|
||||||
property.setComment(comment);
|
|
||||||
staticProperties.put(name, property);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (fullName.equals("stanhebben.zenscript.annotations.ZenOperator")) {
|
|
||||||
String operator = annotation.elementValues()[0].value().value().toString();
|
|
||||||
Type[] parameterTypes = new Type[method.parameters().length];
|
|
||||||
for (int i = 0; i < method.parameters().length; i++) {
|
|
||||||
parameterTypes[i] = method.parameters()[i].type();
|
|
||||||
}
|
|
||||||
operators.add(new ZenOperatorDoc(operator, method, parameterTypes));
|
|
||||||
} else if (fullName.equals("stanhebben.zenscript.annotations.ZenCaster")) {
|
|
||||||
casters.add(new ZenCasterDoc(method));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (ZenExpansionDoc expansion : doc.getExpansions()) {
|
|
||||||
for (MethodDoc method : expansion.getDoc().methods()) {
|
|
||||||
for (AnnotationDesc annotation : method.annotations()) {
|
|
||||||
String fullName = annotation.annotationType().qualifiedName();
|
|
||||||
|
|
||||||
if (fullName.equals("stanhebben.zenscript.annotations.ZenMethod")
|
|
||||||
|| fullName.equals("stanhebben.zenscript.annotations.ZenMethodStatic")) {
|
|
||||||
String name = annotation.elementValues().length > 0
|
|
||||||
? (String) (annotation.elementValues()[0].value().value())
|
|
||||||
: "";
|
|
||||||
|
|
||||||
if (name.length() == 0) {
|
|
||||||
name = method.name();
|
|
||||||
}
|
|
||||||
|
|
||||||
List<ZenParameterDoc> parameters = new ArrayList<ZenParameterDoc>();
|
|
||||||
for (Parameter parameter : method.parameters()) {
|
|
||||||
parameters.add(new ZenParameterDoc(parameter));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fullName.equals("stanhebben.zenscript.annotations.ZenMethodStatic")) {
|
|
||||||
staticMethods.add(new ZenMethodDoc(name, method, parameters));
|
|
||||||
} else {
|
|
||||||
instanceMethods.add(new ZenMethodDoc(name, method, parameters.subList(1, parameters.size())));
|
|
||||||
}
|
|
||||||
} else if (fullName.equals("stanhebben.zenscript.annotations.ZenGetter")) {
|
|
||||||
String name = annotation.elementValues().length > 0
|
|
||||||
? (String) (annotation.elementValues()[0].value().value())
|
|
||||||
: "";
|
|
||||||
|
|
||||||
if (name.length() == 0) {
|
|
||||||
name = method.name();
|
|
||||||
}
|
|
||||||
|
|
||||||
Type type = method.returnType();
|
|
||||||
String[] comment = StringUtil.splitParagraphs(method.commentText());
|
|
||||||
|
|
||||||
if (!method.isStatic()) {
|
|
||||||
if (instanceProperties.containsKey(name)) {
|
|
||||||
ZenPropertyDoc property = instanceProperties.get(name);
|
|
||||||
property.setCanGet(true);
|
|
||||||
property.setComment(comment);
|
|
||||||
} else {
|
|
||||||
ZenPropertyDoc property = new ZenPropertyDoc(name, type);
|
|
||||||
property.setCanGet(true);
|
|
||||||
property.setComment(comment);
|
|
||||||
instanceProperties.put(name, property);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (staticProperties.containsKey(name)) {
|
|
||||||
ZenPropertyDoc property = staticProperties.get(name);
|
|
||||||
property.setCanGet(true);
|
|
||||||
property.setComment(comment);
|
|
||||||
} else {
|
|
||||||
ZenPropertyDoc property = new ZenPropertyDoc(name, type);
|
|
||||||
property.setCanGet(true);
|
|
||||||
property.setComment(comment);
|
|
||||||
staticProperties.put(name, property);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (fullName.equals("stanhebben.zenscript.annotations.ZenSetter")) {
|
|
||||||
String name = annotation.elementValues().length > 0
|
|
||||||
? (String) (annotation.elementValues()[0].value().value())
|
|
||||||
: "";
|
|
||||||
|
|
||||||
if (name.length() == 0) {
|
|
||||||
name = method.name();
|
|
||||||
}
|
|
||||||
|
|
||||||
Type type = method.parameters()[1].type();
|
|
||||||
String[] comment = StringUtil.splitParagraphs(method.commentText());
|
|
||||||
|
|
||||||
if (!method.isStatic()) {
|
|
||||||
if (instanceProperties.containsKey(name)) {
|
|
||||||
ZenPropertyDoc property = instanceProperties.get(name);
|
|
||||||
property.setCanSet(true);
|
|
||||||
} else {
|
|
||||||
ZenPropertyDoc property = new ZenPropertyDoc(name, type);
|
|
||||||
property.setCanGet(true);
|
|
||||||
property.setComment(comment);
|
|
||||||
instanceProperties.put(name, property);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (staticProperties.containsKey(name)) {
|
|
||||||
ZenPropertyDoc property = staticProperties.get(name);
|
|
||||||
property.setCanSet(true);
|
|
||||||
} else {
|
|
||||||
ZenPropertyDoc property = new ZenPropertyDoc(name, type);
|
|
||||||
property.setCanGet(true);
|
|
||||||
property.setComment(comment);
|
|
||||||
staticProperties.put(name, property);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (fullName.equals("stanhebben.zenscript.annotations.ZenOperator")) {
|
|
||||||
String operator = annotation.elementValues()[0].value().value().toString();
|
|
||||||
Type[] parameterTypes = new Type[method.parameters().length - 1];
|
|
||||||
for (int i = 1; i < method.parameters().length; i++) {
|
|
||||||
parameterTypes[i - 1] = method.parameters()[i].type();
|
|
||||||
}
|
|
||||||
operators.add(new ZenOperatorDoc(operator, method, parameterTypes));
|
|
||||||
} else if (fullName.equals("stanhebben.zenscript.annotations.ZenCaster")) {
|
|
||||||
casters.add(new ZenCasterDoc(method));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!staticProperties.isEmpty()) {
|
|
||||||
writer.append("<div class=\"panel panel-info panel-memberlist\">");
|
|
||||||
writer.append("<div class=\"panel-heading\">Static Properties</div>");
|
|
||||||
writer.append("<div class=\"panel-body\">");
|
|
||||||
writer.append("<table class=\"table table-properties table-bordered\"><tbody>");
|
|
||||||
|
|
||||||
String[] names = new String[staticProperties.size()];
|
|
||||||
int namei = 0;
|
|
||||||
for (String name : staticProperties.keySet()) {
|
|
||||||
names[namei++] = name;
|
|
||||||
}
|
|
||||||
Arrays.sort(names);
|
|
||||||
|
|
||||||
for (String name : names) {
|
|
||||||
ZenPropertyDoc property = staticProperties.get(name);
|
|
||||||
|
|
||||||
writer.append("<tr>");
|
|
||||||
writer.append("<td class=\"property-type\">");
|
|
||||||
outputType(writer, property.getType(), classesByJavaName, baseUrl);
|
|
||||||
writer.append("</td>");
|
|
||||||
writer.append("<td>");
|
|
||||||
writer.append("<div class=\"property-name\">");
|
|
||||||
if (!property.isCanSet()) writer.append("<span class=\"fa fa-lock\" style=\"color: #ccc;\" title=\"cannot be set\"></span> ");
|
|
||||||
writer.append("<a href=\"#property-staticvalue\">")
|
|
||||||
.append(property.getName())
|
|
||||||
.append("</a></div>");
|
|
||||||
if (property.getComment() != null && property.getComment().length > 0) {
|
|
||||||
writer.append("<div class=\"property-intro\">")
|
|
||||||
.append(property.getComment()[0])
|
|
||||||
.append("</div>");
|
|
||||||
}
|
|
||||||
writer.append("</td></tr>");
|
|
||||||
}
|
|
||||||
|
|
||||||
writer.append("</tbody></table></div></div>");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!instanceProperties.isEmpty()) {
|
|
||||||
writer.append("<div class=\"panel panel-info panel-memberlist\">");
|
|
||||||
writer.append("<div class=\"panel-heading\">Properties</div>");
|
|
||||||
writer.append("<div class=\"panel-body\">");
|
|
||||||
writer.append("<table class=\"table table-properties table-bordered\"><tbody>");
|
|
||||||
|
|
||||||
String[] names = new String[instanceProperties.size()];
|
|
||||||
int namei = 0;
|
|
||||||
for (String name : instanceProperties.keySet()) {
|
|
||||||
names[namei++] = name;
|
|
||||||
}
|
|
||||||
Arrays.sort(names);
|
|
||||||
|
|
||||||
for (String name : names) {
|
|
||||||
ZenPropertyDoc property = instanceProperties.get(name);
|
|
||||||
|
|
||||||
writer.append("<tr>");
|
|
||||||
writer.append("<td class=\"property-type\">");
|
|
||||||
outputType(writer, property.getType(), classesByJavaName, baseUrl);
|
|
||||||
writer.append("</td>");
|
|
||||||
writer.append("<td>");
|
|
||||||
writer.append("<div class=\"property-name\">");
|
|
||||||
if (!property.isCanSet()) writer.append("<span class=\"fa fa-lock\" style=\"color: #ccc;\" title=\"cannot be set\"></span> ");
|
|
||||||
writer.append("<a href=\"#property-staticvalue\">")
|
|
||||||
.append(property.getName())
|
|
||||||
.append("</a></div>");
|
|
||||||
if (property.getComment() != null && property.getComment().length > 0) {
|
|
||||||
writer.append("<div class=\"property-intro\">")
|
|
||||||
.append(property.getComment()[0])
|
|
||||||
.append("</div>");
|
|
||||||
}
|
|
||||||
writer.append("</td></tr>");
|
|
||||||
}
|
|
||||||
|
|
||||||
writer.append("</tbody></table></div></div>");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!staticMethods.isEmpty()) {
|
|
||||||
writer.append("<div class=\"panel panel-info panel-memberlist\">");
|
|
||||||
writer.append("<div class=\"panel-heading\">Static Methods</div>");
|
|
||||||
writer.append("<div class=\"panel-body\">");
|
|
||||||
writer.append("<table class=\"table table-properties table-bordered\"><tbody>");
|
|
||||||
|
|
||||||
for (ZenMethodDoc method : staticMethods) {
|
|
||||||
writer.append("<tr>");
|
|
||||||
writer.append("<td class=\"property-type\">");
|
|
||||||
outputType(writer, method.getDoc().returnType(), classesByJavaName, baseUrl);
|
|
||||||
writer.append("</td>");
|
|
||||||
writer.append("<td>");
|
|
||||||
writer.append("<div class=\"property-name\">");
|
|
||||||
writer.append("<a href=\"#property-staticvalue\">")
|
|
||||||
.append(method.getName())
|
|
||||||
.append("</a>(");
|
|
||||||
boolean first = true;
|
|
||||||
|
|
||||||
for (ZenParameterDoc param : method.getParameters()) {
|
|
||||||
if (param.isOptional()) writer.append("<span class=\"param-optional\">");
|
|
||||||
if (first) {
|
|
||||||
first = false;
|
|
||||||
} else {
|
|
||||||
writer.append(", ");
|
|
||||||
}
|
|
||||||
writer.append(param.getName());
|
|
||||||
writer.append(" as ");
|
|
||||||
outputType(writer, param.getType(), classesByJavaName, baseUrl);
|
|
||||||
}
|
|
||||||
writer.append(")</div>");
|
|
||||||
|
|
||||||
String[] comment = StringUtil.splitParagraphs(method.getDoc().commentText());
|
|
||||||
if (comment.length > 0) {
|
|
||||||
writer.append("<div class=\"property-intro\">")
|
|
||||||
.append(comment[0])
|
|
||||||
.append("</div>");
|
|
||||||
}
|
|
||||||
writer.append("</td></tr>");
|
|
||||||
}
|
|
||||||
|
|
||||||
writer.append("</tbody></table></div></div>");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!instanceMethods.isEmpty()) {
|
|
||||||
writer.append("<div class=\"panel panel-info panel-memberlist\">");
|
|
||||||
writer.append("<div class=\"panel-heading\">Methods</div>");
|
|
||||||
writer.append("<div class=\"panel-body\">");
|
|
||||||
writer.append("<table class=\"table table-properties table-bordered\"><tbody>");
|
|
||||||
|
|
||||||
for (ZenMethodDoc method : instanceMethods) {
|
|
||||||
writer.append("<tr>");
|
|
||||||
writer.append("<td class=\"property-type\">");
|
|
||||||
outputType(writer, method.getDoc().returnType(), classesByJavaName, baseUrl);
|
|
||||||
writer.append("</td>");
|
|
||||||
writer.append("<td>");
|
|
||||||
writer.append("<div class=\"property-name\">");
|
|
||||||
writer.append("<a href=\"#property-staticvalue\">")
|
|
||||||
.append(method.getName())
|
|
||||||
.append("</a>(");
|
|
||||||
boolean first = true;
|
|
||||||
|
|
||||||
for (ZenParameterDoc param : method.getParameters()) {
|
|
||||||
if (param.isOptional()) writer.append("<span class=\"param-optional\">");
|
|
||||||
if (first) {
|
|
||||||
first = false;
|
|
||||||
} else {
|
|
||||||
writer.append(", ");
|
|
||||||
}
|
|
||||||
writer.append(param.getName());
|
|
||||||
writer.append(" as ");
|
|
||||||
outputType(writer, param.getType(), classesByJavaName, baseUrl);
|
|
||||||
}
|
|
||||||
writer.append(")</div>");
|
|
||||||
|
|
||||||
String[] comment = StringUtil.splitParagraphs(method.getDoc().commentText());
|
|
||||||
if (comment.length > 0) {
|
|
||||||
writer.append("<div class=\"property-intro\">")
|
|
||||||
.append(comment[0])
|
|
||||||
.append("</div>");
|
|
||||||
}
|
|
||||||
writer.append("</td></tr>");
|
|
||||||
}
|
|
||||||
|
|
||||||
writer.append("</tbody></table></div></div>");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!operators.isEmpty()) {
|
|
||||||
writer.append("<div class=\"panel panel-info panel-memberlist\">");
|
|
||||||
writer.append("<div class=\"panel-heading\">Operators</div>");
|
|
||||||
writer.append("<div class=\"panel-body\">");
|
|
||||||
writer.append("<table class=\"table table-properties table-bordered\"><tbody>");
|
|
||||||
|
|
||||||
for (ZenOperatorDoc operator : operators) {
|
|
||||||
writer.append("<tr>");
|
|
||||||
writer.append("<td>");
|
|
||||||
writer.append("<div class=\"property-name\">");
|
|
||||||
/*writer.append("as <a href=\"#property-staticvalue\">");
|
|
||||||
outputTypeRaw(writer, caster.getMethod().returnType(), classesByJavaName);
|
|
||||||
writer.append("</a></div>");*/
|
|
||||||
|
|
||||||
String[] types = new String[operator.getTypes().length];
|
|
||||||
for (int i = 0; i < types.length; i++) {
|
|
||||||
types[i] = outputTypeString(operator.getTypes()[i], classesByJavaName, baseUrl);
|
|
||||||
}
|
|
||||||
writer.append(operator.getOperatorType().fill(types));
|
|
||||||
|
|
||||||
String[] comment = StringUtil.splitParagraphs(operator.getMethod().commentText());
|
|
||||||
if (comment.length > 0) {
|
|
||||||
writer.append("<div class=\"property-intro\">")
|
|
||||||
.append(comment[0])
|
|
||||||
.append("</div>");
|
|
||||||
}
|
|
||||||
writer.append("</td></tr>");
|
|
||||||
}
|
|
||||||
|
|
||||||
writer.append("</tbody></table></div></div>");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!casters.isEmpty()) {
|
|
||||||
writer.append("<div class=\"panel panel-info panel-memberlist\">");
|
|
||||||
writer.append("<div class=\"panel-heading\">Casters</div>");
|
|
||||||
writer.append("<div class=\"panel-body\">");
|
|
||||||
writer.append("<table class=\"table table-properties table-bordered\"><tbody>");
|
|
||||||
|
|
||||||
for (ZenCasterDoc caster : casters) {
|
|
||||||
writer.append("<tr>");
|
|
||||||
writer.append("<td>");
|
|
||||||
writer.append("<div class=\"property-name\">");
|
|
||||||
writer.append("as <a href=\"#property-staticvalue\">");
|
|
||||||
outputTypeRaw(writer, caster.getMethod().returnType(), classesByJavaName);
|
|
||||||
writer.append("</a></div>");
|
|
||||||
|
|
||||||
String[] comment = StringUtil.splitParagraphs(caster.getMethod().commentText());
|
|
||||||
if (comment.length > 0) {
|
|
||||||
writer.append("<div class=\"property-intro\">")
|
|
||||||
.append(comment[0])
|
|
||||||
.append("</div>");
|
|
||||||
}
|
|
||||||
writer.append("</td></tr>");
|
|
||||||
}
|
|
||||||
|
|
||||||
writer.append("</tbody></table></div></div>");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
writer.append("</div></div></div>");
|
|
||||||
writer.append("<script src=\"https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js\"></script>");
|
|
||||||
writer.append("<script src=\"/js/bootstrap.min.js\"></script>");
|
|
||||||
writer.append("<script type=\"application/javascript\">");
|
|
||||||
writer.append("$('#collapse-");
|
|
||||||
writer.append(pkgName.replace('.', '-'));
|
|
||||||
writer.append("').collapse('show');");
|
|
||||||
writer.append("</script>");
|
|
||||||
writer.append("</body></html>");
|
|
||||||
writer.close();
|
|
||||||
} catch (IOException ex) {
|
|
||||||
System.out.println(ex.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* NOTE: Without this method present and returning LanguageVersion.JAVA_1_5,
|
|
||||||
* Javadoc will not process generics because it assumes LanguageVersion.JAVA_1_1
|
|
||||||
* @return language version (hard coded to LanguageVersion.JAVA_1_5)
|
|
||||||
*/
|
|
||||||
public static LanguageVersion languageVersion() {
|
|
||||||
return LanguageVersion.JAVA_1_5;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String buildPackageList(List<ZenClassDoc> classes, String baseurl) {
|
|
||||||
// collect package list
|
|
||||||
Map<String, List<ZenClassDoc>> packages = new HashMap<String, List<ZenClassDoc>>();
|
|
||||||
for (ZenClassDoc cls : classes) {
|
|
||||||
String pkg = cls.getName().substring(0, cls.getName().lastIndexOf('.'));
|
|
||||||
if (packages.containsKey(pkg)) {
|
|
||||||
packages.get(pkg).add(cls);
|
|
||||||
} else {
|
|
||||||
ArrayList<ZenClassDoc> classList = new ArrayList<ZenClassDoc>();
|
|
||||||
classList.add(cls);
|
|
||||||
packages.put(pkg, classList);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
String[] packageSorted = new String[packages.size()];
|
|
||||||
int packageIndex = 0;
|
|
||||||
for (String packageName : packages.keySet()) {
|
|
||||||
packageSorted[packageIndex++] = packageName;
|
|
||||||
}
|
|
||||||
Arrays.sort(packageSorted);
|
|
||||||
|
|
||||||
// output data
|
|
||||||
StringBuilder output = new StringBuilder();
|
|
||||||
output.append("<div class=\"col-md-3\">");
|
|
||||||
output.append("<div class=\"panel panel-group\"><div class=\"panel-body\">");
|
|
||||||
output.append("<div class=\"panel-heading\"><h3>Packages</h3></div>");
|
|
||||||
output.append("<div class=\"panel-scroll\">");
|
|
||||||
|
|
||||||
for (int i = 0; i < packageSorted.length; i++) {
|
|
||||||
String pkgId = extractId(packageSorted[i]);
|
|
||||||
String pkgDir = baseurl + packageSorted[i].replace('.', '/');
|
|
||||||
|
|
||||||
output.append("<div class=\"panel panel-default\">");
|
|
||||||
output.append("<div class=\"panel-heading\"><h4 class=\"panel-title package-title\">");
|
|
||||||
output.append("<a data-toggle=\"collapse\" data-parent=\"#accordion\" href=\"#collapse-")
|
|
||||||
.append(pkgId)
|
|
||||||
.append("\"><span class=\"glyphicon glyphicon-th-large\"></span> ")
|
|
||||||
.append(packageSorted[i])
|
|
||||||
.append("</a>");
|
|
||||||
output.append("</h4></div>");
|
|
||||||
|
|
||||||
output.append("<div id=\"collapse-")
|
|
||||||
.append(pkgId)
|
|
||||||
.append("\" class=\"panel-collapse collapse\">");
|
|
||||||
output.append("<div class=\"panel-body\">");
|
|
||||||
|
|
||||||
// assemble lists
|
|
||||||
List<String> interfaceNames = new ArrayList<String>();
|
|
||||||
List<String> classNames = new ArrayList<String>();
|
|
||||||
|
|
||||||
for (ZenClassDoc cls : packages.get(packageSorted[i])) {
|
|
||||||
if (cls.getDoc().isInterface()) {
|
|
||||||
interfaceNames.add(cls.getDoc().name());
|
|
||||||
} else {
|
|
||||||
classNames.add(cls.getDoc().name());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Collections.sort(interfaceNames);
|
|
||||||
Collections.sort(classNames);
|
|
||||||
|
|
||||||
if (!interfaceNames.isEmpty()) {
|
|
||||||
output.append("<h4 class=\"interfaces-title\">Interfaces</h4>");
|
|
||||||
output.append("<table class=\"table table-classes\"><tbody>");
|
|
||||||
|
|
||||||
for (String ifaceName : interfaceNames) {
|
|
||||||
output.append("<tr><td><a href=\"")
|
|
||||||
.append(pkgDir).append('/').append(ifaceName).append(".html")
|
|
||||||
.append("\">")
|
|
||||||
.append(ifaceName)
|
|
||||||
.append("</a></td></tr>");
|
|
||||||
}
|
|
||||||
|
|
||||||
output.append("</tbody></table>");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!classNames.isEmpty()) {
|
|
||||||
output.append("<h4 class=\"classes-title\">Classes</h4>");
|
|
||||||
output.append("<table class=\"table table-classes\"><tbody>");
|
|
||||||
|
|
||||||
for (String className : classNames) {
|
|
||||||
output.append("<tr><td><a href=\"")
|
|
||||||
.append(pkgDir).append('/').append(className).append(".html")
|
|
||||||
.append("\">")
|
|
||||||
.append(className)
|
|
||||||
.append("</a></td></tr>");
|
|
||||||
}
|
|
||||||
|
|
||||||
output.append("</tbody></table>");
|
|
||||||
}
|
|
||||||
|
|
||||||
output.append("</div></div></div>");
|
|
||||||
}
|
|
||||||
|
|
||||||
output.append("</div></div></div></div>");
|
|
||||||
return output.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String extractId(String pkg) {
|
|
||||||
return pkg.replace('.', '-');
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void outputType(Writer output, Type type, Map<String, ZenClassDoc> javaClasses, String baseUrl) throws IOException {
|
|
||||||
if (javaClasses.containsKey(type.qualifiedTypeName())) {
|
|
||||||
ZenClassDoc doc = javaClasses.get(type.qualifiedTypeName());
|
|
||||||
output.append("<a href=\"");
|
|
||||||
output.append(makeLink(doc.getName(), baseUrl));
|
|
||||||
output.append("\">");
|
|
||||||
output.append(doc.getName().substring(doc.getName().lastIndexOf('.') + 1));
|
|
||||||
output.append("</a>");
|
|
||||||
} else if (type.qualifiedTypeName().equals("java.util.List")) {
|
|
||||||
Type base = type.asParameterizedType().typeArguments()[0];
|
|
||||||
outputType(output, base, javaClasses, baseUrl);
|
|
||||||
output.append("[]");
|
|
||||||
} else if (type.qualifiedTypeName().equals("java.util.Map")) {
|
|
||||||
Type key = type.asParameterizedType().typeArguments()[0];
|
|
||||||
Type value = type.asParameterizedType().typeArguments()[1];
|
|
||||||
outputType(output, value, javaClasses, baseUrl);
|
|
||||||
output.append('[');
|
|
||||||
outputType(output, key, javaClasses, baseUrl);
|
|
||||||
output.append(']');
|
|
||||||
} else if (type.qualifiedTypeName().equals("java.lang.String")) {
|
|
||||||
output.append("string");
|
|
||||||
} else {
|
|
||||||
output.append(type.qualifiedTypeName());
|
|
||||||
}
|
|
||||||
|
|
||||||
output.append(type.dimension());
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String outputTypeString(Type type, Map<String, ZenClassDoc> javaClasses, String baseUrl) throws IOException {
|
|
||||||
StringBuilder result = new StringBuilder();
|
|
||||||
if (javaClasses.containsKey(type.qualifiedTypeName())) {
|
|
||||||
ZenClassDoc doc = javaClasses.get(type.qualifiedTypeName());
|
|
||||||
result.append("<a href=\"");
|
|
||||||
result.append(makeLink(doc.getName(), baseUrl));
|
|
||||||
result.append("\">");
|
|
||||||
result.append(doc.getName().substring(doc.getName().lastIndexOf('.') + 1));
|
|
||||||
result.append("</a>");
|
|
||||||
} else if (type.qualifiedTypeName().equals("java.util.List")) {
|
|
||||||
Type base = type.asParameterizedType().typeArguments()[0];
|
|
||||||
result.append(outputTypeString(base, javaClasses, baseUrl));
|
|
||||||
result.append("[]");
|
|
||||||
} else if (type.qualifiedTypeName().equals("java.util.Map")) {
|
|
||||||
Type key = type.asParameterizedType().typeArguments()[0];
|
|
||||||
Type value = type.asParameterizedType().typeArguments()[1];
|
|
||||||
result.append(outputTypeString(value, javaClasses, baseUrl));
|
|
||||||
result.append('[');
|
|
||||||
result.append(outputTypeString(key, javaClasses, baseUrl));
|
|
||||||
result.append(']');
|
|
||||||
} else if (type.qualifiedTypeName().equals("java.lang.String")) {
|
|
||||||
result.append("string");
|
|
||||||
} else {
|
|
||||||
result.append(type.qualifiedTypeName());
|
|
||||||
}
|
|
||||||
|
|
||||||
result.append(type.dimension());
|
|
||||||
return result.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void outputTypeRaw(Writer output, Type type, Map<String, ZenClassDoc> javaClasses) throws IOException {
|
|
||||||
if (javaClasses.containsKey(type.qualifiedTypeName())) {
|
|
||||||
ZenClassDoc doc = javaClasses.get(type.qualifiedTypeName());
|
|
||||||
output.append(doc.getName().substring(doc.getName().lastIndexOf('.') + 1));
|
|
||||||
} else if (type.qualifiedTypeName().equals("java.util.List")) {
|
|
||||||
Type base = type.asParameterizedType().typeArguments()[0];
|
|
||||||
outputTypeRaw(output, base, javaClasses);
|
|
||||||
output.append("[]");
|
|
||||||
} else if (type.qualifiedTypeName().equals("java.util.Map")) {
|
|
||||||
Type key = type.asParameterizedType().typeArguments()[0];
|
|
||||||
Type value = type.asParameterizedType().typeArguments()[1];
|
|
||||||
outputTypeRaw(output, value, javaClasses);
|
|
||||||
output.append('[');
|
|
||||||
outputTypeRaw(output, key, javaClasses);
|
|
||||||
output.append(']');
|
|
||||||
} else if (type.qualifiedTypeName().equals("java.lang.String")) {
|
|
||||||
output.append("string");
|
|
||||||
} else {
|
|
||||||
output.append(type.qualifiedTypeName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String makeLink(String className, String baseUrl) {
|
|
||||||
return baseUrl + className.replace('.', '/') + ".html";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,481 +0,0 @@
|
|||||||
/*
|
|
||||||
* To change this license header, choose License Headers in Project Properties.
|
|
||||||
* To change this template file, choose Tools | Templates
|
|
||||||
* and open the template in the editor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package stanhebben.zenscript.util;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Stanneke
|
|
||||||
*/
|
|
||||||
public class StringUtil {
|
|
||||||
private StringUtil() {}
|
|
||||||
|
|
||||||
public static String join(String[] values, String separator) {
|
|
||||||
StringBuilder result = new StringBuilder();
|
|
||||||
boolean first = true;
|
|
||||||
for (String value : values) {
|
|
||||||
if (first) {
|
|
||||||
first = false;
|
|
||||||
} else {
|
|
||||||
result.append('.');
|
|
||||||
}
|
|
||||||
result.append(value);
|
|
||||||
}
|
|
||||||
return result.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String join(Iterable<String> values, String separator) {
|
|
||||||
StringBuilder result = new StringBuilder();
|
|
||||||
boolean first = true;
|
|
||||||
for (String value : values) {
|
|
||||||
if (first) {
|
|
||||||
first = false;
|
|
||||||
} else {
|
|
||||||
result.append('.');
|
|
||||||
}
|
|
||||||
result.append(value);
|
|
||||||
}
|
|
||||||
return result.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Splits a string in parts, given a specified delimiter.
|
|
||||||
*
|
|
||||||
* @param value string to be split
|
|
||||||
* @param delimiter delimiter
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static String[] split(String value, char delimiter) {
|
|
||||||
if (value == null) return null;
|
|
||||||
|
|
||||||
ArrayList<String> result = new ArrayList<String>();
|
|
||||||
int start = 0;
|
|
||||||
outer: for (int i = 0; i < value.length(); i++) {
|
|
||||||
if (value.charAt(i) == delimiter) {
|
|
||||||
result.add(value.substring(start, i));
|
|
||||||
start = i + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
result.add(value.substring(start));
|
|
||||||
return result.toArray(new String[result.size()]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Processes a doc comment into paragraphs.
|
|
||||||
*
|
|
||||||
* @param value input value
|
|
||||||
* @return output paragraphs
|
|
||||||
*/
|
|
||||||
public static String[] splitParagraphs(String value) {
|
|
||||||
String[] lines = split(value, '\n');
|
|
||||||
for (int i = 0; i < lines.length; i++) {
|
|
||||||
lines[i] = lines[i].trim();
|
|
||||||
}
|
|
||||||
ArrayList<String> output = new ArrayList<String>();
|
|
||||||
StringBuilder current = new StringBuilder();
|
|
||||||
for (int i = 0; i < lines.length; i++) {
|
|
||||||
if (lines[i].length() == 0) {
|
|
||||||
if (current.length() > 0) {
|
|
||||||
output.add(current.toString());
|
|
||||||
current = new StringBuilder();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
current.append(' ').append(lines[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (current.length() > 0) {
|
|
||||||
output.add(current.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
return output.toArray(new String[output.size()]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ########################
|
|
||||||
// ### String utilities ###
|
|
||||||
// ########################
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* unescape_perl_string()
|
|
||||||
*
|
|
||||||
* Tom Christiansen <[email protected]> Sun Nov 28 12:55:24 MST 2010
|
|
||||||
*
|
|
||||||
* It's completely ridiculous that there's no standard unescape_java_string
|
|
||||||
* function. Since I have to do the damn thing myself, I might as well make
|
|
||||||
* it halfway useful by supporting things Java was too stupid to consider in
|
|
||||||
* strings:
|
|
||||||
*
|
|
||||||
* => "?" items are additions to Java string escapes but normal in Java
|
|
||||||
* regexes
|
|
||||||
*
|
|
||||||
* => "!" items are also additions to Java regex escapes
|
|
||||||
*
|
|
||||||
* Standard singletons: ?\a ?\e \f \n \r \t
|
|
||||||
*
|
|
||||||
* NB: \b is unsupported as backspace so it can pass-through to the regex
|
|
||||||
* translator untouched; I refuse to make anyone doublebackslash it as
|
|
||||||
* doublebackslashing is a Java idiocy I desperately wish would die out.
|
|
||||||
* There are plenty of other ways to write it:
|
|
||||||
*
|
|
||||||
* \cH, \12, \012, \x08 \x{8}, \u0008, \U00000008
|
|
||||||
*
|
|
||||||
* Octal escapes: \0 \0N \0NN \N \NN \NNN Can range up to !\777 not \377
|
|
||||||
*
|
|
||||||
* TODO: add !\o{NNNNN} last Unicode is 4177777 maxint is 37777777777
|
|
||||||
*
|
|
||||||
* Control chars: ?\cX Means: ord(X) ^ ord('@')
|
|
||||||
*
|
|
||||||
* Old hex escapes: \xXX unbraced must be 2 xdigits
|
|
||||||
*
|
|
||||||
* Perl hex escapes: !\x{XXX} braced may be 1-8 xdigits NB: proper Unicode
|
|
||||||
* never needs more than 6, as highest valid codepoint is 0x10FFFF, not
|
|
||||||
* maxint 0xFFFFFFFF
|
|
||||||
*
|
|
||||||
* Lame Java escape: \[IDIOT JAVA PREPROCESSOR]uXXXX must be exactly 4
|
|
||||||
* xdigits;
|
|
||||||
*
|
|
||||||
* I can't write XXXX in this comment where it belongs because the damned
|
|
||||||
* Java Preprocessor can't mind its own business. Idiots!
|
|
||||||
*
|
|
||||||
* Lame Python escape: !\UXXXXXXXX must be exactly 8 xdigits
|
|
||||||
*
|
|
||||||
* TODO: Perl translation escapes: \Q \U \L \E \[IDIOT JAVA PREPROCESSOR]u
|
|
||||||
* \l These are not so important to cover if you're passing the result to
|
|
||||||
* Pattern.compile(), since it handles them for you further downstream. Hm,
|
|
||||||
* what about \[IDIOT JAVA PREPROCESSOR]u?
|
|
||||||
*
|
|
||||||
* @param oldstr
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static String unescapeString(String oldstr) {
|
|
||||||
if (oldstr.charAt(0) != '"' || oldstr.charAt(oldstr.length() - 1) != '"') {
|
|
||||||
// TODO: error
|
|
||||||
//throw new TweakerExecuteException("Not a valid string constant: "
|
|
||||||
// + oldstr);
|
|
||||||
}
|
|
||||||
oldstr = oldstr.substring(1, oldstr.length() - 1);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* In contrast to fixing Java's broken regex charclasses, this one need
|
|
||||||
* be no bigger, as unescaping shrinks the string here, where in the
|
|
||||||
* other one, it grows it.
|
|
||||||
*/
|
|
||||||
|
|
||||||
StringBuilder newstr = new StringBuilder(oldstr.length());
|
|
||||||
|
|
||||||
boolean saw_backslash = false;
|
|
||||||
|
|
||||||
for (int i = 0; i < oldstr.length(); i++) {
|
|
||||||
int cp = oldstr.codePointAt(i);
|
|
||||||
if (oldstr.codePointAt(i) > Character.MAX_VALUE) {
|
|
||||||
i++;
|
|
||||||
/**** WE HATES UTF-16! WE HATES IT FOREVERSES!!! ****/
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!saw_backslash) {
|
|
||||||
if (cp == '\\') {
|
|
||||||
saw_backslash = true;
|
|
||||||
} else {
|
|
||||||
newstr.append(Character.toChars(cp));
|
|
||||||
}
|
|
||||||
continue; /* switch */
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cp == '\\') {
|
|
||||||
saw_backslash = false;
|
|
||||||
newstr.append('\\');
|
|
||||||
newstr.append('\\');
|
|
||||||
continue; /* switch */
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (cp) {
|
|
||||||
|
|
||||||
case 'r':
|
|
||||||
newstr.append('\r');
|
|
||||||
break; /* switch */
|
|
||||||
|
|
||||||
case 'n':
|
|
||||||
newstr.append('\n');
|
|
||||||
break; /* switch */
|
|
||||||
|
|
||||||
case 'f':
|
|
||||||
newstr.append('\f');
|
|
||||||
break; /* switch */
|
|
||||||
|
|
||||||
/* PASS a \b THROUGH!! */
|
|
||||||
case 'b':
|
|
||||||
newstr.append("\\b");
|
|
||||||
break; /* switch */
|
|
||||||
|
|
||||||
case 't':
|
|
||||||
newstr.append('\t');
|
|
||||||
break; /* switch */
|
|
||||||
|
|
||||||
case 'a':
|
|
||||||
newstr.append('\007');
|
|
||||||
break; /* switch */
|
|
||||||
|
|
||||||
case 'e':
|
|
||||||
newstr.append('\033');
|
|
||||||
break; /* switch */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* A "control" character is what you get when you xor its codepoint
|
|
||||||
* with '@'==64. This only makes sense for ASCII, and may not yield
|
|
||||||
* a "control" character after all.
|
|
||||||
*
|
|
||||||
* Strange but true: "\c{" is ";", "\c}" is "=", etc.
|
|
||||||
*/
|
|
||||||
case 'c': {
|
|
||||||
if (++i == oldstr.length()) {
|
|
||||||
// TODO: error
|
|
||||||
//throw new TweakerExecuteException("trailing \\c");
|
|
||||||
}
|
|
||||||
cp = oldstr.codePointAt(i);
|
|
||||||
/*
|
|
||||||
* don't need to grok surrogates, as next line blows them up
|
|
||||||
*/
|
|
||||||
if (cp > 0x7f) {
|
|
||||||
// TODO: error
|
|
||||||
//throw new TweakerExecuteException(
|
|
||||||
// "expected ASCII after \\c");
|
|
||||||
}
|
|
||||||
newstr.append(Character.toChars(cp ^ 64));
|
|
||||||
break; /* switch */
|
|
||||||
}
|
|
||||||
|
|
||||||
case '8':
|
|
||||||
case '9':
|
|
||||||
// TODO: error
|
|
||||||
//throw new TweakerExecuteException("illegal octal digit");
|
|
||||||
/* NOTREACHED */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* may be 0 to 2 octal digits following this one so back up one
|
|
||||||
* for fallthrough to next case; unread this digit and fall
|
|
||||||
* through to next case.
|
|
||||||
*/
|
|
||||||
case '1':
|
|
||||||
case '2':
|
|
||||||
case '3':
|
|
||||||
case '4':
|
|
||||||
case '5':
|
|
||||||
case '6':
|
|
||||||
case '7':
|
|
||||||
--i;
|
|
||||||
/* FALLTHROUGH */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Can have 0, 1, or 2 octal digits following a 0 this permits
|
|
||||||
* larger values than octal 377, up to octal 777.
|
|
||||||
*/
|
|
||||||
case '0': {
|
|
||||||
if (i + 1 == oldstr.length()) {
|
|
||||||
/* found \0 at end of string */
|
|
||||||
newstr.append(Character.toChars(0));
|
|
||||||
break; /* switch */
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
int digits = 0;
|
|
||||||
int j;
|
|
||||||
for (j = 0; j <= 2; j++) {
|
|
||||||
if (i + j == oldstr.length()) {
|
|
||||||
break; /* for */
|
|
||||||
}
|
|
||||||
/* safe because will unread surrogate */
|
|
||||||
int ch = oldstr.charAt(i + j);
|
|
||||||
if (ch < '0' || ch > '7') {
|
|
||||||
break; /* for */
|
|
||||||
}
|
|
||||||
digits++;
|
|
||||||
}
|
|
||||||
if (digits == 0) {
|
|
||||||
--i;
|
|
||||||
newstr.append('\0');
|
|
||||||
break; /* switch */
|
|
||||||
}
|
|
||||||
int value = 0;
|
|
||||||
try {
|
|
||||||
value = Integer
|
|
||||||
.parseInt(oldstr.substring(i, i + digits), 8);
|
|
||||||
} catch (NumberFormatException nfe) {
|
|
||||||
// TODO: error
|
|
||||||
//throw new TweakerExecuteException(
|
|
||||||
// "invalid octal value for \\0 escape");
|
|
||||||
}
|
|
||||||
newstr.append(Character.toChars(value));
|
|
||||||
i += digits - 1;
|
|
||||||
break; /* switch */
|
|
||||||
} /* end case '0' */
|
|
||||||
|
|
||||||
case 'x': {
|
|
||||||
if (i + 2 > oldstr.length()) {
|
|
||||||
// TODO: error
|
|
||||||
//throw new TweakerExecuteException(
|
|
||||||
// "string too short for \\x escape");
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
boolean saw_brace = false;
|
|
||||||
if (oldstr.charAt(i) == '{') {
|
|
||||||
/* ^^^^^^ ok to ignore surrogates here */
|
|
||||||
i++;
|
|
||||||
saw_brace = true;
|
|
||||||
}
|
|
||||||
int j;
|
|
||||||
for (j = 0; j < 8; j++) {
|
|
||||||
|
|
||||||
if (!saw_brace && j == 2) {
|
|
||||||
break; /* for */
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* ASCII test also catches surrogates
|
|
||||||
*/
|
|
||||||
int ch = oldstr.charAt(i + j);
|
|
||||||
if (ch > 127) {
|
|
||||||
// TODO: error
|
|
||||||
//throw new TweakerExecuteException(
|
|
||||||
// "illegal non-ASCII hex digit in \\x escape");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (saw_brace && ch == '}') {
|
|
||||||
break; /* for */
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!((ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'f') || (ch >= 'A' && ch <= 'F'))) {
|
|
||||||
// TODO: error
|
|
||||||
//throw new TweakerExecuteException(String.format(
|
|
||||||
// "illegal hex digit #%d '%c' in \\x", ch, ch));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
if (j == 0) {
|
|
||||||
// TODO: error
|
|
||||||
//throw new TweakerExecuteException(
|
|
||||||
// "empty braces in \\x{} escape");
|
|
||||||
}
|
|
||||||
int value = 0;
|
|
||||||
try {
|
|
||||||
value = Integer.parseInt(oldstr.substring(i, i + j), 16);
|
|
||||||
} catch (NumberFormatException nfe) {
|
|
||||||
// TODO: error
|
|
||||||
//throw new TweakerExecuteException(
|
|
||||||
// "invalid hex value for \\x escape");
|
|
||||||
}
|
|
||||||
newstr.append(Character.toChars(value));
|
|
||||||
if (saw_brace) {
|
|
||||||
j++;
|
|
||||||
}
|
|
||||||
i += j - 1;
|
|
||||||
break; /* switch */
|
|
||||||
}
|
|
||||||
|
|
||||||
case 'u': {
|
|
||||||
if (i + 4 > oldstr.length()) {
|
|
||||||
// TODO: error
|
|
||||||
//throw new TweakerExecuteException(
|
|
||||||
// "string too short for \\u escape");
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
int j;
|
|
||||||
for (j = 0; j < 4; j++) {
|
|
||||||
/* this also handles the surrogate issue */
|
|
||||||
if (oldstr.charAt(i + j) > 127) {
|
|
||||||
// TODO: error
|
|
||||||
//throw new TweakerExecuteException(
|
|
||||||
// "illegal non-ASCII hex digit in \\u escape");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
int value = 0;
|
|
||||||
try {
|
|
||||||
value = Integer.parseInt(oldstr.substring(i, i + j), 16);
|
|
||||||
} catch (NumberFormatException nfe) {
|
|
||||||
// TODO: error
|
|
||||||
//throw new TweakerExecuteException(
|
|
||||||
// "invalid hex value for \\u escape");
|
|
||||||
}
|
|
||||||
newstr.append(Character.toChars(value));
|
|
||||||
i += j - 1;
|
|
||||||
break; /* switch */
|
|
||||||
}
|
|
||||||
|
|
||||||
case 'U': {
|
|
||||||
if (i + 8 > oldstr.length()) {
|
|
||||||
// TODO: error
|
|
||||||
//throw new TweakerExecuteException(
|
|
||||||
// "string too short for \\U escape");
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
int j;
|
|
||||||
for (j = 0; j < 8; j++) {
|
|
||||||
/* this also handles the surrogate issue */
|
|
||||||
if (oldstr.charAt(i + j) > 127) {
|
|
||||||
// TODO: error
|
|
||||||
//throw new TweakerExecuteException(
|
|
||||||
// "illegal non-ASCII hex digit in \\U escape");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
int value = 0;
|
|
||||||
try {
|
|
||||||
value = Integer.parseInt(oldstr.substring(i, i + j), 16);
|
|
||||||
} catch (NumberFormatException nfe) {
|
|
||||||
// TODO: error
|
|
||||||
//throw new TweakerExecuteException(
|
|
||||||
// "invalid hex value for \\U escape");
|
|
||||||
}
|
|
||||||
newstr.append(Character.toChars(value));
|
|
||||||
i += j - 1;
|
|
||||||
break; /* switch */
|
|
||||||
}
|
|
||||||
|
|
||||||
default:
|
|
||||||
newstr.append('\\');
|
|
||||||
newstr.append(Character.toChars(cp));
|
|
||||||
/*
|
|
||||||
* say(String.format(
|
|
||||||
* "DEFAULT unrecognized escape %c passed through", cp));
|
|
||||||
*/
|
|
||||||
break; /* switch */
|
|
||||||
|
|
||||||
}
|
|
||||||
saw_backslash = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* weird to leave one at the end */
|
|
||||||
if (saw_backslash) {
|
|
||||||
newstr.append('\\');
|
|
||||||
}
|
|
||||||
|
|
||||||
return newstr.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Return a string "U+XX.XXX.XXXX" etc, where each XX set is the xdigits of
|
|
||||||
* the logical Unicode code point. No bloody brain-damaged UTF-16 surrogate
|
|
||||||
* crap, just true logical characters.
|
|
||||||
*/
|
|
||||||
private static String uniplus(String s) {
|
|
||||||
if (s.length() == 0) {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
/* This is just the minimum; sb will grow as needed. */
|
|
||||||
StringBuilder sb = new StringBuilder(2 + 3 * s.length());
|
|
||||||
sb.append("U+");
|
|
||||||
for (int i = 0; i < s.length(); i++) {
|
|
||||||
sb.append(String.format("%X", s.codePointAt(i)));
|
|
||||||
if (s.codePointAt(i) > Character.MAX_VALUE) {
|
|
||||||
i++;
|
|
||||||
/**** WE HATES UTF-16! WE HATES IT FOREVERSES!!! ****/
|
|
||||||
}
|
|
||||||
if (i + 1 < s.length()) {
|
|
||||||
sb.append(".");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+5
-3
@@ -1,5 +1,7 @@
|
|||||||
|
// Add your dependencies here
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
shadowImplementation("com.github.GTNewHorizons:ZenScript:1.0.1-GTNH")
|
compile("com.github.GTNewHorizons:NotEnoughItems:2.1.22-GTNH:dev")
|
||||||
implementation("com.github.GTNewHorizons:NotEnoughItems:2.8.75-GTNH:dev")
|
|
||||||
compileOnly("net.industrial-craft:industrialcraft-2:2.2.828-experimental:dev")
|
compile("net.industrial-craft:industrialcraft-2:2.2.828-experimental:dev")
|
||||||
}
|
}
|
||||||
+28
-202
@@ -1,238 +1,64 @@
|
|||||||
# ExampleMod tag to use as Blowdryer (Spotless, etc.) settings version, leave empty to disable.
|
|
||||||
# LOCAL to test local config updates.
|
|
||||||
gtnh.settings.blowdryerTag = 0.2.0
|
|
||||||
|
|
||||||
# Human-readable mod name, available for mcmod.info population.
|
|
||||||
modName = MineTweaker 3
|
modName = MineTweaker 3
|
||||||
|
|
||||||
# Case-sensitive identifier string, available for mcmod.info population and used for automatic mixin JSON generation.
|
# This is a case-sensitive string to identify your mod. Convention is to use lower case.
|
||||||
# Conventionally lowercase.
|
|
||||||
modId = MineTweaker3
|
modId = MineTweaker3
|
||||||
|
|
||||||
# Root package of the mod, used to find various classes in other properties,
|
|
||||||
# mcmod.info substitution, enabling assertions in run tasks, etc.
|
|
||||||
modGroup = minetweaker
|
modGroup = minetweaker
|
||||||
|
|
||||||
# Whether to use modGroup as the maven publishing group.
|
# WHY is there no version field?
|
||||||
# When false, com.github.GTNewHorizons is used.
|
# The build script relies on git to provide a version via tags. It is super easy and will enable you to always know the
|
||||||
useModGroupForPublishing = false
|
# code base or your binary. Check out this tutorial: https://blog.mattclemente.com/2017/10/13/versioning-with-git-tags/
|
||||||
|
|
||||||
# Updates your build.gradle and settings.gradle automatically whenever an update is available.
|
# Will update your build.gradle automatically whenever an update is available
|
||||||
autoUpdateBuildScript = false
|
autoUpdateBuildScript = false
|
||||||
|
|
||||||
# Version of Minecraft to target
|
|
||||||
minecraftVersion = 1.7.10
|
minecraftVersion = 1.7.10
|
||||||
|
|
||||||
# Version of Minecraft Forge to target
|
|
||||||
forgeVersion = 10.13.4.1614
|
forgeVersion = 10.13.4.1614
|
||||||
|
|
||||||
# Specify an MCP channel for dependency deobfuscation and the deobfParams task.
|
# Select a username for testing your mod with breakpoints. You may leave this empty for a random user name each time you
|
||||||
channel = stable
|
# restart Minecraft in development. Choose this dependent on your mod:
|
||||||
|
# Do you need consistent player progressing (for example Thaumcraft)? -> Select a name
|
||||||
|
# Do you need to test how your custom blocks interacts with a player that is not the owner? -> leave name empty
|
||||||
|
developmentEnvironmentUserName = "Developer"
|
||||||
|
|
||||||
# Specify an MCP mappings version for dependency deobfuscation and the deobfParams task.
|
# Define a source file of your project with:
|
||||||
mappingsVersion = 12
|
# public static final String VERSION = "GRADLETOKEN_VERSION";
|
||||||
|
# The string's content will be replaced with your mods version when compiled. You should use this to specify your mod's
|
||||||
# Defines other MCP mappings for dependency deobfuscation.
|
# version in @Mod([...], version = VERSION, [...])
|
||||||
remoteMappings = https\://raw.githubusercontent.com/MinecraftForge/FML/1.7.10/conf/
|
# Leave these properties empty to skip individual token replacements
|
||||||
|
replaceGradleTokenInFile = MineTweakerMod.java
|
||||||
# Select a default username for testing your mod. You can always override this per-run by running
|
|
||||||
# `./gradlew runClient --username=AnotherPlayer`, or configuring this command in your IDE.
|
|
||||||
developmentEnvironmentUserName = Developer
|
|
||||||
|
|
||||||
# Enables modern Java syntax support. Valid values:
|
|
||||||
# - false: No modern syntax, Java 8 only
|
|
||||||
# - jabel: Jabel syntax-only support, compiles to J8 bytecode
|
|
||||||
# - jvmDowngrader: Full modern Java via JVM Downgrader (syntax + stdlib APIs)
|
|
||||||
# - modern: Native modern Java bytecode, no downgrading
|
|
||||||
enableModernJavaSyntax = false
|
|
||||||
|
|
||||||
# If set, ignores the above setting and compiles with the given toolchain. This may cause unexpected issues,
|
|
||||||
# and should *not* be used in most situations. -1 disables this.
|
|
||||||
# forceToolchainVersion = -1
|
|
||||||
|
|
||||||
# Target JVM version for JVM Downgrader bytecode downgrading.
|
|
||||||
# Only used when enableModernJavaSyntax = jvmDowngrader
|
|
||||||
# downgradeTargetVersion = 8
|
|
||||||
|
|
||||||
# Comma-separated list of Java versions for multi-release jar support (JVM Downgrader only).
|
|
||||||
# Classes will be available in META-INF/versions/N/ for each version N in this list.
|
|
||||||
# Default: "21,25" (J25+ gets native classes, J21-24 gets partial downgrade, J8-20 gets full downgrade).
|
|
||||||
# jvmDowngraderMultiReleaseVersions = 21,25
|
|
||||||
|
|
||||||
# Specifies how JVM Downgrader API stubs are provided. Options:
|
|
||||||
# - shade: Shade minimized stubs into the jar
|
|
||||||
# - gtnhlib: GTNHLib provides stubs at runtime (adds version constraint)
|
|
||||||
# - external: Another dependency provides stubs (no constraint, no warning)
|
|
||||||
# - (empty): Warning reminding you to configure stubs
|
|
||||||
# Note: 'shade' option requires you to verify license compliance, see: https://github.com/unimined/JvmDowngrader/blob/main/LICENSE.md
|
|
||||||
# jvmDowngraderStubsProvider =
|
|
||||||
|
|
||||||
# Enables injecting missing generics into the decompiled source code for a better coding experience.
|
|
||||||
# Turns most publicly visible List, Map, etc. into proper List<E>, Map<K, V> types.
|
|
||||||
enableGenericInjection = false
|
|
||||||
|
|
||||||
# Generate a class with a String field for the mod version named as defined below.
|
|
||||||
# If generateGradleTokenClass is empty or not missing, no such class will be generated.
|
|
||||||
# If gradleTokenVersion is empty or missing, the field will not be present in the class.
|
|
||||||
generateGradleTokenClass = minetweaker.mc1710.Tags
|
|
||||||
|
|
||||||
# Name of the token containing the project's current version to generate/replace.
|
|
||||||
gradleTokenVersion = MOD_VERSION
|
|
||||||
|
|
||||||
# [DEPRECATED] Mod ID replacement token.
|
|
||||||
gradleTokenModId =
|
gradleTokenModId =
|
||||||
|
|
||||||
# [DEPRECATED] Mod name replacement token.
|
|
||||||
gradleTokenModName =
|
gradleTokenModName =
|
||||||
|
gradleTokenVersion = GRADLETOKEN_VERSION
|
||||||
# [DEPRECATED] Mod Group replacement token.
|
|
||||||
gradleTokenGroupName =
|
gradleTokenGroupName =
|
||||||
|
|
||||||
# [DEPRECATED]
|
# In case your mod provides an API for other mods to implement you may declare its package here. Otherwise you can
|
||||||
# Multiple source files can be defined here by providing a comma-separated list: Class1.java,Class2.java,Class3.java
|
|
||||||
# public static final String VERSION = "GRADLETOKEN_VERSION";
|
|
||||||
# The string's content will be replaced with your mod's version when compiled. You should use this to specify your mod's
|
|
||||||
# version in @Mod([...], version = VERSION, [...]).
|
|
||||||
# Leave these properties empty to skip individual token replacements.
|
|
||||||
replaceGradleTokenInFile =
|
|
||||||
|
|
||||||
# In case your mod provides an API for other mods to implement you may declare its package here. Otherwise, you can
|
|
||||||
# leave this property empty.
|
# leave this property empty.
|
||||||
# Example value: (apiPackage = api) + (modGroup = com.myname.mymodid) -> com.myname.mymodid.api
|
# Example value: apiPackage = api + modGroup = com.myname.mymodid -> com.myname.mymodid.api
|
||||||
apiPackage =
|
apiPackage =
|
||||||
|
|
||||||
# Specify the configuration file for Forge's access transformers here. It must be placed into /src/main/resources/META-INF/
|
# Specify the configuration file for Forge's access transformers here. I must be placed into /src/main/resources/META-INF/
|
||||||
# There can be multiple files in a space-separated list.
|
# Example value: mymodid_at.cfg
|
||||||
# Example value: mymodid_at.cfg nei_at.cfg
|
|
||||||
accessTransformersFile =
|
accessTransformersFile =
|
||||||
|
|
||||||
# Provides setup for Mixins if enabled. If you don't know what mixins are: Keep it disabled!
|
# Provides setup for Mixins if enabled. If you don't know what mixins are: Keep it disabled!
|
||||||
usesMixins = false
|
usesMixins = false
|
||||||
|
|
||||||
# Set to a non-empty string to configure mixins in a separate source set under src/VALUE, instead of src/main.
|
|
||||||
# This can speed up compile times thanks to not running the mixin annotation processor on all input sources.
|
|
||||||
# Mixin classes will have access to "main" classes, but not the other way around.
|
|
||||||
separateMixinSourceSet =
|
|
||||||
|
|
||||||
# Adds some debug arguments like verbose output and class export.
|
|
||||||
usesMixinDebug = false
|
|
||||||
|
|
||||||
# Specify the location of your implementation of IMixinConfigPlugin. Leave it empty otherwise.
|
# Specify the location of your implementation of IMixinConfigPlugin. Leave it empty otherwise.
|
||||||
mixinPlugin =
|
mixinPlugin =
|
||||||
|
# Specify the package that contains all of your Mixins. You may only place Mixins in this package or the build will fail!
|
||||||
# Specify the package that contains all of your Mixins. The package must exist or
|
|
||||||
# the build will fail. If you have a package property defined in your mixins.<modid>.json,
|
|
||||||
# it must match with this or the build will fail.
|
|
||||||
mixinsPackage =
|
mixinsPackage =
|
||||||
|
|
||||||
# Specify the core mod entry class if you use a core mod. This class must implement IFMLLoadingPlugin!
|
# Specify the core mod entry class if you use a core mod. This class must implement IFMLLoadingPlugin!
|
||||||
# This parameter is for legacy compatibility only
|
# This parameter is for legacy compatability only
|
||||||
# Example value: (coreModClass = asm.FMLPlugin) + (modGroup = com.myname.mymodid) -> com.myname.mymodid.asm.FMLPlugin
|
# Example value: coreModClass = asm.FMLPlugin + modGroup = com.myname.mymodid -> com.myname.mymodid.asm.FMLPlugin
|
||||||
coreModClass =
|
coreModClass =
|
||||||
|
|
||||||
# If your project is only a consolidation of mixins or a core mod and does NOT contain a 'normal' mod ( = some class
|
# If your project is only a consolidation of mixins or a core mod and does NOT contain a 'normal' mod ( = some class
|
||||||
# that is annotated with @Mod) you want this to be true. When in doubt: leave it on false!
|
# that is annotated with @Mod) you want this to be true. When in doubt: leave it on false!
|
||||||
containsMixinsAndOrCoreModOnly = false
|
containsMixinsAndOrCoreModOnly = false
|
||||||
|
|
||||||
# Enables Mixins even if this mod doesn't use them, useful if one of the dependencies uses mixins.
|
# If enabled, you may use 'shadowImplementation' for dependencies. They will be integrated in your jar. It is your
|
||||||
forceEnableMixins = false
|
# responsibility check the licence and request permission for distribution, if required.
|
||||||
|
usesShadowedDependencies = no
|
||||||
|
|
||||||
# If enabled, you may use 'shadowCompile' for dependencies. They will be integrated into your jar. It is your
|
# Optional parameter to customize the produced artifacts. Use this to preserver artifact naming when migrating older
|
||||||
# responsibility to check the license and request permission for distribution if required.
|
|
||||||
usesShadowedDependencies = true
|
|
||||||
|
|
||||||
# If disabled, won't remove unused classes from shadowed dependencies. Some libraries use reflection to access
|
|
||||||
# their own classes, making the minimization unreliable.
|
|
||||||
minimizeShadowedDependencies = false
|
|
||||||
|
|
||||||
# If disabled, won't rename the shadowed classes.
|
|
||||||
relocateShadowedDependencies = false
|
|
||||||
|
|
||||||
# Adds CurseMaven, Modrinth, and some more well-known 1.7.10 repositories.
|
|
||||||
includeWellKnownRepositories = true
|
|
||||||
|
|
||||||
# A list of repositories to exclude from the includeWellKnownRepositories setting. Should be a space separated
|
|
||||||
# list of strings, with the acceptable keys being(case does not matter):
|
|
||||||
# cursemaven
|
|
||||||
# modrinth
|
|
||||||
excludeWellKnownRepositories =
|
|
||||||
|
|
||||||
# Change these to your Maven coordinates if you want to publish to a custom Maven repository instead of the default GTNH Maven.
|
|
||||||
# Authenticate with the MAVEN_USER and MAVEN_PASSWORD environment variables.
|
|
||||||
# If you need a more complex setup disable maven publishing here and add a publishing repository to addon.gradle.
|
|
||||||
usesMavenPublishing = true
|
|
||||||
|
|
||||||
# Maven repository to publish the mod to.
|
|
||||||
# mavenPublishUrl = https\://nexus.gtnewhorizons.com/repository/releases/
|
|
||||||
|
|
||||||
# Publishing to Modrinth requires you to set the MODRINTH_TOKEN environment variable to your current Modrinth API token.
|
|
||||||
#
|
|
||||||
# The project's ID on Modrinth. Can be either the slug or the ID.
|
|
||||||
# Leave this empty if you don't want to publish to Modrinth.
|
|
||||||
modrinthProjectId =
|
|
||||||
|
|
||||||
# The project's relations on Modrinth. You can use this to refer to other projects on Modrinth.
|
|
||||||
# Syntax: scope1-type1:name1;scope2-type2:name2;...
|
|
||||||
# Where scope can be one of [required, optional, incompatible, embedded],
|
|
||||||
# type can be one of [project, version],
|
|
||||||
# and the name is the Modrinth project or version slug/id of the other mod.
|
|
||||||
# Example: required-project:fplib;optional-project:gasstation;incompatible-project:gregtech
|
|
||||||
# Note: UniMixins is automatically set as a required dependency if usesMixins = true.
|
|
||||||
modrinthRelations =
|
|
||||||
|
|
||||||
# Publishing to CurseForge requires you to set the CURSEFORGE_TOKEN environment variable to one of your CurseForge API tokens.
|
|
||||||
#
|
|
||||||
# The project's numeric ID on CurseForge. You can find this in the About Project box.
|
|
||||||
# Leave this empty if you don't want to publish on CurseForge.
|
|
||||||
curseForgeProjectId =
|
|
||||||
|
|
||||||
# The project's relations on CurseForge. You can use this to refer to other projects on CurseForge.
|
|
||||||
# Syntax: type1:name1;type2:name2;...
|
|
||||||
# Where type can be one of [requiredDependency, embeddedLibrary, optionalDependency, tool, incompatible],
|
|
||||||
# and the name is the CurseForge project slug of the other mod.
|
|
||||||
# Example: requiredDependency:railcraft;embeddedLibrary:cofhlib;incompatible:buildcraft
|
|
||||||
# Note: UniMixins is automatically set as a required dependency if usesMixins = true.
|
|
||||||
curseForgeRelations =
|
|
||||||
|
|
||||||
# Optional parameter to customize the produced artifacts. Use this to preserve artifact naming when migrating older
|
|
||||||
# projects. New projects should not use this parameter.
|
# projects. New projects should not use this parameter.
|
||||||
customArchiveBaseName = CraftTweaker
|
customArchiveBaseName = CraftTweaker
|
||||||
|
|
||||||
# Optional parameter to customize the default working directory used by the runClient* tasks. Relative to the project directory.
|
|
||||||
# runClientWorkingDirectory = run/client
|
|
||||||
|
|
||||||
# Optional parameter to customize the default working directory used by the runServer* tasks. Relative to the project directory.
|
|
||||||
# runServerWorkingDirectory = run/server
|
|
||||||
|
|
||||||
# Optional parameter to have the build automatically fail if an illegal version is used.
|
|
||||||
# This can be useful if you e.g. only want to allow versions in the form of '1.1.xxx'.
|
|
||||||
# The check is ONLY performed if the version is a git tag.
|
|
||||||
# Note: the specified string must be escaped, so e.g. 1\\.1\\.\\d+ instead of 1\.1\.\d+
|
|
||||||
# versionPattern =
|
|
||||||
|
|
||||||
# Uncomment to prevent the source code from being published.
|
|
||||||
# noPublishedSources = true
|
|
||||||
|
|
||||||
# Uncomment this to disable Spotless checks.
|
|
||||||
# This should only be uncommented to keep it easier to sync with upstream/other forks.
|
|
||||||
# That is, if there is no other active fork/upstream, NEVER change this.
|
|
||||||
# disableSpotless = true
|
|
||||||
|
|
||||||
# Uncomment this to disable Checkstyle checks (currently wildcard import check).
|
|
||||||
disableCheckstyle = true
|
|
||||||
|
|
||||||
# Override the IDEA build type. Valid values are: "" (leave blank, do not override), "idea" (force use native IDEA build), "gradle"
|
|
||||||
# (force use delegated build).
|
|
||||||
# This is meant to be set in $HOME/.gradle/gradle.properties.
|
|
||||||
# e.g. add "systemProp.org.gradle.project.ideaOverrideBuildType=idea" will override the build type to be native build.
|
|
||||||
# WARNING: If you do use this option, it will overwrite whatever you have in your existing projects. This might not be what you want!
|
|
||||||
# Usually there is no need to uncomment this here as other developers do not necessarily use the same build type as you.
|
|
||||||
# ideaOverrideBuildType = idea
|
|
||||||
|
|
||||||
# Whether IDEA should run spotless checks when pressing the Build button.
|
|
||||||
# This is meant to be set in $HOME/.gradle/gradle.properties.
|
|
||||||
# ideaCheckSpotlessOnBuild = true
|
|
||||||
|
|
||||||
# Non-GTNH properties
|
|
||||||
org.gradle.configuration-cache = true
|
|
||||||
org.gradle.parallel = true
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
#This file is generated by updateDaemonJvm
|
|
||||||
toolchainUrl.FREE_BSD.AARCH64=https\://api.foojay.io/disco/v3.0/ids/1630f7ebef05444cb27a2709ea0249b3/redirect
|
|
||||||
toolchainUrl.FREE_BSD.X86_64=https\://api.foojay.io/disco/v3.0/ids/cd495626d2ee49a75447e3fdc6afb287/redirect
|
|
||||||
toolchainUrl.LINUX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/1630f7ebef05444cb27a2709ea0249b3/redirect
|
|
||||||
toolchainUrl.LINUX.X86_64=https\://api.foojay.io/disco/v3.0/ids/cd495626d2ee49a75447e3fdc6afb287/redirect
|
|
||||||
toolchainUrl.MAC_OS.AARCH64=https\://api.foojay.io/disco/v3.0/ids/e1118b4c7c2858d28154d086dbff010e/redirect
|
|
||||||
toolchainUrl.MAC_OS.X86_64=https\://api.foojay.io/disco/v3.0/ids/59a9771cad43219260d9aac9a8ec4d6a/redirect
|
|
||||||
toolchainUrl.UNIX.AARCH64=https\://api.foojay.io/disco/v3.0/ids/1630f7ebef05444cb27a2709ea0249b3/redirect
|
|
||||||
toolchainUrl.UNIX.X86_64=https\://api.foojay.io/disco/v3.0/ids/cd495626d2ee49a75447e3fdc6afb287/redirect
|
|
||||||
toolchainUrl.WINDOWS.X86_64=https\://api.foojay.io/disco/v3.0/ids/b96cb7670c095245220e7d01d5927b58/redirect
|
|
||||||
toolchainVendor=ADOPTIUM
|
|
||||||
toolchainVersion=25
|
|
||||||
Vendored
BIN
Binary file not shown.
+1
-3
@@ -1,7 +1,5 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.0-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-6.9.1-bin.zip
|
||||||
networkTimeout=10000
|
|
||||||
validateDistributionUrl=true
|
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/bin/sh
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
#
|
#
|
||||||
# Copyright © 2015 the original authors.
|
# Copyright 2015 the original author or authors.
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
@@ -15,114 +15,80 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
|
||||||
#
|
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
#
|
##
|
||||||
# Gradle start up script for POSIX generated by Gradle.
|
## Gradle start up script for UN*X
|
||||||
#
|
##
|
||||||
# Important for running:
|
|
||||||
#
|
|
||||||
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
|
||||||
# noncompliant, but you have some other compliant shell such as ksh or
|
|
||||||
# bash, then to run this script, type that shell name before the whole
|
|
||||||
# command line, like:
|
|
||||||
#
|
|
||||||
# ksh Gradle
|
|
||||||
#
|
|
||||||
# Busybox and similar reduced shells will NOT work, because this script
|
|
||||||
# requires all of these POSIX shell features:
|
|
||||||
# * functions;
|
|
||||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
|
||||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
|
||||||
# * compound commands having a testable exit status, especially «case»;
|
|
||||||
# * various built-in commands including «command», «set», and «ulimit».
|
|
||||||
#
|
|
||||||
# Important for patching:
|
|
||||||
#
|
|
||||||
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
|
||||||
# by Bash, Ksh, etc; in particular arrays are avoided.
|
|
||||||
#
|
|
||||||
# The "traditional" practice of packing multiple parameters into a
|
|
||||||
# space-separated string is a well documented source of bugs and security
|
|
||||||
# problems, so this is (mostly) avoided, by progressively accumulating
|
|
||||||
# options in "$@", and eventually passing that to Java.
|
|
||||||
#
|
|
||||||
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
|
||||||
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
|
||||||
# see the in-line comments for details.
|
|
||||||
#
|
|
||||||
# There are tweaks for specific operating systems such as AIX, CygWin,
|
|
||||||
# Darwin, MinGW, and NonStop.
|
|
||||||
#
|
|
||||||
# (3) This script is generated from the Groovy template
|
|
||||||
# https://github.com/gradle/gradle/blob/b631911858264c0b6e4d6603d677ff5218766cee/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
|
||||||
# within the Gradle project.
|
|
||||||
#
|
|
||||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
|
||||||
#
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
# Attempt to set APP_HOME
|
# Attempt to set APP_HOME
|
||||||
|
|
||||||
# Resolve links: $0 may be a link
|
# Resolve links: $0 may be a link
|
||||||
app_path=$0
|
PRG="$0"
|
||||||
|
# Need this for relative symlinks.
|
||||||
# Need this for daisy-chained symlinks.
|
while [ -h "$PRG" ] ; do
|
||||||
while
|
ls=`ls -ld "$PRG"`
|
||||||
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||||
[ -h "$app_path" ]
|
if expr "$link" : '/.*' > /dev/null; then
|
||||||
do
|
PRG="$link"
|
||||||
ls=$( ls -ld "$app_path" )
|
else
|
||||||
link=${ls#*' -> '}
|
PRG=`dirname "$PRG"`"/$link"
|
||||||
case $link in #(
|
fi
|
||||||
/*) app_path=$link ;; #(
|
|
||||||
*) app_path=$APP_HOME$link ;;
|
|
||||||
esac
|
|
||||||
done
|
done
|
||||||
|
SAVED="`pwd`"
|
||||||
|
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||||
|
APP_HOME="`pwd -P`"
|
||||||
|
cd "$SAVED" >/dev/null
|
||||||
|
|
||||||
# This is normally unused
|
APP_NAME="Gradle"
|
||||||
# shellcheck disable=SC2034
|
APP_BASE_NAME=`basename "$0"`
|
||||||
APP_BASE_NAME=${0##*/}
|
|
||||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
|
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||||
|
|
||||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
MAX_FD=maximum
|
MAX_FD="maximum"
|
||||||
|
|
||||||
warn () {
|
warn () {
|
||||||
echo "$*"
|
echo "$*"
|
||||||
} >&2
|
}
|
||||||
|
|
||||||
die () {
|
die () {
|
||||||
echo
|
echo
|
||||||
echo "$*"
|
echo "$*"
|
||||||
echo
|
echo
|
||||||
exit 1
|
exit 1
|
||||||
} >&2
|
}
|
||||||
|
|
||||||
# OS specific support (must be 'true' or 'false').
|
# OS specific support (must be 'true' or 'false').
|
||||||
cygwin=false
|
cygwin=false
|
||||||
msys=false
|
msys=false
|
||||||
darwin=false
|
darwin=false
|
||||||
nonstop=false
|
nonstop=false
|
||||||
case "$( uname )" in #(
|
case "`uname`" in
|
||||||
CYGWIN* ) cygwin=true ;; #(
|
CYGWIN* )
|
||||||
Darwin* ) darwin=true ;; #(
|
cygwin=true
|
||||||
MSYS* | MINGW* ) msys=true ;; #(
|
;;
|
||||||
NONSTOP* ) nonstop=true ;;
|
Darwin* )
|
||||||
|
darwin=true
|
||||||
|
;;
|
||||||
|
MINGW* )
|
||||||
|
msys=true
|
||||||
|
;;
|
||||||
|
NONSTOP* )
|
||||||
|
nonstop=true
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||||
|
|
||||||
# Determine the Java command to use to start the JVM.
|
# Determine the Java command to use to start the JVM.
|
||||||
if [ -n "$JAVA_HOME" ] ; then
|
if [ -n "$JAVA_HOME" ] ; then
|
||||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||||
# IBM's JDK on AIX uses strange locations for the executables
|
# IBM's JDK on AIX uses strange locations for the executables
|
||||||
JAVACMD=$JAVA_HOME/jre/sh/java
|
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||||
else
|
else
|
||||||
JAVACMD=$JAVA_HOME/bin/java
|
JAVACMD="$JAVA_HOME/bin/java"
|
||||||
fi
|
fi
|
||||||
if [ ! -x "$JAVACMD" ] ; then
|
if [ ! -x "$JAVACMD" ] ; then
|
||||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||||
@@ -131,118 +97,92 @@ Please set the JAVA_HOME variable in your environment to match the
|
|||||||
location of your Java installation."
|
location of your Java installation."
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
JAVACMD=java
|
JAVACMD="java"
|
||||||
if ! command -v java >/dev/null 2>&1
|
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
then
|
|
||||||
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
|
||||||
|
|
||||||
Please set the JAVA_HOME variable in your environment to match the
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
location of your Java installation."
|
location of your Java installation."
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Increase the maximum file descriptors if we can.
|
# Increase the maximum file descriptors if we can.
|
||||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||||
case $MAX_FD in #(
|
MAX_FD_LIMIT=`ulimit -H -n`
|
||||||
max*)
|
if [ $? -eq 0 ] ; then
|
||||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||||
# shellcheck disable=SC2039,SC3045
|
MAX_FD="$MAX_FD_LIMIT"
|
||||||
MAX_FD=$( ulimit -H -n ) ||
|
fi
|
||||||
warn "Could not query maximum file descriptor limit"
|
ulimit -n $MAX_FD
|
||||||
esac
|
if [ $? -ne 0 ] ; then
|
||||||
case $MAX_FD in #(
|
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||||
'' | soft) :;; #(
|
fi
|
||||||
*)
|
else
|
||||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||||
# shellcheck disable=SC2039,SC3045
|
fi
|
||||||
ulimit -n "$MAX_FD" ||
|
|
||||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
|
||||||
esac
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Collect all arguments for the java command, stacking in reverse order:
|
# For Darwin, add options to specify how the application appears in the dock
|
||||||
# * args from the command line
|
if $darwin; then
|
||||||
# * the main class name
|
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||||
# * -classpath
|
fi
|
||||||
# * -D...appname settings
|
|
||||||
# * --module-path (only if needed)
|
|
||||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
|
||||||
|
|
||||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||||
if "$cygwin" || "$msys" ; then
|
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
||||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||||
|
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||||
|
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||||
|
|
||||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
# We build the pattern for arguments to be converted via cygpath
|
||||||
|
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
SEP=""
|
||||||
for arg do
|
for dir in $ROOTDIRSRAW ; do
|
||||||
if
|
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||||
case $arg in #(
|
SEP="|"
|
||||||
-*) false ;; # don't mess with options #(
|
|
||||||
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
|
||||||
[ -e "$t" ] ;; #(
|
|
||||||
*) false ;;
|
|
||||||
esac
|
|
||||||
then
|
|
||||||
arg=$( cygpath --path --ignore --mixed "$arg" )
|
|
||||||
fi
|
|
||||||
# Roll the args list around exactly as many times as the number of
|
|
||||||
# args, so each arg winds up back in the position where it started, but
|
|
||||||
# possibly modified.
|
|
||||||
#
|
|
||||||
# NB: a `for` loop captures its iteration list before it begins, so
|
|
||||||
# changing the positional parameters here affects neither the number of
|
|
||||||
# iterations, nor the values presented in `arg`.
|
|
||||||
shift # remove old arg
|
|
||||||
set -- "$@" "$arg" # push replacement arg
|
|
||||||
done
|
done
|
||||||
|
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||||
|
# Add a user-defined pattern to the cygpath arguments
|
||||||
|
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||||
|
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||||
|
fi
|
||||||
|
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||||
|
i=0
|
||||||
|
for arg in "$@" ; do
|
||||||
|
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||||
|
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||||
|
|
||||||
|
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||||
|
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||||
|
else
|
||||||
|
eval `echo args$i`="\"$arg\""
|
||||||
|
fi
|
||||||
|
i=$((i+1))
|
||||||
|
done
|
||||||
|
case $i in
|
||||||
|
(0) set -- ;;
|
||||||
|
(1) set -- "$args0" ;;
|
||||||
|
(2) set -- "$args0" "$args1" ;;
|
||||||
|
(3) set -- "$args0" "$args1" "$args2" ;;
|
||||||
|
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||||
|
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||||
|
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||||
|
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||||
|
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||||
|
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||||
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Escape application args
|
||||||
|
save () {
|
||||||
|
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||||
|
echo " "
|
||||||
|
}
|
||||||
|
APP_ARGS=$(save "$@")
|
||||||
|
|
||||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||||
|
|
||||||
# Collect all arguments for the java command:
|
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
|
||||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
|
||||||
# and any embedded shellness will be escaped.
|
cd "$(dirname "$0")"
|
||||||
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
|
||||||
# treated as '${Hostname}' itself on the command line.
|
|
||||||
|
|
||||||
set -- \
|
|
||||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
|
||||||
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
|
|
||||||
"$@"
|
|
||||||
|
|
||||||
# Stop when "xargs" is not available.
|
|
||||||
if ! command -v xargs >/dev/null 2>&1
|
|
||||||
then
|
|
||||||
die "xargs is not available"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Use "xargs" to parse quoted args.
|
|
||||||
#
|
|
||||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
|
||||||
#
|
|
||||||
# In Bash we could simply go:
|
|
||||||
#
|
|
||||||
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
|
||||||
# set -- "${ARGS[@]}" "$@"
|
|
||||||
#
|
|
||||||
# but POSIX shell has neither arrays nor command substitution, so instead we
|
|
||||||
# post-process each arg (as a line of input to sed) to backslash-escape any
|
|
||||||
# character that might be a shell metacharacter, then use eval to reverse
|
|
||||||
# that process (while maintaining the separation between arguments), and wrap
|
|
||||||
# the whole thing up as a single "set" statement.
|
|
||||||
#
|
|
||||||
# This will of course break if any of these variables contains a newline or
|
|
||||||
# an unmatched quote.
|
|
||||||
#
|
|
||||||
|
|
||||||
eval "set -- $(
|
|
||||||
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
|
||||||
xargs -n1 |
|
|
||||||
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
|
||||||
tr '\n' ' '
|
|
||||||
)" '"$@"'
|
|
||||||
|
|
||||||
exec "$JAVACMD" "$@"
|
exec "$JAVACMD" "$@"
|
||||||
Vendored
+34
-27
@@ -13,10 +13,8 @@
|
|||||||
@rem See the License for the specific language governing permissions and
|
@rem See the License for the specific language governing permissions and
|
||||||
@rem limitations under the License.
|
@rem limitations under the License.
|
||||||
@rem
|
@rem
|
||||||
@rem SPDX-License-Identifier: Apache-2.0
|
|
||||||
@rem
|
|
||||||
|
|
||||||
@if "%DEBUG%"=="" @echo off
|
@if "%DEBUG%" == "" @echo off
|
||||||
@rem ##########################################################################
|
@rem ##########################################################################
|
||||||
@rem
|
@rem
|
||||||
@rem Gradle startup script for Windows
|
@rem Gradle startup script for Windows
|
||||||
@@ -27,14 +25,10 @@
|
|||||||
if "%OS%"=="Windows_NT" setlocal
|
if "%OS%"=="Windows_NT" setlocal
|
||||||
|
|
||||||
set DIRNAME=%~dp0
|
set DIRNAME=%~dp0
|
||||||
if "%DIRNAME%"=="" set DIRNAME=.
|
if "%DIRNAME%" == "" set DIRNAME=.
|
||||||
@rem This is normally unused
|
|
||||||
set APP_BASE_NAME=%~n0
|
set APP_BASE_NAME=%~n0
|
||||||
set APP_HOME=%DIRNAME%
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
|
||||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
|
||||||
|
|
||||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||||
|
|
||||||
@@ -43,13 +37,13 @@ if defined JAVA_HOME goto findJavaFromJavaHome
|
|||||||
|
|
||||||
set JAVA_EXE=java.exe
|
set JAVA_EXE=java.exe
|
||||||
%JAVA_EXE% -version >NUL 2>&1
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
if %ERRORLEVEL% equ 0 goto execute
|
if "%ERRORLEVEL%" == "0" goto init
|
||||||
|
|
||||||
echo. 1>&2
|
echo.
|
||||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
echo. 1>&2
|
echo.
|
||||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
echo Please set the JAVA_HOME variable in your environment to match the
|
||||||
echo location of your Java installation. 1>&2
|
echo location of your Java installation.
|
||||||
|
|
||||||
goto fail
|
goto fail
|
||||||
|
|
||||||
@@ -57,35 +51,48 @@ goto fail
|
|||||||
set JAVA_HOME=%JAVA_HOME:"=%
|
set JAVA_HOME=%JAVA_HOME:"=%
|
||||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||||
|
|
||||||
if exist "%JAVA_EXE%" goto execute
|
if exist "%JAVA_EXE%" goto init
|
||||||
|
|
||||||
echo. 1>&2
|
echo.
|
||||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
|
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||||
echo. 1>&2
|
echo.
|
||||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
echo Please set the JAVA_HOME variable in your environment to match the
|
||||||
echo location of your Java installation. 1>&2
|
echo location of your Java installation.
|
||||||
|
|
||||||
goto fail
|
goto fail
|
||||||
|
|
||||||
|
:init
|
||||||
|
@rem Get command-line arguments, handling Windows variants
|
||||||
|
|
||||||
|
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||||
|
|
||||||
|
:win9xME_args
|
||||||
|
@rem Slurp the command line arguments.
|
||||||
|
set CMD_LINE_ARGS=
|
||||||
|
set _SKIP=2
|
||||||
|
|
||||||
|
:win9xME_args_slurp
|
||||||
|
if "x%~1" == "x" goto execute
|
||||||
|
|
||||||
|
set CMD_LINE_ARGS=%*
|
||||||
|
|
||||||
:execute
|
:execute
|
||||||
@rem Setup the command line
|
@rem Setup the command line
|
||||||
|
|
||||||
|
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||||
|
|
||||||
@rem Execute Gradle
|
@rem Execute Gradle
|
||||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
|
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||||
|
|
||||||
:end
|
:end
|
||||||
@rem End local scope for the variables with windows NT shell
|
@rem End local scope for the variables with windows NT shell
|
||||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||||
|
|
||||||
:fail
|
:fail
|
||||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||||
rem the _cmd.exe /c_ return code!
|
rem the _cmd.exe /c_ return code!
|
||||||
set EXIT_CODE=%ERRORLEVEL%
|
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
exit /b 1
|
||||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
|
||||||
exit /b %EXIT_CODE%
|
|
||||||
|
|
||||||
:mainEnd
|
:mainEnd
|
||||||
if "%OS%"=="Windows_NT" endlocal
|
if "%OS%"=="Windows_NT" endlocal
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
before_install:
|
||||||
|
- ./gradlew setupCIWorkspace
|
||||||
@@ -1,4 +1,19 @@
|
|||||||
// Add any additional repositories for your dependencies here
|
// Add any additional repositories for your dependencies here
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
|
maven {
|
||||||
|
name = "GTNH Maven"
|
||||||
|
url = "http://jenkins.usrv.eu:8081/nexus/content/groups/public/"
|
||||||
|
}
|
||||||
|
maven {
|
||||||
|
name = "ic2"
|
||||||
|
url = "http://maven.ic2.player.to/"
|
||||||
|
metadataSources {
|
||||||
|
mavenPom()
|
||||||
|
artifact()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
maven {
|
||||||
|
url = "https://jitpack.io"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
|
|
||||||
pluginManagement {
|
|
||||||
repositories {
|
|
||||||
maven {
|
|
||||||
// RetroFuturaGradle
|
|
||||||
name "GTNH Maven"
|
|
||||||
url "https://nexus.gtnewhorizons.com/repository/public/"
|
|
||||||
mavenContent {
|
|
||||||
includeGroup("com.gtnewhorizons")
|
|
||||||
includeGroupByRegex("com\\.gtnewhorizons\\..+")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
gradlePluginPortal()
|
|
||||||
mavenCentral()
|
|
||||||
mavenLocal()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
plugins {
|
|
||||||
id 'com.gtnewhorizons.gtnhsettingsconvention' version '2.0.24'
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@@ -3,14 +3,13 @@ package minetweaker;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The class registry provides the list of annotated classes to the scripting system.
|
* The class registry provides the list of annotated classes to the scripting
|
||||||
*
|
* system.
|
||||||
|
*
|
||||||
* @author Stan Hebben
|
* @author Stan Hebben
|
||||||
*/
|
*/
|
||||||
public class ClassRegistry {
|
public class ClassRegistry {
|
||||||
|
public static void getClasses(List<Class> output) {
|
||||||
public static void getClasses(List<Class> output) {
|
// method stub; contents generated by RegisterZenClassesTask
|
||||||
// no longer needed. kept to not break anyone who reference this
|
}
|
||||||
// seriously though, why would anyone want to look at this registry anyway
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
package minetweaker;
|
package minetweaker;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import stanhebben.zenscript.compiler.IEnvironmentGlobal;
|
import stanhebben.zenscript.compiler.IEnvironmentGlobal;
|
||||||
import stanhebben.zenscript.parser.Token;
|
import stanhebben.zenscript.parser.Token;
|
||||||
import stanhebben.zenscript.symbols.IZenSymbol;
|
import stanhebben.zenscript.symbols.IZenSymbol;
|
||||||
@@ -9,25 +8,25 @@ import stanhebben.zenscript.symbols.IZenSymbol;
|
|||||||
/**
|
/**
|
||||||
* Bracket handlers enable processing of the bracket syntax.
|
* Bracket handlers enable processing of the bracket syntax.
|
||||||
*
|
*
|
||||||
* Inside brackets, any kind of token is acceptable except the closing bracket. (>) Bracket handlers (multiple
|
* Inside brackets, any kind of token is acceptable except the closing bracket.
|
||||||
* handlers can be registered) will resolve these tokens into actual values. Values have to be ZenScript symbols and
|
* (>) Bracket handlers (multiple handlers can be registered) will resolve
|
||||||
* will resolve at compile-time.
|
* these tokens into actual values. Values have to be ZenScript symbols and will
|
||||||
|
* resolve at compile-time.
|
||||||
*
|
*
|
||||||
* These may of course return an expression that are executed on run-time, but the type of the resulting value must be
|
* These may of course return an expression that are executed on run-time, but
|
||||||
* known compile-time.
|
* the type of the resulting value must be known compile-time.
|
||||||
*
|
*
|
||||||
* @author Stan Hebben
|
* @author Stan Hebben
|
||||||
*/
|
*/
|
||||||
public interface IBracketHandler {
|
public interface IBracketHandler {
|
||||||
|
/**
|
||||||
/**
|
* Resolves a set of tokens.
|
||||||
* Resolves a set of tokens.
|
*
|
||||||
*
|
* If the series of tokens is unrecognized, this method should return null.
|
||||||
* If the series of tokens is unrecognized, this method should return null.
|
*
|
||||||
*
|
* @param environment global compilation environment
|
||||||
* @param environment global compilation environment
|
* @param tokens token stream to be detected
|
||||||
* @param tokens token stream to be detected
|
* @return the resolved symbol, or null
|
||||||
* @return the resolved symbol, or null
|
*/
|
||||||
*/
|
public IZenSymbol resolve(IEnvironmentGlobal environment, List<Token> tokens);
|
||||||
public IZenSymbol resolve(IEnvironmentGlobal environment, List<Token> tokens);
|
|
||||||
}
|
}
|
||||||
@@ -4,33 +4,33 @@ import minetweaker.api.chat.IChatMessage;
|
|||||||
import minetweaker.api.item.IItemDefinition;
|
import minetweaker.api.item.IItemDefinition;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Platform functions are a set of internal functions implemented by the platform intended to communicate between API
|
* Platform functions are a set of internal functions implemented by the
|
||||||
* and implementation.
|
* platform intended to communicate between API and implementation.
|
||||||
*
|
*
|
||||||
* @author Stan Hebben
|
* @author Stan Hebben
|
||||||
*/
|
*/
|
||||||
public interface IPlatformFunctions {
|
public interface IPlatformFunctions {
|
||||||
|
/**
|
||||||
|
* Converts a string into a chat message.
|
||||||
|
*
|
||||||
|
* @param message message string
|
||||||
|
* @return chat message
|
||||||
|
*/
|
||||||
|
public IChatMessage getMessage(String message);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts a string into a chat message.
|
* Distributes the given script data to all connected clients. Automatically
|
||||||
*
|
* reloads the scripts from this data.
|
||||||
* @param message message string
|
*
|
||||||
* @return chat message
|
* @param data data to be distributed
|
||||||
*/
|
*/
|
||||||
public IChatMessage getMessage(String message);
|
public void distributeScripts(byte[] data);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Distributes the given script data to all connected clients. Automatically reloads the scripts from this data.
|
* Finds the item definition with the given ID.
|
||||||
*
|
*
|
||||||
* @param data data to be distributed
|
* @param id item ID
|
||||||
*/
|
* @return resulting item definition
|
||||||
public void distributeScripts(byte[] data);
|
*/
|
||||||
|
public IItemDefinition getItemDefinition(int id);
|
||||||
/**
|
|
||||||
* Finds the item definition with the given ID.
|
|
||||||
*
|
|
||||||
* @param id item ID
|
|
||||||
* @return resulting item definition
|
|
||||||
*/
|
|
||||||
public IItemDefinition getItemDefinition(int id);
|
|
||||||
}
|
}
|
||||||
@@ -3,17 +3,16 @@ package minetweaker;
|
|||||||
import minetweaker.api.item.IIngredient;
|
import minetweaker.api.item.IIngredient;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to register removable mod recipes for mod machines. Once registered, it will be called when minetweaker.remove()
|
* Used to register removable mod recipes for mod machines. Once registered, it
|
||||||
* is called.
|
* will be called when minetweaker.remove() is called.
|
||||||
*
|
*
|
||||||
* @author Stan Hebben
|
* @author Stan Hebben
|
||||||
*/
|
*/
|
||||||
public interface IRecipeRemover {
|
public interface IRecipeRemover {
|
||||||
|
/**
|
||||||
/**
|
* Removes all the items matching the given ingredient.
|
||||||
* Removes all the items matching the given ingredient.
|
*
|
||||||
*
|
* @param ingredient ingredient
|
||||||
* @param ingredient ingredient
|
*/
|
||||||
*/
|
public void remove(IIngredient ingredient);
|
||||||
public void remove(IIngredient ingredient);
|
|
||||||
}
|
}
|
||||||
@@ -3,70 +3,82 @@ package minetweaker;
|
|||||||
/**
|
/**
|
||||||
* Defines a (possibly) undoable action.
|
* Defines a (possibly) undoable action.
|
||||||
*
|
*
|
||||||
* Every modification made by a command must be registered to the Tweaker with the Tweaker.apply method. This enables
|
* Every modification made by a command must be registered to the Tweaker with
|
||||||
* MineTweaker to keep track of actions that have been performed, and enables them to be rolled back later on.
|
* the Tweaker.apply method. This enables MineTweaker to keep track of actions
|
||||||
|
* that have been performed, and enables them to be rolled back later on.
|
||||||
*
|
*
|
||||||
* Actions exist in two flavors: undoable and permanent. If an action returns canUndo(), the action is undoable,
|
* Actions exist in two flavors: undoable and permanent. If an action returns
|
||||||
* otherwise it is permanent. Permanent actions cannot be used in server scripts.
|
* canUndo(), the action is undoable, otherwise it is permanent. Permanent
|
||||||
|
* actions cannot be used in server scripts.
|
||||||
*
|
*
|
||||||
* There also exist semi-permanent actions. Those actions can return an override key; if a newer action has the same
|
* There also exist semi-permanent actions. Those actions can return an override
|
||||||
* override key as an old action, the new action is considered to override the old one.
|
* key; if a newer action has the same override key as an old action, the new
|
||||||
|
* action is considered to override the old one.
|
||||||
*
|
*
|
||||||
* Likewise, actions can implement hashCode and equals methods to indicate that they are equal. If an action is equal to
|
* Likewise, actions can implement hashCode and equals methods to indicate that
|
||||||
* a non-undoable stuck action, it will be omitted from execution.
|
* they are equal. If an action is equal to a non-undoable stuck action, it will
|
||||||
|
* be omitted from execution.
|
||||||
*
|
*
|
||||||
* @author Stan Hebben
|
* @author Stan Hebben
|
||||||
*/
|
*/
|
||||||
public interface IUndoableAction {
|
public interface IUndoableAction {
|
||||||
|
/**
|
||||||
|
* Executes what the action is supposed to do. This method can be called
|
||||||
|
* again if undo() has been called in between.
|
||||||
|
*/
|
||||||
|
public void apply();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes what the action is supposed to do. This method can be called again if undo() has been called in between.
|
* Checks if this action can be undone. If this method returns true, it must
|
||||||
*/
|
* implement undo() properly. If this method returns false, the action is
|
||||||
public void apply();
|
* considered permanent, undo() will never be called, and the action cannot
|
||||||
|
* be executed as part of a server script. Additionally, the
|
||||||
|
* minetweaker.clear() function will not work and minetweaker.canClear will
|
||||||
|
* return false.
|
||||||
|
*
|
||||||
|
* @return undoable status
|
||||||
|
*/
|
||||||
|
public boolean canUndo();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if this action can be undone. If this method returns true, it must implement undo() properly. If this
|
* Undoes the action. Will only be called after apply() has been executed.
|
||||||
* method returns false, the action is considered permanent, undo() will never be called, and the action cannot be
|
* After an undo, apply may be called again. They could be done multiple
|
||||||
* executed as part of a server script. Additionally, the minetweaker.clear() function will not work and
|
* times in certain scenarios.
|
||||||
* minetweaker.canClear will return false.
|
*/
|
||||||
*
|
public void undo();
|
||||||
* @return undoable status
|
|
||||||
*/
|
|
||||||
public boolean canUndo();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Undoes the action. Will only be called after apply() has been executed. After an undo, apply may be called again.
|
* Describes, in a single human-readable sentence, what this specific action
|
||||||
* They could be done multiple times in certain scenarios.
|
* is doing. Used in logging messages, lists, ...
|
||||||
*/
|
*
|
||||||
public void undo();
|
* Try to be as descriptive as possible without being too verbose.
|
||||||
|
*
|
||||||
|
* Examples: - Adding Peach planks to the woodPlanks ore dictionary entry -
|
||||||
|
* Removing a recipe for Iron Ore
|
||||||
|
*
|
||||||
|
* @return the description of this action
|
||||||
|
*/
|
||||||
|
public String describe();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Describes, in a single human-readable sentence, what this specific action is doing. Used in logging messages,
|
* Describes what this action does if it is undone. Similar to the
|
||||||
* lists, ...
|
* describe() method. No implementation is needed if the action cannot be
|
||||||
*
|
* undone.
|
||||||
* Try to be as descriptive as possible without being too verbose.
|
*
|
||||||
*
|
* @return the description of this action, when undone
|
||||||
* Examples: - Adding Peach planks to the woodPlanks ore dictionary entry - Removing a recipe for Iron Ore
|
*/
|
||||||
*
|
public String describeUndo();
|
||||||
* @return the description of this action
|
|
||||||
*/
|
|
||||||
public String describe();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Describes what this action does if it is undone. Similar to the describe() method. No implementation is needed if
|
* Returns the override key. Two actions are considered to override each
|
||||||
* the action cannot be undone.
|
* other if their override key is equal. You can return null to indicate
|
||||||
*
|
* that an action can never be overridden.
|
||||||
* @return the description of this action, when undone
|
*
|
||||||
*/
|
* This value only makes sense for recipes that are not undoable. For
|
||||||
public String describeUndo();
|
* undoable recipes, you should return null.
|
||||||
|
*
|
||||||
/**
|
* @return override key (null for actions that are undoable or which can
|
||||||
* Returns the override key. Two actions are considered to override each other if their override key is equal. You
|
* never be overridden by another action)
|
||||||
* can return null to indicate that an action can never be overridden.
|
*/
|
||||||
*
|
public Object getOverrideKey();
|
||||||
* This value only makes sense for recipes that are not undoable. For undoable recipes, you should return null.
|
|
||||||
*
|
|
||||||
* @return override key (null for actions that are undoable or which can never be overridden by another action)
|
|
||||||
*/
|
|
||||||
public Object getOverrideKey();
|
|
||||||
}
|
}
|
||||||
@@ -1,15 +1,5 @@
|
|||||||
package minetweaker;
|
package minetweaker;
|
||||||
|
|
||||||
import java.lang.annotation.Annotation;
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.lang.reflect.Modifier;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import minetweaker.annotations.BracketHandler;
|
import minetweaker.annotations.BracketHandler;
|
||||||
import minetweaker.annotations.ModOnly;
|
import minetweaker.annotations.ModOnly;
|
||||||
import minetweaker.api.client.IClient;
|
import minetweaker.api.client.IClient;
|
||||||
@@ -36,385 +26,427 @@ import stanhebben.zenscript.symbols.SymbolJavaStaticMethod;
|
|||||||
import stanhebben.zenscript.type.natives.IJavaMethod;
|
import stanhebben.zenscript.type.natives.IJavaMethod;
|
||||||
import stanhebben.zenscript.type.natives.JavaMethod;
|
import stanhebben.zenscript.type.natives.JavaMethod;
|
||||||
|
|
||||||
|
import java.lang.annotation.Annotation;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.lang.reflect.Modifier;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides access to the MineTweaker API.
|
* Provides access to the MineTweaker API.
|
||||||
*
|
*
|
||||||
* An implementing platform needs to do the following: - Set a logger - Set the ore dictionary - Set the recipe manager
|
* An implementing platform needs to do the following: - Set a logger - Set the
|
||||||
* - Set the furnace manager - Set event manager - Set resource manager
|
* ore dictionary - Set the recipe manager - Set the furnace manager - Set event
|
||||||
|
* manager - Set resource manager
|
||||||
*
|
*
|
||||||
* - Register additional global symbols to the GlobalRegistry (recipes, minetweaker, oreDict, logger, as well as the
|
* - Register additional global symbols to the GlobalRegistry (recipes,
|
||||||
* official set of functions) - Register native classes using the GlobalRegistry - Register bracket handlers to resolve
|
* minetweaker, oreDict, logger, as well as the official set of functions) -
|
||||||
* block/item/... references using the bracket syntax
|
* Register native classes using the GlobalRegistry - Register bracket handlers
|
||||||
|
* to resolve block/item/... references using the bracket syntax
|
||||||
*
|
*
|
||||||
* @author Stan Hebben
|
* @author Stan Hebben
|
||||||
*/
|
*/
|
||||||
public class MineTweakerAPI {
|
public class MineTweakerAPI {
|
||||||
|
public static final String[] COLOR_NAMES = {
|
||||||
public static final String[] COLOR_NAMES = { "White", "Orange", "Magenta", "Light Blue", "Yellow", "Lime", "Pink",
|
"White",
|
||||||
"Gray", "Light Gray", "Cyan", "Purple", "Blue", "Brown", "Green", "Red", "Black" };
|
"Orange",
|
||||||
|
"Magenta",
|
||||||
|
"Light Blue",
|
||||||
|
"Yellow",
|
||||||
|
"Lime",
|
||||||
|
"Pink",
|
||||||
|
"Gray",
|
||||||
|
"Light Gray",
|
||||||
|
"Cyan",
|
||||||
|
"Purple",
|
||||||
|
"Blue",
|
||||||
|
"Brown",
|
||||||
|
"Green",
|
||||||
|
"Red",
|
||||||
|
"Black"
|
||||||
|
};
|
||||||
private static IJEIRecipeRegistry ijeiRecipeRegistry = new DummyJEIRecipeRegistry();
|
private static IJEIRecipeRegistry ijeiRecipeRegistry = new DummyJEIRecipeRegistry();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
registerClassRegistry(ClassRegistry.class, "MT-API");
|
registerClassRegistry(ClassRegistry.class, "MT-API");
|
||||||
|
|
||||||
registerGlobalSymbol("logger", getJavaStaticGetterSymbol(MineTweakerAPI.class, "getLogger"));
|
registerGlobalSymbol("logger", getJavaStaticGetterSymbol(MineTweakerAPI.class, "getLogger"));
|
||||||
registerGlobalSymbol("recipes", getJavaStaticFieldSymbol(MineTweakerAPI.class, "recipes"));
|
registerGlobalSymbol("recipes", getJavaStaticFieldSymbol(MineTweakerAPI.class, "recipes"));
|
||||||
// registerGlobalSymbol("brewing", getJavaStaticFieldSymbol(MineTweakerAPI.class, "brewing"));
|
// registerGlobalSymbol("brewing", getJavaStaticFieldSymbol(MineTweakerAPI.class, "brewing"));
|
||||||
registerGlobalSymbol("furnace", getJavaStaticFieldSymbol(MineTweakerAPI.class, "furnace"));
|
registerGlobalSymbol("furnace", getJavaStaticFieldSymbol(MineTweakerAPI.class, "furnace"));
|
||||||
registerGlobalSymbol("oreDict", getJavaStaticFieldSymbol(MineTweakerAPI.class, "oreDict"));
|
registerGlobalSymbol("oreDict", getJavaStaticFieldSymbol(MineTweakerAPI.class, "oreDict"));
|
||||||
registerGlobalSymbol("events", getJavaStaticFieldSymbol(MineTweakerAPI.class, "events"));
|
registerGlobalSymbol("events", getJavaStaticFieldSymbol(MineTweakerAPI.class, "events"));
|
||||||
registerGlobalSymbol("server", getJavaStaticFieldSymbol(MineTweakerAPI.class, "server"));
|
registerGlobalSymbol("server", getJavaStaticFieldSymbol(MineTweakerAPI.class, "server"));
|
||||||
registerGlobalSymbol("client", getJavaStaticFieldSymbol(MineTweakerAPI.class, "client"));
|
registerGlobalSymbol("client", getJavaStaticFieldSymbol(MineTweakerAPI.class, "client"));
|
||||||
registerGlobalSymbol("game", getJavaStaticFieldSymbol(MineTweakerAPI.class, "game"));
|
registerGlobalSymbol("game", getJavaStaticFieldSymbol(MineTweakerAPI.class, "game"));
|
||||||
registerGlobalSymbol("loadedMods", getJavaStaticFieldSymbol(MineTweakerAPI.class, "loadedMods"));
|
registerGlobalSymbol("loadedMods", getJavaStaticFieldSymbol(MineTweakerAPI.class, "loadedMods"));
|
||||||
registerGlobalSymbol("format", getJavaStaticFieldSymbol(MineTweakerAPI.class, "format"));
|
registerGlobalSymbol("format", getJavaStaticFieldSymbol(MineTweakerAPI.class, "format"));
|
||||||
registerGlobalSymbol("vanilla", getJavaStaticFieldSymbol(MineTweakerAPI.class, "vanilla"));
|
registerGlobalSymbol("vanilla", getJavaStaticFieldSymbol(MineTweakerAPI.class, "vanilla"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private MineTweakerAPI() {
|
private MineTweakerAPI() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Tweaker is where you apply undoable actions. Any kind of action that reloads with the scripts should always
|
* The Tweaker is where you apply undoable actions. Any kind of action that
|
||||||
* be submitted to the tweaker.
|
* reloads with the scripts should always be submitted to the tweaker.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static final ITweaker tweaker = new MTTweaker();
|
public static final ITweaker tweaker = new MTTweaker();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The logger can be used to write logging messages to the client. Error and warning messages should be relayed to
|
* The logger can be used to write logging messages to the client. Error and
|
||||||
* admins for further handling.
|
* warning messages should be relayed to admins for further handling.
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static final ILogger getLogger() {
|
public static final ILogger getLogger() {
|
||||||
return MineTweakerImplementationAPI.logger;
|
return MineTweakerImplementationAPI.logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Access point to the ore dictionary.
|
* Access point to the ore dictionary.
|
||||||
*/
|
*/
|
||||||
public static IOreDict oreDict = null;
|
public static IOreDict oreDict = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Access point to the recipe manager.
|
* Access point to the recipe manager.
|
||||||
*/
|
*/
|
||||||
public static IRecipeManager recipes = null;
|
public static IRecipeManager recipes = null;
|
||||||
|
|
||||||
// /**
|
// /**
|
||||||
// * Access point to the brewing manager.
|
// * Access point to the brewing manager.
|
||||||
// */
|
// */
|
||||||
// public static IBrewingManager brewing = null;
|
// public static IBrewingManager brewing = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Access point to the furnace manager.
|
* Access point to the furnace manager.
|
||||||
*/
|
*/
|
||||||
public static IFurnaceManager furnace = null;
|
public static IFurnaceManager furnace = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Access point to the events manager.
|
* Access point to the events manager.
|
||||||
*/
|
*/
|
||||||
public static final IEventManager events = MineTweakerImplementationAPI.events;
|
public static final IEventManager events = MineTweakerImplementationAPI.events;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Access point to the server, if any.
|
* Access point to the server, if any.
|
||||||
*/
|
*/
|
||||||
public static IServer server = null;
|
public static IServer server = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Access point to the client, if any.
|
* Access point to the client, if any.
|
||||||
*/
|
*/
|
||||||
public static IClient client = null;
|
public static IClient client = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Access point to general game data, such as items.
|
* Access point to general game data, such as items.
|
||||||
*/
|
*/
|
||||||
public static IGame game = null;
|
public static IGame game = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Access point to mods list.
|
* Access point to mods list.
|
||||||
*/
|
*/
|
||||||
public static ILoadedMods loadedMods = null;
|
public static ILoadedMods loadedMods = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Access point to the text formatter.
|
* Access point to the text formatter.
|
||||||
*/
|
*/
|
||||||
public static IFormatter format = null;
|
public static IFormatter format = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Access point to the vanilla functions and data.
|
* Access point to the vanilla functions and data.
|
||||||
*/
|
*/
|
||||||
public static IVanilla vanilla = null;
|
public static IVanilla vanilla = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Applies this given action.
|
* Applies this given action.
|
||||||
*
|
*
|
||||||
* @param action action object
|
* @param action action object
|
||||||
*/
|
*/
|
||||||
public static void apply(IUndoableAction action) {
|
public static void apply(IUndoableAction action) {
|
||||||
tweaker.apply(action);
|
tweaker.apply(action);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logs a command message. Commands messages are those generated as output in response to a command.
|
* Logs a command message. Commands messages are those generated as output
|
||||||
*
|
* in response to a command.
|
||||||
* @param message command message
|
*
|
||||||
*/
|
* @param message command message
|
||||||
public static void logCommand(String message) {
|
*/
|
||||||
getLogger().logCommand(message);
|
public static void logCommand(String message) {
|
||||||
}
|
getLogger().logCommand(message);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logs an info message. Info messages have low priority and will only be displayed in the log files, but not
|
* Logs an info message. Info messages have low priority and will only be
|
||||||
* directly to players in-game.
|
* displayed in the log files, but not directly to players in-game.
|
||||||
*
|
*
|
||||||
* @param message info message
|
* @param message info message
|
||||||
*/
|
*/
|
||||||
public static void logInfo(String message) {
|
public static void logInfo(String message) {
|
||||||
getLogger().logInfo(message);
|
getLogger().logInfo(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logs a warning message. Warning messages are displayed to admins and indicate that there is an issue. However,
|
* Logs a warning message. Warning messages are displayed to admins and
|
||||||
* the issue is not a large problem, and everything should run fine - besides perhaps a few things not entirely
|
* indicate that there is an issue. However, the issue is not a large
|
||||||
* working as expected.
|
* problem, and everything should run fine - besides perhaps a few things
|
||||||
*
|
* not entirely working as expected.
|
||||||
* @param message warning message
|
*
|
||||||
*/
|
* @param message warning message
|
||||||
public static void logWarning(String message) {
|
*/
|
||||||
getLogger().logWarning(message);
|
public static void logWarning(String message) {
|
||||||
}
|
getLogger().logWarning(message);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logs an error message. Error messages indicate a real problem and indicate that things won't run properly. The
|
* Logs an error message. Error messages indicate a real problem and
|
||||||
* scripting system will still make a best-effort attempt at executing the rest of the scripts, but that might cause
|
* indicate that things won't run properly. The scripting system will still
|
||||||
* additional errors and issues.
|
* make a best-effort attempt at executing the rest of the scripts, but that
|
||||||
*
|
* might cause additional errors and issues.
|
||||||
* @param message error message
|
*
|
||||||
*/
|
* @param message error message
|
||||||
public static void logError(String message) {
|
*/
|
||||||
getLogger().logError(message);
|
public static void logError(String message) {
|
||||||
}
|
getLogger().logError(message);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logs an error message. Error messages indicate a real problem and indicate that things won't run properly. The
|
* Logs an error message. Error messages indicate a real problem and
|
||||||
* scripting system will still make a best-effort attempt at executing the rest of the scripts, but that might cause
|
* indicate that things won't run properly. The scripting system will still
|
||||||
* additional errors and issues.
|
* make a best-effort attempt at executing the rest of the scripts, but that
|
||||||
*
|
* might cause additional errors and issues.
|
||||||
* @param message error message
|
*
|
||||||
* @param exception exception that was caught related to the error
|
* @param message error message
|
||||||
*/
|
* @param exception exception that was caught related to the error
|
||||||
public static void logError(String message, Throwable exception) {
|
*/
|
||||||
getLogger().logError(message, exception);
|
public static void logError(String message, Throwable exception) {
|
||||||
}
|
getLogger().logError(message, exception);
|
||||||
|
}
|
||||||
|
|
||||||
// ###################################
|
// ###################################
|
||||||
// ### Plugin registration methods ###
|
// ### Plugin registration methods ###
|
||||||
// ###################################
|
// ###################################
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register a class registry class. Such class must have (at least) a public static method called "getClasses" with
|
* Register a class registry class. Such class must have (at least) a public
|
||||||
* accepts a List of classes and which stores its classes into that list.
|
* static method called "getClasses" with accepts a List of classes and
|
||||||
*
|
* which stores its classes into that list.
|
||||||
* @param registryClass
|
*
|
||||||
*/
|
* @param registryClass
|
||||||
public static void registerClassRegistry(Class registryClass) {
|
*/
|
||||||
registerClassRegistry(registryClass, null);
|
public static void registerClassRegistry(Class registryClass) {
|
||||||
}
|
registerClassRegistry(registryClass, null);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register a class registry class. Such class must have (at least) a public static method called "getClasses" with
|
* Register a class registry class. Such class must have (at least) a public
|
||||||
* accepts a List of classes and which stores its classes into that list.
|
* static method called "getClasses" with accepts a List of classes and
|
||||||
*
|
* which stores its classes into that list.
|
||||||
* @param registryClass
|
*
|
||||||
* @param description
|
* @param registryClass
|
||||||
*/
|
* @param description
|
||||||
public static void registerClassRegistry(Class registryClass, String description) {
|
*/
|
||||||
try {
|
public static void registerClassRegistry(Class registryClass, String description) {
|
||||||
Method method = registryClass.getMethod("getClasses", List.class);
|
try {
|
||||||
if ((method.getModifiers() & Modifier.STATIC) == 0) {
|
Method method = registryClass.getMethod("getClasses", List.class);
|
||||||
logError("ERROR: getClasses method in " + registryClass.getName() + " isn't static");
|
if ((method.getModifiers() & Modifier.STATIC) == 0) {
|
||||||
} else {
|
logError("ERROR: getClasses method in " + registryClass.getName() + " isn't static");
|
||||||
List<Class> classes = new ArrayList<Class>();
|
} else {
|
||||||
method.invoke(null, classes);
|
List<Class> classes = new ArrayList<Class>();
|
||||||
|
method.invoke(null, classes);
|
||||||
|
|
||||||
outer: for (Class cls : classes) {
|
outer: for (Class cls : classes) {
|
||||||
for (Annotation annotation : cls.getAnnotations()) {
|
for (Annotation annotation : cls.getAnnotations()) {
|
||||||
if (annotation instanceof ModOnly) {
|
if (annotation instanceof ModOnly) {
|
||||||
String[] value = ((ModOnly) annotation).value();
|
String[] value = ((ModOnly) annotation).value();
|
||||||
String version = ((ModOnly) annotation).version();
|
String version = ((ModOnly) annotation).version();
|
||||||
|
|
||||||
for (String mod : value) {
|
for (String mod : value) {
|
||||||
if (!loadedMods.contains(mod)) continue outer;
|
if (!loadedMods.contains(mod))
|
||||||
|
continue outer;
|
||||||
|
|
||||||
if (!loadedMods.get(mod).getVersion().startsWith(version)) continue outer;
|
if (!loadedMods.get(mod).getVersion().startsWith(version))
|
||||||
}
|
continue outer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
MineTweakerAPI.registerClass(cls);
|
MineTweakerAPI.registerClass(cls);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (description != null) logInfo("Loaded class registry: " + description);
|
if (description != null)
|
||||||
}
|
logInfo("Loaded class registry: " + description);
|
||||||
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
|
}
|
||||||
if (ex.getCause() instanceof NoClassDefFoundError) {
|
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
|
||||||
logInfo("Classes for registry " + registryClass + " not found, skipping");
|
if(ex.getCause() instanceof NoClassDefFoundError) {
|
||||||
|
logInfo("Classes for registry " + registryClass + " not found, skipping");
|
||||||
} else {
|
} else {
|
||||||
logError("Error registering class registry", ex);
|
logError("Error registering class registry", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers a class registry. Will attempt to resolve the given class name. Does nothing if the class could not be
|
* Registers a class registry. Will attempt to resolve the given class name.
|
||||||
* loaded.
|
* Does nothing if the class could not be loaded.
|
||||||
*
|
*
|
||||||
* @param className class name to be loaded
|
* @param className class name to be loaded
|
||||||
* @return true if registration was successful
|
* @return true if registration was successful
|
||||||
*/
|
*/
|
||||||
public static boolean registerClassRegistry(String className) {
|
public static boolean registerClassRegistry(String className) {
|
||||||
return registerClassRegistry(className, null);
|
return registerClassRegistry(className, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers a class registry. Will attempt to resolve the given class name. Does nothing if the class could not be
|
* Registers a class registry. Will attempt to resolve the given class name.
|
||||||
* loaded.
|
* Does nothing if the class could not be loaded.
|
||||||
*
|
*
|
||||||
* @param className class name to be loaded
|
* @param className class name to be loaded
|
||||||
* @param description
|
* @param description
|
||||||
* @return true if registration was successful
|
* @return true if registration was successful
|
||||||
*/
|
*/
|
||||||
public static boolean registerClassRegistry(String className, String description) {
|
public static boolean registerClassRegistry(String className, String description) {
|
||||||
try {
|
try {
|
||||||
registerClassRegistry(Class.forName(className), description);
|
registerClassRegistry(Class.forName(className), description);
|
||||||
return true;
|
return true;
|
||||||
} catch (ClassNotFoundException ex) {
|
} catch (ClassNotFoundException ex) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers an annotated class. A class is annotated with either @ZenClass or @ZenExpansion. Classes not annotated
|
* Registers an annotated class. A class is annotated with either @ZenClass
|
||||||
* with either of these will be ignored.
|
* or @ZenExpansion. Classes not annotated with either of these will be
|
||||||
*
|
* ignored.
|
||||||
* @param annotatedClass
|
*
|
||||||
*/
|
* @param annotatedClass
|
||||||
public static void registerClass(Class annotatedClass) {
|
*/
|
||||||
// System.out.println("Registering " + annotatedClass.getName());
|
public static void registerClass(Class annotatedClass) {
|
||||||
|
// System.out.println("Registering " + annotatedClass.getName());
|
||||||
|
|
||||||
for (Annotation annotation : annotatedClass.getAnnotations()) {
|
for (Annotation annotation : annotatedClass.getAnnotations()) {
|
||||||
if (annotation instanceof ZenExpansion) {
|
if (annotation instanceof ZenExpansion) {
|
||||||
GlobalRegistry.registerExpansion(annotatedClass);
|
GlobalRegistry.registerExpansion(annotatedClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (annotation instanceof ZenClass) {
|
if (annotation instanceof ZenClass) {
|
||||||
GlobalRegistry.registerNativeClass(annotatedClass);
|
GlobalRegistry.registerNativeClass(annotatedClass);
|
||||||
}
|
}
|
||||||
if ((annotation instanceof BracketHandler) && IBracketHandler.class.isAssignableFrom(annotatedClass)) {
|
if ((annotation instanceof BracketHandler) && IBracketHandler.class.isAssignableFrom(annotatedClass)) {
|
||||||
try {
|
try {
|
||||||
IBracketHandler bracketHandler = (IBracketHandler) annotatedClass.newInstance();
|
IBracketHandler bracketHandler = (IBracketHandler) annotatedClass.newInstance();
|
||||||
registerBracketHandler(bracketHandler);
|
registerBracketHandler(bracketHandler);
|
||||||
} catch (InstantiationException ex) {
|
} catch (InstantiationException ex) {
|
||||||
Logger.getLogger(MineTweakerAPI.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(MineTweakerAPI.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
} catch (IllegalAccessException ex) {
|
} catch (IllegalAccessException ex) {
|
||||||
Logger.getLogger(MineTweakerAPI.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(MineTweakerAPI.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers a global symbol. Global symbols are immediately accessible from anywhere in the scripts.
|
* Registers a global symbol. Global symbols are immediately accessible from
|
||||||
*
|
* anywhere in the scripts.
|
||||||
* @param name symbol name
|
*
|
||||||
* @param symbol symbol
|
* @param name symbol name
|
||||||
*/
|
* @param symbol symbol
|
||||||
public static void registerGlobalSymbol(String name, IZenSymbol symbol) {
|
*/
|
||||||
GlobalRegistry.registerGlobal(name, symbol);
|
public static void registerGlobalSymbol(String name, IZenSymbol symbol) {
|
||||||
}
|
GlobalRegistry.registerGlobal(name, symbol);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers a recipe remover. Removers are called when the global minetweaker.remove() function is called.
|
* Registers a recipe remover. Removers are called when the global
|
||||||
*
|
* minetweaker.remove() function is called.
|
||||||
* @param remover recipe remover
|
*
|
||||||
*/
|
* @param remover recipe remover
|
||||||
public static void registerRemover(IRecipeRemover remover) {
|
*/
|
||||||
GlobalRegistry.registerRemover(remover);
|
public static void registerRemover(IRecipeRemover remover) {
|
||||||
}
|
GlobalRegistry.registerRemover(remover);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers a bracket handler. Is capable of converting the bracket syntax to an actual value. This new handler
|
* Registers a bracket handler. Is capable of converting the bracket syntax
|
||||||
* will be added last - it can thus not intercept values that are already handled by the system.
|
* to an actual value. This new handler will be added last - it can thus not
|
||||||
*
|
* intercept values that are already handled by the system.
|
||||||
* @param handler bracket handler to be added
|
*
|
||||||
*/
|
* @param handler bracket handler to be added
|
||||||
public static void registerBracketHandler(IBracketHandler handler) {
|
*/
|
||||||
GlobalRegistry.registerBracketHandler(handler);
|
public static void registerBracketHandler(IBracketHandler handler) {
|
||||||
}
|
GlobalRegistry.registerBracketHandler(handler);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a symbol that refers to a java method.
|
* Creates a symbol that refers to a java method.
|
||||||
*
|
*
|
||||||
* @param cls class that contains the method
|
* @param cls class that contains the method
|
||||||
* @param name method name
|
* @param name method name
|
||||||
* @param arguments method argument types
|
* @param arguments method argument types
|
||||||
* @return corresponding symbol
|
* @return corresponding symbol
|
||||||
*/
|
*/
|
||||||
public static IZenSymbol getJavaStaticMethodSymbol(Class cls, String name, Class... arguments) {
|
public static IZenSymbol getJavaStaticMethodSymbol(Class cls, String name, Class... arguments) {
|
||||||
IJavaMethod method = JavaMethod.get(GlobalRegistry.getTypeRegistry(), cls, name, arguments);
|
IJavaMethod method = JavaMethod.get(GlobalRegistry.getTypeRegistry(), cls, name, arguments);
|
||||||
return new SymbolJavaStaticMethod(method);
|
return new SymbolJavaStaticMethod(method);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a symbol that refers to a java getter. The getter must be a method with no arguments. The given symbol
|
* Creates a symbol that refers to a java getter. The getter must be a
|
||||||
* will act as a variable of which the value can be retrieved but not set.
|
* method with no arguments. The given symbol will act as a variable of
|
||||||
*
|
* which the value can be retrieved but not set.
|
||||||
* @param cls class that contains the getter method
|
*
|
||||||
* @param name name of the method
|
* @param cls class that contains the getter method
|
||||||
* @return corresponding symbol
|
* @param name name of the method
|
||||||
*/
|
* @return corresponding symbol
|
||||||
public static IZenSymbol getJavaStaticGetterSymbol(Class cls, String name) {
|
*/
|
||||||
IJavaMethod method = JavaMethod.get(GlobalRegistry.getTypeRegistry(), cls, name);
|
public static IZenSymbol getJavaStaticGetterSymbol(Class cls, String name) {
|
||||||
return new SymbolJavaStaticGetter(method);
|
IJavaMethod method = JavaMethod.get(GlobalRegistry.getTypeRegistry(), cls, name);
|
||||||
}
|
return new SymbolJavaStaticGetter(method);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a symbol that refers to a static field. The field must be an existing public field in the given class.
|
* Creates a symbol that refers to a static field. The field must be an
|
||||||
* The field will act as a variable that can be retrieved but not set.
|
* existing public field in the given class. The field will act as a
|
||||||
*
|
* variable that can be retrieved but not set.
|
||||||
* @param cls class that contains the field
|
*
|
||||||
* @param name field name (must be public)
|
* @param cls class that contains the field
|
||||||
* @return corresponding symbol
|
* @param name field name (must be public)
|
||||||
*/
|
* @return corresponding symbol
|
||||||
public static IZenSymbol getJavaStaticFieldSymbol(Class cls, String name) {
|
*/
|
||||||
try {
|
public static IZenSymbol getJavaStaticFieldSymbol(Class cls, String name) {
|
||||||
Field field = cls.getField(name);
|
try {
|
||||||
return new SymbolJavaStaticField(cls, field, GlobalRegistry.getTypeRegistry());
|
Field field = cls.getField(name);
|
||||||
} catch (NoSuchFieldException ex) {
|
return new SymbolJavaStaticField(cls, field, GlobalRegistry.getTypeRegistry());
|
||||||
return null;
|
} catch (NoSuchFieldException ex) {
|
||||||
} catch (SecurityException ex) {
|
return null;
|
||||||
return null;
|
} catch (SecurityException ex) {
|
||||||
}
|
return null;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Loads a Java method from an existing class.
|
|
||||||
*
|
|
||||||
* @param cls method class
|
|
||||||
* @param name method name
|
|
||||||
* @param arguments argument types
|
|
||||||
* @return java method
|
|
||||||
*/
|
|
||||||
public static IJavaMethod getJavaMethod(Class cls, String name, Class... arguments) {
|
|
||||||
return JavaMethod.get(GlobalRegistry.getTypeRegistry(), cls, name, arguments);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads a Java method from an existing class.
|
||||||
|
*
|
||||||
|
* @param cls method class
|
||||||
|
* @param name method name
|
||||||
|
* @param arguments argument types
|
||||||
|
* @return java method
|
||||||
|
*/
|
||||||
|
public static IJavaMethod getJavaMethod(Class cls, String name, Class... arguments) {
|
||||||
|
return JavaMethod.get(GlobalRegistry.getTypeRegistry(), cls, name, arguments);
|
||||||
|
}
|
||||||
|
|
||||||
public static IJEIRecipeRegistry getIjeiRecipeRegistry() {
|
public static IJEIRecipeRegistry getIjeiRecipeRegistry() {
|
||||||
return ijeiRecipeRegistry;
|
return ijeiRecipeRegistry;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setIjeiRecipeRegistry(IJEIRecipeRegistry ijeiRecipeRegistry) {
|
public static void setIjeiRecipeRegistry(IJEIRecipeRegistry ijeiRecipeRegistry) {
|
||||||
MineTweakerAPI.ijeiRecipeRegistry = ijeiRecipeRegistry;
|
MineTweakerAPI.ijeiRecipeRegistry = ijeiRecipeRegistry;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* To change this license header, choose License Headers in Project Properties. To change this template file, choose
|
* To change this license header, choose License Headers in Project Properties.
|
||||||
* Tools | Templates and open the template in the editor.
|
* To change this template file, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package minetweaker;
|
package minetweaker;
|
||||||
|
|||||||
File diff suppressed because it is too large.
Load diff
@@ -6,17 +6,17 @@ package minetweaker;
|
|||||||
* @author Stan Hebben
|
* @author Stan Hebben
|
||||||
*/
|
*/
|
||||||
public abstract class OneWayAction implements IUndoableAction {
|
public abstract class OneWayAction implements IUndoableAction {
|
||||||
|
@Override
|
||||||
|
public boolean canUndo() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canUndo() {
|
public void undo() {
|
||||||
return false;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void undo() {}
|
public String describeUndo() {
|
||||||
|
return "impossibru!";
|
||||||
@Override
|
}
|
||||||
public String describeUndo() {
|
|
||||||
return "impossibru!";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -6,20 +6,20 @@ import java.lang.annotation.RetentionPolicy;
|
|||||||
import java.lang.annotation.Target;
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Marks a bracket handler. Bracket handlers are automatically registered. The marked class should have an empty
|
* Marks a bracket handler. Bracket handlers are automatically registered. The
|
||||||
* constructor.
|
* marked class should have an empty constructor.
|
||||||
*
|
*
|
||||||
* @author Stan Hebben
|
* @author Stan Hebben
|
||||||
*/
|
*/
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Target({ ElementType.TYPE })
|
@Target({ ElementType.TYPE })
|
||||||
public @interface BracketHandler {
|
public @interface BracketHandler {
|
||||||
|
/**
|
||||||
/**
|
* Indicates priority. A lower value means a higher priority. Only change if
|
||||||
* Indicates priority. A lower value means a higher priority. Only change if you have issues, default value is 10.
|
* you have issues, default value is 10. Internal minetweaker handlers have
|
||||||
* Internal minetweaker handlers have priorities up to 100.
|
* priorities up to 100.
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public int priority() default 10;
|
public int priority() default 10;
|
||||||
}
|
}
|
||||||
@@ -6,15 +6,15 @@ import java.lang.annotation.RetentionPolicy;
|
|||||||
import java.lang.annotation.Target;
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates that a certain class is only available when a specific mod is available. Multiple mods can be specified.
|
* Indicates that a certain class is only available when a specific mod is
|
||||||
|
* available. Multiple mods can be specified.
|
||||||
*
|
*
|
||||||
* @author Stan Hebben
|
* @author Stan Hebben
|
||||||
*/
|
*/
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Target({ ElementType.TYPE, ElementType.METHOD })
|
@Target({ ElementType.TYPE, ElementType.METHOD })
|
||||||
public @interface ModOnly {
|
public @interface ModOnly {
|
||||||
|
public String[] value();
|
||||||
|
|
||||||
public String[] value();
|
public String version() default "";
|
||||||
|
|
||||||
public String version() default "";
|
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* To change this license header, choose License Headers in Project Properties. To change this template file, choose
|
* To change this license header, choose License Headers in Project Properties.
|
||||||
* Tools | Templates and open the template in the editor.
|
* To change this template file, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package minetweaker.annotations;
|
package minetweaker.annotations;
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package minetweaker.api.block;
|
package minetweaker.api.block;
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
import minetweaker.util.ArrayUtil;
|
import minetweaker.util.ArrayUtil;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Stan
|
* @author Stan
|
||||||
*/
|
*/
|
||||||
@@ -16,13 +16,13 @@ public class BlockPatternOr implements IBlockPattern {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public BlockPatternOr(IBlockPattern a, IBlockPattern b) {
|
public BlockPatternOr(IBlockPattern a, IBlockPattern b) {
|
||||||
this.elements = new IBlockPattern[] { a, b };
|
this.elements = new IBlockPattern[]{a, b};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<IBlock> getBlocks() {
|
public List<IBlock> getBlocks() {
|
||||||
List<IBlock> blocks = new ArrayList<>();
|
List<IBlock> blocks = new ArrayList<>();
|
||||||
for (IBlockPattern pattern : elements) {
|
for(IBlockPattern pattern : elements) {
|
||||||
blocks.addAll(pattern.getBlocks());
|
blocks.addAll(pattern.getBlocks());
|
||||||
}
|
}
|
||||||
return blocks;
|
return blocks;
|
||||||
@@ -30,8 +30,9 @@ public class BlockPatternOr implements IBlockPattern {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matches(IBlock block) {
|
public boolean matches(IBlock block) {
|
||||||
for (IBlockPattern pattern : elements) {
|
for(IBlockPattern pattern : elements) {
|
||||||
if (pattern.matches(block)) return true;
|
if(pattern.matches(block))
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@@ -41,8 +42,8 @@ public class BlockPatternOr implements IBlockPattern {
|
|||||||
public String getDisplayName() {
|
public String getDisplayName() {
|
||||||
StringBuilder result = new StringBuilder();
|
StringBuilder result = new StringBuilder();
|
||||||
boolean first = true;
|
boolean first = true;
|
||||||
for (IBlockPattern pattern : elements) {
|
for(IBlockPattern pattern : elements) {
|
||||||
if (first) {
|
if(first) {
|
||||||
first = false;
|
first = false;
|
||||||
} else {
|
} else {
|
||||||
result.append(" | ");
|
result.append(" | ");
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package minetweaker.api.block;
|
package minetweaker.api.block;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import stanhebben.zenscript.annotations.*;
|
import stanhebben.zenscript.annotations.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Stan
|
* @author Stan
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -3,14 +3,14 @@ package minetweaker.api.chat;
|
|||||||
import stanhebben.zenscript.annotations.*;
|
import stanhebben.zenscript.annotations.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a chat message. Strings can be converted into chat messages, and chat messages can be colored and
|
* Represents a chat message. Strings can be converted into chat messages, and
|
||||||
* concatenated.
|
* chat messages can be colored and concatenated.
|
||||||
*
|
*
|
||||||
* @author Stan Hebben
|
* @author Stan Hebben
|
||||||
*/
|
*/
|
||||||
@ZenClass("minetweaker.chat.IChatMessage")
|
@ZenClass("minetweaker.chat.IChatMessage")
|
||||||
public interface IChatMessage {
|
public interface IChatMessage {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Concatenates two chat messages.
|
* Concatenates two chat messages.
|
||||||
*
|
*
|
||||||
@@ -20,9 +20,10 @@ public interface IChatMessage {
|
|||||||
*/
|
*/
|
||||||
@ZenOperator(OperatorType.ADD)
|
@ZenOperator(OperatorType.ADD)
|
||||||
IChatMessage add(IChatMessage other);
|
IChatMessage add(IChatMessage other);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the internal object backing this object. Must be generated by the implementing platform.
|
* Retrieves the internal object backing this object. Must be generated by
|
||||||
|
* the implementing platform.
|
||||||
*
|
*
|
||||||
* @return internal object
|
* @return internal object
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import stanhebben.zenscript.annotations.*;
|
|||||||
*/
|
*/
|
||||||
@ZenClass("minetweaker.api.IClient")
|
@ZenClass("minetweaker.api.IClient")
|
||||||
public interface IClient {
|
public interface IClient {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the current player.
|
* Gets the current player.
|
||||||
*
|
*
|
||||||
@@ -18,7 +18,7 @@ public interface IClient {
|
|||||||
*/
|
*/
|
||||||
@ZenGetter("player")
|
@ZenGetter("player")
|
||||||
IPlayer getPlayer();
|
IPlayer getPlayer();
|
||||||
|
|
||||||
@ZenGetter("language")
|
@ZenGetter("language")
|
||||||
String getLanguage();
|
String getLanguage();
|
||||||
}
|
}
|
||||||
@@ -1,41 +1,45 @@
|
|||||||
package minetweaker.api.compat;
|
package minetweaker.api.compat;
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
import minetweaker.api.item.IIngredient;
|
import minetweaker.api.item.IIngredient;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
public class DummyJEIRecipeRegistry implements IJEIRecipeRegistry {
|
public class DummyJEIRecipeRegistry implements IJEIRecipeRegistry {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addRecipe(Object object) {}
|
public void addRecipe(Object object) {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addRecipe(Object object, String category) {
|
public void addRecipe(Object object, String category) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeRecipe(Object object) {}
|
public void removeRecipe(Object object) {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeRecipe(Object output, String category) {
|
public void removeRecipe(Object output, String category) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addFurnace(List<Object> inputs, Object output) {}
|
public void addFurnace(List<Object> inputs, Object output) {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeFurnace(Object object) {}
|
public void removeFurnace(Object object) {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addFuel(Collection<Object> input, int burnTime) {
|
public void addFuel(Collection<Object> input, int burnTime) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeFuel(Object object) {
|
public void removeFuel(Object object) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,33 +1,34 @@
|
|||||||
package minetweaker.api.compat;
|
package minetweaker.api.compat;
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
import minetweaker.api.item.IIngredient;
|
import minetweaker.api.item.IIngredient;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
public interface IJEIRecipeRegistry {
|
public interface IJEIRecipeRegistry {
|
||||||
|
|
||||||
void addRecipe(Object object);
|
void addRecipe(Object object);
|
||||||
|
|
||||||
void addRecipe(Object object, String category);
|
void addRecipe(Object object, String category);
|
||||||
|
|
||||||
void removeRecipe(Object output);
|
void removeRecipe(Object output);
|
||||||
|
|
||||||
void removeRecipe(Object output, String category);
|
void removeRecipe(Object output, String category);
|
||||||
|
|
||||||
|
|
||||||
void addFurnace(List<Object> inputs, Object output);
|
void addFurnace(List<Object> inputs, Object output);
|
||||||
|
|
||||||
void removeFurnace(Object output);
|
void removeFurnace(Object output);
|
||||||
|
|
||||||
void addFuel(Collection<Object> input, int burnTime);
|
void addFuel(Collection<Object> input, int burnTime);
|
||||||
|
|
||||||
void removeFuel(Object object);
|
void removeFuel(Object object);
|
||||||
|
|
||||||
void invalidateTooltips(IIngredient ingredient);
|
void invalidateTooltips(IIngredient ingredient);
|
||||||
|
|
||||||
// To update the items in 1.10.2
|
//To update the items in 1.10.2
|
||||||
void reloadItemList();
|
void reloadItemList();
|
||||||
|
|
||||||
// To update the items in 1.11.2 both below are used
|
//To update the items in 1.11.2 both below are used
|
||||||
void removeItem(Object stack);
|
void removeItem(Object stack);
|
||||||
|
|
||||||
void addItem(Object stack);
|
void addItem(Object stack);
|
||||||
|
|||||||
@@ -20,7 +20,8 @@ public interface IContainer extends Iterable<IItemStack> {
|
|||||||
int getContainerSize();
|
int getContainerSize();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the item stack at the given position. Returns null if there is no stack at that position.
|
* Gets the item stack at the given position. Returns null if there is no
|
||||||
|
* stack at that position.
|
||||||
*
|
*
|
||||||
* @param i stack position
|
* @param i stack position
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -110,9 +110,11 @@ public class DataByteArray implements IData {
|
|||||||
StringBuilder result = new StringBuilder();
|
StringBuilder result = new StringBuilder();
|
||||||
result.append("[");
|
result.append("[");
|
||||||
boolean first = true;
|
boolean first = true;
|
||||||
for (byte value : data) {
|
for(byte value : data) {
|
||||||
if (first) first = false;
|
if(first)
|
||||||
else result.append(", ");
|
first = false;
|
||||||
|
else
|
||||||
|
result.append(", ");
|
||||||
|
|
||||||
result.append(value);
|
result.append(value);
|
||||||
}
|
}
|
||||||
@@ -123,7 +125,7 @@ public class DataByteArray implements IData {
|
|||||||
@Override
|
@Override
|
||||||
public List<IData> asList() {
|
public List<IData> asList() {
|
||||||
List<IData> result = new ArrayList<IData>();
|
List<IData> result = new ArrayList<IData>();
|
||||||
for (byte value : data) {
|
for(byte value : data) {
|
||||||
result.add(new DataByte(value));
|
result.add(new DataByte(value));
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@@ -142,7 +144,7 @@ public class DataByteArray implements IData {
|
|||||||
@Override
|
@Override
|
||||||
public int[] asIntArray() {
|
public int[] asIntArray() {
|
||||||
int[] result = new int[data.length];
|
int[] result = new int[data.length];
|
||||||
for (int i = 0; i < result.length; i++) {
|
for(int i = 0; i < result.length; i++) {
|
||||||
result[i] = data[i];
|
result[i] = data[i];
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@@ -155,7 +157,7 @@ public class DataByteArray implements IData {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setAt(int i, IData value) {
|
public void setAt(int i, IData value) {
|
||||||
if (immutable) {
|
if(immutable) {
|
||||||
throw new UnsupportedOperationException("Cannot modify this byte array");
|
throw new UnsupportedOperationException("Cannot modify this byte array");
|
||||||
} else {
|
} else {
|
||||||
data[i] = value.asByte();
|
data[i] = value.asByte();
|
||||||
@@ -194,7 +196,7 @@ public class DataByteArray implements IData {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IData immutable() {
|
public IData immutable() {
|
||||||
if (immutable) {
|
if(immutable) {
|
||||||
return this;
|
return this;
|
||||||
} else {
|
} else {
|
||||||
return new DataByteArray(Arrays.copyOf(this.data, this.data.length), true);
|
return new DataByteArray(Arrays.copyOf(this.data, this.data.length), true);
|
||||||
|
|||||||
@@ -110,8 +110,8 @@ public class DataIntArray implements IData {
|
|||||||
StringBuilder result = new StringBuilder();
|
StringBuilder result = new StringBuilder();
|
||||||
result.append('[');
|
result.append('[');
|
||||||
boolean first = true;
|
boolean first = true;
|
||||||
for (int value : data) {
|
for(int value : data) {
|
||||||
if (first) {
|
if(first) {
|
||||||
first = false;
|
first = false;
|
||||||
} else {
|
} else {
|
||||||
result.append(", ");
|
result.append(", ");
|
||||||
@@ -125,7 +125,7 @@ public class DataIntArray implements IData {
|
|||||||
@Override
|
@Override
|
||||||
public List<IData> asList() {
|
public List<IData> asList() {
|
||||||
List<IData> result = new ArrayList<>();
|
List<IData> result = new ArrayList<>();
|
||||||
for (int value : data) {
|
for(int value : data) {
|
||||||
result.add(new DataInt(value));
|
result.add(new DataInt(value));
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@@ -139,7 +139,7 @@ public class DataIntArray implements IData {
|
|||||||
@Override
|
@Override
|
||||||
public byte[] asByteArray() {
|
public byte[] asByteArray() {
|
||||||
byte[] result = new byte[data.length];
|
byte[] result = new byte[data.length];
|
||||||
for (int i = 0; i < result.length; i++) {
|
for(int i = 0; i < result.length; i++) {
|
||||||
result[i] = (byte) data[i];
|
result[i] = (byte) data[i];
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@@ -157,7 +157,7 @@ public class DataIntArray implements IData {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setAt(int i, IData value) {
|
public void setAt(int i, IData value) {
|
||||||
if (immutable) {
|
if(immutable) {
|
||||||
throw new UnsupportedOperationException("Cannot modify this byte array");
|
throw new UnsupportedOperationException("Cannot modify this byte array");
|
||||||
} else {
|
} else {
|
||||||
data[i] = value.asInt();
|
data[i] = value.asInt();
|
||||||
@@ -196,7 +196,7 @@ public class DataIntArray implements IData {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IData immutable() {
|
public IData immutable() {
|
||||||
if (immutable) {
|
if(immutable) {
|
||||||
return this;
|
return this;
|
||||||
} else {
|
} else {
|
||||||
return new DataIntArray(Arrays.copyOf(this.data, this.data.length), true);
|
return new DataIntArray(Arrays.copyOf(this.data, this.data.length), true);
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ public class DataList implements IData {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<IData> asList() {
|
public List<IData> asList() {
|
||||||
if (immutable) {
|
if(immutable) {
|
||||||
return Collections.unmodifiableList(values);
|
return Collections.unmodifiableList(values);
|
||||||
} else {
|
} else {
|
||||||
return values;
|
return values;
|
||||||
@@ -71,8 +71,8 @@ public class DataList implements IData {
|
|||||||
StringBuilder output = new StringBuilder();
|
StringBuilder output = new StringBuilder();
|
||||||
output.append('[');
|
output.append('[');
|
||||||
boolean first = true;
|
boolean first = true;
|
||||||
for (IData value : values) {
|
for(IData value : values) {
|
||||||
if (first) {
|
if(first) {
|
||||||
first = false;
|
first = false;
|
||||||
} else {
|
} else {
|
||||||
output.append(", ");
|
output.append(", ");
|
||||||
@@ -87,11 +87,11 @@ public class DataList implements IData {
|
|||||||
public byte[] asByteArray() {
|
public byte[] asByteArray() {
|
||||||
try {
|
try {
|
||||||
byte[] result = new byte[values.size()];
|
byte[] result = new byte[values.size()];
|
||||||
for (int i = 0; i < values.size(); i++) {
|
for(int i = 0; i < values.size(); i++) {
|
||||||
result[i] = values.get(i).asByte();
|
result[i] = values.get(i).asByte();
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
} catch (IllegalDataException ex) {
|
} catch(IllegalDataException ex) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -100,11 +100,11 @@ public class DataList implements IData {
|
|||||||
public int[] asIntArray() {
|
public int[] asIntArray() {
|
||||||
try {
|
try {
|
||||||
int[] result = new int[values.size()];
|
int[] result = new int[values.size()];
|
||||||
for (int i = 0; i < values.size(); i++) {
|
for(int i = 0; i < values.size(); i++) {
|
||||||
result[i] = values.get(i).asInt();
|
result[i] = values.get(i).asInt();
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
} catch (IllegalDataException ex) {
|
} catch(IllegalDataException ex) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -116,7 +116,7 @@ public class DataList implements IData {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setAt(int i, IData value) {
|
public void setAt(int i, IData value) {
|
||||||
if (immutable) {
|
if(immutable) {
|
||||||
throw new UnsupportedOperationException("this list is immutable");
|
throw new UnsupportedOperationException("this list is immutable");
|
||||||
} else {
|
} else {
|
||||||
values.set(i, value);
|
values.set(i, value);
|
||||||
@@ -141,19 +141,23 @@ public class DataList implements IData {
|
|||||||
@Override
|
@Override
|
||||||
public boolean contains(IData data) {
|
public boolean contains(IData data) {
|
||||||
List<IData> dataValues = data.asList();
|
List<IData> dataValues = data.asList();
|
||||||
if (dataValues != null && containsList(dataValues)) return true;
|
if(dataValues != null && containsList(dataValues))
|
||||||
|
return true;
|
||||||
|
|
||||||
for (IData value : values) {
|
for(IData value : values) {
|
||||||
if (value.contains(data)) return true;
|
if(value.contains(data))
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean containsList(List<IData> dataValues) {
|
private boolean containsList(List<IData> dataValues) {
|
||||||
outer: for (IData dataValue : dataValues) {
|
outer:
|
||||||
for (IData value : values) {
|
for(IData dataValue : dataValues) {
|
||||||
if (value.contains(dataValue)) continue outer;
|
for(IData value : values) {
|
||||||
|
if(value.contains(dataValue))
|
||||||
|
continue outer;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@@ -165,10 +169,12 @@ public class DataList implements IData {
|
|||||||
@Override
|
@Override
|
||||||
public boolean equals(IData data) {
|
public boolean equals(IData data) {
|
||||||
List<IData> otherValues = data.asList();
|
List<IData> otherValues = data.asList();
|
||||||
if (otherValues.size() != values.size()) return false;
|
if(otherValues.size() != values.size())
|
||||||
|
return false;
|
||||||
|
|
||||||
for (int i = 0; i < values.size(); i++) {
|
for(int i = 0; i < values.size(); i++) {
|
||||||
if (!values.get(i).equals(otherValues.get(i))) return false;
|
if(!values.get(i).equals(otherValues.get(i)))
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -181,11 +187,11 @@ public class DataList implements IData {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IData immutable() {
|
public IData immutable() {
|
||||||
if (immutable) {
|
if(immutable) {
|
||||||
return this;
|
return this;
|
||||||
} else {
|
} else {
|
||||||
List<IData> copy = new ArrayList<>();
|
List<IData> copy = new ArrayList<>();
|
||||||
for (IData value : values) {
|
for(IData value : values) {
|
||||||
copy.add(value.immutable());
|
copy.add(value.immutable());
|
||||||
}
|
}
|
||||||
return new DataList(copy, true);
|
return new DataList(copy, true);
|
||||||
@@ -194,7 +200,8 @@ public class DataList implements IData {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IData update(IData data) {
|
public IData update(IData data) {
|
||||||
if (immutable) data = data.immutable();
|
if(immutable)
|
||||||
|
data = data.immutable();
|
||||||
|
|
||||||
List<IData> result = new ArrayList<>();
|
List<IData> result = new ArrayList<>();
|
||||||
result.addAll(values);
|
result.addAll(values);
|
||||||
|
|||||||
@@ -24,10 +24,10 @@ public class DataMap implements IData {
|
|||||||
Map<String, IData> result = new HashMap<>();
|
Map<String, IData> result = new HashMap<>();
|
||||||
Map<String, IData> otherMap = other.asMap();
|
Map<String, IData> otherMap = other.asMap();
|
||||||
|
|
||||||
for (Map.Entry<String, IData> entry : data.entrySet()) {
|
for(Map.Entry<String, IData> entry : data.entrySet()) {
|
||||||
result.put(entry.getKey(), entry.getValue());
|
result.put(entry.getKey(), entry.getValue());
|
||||||
}
|
}
|
||||||
for (Map.Entry<String, IData> entry : otherMap.entrySet()) {
|
for(Map.Entry<String, IData> entry : otherMap.entrySet()) {
|
||||||
result.put(entry.getKey(), entry.getValue());
|
result.put(entry.getKey(), entry.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -39,10 +39,10 @@ public class DataMap implements IData {
|
|||||||
Map<String, IData> result = new HashMap<>();
|
Map<String, IData> result = new HashMap<>();
|
||||||
Map<String, IData> otherMap = other.asMap();
|
Map<String, IData> otherMap = other.asMap();
|
||||||
|
|
||||||
for (Map.Entry<String, IData> entry : data.entrySet()) {
|
for(Map.Entry<String, IData> entry : data.entrySet()) {
|
||||||
result.put(entry.getKey(), entry.getValue());
|
result.put(entry.getKey(), entry.getValue());
|
||||||
}
|
}
|
||||||
for (String key : otherMap.keySet()) {
|
for(String key : otherMap.keySet()) {
|
||||||
result.remove(key);
|
result.remove(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,14 +129,14 @@ public class DataMap implements IData {
|
|||||||
StringBuilder result = new StringBuilder();
|
StringBuilder result = new StringBuilder();
|
||||||
result.append('{');
|
result.append('{');
|
||||||
boolean first = true;
|
boolean first = true;
|
||||||
for (Map.Entry<String, IData> entry : data.entrySet()) {
|
for(Map.Entry<String, IData> entry : data.entrySet()) {
|
||||||
if (first) {
|
if(first) {
|
||||||
first = false;
|
first = false;
|
||||||
} else {
|
} else {
|
||||||
result.append(", ");
|
result.append(", ");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isValidIdentifier(entry.getKey())) {
|
if(isValidIdentifier(entry.getKey())) {
|
||||||
result.append(entry.getKey());
|
result.append(entry.getKey());
|
||||||
} else {
|
} else {
|
||||||
result.append("\"").append(entry.getKey()).append("\"");
|
result.append("\"").append(entry.getKey()).append("\"");
|
||||||
@@ -156,7 +156,7 @@ public class DataMap implements IData {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, IData> asMap() {
|
public Map<String, IData> asMap() {
|
||||||
if (immutable) {
|
if(immutable) {
|
||||||
return Collections.unmodifiableMap(data);
|
return Collections.unmodifiableMap(data);
|
||||||
} else {
|
} else {
|
||||||
return data;
|
return data;
|
||||||
@@ -190,7 +190,7 @@ public class DataMap implements IData {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void memberSet(String name, IData data) {
|
public void memberSet(String name, IData data) {
|
||||||
if (immutable) {
|
if(immutable) {
|
||||||
throw new UnsupportedOperationException("this map is not modifiable");
|
throw new UnsupportedOperationException("this map is not modifiable");
|
||||||
} else {
|
} else {
|
||||||
this.data.put(name, data);
|
this.data.put(name, data);
|
||||||
@@ -204,17 +204,18 @@ public class DataMap implements IData {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean contains(IData data) {
|
public boolean contains(IData data) {
|
||||||
if (data instanceof DataString) {
|
if(data instanceof DataString) {
|
||||||
return this.data.containsKey(data.asString());
|
return this.data.containsKey(data.asString());
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, IData> dataMap = data.asMap();
|
Map<String, IData> dataMap = data.asMap();
|
||||||
if (dataMap == null) return false;
|
if(dataMap == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
for (Map.Entry<String, IData> dataEntry : dataMap.entrySet()) {
|
for(Map.Entry<String, IData> dataEntry : dataMap.entrySet()) {
|
||||||
if (!this.data.containsKey(dataEntry.getKey())) {
|
if(!this.data.containsKey(dataEntry.getKey())) {
|
||||||
return false;
|
return false;
|
||||||
} else if (!this.data.get(dataEntry.getKey()).contains(dataEntry.getValue())) {
|
} else if(!this.data.get(dataEntry.getKey()).contains(dataEntry.getValue())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -229,15 +230,17 @@ public class DataMap implements IData {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(IData data) {
|
public boolean equals(IData data) {
|
||||||
if (this == data) return true;
|
if(this == data)
|
||||||
|
return true;
|
||||||
|
|
||||||
Map<String, IData> dataMap = data.asMap();
|
Map<String, IData> dataMap = data.asMap();
|
||||||
if (dataMap.size() != this.data.size()) return false;
|
if(dataMap.size() != this.data.size())
|
||||||
|
return false;
|
||||||
|
|
||||||
for (Map.Entry<String, IData> dataEntry : this.data.entrySet()) {
|
for(Map.Entry<String, IData> dataEntry : this.data.entrySet()) {
|
||||||
if (!dataMap.containsKey(dataEntry.getKey())) {
|
if(!dataMap.containsKey(dataEntry.getKey())) {
|
||||||
return false;
|
return false;
|
||||||
} else if (!dataMap.get(dataEntry.getKey()).equals(dataEntry.getValue())) {
|
} else if(!dataMap.get(dataEntry.getKey()).equals(dataEntry.getValue())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -247,11 +250,11 @@ public class DataMap implements IData {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IData immutable() {
|
public IData immutable() {
|
||||||
if (immutable) {
|
if(immutable) {
|
||||||
return this;
|
return this;
|
||||||
} else {
|
} else {
|
||||||
Map<String, IData> result = new HashMap<>();
|
Map<String, IData> result = new HashMap<>();
|
||||||
for (Map.Entry<String, IData> entry : this.data.entrySet()) {
|
for(Map.Entry<String, IData> entry : this.data.entrySet()) {
|
||||||
result.put(entry.getKey(), entry.getValue().immutable());
|
result.put(entry.getKey(), entry.getValue().immutable());
|
||||||
}
|
}
|
||||||
return new DataMap(result, true);
|
return new DataMap(result, true);
|
||||||
@@ -260,13 +263,14 @@ public class DataMap implements IData {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IData update(IData data) {
|
public IData update(IData data) {
|
||||||
if (immutable) data = data.immutable();
|
if(immutable)
|
||||||
|
data = data.immutable();
|
||||||
|
|
||||||
Map<String, IData> result = new HashMap<>();
|
Map<String, IData> result = new HashMap<>();
|
||||||
for (Map.Entry<String, IData> entry : this.data.entrySet()) {
|
for(Map.Entry<String, IData> entry : this.data.entrySet()) {
|
||||||
result.put(entry.getKey(), entry.getValue());
|
result.put(entry.getKey(), entry.getValue());
|
||||||
}
|
}
|
||||||
for (Map.Entry<String, IData> entry : data.asMap().entrySet()) {
|
for(Map.Entry<String, IData> entry : data.asMap().entrySet()) {
|
||||||
result.put(entry.getKey(), entry.getValue());
|
result.put(entry.getKey(), entry.getValue());
|
||||||
}
|
}
|
||||||
return new DataMap(result, immutable);
|
return new DataMap(result, immutable);
|
||||||
@@ -283,10 +287,12 @@ public class DataMap implements IData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean isValidIdentifier(String str) {
|
private boolean isValidIdentifier(String str) {
|
||||||
if (!Character.isJavaIdentifierStart(str.charAt(0))) return false;
|
if(!Character.isJavaIdentifierStart(str.charAt(0)))
|
||||||
|
return false;
|
||||||
|
|
||||||
for (int i = 1; i < str.length(); i++) {
|
for(int i = 1; i < str.length(); i++) {
|
||||||
if (!Character.isJavaIdentifierPart(str.charAt(i))) return false;
|
if(!Character.isJavaIdentifierPart(str.charAt(i)))
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ public class DataString implements IData {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IData memberGet(String name) {
|
public IData memberGet(String name) {
|
||||||
if (name.equals("length")) {
|
if(name.equals("length")) {
|
||||||
return new DataInt(value.length());
|
return new DataInt(value.length());
|
||||||
} else {
|
} else {
|
||||||
throw new UnsupportedOperationException("no such member: " + name);
|
throw new UnsupportedOperationException("no such member: " + name);
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
package minetweaker.api.data;
|
package minetweaker.api.data;
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
import stanhebben.zenscript.annotations.*;
|
import stanhebben.zenscript.annotations.*;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generic data interface. A data element may contain any kind of basic data element (bool, byte, short, int, long,
|
* Generic data interface. A data element may contain any kind of basic data
|
||||||
* float, double, string, list, map, int array or byte array). Used to store data with stacks, blocks, world, ...
|
* element (bool, byte, short, int, long, float, double, string, list, map, int
|
||||||
|
* array or byte array). Used to store data with stacks, blocks, world, ...
|
||||||
*
|
*
|
||||||
* @author Stan Hebben
|
* @author Stan Hebben
|
||||||
*/
|
*/
|
||||||
@@ -68,7 +69,8 @@ public interface IData {
|
|||||||
String asString();
|
String asString();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempts to convert this value to a List. Returns null if this value cannot be converted to a list.
|
* Attempts to convert this value to a List. Returns null if this value
|
||||||
|
* cannot be converted to a list.
|
||||||
*
|
*
|
||||||
* @return list data of this value, if any
|
* @return list data of this value, if any
|
||||||
*/
|
*/
|
||||||
@@ -76,7 +78,8 @@ public interface IData {
|
|||||||
List<IData> asList();
|
List<IData> asList();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempts to convert this value to a Map. Returns null if this value cannot be converted to a map.
|
* Attempts to convert this value to a Map. Returns null if this value
|
||||||
|
* cannot be converted to a map.
|
||||||
*
|
*
|
||||||
* @return map data of this value, if any
|
* @return map data of this value, if any
|
||||||
*/
|
*/
|
||||||
@@ -84,7 +87,8 @@ public interface IData {
|
|||||||
Map<String, IData> asMap();
|
Map<String, IData> asMap();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempts to convert this value to a byte array. Returns null if this value cannot be converted to a byte array.
|
* Attempts to convert this value to a byte array. Returns null if this
|
||||||
|
* value cannot be converted to a byte array.
|
||||||
*
|
*
|
||||||
* @return byte array data of this value, if any
|
* @return byte array data of this value, if any
|
||||||
*/
|
*/
|
||||||
@@ -92,7 +96,8 @@ public interface IData {
|
|||||||
byte[] asByteArray();
|
byte[] asByteArray();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempts to convert this value to an int array. Returns null if this value cannot be converted to an int array.
|
* Attempts to convert this value to an int array. Returns null if this
|
||||||
|
* value cannot be converted to an int array.
|
||||||
*
|
*
|
||||||
* @return int array data of this value, if any
|
* @return int array data of this value, if any
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* This file is part of MineTweaker API, licensed under the MIT License (MIT). Copyright (c) 2014 MineTweaker
|
* This file is part of MineTweaker API, licensed under the MIT License (MIT).
|
||||||
* <http://minetweaker3.powerofbytes.com>
|
*
|
||||||
|
* Copyright (c) 2014 MineTweaker <http://minetweaker3.powerofbytes.com>
|
||||||
*/
|
*/
|
||||||
package minetweaker.api.data;
|
package minetweaker.api.data;
|
||||||
|
|
||||||
|
|||||||
@@ -5,8 +5,9 @@ import minetweaker.api.world.IDimension;
|
|||||||
import stanhebben.zenscript.annotations.*;
|
import stanhebben.zenscript.annotations.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Entity interface. Used to obtain information about entities, and modify their data. Entities are any item that is
|
* Entity interface. Used to obtain information about entities, and modify their
|
||||||
* freely movable in the world, such as players, monsters, items on the ground, ...
|
* data. Entities are any item that is freely movable in the world, such as
|
||||||
|
* players, monsters, items on the ground, ...
|
||||||
*
|
*
|
||||||
* @author Stan Hebben
|
* @author Stan Hebben
|
||||||
*/
|
*/
|
||||||
@@ -54,7 +55,8 @@ public interface IEntity {
|
|||||||
Position3f getPosition();
|
Position3f getPosition();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the position of this entity. Instantly moves (teleports) the entity to that position.
|
* Sets the position of this entity. Instantly moves (teleports) the entity
|
||||||
|
* to that position.
|
||||||
*
|
*
|
||||||
* @param position entity position
|
* @param position entity position
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,37 +1,38 @@
|
|||||||
package minetweaker.api.entity;
|
package minetweaker.api.entity;
|
||||||
|
|
||||||
|
import minetweaker.api.item.IItemStack;
|
||||||
|
import stanhebben.zenscript.annotations.Optional;
|
||||||
|
import stanhebben.zenscript.annotations.*;
|
||||||
|
import stanhebben.zenscript.value.*;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import minetweaker.api.item.IItemStack;
|
|
||||||
import stanhebben.zenscript.annotations.*;
|
|
||||||
import stanhebben.zenscript.annotations.Optional;
|
|
||||||
import stanhebben.zenscript.value.*;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Stan Hebben
|
* @author Stan Hebben
|
||||||
*/
|
*/
|
||||||
@ZenClass("minetweaker.entity.IEntityDefinition")
|
@ZenClass("minetweaker.entity.IEntityDefinition")
|
||||||
public interface IEntityDefinition {
|
public interface IEntityDefinition {
|
||||||
|
|
||||||
@ZenGetter("id")
|
@ZenGetter("id")
|
||||||
String getId();
|
String getId();
|
||||||
|
|
||||||
@ZenGetter("name")
|
@ZenGetter("name")
|
||||||
String getName();
|
String getName();
|
||||||
|
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
void addDrop(IItemStack stack, @Optional int min, @Optional int max);
|
void addDrop(IItemStack stack, @Optional int min, @Optional int max);
|
||||||
|
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
void addPlayerOnlyDrop(IItemStack stack, @Optional int min, @Optional int max);
|
void addPlayerOnlyDrop(IItemStack stack, @Optional int min, @Optional int max);
|
||||||
|
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
void removeDrop(IItemStack stack);
|
void removeDrop(IItemStack stack);
|
||||||
|
|
||||||
Map<IItemStack, IntRange> getDropsToAdd();
|
Map<IItemStack, IntRange> getDropsToAdd();
|
||||||
|
|
||||||
Map<IItemStack, IntRange> getDropsToAddPlayerOnly();
|
Map<IItemStack, IntRange> getDropsToAddPlayerOnly();
|
||||||
|
|
||||||
List<IItemStack> getDropsToRemove();
|
List<IItemStack> getDropsToRemove();
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -4,8 +4,8 @@ import minetweaker.api.item.IItemStack;
|
|||||||
import stanhebben.zenscript.annotations.ZenGetter;
|
import stanhebben.zenscript.annotations.ZenGetter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents an item entity. Item entities are entities representing an item stack on the ground (or flying through the
|
* Represents an item entity. Item entities are entities representing an item
|
||||||
* air).
|
* stack on the ground (or flying through the air).
|
||||||
*
|
*
|
||||||
* @author Stan Hebben
|
* @author Stan Hebben
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package minetweaker.api.event;
|
package minetweaker.api.event;
|
||||||
|
|
||||||
import java.io.Closeable;
|
|
||||||
|
|
||||||
import stanhebben.zenscript.annotations.*;
|
import stanhebben.zenscript.annotations.*;
|
||||||
|
|
||||||
|
import java.io.Closeable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents an event handle. Event handles are used to cancel event listeners.
|
* Represents an event handle. Event handles are used to cancel event listeners.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -10,58 +10,88 @@ import minetweaker.util.IEventHandler;
|
|||||||
* @author Stan
|
* @author Stan
|
||||||
*/
|
*/
|
||||||
public interface IEventManager {
|
public interface IEventManager {
|
||||||
|
|
||||||
// implemented
|
// implemented
|
||||||
IEventHandle onPlayerCrafted(IEventHandler<PlayerCraftedEvent> ev);
|
IEventHandle onPlayerCrafted(IEventHandler<PlayerCraftedEvent> ev);
|
||||||
|
|
||||||
// implemented
|
// implemented
|
||||||
IEventHandle onPlayerSmelted(IEventHandler<PlayerSmeltedEvent> ev);
|
IEventHandle onPlayerSmelted(IEventHandler<PlayerSmeltedEvent> ev);
|
||||||
|
|
||||||
IEventHandle onPlayerChangedDimension(IEventHandler<PlayerChangedDimensionEvent> ev);
|
IEventHandle onPlayerChangedDimension(IEventHandler<PlayerChangedDimensionEvent> ev);
|
||||||
|
|
||||||
IEventHandle onPlayerRespawn(IEventHandler<PlayerRespawnEvent> ev);
|
IEventHandle onPlayerRespawn(IEventHandler<PlayerRespawnEvent> ev);
|
||||||
|
|
||||||
IEventHandle onPlayerAttackEntity(IEventHandler<PlayerAttackEntityEvent> ev);
|
IEventHandle onPlayerAttackEntity(IEventHandler<PlayerAttackEntityEvent> ev);
|
||||||
|
|
||||||
IEventHandle onPlayerBonemeal(IEventHandler<PlayerBonemealEvent> ev);
|
IEventHandle onPlayerBonemeal(IEventHandler<PlayerBonemealEvent> ev);
|
||||||
|
|
||||||
IEventHandle onPlayerInteractEntity(IEventHandler<PlayerInteractEntityEvent> ev);
|
IEventHandle onPlayerInteractEntity(IEventHandler<PlayerInteractEntityEvent> ev);
|
||||||
|
|
||||||
IEventHandle onPlayerPickup(IEventHandler<PlayerPickupEvent> ev);
|
IEventHandle onPlayerPickup(IEventHandler<PlayerPickupEvent> ev);
|
||||||
|
|
||||||
IEventHandle onPlayerPickupItem(IEventHandler<PlayerPickupItemEvent> ev);
|
IEventHandle onPlayerPickupItem(IEventHandler<PlayerPickupItemEvent> ev);
|
||||||
|
|
||||||
IEventHandle onPlayerFillBucket(IEventHandler<PlayerFillBucketEvent> ev);
|
IEventHandle onPlayerFillBucket(IEventHandler<PlayerFillBucketEvent> ev);
|
||||||
|
|
||||||
IEventHandle onPlayerDeathDrops(IEventHandler<PlayerDeathDropsEvent> ev);
|
IEventHandle onPlayerDeathDrops(IEventHandler<PlayerDeathDropsEvent> ev);
|
||||||
|
|
||||||
IEventHandle onPlayerInteract(IEventHandler<PlayerInteractEvent> ev);
|
IEventHandle onPlayerInteract(IEventHandler<PlayerInteractEvent> ev);
|
||||||
|
|
||||||
IEventHandle onPlayerOpenContainer(IEventHandler<PlayerOpenContainerEvent> ev);
|
IEventHandle onPlayerOpenContainer(IEventHandler<PlayerOpenContainerEvent> ev);
|
||||||
|
|
||||||
IEventHandle onPlayerPickupXp(IEventHandler<PlayerPickupXpEvent> ev);
|
IEventHandle onPlayerPickupXp(IEventHandler<PlayerPickupXpEvent> ev);
|
||||||
|
|
||||||
IEventHandle onPlayerSleepInBed(IEventHandler<PlayerSleepInBedEvent> ev);
|
IEventHandle onPlayerSleepInBed(IEventHandler<PlayerSleepInBedEvent> ev);
|
||||||
|
|
||||||
IEventHandle onPlayerUseHoe(IEventHandler<PlayerUseHoeEvent> ev);
|
IEventHandle onPlayerUseHoe(IEventHandler<PlayerUseHoeEvent> ev);
|
||||||
|
|
||||||
IEventHandle onPlayerUseItemStart(IEventHandler<PlayerUseItemStartEvent> ev);
|
IEventHandle onPlayerUseItemStart(IEventHandler<PlayerUseItemStartEvent> ev);
|
||||||
|
|
||||||
IEventHandle onPlayerUseItemTick(IEventHandler<PlayerUseItemTickEvent> ev);
|
IEventHandle onPlayerUseItemTick(IEventHandler<PlayerUseItemTickEvent> ev);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* IEventHandle onPlayerUseItemStop(IEventHandler<PlayerUseItemStopEvent> ev); IEventHandle
|
* IEventHandle
|
||||||
* onPlayerUseItemFinish(IPlayerUserItemFinishEventHandler ev); IEventHandle onPlayerChat(IPlayerChatEventHandler
|
* onPlayerUseItemStop(IEventHandler<PlayerUseItemStopEvent> ev);
|
||||||
* ev); IEventHandle onTimerSingle(int millis, ITimerEventHandler ev); IEventHandle onTimerRepeat(int millis,
|
*
|
||||||
* ITimerEventHandler ev); IEventHandle onEntityJoinWorld(IEntityJoinWorldEventHandler ev); IEventHandle
|
* IEventHandle
|
||||||
* onEntityStruckByLightning(IEntityStruckByLightningEventHandler ev); IEventHandle
|
* onPlayerUseItemFinish(IPlayerUserItemFinishEventHandler ev);
|
||||||
* onLivingEnderTeleport(ILivingEnderTeleportEventHandler ev); IEventHandle
|
*
|
||||||
* onLivingAttackEvent(ILivingAttackEventHandler ev); IEventHandle onLivingDeathEvent(ILivingDeathEventHandler ev);
|
* IEventHandle onPlayerChat(IPlayerChatEventHandler ev);
|
||||||
* IEventHandle onLivingJumpEvent(ILivingJumpEventHandler ev); IEventHandle
|
*
|
||||||
* onLivingFallEvent(ILivingFallEventHandler ev); IEventHandle onLivingHurtEvent(ILivingHurtEventHandler ev);
|
* IEventHandle onTimerSingle(int millis, ITimerEventHandler ev);
|
||||||
* IEventHandle onLivingDeathDropsEvent(ILivingDeathDropsEventHandler ev); IEventHandle
|
*
|
||||||
* onItemTossed(IItemTossedEventHandler ev); IEventHandle onItemExpired(IItemExpiredEventHandler ev); IEventHandle
|
* IEventHandle onTimerRepeat(int millis, ITimerEventHandler ev);
|
||||||
* onMinecartCollision(IMinecartCollisionEventHandler ev); IEventHandle
|
*
|
||||||
* onMinecartInteract(IMinecartInteractEventHandler ev); IEventHandle onCommand(ICommandEventHandler ev);
|
* IEventHandle onEntityJoinWorld(IEntityJoinWorldEventHandler ev);
|
||||||
*/
|
*
|
||||||
|
* IEventHandle
|
||||||
|
* onEntityStruckByLightning(IEntityStruckByLightningEventHandler ev);
|
||||||
|
*
|
||||||
|
* IEventHandle
|
||||||
|
* onLivingEnderTeleport(ILivingEnderTeleportEventHandler ev);
|
||||||
|
*
|
||||||
|
* IEventHandle onLivingAttackEvent(ILivingAttackEventHandler ev);
|
||||||
|
*
|
||||||
|
* IEventHandle onLivingDeathEvent(ILivingDeathEventHandler ev);
|
||||||
|
*
|
||||||
|
* IEventHandle onLivingJumpEvent(ILivingJumpEventHandler ev);
|
||||||
|
*
|
||||||
|
* IEventHandle onLivingFallEvent(ILivingFallEventHandler ev);
|
||||||
|
*
|
||||||
|
* IEventHandle onLivingHurtEvent(ILivingHurtEventHandler ev);
|
||||||
|
*
|
||||||
|
* IEventHandle onLivingDeathDropsEvent(ILivingDeathDropsEventHandler
|
||||||
|
* ev);
|
||||||
|
*
|
||||||
|
* IEventHandle onItemTossed(IItemTossedEventHandler ev);
|
||||||
|
*
|
||||||
|
* IEventHandle onItemExpired(IItemExpiredEventHandler ev);
|
||||||
|
*
|
||||||
|
* IEventHandle onMinecartCollision(IMinecartCollisionEventHandler
|
||||||
|
* ev);
|
||||||
|
*
|
||||||
|
* IEventHandle onMinecartInteract(IMinecartInteractEventHandler ev);
|
||||||
|
*
|
||||||
|
* IEventHandle onCommand(ICommandEventHandler ev);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
@@ -1,12 +1,12 @@
|
|||||||
package minetweaker.api.event;
|
package minetweaker.api.event;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import minetweaker.api.damage.IDamageSource;
|
import minetweaker.api.damage.IDamageSource;
|
||||||
import minetweaker.api.entity.IEntityItem;
|
import minetweaker.api.entity.IEntityItem;
|
||||||
import minetweaker.api.player.IPlayer;
|
import minetweaker.api.player.IPlayer;
|
||||||
import stanhebben.zenscript.annotations.*;
|
import stanhebben.zenscript.annotations.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Stan
|
* @author Stan
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -10,89 +10,89 @@ import stanhebben.zenscript.annotations.*;
|
|||||||
*/
|
*/
|
||||||
@ZenClass("minetweaker.event.PlayerInteractEvent")
|
@ZenClass("minetweaker.event.PlayerInteractEvent")
|
||||||
public class PlayerInteractEvent {
|
public class PlayerInteractEvent {
|
||||||
|
|
||||||
private final IPlayer player;
|
private final IPlayer player;
|
||||||
private final IBlockGroup blocks;
|
private final IBlockGroup blocks;
|
||||||
private final int x;
|
private final int x;
|
||||||
private final int y;
|
private final int y;
|
||||||
private final int z;
|
private final int z;
|
||||||
|
|
||||||
private boolean canceled;
|
private boolean canceled;
|
||||||
private boolean useBlock;
|
private boolean useBlock;
|
||||||
private boolean useItem;
|
private boolean useItem;
|
||||||
|
|
||||||
public PlayerInteractEvent(IPlayer player, IBlockGroup blocks, int x, int y, int z) {
|
public PlayerInteractEvent(IPlayer player, IBlockGroup blocks, int x, int y, int z) {
|
||||||
this.player = player;
|
this.player = player;
|
||||||
this.blocks = blocks;
|
this.blocks = blocks;
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
this.z = z;
|
this.z = z;
|
||||||
|
|
||||||
canceled = false;
|
canceled = false;
|
||||||
useBlock = false;
|
useBlock = false;
|
||||||
useItem = false;
|
useItem = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
public void cancel() {
|
public void cancel() {
|
||||||
canceled = true;
|
canceled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
public void useBlock() {
|
public void useBlock() {
|
||||||
useBlock = true;
|
useBlock = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
public void useItem() {
|
public void useItem() {
|
||||||
useItem = true;
|
useItem = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ZenGetter("canceled")
|
@ZenGetter("canceled")
|
||||||
public boolean isCanceled() {
|
public boolean isCanceled() {
|
||||||
return canceled;
|
return canceled;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ZenGetter("usingBlock")
|
@ZenGetter("usingBlock")
|
||||||
public boolean isUsingBlock() {
|
public boolean isUsingBlock() {
|
||||||
return useBlock;
|
return useBlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ZenGetter("usingItem")
|
@ZenGetter("usingItem")
|
||||||
public boolean isUsingItem() {
|
public boolean isUsingItem() {
|
||||||
return useItem;
|
return useItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ZenGetter("player")
|
@ZenGetter("player")
|
||||||
public IPlayer getPlayer() {
|
public IPlayer getPlayer() {
|
||||||
return player;
|
return player;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ZenGetter("blocks")
|
@ZenGetter("blocks")
|
||||||
public IBlockGroup getBlocks() {
|
public IBlockGroup getBlocks() {
|
||||||
return blocks;
|
return blocks;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ZenGetter("x")
|
@ZenGetter("x")
|
||||||
public int getX() {
|
public int getX() {
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ZenGetter("y")
|
@ZenGetter("y")
|
||||||
public int getY() {
|
public int getY() {
|
||||||
return y;
|
return y;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ZenGetter("z")
|
@ZenGetter("z")
|
||||||
public int getZ() {
|
public int getZ() {
|
||||||
return z;
|
return z;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ZenGetter("block")
|
@ZenGetter("block")
|
||||||
public IBlock getBlock() {
|
public IBlock getBlock() {
|
||||||
return blocks.getBlock(x, y, z);
|
return blocks.getBlock(x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ZenGetter("dimension")
|
@ZenGetter("dimension")
|
||||||
public IDimension getDimension() {
|
public IDimension getDimension() {
|
||||||
return blocks.getDimension();
|
return blocks.getDimension();
|
||||||
|
|||||||
@@ -8,13 +8,13 @@ import stanhebben.zenscript.annotations.*;
|
|||||||
*/
|
*/
|
||||||
@ZenClass("minetweaker.event.PlayerLoggedInEvent")
|
@ZenClass("minetweaker.event.PlayerLoggedInEvent")
|
||||||
public class PlayerLoggedInEvent {
|
public class PlayerLoggedInEvent {
|
||||||
|
|
||||||
private final IPlayer player;
|
private final IPlayer player;
|
||||||
|
|
||||||
public PlayerLoggedInEvent(IPlayer player) {
|
public PlayerLoggedInEvent(IPlayer player) {
|
||||||
this.player = player;
|
this.player = player;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ZenGetter("player")
|
@ZenGetter("player")
|
||||||
public IPlayer getPlayer() {
|
public IPlayer getPlayer() {
|
||||||
return player;
|
return player;
|
||||||
|
|||||||
@@ -8,13 +8,13 @@ import stanhebben.zenscript.annotations.*;
|
|||||||
*/
|
*/
|
||||||
@ZenClass("minetweaker.event.PlayerLoggedOutEvent")
|
@ZenClass("minetweaker.event.PlayerLoggedOutEvent")
|
||||||
public class PlayerLoggedOutEvent {
|
public class PlayerLoggedOutEvent {
|
||||||
|
|
||||||
private final IPlayer player;
|
private final IPlayer player;
|
||||||
|
|
||||||
public PlayerLoggedOutEvent(IPlayer player) {
|
public PlayerLoggedOutEvent(IPlayer player) {
|
||||||
this.player = player;
|
this.player = player;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ZenGetter("player")
|
@ZenGetter("player")
|
||||||
public IPlayer getPlayer() {
|
public IPlayer getPlayer() {
|
||||||
return player;
|
return player;
|
||||||
|
|||||||
@@ -9,33 +9,33 @@ import stanhebben.zenscript.annotations.*;
|
|||||||
*/
|
*/
|
||||||
@ZenClass("minetweaker.event.PlayerOpenContainerEvent")
|
@ZenClass("minetweaker.event.PlayerOpenContainerEvent")
|
||||||
public class PlayerOpenContainerEvent {
|
public class PlayerOpenContainerEvent {
|
||||||
|
|
||||||
private final IPlayer player;
|
private final IPlayer player;
|
||||||
private final IContainer container;
|
private final IContainer container;
|
||||||
private boolean canceled;
|
private boolean canceled;
|
||||||
|
|
||||||
public PlayerOpenContainerEvent(IPlayer player, IContainer container) {
|
public PlayerOpenContainerEvent(IPlayer player, IContainer container) {
|
||||||
this.player = player;
|
this.player = player;
|
||||||
this.container = container;
|
this.container = container;
|
||||||
|
|
||||||
canceled = false;
|
canceled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
public void cancel() {
|
public void cancel() {
|
||||||
canceled = true;
|
canceled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ZenGetter("canceled")
|
@ZenGetter("canceled")
|
||||||
public boolean isCanceled() {
|
public boolean isCanceled() {
|
||||||
return canceled;
|
return canceled;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ZenGetter("player")
|
@ZenGetter("player")
|
||||||
public IPlayer getPlayer() {
|
public IPlayer getPlayer() {
|
||||||
return player;
|
return player;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ZenGetter("container")
|
@ZenGetter("container")
|
||||||
public IContainer getContainer() {
|
public IContainer getContainer() {
|
||||||
return container;
|
return container;
|
||||||
|
|||||||
@@ -6,69 +6,69 @@ import stanhebben.zenscript.annotations.ZenMethod;
|
|||||||
* @author Stan
|
* @author Stan
|
||||||
*/
|
*/
|
||||||
public interface IFormatter {
|
public interface IFormatter {
|
||||||
|
|
||||||
IFormattedText string(String text);
|
IFormattedText string(String text);
|
||||||
|
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
IFormattedText black(IFormattedText text);
|
IFormattedText black(IFormattedText text);
|
||||||
|
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
IFormattedText darkBlue(IFormattedText text);
|
IFormattedText darkBlue(IFormattedText text);
|
||||||
|
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
IFormattedText darkGreen(IFormattedText text);
|
IFormattedText darkGreen(IFormattedText text);
|
||||||
|
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
IFormattedText darkAqua(IFormattedText text);
|
IFormattedText darkAqua(IFormattedText text);
|
||||||
|
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
IFormattedText darkRed(IFormattedText text);
|
IFormattedText darkRed(IFormattedText text);
|
||||||
|
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
IFormattedText darkPurple(IFormattedText text);
|
IFormattedText darkPurple(IFormattedText text);
|
||||||
|
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
IFormattedText gold(IFormattedText text);
|
IFormattedText gold(IFormattedText text);
|
||||||
|
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
IFormattedText gray(IFormattedText text);
|
IFormattedText gray(IFormattedText text);
|
||||||
|
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
IFormattedText darkGray(IFormattedText text);
|
IFormattedText darkGray(IFormattedText text);
|
||||||
|
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
IFormattedText blue(IFormattedText text);
|
IFormattedText blue(IFormattedText text);
|
||||||
|
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
IFormattedText green(IFormattedText text);
|
IFormattedText green(IFormattedText text);
|
||||||
|
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
IFormattedText aqua(IFormattedText text);
|
IFormattedText aqua(IFormattedText text);
|
||||||
|
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
IFormattedText red(IFormattedText text);
|
IFormattedText red(IFormattedText text);
|
||||||
|
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
IFormattedText lightPurple(IFormattedText text);
|
IFormattedText lightPurple(IFormattedText text);
|
||||||
|
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
IFormattedText yellow(IFormattedText text);
|
IFormattedText yellow(IFormattedText text);
|
||||||
|
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
IFormattedText white(IFormattedText text);
|
IFormattedText white(IFormattedText text);
|
||||||
|
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
IFormattedText obfuscated(IFormattedText text);
|
IFormattedText obfuscated(IFormattedText text);
|
||||||
|
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
IFormattedText bold(IFormattedText text);
|
IFormattedText bold(IFormattedText text);
|
||||||
|
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
IFormattedText strikethrough(IFormattedText text);
|
IFormattedText strikethrough(IFormattedText text);
|
||||||
|
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
IFormattedText underline(IFormattedText text);
|
IFormattedText underline(IFormattedText text);
|
||||||
|
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
IFormattedText italic(IFormattedText text);
|
IFormattedText italic(IFormattedText text);
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,5 @@
|
|||||||
package minetweaker.api.game;
|
package minetweaker.api.game;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import minetweaker.api.block.IBlockDefinition;
|
import minetweaker.api.block.IBlockDefinition;
|
||||||
import minetweaker.api.entity.IEntityDefinition;
|
import minetweaker.api.entity.IEntityDefinition;
|
||||||
import minetweaker.api.item.IItemDefinition;
|
import minetweaker.api.item.IItemDefinition;
|
||||||
@@ -9,6 +7,8 @@ import minetweaker.api.liquid.ILiquidDefinition;
|
|||||||
import minetweaker.api.world.IBiome;
|
import minetweaker.api.world.IBiome;
|
||||||
import stanhebben.zenscript.annotations.*;
|
import stanhebben.zenscript.annotations.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Game interface. Used to obtain general game information.
|
* Game interface. Used to obtain general game information.
|
||||||
*
|
*
|
||||||
@@ -16,7 +16,7 @@ import stanhebben.zenscript.annotations.*;
|
|||||||
*/
|
*/
|
||||||
@ZenClass("minetweaker.game.IGame")
|
@ZenClass("minetweaker.game.IGame")
|
||||||
public interface IGame {
|
public interface IGame {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the item definitions in this game.
|
* Retrieves the item definitions in this game.
|
||||||
*
|
*
|
||||||
@@ -24,7 +24,7 @@ public interface IGame {
|
|||||||
*/
|
*/
|
||||||
@ZenGetter("items")
|
@ZenGetter("items")
|
||||||
List<IItemDefinition> getItems();
|
List<IItemDefinition> getItems();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the block definitions in this game.
|
* Retrieves the block definitions in this game.
|
||||||
*
|
*
|
||||||
@@ -32,7 +32,7 @@ public interface IGame {
|
|||||||
*/
|
*/
|
||||||
@ZenGetter("blocks")
|
@ZenGetter("blocks")
|
||||||
List<IBlockDefinition> getBlocks();
|
List<IBlockDefinition> getBlocks();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the liquids in this game.
|
* Retrieves the liquids in this game.
|
||||||
*
|
*
|
||||||
@@ -40,7 +40,7 @@ public interface IGame {
|
|||||||
*/
|
*/
|
||||||
@ZenGetter("liquids")
|
@ZenGetter("liquids")
|
||||||
List<ILiquidDefinition> getLiquids();
|
List<ILiquidDefinition> getLiquids();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the biomes in this game.
|
* Retrieves the biomes in this game.
|
||||||
*
|
*
|
||||||
@@ -48,7 +48,7 @@ public interface IGame {
|
|||||||
*/
|
*/
|
||||||
@ZenGetter("biomes")
|
@ZenGetter("biomes")
|
||||||
List<IBiome> getBiomes();
|
List<IBiome> getBiomes();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the entities in this game.
|
* Retrieves the entities in this game.
|
||||||
*
|
*
|
||||||
@@ -56,10 +56,10 @@ public interface IGame {
|
|||||||
*/
|
*/
|
||||||
@ZenGetter("entities")
|
@ZenGetter("entities")
|
||||||
List<IEntityDefinition> getEntities();
|
List<IEntityDefinition> getEntities();
|
||||||
|
|
||||||
@ZenMethod()
|
@ZenMethod()
|
||||||
IEntityDefinition getEntity(String entityName);
|
IEntityDefinition getEntity(String entityName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a localization value.
|
* Sets a localization value.
|
||||||
*
|
*
|
||||||
@@ -68,7 +68,7 @@ public interface IGame {
|
|||||||
*/
|
*/
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
void setLocalization(String key, String value);
|
void setLocalization(String key, String value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a localization value.
|
* Sets a localization value.
|
||||||
*
|
*
|
||||||
@@ -78,7 +78,7 @@ public interface IGame {
|
|||||||
*/
|
*/
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
void setLocalization(String lang, String key, String value);
|
void setLocalization(String lang, String key, String value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a localized string.
|
* Gets a localized string.
|
||||||
*
|
*
|
||||||
@@ -88,7 +88,7 @@ public interface IGame {
|
|||||||
*/
|
*/
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
String localize(String key);
|
String localize(String key);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a localized string.
|
* Gets a localized string.
|
||||||
*
|
*
|
||||||
@@ -99,15 +99,16 @@ public interface IGame {
|
|||||||
*/
|
*/
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
String localize(String key, String lang);
|
String localize(String key, String lang);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lock the game and disable reload. Recommended for distributed versions.
|
* Lock the game and disable reload. Recommended for distributed versions.
|
||||||
* <p>
|
* <p>
|
||||||
* Once locked, reload cannot be unlocked - a game restart is required to alter the scripts.
|
* Once locked, reload cannot be unlocked - a game restart is required to
|
||||||
|
* alter the scripts.
|
||||||
*/
|
*/
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
void lock();
|
void lock();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the lock state. True if locked.
|
* Returns the lock state. True if locked.
|
||||||
*
|
*
|
||||||
@@ -115,7 +116,7 @@ public interface IGame {
|
|||||||
*/
|
*/
|
||||||
@ZenGetter("locked")
|
@ZenGetter("locked")
|
||||||
boolean isLocked();
|
boolean isLocked();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Signals a modified script while in locked mode.
|
* Signals a modified script while in locked mode.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,61 +1,66 @@
|
|||||||
package minetweaker.api.item;
|
package minetweaker.api.item;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import minetweaker.api.liquid.ILiquidStack;
|
import minetweaker.api.liquid.ILiquidStack;
|
||||||
import minetweaker.api.player.IPlayer;
|
import minetweaker.api.player.IPlayer;
|
||||||
import stanhebben.zenscript.annotations.*;
|
import stanhebben.zenscript.annotations.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a recipe ingredient. An ingredient can be an item, an ore dictionary entry, an item stack, an ore
|
* Represents a recipe ingredient. An ingredient can be an item, an ore
|
||||||
* dictionary entry multiplied with an amount, or other kinds of ingredients as offered by the API.
|
* dictionary entry, an item stack, an ore dictionary entry multiplied with an
|
||||||
|
* amount, or other kinds of ingredients as offered by the API.
|
||||||
* <p>
|
* <p>
|
||||||
* There is no guarantee that every mod will respect the conditions or transformations, or that every mod will support
|
* There is no guarantee that every mod will respect the conditions or
|
||||||
* every kind of ingredient.
|
* transformations, or that every mod will support every kind of ingredient.
|
||||||
*
|
*
|
||||||
* @author Stan Hebben
|
* @author Stan Hebben
|
||||||
*/
|
*/
|
||||||
@ZenClass("minetweaker.item.IIngredient")
|
@ZenClass("minetweaker.item.IIngredient")
|
||||||
public interface IIngredient {
|
public interface IIngredient {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the mark of the ingredient. Ingredients can be marked so they can be used in crafting functions.
|
* Gets the mark of the ingredient. Ingredients can be marked so they can be
|
||||||
|
* used in crafting functions.
|
||||||
*
|
*
|
||||||
* @return ingredient mark
|
* @return ingredient mark
|
||||||
*/
|
*/
|
||||||
@ZenGetter("mark")
|
@ZenGetter("mark")
|
||||||
String getMark();
|
String getMark();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the amount.
|
* Gets the amount.
|
||||||
* <p>
|
* <p>
|
||||||
* Should return -1 if no amount is available and 1 for a single item. Stacks return the stack size.
|
* Should return -1 if no amount is available and 1 for a single item.
|
||||||
|
* Stacks return the stack size.
|
||||||
*
|
*
|
||||||
* @return stack size
|
* @return stack size
|
||||||
*/
|
*/
|
||||||
@ZenGetter("amount")
|
@ZenGetter("amount")
|
||||||
int getAmount();
|
int getAmount();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets all possible items for this ingredient.
|
* Gets all possible items for this ingredient.
|
||||||
* <p>
|
* <p>
|
||||||
* If there is no item list (for example, it is the <*> wildcard item) null should be returned.
|
* If there is no item list (for example, it is the <*> wildcard item)
|
||||||
|
* null should be returned.
|
||||||
*
|
*
|
||||||
* @return the items for this ingredient, or null
|
* @return the items for this ingredient, or null
|
||||||
*/
|
*/
|
||||||
@ZenGetter("items")
|
@ZenGetter("items")
|
||||||
List<IItemStack> getItems();
|
List<IItemStack> getItems();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets all possible liquids for this ingredient.
|
* Gets all possible liquids for this ingredient.
|
||||||
* <p>
|
* <p>
|
||||||
* If there is no liquid list (for example, it is the <*&ft; wildcard item) null should be returned.
|
* If there is no liquid list (for example, it is the <*&ft; wildcard
|
||||||
|
* item) null should be returned.
|
||||||
*
|
*
|
||||||
* @return the liquids for this ingredient, or null
|
* @return the liquids for this ingredient, or null
|
||||||
*/
|
*/
|
||||||
@ZenGetter("liquids")
|
@ZenGetter("liquids")
|
||||||
List<ILiquidStack> getLiquids();
|
List<ILiquidStack> getLiquids();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a new ingredient with the given stack size.
|
* Returns a new ingredient with the given stack size.
|
||||||
*
|
*
|
||||||
@@ -66,9 +71,10 @@ public interface IIngredient {
|
|||||||
@ZenOperator(OperatorType.MUL)
|
@ZenOperator(OperatorType.MUL)
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
IIngredient amount(int amount);
|
IIngredient amount(int amount);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Combines multiple ingredients into a single one. Note that ore dictionary entries are preferred to or statements.
|
* Combines multiple ingredients into a single one. Note that ore dictionary
|
||||||
|
* entries are preferred to or statements.
|
||||||
*
|
*
|
||||||
* @param ingredient ingredient to combine with
|
* @param ingredient ingredient to combine with
|
||||||
*
|
*
|
||||||
@@ -77,7 +83,7 @@ public interface IIngredient {
|
|||||||
@ZenOperator(OperatorType.OR)
|
@ZenOperator(OperatorType.OR)
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
IIngredient or(IIngredient ingredient);
|
IIngredient or(IIngredient ingredient);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a new ingredient with the given transform added to it.
|
* Returns a new ingredient with the given transform added to it.
|
||||||
*
|
*
|
||||||
@@ -87,7 +93,7 @@ public interface IIngredient {
|
|||||||
*/
|
*/
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
IIngredient transform(IItemTransformer transformer);
|
IIngredient transform(IItemTransformer transformer);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a new ingredient with the given condition added to it.
|
* Returns a new ingredient with the given condition added to it.
|
||||||
*
|
*
|
||||||
@@ -97,7 +103,7 @@ public interface IIngredient {
|
|||||||
*/
|
*/
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
IIngredient only(IItemCondition condition);
|
IIngredient only(IItemCondition condition);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a new ingredient marked with the given name.
|
* Returns a new ingredient marked with the given name.
|
||||||
*
|
*
|
||||||
@@ -107,9 +113,10 @@ public interface IIngredient {
|
|||||||
*/
|
*/
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
IIngredient marked(String mark);
|
IIngredient marked(String mark);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if this ingredient matches the given item. For liquids, will match the item if it is a valid container.
|
* Checks if this ingredient matches the given item. For liquids, will match
|
||||||
|
* the item if it is a valid container.
|
||||||
*
|
*
|
||||||
* @param item item to check
|
* @param item item to check
|
||||||
*
|
*
|
||||||
@@ -117,9 +124,10 @@ public interface IIngredient {
|
|||||||
*/
|
*/
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
boolean matches(IItemStack item);
|
boolean matches(IItemStack item);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if this ingredient matches the given item. For liquids, will match the item if it is a valid container.
|
* Checks if this ingredient matches the given item. For liquids, will match
|
||||||
|
* the item if it is a valid container.
|
||||||
*
|
*
|
||||||
* @param item item to check
|
* @param item item to check
|
||||||
*
|
*
|
||||||
@@ -127,7 +135,8 @@ public interface IIngredient {
|
|||||||
*/
|
*/
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
boolean matchesExact(IItemStack item);
|
boolean matchesExact(IItemStack item);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if this ingredient matches the given liquid.
|
* Checks if this ingredient matches the given liquid.
|
||||||
*
|
*
|
||||||
@@ -137,9 +146,10 @@ public interface IIngredient {
|
|||||||
*/
|
*/
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
boolean matches(ILiquidStack liquid);
|
boolean matches(ILiquidStack liquid);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if this ingredient contains all possible values for the given ingredient.
|
* Check if this ingredient contains all possible values for the given
|
||||||
|
* ingredient.
|
||||||
*
|
*
|
||||||
* @param ingredient ingredient to check
|
* @param ingredient ingredient to check
|
||||||
*
|
*
|
||||||
@@ -147,7 +157,7 @@ public interface IIngredient {
|
|||||||
*/
|
*/
|
||||||
@ZenOperator(OperatorType.CONTAINS)
|
@ZenOperator(OperatorType.CONTAINS)
|
||||||
boolean contains(IIngredient ingredient);
|
boolean contains(IIngredient ingredient);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Applies transformations after crafting, if any, to the given item.
|
* Applies transformations after crafting, if any, to the given item.
|
||||||
*
|
*
|
||||||
@@ -158,23 +168,25 @@ public interface IIngredient {
|
|||||||
*/
|
*/
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
IItemStack applyTransform(IItemStack item, IPlayer byPlayer);
|
IItemStack applyTransform(IItemStack item, IPlayer byPlayer);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if this ingredient has (or could have) any transformatiosns.
|
* Checks if this ingredient has (or could have) any transformatiosns.
|
||||||
*
|
*
|
||||||
* @return true if there are (or could be) any transformations false otherwise.
|
* @return true if there are (or could be) any transformations false
|
||||||
|
* otherwise.
|
||||||
*/
|
*/
|
||||||
@ZenGetter("hasTransformations")
|
@ZenGetter("hasTransformations")
|
||||||
boolean hasTransformers();
|
boolean hasTransformers();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the internal item backing this ingredient.
|
* Gets the internal item backing this ingredient.
|
||||||
* <p>
|
* <p>
|
||||||
* The value is implementation-dependent and should only be handled by the internal code. Don't use this value -
|
* The value is implementation-dependent and should only be handled by the
|
||||||
* instead, use the version-specific helper methods.
|
* internal code. Don't use this value - instead, use the version-specific
|
||||||
|
* helper methods.
|
||||||
*
|
*
|
||||||
* @return internal item
|
* @return internal item
|
||||||
*/
|
*/
|
||||||
Object getInternal();
|
Object getInternal();
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -5,8 +5,9 @@ import stanhebben.zenscript.annotations.ZenClass;
|
|||||||
/**
|
/**
|
||||||
* Item conditions apply additional conditions on item stacks.
|
* Item conditions apply additional conditions on item stacks.
|
||||||
* <p>
|
* <p>
|
||||||
* They may, for instance, require specific damage ranges or NBT tags. Custom implementations of this functional
|
* They may, for instance, require specific damage ranges or NBT tags. Custom
|
||||||
* interface may contain any kind of condition.
|
* implementations of this functional interface may contain any kind of
|
||||||
|
* condition.
|
||||||
*
|
*
|
||||||
* @author Stan Hebben
|
* @author Stan Hebben
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,21 +1,22 @@
|
|||||||
package minetweaker.api.item;
|
package minetweaker.api.item;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import minetweaker.api.oredict.IOreDictEntry;
|
import minetweaker.api.oredict.IOreDictEntry;
|
||||||
import stanhebben.zenscript.annotations.*;
|
import stanhebben.zenscript.annotations.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Contains an item definition. Item definitions provide general information about an item, such as its name and ID.
|
* Contains an item definition. Item definitions provide general information
|
||||||
|
* about an item, such as its name and ID.
|
||||||
* <p>
|
* <p>
|
||||||
* Item definitions themselves have no localized name, as it could be different for each subitem or even depend on NBT
|
* Item definitions themselves have no localized name, as it could be different
|
||||||
* tags.
|
* for each subitem or even depend on NBT tags.
|
||||||
*
|
*
|
||||||
* @author Stan Hebben
|
* @author Stan Hebben
|
||||||
*/
|
*/
|
||||||
@ZenClass("minetweaker.item.IItemDefinition")
|
@ZenClass("minetweaker.item.IItemDefinition")
|
||||||
public interface IItemDefinition {
|
public interface IItemDefinition {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the item ID.
|
* Gets the item ID.
|
||||||
*
|
*
|
||||||
@@ -23,7 +24,7 @@ public interface IItemDefinition {
|
|||||||
*/
|
*/
|
||||||
@ZenGetter("id")
|
@ZenGetter("id")
|
||||||
String getId();
|
String getId();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the unlocalized item name.
|
* Gets the unlocalized item name.
|
||||||
*
|
*
|
||||||
@@ -31,7 +32,7 @@ public interface IItemDefinition {
|
|||||||
*/
|
*/
|
||||||
@ZenGetter("name")
|
@ZenGetter("name")
|
||||||
String getName();
|
String getName();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Makes an item stack from this definition.
|
* Makes an item stack from this definition.
|
||||||
*
|
*
|
||||||
@@ -41,9 +42,10 @@ public interface IItemDefinition {
|
|||||||
*/
|
*/
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
IItemStack makeStack(@Optional int meta);
|
IItemStack makeStack(@Optional int meta);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns all ore entries containing this item. Also contains ore entries that refer to a specific sub-item.
|
* Returns all ore entries containing this item. Also contains ore entries
|
||||||
|
* that refer to a specific sub-item.
|
||||||
*
|
*
|
||||||
* @return all the ore entries containing this item.
|
* @return all the ore entries containing this item.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,28 +1,31 @@
|
|||||||
package minetweaker.api.item;
|
package minetweaker.api.item;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import minetweaker.api.block.IBlock;
|
import minetweaker.api.block.IBlock;
|
||||||
import minetweaker.api.data.IData;
|
import minetweaker.api.data.IData;
|
||||||
import minetweaker.api.liquid.ILiquidStack;
|
import minetweaker.api.liquid.ILiquidStack;
|
||||||
import minetweaker.api.oredict.IOreDictEntry;
|
import minetweaker.api.oredict.IOreDictEntry;
|
||||||
import stanhebben.zenscript.annotations.*;
|
import stanhebben.zenscript.annotations.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Contains an item stack. An item stack consists of an item definition, a meta or damage value and NBT data.
|
* Contains an item stack. An item stack consists of an item definition, a meta
|
||||||
|
* or damage value and NBT data.
|
||||||
* <p>
|
* <p>
|
||||||
* Item stacks can be retrieved using its name (or ID, in 1.6.4) with the bracket syntax. When using the bracket syntax,
|
* Item stacks can be retrieved using its name (or ID, in 1.6.4) with the
|
||||||
* by default, the item stack will match any size when used as ingredient. Item stacks can be multiplied with an integer
|
* bracket syntax. When using the bracket syntax, by default, the item stack
|
||||||
* to create a stack of different size.
|
* will match any size when used as ingredient. Item stacks can be multiplied
|
||||||
|
* with an integer to create a stack of different size.
|
||||||
* <p>
|
* <p>
|
||||||
* Item stacks are immutable. You can, however, easily create modified stacks using the helper methods. Adding
|
* Item stacks are immutable. You can, however, easily create modified stacks
|
||||||
* conditions and transformations will turn the item stack into an ingredients.
|
* using the helper methods. Adding conditions and transformations will turn the
|
||||||
|
* item stack into an ingredients.
|
||||||
*
|
*
|
||||||
* @author Stan Hebben
|
* @author Stan Hebben
|
||||||
*/
|
*/
|
||||||
@ZenClass("minetweaker.item.IItemStack")
|
@ZenClass("minetweaker.item.IItemStack")
|
||||||
public interface IItemStack extends IIngredient {
|
public interface IItemStack extends IIngredient {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the item definition.
|
* Gets the item definition.
|
||||||
*
|
*
|
||||||
@@ -30,7 +33,7 @@ public interface IItemStack extends IIngredient {
|
|||||||
*/
|
*/
|
||||||
@ZenGetter("definition")
|
@ZenGetter("definition")
|
||||||
IItemDefinition getDefinition();
|
IItemDefinition getDefinition();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the unlocalized item name.
|
* Gets the unlocalized item name.
|
||||||
*
|
*
|
||||||
@@ -38,25 +41,26 @@ public interface IItemStack extends IIngredient {
|
|||||||
*/
|
*/
|
||||||
@ZenGetter("name")
|
@ZenGetter("name")
|
||||||
String getName();
|
String getName();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the display name. By default, it is the localized item name, but could also be the display name from NBT
|
* Gets the display name. By default, it is the localized item name, but
|
||||||
* data, or another item-specific name.
|
* could also be the display name from NBT data, or another item-specific
|
||||||
|
* name.
|
||||||
*
|
*
|
||||||
* @return item display name
|
* @return item display name
|
||||||
*/
|
*/
|
||||||
@ZenGetter("displayName")
|
@ZenGetter("displayName")
|
||||||
String getDisplayName();
|
String getDisplayName();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the display name. Only works if the name is translatable. Does not override names set by NBT data or using
|
* Sets the display name. Only works if the name is translatable. Does not
|
||||||
* item-specific logic.
|
* override names set by NBT data or using item-specific logic.
|
||||||
*
|
*
|
||||||
* @param name item display name
|
* @param name item display name
|
||||||
*/
|
*/
|
||||||
@ZenSetter("displayName")
|
@ZenSetter("displayName")
|
||||||
void setDisplayName(String name);
|
void setDisplayName(String name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the max stack size for an item
|
* Gets the max stack size for an item
|
||||||
*
|
*
|
||||||
@@ -64,7 +68,7 @@ public interface IItemStack extends IIngredient {
|
|||||||
*/
|
*/
|
||||||
@ZenGetter("maxStackSize")
|
@ZenGetter("maxStackSize")
|
||||||
int getMaxStackSize();
|
int getMaxStackSize();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the ItemStack max stack size.
|
* Sets the ItemStack max stack size.
|
||||||
*
|
*
|
||||||
@@ -72,13 +76,13 @@ public interface IItemStack extends IIngredient {
|
|||||||
*/
|
*/
|
||||||
@ZenSetter("maxStackSize")
|
@ZenSetter("maxStackSize")
|
||||||
void setMaxStackSize(int size);
|
void setMaxStackSize(int size);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the block hardness
|
* Gets the block hardness
|
||||||
*/
|
*/
|
||||||
@ZenGetter("hardness")
|
@ZenGetter("hardness")
|
||||||
float getBlockHardness();
|
float getBlockHardness();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the block hardness
|
* Sets the block hardness
|
||||||
*
|
*
|
||||||
@@ -86,7 +90,7 @@ public interface IItemStack extends IIngredient {
|
|||||||
*/
|
*/
|
||||||
@ZenSetter("hardness")
|
@ZenSetter("hardness")
|
||||||
void setBlockHardness(float hardness);
|
void setBlockHardness(float hardness);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the item damage. Returns 0 if the item cannot be damaged.
|
* Gets the item damage. Returns 0 if the item cannot be damaged.
|
||||||
*
|
*
|
||||||
@@ -94,7 +98,7 @@ public interface IItemStack extends IIngredient {
|
|||||||
*/
|
*/
|
||||||
@ZenGetter("damage")
|
@ZenGetter("damage")
|
||||||
int getDamage();
|
int getDamage();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the maximum item damage. Returns 0 if the item cannot be damaged.
|
* Gets the maximum item damage. Returns 0 if the item cannot be damaged.
|
||||||
*
|
*
|
||||||
@@ -102,7 +106,7 @@ public interface IItemStack extends IIngredient {
|
|||||||
*/
|
*/
|
||||||
@ZenGetter("maxDamage")
|
@ZenGetter("maxDamage")
|
||||||
int getMaxDamage();
|
int getMaxDamage();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the max Itemstack damage
|
* Sets the max Itemstack damage
|
||||||
*
|
*
|
||||||
@@ -110,25 +114,27 @@ public interface IItemStack extends IIngredient {
|
|||||||
*/
|
*/
|
||||||
@ZenSetter("maxDamage")
|
@ZenSetter("maxDamage")
|
||||||
void setMaxDamage(int damage);
|
void setMaxDamage(int damage);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the item tag. (NBT data) The resulting data is immutable and can only be changed with updateTag. Returns
|
* Gets the item tag. (NBT data) The resulting data is immutable and can
|
||||||
* empty data if there is no data. Never returns null.
|
* only be changed with updateTag. Returns empty data if there is no data.
|
||||||
|
* Never returns null.
|
||||||
*
|
*
|
||||||
* @return item tag
|
* @return item tag
|
||||||
*/
|
*/
|
||||||
@ZenGetter("tag")
|
@ZenGetter("tag")
|
||||||
IData getTag();
|
IData getTag();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the liquid contained in this item, if any. If this item stack is not an item container, it returns null.
|
* Gets the liquid contained in this item, if any. If this item stack is not
|
||||||
* Only returns the amount of liquid in a single item and doesn't into account stack size.
|
* an item container, it returns null. Only returns the amount of liquid in
|
||||||
|
* a single item and doesn't into account stack size.
|
||||||
*
|
*
|
||||||
* @return liquid data
|
* @return liquid data
|
||||||
*/
|
*/
|
||||||
@ZenGetter("liquid")
|
@ZenGetter("liquid")
|
||||||
ILiquidStack getLiquid();
|
ILiquidStack getLiquid();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new item stack with a different stack size.
|
* Creates a new item stack with a different stack size.
|
||||||
*
|
*
|
||||||
@@ -138,9 +144,10 @@ public interface IItemStack extends IIngredient {
|
|||||||
*/
|
*/
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
IItemStack amount(int amount);
|
IItemStack amount(int amount);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a weighted item stack with the given percentage chance. Does the same as item.weight(p * 0.01).
|
* Creates a weighted item stack with the given percentage chance. Does the
|
||||||
|
* same as item.weight(p * 0.01).
|
||||||
*
|
*
|
||||||
* @param p probability, with percent
|
* @param p probability, with percent
|
||||||
*
|
*
|
||||||
@@ -148,7 +155,7 @@ public interface IItemStack extends IIngredient {
|
|||||||
*/
|
*/
|
||||||
@ZenOperator(OperatorType.MOD)
|
@ZenOperator(OperatorType.MOD)
|
||||||
WeightedItemStack percent(float p);
|
WeightedItemStack percent(float p);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a weighted item stack with the given weight.
|
* Creates a weighted item stack with the given weight.
|
||||||
*
|
*
|
||||||
@@ -158,16 +165,16 @@ public interface IItemStack extends IIngredient {
|
|||||||
*/
|
*/
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
WeightedItemStack weight(float p);
|
WeightedItemStack weight(float p);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an item stack with the same item and stack size, but accepting any damage value. Only useful for items
|
* Creates an item stack with the same item and stack size, but accepting
|
||||||
* used as ingredients.
|
* any damage value. Only useful for items used as ingredients.
|
||||||
*
|
*
|
||||||
* @return item stack with wildcard damage
|
* @return item stack with wildcard damage
|
||||||
*/
|
*/
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
IIngredient anyDamage();
|
IIngredient anyDamage();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an item stack with the specified damage.
|
* Creates an item stack with the specified damage.
|
||||||
*
|
*
|
||||||
@@ -177,7 +184,7 @@ public interface IItemStack extends IIngredient {
|
|||||||
*/
|
*/
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
IItemStack withDamage(int damage);
|
IItemStack withDamage(int damage);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an item stack with the specified stack size.
|
* Creates an item stack with the specified stack size.
|
||||||
*
|
*
|
||||||
@@ -188,16 +195,16 @@ public interface IItemStack extends IIngredient {
|
|||||||
@ZenOperator(OperatorType.MUL)
|
@ZenOperator(OperatorType.MUL)
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
IItemStack withAmount(int amount);
|
IItemStack withAmount(int amount);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an item stack with wildcard stack size.
|
* Creates an item stack with wildcard stack size.
|
||||||
*
|
*
|
||||||
* @return new, modified item stack
|
* @return new, modified item stack
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
IItemStack anyAmount();
|
IItemStack anyAmount();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an item stack with the given nbt tag. Ignores existing tags.
|
* Creates an item stack with the given nbt tag. Ignores existing tags.
|
||||||
*
|
*
|
||||||
@@ -207,7 +214,7 @@ public interface IItemStack extends IIngredient {
|
|||||||
*/
|
*/
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
IItemStack withTag(IData tag);
|
IItemStack withTag(IData tag);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create an item stack with an empty nbt tag. Removes previous tag if any.
|
* Create an item stack with an empty nbt tag. Removes previous tag if any.
|
||||||
*
|
*
|
||||||
@@ -215,7 +222,7 @@ public interface IItemStack extends IIngredient {
|
|||||||
*/
|
*/
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
IItemStack withEmptyTag();
|
IItemStack withEmptyTag();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an item stack without the given nbt tag.
|
* Creates an item stack without the given nbt tag.
|
||||||
*
|
*
|
||||||
@@ -225,7 +232,7 @@ public interface IItemStack extends IIngredient {
|
|||||||
*/
|
*/
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
IItemStack removeTag(String tag);
|
IItemStack removeTag(String tag);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an item stack with updated nbt tag. Updates existing tags.
|
* Creates an item stack with updated nbt tag. Updates existing tags.
|
||||||
*
|
*
|
||||||
@@ -235,7 +242,7 @@ public interface IItemStack extends IIngredient {
|
|||||||
*/
|
*/
|
||||||
@ZenMethod
|
@ZenMethod
|
||||||
IItemStack updateTag(IData tagUpdate);
|
IItemStack updateTag(IData tagUpdate);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts this item stack into a block.
|
* Converts this item stack into a block.
|
||||||
*
|
*
|
||||||
@@ -243,9 +250,10 @@ public interface IItemStack extends IIngredient {
|
|||||||
*/
|
*/
|
||||||
@ZenCaster
|
@ZenCaster
|
||||||
IBlock asBlock();
|
IBlock asBlock();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves all the ores referring to this item. Includes wildcard ore entries.
|
* Retrieves all the ores referring to this item. Includes wildcard ore
|
||||||
|
* entries.
|
||||||
*
|
*
|
||||||
* @return ore entries containing this item stack
|
* @return ore entries containing this item stack
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -4,8 +4,9 @@ import minetweaker.api.player.IPlayer;
|
|||||||
import stanhebben.zenscript.annotations.*;
|
import stanhebben.zenscript.annotations.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An item transformer modifies an item stack after crafting. Used to apply damage, grab multiple items, change NBT
|
* An item transformer modifies an item stack after crafting. Used to apply
|
||||||
* tags, replace the item with something else - or whatever else you'd want to happen to the input stack.
|
* damage, grab multiple items, change NBT tags, replace the item with something
|
||||||
|
* else - or whatever else you'd want to happen to the input stack.
|
||||||
*
|
*
|
||||||
* @author Stan Hebben
|
* @author Stan Hebben
|
||||||
*/
|
*/
|
||||||
@@ -13,7 +14,8 @@ import stanhebben.zenscript.annotations.*;
|
|||||||
public interface IItemTransformer {
|
public interface IItemTransformer {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transforms the specified item. May modify this item (and return it) or return an entirely new one.
|
* Transforms the specified item. May modify this item (and return it) or
|
||||||
|
* return an entirely new one.
|
||||||
*
|
*
|
||||||
* @param item input item
|
* @param item input item
|
||||||
* @param byPlayer player that performs the crafting
|
* @param byPlayer player that performs the crafting
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
package minetweaker.api.item;
|
package minetweaker.api.item;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import minetweaker.api.liquid.ILiquidStack;
|
import minetweaker.api.liquid.ILiquidStack;
|
||||||
import minetweaker.api.player.IPlayer;
|
import minetweaker.api.player.IPlayer;
|
||||||
import minetweaker.util.ArrayUtil;
|
import minetweaker.util.ArrayUtil;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents the wildcard ingredient (<*>).
|
* Represents the wildcard ingredient (<*>).
|
||||||
*
|
*
|
||||||
@@ -18,7 +18,8 @@ public class IngredientAny implements IIngredient {
|
|||||||
public static Object INTERNAL_ANY = null; // platforms supporting an "any"
|
public static Object INTERNAL_ANY = null; // platforms supporting an "any"
|
||||||
// item should fill it here
|
// item should fill it here
|
||||||
|
|
||||||
private IngredientAny() {}
|
private IngredientAny() {
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getMark() {
|
public String getMark() {
|
||||||
@@ -47,12 +48,12 @@ public class IngredientAny implements IIngredient {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IIngredient transform(IItemTransformer transformer) {
|
public IIngredient transform(IItemTransformer transformer) {
|
||||||
return new IngredientAnyAdvanced(null, ArrayUtil.EMPTY_CONDITIONS, new IItemTransformer[] { transformer });
|
return new IngredientAnyAdvanced(null, ArrayUtil.EMPTY_CONDITIONS, new IItemTransformer[]{transformer});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IIngredient only(IItemCondition condition) {
|
public IIngredient only(IItemCondition condition) {
|
||||||
return new IngredientAnyAdvanced(null, new IItemCondition[] { condition }, ArrayUtil.EMPTY_TRANSFORMERS);
|
return new IngredientAnyAdvanced(null, new IItemCondition[]{condition}, ArrayUtil.EMPTY_TRANSFORMERS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -75,6 +76,7 @@ public class IngredientAny implements IIngredient {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matches(ILiquidStack liquid) {
|
public boolean matches(ILiquidStack liquid) {
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -1,13 +1,14 @@
|
|||||||
package minetweaker.api.item;
|
package minetweaker.api.item;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import minetweaker.api.liquid.ILiquidStack;
|
import minetweaker.api.liquid.ILiquidStack;
|
||||||
import minetweaker.api.player.IPlayer;
|
import minetweaker.api.player.IPlayer;
|
||||||
import minetweaker.util.ArrayUtil;
|
import minetweaker.util.ArrayUtil;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents the wildcard ingredient, with conditions and/or transformers applied to it.
|
* Represents the wildcard ingredient, with conditions and/or transformers
|
||||||
|
* applied to it.
|
||||||
*
|
*
|
||||||
* @author Stan Hebben
|
* @author Stan Hebben
|
||||||
*/
|
*/
|
||||||
@@ -70,8 +71,9 @@ public class IngredientAnyAdvanced implements IIngredient {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matches(IItemStack item) {
|
public boolean matches(IItemStack item) {
|
||||||
for (IItemCondition condition : conditions) {
|
for(IItemCondition condition : conditions) {
|
||||||
if (!condition.matches(item)) return false;
|
if(!condition.matches(item))
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -79,8 +81,9 @@ public class IngredientAnyAdvanced implements IIngredient {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matchesExact(IItemStack item) {
|
public boolean matchesExact(IItemStack item) {
|
||||||
for (IItemCondition condition : conditions) {
|
for(IItemCondition condition : conditions) {
|
||||||
if (!condition.matches(item)) return false;
|
if(!condition.matches(item))
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -95,8 +98,9 @@ public class IngredientAnyAdvanced implements IIngredient {
|
|||||||
@Override
|
@Override
|
||||||
public boolean contains(IIngredient ingredient) {
|
public boolean contains(IIngredient ingredient) {
|
||||||
List<IItemStack> iitems = ingredient.getItems();
|
List<IItemStack> iitems = ingredient.getItems();
|
||||||
for (IItemStack iitem : iitems) {
|
for(IItemStack iitem : iitems) {
|
||||||
if (!matches(iitem)) return false;
|
if(!matches(iitem))
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -104,7 +108,7 @@ public class IngredientAnyAdvanced implements IIngredient {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IItemStack applyTransform(IItemStack item, IPlayer byPlayer) {
|
public IItemStack applyTransform(IItemStack item, IPlayer byPlayer) {
|
||||||
for (IItemTransformer transform : transformers) {
|
for(IItemTransformer transform : transformers) {
|
||||||
item = transform.transform(item, byPlayer);
|
item = transform.transform(item, byPlayer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,8 +4,9 @@ import minetweaker.api.data.IData;
|
|||||||
import stanhebben.zenscript.annotations.*;
|
import stanhebben.zenscript.annotations.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Conditions can be used to set requirements for matching items. They can be used to require specific NBT tags or
|
* Conditions can be used to set requirements for matching items. They can be
|
||||||
* damage values, requiring changed items or as complement to damage-consuming or stack-consuming recipes.
|
* used to require specific NBT tags or damage values, requiring changed items
|
||||||
|
* or as complement to damage-consuming or stack-consuming recipes.
|
||||||
*
|
*
|
||||||
* @author Stan Hebben
|
* @author Stan Hebben
|
||||||
*/
|
*/
|
||||||
@@ -22,7 +23,6 @@ public class IngredientCondition {
|
|||||||
@ZenMethod
|
@ZenMethod
|
||||||
public static IIngredient onlyDamaged(IIngredient ingredient) {
|
public static IIngredient onlyDamaged(IIngredient ingredient) {
|
||||||
return ingredient.only(new IItemCondition() {
|
return ingredient.only(new IItemCondition() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matches(IItemStack stack) {
|
public boolean matches(IItemStack stack) {
|
||||||
return stack.getDamage() > 0;
|
return stack.getDamage() > 0;
|
||||||
@@ -41,7 +41,6 @@ public class IngredientCondition {
|
|||||||
@ZenMethod
|
@ZenMethod
|
||||||
public static IIngredient onlyDamageAtLeast(IIngredient ingredient, final int minDamage) {
|
public static IIngredient onlyDamageAtLeast(IIngredient ingredient, final int minDamage) {
|
||||||
return ingredient.only(new IItemCondition() {
|
return ingredient.only(new IItemCondition() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matches(IItemStack stack) {
|
public boolean matches(IItemStack stack) {
|
||||||
return stack.getDamage() >= minDamage;
|
return stack.getDamage() >= minDamage;
|
||||||
@@ -50,7 +49,8 @@ public class IngredientCondition {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Requires the item to be damaged with at most a specified amount. An undamaged item is accepted.
|
* Requires the item to be damaged with at most a specified amount. An
|
||||||
|
* undamaged item is accepted.
|
||||||
*
|
*
|
||||||
* @param ingredient target value
|
* @param ingredient target value
|
||||||
* @param maxDamage maximum damage
|
* @param maxDamage maximum damage
|
||||||
@@ -60,7 +60,6 @@ public class IngredientCondition {
|
|||||||
@ZenMethod
|
@ZenMethod
|
||||||
public static IIngredient onlyDamageAtMost(IIngredient ingredient, final int maxDamage) {
|
public static IIngredient onlyDamageAtMost(IIngredient ingredient, final int maxDamage) {
|
||||||
return ingredient.only(new IItemCondition() {
|
return ingredient.only(new IItemCondition() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matches(IItemStack stack) {
|
public boolean matches(IItemStack stack) {
|
||||||
return stack.getDamage() <= maxDamage;
|
return stack.getDamage() <= maxDamage;
|
||||||
@@ -80,7 +79,6 @@ public class IngredientCondition {
|
|||||||
@ZenMethod
|
@ZenMethod
|
||||||
public static IIngredient onlyDamageBetween(IIngredient ingredient, final int minDamage, final int maxDamage) {
|
public static IIngredient onlyDamageBetween(IIngredient ingredient, final int minDamage, final int maxDamage) {
|
||||||
return ingredient.only(new IItemCondition() {
|
return ingredient.only(new IItemCondition() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matches(IItemStack stack) {
|
public boolean matches(IItemStack stack) {
|
||||||
return stack.getDamage() >= minDamage && stack.getDamage() <= maxDamage;
|
return stack.getDamage() >= minDamage && stack.getDamage() <= maxDamage;
|
||||||
@@ -89,8 +87,8 @@ public class IngredientCondition {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Requires the item to contain at least the given tags. It is OK for the item to contain more data, as remaining
|
* Requires the item to contain at least the given tags. It is OK for the
|
||||||
* data is ignored.
|
* item to contain more data, as remaining data is ignored.
|
||||||
*
|
*
|
||||||
* @param ingredient target value
|
* @param ingredient target value
|
||||||
* @param data required data
|
* @param data required data
|
||||||
@@ -100,7 +98,6 @@ public class IngredientCondition {
|
|||||||
@ZenMethod
|
@ZenMethod
|
||||||
public static IIngredient onlyWithTag(IIngredient ingredient, final IData data) {
|
public static IIngredient onlyWithTag(IIngredient ingredient, final IData data) {
|
||||||
return ingredient.only(new IItemCondition() {
|
return ingredient.only(new IItemCondition() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matches(IItemStack stack) {
|
public boolean matches(IItemStack stack) {
|
||||||
return stack.getTag() != null && stack.getTag().contains(data);
|
return stack.getTag() != null && stack.getTag().contains(data);
|
||||||
@@ -109,8 +106,8 @@ public class IngredientCondition {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Requires the input stack to contain at least the given number of items. Used in combination with stack consuming
|
* Requires the input stack to contain at least the given number of items.
|
||||||
* recipes.
|
* Used in combination with stack consuming recipes.
|
||||||
*
|
*
|
||||||
* @param ingredient target value
|
* @param ingredient target value
|
||||||
* @param amount required stack size
|
* @param amount required stack size
|
||||||
@@ -120,7 +117,6 @@ public class IngredientCondition {
|
|||||||
@ZenMethod
|
@ZenMethod
|
||||||
public static IIngredient onlyStack(IIngredient ingredient, final int amount) {
|
public static IIngredient onlyStack(IIngredient ingredient, final int amount) {
|
||||||
return ingredient.only(new IItemCondition() {
|
return ingredient.only(new IItemCondition() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matches(IItemStack stack) {
|
public boolean matches(IItemStack stack) {
|
||||||
return stack.getAmount() >= amount;
|
return stack.getAmount() >= amount;
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
package minetweaker.api.item;
|
package minetweaker.api.item;
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
import minetweaker.api.liquid.ILiquidStack;
|
import minetweaker.api.liquid.ILiquidStack;
|
||||||
import minetweaker.api.player.IPlayer;
|
import minetweaker.api.player.IPlayer;
|
||||||
import minetweaker.util.ArrayUtil;
|
import minetweaker.util.ArrayUtil;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Contains an item stack with modifiers applied to it.
|
* Contains an item stack with modifiers applied to it.
|
||||||
*
|
*
|
||||||
@@ -75,10 +75,12 @@ public class IngredientItem implements IIngredient {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matches(IItemStack item) {
|
public boolean matches(IItemStack item) {
|
||||||
if (!this.item.matches(item)) return false;
|
if(!this.item.matches(item))
|
||||||
|
return false;
|
||||||
|
|
||||||
for (IItemCondition condition : conditions) {
|
for(IItemCondition condition : conditions) {
|
||||||
if (!condition.matches(item)) return false;
|
if(!condition.matches(item))
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -86,10 +88,12 @@ public class IngredientItem implements IIngredient {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean matchesExact(IItemStack item) {
|
public boolean matchesExact(IItemStack item) {
|
||||||
if (!this.item.matchesExact(item)) return false;
|
if(!this.item.matchesExact(item))
|
||||||
|
return false;
|
||||||
|
|
||||||
for (IItemCondition condition : conditions) {
|
for(IItemCondition condition : conditions) {
|
||||||
if (!condition.matches(item)) return false;
|
if(!condition.matches(item))
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -103,8 +107,9 @@ public class IngredientItem implements IIngredient {
|
|||||||
@Override
|
@Override
|
||||||
public boolean contains(IIngredient ingredient) {
|
public boolean contains(IIngredient ingredient) {
|
||||||
List<IItemStack> iitems = ingredient.getItems();
|
List<IItemStack> iitems = ingredient.getItems();
|
||||||
for (IItemStack iitem : iitems) {
|
for(IItemStack iitem : iitems) {
|
||||||
if (!matches(iitem)) return false;
|
if(!matches(iitem))
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -112,7 +117,7 @@ public class IngredientItem implements IIngredient {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IItemStack applyTransform(IItemStack item, IPlayer byPlayer) {
|
public IItemStack applyTransform(IItemStack item, IPlayer byPlayer) {
|
||||||
for (IItemTransformer transform : transformers) {
|
for(IItemTransformer transform : transformers) {
|
||||||
item = transform.transform(item, byPlayer);
|
item = transform.transform(item, byPlayer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loaded 100 of 269 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user